1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[304],{38634:function(e,t,r){r.d(t,{HO:function(){return d},hR:function(){return l},i8:function(){return n},m$:function(){return s},oA:function(){return o},ry:function(){return i}});var a=r(19609);let l={validate:"/api/v1/voice/validate",validateInfo:"/api/v1/voice/validate-info",result:"/api/v1/voice/record-info",generate:"/api/v1/voice/generate",regenerate:"/api/v1/voice/regenerate"},i=e=>{let{endpoint:t,data:r}=e;return(0,a.Z)({url:t||l.validate,method:"post",data:r})},s=e=>{let{endpoint:t,taskId:r}=e;return(0,a.Z)({url:t||l.validateInfo,method:"get",params:{taskId:r}})},n=e=>{let{endpoint:t,taskId:r}=e;return(0,a.Z)({url:t||l.result,method:"get",params:{taskId:r}})},o=e=>{let{endpoint:t,data:r}=e;return(0,a.Z)({url:t||l.generate,method:"post",data:r})},d=e=>{let{endpoint:t,data:r}=e;return(0,a.Z)({url:t||l.regenerate,method:"post",data:r})}},51763:function(e,t,r){var a=r(39696),l=r(58302),i=r(82135),s=r(27220),n=r(18492),o=r(68237),d=r(56156);let c=(0,i.Pi)(e=>{let{loginSuccessCallback:t}=e;(0,o.useRouter)();let{userStore:r}=(0,s.o)(),{t:i}=(0,d.Z)("common");return(0,l._7)({onSuccess:e=>{let a=n.ZP.loading(i("googleOneTap.loading"));r.sendGoogleLogin(e.credential,()=>{null==t||t(),n.ZP.success(i("googleOneTap.success"))}).finally(()=>{n.ZP.dismiss(a)})},onError:e=>{n.ZP.error(i("googleOneTap.error")),console.log("Google One Tap Login Failed",e)}}),(0,a.jsx)(a.Fragment,{})});t.Z=c},93893:function(e,t,r){r.d(t,{Z:function(){return eC}});var a=r(39696),l=r(90170),i=r(4993),s=r(73868),n=r(94204),o=r(82045),d=r(32324),c=r(18492),u=r(27220),m=r(82135),x=r(2365),p=r(29445),g=r(25043),h=r.n(g),f=r(83460);let b=h()(()=>Promise.resolve().then(r.bind(r,99245)),{loadableGenerated:{webpack:()=>[99245]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"flex h-64 items-center justify-center rounded-lg border border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700",children:(0,a.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading editor..."})})});function v(e){let{value:t={},onChange:r,formContent:i=[],extraSchemaProperties:s={},className:n="",height:o=300}=e,[d,u]=(0,l.useState)(""),[m,x]=(0,l.useState)([]),[g,h]=(0,l.useState)(!1),v=(0,l.useRef)(null),y=(0,l.useRef)(null),j=(0,l.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},a=[];return e.forEach(e=>{var t,l,i,s,n,o;let d=e.props,c=d.parameterKey;switch("PlaygroundFrameUploader"!==e.type&&d.required&&a.push(c),e.type){case"PlaygroundFrameUploader":{let e=(0,f.RV)(d),{primaryKey:i,secondaryKey:s}=(0,f.LB)(d);if("single"===d.fieldMode)r[i]={type:"array",description:d.actionDescription||"Frame image URLs",minItems:(null===(t=e[0])||void 0===t?void 0:t.required)?1:void 0,maxItems:2,items:{type:"string",format:"uri"}},(null===(l=e[0])||void 0===l?void 0:l.required)&&a.push(i);else{let t=e[0],l=e[1];i&&(r[i]={type:"string",format:"uri",description:(null==t?void 0:t.label)||"Start frame image URL"}),s&&(r[s]={type:"string",format:"uri",description:(null==l?void 0:l.label)||"End frame image URL"}),(null==t?void 0:t.required)&&i&&a.push(i),(null==l?void 0:l.required)&&s&&a.push(s)}("single"===d.fieldMode?[i].filter(Boolean):[i,s].filter(Boolean)).forEach(e=>{let t=r[e];t&&Object.keys(t).forEach(e=>{void 0===t[e]&&delete t[e]})});break}case"PlaygroundInput":case"PlaygroundTextarea":r[c]={type:"string",description:d.note||d.placeholder||"",maxLength:d.maxLength};break;case"PlaygroundInputNumber":case"PlaygroundSlider":r[c]={type:"number",description:d.note||"",minimum:d.min,maximum:d.max};break;case"PlaygroundSwitch":r[c]={type:"boolean",description:d.note||""};break;case"PlaygroundSelect":r[c]={type:"string",enum:(null===(i=d.selectOption)||void 0===i?void 0:i.map(e=>e.value))||[],description:d.note||""};break;case"PlaygroundRadio":r[c]={type:(null===(n=d.radioOptions)||void 0===n?void 0:null===(s=n[0])||void 0===s?void 0:s.value)!==void 0?typeof d.radioOptions[0].value:"string",enum:(null===(o=d.radioOptions)||void 0===o?void 0:o.map(e=>e.value))||[],description:d.note||""};break;case"PlaygroundFileUpload":r[c]={type:e.props.multiple?"array":"string",format:"uri",description:d.note||"File URL"};break;case"PlaygroundArrayForm":{let e;let t=d.itemType||"input";if("object"===t){let t={};
1(d.objectSchema||[]).forEach(e=>{t[e.key]={type:"number"===e.valueType?"number":"boolean"===e.valueType?"boolean":"string"}}),e={type:"object",properties:t}}else e={type:"number"===t?"number":"switch"===t?"boolean":"string"};r[c]={type:"array",description:d.note||"",minItems:d.minLength||void 0,maxItems:d.maxLength&&d.maxLength>0?d.maxLength:void 0,items:e};break}default:r[c]={type:"string",description:d.note||""}}"PlaygroundFrameUploader"!==e.type&&r[c]&&Object.keys(r[c]).forEach(e=>{void 0===r[c][e]&&delete r[c][e]})}),Object.entries(t).forEach(e=>{let[t,a]=e;r[t]=a}),{type:"object",properties:r,required:a,additionalProperties:!1}})(i,s),[i,s]);(0,l.useEffect)(()=>{try{let e=JSON.stringify(t,null,2);u(e),v.current&&v.current.getValue()!==e&&v.current.setValue(e),x([])}catch(e){u("{}"),v.current&&v.current.setValue("{}"),x([])}},[t]),(0,l.useEffect)(()=>{let e=()=>{h(document.documentElement.classList.contains("dark"))};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);let k=(0,l.useCallback)((e,t)=>{v.current=e,y.current=t,t.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:[{uri:"http://myserver/foo-schema.json",fileMatch:["*"],schema:j}]}),t.editor.defineTheme("custom-dark",{base:"vs-dark",inherit:!0,rules:[{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"number.json",foreground:"B5CEA8"},{token:"keyword.json",foreground:"569CD6"}],colors:{"editor.background":"#374151","editor.foreground":"#F3F4F6","editorLineNumber.foreground":"#6B7280","editor.selectionBackground":"#4B5563","editor.inactiveSelectionBackground":"#374151"}}),t.editor.defineTheme("custom-light",{base:"vs",inherit:!0,rules:[{token:"string.key.json",foreground:"0451A5"},{token:"string.value.json",foreground:"A31515"},{token:"number.json",foreground:"098658"},{token:"keyword.json",foreground:"0000FF"}],colors:{"editor.background":"#F9FAFB","editor.foreground":"#1F2937","editorLineNumber.foreground":"#9CA3AF","editor.selectionBackground":"#E5E7EB","editor.inactiveSelectionBackground":"#F3F4F6"}}),t.editor.setTheme(g?"custom-dark":"custom-light")},[j,g]);(0,l.useEffect)(()=>{y.current&&y.current.editor.setTheme(g?"custom-dark":"custom-light")},[g,y.current]);let w=(0,l.useCallback)(e=>{u(e);try{let t=JSON.parse(e),a=function(e,t){let r=[];return e&&"object"==typeof e?(t.required&&t.required.forEach(t=>{t in e||r.push({line:1,column:1,message:"Missing required field: ".concat(t),severity:"error"})}),!1===t.additionalProperties&&Object.keys(e).forEach(e=>{t.properties[e]||r.push({line:1,column:1,message:"Unknown field: ".concat(e,". Expected fields: ").concat(Object.keys(t.properties).join(", ")),severity:"warning"})}),Object.keys(e).forEach(a=>{let l=e[a],i=t.properties[a];if(!i)return;let s=Array.isArray(l)?"array":typeof l;i.type&&s!==i.type&&("number"===i.type&&"number"===s||r.push({line:1,column:1,message:'Field "'.concat(a,'" should be ').concat(i.type,", but got ").concat(s),severity:"error"})),i.enum&&!i.enum.includes(l)&&r.push({line:1,column:1,message:'Field "'.concat(a,'" should be one of: ').concat(i.enum.join(", ")),severity:"error"}),"number"===i.type&&"number"==typeof l&&(void 0!==i.minimum&&l<i.minimum&&r.push({line:1,column:1,message:'Field "'.concat(a,'" should be >= ').concat(i.minimum),severity:"error"}),void 0!==i.maximum&&l>i.maximum&&r.push({line:1,column:1,message:'Field "'.concat(a,'" should be <= ').concat(i.maximum),severity:"error"})),"string"===i.type&&"string"==typeof l&&i.maxLength&&l.length>i.maxLength&&r.push({line:1,column:1,message:'Field "'.concat(a,'" exceeds maximum length of ').concat(i.maxLength),severity:"error"})})):r.push({line:1,column:1,message:"Root must be an object",severity:"error"}),r}(t,j);x(a),0===a.filter(e=>"error"===e.severity).length&&(null==r||r(t))}catch(e){x([{line:1,column:1,message:"JSON Syntax Error: ".concat(e.message),severity:"error"}])}},[j,r]),N=(0,l.useCallback)(()=>{try{let e=(0,p.Fx)(i),t=JSON.stringify(e,null,2);u(t),v.current&&v.current.setValue(t),x([]),null==r||r(e),c.Am.success("JSON reset to initial value")}catch(e){u("{}"),v.current&&v.current.setValue("{}"),x([]),null==r||r({}),c.Am.error("Failed to reset, set to empty object")}},[i,r]);return(0,a.jsxs)("div",{className:"space-y-2 ".concat(n),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"JSON Editor"}),(0,a.jsx)("div",{className:"flex gap-2",children:(0,a.jsx)("button",{type:"button",onClick:N,className:"rounded px-2 py-1 text-xs text-gray-600 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-700",children:"Reset"})})]}),(0,a.jsx)("div",{className:"border border-gray-300 dark:border-gray-600",children:(0,a.jsx)(b,{height:o,language:"json",value:d,onChange:w,onMount:k,options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,tabSize:2,wordWrap:"on",lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},autoIndent:"full",formatOnPaste:!0,formatOnType:!0,suggest:{showKeywords:!0,showSnippets:!0},quickSuggestions:{other:!0,comments:!1,strings:!0},padding:{top:8,bottom:8},roundedSelection:!1,scrollbar:{vertical:"auto",horizontal:"auto"}}})}),m.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:m.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-start gap-2 rounded-md p-2 text-sm ".concat("error"===e.severity?"bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-400":"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/20 dark:text-yellow-400"),children:[(0,a.jsx)("span",{className:"mt-0.5 flex-shrink-0",children:"error"===e.severity?"â":"â ï¸"}),(0,a.jsx)("span",{children:e.message})]},t))}),i.length>0&&(0,a.jsxs)("details",{className:"text-xs text-gray-500 dark:text-gray-400",children:[(0,a.jsxs)("summary",{className:"cursor-pointer hover:text-gray-700 dark:hover:text-gray-300",children:["View expected fields (",Object.keys(j.properties).length,")"]}),(0,a.jsx)("div",{className:"mt-2 space-y-1 pl-4",children:Object.entries(j.properties).map(e=>{var t;let[r,l]=e;return(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("span",{className:"font-mono text-blue-600 dar
1k:text-blue-400",children:[r,":"]}),(0,a.jsxs)("span",{className:"text-gray-600 dark:text-gray-400",children:[l.type,l.enum&&" (".concat(l.enum.join(" | "),")"),(null===(t=j.required)||void 0===t?void 0:t.includes(r))&&(0,a.jsx)("span",{className:"ml-1 text-red-500",children:"*"})]})]},r)})})]})]})}var y=r(2104),j=r(84140);let k=[{Scene:"A cute fluffy orange-and-white kitten wearing orange headphones, sitting at a cozy indoor table with a small slice of cake on a plate, a toy fish and a silver microphone nearby, warm soft lighting, cinematic close-up, shallow depth of field, gentle ASMR atmosphere.",duration:7.5},{Scene:"The same cute fluffy orange-and-white kitten wearing orange headphones, in the same cozy indoor ASMR setup with the toy fish and microphone, the cake now finished, the kitten gently licks its lips with a satisfied smile, warm ambient lighting, cinematic close-up, shallow depth of field, calm and content mood.",duration:7.5}];function w(e){let{duration:t,handleFieldChange:r}=e,[i,s]=(0,l.useState)(k.map((e,t)=>({id:Date.now()+t,Scene:e.Scene,duration:e.duration}))),n=i.reduce((e,t)=>e+(parseFloat(t.duration)||0),0),o=n>t,u=t-n;(0,l.useEffect)(()=>{r("shots",i.map(e=>{let{Scene:t,duration:r}=e;return{Scene:t,duration:parseFloat(parseFloat(r).toFixed(2))}}))},[i]);let m=e=>{if(1===i.length){c.Am.error("At least one scene is required");return}s(i.filter(t=>t.id!==e))},x=(e,t)=>{s(i.map(r=>r.id===e?{...r,Scene:t}:r))},p=(e,t)=>{if(!/^\d*\.?\d*$/.test(t))return;if(""===t||"."===t){s(i.map(r=>r.id===e?{...r,duration:t}:r));return}let r=parseFloat(t);isNaN(r)||(r>15?s(i.map(t=>t.id===e?{...t,duration:"15"}:t)):s(i.map(r=>r.id===e?{...r,duration:t}:r)))},g=(e,t)=>{let r=parseFloat(t);isNaN(r)||r<.1?s(i.map(t=>t.id===e?{...t,duration:"0.1"}:t)):r>15?s(i.map(t=>t.id===e?{...t,duration:"15"}:t)):s(i.map(t=>t.id===e?{...t,duration:r.toString()}:t))};return(0,l.useEffect)(()=>{1===i.length&&s([{id:Date.now(),Scene:"",duration:t>15?15:t}])},[t]),(0,a.jsxs)("div",{className:"space-y-3",id:"prompt-component",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["shots",(0,a.jsxs)("span",{className:"ml-2 text-xs text-gray-500 dark:text-gray-400",children:["(Total Duration: ",t,"s)"]})]}),(0,a.jsxs)("span",{className:"text-sm font-medium ".concat(u<0?"text-red-500 dark:text-red-400":"text-gray-600 dark:text-gray-300"),children:["Remaining: ",u.toFixed(2),"s"]})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[i.map((e,t)=>(0,a.jsxs)("div",{id:e.id,className:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800/80",children:[(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsxs)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["Scene ",t+1]})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(y.Y,{placeholder:"Describe this scene... who, where, what happens?",value:e.Scene,onChange:t=>x(e.id,t.target.value),minRows:2,size:"sm",classNames:{base:"w-full",input:"text-sm text-gray-700 dark:text-gray-200 placeholder:text-gray-400 dark:placeholder:text-gray-500",inputWrapper:"bg-white dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 shadow-none"}}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"relative w-24",children:[(0,a.jsx)("input",{type:"text",value:String(e.duration),onChange:t=>p(e.id,t.target.value),onBlur:t=>g(e.id,t.target.value),placeholder:"0.0",className:"h-8 w-full rounded-lg border px-3 pr-6 text-sm shadow-none outline-none transition-colors placeholder:text-gray-500 focus:border-gray-600 dark:border-gray-600 dark:bg-gray-900/50 dark:text-gray-200"}),(0,a.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs dark:text-gray-400",children:"s"})]}),i.length>1&&(0,a.jsx)(d.A,{isIconOnly:!0,size:"sm",variant:"light",color:"danger",onPress:()=>m(e.id),className:"min-w-unit-8 h-8 w-8",children:(0,a.jsx)(j.JO,{icon:"lucide:trash-2",className:"h-4 w-4"})})]})]})]},e.id)),(0,a.jsxs)("button",{onClick:()=>{let e=Date.now();if(u)s([...i,{id:e,Scene:"",duration:u<15?u:15}]);else{let t=i[i.length-1],r=parseFloat(t.duration)||0,a=r/2,l=Math.ceil(100*a)/100>.1?Math.ceil(100*a)/100:.1;s([...i.slice(0,-1),{...t,duration:l.toFixed(2)},{id:e,Scene:"",duration:(Math.floor((r-l)*100)/100>.1?Math.floor((r-l)*100)/100:.1).toFixed(2)}])}},className:"w-full rounded-lg border border-dashed border-gray-300 bg-gray-50 p-4 text-left transition-colors hover:border-gray-400 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-800/80 dark:hover:border-gray-500 dark:hover:bg-gray-700/80",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsxs)("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:["Scene ",i.length+1]})}),(0,a.jsx)("div",{className:"text-sm text-gray-400 dark:text-gray-500",children:"Describe this scene... who, where, what happens?"})]})]}),o&&(0,a.jsxs)("div",{className:"rounded-lg bg-red-50 p-3 text-sm text-red-600 dark:bg-red-900/20 dark:text-red-400",children:[(0,a.jsx)(j.JO,{icon:"lucide:alert-circle",className:"mr-1 inline h-4 w-4"}),"Total scene duration exceeds maximum limit, please adjust each scene duration"]}),!o&&u>0&&(0,a.jsxs)("div",{className:"rounded-lg bg-amber-50 p-3 text-sm text-amber-600 dar
1k:bg-amber-900/20 dark:text-amber-400",children:[(0,a.jsx)(j.JO,{icon:"lucide:info",className:"mr-1 inline h-4 w-4"}),"Please allocate all remaining duration (",u.toFixed(2),"s) to scenes before generating"]})]})}var N=r(53070),A=r(44965);let S=async(e,t,r)=>{try{let a=document.createElement("video");a.muted=!0,a.playsInline=!0;let l="";if(e instanceof File||e instanceof Blob)l=URL.createObjectURL(e),a.src=l;else if("string"==typeof e)a.src=e;else throw Error("Invalid input type");await new Promise((e,t)=>{a.onloadedmetadata=e,a.onerror=()=>t(Error("Video loading failed"))});let i=a.duration;if(t>=i||r<=t)return l&&URL.revokeObjectURL(l),e;let s=a.captureStream(),n=[],o="";for(let e of["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"])if(MediaRecorder.isTypeSupported(e)){o=e;break}if(!o)return l&&URL.revokeObjectURL(l),e;let d=new MediaRecorder(s,{mimeType:o,videoBitsPerSecond:25e5});d.ondataavailable=e=>{e.data&&e.data.size>0&&n.push(e.data)},d.onstop=()=>{if(n.length>0){let e=new Blob(n,{type:o});l&&URL.revokeObjectURL(l),resolve(e)}else l&&URL.revokeObjectURL(l),resolve(e)},d.onerror=()=>{l&&URL.revokeObjectURL(l),resolve(e)},d.start(),a.currentTime=t,await a.play();let c=()=>{a.currentTime>=r&&(a.removeEventListener("timeupdate",c),a.pause(),d.stop())};return a.addEventListener("timeupdate",c),new Promise(t=>{d.onstop=()=>{if(n.length>0){let e=new Blob(n,{type:o});l&&URL.revokeObjectURL(l),t(e)}else l&&URL.revokeObjectURL(l),t(e)}})}catch(t){return console.warn("Video trimming failed, returning original video:",t),e}},C=async e=>{if(!e||0===e.length)throw Error("Please upload at least one video");for(let t=0;t<e.length;t++){let r=e[t];if(!r||"object"!=typeof r)throw Error("Video ".concat(t+1," data is invalid, please re-upload"))}let t=e.map(async(e,t)=>{let r=e.file||e.url;if(!r)throw Error("Video ".concat(t+1," has no valid file or URL, please re-upload"));if(!(e.startTime>0||e.endTime<(e.duration||1/0))){if(e.file&&e.file instanceof File)return await (0,A._R)(e.file,"kieai/market");throw Error("Video ".concat(t+1," has no valid file"))}try{let t=await S(r,e.startTime,e.endTime);if(!t||0===t.size)throw Error("Trim result is invalid");let a=new File([t],"trimmed-video-".concat(Date.now(),".mp4"),{type:"video/mp4",lastModified:Date.now()});return await (0,A._R)(a,"kieai/market")}catch(e){throw console.error("Video ".concat(t+1," frontend trimming failed:"),e),Error("Video ".concat(t+1," trimming failed: ").concat(e.message,". Please check browser compatibility or video format."))}});return await Promise.all(t)};function M(e){let{video:t,onUpdate:r,canvasRef:i,index:s,onDelete:n}=e,o=(0,l.useRef)(null),d=(0,l.useRef)(null),[c,u]=(0,l.useState)(!1),[m,x]=(0,l.useState)(!1),[p,g]=(0,l.useState)(!1),[h,f]=(0,l.useState)(0),[b,v]=(0,l.useState)(0),[y,j]=(0,l.useState)([]),k=(0,l.useCallback)(e=>b?e/b*100:0,[b]),w=(0,l.useCallback)(e=>b?e/100*b:0,[b]);(0,l.useEffect)(()=>{t.url&&(async()=>{let e=document.createElement("video");e.src=t.url,e.muted=!0,e.playsInline=!0,e.preload="metadata";try{await new Promise((t,r)=>{let a=setTimeout(()=>{r(Error("Video metadata loading timeout"))},1e4);e.addEventListener("loadedmetadata",()=>{clearTimeout(a),t()},{once:!0}),e.addEventListener("error",()=>{clearTimeout(a),r(Error("Video loading failed"))},{once:!0})});let t=e.duration;v(t);let r=Math.min(Math.ceil(10*t),100),a=t/r,l=[],s=r=>new Promise(l=>{let s=Math.min(r*a,t-.01);e.currentTime=s;let n=()=>{let t=i.current||document.createElement("canvas");t.width=e.videoWidth||160,t.height=e.videoHeight||90,t.getContext("2d").drawImage(e,0,0,t.width,t.height);let a=t.toDataURL("image/jpeg",.7);l({index:r,thumbnail:a,time:s}),e.removeEventListener("seeked",n)};e.addEventListener("seeked",n,{once:!0})});for(let e=0;e<r;e++){let t=await s(e);l.push(t)}l.sort((e,t)=>e.index-t.index);let n=l.map(e=>e.thumbnail);j(n)}catch(e){}finally{e.src=""}})()},[t.url,i]);let A=(e,t)=>{e.preventDefault(),"start"===t?u(!0):"end"===t?x(!0):g(!0),f(e.clientX)};return(0,l.useEffect)(()=>{let e=e=>{if(!c&&!m&&!p||!d.current||!b)return;let a=d.current.getBoundingClientRect(),l=a.width,i=w(Math.max(0,Math.min(100,(e.clientX-a.left)/l*100)));if(c){let e=Math.max(Math.max(0,t.endTime-4),Math.min(Math.max(0,t.endTime-1),i));r({...t,startTime:e}),o.current&&(o.current.currentTime=e)}else if(m){let e=Math.max(Math.min(b,t.startTime+1),Math.min(Math.min(b,t.startTime+4),i));r({...t,endTime:e}),o.current&&o.current.currentTime>
1e&&(o.current.currentTime=t.startTime)}else if(p){let a=w((e.clientX-h)/l*100),i=Math.max(1,Math.min(t.endTime-t.startTime,4)),s=Math.max(0,Math.min(t.startTime+a,b-i)),n=Math.min(b,s+i);if(n-s>=1&&n-s<=4&&(r({...t,startTime:s,endTime:n}),o.current)){let e=s+(o.current.currentTime-t.startTime);e>=s&&e<=n?o.current.currentTime=e:o.current.currentTime=s}f(e.clientX)}},a=()=>{u(!1),x(!1),g(!1)};if(c||m||p)return document.addEventListener("mousemove",e),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",a)}},[c,m,p,h,t,r,w,b]),(0,l.useEffect)(()=>{if(o.current&&t.url&&b>0){let e=o.current,r=()=>{let r=e.currentTime;r>=t.endTime?e.currentTime=t.startTime:r<t.startTime&&(e.currentTime=t.startTime)},a=()=>{let r=e.currentTime;(r<t.startTime||r>t.endTime)&&(e.currentTime=t.startTime)};return e.addEventListener("timeupdate",r),e.addEventListener("seeked",a),e.currentTime=t.startTime,()=>{e.removeEventListener("timeupdate",r),e.removeEventListener("seeked",a)}}},[t.url,b,t.startTime,t.endTime]),(0,a.jsxs)("div",{className:"mb-6 rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Video"}),(0,a.jsx)("button",{onClick:n,className:"flex h-6 w-6 items-center justify-center rounded-full bg-gray-200 text-gray-700 transition hover:bg-red-500 dark:bg-gray-600 dark:text-gray-200 dark:hover:bg-red-600",children:(0,a.jsx)(N.Z,{className:"h-4 w-4"})})]}),(0,a.jsx)("div",{className:"mb-4 flex justify-center",children:t.url&&(0,a.jsx)("video",{ref:o,src:t.url,className:"max-h-[200px] w-full rounded-lg",muted:!0,playsInline:!0,autoPlay:!0,loop:!0})}),(0,a.jsxs)("div",{className:"mb-2",children:[(0,a.jsxs)("div",{ref:d,className:"relative h-16 w-full overflow-hidden rounded-lg bg-gray-200 p-2 dark:bg-gray-700",children:[(()=>{let e=(()=>{if(0===y.length)return[];if(y.length<=15)return y;let e=y.length/15,t=[];for(let r=0;r<15;r++){let a=Math.floor(r*e);t.push(y[a])}return t})();return(0,a.jsx)("div",{className:"flex h-full gap-0.5",children:e.length>0?e.map((e,t)=>(0,a.jsx)("div",{className:"h-full flex-1 opacity-100",style:{backgroundImage:e?"url(".concat(e,")"):"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:e?"transparent":"#374151"}},t)):Array.from({length:15}).map((e,t)=>(0,a.jsx)("div",{className:"h-full flex-1 rounded bg-gray-300 dark:bg-gray-600"},t))})})(),b>0&&t.startTime>0&&(0,a.jsx)("div",{className:"pointer-events-none absolute bottom-0 top-0 z-10 bg-gray-300/40 dark:bg-gray-600/50",style:{left:"0%",width:"".concat(k(t.startTime),"%")}}),b>0&&t.endTime<b&&(0,a.jsx)("div",{className:"pointer-events-none absolute bottom-0 top-0 z-10 bg-gray-300/40 dark:bg-gray-600/50",style:{left:"".concat(k(t.endTime),"%"),width:"".concat(k(b-t.endTime),"%")}}),b>0&&y.length>0&&(0,a.jsx)("div",{className:"z-15 pointer-events-none absolute bottom-1 top-1 rounded-md border border-blue-400",style:{left:"".concat(k(t.startTime),"%"),width:"".concat(k(t.endTime-t.startTime),"%")}}),b>0&&(0,a.jsx)("div",{className:"absolute bottom-1/4 top-1/4 z-20 w-1 cursor-ew-resize bg-blue-400 dark:bg-gray-200",style:{left:"".concat(k(t.startTime),"%"),transform:"translateX(-50%)"},onMouseDown:e=>A(e,"start")}),b>0&&(0,a.jsx)("div",{className:"absolute bottom-1/4 top-1/4 z-20 w-1 cursor-ew-resize bg-blue-400 dark:bg-gray-200",style:{left:"".concat(k(t.endTime),"%"),transform:"translateX(-50%)"},onMouseDown:e=>A(e,"end")}),b>0&&(0,a.jsx)("div",{className:"z-15 absolute bottom-2 top-2 cursor-move",style:{left:"".concat(k(t.startTime),"%"),width:"".concat(k(t.endTime-t.startTime),"%")},onMouseDown:e=>A(e,"range")})]}),b>0&&(0,a.jsxs)("div",{className:"mt-2 flex justify-between text-xs text-gray-500 dark:text-gray-400",children:[(0,a.jsxs)("span",{children:["Start: ",t.startTime.toFixed(1),"s"]}),(0,a.jsxs)("span",{children:["End: ",t.endTime.toFixed(1),"s"]}),(0,a.jsxs)("span",{children:["Duration: ",(t.endTime-t.startTime).toFixed(1),"s"]}),(0,a.jsxs)("span",{children:["Total: ",b.toFixed(1),"s"]})]})]})]})}function I(e){let{videos:t,onChange:r}=e,[i,s]=(0,l.useState)(!1),n=(0,l.useRef)(null),o=(0,l.useRef)(null),u=async e=>{let t=URL.createObjectURL(e),r=document.createElement("video");
1r.src=t,r.muted=!0,r.playsInline=!0,r.preload="metadata";try{await new Promise((e,t)=>{let a=setTimeout(()=>{t(Error("Video metadata loading timeout"))},1e4);r.addEventListener("loadedmetadata",()=>{clearTimeout(a),e()},{once:!0}),r.addEventListener("error",()=>{clearTimeout(a),t(Error("Video loading failed"))},{once:!0})});let a=r.duration;if(isNaN(a)||a<=0)throw Error("Unable to get video duration, please check if the video file is valid");if(a<1)throw Error("Video duration must be greater than ".concat(1," seconds"));return{url:t,file:e,startTime:0,endTime:Math.min(4,Math.max(1,a))}}finally{r.src=""}},m=async e=>{let a=Array.from(e.target.files||[]).filter(e=>e.type.startsWith("video/"));if(0===a.length)return;let l=a[0];s(!0);try{var i;t.length>0&&(null===(i=t[0])||void 0===i?void 0:i.url)&&URL.revokeObjectURL(t[0].url);let e=await u(l);r([e])}catch(e){c.ZP.error(e.message||"Video upload failed, please try again")}finally{s(!1),n.current&&(n.current.value="")}},x=(e,a)=>{let l=[...t];l[a]=e,r(l)},p=e=>{let a=t[e];a&&a.url&&URL.revokeObjectURL(a.url),r(t.filter((t,r)=>r!==e))};return(0,a.jsxs)("div",{className:"relative rounded-2xl",children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)("label",{className:"text-left text-sm font-semibold text-gray-500 dark:text-gray-300",children:["character_file_url ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]})}),(0,a.jsx)("input",{ref:n,type:"file",accept:"video/*",onChange:m,className:"hidden",disabled:i}),(0,a.jsx)("div",{className:"mb-6 max-h-[500px] overflow-y-auto",style:{scrollbarWidth:"thin",scrollbarColor:"var(--akr-color-text-secondary) transparent"},children:0===t.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-lg border border-gray-300 bg-gray-50 p-6 py-12 dark:border-gray-600 dark:bg-gray-800",children:[(0,a.jsx)(j.JO,{icon:"mdi:video-off",className:"mb-4 h-12 w-12 text-gray-400 dark:text-gray-500"}),(0,a.jsxs)("p",{className:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400",children:["Click to upload a video",(0,a.jsx)("br",{}),"Supported formats: MP4, WEBM, AVI, MOV. Maximum file size: 10MB; Maximum files: 1"]}),(0,a.jsx)(d.A,{size:"sm",variant:"flat",className:"mt-4 bg-gray-200 text-gray-800 dark:bg-gray-600 dark:text-gray-100",onPress:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.click()},isDisabled:i,isLoading:i,children:i?"Uploading...":"Upload video"})]}):t.map((e,t)=>(0,a.jsx)(M,{video:e,index:t,onUpdate:e=>x(e,t),onDelete:()=>p(t),canvasRef:o},"".concat(e.url,"-").concat(t)))}),(0,a.jsx)("canvas",{ref:o,className:"hidden"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Upload a 1-4 s clip (⤠100 MB, mp4/mov/webm/m4v/avi) featuring a non-real person; keep the subject centered, well-lit, and free of motion blur for best recognition."})]})}var O=r(15301),_=r(49650),F=r(36380),E=r.n(F),P=r(69194),T=r(25411),L=r(64842),D=r(72860),R=r(15050),U=r(7986),z=r(29193),V=r(30138),K=r(44116),q=r(67293),B=r(29109),W=r(75871);let Z={PlaygroundUniversalForm:e=>(0,a.jsx)(z.Z,{...e}),PlaygroundSunoVoice:e=>{let{field:t,onChange:r}=e;return(0,a.jsx)(B.Z,{field:t,onChange:r})},PlaygroundColorPalette:e=>{let{field:t,value:r,onChange:l,error:i}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(V.ZP,{value:Array.isArray(r)?r:[],onChange:e=>l(t.parameterKey,e),error:i})]})},PlaygroundKlingShots:e=>{let{field:t,onChange:r,error:l,formData:i,onUploadStateChange:s}=e;return(0,a.jsx)(q.Z,{field:t,onChange:r,error:l,formData:i,onUploadStateChange:s})},PlaygroundBBoxEditor:e=>{let{field:t,value:r,onChange:l,error:i,formData:s}=e,n=(0,K.Zs)(null==s?void 0:s[t.imageUrlsKey||"input_urls"]),o=(0,K.oe)(r,n);return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(K.ZP,{imageUrls:n,value:o,onChange:e=>l(t.parameterKey,e),error:i})]})},PlaygroundInput:e=>{let{field:t,value:r,onChange:l,error:i,isReadOnly:s}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("input",{type:"text",value:r,onChange:e=>l(t.parameterKey,e.target.value),placeholder:t.placeholder,maxLength:t.maxLength,disabled:s,className:"h-10 w-full rounded-lg border px-3 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-1 ".concat(i?"border-red-500 focus:border-red-500 focus:ring-red-500 dark:border-red-400 dark:focus:border-red-400 dark:focus:ring-red-400":"border-gray-300 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"," bg-white dark:bg-gray-700 ").concat(s?"cursor-not-allowed opacity-50":"")}),i&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:i}),t.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.note})]})},PlaygroundInputNumber:e=>{let{field:t,value:r,onChange:i,error:s,isReadOnly:n}=e,[o,d]=(0,l.useState)(null==r?"":String(r));return(0,l.useEffect)(()=>{d(null==r?"":String(r))},[r]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 space-y-2",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"relative w-[50%]",children:[(0,a.jsx)("input",{type:"number",value:o,onBlur:()=>{let e=o.trim();if(""===e){d(""),i(t.parameterKey,void 0);return}let r=Number(e);if(!Number.isFinite(r))return;let a=r;t.float&&(a=J(a,1)),d(String(a)),i(t.parameterKey,a)},onChange:e=>{d(e.target.value)},placeholder:t.placeholder,disabled:n,className:"h-10 w-full appearance-none rounded-lg border px-3 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-1 ".concat(s?"border-red-500 focus:border-red-500 focus:ring-red-500 dark:border-red-400 dark:focus:border-red-400 dark:focus:ring-red-400":"border-gray-300 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"," bg-white [appearance:textfield] dark:bg-gray-700 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none ").concat(n?"cursor-not-allowed opacity-50":"")}),!t.required&&!n&&""!==o&&(0,a.jsx)("button",{type:"button",onClick:()=>{d(""),i(t.parameterKey,void 0)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:(0,a.jsx)(N.Z,{size:16})})]})]}),s&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:s}),t.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.note})]})},PlaygroundTextarea:e=>{let{field:t,value:r,onChange:l,error:i,isReadOnly:s}=e,n=(0,W.F)(r,t.maxLength);return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("textarea",{value:r,onChange:e=>l(t.parameterKey,e.target.value),rows:t.rows||4,maxLength:t.maxLength,placeholder:t.placeholder,disabled:s,className:"w-full resize-y rounded-lg border px-3 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-1 ".concat(i?"border-red-500 focus:border-red-500 focus:ring-red-500 dark:border-red-400 dark:focus:border-red-400 dark:focus:ring-red-400":"border-gray-300 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"," bg-white dark:bg-gray-700 ").concat(s?"cursor-not-allowed opacity-50":"")}),i&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:i}),(t.note||n.hasLimit)&&(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 text-xs",children:[(0,a.jsx)("p",{className:"min-w-0 flex-1 break-words text-gray-500 dark:text-gray-400",children:t.note}),n.hasLimit&&(0,a.jsxs)("span",{className:"shrink-0 tabular-nums ".concat(n.isAtLimit?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:[n.count,"/",n.limit]})]})]})},PlaygroundSelect:e=>{var t;let{field:r,value:i,onChange:s,error:n,isReadOnly:o,disabledOptions:d}=e,[c,u]=(0,l.useState)(null),[m,x]=(0,l.useState)(!1),p=null!=i&&""!==i;return(0,l.useEffect)(()=>{var e,t;let a=null===(e=r.selectOption)||void 0===e?void 0:e.find(e=>e.value===i);u(a||null),x(!!(null==a?void 0:null===(t=a.description)||void 0===t?void 0:t.trim()))},[i,r.selectOption]),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[r.parameterKey," ",r.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-3 ".concat(m?"flex-row":"flex-col"),children:[(0,a.jsx)("div",{className:m?"flex-1":"w-full",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(P.g,{selectedKeys:p?[i]:[],onSelectionChange:e=>{let t=Array.from(e)[0];s(r.parameterKey,t||null)},placeholder:r.placeholder||"Select an option",isInvalid:!!n,errorMessage:n,isDisabled:o,classNames:{trigger:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 focus-within:border-blue-500 dark:focus-within:border-blue-400 ".concat(p?"pr-16":""),value:"text-gray-900 dark:text-white",popover:"bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600"},children:null===(t=r.selectOption)||void 0===t?void 0:t.map(e=>{let t=Array.isArray(d)&&d.includes(e.value);return(0,a.jsx)(T.R,{value:e.value,isDisabled:t,children:e.label},e.value)})}
1),p&&!o&&(0,a.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),s(r.parameterKey,null)},"aria-label":"Clear ".concat(r.parameterKey),className:"absolute right-8 top-5 z-20 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:text-gray-500 dark:hover:bg-gray-600 dark:hover:text-gray-200",children:(0,a.jsx)(N.Z,{size:16})})]})}),m&&(0,a.jsx)("div",{className:"flex min-h-[40px] flex-1 items-center overflow-hidden",children:(0,a.jsx)("p",{className:"max-w-full truncate text-sm text-gray-600 dark:text-gray-400",title:c.description,children:c.description})})]}),r.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r.note})]})},PlaygroundRadio:e=>{var t;let{field:r,value:l,onChange:i,error:s,isOptionDisabled:n,disabledOptions:o,isReadOnly:d}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[r.parameterKey," ",r.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex cursor-pointer items-center gap-2 overflow-x-auto pb-2",children:null===(t=r.radioOptions)||void 0===t?void 0:t.map(e=>{let t=d||(null==n?void 0:n(r.parameterKey,e.value))||Array.isArray(o)&&o.includes(e.value)||!1;return(0,a.jsxs)("button",{type:"button",onClick:()=>!t&&i(r.parameterKey,e.value),disabled:t,className:"flex h-[40px] min-w-[66px] items-center justify-center space-x-2 rounded-lg border-2 p-3 transition-all ".concat(t?"cursor-not-allowed border-gray-200 bg-gray-100 opacity-50 dark:border-gray-700 dark:bg-gray-800":"hover:border-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20"," ").concat(l===e.value?"border-blue-500 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-gray-200 bg-white dark:border-gray-600 dark:bg-gray-700"),children:[e.icon&&(0,a.jsx)(j.JO,{className:"text-default-500",icon:e.icon,width:20}),(0,a.jsx)("span",{className:"text-sm font-medium ".concat(l===e.value?"text-blue-600 dark:text-blue-400":"text-gray-700 dark:text-gray-300"),children:e.label})]},e.value)})}),s&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:s}),r.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r.note})]})},PlaygroundSwitch:e=>{let{field:t,value:r,onChange:l,error:i,isReadOnly:s}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.parameterKey," ",t.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),t.note&&!(t.warn&&s)&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.note}),t.warn&&s&&(0,a.jsxs)("div",{className:"mt-1 flex gap-2 pl-0.5 text-xs text-gray-500 dark:text-gray-400",children:[(0,a.jsx)(j.JO,{icon:"mdi:alert",className:"h-4 w-4"}),t.warn]})]}),(0,a.jsxs)("label",{className:"relative inline-flex cursor-pointer items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:r,onChange:e=>l(t.parameterKey,e.target.checked),className:"peer sr-only",disabled:s}),(0,a.jsx)("div",{className:"peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-blue-600 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300/20 dark:bg-gray-600 dark:after:border-gray-500 dark:after:bg-gray-300 dark:peer-checked:bg-blue-500 dark:peer-focus:ring-blue-800/20 ".concat(s?"pointer-events-none opacity-50":"")})]})]}),"nsfw_checker"===t.parameterKey&&(0,a.jsx)("div",{className:"mt-1 flex gap-2 pl-0.5 text-xs text-amber-600 dark:text-amber-400",children:(0,a.jsx)("span",{children:"There is no guarantee that everything can be filtered out; if you are not satisfied with the results, you will need to make your own arrangements."})}),i&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:i})]})},PlaygroundFileUpload:e=>{var t,r;let{field:i,value:s,onChange:n,error:o,onUploadStateChange:u,isReadOnly:m}=e,[x,p]=(0,l.useState)(i.multiple?[]:null),[g,h]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[v,y]=(0,l.useState)(i.multiple?[]:null),j=i.multiple?null!==(r=i.limitFile)&&void 0!==r?r:5:1,k=l.useRef(null),w=e=>{let t=e.toLowerCase();return t.endsWith(".mp4")||t.endsWith(".mov")||t.endsWith(".avi")||t.endsWith(".webm")||t.endsWith(".wmv")||t.endsWith(".mkv")?"video":t.endsWith(".mp3")||t.endsWith(".wav")||t.endsWith(".ogg")||t.endsWith(".m4a")||t.endsWith(".flac")||t.endsWith(".aac")||t.endsWith(".wma")?"audio":"image"};(0,l.useEffect)(()=>{s?i.multiple&&Array.isArray(s)?(p(s),y(s.map(e=>w(e)))):i.multiple||"string"!=typeof s?(p(i.multiple?[]:null),y(i.multiple?[]:null)):(p(s),y(w(s))):(p(i.multiple?[]:null),y(i.multiple?[]:null))},[s,i.multiple]);let N=async e=>{if(!e||0===e.length)return;let t=Array.isArray(e)?e:Array.from(e),r=i.multiple?t:[t[0]];if(i.multiple){let e=Array.isArray(s)?s.length:0;if(e+r.length>j){c.Am.error("Maximum ".concat(j," files allowed, currently have ").concat(e," files"));return}}for(let e of r){var a;if(!(null===(a=i.acceptedFileTypes)||void 0===a?void 0:a.includes(e.type))){c.Am.error("Unsupported file format: ".concat(e.name));return}if(i.maxFileSize&&e.size>1048576*i.maxFileSize){c.Am.error("File ".concat(e.name," exceeds ").concat(i.maxFileSize,"MB limit"));return}}h(!0),null==u||u(1);let l=c.Am.loading("Uploading file...");try{let e=r.map(e=>(0,A._R)(e,"kieai/market")),t=await Promise.all(e);
1if(c.Am.dismiss(l),i.multiple){let e=[...Array.isArray(s)?s:[],...t];n(i.parameterKey,e);let a=r.map(e=>URL.createObjectURL(e)),l=r.map(e=>e.type.startsWith("image/")?"image":e.type.startsWith("video/")?"video":e.type.startsWith("audio/")?"audio":"image");p(e=>[...Array.isArray(e)?e:[],...a]),y(e=>[...Array.isArray(e)?e:[],...l])}else{let e=t[0],a=r[0];n(i.parameterKey,e);let l=URL.createObjectURL(a);p(l),a.type.startsWith("image/")?y("image"):a.type.startsWith("video/")?y("video"):a.type.startsWith("audio/")&&y("audio")}c.Am.success("Successfully uploaded ".concat(r.length," file(s)"))}catch(e){console.error("Upload error:",e),c.Am.dismiss(l),c.Am.error("Upload failed: "+e.message)}finally{h(!1),null==u||u(-1)}},S=async e=>{let t=e.target.files;t&&t.length>0&&await N(t)},C=()=>{var e;null===(e=k.current)||void 0===e||e.click()},M=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(i.multiple&&Array.isArray(s)){if(null!==e){let t=s.filter((t,r)=>r!==e),r=Array.isArray(x)?x.filter((t,r)=>r!==e):[],a=Array.isArray(v)?v.filter((t,r)=>r!==e):[];n(i.parameterKey,t.length>0?t:null),p(r),y(a)}else n(i.parameterKey,null),p([]),y([])}else n(i.parameterKey,null),p(null),y(null);k.current&&(k.current.value="")},I=async e=>{e.preventDefault(),b(!1);let t=e.dataTransfer.files;t&&t.length>0&&await N(t)};return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[i.parameterKey," ",i.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),i.multiple&&Array.isArray(s)&&(0,a.jsx)(d.A,{color:"danger",size:"sm",variant:"flat",onPress:()=>M(),children:"Remove All"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"relative rounded-lg border-2 border-dashed transition-all ".concat(f?"border-blue-400 bg-blue-50 dark:border-blue-400 dark:bg-blue-900/20":"border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-800"," ").concat((i.multiple?Array.isArray(s)&&s.length>0:s)?"hidden":"block"),onDragOver:e=>{e.preventDefault(),b(!0)},onDragLeave:e=>{e.preventDefault(),b(!1)},onDrop:I,children:(0,a.jsx)("div",{className:"flex flex-col items-center justify-center p-8",children:g?(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,a.jsx)("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"loading..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700",children:/^(video)\//.test(i.acceptedFileTypes[0])?(0,a.jsx)("svg",{className:"h-8 w-8 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}):/^(audio)\//.test(i.acceptedFileTypes[0])?(0,a.jsx)("svg",{className:"h-8 w-8 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{fill:"currentColor",d:"M10.058 19.808q-1.238 0-2.119-.882t-.881-2.118t.881-2.119t2.119-.881q.575 0 1.091.204q.517.205.909.615V5q0-.343.234-.575t.581-.233h3.263q.347 0 .577.233t.23.575v.923q0 .343-.233.576q-.232.232-.576.232h-3.076v10.077q0 1.237-.882 2.118t-2.118.882"})}):(0,a.jsx)("svg",{className:"h-8 w-8 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),(0,a.jsx)("p",{className:"mb-2 text-sm text-gray-600 dark:text-gray-400",children:"Click to upload or drag and drop"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:(()=>
1{if(i.acceptedFileTypes){let e=i.acceptedFileTypes.filter(e=>e.startsWith("image/")),t=i.acceptedFileTypes.filter(e=>e.startsWith("video/")),r=i.acceptedFileTypes.filter(e=>e.startsWith("audio/")),a="";return e.length>0&&(a+="Supported formats: ".concat(e.map(e=>e.split("/")[1].toUpperCase()).join(", ")," Maximum file size: ").concat(i.maxFileSize,"MB")),t.length>0&&(a&&(a+="; "),a+="Supported formats: ".concat(t.map(e=>e.split("/")[1].toUpperCase()).join(", ")," Maximum file size: ").concat(i.maxFileSize,"MB")),r.length>0&&(a&&(a+="; "),a+="Supported formats: ".concat(r.map(e=>e.split("/")[1].toUpperCase()).join(", ")," Maximum file size: ").concat(i.maxFileSize,"MB")),i.multiple&&(a+="; Maximum files: ".concat(j)),a}let e="Supported formats: JPG, JPEG, PNG, MP4, AVI, MOV, WMV, WEBM, MKV, MP3, WAV, OGG; Maximum file size: ".concat(i.maxFileSize,"MB");return i.multiple?"".concat(e,"; Maximum files: ").concat(j):e})()}),(0,a.jsx)("button",{type:"button",onClick:C,disabled:g||m,className:"mt-4 rounded-lg bg-blue-500 px-4 py-2 text-sm font-medium text-white transition-all hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-blue-600 dark:hover:bg-blue-700",children:g?"Uploading...":i.multiple?"Select files":"Select file"})]})})}),(0,a.jsx)("input",{ref:k,type:"file",onChange:S,multiple:i.multiple,className:"hidden",accept:(null===(t=i.acceptedFileTypes)||void 0===t?void 0:t.join(","))||"*",disabled:m}),(i.multiple&&Array.isArray(s)&&s.length>0||!i.multiple&&s)&&(0,a.jsx)("div",{className:"space-y-3",children:i.multiple&&Array.isArray(s)?(0,a.jsxs)(a.Fragment,{children:[s.map((e,t)=>(0,a.jsx)(L.w,{className:"bg-gray-50 dark:bg-gray-700",children:(0,a.jsxs)(D.G,{className:"p-4",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:[Array.isArray(v)&&"video"===v[t]?(0,a.jsx)("svg",{className:"h-6 w-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}):Array.isArray(v)&&"audio"===v[t]?(0,a.jsx)("svg",{className:"h-6 w-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3"})}):(0,a.jsx)(O.Z,{className:"h-6 w-6 text-gray-500"}),(0,a.jsx)("div",{children:(0,a.jsxs)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:["File ",t+1]})})]}),(0,a.jsx)(d.A,{color:"danger",size:"sm",variant:"flat",onPress:()=>M(t),children:"Remove"})]}),Array.isArray(x)&&x[t]&&(0,a.jsx)("div",{className:"relative",children:Array.isArray(v)&&"video"===v[t]?(0,a.jsx)("video",{src:x[t],controls:!0,className:"h-48 w-full rounded-lg border border-gray-200 object-contain dark:border-gray-600",children:"Your browser does not support video playback"}):Array.isArray(v)&&"audio"===v[t]?(0,a.jsx)("div",{className:"flex flex-col items-center justify-center p-8",children:(0,a.jsx)("audio",{src:x[t],controls:!0,className:"w-full max-w-md",children:"Your browser does not support audio playback"})}):(0,a.jsx)("img",{src:x[t],alt:"Preview ".concat(t+1),className:"h-48 w-full rounded-lg border border-gray-200 object-contain dark:border-gray-600"})})]})},t)),Array.isArray(s)&&s.length<j&&(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)(d.A,{variant:"bordered",onPress:C,disabled:g,className:"border-dashed border-gray-300 text-gray-600 hover:border-blue-400 hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:text-gray-400 dark:hover:border-blue-400 dark:hover:text-blue-400",startContent:g?(0,a.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400"}):(0,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),children:g?"Uploading...":"Add more files (".concat(s.length,"/").concat(j,")")})}),Array.isArray(s)&&s.length>=j&&(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Maximum file number limit reached (",s.length,"/",j,")"]})})]}):(0,a.jsx)(L.w,{className:"bg-gray-50 dark:bg-gray-700",children:(0,a.jsxs)(D.G,{className:"p-4",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:["video"===v?(0,a.jsx)("svg",{className:"h-6 w-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}):"audio"===v?(0,a.jsx)("svg",{className:"h-6 w-6 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3"})}):(0,a.jsx)(O.Z,{className:"h-6 w-6 text-gray-500"}),(0,a.jsx)("div",{children:(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Upload successfully"})})]}),(0,a.jsx)(d.A,{color:"danger",size:"sm",variant:"flat",onPress:()=>M(),children:"Remove"})]}),x&&(0,a.jsx)("div",{className:"relative",children:"video"===v?(0,a.jsx)("video",{src:x,controls:!0,className:"h-48 w-full rounded-lg border border-gray-200 object-contain dark:border-gray-600",children:"Your browser does not support video playback"}):"audio"===v?(0,a.jsx)("div",{className:"flex flex-col items-center justify-center p-8",children:(0,a.jsx)("audio",{src:x,controls:!0,className:"w-full max-w-md",children:"Your browser does not support audio playback"})}):(0,a.jsx)("img",{src:x,alt:"Preview",className:"h-48 w-full rounded-lg border border-gray-200 object-contain dark:border-gray-600"})})]})})})]}),o&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:o}),i.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.note})]})},PlaygroundFrameUploader:e=>{let{field:t,value:r,secondaryValue:i,onChange:n,onUploadStateChange:o,error:d,secondaryError:u,isReadOnly:m,formData:x,linkageRules:p}=e,[g,h]=(0,l.useState)({start:!1,end:!1}),b=(0,l.useMemo)(()=>{let{startKey:e,endKey:r}=(0,f.Df)(t);return{start:(0,R.Gc)(e,p,x||{}),end:(0,R.Gc)(r,p,x||{})}},[t,p,x]),v=(0,l.useRef)(null),y=(0,l.useRef)(null),j=(0,l.useMemo)(()=>(0,f.hD)(t.acceptedFileTypes),[t.acceptedFileTypes]),k=(0,l.useMemo)(()=>(0,f.a8)(t.acceptedFileTypes),[t.acceptedFileTypes]),w=(0,l.useMemo)(()=>(0,f.RV)(t),[t]),{primaryKey:S,secondaryKey:C}=(0,l.useMemo)(()=>(0,f.LB)(t),[t]);(0,l.useEffect)(()=>{let e=b.start&&(!b.start.visible||b.start.disabled),a=b.end&&(!b.end.visible||b.end.disabled);if(e||a){if("single"===t.fieldMode){if(!Array.isArray(r))return;let t=void 0!==r[0]&&""!==r[0],l=void 0!==r[1]&&""!==r[1];if(e&&t||a&&l){let t=[...r];e&&(t[0]=void 0),a&&(t[1]=void 0),n(S,(0,f.Vz)(t))}return}e&&void 0!==r&&""!==r&&n(S,void 0),a&&C&&void 0!==i&&""!==i&&n(C,void 0)}},[b,t.fieldMode,r,i,S,C,n]);let M=(0,l.useCallback)(e=>"single"===t.fieldMode?Array.isArray(r)?"start"===e&&(0,f.q$)(r[0])?r[0]:"end"===e&&(0,f.q$)(r[1])?r[1]:void 0:void 0:"start"===e&&(0,f.q$)(r)?r:"end"===e&&(0,f.q$)(i)?i:void 0,[t.fieldMode,i,r]),I=M("start"),O=M("end"),F=t.requireFirstFrameFirst&&!I,P=(0,l.useCallback)((e,a)=>{if("single"===t.fieldMode){let t=Array.isArray(r)?[...r]:[void 0,void 0];"start"===e?t[0]=a:t[1]=a,n(S,(0,f.Vz)(t));return}if("start"===e){n(S,a);return}C&&n(C,a)},[t.fieldMode,n,S,C,r]),T=(0,l.useCallback)(e=>{if("single"===t.fieldMode){let a=Array.isArray(r)?[...r]:[void 0,void 0];if("start"===e){a[0]=void 0,t.clearLastFrameWhenFirstRemoved&&(a[1]=void 0),n(S,(0,f.Vz)(a)),v.current&&(v.current.value=""),t.clearLastFrameWhenFirstRemoved&&y.current&&(y.current.value="");return}
1a[1]=void 0,n(S,(0,f.Vz)(a)),y.current&&(y.current.value="");return}if("start"===e){P("start",void 0),t.clearLastFrameWhenFirstRemoved&&P("end",void 0),v.current&&(v.current.value=""),t.clearLastFrameWhenFirstRemoved&&y.current&&(y.current.value="");return}P("end",void 0),y.current&&(y.current.value="")},[t.clearLastFrameWhenFirstRemoved,t.fieldMode,n,S,P,r]),L=(0,l.useCallback)(async(e,r)=>{let a=[];e instanceof FileList?a=Array.from(e):Array.isArray(e)&&(a=e);let l=a[0];if(l){if("end"===r&&F){c.Am.error("Please upload the first frame before uploading the last frame");return}if(!j.includes(l.type)){c.Am.error("Unsupported image format");return}if(t.maxFileSize&&l.size>1048576*t.maxFileSize){c.Am.error("Image size cannot exceed ".concat(t.maxFileSize,"MB"));return}h(e=>({...e,[r]:!0})),null==o||o(1);try{let e=await (0,A._R)(l,"kieai/market");P(r,e),c.Am.success("Successfully uploaded image")}catch(e){console.error("Upload error:",e),c.Am.error("Upload failed, please try again")}finally{h(e=>({...e,[r]:!1})),null==o||o(-1)}}},[j,t.maxFileSize,F,o,P]),D=(0,l.useCallback)((e,t)=>{e.preventDefault(),L(e.dataTransfer.files,t)},[L]),U=(0,l.useCallback)((e,t)=>{var r;e.preventDefault();let a=(null===(r=e.clipboardData)||void 0===r?void 0:r.items)||[];for(let e=0;e<a.length;e+=1){let r=a[e];if("file"===r.kind&&j.includes(r.type)){let e=r.getAsFile();e&&L([e],t);break}}},[j,L]),z={start:I,end:O},V={start:v,end:y},K=(e,t)=>e?"cursor-not-allowed border-default-200 opacity-50":t?"border-blue-500 hover:border-blue-500":"cursor-pointer border-default-200 hover:border-blue-500",q=(e,t)=>t?(0,a.jsxs)("div",{className:"flex h-full w-full items-center justify-center",children:[(0,a.jsx)("div",{className:"relative h-full w-full",children:(0,a.jsx)(E(),{src:t,alt:e.label,fill:!0,unoptimized:!0,className:"object-contain"})}),(0,a.jsx)("button",{type:"button",className:"absolute right-1 top-1 z-10 inline-flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-white shadow-md transition duration-500 hover:opacity-80",onClick:t=>{t.stopPropagation(),T(e.key)},children:(0,a.jsx)(N.Z,{width:16})})]}):(0,a.jsx)("div",{className:"flex flex-col items-center justify-center gap-2 py-6",children:g[e.key]?(0,a.jsx)(s.Z,{className:"h-6 w-6 animate-spin text-blue-500"}):(0,a.jsx)(_.Z,{className:"h-10 w-10 text-default-400"})});return(0,a.jsxs)("div",{className:"space-y-2 ".concat(m?"pointer-events-none opacity-50":""),children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:t.componentLabel}),(0,a.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:w.map(e=>{let t;let r=b[e.key];if(r&&!r.visible)return null;let l=z[e.key],i=!!r&&r.disabled||"end"===e.key&&F,s=!i&&!l;return"start"===e.key?t=d:"end"===e.key&&(t=u),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"rounded-lg border border-default-200 bg-default-50/70 px-3 text-center dark:border-default-100/20 dark:bg-default-100/10",children:(0,a.jsxs)("div",{className:"mt-1 text-xs font-medium text-default-700",children:[e.label," ",e.required?(0,a.jsx)("span",{className:"text-red-500",children:"*"}):null]})}),(0,a.jsxs)("div",{className:"relative flex h-[6.5rem] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed text-center transition ".concat(K(i,l)),onClick:()=>{if(s){var t;null===(t=V[e.key].current)||void 0===t||t.click()}},onDrop:t=>{s&&D(t,e.key)},onDragOver:e=>{s&&e.preventDefault()},onPaste:t=>{s&&U(t,e.key)},children:[q(e,l),(0,a.jsx)("input",{type:"file",ref:V[e.key],accept:j.join(","),className:"hidden",onChange:t=>L(t.target.files,e.key),disabled:!s})]}),t?(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:t}):null]},e.key)})}),(0,a.jsxs)("div",{className:"mt-3 rounded-md bg-gray-50 px-3 py-2 text-center text-xs text-default-500 dark:bg-gray-700/60",children:[(0,a.jsx)("p",{className:"mb-1 text-sm text-default-600",children:t.actionDescription||"Click to upload, drag and drop, or paste an image."}),(0,a.jsxs)("p",{children:["Images: ",k,", Max ",t.maxFileSize||10,"MB"]})]})]})]})},PlaygroundArrayForm:e=>{var t;
1let{field:r,value:l,onChange:i,error:s,isReadOnly:n}=e,o=r.itemType||"input",d=r.minLength||0,c=r.maxLength||0,u=!c||0===c,m=Array.isArray(l)?l:[],x=r.objectSchema||[],p=()=>"switch"!==o&&("number"===o?0:"object"===o?x.reduce((e,t)=>(e[t.key]="number"===t.valueType?0:"boolean"!==t.valueType&&"",e),{}):""),g=e=>{m.length<=d||n||i(r.parameterKey,m.filter((t,r)=>r!==e))},h=(e,t)=>{i(r.parameterKey,m.map((r,a)=>a===e?t:r))},f=null!==(t=({input:"Text",number:"Number",switch:"Switch",object:"Object"})[o])&&void 0!==t?t:"Text",b=!u&&m.length>=c;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[r.parameterKey,r.required&&(0,a.jsx)("span",{className:"ml-1 text-red-500",children:"*"})]}),(0,a.jsx)("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-500 dark:bg-gray-700 dark:text-gray-400",children:f})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:[m.length," / ",u?"â":c]}),(0,a.jsxs)("button",{type:"button",disabled:b||n,onClick:()=>{!u&&m.length>=c||n||i(r.parameterKey,[...m,p()])},className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-1 text-xs font-medium text-blue-600 hover:bg-blue-100 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-blue-900/20 dark:text-blue-400",children:[(0,a.jsx)(j.JO,{icon:"mingcute:add-line",width:13})," Add"]})]})]}),(0,a.jsx)("div",{className:"flex flex-col gap-2 ".concat(n?"pointer-events-none opacity-60":""),children:0===m.length?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5 rounded-xl border border-dashed border-gray-200 py-4 text-gray-400 dark:border-gray-600",children:[(0,a.jsx)(j.JO,{icon:"mingcute:list-add-line",width:20}),(0,a.jsx)("span",{className:"text-xs",children:"No items yet. Click Add to start."})]}):m.map((e,t)=>{let l="object"===o&&"object"==typeof e&&null!==e?e:{};return"object"===o?(0,a.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-gray-50 px-3 py-2.5 dark:border-gray-600 dark:bg-gray-700/40",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"text-xs font-medium text-gray-500",children:["Item ",t+1]}),(0,a.jsx)("button",{type:"button",disabled:m.length<=d,onClick:()=>g(t),className:"flex h-5 w-5 items-center justify-center rounded-lg text-gray-400 hover:bg-red-50 hover:text-red-500 disabled:cursor-not-allowed disabled:opacity-30 dark:hover:bg-red-900/20",children:(0,a.jsx)(j.JO,{icon:"mingcute:close-line",width:12})})]}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:x.map(e=>{var r;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-20 shrink-0 truncate text-xs text-gray-500",children:e.key}),"boolean"===e.valueType?(0,a.jsxs)("label",{className:"relative inline-flex cursor-pointer items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!l[e.key],onChange:r=>h(t,{...l,[e.key]:r.target.checked}),className:"peer sr-only"}),(0,a.jsx)("div",{className:"peer h-5 w-9 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:bg-white after:transition-all after:content-[''] peer-checked:bg-blue-600 peer-checked:after:translate-x-full peer-focus:outline-none dark:bg-gray-600"})]}):(0,a.jsx)("input",{type:"number"===e.valueType?"number":"text",value:null!==(r=l[e.key])&&void 0!==r?r:"",onChange:r=>h(t,{...l,[e.key]:"number"===e.valueType?Number(r.target.value):r.target.value}),className:"flex-1 rounded-lg border border-gray-200 bg-white px-2 py-1 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100"})]},e.key)})})]},t):(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-gray-100 text-xs font-semibold text-gray-500 dark:bg-gray-700",children:t+1}),"switch"===o?(0,a.jsxs)("label",{className:"relative inline-flex flex-1 cursor-pointer items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:!!e,onChange:e=>h(t,e.target.checked),className:"peer sr-only"}),(0,a.jsx)("div",{className:"peer h-6 w-11 rounded-full bg-gray-200 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-blue-600 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none dark:bg-gray-600"})]}):(0,a.jsx)("input",{type:"number"===o?"number":"text",value:null!=e?e:"",placeholder:r.placeholder||"",onChange:e=>h(t,"number"===o?Number(e.target.value):e.target.value),className:"flex-1 rounded-lg border border-gray-200 bg-gray-50 px-3 py-1.5 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100"}),(0,a.jsx)("button",{type:"button",disabled:m.length<=d,onClick:()=>g(t),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-lg text-gray-400 hover:bg-red-50 hover:text-red-500 disabled:cursor-not-allowed disabled:opacity-30 dark:hover:bg-red-900/20",children:(0,a.jsx)(j.JO,{icon:"mingcute:close-line",width:13})})]},t)})}),!u&&(0,a.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-700",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-blue-400 transition-all duration-300",style:{width:"".concat(Math.min(m.length/c*100,100),"%")}})}),s&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:s}),!s&&r.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r.note})]})},PlaygroundSlider:e=>{var t,r,i,s,n;let{field:o,value:d,onChange:c,error:u,isReadOnly:m}=e,[x,p]=(0,l.useState)(d||o.defaultValue);l.useEffect(()=>{p(d)},[d,o.defaultValue,o.min]);let g=(0,l.useMemo)(()=>{var e,t,r;return null==x?0:(J(x,o.step)-(null!==(e=o.min)&&void 0!==e?e:0))/((null!==(t=o.max)&&void 0!==t?t:100)-(null!==(r=o.min)&&void 0!==r?r:0))*100},[x,o.step,o.min,o.max]),h=void 0!==o.excludedMin&&null!==o.excludedMin&&void 0!==o.excludedMax&&null!==o.excludedMax,f=h?(o.excludedMin-(null!==(t=o.min)&&void 0!==t?t:0))/((null!==(r=o.max)&&void 0!==r?r:100)-(null!==(i=o.min)&&void 0!==i?i:0))*100:0,b=h?(o.excludedMax-o.excludedMin)/((null!==(s=o.max)&&void 0!==s?s:100)-(null!==(n=o.min)&&void 0!==n?n:0))*100:0;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"flex items-center space-x-2",children:(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[o.parameterKey," ",o.required&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]})}),(0,a.jsxs)("div",{className:"flex items-center space-x-3 ".concat(m?"pointer-events-none opacity-50":""),children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:"range",min:o.min,max:o.max||100,step:o.step||1,value:x?Number(x):0,onChange:e=>{let t=Number(e.target.value),r=(0,U.G)(t,o.min||0,o.max||100,o.step,o.excludedMin,o.excludedMax);p(r),c(o.parameterKey,r)},className:"h-2 w-full cursor-pointer appearance-none rounded-lg bg-gray-200 dark:bg-gray-700 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-blue-500 [&::-moz-range-thumb]:shadow-sm [&::-moz-range-thumb]:transition-all [&::-moz-range-thumb]:hover:bg-blue-600 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-blue-500 [&::-webkit-slider-thumb]:shadow-sm [&::-webkit-slider-thumb]:transition-all [&::-webkit-slider-thumb]:hover:bg-blue-600",style:{background:"linear-gradient(to right, #3B82F6 0%, #3B82F6 ".concat(g,"%, #e5e7eb ").concat(g,"%, #e5e7eb 100%)")}}),h&&(0,a.jsx)("div",{className:"pointer-events-none absolute top-1/2 h-2 -translate-y-1/2 roun
1ded-full bg-[repeating-linear-gradient(45deg,rgba(0,0,0,0.28)_0_4px,transparent_4px_8px)]",style:{left:"".concat(f,"%"),width:"".concat(b,"%")},title:"".concat(o.excludedMin," ~ ").concat(o.excludedMax," not selectable")})]}),(0,a.jsx)("div",{className:"w-16",children:(0,a.jsx)("input",{type:"number",min:o.min||0,max:o.max||100,step:o.step||1,value:null!=x?x:"",onChange:e=>{p(e.target.value)},onBlur:e=>{let t=J(e.target.value,o.step),r=(0,U.G)(Math.max(o.min||0,Math.min(o.max||100,t)),o.min||0,o.max||100,o.step,o.excludedMin,o.excludedMax);p(r),c(o.parameterKey,r)},className:"w-full appearance-none rounded-lg border border-default-100 bg-default-50 px-2 py-1 text-center text-sm text-default-600 [-moz-appearance:textfield] focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{x!==o.defaultValue&&"number"==typeof x?(p(o.defaultValue),c(o.parameterKey,o.defaultValue)):(p(void 0),c(o.parameterKey,void 0))},className:"flex h-7 w-7 items-center justify-center rounded border border-default-100 bg-default-50 text-default-500 hover:opacity-90",children:(0,a.jsx)(N.Z,{className:"h-4 w-4"})})]}),u&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:u}),o.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.note})]})}};function J(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(t<=0||!isFinite(e)||!isFinite(t))return e;let r=10**Math.max((t.toString().split(".")[1]||"").length,(e.toString().split(".")[1]||"").length),a=Math.round(t*r);return Math.round(Math.round(e*r)/a)*a/r}var G=r(40559),H=r(2649),Y=r(95866),$=r(1993),X=r(38489),Q=r(71608),ee=r(44421),et=r(11433),er=r(85666),ea=r(50014),el=r(67968);let ei=[{kieAudioId:"achernar",name:"Achernar",voiceDescription:"Female, soft, high pitch"},{kieAudioId:"achird",name:"Achird",voiceDescription:"Male, friendly, mid pitch"},{kieAudioId:"algenib",name:"Algenib",voiceDescription:"Male, gravelly, low pitch"},{kieAudioId:"algieba",name:"Algieba",voiceDescription:"Male, easy-going, mid-low pitch"},{kieAudioId:"alnilam",name:"Alnilam",voiceDescription:"Male, firm, mid-low pitch"},{kieAudioId:"aoede",name:"Aoede",voiceDescription:"Female, breezy, mid pitch"},{kieAudioId:"autonoe",name:"Autonoe",voiceDescription:"Female, bright, mid pitch"},{kieAudioId:"callirrhoe",name:"Callirrhoe",voiceDescription:"Female, easy-going, mid pitch"},{kieAudioId:"charon",name:"Charon",voiceDescription:"Male, informative, lower pitch"},{kieAudioId:"despina",name:"Despina",voiceDescription:"Female, smooth, mid pitch"},{kieAudioId:"enceladus",name:"Enceladus",voiceDescription:"Male, breathy, lower pitch"},{kieAudioId:"erinome",name:"Erinome",voiceDescription:"Female, clear, mid pitch"},{kieAudioId:"fenrir",name:"Fenrir",voiceDescription:"Male, excitable, younger pitch"},{kieAudioId:"gacrux",name:"Gacrux",voiceDescription:"Female, mature, mid pitch"},{kieAudioId:"iapetus",name:"Iapetus",voiceDescription:"Male, clear, mid-low pitch"},{kieAudioId:"kore",name:"Kore",voiceDescription:"Female, firm, mid pitch"},{kieAudioId:"laomedeia",name:"Laomedeia",voiceDescription:"Female, upbeat, mid-high pitch"},{kieAudioId:"leda",name:"Leda",voiceDescription:"Female, youthful, mid-high pitch"},{kieAudioId:"orus",name:"Orus",voiceDescription:"Male, firm, mid-low pitch"},{kieAudioId:"puck",name:"Puck",voiceDescription:"Male, upbeat, mid pitch"},{kieAudioId:"pulcherrima",name:"Pulcherrima",voiceDescription:"Ungendered, forward, mid-high pitch"},{kieAudioId:"rasalgethi",name:"Rasalgethi",voiceDescription:"Male, informative, mid pitch"},{kieAudioId:"sadachbia",name:"Sadachbia",voiceDescription:"Male, lively, low pitch"},{kieAudioId:"sadaltager",name:"Sadaltager",voiceDescription:"Male, knowledgeable, mid pitch"},{kieAudioId:"schedar",name:"Schedar",voiceDescription:"Male, even, mid-low pitch"},{kieAudioId:"sulafat",name:"Sulafat",voiceDescription:"Female, warm, mid pitch"},{kieAudioId:"umbriel",name:"Umbriel",voiceDescription:"Male, smooth, lower pitch"},{kieAudioId:"vindemiatrix",name:"Vindemiatrix",voiceDescription:"Female, gentle, mid pitch"},{kieAudioId:"zephyr",name:"Zephyr",voiceDescription:"Female, bright, mid-high pitch"},{kieAudioId:"zubenelgenubi",name:"Zubenelgenubi",voiceDescription:"Male, casual, mid-low pitch"}],es=e=>{if(!e)return ei;let t=e.toLowerCase();return ei.filter(e=>e.name.toLowerCase().includes(t)||e.voiceDescription.toLowerCase().includes(t)||e.kieAudioId.toLowerCase().includes(t))},en={audio_ids:{endpoint:"/api/v1/omni/audio/find",modalTitle:"Select audio ID",searchPlaceholder:"Search audio by name or ID",emptyText:"No audio IDs found"},character_ids:{endpoint:"/api/v1/omni/character/find",modalTitle:"Select character ID",searchPlaceholder:"Search character by name or ID",emptyText:"No character IDs found"}},eo=[0,200],ed=e=>{var t;return null!==(t=null==e?void 0:e.data)&&void 0!==t?t:e},ec=e=>{var t,r,a,l,i,s,n,o,d;let c=ed(e),u=(null==c?void 0:c.records)||(null==c?void 0:c.list)||(null==c?void 0:c.items)||(null==c?void 0:null===(t=c.data)||void 0===t?void 0:t.records)||(null==c?void 0:null===(r=c.data)||void 0===r?void 0:r.list)||(null==c?void 0:null===(a=c.data)||void 0===a?void 0:a.items)||(Array.isArray(c)?c:[]),m=null!==(n=null!==(s=null==c?void 0:c.total)&&void 0!==s?s:null==c?void 0:null===(l=c.data)||void 0===l?void 0:l.total)&&void 0!==n?n:u.length,x=null!==(d=null!==(o=null==c?void 0:c.pages)&&void 0!==o?o:null==c?void 0:null===(i=c.data)||void 0===i?void 0:i.pages)&&void 0!==d?d:Math.max(1,Math.ceil((Number(m)||u.length)/10));return{records:Array.isArray(u)?u:[],total:Number(m)||0,pages:Number(x)||1}},eu=(e,t,r)=>{let a={page_size:10,page_num:t,pageSize:10,pageNum:t};return r?{...a,keyword:r,name:r,id:r,..."audio_ids"===e?{kieAudioId:r}:{characterName:r,kieCharacterId:r}}:a},em=async(e,t,r)=>{let a={"Content-Type":"application/json"},l=(0,ea.T4)(),i=await (0,ea.Ki)();r&&(a.Authorization="Bearer ".concat(r)),l&&(a.customizeCookie=l),i&&(a.uniqueId=i);let s=await fetch("".concat("https://api.kie.ai").concat(e),{method:"POST",headers:a,body:JSON.stringify(t)}),n=await s.json();if(!s.ok||(null==n?void 0:n.code)!=null&&!eo.includes(Number(n.code)))throw Error((null==n?void 0:n.msg)||"Failed to fetch asset list");return n},ex=(e,t)=>{var r,a,l,i,s,n,o;if("string"==typeof e)return{id:e,name:e,description:""};let d=null!==(o=null!==(n=null!==(s=null!==(i=null!==(l=null!==(a=null!==(r=null==e?void 0:e.kieAudioId)&&void 0!==r?r:null==e?void 0:e.kieCharacterId)&&void 0!==a?a:null==e?void 0:e.id)&&void 0!==l?l:null==e?void 0:e.audio_id)&&void 0!==i?i:null==e?void 0:e.audioId)&&void 0!==s?s:null==e?void 0:e.character_id)&&void 0!==n?n:null==e?void 0:e.characterId)&&void 0!==o?o:null==e?void 0:e.value,c="audio_ids"===t?[null==e?void 0:e.voiceDescription,null==e?void 0:e.exampleDialogue,null==e?void 0:e.description,null==e?void 0:e.desc,null==e?void 0:e.remark].filter(
1Boolean).join(" \xb7 "):[null==e?void 0:e.descrptions,null==e?void 0:e.description,null==e?void 0:e.desc,null==e?void 0:e.remark,Array.isArray(null==e?void 0:e.audioIds)&&e.audioIds.length>0?"".concat(e.audioIds.length," linked audio ID(s)"):""].filter(Boolean).join(" \xb7 ");return{id:null==d?"":String(d),name:(null==e?void 0:e.name)||(null==e?void 0:e.characterName)||(null==e?void 0:e.title)||(null==e?void 0:e.displayName)||(null==e?void 0:e.label)||String(d||""),description:c}},ep=(0,m.Pi)(function(e){var t;let{label:r,parameterKey:i,value:s,maxItems:n,addLabel:o,note:c,error:m,onFieldChange:x}=e,{userStore:p}=(0,u.o)(),g=null===(t=p.user)||void 0===t?void 0:t.apiKey,h=en[i],f=(0,l.useMemo)(()=>Array.isArray(s)?s.map(String).slice(0,n):[],[n,s]),[b,v]=(0,l.useState)(!1),[y,j]=(0,l.useState)(""),[k,w]=(0,l.useState)(""),[A,S]=(0,l.useState)(1),[C,M]=(0,l.useState)([]),[I,O]=(0,l.useState)(1),[_,F]=(0,l.useState)(0),[E,P]=(0,l.useState)(!1),[T,L]=(0,l.useState)(new Set),D=n-f.length,R=D>0,U=(0,l.useMemo)(()=>"audio_ids"!==i?[]:es(k).map(e=>ex(e,i)),[i,k]),z=(0,l.useMemo)(()=>{if(0===U.length)return C;let e=new Set(U.map(e=>e.id));return[...U,...C.filter(t=>!e.has(t.id))]},[U,C]);(0,l.useEffect)(()=>{if(!b)return;let e=window.setTimeout(()=>{w(y.trim()),S(1)},350);return()=>window.clearTimeout(e)},[b,y]),(0,l.useEffect)(()=>{if(!b||!(null==h?void 0:h.endpoint))return;let e=!1;return(async()=>{P(!0);try{let t=await em(h.endpoint,eu(i,A,k),g);if(e)return;let r=ec(t);M(r.records.map(e=>ex(e,i)).filter(e=>e.id)),F(r.total),O(r.pages)}catch(t){if(e)return;M([]),F(0),O(1)}finally{e||P(!1)}})(),()=>{e=!0}},[g,null==h?void 0:h.endpoint,k,b,A,i]);let V=e=>{e&&(f.includes(e)||L(t=>{let r=new Set(t);return r.has(e)?r.delete(e):f.length+r.size<n&&r.add(e),r}))},K=e=>{x(i,f.filter((t,r)=>r!==e))};return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r}),(0,a.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[f.length,"/",n]})]}),f.length>0&&(0,a.jsx)("div",{className:"space-y-2",children:f.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-gray-800/80",children:[(0,a.jsx)("span",{className:"min-w-0 truncate text-sm text-gray-800 dark:text-gray-100",children:e}),(0,a.jsx)(d.A,{isIconOnly:!0,radius:"sm",size:"sm",variant:"flat",color:"danger",className:"h-7 min-w-7 rounded-md",onPress:()=>K(t),children:(0,a.jsx)(N.Z,{className:"h-4 w-4"})})]},"".concat(i,"-").concat(e,"-").concat(t)))}),(0,a.jsxs)(d.A,{radius:"sm",variant:"bordered",onPress:()=>{R&&(j(""),w(""),S(1),L(new Set),v(!0))},isDisabled:!R,className:"min-h-11 w-full rounded-md border-dashed border-gray-300 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-white/15 dark:text-gray-100 dark:hover:bg-gray-700/60",children:["+ ",o]}),m&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:m}),c&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c}),(0,a.jsx)(H.R,{isOpen:b,onClose:()=>v(!1),size:"2xl",placement:"center",children:(0,a.jsxs)(Y.A,{className:"border border-gray-200 bg-white text-gray-900 shadow-xl dark:border-white/10 dark:bg-gray-800 dark:text-white",children:[(0,a.jsxs)($.k,{className:"flex flex-col gap-1 border-b border-gray-200 px-6 py-5 dark:border-white/10",children:[(0,a.jsx)("span",{children:(null==h?void 0:h.modalTitle)||"Select ".concat(r)}),(0,a.jsxs)("span",{className:"text-xs font-normal text-gray-500 dark:text-gray-400",children:["Search by name or ID, then select one or more items (up to ",D," remaining)."]})]}),(0,a.jsx)(X.I,{className:"gap-4 bg-gray-50/80 px-6 py-5 dark:bg-gray-800",children:(0,a.jsx)("div",{className:"max-h-[24rem] min-h-[18rem] overflow-y-auto rounded-lg border border-gray-200 bg-white dark:border-white/10 dark:bg-gray-900/35",children:E?(0,a.jsx)("div",{className:"flex h-[18rem] items-center justify-center",children:(0,a.jsx)(Q.c,{size:"sm"})}):z.length>0?(0,a.jsx)("div",{className:"space-y-2 p-3",children:z.map(e=>{let t=f.includes(e.id),r=T.has(e.id),l=!r&&f.length+T.size>=n;return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3 ".concat(r?"bg-blue-50 dark:bg-blue-900/20":"bg-white dark:bg-gray-900/20"),children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-white",children:e.name||e.
1id}),(0,a.jsx)("div",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",children:e.id}),e.description&&(0,a.jsx)("div",{className:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400",children:e.description})]}),(0,a.jsx)(d.A,{size:"sm",radius:"sm",color:r?"primary":"default",variant:t?"flat":r?"solid":"bordered",isDisabled:t||!r&&l,onPress:()=>V(e.id),children:t?"Added":r?"â Selected":"Select"})]},e.id)})}):(0,a.jsxs)("div",{className:"flex h-[18rem] flex-col items-center justify-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,a.jsx)(er.Z,{className:"h-6 w-6"}),(0,a.jsx)("span",{className:"text-sm",children:(null==h?void 0:h.emptyText)||"No results found"})]})})}),(0,a.jsxs)(ee.R,{className:"items-center justify-between border-t border-gray-200 bg-white px-6 py-4 dark:border-white/10 dark:bg-gray-800",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[U.length+_," result",U.length+_===1?"":"s",T.size>0&&(0,a.jsxs)("span",{className:"ml-2 font-medium text-blue-600 dark:text-blue-400",children:["\xb7 ",T.size," selected"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(et.g,{size:"sm",page:A,total:Math.max(I,1),onChange:S,isDisabled:E}),(0,a.jsx)(d.A,{size:"sm",radius:"sm",variant:"flat",onPress:()=>v(!1),children:"Cancel"}),(0,a.jsxs)(d.A,{size:"sm",radius:"sm",color:"primary",isDisabled:0===T.size,onPress:()=>{if(0===T.size){v(!1);return}x(i,[...f,...T].slice(0,n)),v(!1)},children:["Confirm",T.size>0?" (".concat(T.size,")"):""]})]})]})]})})]})}),eg=e=>{var t,r;let{value:i,onFieldChange:n,onUploadStateChange:u,error:m}=e,[x,p]=(0,l.useState)(!1),g=(0,l.useRef)(null),h=(0,el.CR)(i)[0],f=!!(null==h?void 0:h.url),b=null!==(t=null==h?void 0:h.start)&&void 0!==t?t:el.QK.start,v=null!==(r=null==h?void 0:h.ends)&&void 0!==r?r:el.QK.ends,y=e=>{let t={url:(null==h?void 0:h.url)||"",start:b,ends:v,...e};n("video_list",t.url?[t]:[])},j=async e=>{let t=null==e?void 0:e[0];if(!t)return;if(!el.Tl.includes(t.type)){c.Am.error("Unsupported file format: ".concat(t.name));return}p(!0),null==u||u(1);let r=c.Am.loading("Uploading file...");try{let e=await (0,A._R)(t,"kieai/market");c.Am.dismiss(r),n("video_list",[{url:e,start:el.QK.start,ends:el.QK.ends}]),c.Am.success("Successfully uploaded video")}catch(e){c.Am.dismiss(r),c.Am.error("Upload failed: "+e.message)}finally{p(!1),null==u||u(-1)}};return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"video_list"}),f?(0,a.jsx)(L.w,{className:"border border-gray-200 bg-white shadow-sm dark:border-white/10 dark:bg-gray-900/35",children:(0,a.jsxs)(D.G,{className:"space-y-4 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 text-sm font-medium text-gray-800 dark:text-gray-100",children:[(0,a.jsx)("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-300",children:(0,a.jsx)(_.Z,{className:"h-4 w-4"})}),(0,a.jsx)("span",{children:"Video uploaded"})]}),(0,a.jsx)(d.A,{size:"sm",variant:"bordered",className:"border-red-200 bg-red-50/70 text-red-600 hover:bg-red-100 dark:border-red-400/20 dark:bg-red-400/10 dark:text-red-300 dark:hover:bg-red-400/15",onPress:()=>y({url:""}),children:"Remove"})]}),(0,a.jsx)("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-gray-100 dark:border-white/10 dark:bg-black/30",children:(0,a.jsx)("video",{src:h.url,controls:!0,className:"h-48 w-full object-contain",children:"Your browser does not support video playback"})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,a.jsx)(o.Y,{type:"number",label:"start",value:String(b),onValueChange:e=>y({start:Number(e||el.QK.start)}),classNames:{label:"text-gray-500 dark:text-gray-300",input:"text-gray-900 dark:text-white",inputWrapper:"border border-gray-200 bg-gray-50 shadow-none data-[hover=true]:bg-gray-50 data-[focus=true]:bg-gray-50 dark:border-white/10 dark:bg-gray-950/40 dark:data-[hover=true]:bg-gray-950/40 dark:data-[focus=true]:bg-gray-950/40 data-[hover=true]:border-blue-300 dark:data-[hover=true]:border-blue-400/50 group-data-[focus=true]:border-blue-500 dark:group-data-[focus=true]:border-blue-400"}}),(0,a.jsx)(o.Y,{type:"number",label:"ends",value:String(v),onValueChange:e=>y({ends:Number(e||el.QK.ends)}),classNames:{label:"text-gray-500 dark:text-gray-300",input:"text-gray-900 dark:text-white",inputWrapper:"border border-gray-200 bg-gray-50 shadow-none data-[hover=true]:bg-gray-50 data-[focus=true]:bg-gray-50 dark:border-white/10 dark:bg-gray-950/40 dark:data-[hover=true]:bg-gray-950/40 dark:data-[focus=true]:bg-gray-950/40 data-[hover=true]:border-blue-300 dark:data-[hover=true]:border-blue-400/50 group-data-[focus=true]:border-blue-500 dark:group-data-[focus=true]:border-blue-400"}})]})]})}):(0,a.jsx)("div",{className:"relative rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 transition-all hover:border-blue-400 dark:border-gray-600 dark:bg-gray-800",onClick:()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.click()},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),j(e.dataTransfer.files)},children:(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-8",children:[(0,a.jsx)("div",{className:"mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700",children:x?(0,a.jsx)(s.Z,{className:"h-8 w-8 animate-spin text-blue-500"}):(0,a.jsx)(_.Z,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})}),(0,a.jsx)("p",{className:"mb-2 text-sm text-gray-600 dark:text-gray-400",children:"Click to upload or drag and drop"}),(0,a.jsx)(d.A,{size:"sm",color:"primary",className:"mt-4",isLoading:x,onPress:()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.click()},children:"Select file"})]})}),(0,a.jsx)("input",{ref:g,type:"file",onChange:e=>j(e.target.files),className:"hidden",accept:el.Tl.join(",")}),m&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:m}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Optional video input. Only 1 video is allowed and it uses 2 image slots."})]})};function eh(e){let{formData:t,errors:r,onFieldChange:l,onUploadStateChange:i}=e,s=(0,el.Fb)(t),n=(0,el.kg)(t);return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(ep,{label:"audio_ids",parameterKey:"audio_ids",value:t.audio_ids,maxItems:el.YY,addLabel:"Add audio ID",note:"Audio ID list. Up to 1 ID is allowed.",error:r.audio_ids,onFieldChange:l}),(0,a.jsx)(eg,{value:t.video_list,onFieldChange:l,onUploadStateChange:i,error:r.video_list}),(0,a.jsx)(ep,{label:"character_ids",parameterKey:"character_ids",value:t.character_ids,maxItems:s,addLabel:"Add character ID",note:"Character ID list. Each character ID uses 1 image slot. Available character slots: ".concat(s,"/").concat(el.oe,". Remaining image slots: ").concat(n,"/").concat(el.oe,"."),error:r.character_ids,onFieldChange:l})]})}function ef(e){let{formData:t,errors:r,onFieldChange:l}=e;return(0,a.jsx)("div",{className:"space-y-6",children:(0,a.jsx)(ep,{label:"audio_ids",parameterKey:"audio_ids",value:t.audio_ids,maxItems:1,addLabel:"Add audio ID",note:"Audio ID list. Up to ".concat(1," IDs are allowed."),error:null==r?void 0:r.audio_ids,onFieldChange:l})})}let eb=[{kieAudioId:"achernar",name:"Achernar",voiceDescription:"Female, soft, high pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Achernar.wav"},{kieAudioId:"achird",name:"Achird",voiceDescription:"Male, friendly, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Achird.wav"},{kieAudioId:"algenib",name:"Algenib",voiceDescription:"Male, gravelly, low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Algenib.wav"},{kieAudioId:"algieba",name:"Algieba",voiceDescription:"Male, easy-going, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Algieba.wav"},{kieAudioId:"alnilam",name:"Alnilam",voiceDescription:"Male, firm, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Alnilam.wav"},{kieAudioId:"aoede",name:"Aoede",voiceDescription:"Female, breezy, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Aoede.wav"},{kieAudioId:"autonoe",name:"Autonoe",voiceDescription:"Female, bright, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Autonoe.wav"},{kieAudioId:"callirrhoe",name:"Callirrhoe",voiceDescription:"Female, easy-going, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Callirrhoe.wav"},{kieAudioId:"charon",name:"Charon",voiceDescription:"Male, informative, lower pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Charon.wav"},{kieAudioId:"despina",name:"Despina",voiceDescription:"Female, smooth, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Despina.wav"},{kieAudioId:"enceladus",name:"Enceladus",voiceDescription:"Male, breathy, lower pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Enceladus.wav"},{kieAudioId:"erinome",name:"Erinome",voiceDescription:"Female, clear, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Erinome.wav"},{kieAudioId:"fenrir",name:"Fenrir",voiceDescription:"Male, excitable, younger pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Fenrir.wav"},{kieAudioId:"gacrux",name:"Gacrux",voiceDescription:"Female, mature, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Gacrux.wav"},{kieAudioId:"iapetus",name:"Iapetus",voiceDescription:"Male, clear, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Iapetus.wav"},{kieAudioId:"kore",name:"Kore",voiceDescription:"Female, firm, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Kore.wav"},{kieAudioId:"laomedeia",name:"Laomedeia",voiceDescription:"Female, upbeat, mid-high pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Laomedeia.wav"},{kieAudioId:"leda",name:"Leda",voiceDescription:"Female, youthful, mid-high pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Leda.wav"},{kieAudioId:"orus",name:"Orus",voiceDescription:"Male, firm, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Orus.wav"},{kieAudioId:"puck",name:"Puck",voiceDescription:"Male, upbeat, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Puck.wav"},{kieAudioId:"pulcherrima",name:"Pulcherrima",voiceDescription:"Ungendered, forward, mid-high pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Pulcherrima.wav"},{kieAudioId:"rasalgethi",name:"Rasalgethi",voiceDescription:"Male, informative, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Rasalgethi.wav"},{kieAudioId:"sadachbia",name:"Sadachbia",voiceDescription:"Male, lively, low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Sadachbia.wav"},{kieAudioId:"sadaltager",name:"Sadaltager",voiceDescription:"Male, knowledgeable, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Sadaltager.wav"},{kieAudioId:"schedar",name:"Schedar",voiceDescription:"Male, even, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Schedar.wav"},{kieAudioId:"sulafat",name:"Sulafat",voiceDescription:"Female, warm, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Sulafat.wav"},{kieAudioId:"umbriel",name:"Umbriel",voiceDescription:"Male, smooth, lower pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Umbriel.wav"},{kieAudioId:"vindemiatrix",name:"Vindemiatrix",voiceDescription:"Female, gentle, mid pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Vindemiatrix.wav"},{kieAudioId:"zephyr",name:"Zephyr",voiceDescription:"Female, bright, mid-high pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Zephyr.wav"},{kieAudioId:"zubenelgenubi",name:"Zubenelgenubi",voiceDescription:"Male, casual, mid-low pitch",preview_url:"https://static.aiquickdraw.com/tools/example/Zubenelgenubi.wav"}],ev=e=>e.startsWith("Female")?"Female":e.startsWith("Male")?"Male":"Other",ey=(()=>{let e={};return eb.forEach(t=>{let r=ev(t.voiceDescription);e[r]||(e[r]=[]),e[r].push({value:t.kieAudioId,label:t.name,description:t.voiceDescription,preview_url:t.preview_url})}),e})(),ej=eb.map(e=>({value:e.kieAudioId,label:e.name,description:e.voiceDescription,preview_url:e.preview_url})),ek=e=>{let t=(e||"").toLowerCase().trim();if(!t)return ey;let r={};
1return Object.entries(ey).forEach(e=>{let[a,l]=e,i=l.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t));i.length>0&&(r[a]=i)}),r};var ew=e=>{let{value:t,onChange:r,placeholder:i="Select a voice",error:n,isInvalid:o,multiple:d=!1,maxItems:c=1,label:u,note:m}=e,[x,p]=(0,l.useState)(!1),[g,h]=(0,l.useState)(""),[f,b]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),[k,w]=(0,l.useState)(null),N=(0,l.useRef)({}),A=(0,l.useRef)(null),S=(0,l.useRef)(null),C=(0,l.useRef)(null),M=(0,l.useRef)(null),I=(0,l.useRef)(null);(0,l.useEffect)(()=>{M.current=f},[f]),(0,l.useEffect)(()=>{I.current=k},[k]);let O=()=>{let e=M.current;if(e){let t=N.current[e];t&&(t.pause(),t.currentTime=0),A.current&&(A.current.pause(),A.current.currentTime=0,A.current=null),b(null)}y(null),w(null),I.current=null};(0,l.useEffect)(()=>{let e=e=>{S.current&&!S.current.contains(e.target)&&C.current&&!C.current.contains(e.target)&&(O(),p(!1),h(""))};if(x)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[x]);let _=(0,l.useMemo)(()=>ek(g),[g]),F=(0,l.useMemo)(()=>d&&Array.isArray(t)?t:t?[t]:[],[t,d]),E=(0,l.useMemo)(()=>F.map(e=>ej.find(t=>t.value===e)).filter(Boolean),[F]),P=e=>F.includes(e),T=!d||F.length<c,L=(e,t,r)=>{if(r.preventDefault(),r.stopPropagation(),I.current===t)return;if(I.current=t,f&&f!==e){let e=N.current[f];e&&(e.pause(),e.currentTime=0),A.current&&(A.current.pause(),A.current.currentTime=0,A.current=null)}w(t);let a=N.current[e];if(a)A.current=null;else{let t=ej.find(t=>t.value===e);(null==t?void 0:t.preview_url)&&(a=new Audio(t.preview_url),N.current[e]=a,a.addEventListener("ended",()=>{b(null),y(null)}),A.current=a)}if(!a){w(null),I.current=null;return}if(v===t)a.pause(),a.currentTime=0,w(null),I.current=null,b(null),y(null),A.current===a&&(A.current=null);else{f===e&&(a.currentTime=0);let r=a.play();void 0!==r?r.then(()=>{w(null),I.current=null,b(e),y(t)}).catch(()=>{w(null),I.current=null,b(null),y(null),A.current===a&&(A.current=null)}):(w(null),I.current=null,b(e),y(t))}},D=e=>{if(d){let t;if(P(e))t=F.filter(t=>t!==e);else{if(!T)return;t=[...F,e]}r(t)}else r(e),O(),p(!1),h("")},R=(e,t)=>{t.stopPropagation(),d?r(F.filter(t=>t!==e)):r("")};return(0,a.jsxs)("div",{className:"w-full",children:[u&&(0,a.jsxs)("label",{className:"mb-1 block text-sm font-medium text-default-700",children:[u," ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"relative w-full",children:[(0,a.jsxs)("div",{ref:C,onClick:()=>p(!x),className:"flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ".concat(o||n?"border-red-500 focus-within:border-red-500 focus-within:ring-red-500 dark:border-red-400 dark:focus-within:border-red-400 dark:focus-within:ring-red-400":"border-gray-300 bg-white focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-blue-400 dark:focus-within:ring-blue-400"),children:[(()=>{if(0===E.length)return(0,a.jsx)("div",{className:"flex-1 text-sm text-default-500",children:i});if(!d){let e=E[0];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-blue-500/10 text-blue-500",children:(0,a.jsx)(j.JO,{icon:"mdi:volume-high",className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"line-clamp-1 text-sm font-medium text-default-700",children:e.label}),e.description&&(0,a.jsx)("div",{className:"text-xs text-default-500",children:e.description})]})]})}return(0,a.jsxs)("div",{className:"flex flex-1 flex-wrap gap-1",children:[E.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-300",children:[e.label,(0,a.jsx)("button",{type:"button",onClick:t=>R(e.value,t),className:"ml-0.5 hover:text-blue-900 dark:hover:text-blue-100",children:(0,a.jsx)(j.JO,{icon:"mdi:close",className:"h-3 w-3"})})]},e.value)),T&&(0,a.jsxs)("span",{className:"text-xs text-default-400",children:[F.length,"/",c]})]})})(),(0,a.jsx)(j.JO,{icon:x?"mdi:chevron-up":"mdi:chevron-down",className:"h-5 w-5 text-gray-400"})]}),x&&(0,a.jsxs)("div",{ref:S,className:"absolute z-[21] mt-2 w-full rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-600 dark:bg-gray-700",children:[(0,a.jsx)("div",{className:"border-b border-gray-200 p-3 dark:border-gray-600",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(j.JO,{icon:"mdi:magnify",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),(0,a.jsx)("input",{type:"text",value:g,onChange:e=>h(e.target.value),placeholder:"Search voices...",className:"w-full rounded-lg border border-gray-300 bg-white px-10 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder:text-gray-500 dark:focus:border-blue-400 dark:focus:ring-blue-400",onClick:e=>e.stopPropagation()})]})}),(0,a.jsx)("div",{className:"max-h-80 overflow-y-auto",children:0===Object.keys(_).length?(0,a.jsx)("div",{className:"p-4 text-center text-sm text-default-500",children:"No voices found"}):Object.entries(_).map(e=>{let[t,r]=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"bg-default-400/10 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-default-500",children:t}),r.map((e,r)=>{let l="".concat(t,"-").concat(e.value,"-").concat(r),i=P(e.value),n=v===l,o=k===l,c=e.preview_url,u=d&&!i&&!T;return(0,a.jsxs)("div",{className:"flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors ".concat(u?"cursor-not-allowed opacity-50":"hover:bg-gray-50 dark:hover:bg-gray-600"," ").concat(n?"bg-blue-50 dark:bg-blue-900/30":i?"bg-blue-50 dark:bg-blue-900/20":""),children:[(0,a.jsxs)("div",{onClick:()=>!u&&D(e.value),className:"flex flex-1 items-center gap-3",children:[(0,a.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-medium ".concat(i?"bg-blue-500 text-white":"bg-default-200 text-default-500"),
1children:i&&d?(0,a.jsx)(j.JO,{icon:"mdi:check",className:"h-4 w-4"}):e.label.charAt(0)}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-default-700",children:e.label}),i&&!d&&(0,a.jsx)(j.JO,{icon:"mdi:check",className:"h-4 w-4 text-blue-500"})]}),e.description&&(0,a.jsx)("div",{className:"text-[10px] text-default-500",children:e.description})]})]}),c&&(0,a.jsx)("button",{type:"button",disabled:o,onClick:t=>L(e.value,l,t),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border transition-colors ".concat(o?"cursor-not-allowed border-gray-300 bg-gray-100 opacity-70 dark:border-gray-600 dark:bg-gray-600":n?"border-blue-500 bg-blue-500 text-white hover:bg-blue-600 dark:border-blue-400 dark:bg-blue-500 dark:text-white dark:hover:bg-blue-600":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600"),children:o?(0,a.jsx)(s.Z,{className:"h-4 w-4 animate-spin text-blue-500"}):(0,a.jsx)(j.JO,{icon:n?"mdi:pause":"mdi:play",className:"h-4 w-4"})})]},l)})]},t)})})]})]}),m&&!n&&(0,a.jsx)("p",{className:"mt-1 text-xs text-default-500",children:m}),n&&(0,a.jsx)("p",{className:"mt-1 text-sm text-red-500 dark:text-red-400",children:n})]})},eN=r(44568);let eA=["Form","JSON"],eS=e=>{var t;let r=null===(t=e.props)||void 0===t?void 0:t.parameterKey;return"PlaygroundKlingShots"!==e.type?r:(0,eN.iU)(e.props)};var eC=(0,m.Pi)(function(e){let{onGenerator:t,generating:r,formContent:m=[],consumeCredit:g=0,onChangeOption:h,model:b,creditLoading:y,handlePageNavigation:j,linkageRules:k=[]}=e,[N,A]=(0,l.useState)("Form"),[S,M]=(0,l.useState)({}),[O,_]=(0,l.useState)({}),[F,E]=(0,l.useState)([]),[P,T]=(0,l.useState)(0),L=(0,el.Kl)(b),D=null==b?void 0:b.endsWith("gemini-omni-character"),U=null==b?void 0:b.endsWith("gemini-omni-audio"),{userStore:z}=(0,u.o)(),{isOpen:V,onOpen:K,onClose:q}=(0,n.q)(),B=(0,l.useRef)(null),W=(0,l.useRef)(null),J=(0,l.useRef)(h);(0,l.useEffect)(()=>{J.current=h},[h]);let H=(0,l.useCallback)(e=>{W.current=e,B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{J.current&&W.current&&J.current(W.current),B.current=null},1500)},[]),Y=(0,l.useMemo)(()=>{let e=m;return L&&(e=(0,el.V9)(e,S)),e},[m,S,L]),$=(0,l.useMemo)(()=>k&&0!==k.length?Y.map(e=>{var t;let r=eS(e)||(null===(t=e.props)||void 0===t?void 0:t.parameterKey),{patchProps:a}=(0,R.Gc)(r,k,S);return a?{...e,props:{...e.props,...a}}:e}):Y,[Y,k,S]),X=(0,l.useMemo)(()=>S,[S]),Q=(0,l.useMemo)(()=>D?{audio_ids:{type:"array",description:"Audio ID list. Up to ".concat(1," IDs are allowed."),maxItems:1,items:{type:"string"}}}:{},[D]),ee=(0,l.useMemo)(()=>U?{audio_id:{type:"string",description:"Select a preset voice for audio generation."}}:{},[U]),et=(0,l.useMemo)(()=>L?{audio_ids:{type:"array",description:"Audio ID list. Up to 3 IDs are allowed.",maxItems:el.YY,items:{type:"string"}},video_list:{type:"array",description:"Optional video input. Only 1 video is allowed.",maxItems:el.cH,items:{type:"object",required:["url","start","ends"],properties:{url:{type:"string",format:"uri"},start:{type:"number"},ends:{type:"number"}}}},character_ids:{type:"array",description:"Character ID list. Each character_id uses 1 image slot.",maxItems:(0,el.Fb)(S),items:{type:"string"}}}:{},[S,L]),er=()=>{let e=(0,p.Fx)(m);L&&(e.audio_ids=[],e.video_list=el.$k.map(e=>({...e})),e.character_ids=[],e.image_urls=[...el.Ac]),U&&(e.audio_id=""),M(t=>({...t,...e})),_({})};l.useEffect(()=>{er()},[b]);let ea=(e,t)=>{if(M(r=>L?(0,el.LH)(r,e,t):D&&"audio_ids"===e?{...r,audio_ids:(0,el._6)(t,1)}:U&&"audio_id"===e?{...r,audio_id:t}:{...r,[e]:t}),"sora-2-characters-pro"==b&&("timestamps_start"===e||"timestamps_end"===e)&&O.timestamps){let r="timestamps_start"===e?t:S.timestamps_start,a="timestamps_end"===e?t:S.timestamps_end,l=parseFloat(r),i=parseFloat(a);null!=r&&""!==r&&null!=a&&""!==a&&!isNaN(l)&&!isNaN(i)&&i>l&&i-l>=1&&i-l<=4&&_(e=>({...e,timestamps:""}))}O[e]&&_(t=>({...t,[e]:""}))};(0,l.useEffect)(()=>
1{if(!k||0===k.length)return;let e={};Y.forEach(t=>{let r=eS(t);if(!r)return;let{forcedValue:a}=(0,R.Gc)(r,k,S);void 0!==a&&(Object.is(S[r],a)||(e[r]=a))}),0!==Object.keys(e).length&&M(t=>{let r=!1,a={...t};return Object.entries(e).forEach(e=>{let[l,i]=e;Object.is(t[l],i)||(a[l]=i,r=!0)}),r?a:t})},[Y,S,k]),(0,l.useEffect)(()=>{if(!k||0===k.length)return;let e={};Y.forEach(t=>{var r;let a=null===(r=t.props)||void 0===r?void 0:r.parameterKey;if(!a)return;let{patchProps:l}=(0,R.Gc)(a,k,S);if(!l)return;let i=S[a];if("PlaygroundFileUpload"===t.type){if(void 0===l.multiple&&void 0===l.limitFile)return;let r={...t.props,...l},s=(0,p.J1)(r,i);s!==i&&(e[a]=s);return}if("number"!=typeof i)return;let s=i;"number"==typeof l.max&&s>l.max&&(s=l.max),"number"==typeof l.min&&s<l.min&&(s=l.min),s!==i&&(e[a]=s)}),0!==Object.keys(e).length&&M(t=>{let r=!1,a={...t};return Object.entries(e).forEach(e=>{let[l,i]=e;Object.is(t[l],i)||(a[l]=i,r=!0)}),r?a:t})},[Y,S,k]),(0,l.useEffect)(()=>{if(!k||0===k.length)return;let e=(0,p.Fx)(Y),t=[],r={};Y.forEach(a=>{var l;let i=eS(a)||(null===(l=a.props)||void 0===l?void 0:l.parameterKey);if(!i)return;let{visible:s}=(0,R.Gc)(i,k,S),n=Object.prototype.hasOwnProperty.call(S,i);!s&&n?t.push(i):s&&!n&&Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}),(0!==t.length||0!==Object.keys(r).length)&&M(e=>{let a={...e},l=!1;return t.forEach(e=>{Object.prototype.hasOwnProperty.call(a,e)&&(delete a[e],l=!0)}),Object.entries(r).forEach(e=>{let[t,r]=e;Object.prototype.hasOwnProperty.call(a,t)||(a[t]=r,l=!0)}),l?a:e})},[k,JSON.stringify(S)]),(0,l.useEffect)(()=>{k&&0!==k.length&&Y.forEach(e=>{var t;let r=e.type;if("PlaygroundSelect"!==r&&"PlaygroundRadio"!==r)return;let a=null===(t=e.props)||void 0===t?void 0:t.parameterKey;if(!a)return;let{disabledOptions:l}=(0,R.Gc)(a,k,S);if(!Array.isArray(l)||0===l.length)return;let i=S[a];if(!l.includes(i))return;let s="PlaygroundSelect"===r?e.props.selectOption:e.props.radioOptions,n=null==s?void 0:s.find(e=>!l.includes(e.value));n&&ea(a,n.value)})},[k,JSON.stringify(S)]);let ei=()=>{var e;let t={};if(Y.forEach(e=>{var r,a,l,i,s,n,o,d,c,u,m,x;let p=eS(e)||(null===(r=e.props)||void 0===r?void 0:r.parameterKey),{visible:g,patchProps:h}=(0,R.Gc)(p,k,S);if(!g)return;let b=h?{...e.props,...h}:e.props;if("PlaygroundFrameUploader"===e.type){let e=(0,f.RV)(b),{primaryKey:r,secondaryKey:n}=(0,f.LB)(b),o=S[r],d=S[n],c=e[0],u=e[1];if(null==c?void 0:c.required){if("single"===b.fieldMode){let e=Array.isArray(o)?o[0]:void 0;(0,f.q$)(e)||(t[r]=(null===(a=b.error)||void 0===a?void 0:a.required)||"".concat(r," is required"))}else(0,f.q$)(o)||(t[r]=(null===(l=b.error)||void 0===l?void 0:l.required)||"".concat(r," is required"))}if(null==u?void 0:u.required){if("single"===b.fieldMode){let e=Array.isArray(o)?o[1]:void 0;(0,f.q$)(e)||(t[r]=(null===(i=b.error)||void 0===i?void 0:i.required)||"".concat(r," is required"))}else(0,f.q$)(d)||(t[n]=(null===(s=b.error)||void 0===s?void 0:s.required)||"".concat(n," is required"))}return}let v=S[b.parameterKey],y=b.parameterKey;if(b.required&&"PlaygroundSwitch"!==e.type&&(!v||"string"==typeof v&&""===v.trim())&&(t[y]=(null===(n=b.error)||void 0===n?void 0:n.required)||"".concat(y," is required")),b.minLength&&b.minLength>0&&"string"==typeof v&&v.trim()&&v.length<=b.minLength&&(t[y]=(null===(o=b.error)||void 0===o?void 0:o.minLength)||"Minimum length is ".concat(b.minLength)),b.maxLength&&"string"==typeof v&&(null==v?void 0:v.length)>b.maxLength&&(t[y]=(null===(d=b.error)||void 0===d?void 0:d.maxLength)||"Maximum length is ".concat(b.maxLength)),b.maxFileSize&&v instanceof File&&v.size>b.maxFileSize&&(t[y]=(null===(c=b.error)||void 0===c?void 0:c.fileSize)||"File size cannot exceed ".concat(b.maxFileSize/1024/1024,"MB")),"PlaygroundArrayForm"===e.type){let e=Array.isArray(v)?v:[];b.required&&0===e.length?t[y]=(null===(u=b.error)||void 0===u?void 0:u.required)||"".concat(y," is required"):b.minLength&&e.length<b.minLength?t[y]=(null===(m=b.error)||void 0===m?void 0:m.minLength)||"Please add at least ".concat(b.minLength," items"):b.maxLength&&b.maxLength>0&&e.length>b.maxLength&&(t[y]=(null===(x=b.error)||void 0===x?void 0:x.maxLength)||"Maximum ".concat(b.maxLength," items allowed"))}}),D&&(0,el._6)(S.audio_ids,Number.POSITIVE_INFINITY).length>1&&(t.audio_ids="Maximum ".concat(1," audio ID(s) allowed")),L){(0,el._6)(S.audio_ids,Number.POSITIVE_INFINITY).length>el.YY&&(t.audio_ids="Maximum ".concat(el.YY," audio ID(s) allowed"));let e=(0,el.CR)(S.video_list,Number.POSITIVE_INFINITY);e.length>el.cH&&(t.video_list="Maximum ".concat(el.cH," video(s) allowed")),e.forEach(e
1=>{Number(e.ends)<=Number(e.start)&&(t.video_list="Video ends must be greater than start")});let r=(0,el.Fb)(S);(0,el._6)(S.character_ids,Number.POSITIVE_INFINITY).length>r&&(t.character_ids="Maximum ".concat(r," character ID(s) allowed"));let a=(0,el.kg)(S);(0,el._6)(S.image_urls,Number.POSITIVE_INFINITY).length>a&&(t.image_urls="Maximum ".concat(a," image(s) allowed"))}if("sora-2-characters-pro"==b){let e=S.timestamps_start,r=S.timestamps_end,a=parseFloat(e),l=parseFloat(r);if(""===e||null==e)t.timestamps="Please enter the start time";else if(""===r||null==r)t.timestamps="Please enter the end time";else if(isNaN(a)||isNaN(l))t.timestamps="Please enter valid numbers";else if(l<=a)t.timestamps="End time must be greater than start time";else{let e=l-a;(e<1||e>4)&&(t.timestamps="The difference between end and start must be between 1 and 4 seconds")}}return Y.forEach(e=>{if("PlaygroundUniversalForm"===e.type){let r=eS(e)||e.props.parameterKey,{visible:a,patchProps:l}=(0,R.Gc)(r,k,S);if(!a)return;let i=l?{...e.props,...l}:e.props,s=S[r],n=(0,G.Ok)(i,s);if(!n.ok){if(n.message)t[r]=n.message;else{let e=Object.keys(n.errors)[0];e&&(t[r]=n.errors[e])}}}}),_(t),(null===(e=Object.keys(t))||void 0===e?void 0:e.length)===0},es=async()=>{if(!z.user){K();return}if("sora-2-characters"==b&&(null==F?void 0:F.length)===0){c.Am.error("please upload at least one video");return}if(ei()){let e=S.shots,r=(0,p.HU)(S,$);if(L&&(r=(0,el.wR)({...S,...r})),D){let e=(0,el._6)(S.audio_ids,1);e.length>0?r.audio_ids=e:delete r.audio_ids}if(U&&(S.audio_id?r.audio_id=S.audio_id:delete r.audio_id),S.voice&&((null==b?void 0:b.includes("elevenlabs"))||(null==b?void 0:b.includes("text-to-speech")))&&(r.voice=S.voice),"sora-2-pro-storyboard"==b&&(r.shots=e),"sora-2-characters"==b){t(r,async e=>{try{let t=await C(F);return ea("character_file_url",t),e.character_file_url=t,e}catch(e){throw Error(e.message||"è§é¢ä¸ä¼ 失败ï¼è¯·éè¯")}});return}if("sora-2-characters-pro"==b){let e=S.timestamps_start,t=S.timestamps_end;null!=e&&""!==e&&null!=t&&""!==t&&(r.timestamps="".concat(e,",").concat(t))}t(r)}else c.Am.error("Form validation failed")},en=(0,l.useMemo)(()=>Y.map(e=>{if(["PlaygroundSwitch","PlaygroundRadio","PlaygroundSelect","PlaygroundFileUpload","PlaygroundInput","PlaygroundTextarea","PlaygroundSlider","PlaygroundArrayForm"].includes(e.type))return e.props.parameterKey}),[Y]),eo=(0,l.useMemo)(()=>{let e=b+"/n";return en.forEach(t=>{e+=S[t]}),L&&(e+=JSON.stringify({audio_ids:S.audio_ids,video_list:S.video_list,character_ids:S.character_ids})),U&&(e+=S.audio_id||""),e},[S,en,b,L,U]);(0,l.useEffect)(()=>{L?H((0,el.wR)(S)):H(S)},[eo,z.user,H,L,S]);let ed=(0,l.useCallback)(e=>{if(L){M((0,el.px)(e));return}if(D){M({...e,audio_ids:(0,el._6)(e.audio_ids,1)});return}if(U){M({...e,audio_id:e.audio_id||""});return}M(e)},[S,U,D,L]);return(0,l.useEffect)(()=>()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsx)("div",{className:"border-b border-gray-200 p-4 dark:border-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Input"}),(0,a.jsx)("div",{className:"flex rounded-lg bg-gray-100 p-1 dark:bg-gray-700",children:eA.map(e=>(0,a.jsx)("button",{onClick:()=>A(e),className:"".concat(N===e?"bg-white text-gray-900 shadow-sm dark:bg-gray-600 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"," rounded-md px-3 py-1.5 text-sm font-medium transition-all"),children:e},e))})]})}),(0,a.jsxs)("div",{className:"space-y-6 p-6 pb-0 ".concat("Form"===N?"block":"hidden"),children:["sora-2-pro-storyboard"==b&&(0,a.jsx)(w,{duration:S.n_frames,handleFieldChange:ea}),"sora-2-characters"==b&&(0,a.jsx)(I,{videos:F,onChange:e=>{E(e),ea("character_file_url",e.map(e=>e.url).filter(e=>e))}}),U&&(0,a.jsx)(ew,{label:"audio_id",value:S.audio_id||"",onChange:e=>ea("audio_id",e),placeholder:"Select a voice",error:null==O?void 0:O.audio_id,note:"Basic Voice"}),Y.map((e,t)=>{var r,i;let s;let n=Z[e.type];if(!n)return console.warn("Unknown form component type: ".concat(e.type)),null;let d=S[e.props.parameterKey],c=S[e.props.secondaryParameterKey]||void 0,u=eS(e)||e.props.parameterKey;if("PlaygroundFrameUploader"===e.type){let{primaryKey:t,secondaryKey:r}=(0,f.LB)(e.props);d=S[t],c=S[r]||void 0,"dual"===e.props.fieldMode&&(s=O[r])}let m=!!e.props.isReadOnly,{visible:x,disabled:p,disabledOptions:g,patchProps:h,forcedValue:v}=(0,R.Gc)(u,k,S);if(!x)return null;let y=void 0!==v?v:d,j=void 0!==h?{...e.props,...h}:e.props;return(0,a.jsxs)(l.Fragment,{children:[(0,a.jsx)(n,{field:j,value:y,secondaryValue:c,onChange:ea,error:O[u],secondaryError:s,isReadOnly:m||p,disabledOptions:g,formData:S,linkageRules:k,onUploadStateChange:"PlaygroundFileUpload"===e.type||"PlaygroundFrameUploader"===e.type||"PlaygroundUniversalForm"===e.type||"PlaygroundKlingShots"===e.type?e=>T(t=>t+e):void 0}
1),L&&"image_urls"===e.props.parameterKey&&(0,a.jsx)(eh,{formData:S,errors:O,onFieldChange:ea,onUploadStateChange:e=>T(t=>t+e)}),D&&"image_urls"===e.props.parameterKey&&(0,a.jsx)(ef,{formData:S,errors:O,onFieldChange:ea}),"sora-2-characters-pro"==b&&"origin_task_id"==e.props.parameterKey&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:["Video Timestamps ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"flex items-stretch gap-3",children:[(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsx)(o.Y,{type:"number",step:"0.01",min:"0",placeholder:"Start (e.g. 3.55)",value:null!==(r=S.timestamps_start)&&void 0!==r?r:"",onValueChange:e=>ea("timestamps_start",e),isInvalid:!!O.timestamps,classNames:{input:"text-gray-900 dark:text-white",inputWrapper:"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700"}})}),(0,a.jsx)("span",{className:"flex shrink-0 items-center text-gray-500 dark:text-gray-400",children:"â"}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsx)(o.Y,{type:"number",step:"0.01",min:"0",placeholder:"End (e.g. 5.55)",value:null!==(i=S.timestamps_end)&&void 0!==i?i:"",onValueChange:e=>ea("timestamps_end",e),isInvalid:!!O.timestamps,classNames:{input:"text-gray-900 dark:text-white",inputWrapper:"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700"}})})]}),O.timestamps&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:O.timestamps}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Enter the clip's start and end times in seconds. The segment you select must be completely inside the original video and between 1 sâ4 s long; that slice will be used as the character's training material."})]})]},"".concat(b,"-").concat(u,"-").concat(e.props.id||t))}),(0,a.jsxs)("div",{className:"sticky bottom-0 z-20 flex items-center justify-end gap-3 border-t border-gray-200 bg-white pb-6 pt-4 dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsx)(d.A,{variant:"bordered",onPress:er,className:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-600",children:"Reset"}),(0,a.jsxs)(d.A,{color:"primary",onPress:es,isDisabled:r||P>0,isLoading:r,className:"bg-blue-500 text-white hover:bg-blue-400",children:[!!g&&"bytedance/seedance-2-asset"!==b&&!D&&!(null==b?void 0:b.endsWith("gemini-omni-audio"))&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-white opacity-80",children:[(0,a.jsx)(i.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:y?(0,a.jsx)(s.Z,{className:"h-4 w-4 animate-spin text-white"}):g})]}),"Run"]})]})]}),(0,a.jsx)("div",{className:"space-y-6 p-6 ".concat("JSON"===N?"block":"hidden"),children:(0,a.jsx)(v,{value:X,onChange:ed,formContent:Y,extraSchemaProperties:{...et,...Q,...ee},height:300})})]}),(0,a.jsx)(x.default,{isOpen:V,onClose:q,onLoginSuccess:()=>{z.loadUserInfo()}})]})})},49787:function(e,t,r){r.d(t,{Z:function(){return A}});var a=r(39696),l=r(90170),i=r(43118),s=r(92678),n=r(63698),o=r(35351),d=r(12893),c=r(85717),u=r(44300),m=r(42370),x=r(79399),p=r(80356),g=r(32324),h=r(68237),f=r(26716),b=r(25043),v=r.n(b),y=r(18492),j=r(36380),k=r.n(j);let w=v()(()=>Promise.resolve().then(r.bind(r,99245)),{loadableGenerated:{webpack:()=>[99245]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"flex h-64 items-center justify-center rounded-lg border border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700",children:(0,a.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading JSON viewer..."})})}),N=["Preview","JSON"];function A(e){let{record:t,generating:r,mediaType:b,resultData:v,progressDuration:j=180,resultObjectText:A,model:S}=e,C=(0,h.useRouter)(),[M,I]=(0,l.useState)("Preview"),[O,_]=(0,l.useState)(!1),[F,E]=(0,l.useState)(0),[P,T]=(0,l.useState)(0),[L,D]=(0,l.useState)(!1),[R,U]=(0,l.useState)(!1),z=(0,l.useRef)(null),V=(null==S?void 0:S.endsWith("gemini-omni-character"))||(null==S?void 0:S.endsWith("gemini-omni-audio")),K=(e,t)=>{z.current=t,t.editor.defineTheme("custom-dark",{base:"vs-dark",inherit:!0,rules:[{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"number.json",foreground:"B5CEA8"},{token:"keyword.json",foreground:"569CD6"}
1],colors:{"editor.background":"#374151","editor.foreground":"#F3F4F6","editorLineNumber.foreground":"#6B7280","editor.selectionBackground":"#4B5563","editor.inactiveSelectionBackground":"#374151"}}),t.editor.defineTheme("custom-light",{base:"vs",inherit:!0,rules:[{token:"string.key.json",foreground:"0451A5"},{token:"string.value.json",foreground:"A31515"},{token:"number.json",foreground:"098658"},{token:"keyword.json",foreground:"0000FF"}],colors:{"editor.background":"#F9FAFB","editor.foreground":"#1F2937","editorLineNumber.foreground":"#9CA3AF","editor.selectionBackground":"#E5E7EB","editor.inactiveSelectionBackground":"#F3F4F6"}}),t.editor.setTheme(R?"custom-dark":"custom-light")},q=e=>{try{if(!e)return"";let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(t){return e||""}};(0,l.useEffect)(()=>{if((null==t?void 0:t.state)==="generating"||(null==t?void 0:t.state)==="waiting"){if(null==t?void 0:t.progress){T(Math.max(0,Math.min(null==t?void 0:t.progress,99)));return}let e=setInterval(()=>{T(Math.max(0,Math.min((Date.now()-(null==t?void 0:t.createTime))/1e3/j*99,99)))},100);return()=>clearInterval(e)}T(0)},[null==t?void 0:t.state,j,null==t?void 0:t.createTime,null==t?void 0:t.progress]);let B=(()=>{if((null==t?void 0:t.state)==="success"&&(null==t?void 0:t.resultJson))try{let e=JSON.parse(t.resultJson);if("text"==b)return{outputMediaType:b,outputPrompt:JSON.stringify(e.resultObject,null,2),parsedResultJson:e};if(null==e?void 0:e.resultUrls){let t;let r=e.resultUrls;if((null==r?void 0:r.length)>0){let e=r[0];e&&(e.includes(".mp4")||e.includes(".webm")||e.includes(".mov")?t="video":e.includes(".mp3")||e.includes(".wav")||e.includes(".m4a")?t="audio":(e.includes(".webp")||e.includes(".png")||e.includes(".jpg")||e.includes(".jpeg"))&&(t="image"))}return{outputMediaType:t,outputMediaUrls:r.map(e=>({mediaUrl:e})),parsedResultJson:e}}}catch(e){console.error("Failed to parse resultJson:",e)}return{outputMediaType:b,outputMediaUrls:v,outputPrompt:A}})(),W=B.outputMediaType,Z=B.outputMediaUrls,J=B.outputPrompt,G=(null==t?void 0:t.createTime)!=null&&(null==t?void 0:t.completeTime)!=null?(Number(t.completeTime)-Number(t.createTime))/1e3:NaN,H=(null==t?void 0:t.state)==="success"&&Number.isFinite(G)&&G>=0,Y=async()=>{if(Z&&0!==Z.length){D(!0);try{if(1===Z.length)await (0,f.$)(Z[0].mediaUrl);else for(let e=0;e<Z.length;e++)await (0,f.$)(Z[e].mediaUrl),e<Z.length-1&&await new Promise(e=>setTimeout(e,500))}catch(e){console.error("Download failed:",e)}finally{D(!1)}}},$=async()=>{if(Z&&0!==Z.length){D(!0);try{await (0,f.$)(Z[F].mediaUrl)}catch(e){console.error("Download failed:",e)}finally{D(!1)}}},X=()=>(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,a.jsx)("div",{className:"mb-6 flex items-center justify-center",children:(0,a.jsx)("div",{className:"rounded-full bg-red-100 p-3 dark:bg-red-900/20",children:(0,a.jsx)(s.Z,{className:"h-12 w-12 text-red-500"})})}),(0,a.jsx)("h3",{className:"mb-2 text-lg font-semibold text-gray-900 dark:text-white",children:"Generation Failed"}),(0,a.jsx)("p",{className:"mb-4 text-sm text-gray-500 dark:text-gray-400",children:"Something went wrong while processing your request"}),(null==t?void 0:t.failMsg)&&(0,a.jsx)("div",{className:"w-full max-w-md rounded-lg border border-red-200 bg-red-50 p-4 dark:border-red-800 dark:bg-red-900/20",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(s.Z,{className:"mr-2 mt-0.5 h-4 w-4 flex-shrink-0 text-red-500"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-red-800 dark:text-red-400",children:"Error Details"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-red-700 dark:text-red-300",children:t.failMsg})]})]})}),(0,a.jsxs)("div",{className:"mt-6 flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"h-2 w-2 rounded-full bg-red-400"}),(0,a.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Failed"})]})]}),Q=(e,r)=>{switch(W){case"image":return(0,a.jsx)("div",{className:"group relative",children:(0,a.jsxs)("div",{className:"relative max-h-[1000px] w-full overflow-auto rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-600 dark:bg-gray-900/30",children:[(0,a.jsx)(k(),{width:960,height:100,qual
1ity:(null==t?void 0:t.taskId)?0:85,src:e,alt:"Generated output",className:"block h-auto w-full object-contain"}),(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute bottom-2 right-2 bg-white/80 opacity-0 transition-opacity group-hover:opacity-100 dark:bg-gray-800/80",onClick:$,isDisabled:L,children:L?(0,a.jsx)(i.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(o.Z,{className:"h-4 w-4"})})]})});case"video":return(0,a.jsx)("div",{className:"group relative",children:(0,a.jsxs)("div",{className:"relative h-auto w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-600",children:[(0,a.jsx)("video",{src:e,controls:!0,className:"w-full",onPlay:()=>_(!0),onPause:()=>_(!1),children:"Your browser does not support the video tag."}),(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute bottom-2 right-2 bg-white/80 opacity-0 transition-opacity group-hover:opacity-100 dark:bg-gray-800/80",onClick:$,isDisabled:L,children:L?(0,a.jsx)(i.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(o.Z,{className:"h-4 w-4"})})]})});case"audio":return(0,a.jsx)("div",{className:"group relative",children:(0,a.jsxs)("div",{className:"aspect-video w-full rounded-lg border border-gray-200 bg-gray-50 p-6 dark:border-gray-600 dark:bg-gray-700",children:[(0,a.jsx)("div",{className:"flex items-center justify-center space-x-4",children:(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)("audio",{src:e,controls:!0,className:"w-full",onPlay:()=>_(!0),onPause:()=>_(!1),children:"Your browser does not support the audio tag."})})}),(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute bottom-2 right-2 bg-white/80 dark:bg-gray-800/80",onClick:$,isDisabled:L,children:L?(0,a.jsx)(i.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(o.Z,{className:"h-4 w-4"})})]})});case"text":return(0,a.jsx)("div",{className:"group relative",children:(0,a.jsx)("div",{className:"rounded-lg border border-gray-200 dark:border-gray-600",children:(0,a.jsx)(w,{height:320,language:"json",value:q(r),onMount:K,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,tabSize:2,wordWrap:"on",lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},padding:{top:8,bottom:8},roundedSelection:!1,scrollbar:{vertical:"auto",horizontal:"auto"},contextmenu:!1,selectOnLineNumbers:!1,automaticLayout:!0}})})});default:return(0,a.jsx)("div",{className:"flex h-64 items-center justify-center rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-600 dark:bg-gray-700",children:(0,a.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"䏿¯æçåªä½ç±»å"})})}};return(0,a.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsx)("div",{className:"border-b border-gray-200 p-4 dark:border-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Output"}),(0,a.jsx)("div",{className:"flex rounded-lg bg-gray-100 p-1 dark:bg-gray-700",children:N.map(e=>(0,a.jsx)("button",{onClick:()=>I(e),className:"".concat(M===e?"bg-white text-gray-900 shadow-sm dark:bg-gray-600 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"," rounded-md px-3 py-1.5 text-sm font-medium transition-all"),children:e},e))})]})}),"Preview"===M&&(0,a.jsx)("div",{className:"p-6",children:V?(()=>{if((null==t?void 0:t.state)==="generating"||(null==t?void 0:t.state)==="waiting")return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-16",children:[(0,a.jsx)(i.Z,{className:"h-10 w-10 animate-spin text-blue-500"}),(0,a.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading..."})]});if((null==t?void 0:t.state)==="fail")return X();if((null==t?void 0:t.state)==="success"&&(null==t?void 0:t.resultJson)){let e=q(t.resultJson);return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Result"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"h-2 w-2 rounded-full bg-green-400"}),(0,a.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Complete"})]})]}),(0,a.jsx)("div",{className:"overflow-hidden rounded-lg",children:(0,a.jsx)(w,{height:320,language:"json",value:e,onMount:K,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,tabSize:2,wordWrap:"on",lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},padding:{top:8,bottom:8},roundedSelection:!1,scrollbar:{vertical:"auto",horizontal:"auto"},contextmenu:!1,selectOnLineNumbers:!1,automaticLayout:!0}})}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(p.e,{content:"Copy",children:(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"solid",onPress:()=>{navigator.clipboard.writeText(e),y.ZP.success("Copied successfully!")},children:(0,a.jsx)(n.Z,{className:"h-4 w-4"})})})})]})}return(0,a.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,a.jsx)("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:"No result yet. Click generate to start."})})})():(null==t?void 0:t.state)==="generating"||(null==t?void 0:t.state)==="waiting"?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,a.jsx)("div",{className:"mb-6 flex items-center justify-center",children:(0,a.jsx)(i.Z,{className:"h-12 w-12 animate-spin text-blue-500"})}),(0,a.jsx)("h3",{className:"mb-2 text-lg font-semibold text-gray-900 dark:text-white",children:"Generating content..."}),(0,a.jsx)("p",{className:"mb-6 text-sm text-gray-500 dark:text-gray-400",children:"Please wait while we process your request"}),(0,a.jsxs)("div",{className:"w-full max-w-md",children:[(0,a.jsx)("div",{className:"mb-2 flex items-center justify-between text-sm",children:(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Progress"})}),(0,a.jsx)(x.W,{value:P,className:"w-full",color:"primary",size:"md"}),(0,a.jsxs)("div",{className:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400",children:[P.toFixed(0),"% complete"]})]}),(0,a.jsxs)("div",{className:"mt-6 flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-400"}),(0,a.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Processing"})]})]}):(null==t?void 0:t.state)==="fail"?X():(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"output type"}),(0,a.jsx)("span",{className:"rounded-full bg-blue-100 px-2 py-1 text-xs font-medium text-blue-800 dark:bg-blue-900/20 dark:text-blue-400",children:W})]}),(null==Z?void 0:Z.length)>1&&(0,a.jsxs)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[F+1," / ",null==Z?void 0:Z.length]})]}),(0,a.jsx)("div",{className:"mb-6",children:"text"!==b&&(null==Z?void 0:Z.length)===0?(0,a.jsx)("div",{className:"flex h-64 items-center justify-center rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-600 dark:bg-gray-700",children:(0,a.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"no output"})}):"text"===b?Q(null,J):(null==Z?void 0:Z.length)===1?Q(Z[0].mediaUrl):(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"rounded-lg ".concat("image"===W?"max-h-[1000px] overflow-y-auto overflow-x-hidden":"overflow-hidden"),children:(0,a.jsx)("div",{className:"flex transition-transform duration-300 ease-in-out",children:null==Z?void 0:Z.map((e,t)=>(0,a.jsx)("div",{className:"w-full flex-shrink-0",style:{transform:"translateX(-".concat(100*F,"%)")},children:Q(e.mediaUrl)},t))})}),(null==Z?void 0:Z.length)>1&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-white/80 dark:bg-gray-800/80",onClick:()=>{E(e=>(e-1+(null==Z?void 0:Z.length))%(null==Z?void 0:Z.length))},children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})}),(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-white/80 dark:bg-gray-800/80",onClick:()=>{E(e=>(e+1)%(null==Z?void 0:Z.length))},children:(0,a.jsx)(c.Z,{className:"h-4 w-4"})}),(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"flat",size:"sm",className:"absolute bottom-2 right-2 bg-white/80 dark:bg-gray-800/80",onClick:$,isDisabled:L,children:L?(0,a.jsx)(i.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(o.Z,{className:"h-4 w-4"})}),(0,a.jsx)("div",{className:"absolute bottom-2 left-1/2 flex -translate-x-1/2 space-x-1",children:Z.map((e,t)=>(0,a.jsx)("button",{onClick:()=>E(t),className:"h-2 w-2 rounded-full transition-colors ".concat(t===F?"bg-blue-500 dark:bg-blue-400":"bg-gray-400 dark:bg-gray-600")},t))})]})]})}),(0,a.jsxs)("div",{className:"mb-4 flex w-full items-center justify-end gap-3",children:["text"!==b&&(0,a.jsx)(p.e,{content:(null==Z?void 0:Z.length)>1?"Download All":"Download",children:(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"solid",isDisabled:r||L,onPress:Y,children:L?(0,a.jsx)(i.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(o.Z,{className:"h-4 w-4"})})}),"text"===b&&(0,a.jsx)(p.e,{content:"Copy",children:(0,a.jsx)(g.A,{isIconOnly:!0,color:"primary",variant:"solid",isDisabled:""===J,onPress:()=>{navigator.clipboard.writeText(J),y.ZP.success("Copied successfully!")},children:(0,a.jsx)(n.Z,{className:"h-4 w-4"})})}),(0,a.jsx)("div",{className:"",children:(0,a.jsxs)(g.A,{isIconOnly:!0,color:"primary",variant:"ghost",onPress:()=>{C.push("/logs")},className:"w-max px-2",children:[(0,a.jsx)(u.Z,{className:"mr-2 h-4 w-4"})," View full history"]})})]}),(null==t?void 0:t.state)==="success"&&(null==t?void 0:t.resultJson)&&(0,a.jsx)("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-600 dark:bg-gray-700/50",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center space-x-4 text-sm",children:H?(0,a.jsxs)("div",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[(0,a.jsx)(m.Z,{className:"mr-2 h-4 w-4"}),"Generated in"," ",(0,a.jsxs)("span",{className:"ml-1 font-medium text-gray-900 dark:text-white",children:[G.toFixed(1)," seconds"]})]}):(0,a.jsxs)("div",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[(0,a.jsx)(m.Z,{className:"mr-2 h-4 w-4"}),(0,a.jsx)("span",{className:"text-gray-900 dark:text-white",children:"Completed"})]})}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:"h-2 w-2 rounded-full bg-green-400"}),(0,a.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Complete"})]})]})})]})}),"JSON"===M&&(0,a.jsx)("div",{className:"p-6",children:V?(null==t?void 0:t.state)==="generating"||(null==t?void 0:t.state)==="waiting"?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3 py-12",children:[(0,a.jsx)(i.Z,{className:"h-6 w-6 animate-spin text-blue-500"}),(0,a.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading..."})]}):(null==t?void 0:t.state)==="fail"?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(s.Z,{className:"mx-auto mb-4 h-8 w-8 text-red-500"}),(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:t.failMsg||"Request failed"})]})}):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Output Data"}),(0,a.jsx)("textarea",{value:(null==t?void 0:t.resultJson)?q(t.resultJson):"",readOnly:!0,placeholder:"No result yet.",className:"h-64 w-full resize-none rounded-lg bg-gray-50 px-3 py-3 text-sm text-gray-900 dark:bg-gray-700 dark:text-white"})]}):(null==t?void 0:t.state)==="waiting"||(null==t?void 0:t.state)==="generating"?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(i.Z,{className:"mx-auto mb-4 h-8 w-8 animate-spin text-blue-500"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Waiting for generation to complete..."})]})}):(null==t?void 0:t.state)==="fail"?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(s.Z,{className:"mx-auto mb-4 h-8 w-8 text-red-500"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No JSON data available due to generation failure"}),(null==t?void 0:t.failMsg)&&(0,a.jsx)("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:t.failMsg})]})}):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Output Data"}),(0,a.jsx)("textarea",{value:JSON.stringify((()=>
1{if((null==t?void 0:t.state)==="success"&&(null==t?void 0:t.resultJson))return JSON.parse(t.resultJson);if("text"===b)try{return{resultObject:"string"==typeof J?JSON.parse(J||"{}"):J}}catch(e){return{resultObject:{}}}return{resultUrls:Z.map(e=>e.mediaUrl)}})(),null,2),readOnly:!0,className:"h-64 w-full resize-none rounded-lg border border-gray-300 bg-gray-50 px-3 py-3 text-sm text-gray-900 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]})})]})}},67968:function(e,t,r){r.d(t,{$k:function(){return u},Ac:function(){return c},CR:function(){return g},Fb:function(){return y},Hs:function(){return C},Kl:function(){return x},LH:function(){return I},QK:function(){return d},Tl:function(){return o},V9:function(){return M},YY:function(){return i},_6:function(){return p},cH:function(){return s},kg:function(){return j},oe:function(){return l},px:function(){return _},wR:function(){return F}});let a="gemini-omni-video",l=7,i=3,s=1,n=["image/png","image/jpeg","image/webp"],o=["video/mp4","video/quicktime","video/webm"],d={start:0,ends:20},c=["https://static.aiquickdraw.com/tools/example/1779268517487_RYXkeF8f.png"],u=[{url:"https://static.aiquickdraw.com/tools/example/1779271048192_jD495zLY.mp4",start:0,ends:7}],m=(e,t)=>{let r=Number(e);return Number.isFinite(r)?r:t},x=e=>e===a,p=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.POSITIVE_INFINITY;return Array.isArray(e)?e.map(e=>null==e?"":String(e).trim()).filter(Boolean).slice(0,t):"string"!=typeof e?[]:e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean).slice(0,t)},g=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;return(Array.isArray(e)?e:e?[e]:[]).map(e=>{if(!e||"object"!=typeof e)return null;let t="string"==typeof e.url?e.url.trim():"";return t?{url:t,start:m(e.start,0),ends:m(e.ends,20)}:null}).filter(Boolean).slice(0,t)},h=(e,t)=>p(e,t),f=(e,t)=>Array.isArray(e)?e.slice(0,t):p(e,t),b=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(e.video_list).length>0?2:0},v=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Array.isArray(e.character_ids)?e.character_ids.slice(0,y(e)).length:p(e.character_ids,y(e)).length},y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Math.min(3,Math.max(0,l-b(e)))},j=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Math.max(0,l-b(e)-v(e))},k=(e,t)=>Array.isArray(e)?e.find(e=>{var r;return(null==e?void 0:null===(r=e.props)||void 0===r?void 0:r.parameterKey)===t}):void 0,w=e=>{var t,r,a,l,i,s,n,o,d;return{type:(null==e?void 0:e.type)||"PlaygroundTextarea",props:{...(null==e?void 0:e.props)||{},id:(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.id)||"gemini-omni-image-to-video-prompt",parameterKey:"prompt",defaultValue:null!==(o=null==e?void 0:null===(r=e.props)||void 0===r?void 0:r.defaultValue)&&void 0!==o?o:"",placeholder:(null==e?void 0:null===(a=e.props)||void 0===a?void 0:a.placeholder)||"Describe the video you want to generate",note:(null==e?void 0:null===(l=e.props)||void 0===l?void 0:l.note)||"Text prompt for the generated video.",required:null===(d=null==e?void 0:null===(i=e.props)||void 0===i?void 0:i.required)||void 0===d||d,rows:(null==e?void 0:null===(s=e.props)||void 0===s?void 0:s.rows)||4,error:(null==e?void 0:null===(n=e.props)||void 0===n?void 0:n.error)||{required:"Prompt is required.",maxLength:"Prompt cannot exceed 5000 characters."}}}},N=e=>{var t,r,a;return{type:(null==e?void 0:e.type)||"PlaygroundFileUpload",props:{...(null==e?void 0:e.props)||{},id:(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.id)||"gemini-omni-image-to-video-image-urls",parameterKey:"image_urls",defaultValue:c,note:"Reference images. The base limit is 7; a video uses 2 image slots and each character_id uses 1 image slot.",required:!1,multiple:!0,limitFile:l,maxFileSize:(null==e?void 0:null===(r=e.props)||void 0===r?void 0:r.maxFileSize)||10,acceptedFileTypes:(null==e?void 0:null===(a=e.props)||void 0===a?void 0:a.acceptedFileTypes)||n}}},A=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=Array.isArray(e)?e:[];if(0===t.length)return[w(),N()];let r=t.map(e=>{var t;let r=null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.parameterKey;return"prompt"===r?w(e):"image_urls"===r?N(e):e});if(k(r,"prompt")||r.unshift(w()),!k(r,"image_urls")){let e=r.findIndex(e=>{var t;return(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.parameterKey)==="prompt"});r.splice(e>=0?e+1:0,0,N())}return r},S={id:a,formContent:A(),outputMediaType:"video",outputMediaUrls:[],progressDuration:120},C=e=>{var t,r,a,l,i;if(!x(null==e?void 0:e.model))return e;let s=A(null===(t=e.playgroundData)||void 0===t?void 0:t.formContent);return{...e,playgroundData:{...S,...e.playgroundData||{},formContent:s,outputMediaType:(null===(r=e.playgroundData)||void 0===r?void 0:r.outputMediaType)||S.outputMediaType,outputMediaUrls:(null===(a=e.playgroundData)||void 0===a?void 0:a.outputMediaUrls)||S.outputMediaUrls,progressDuration:null!==(i=null===(l=e.playgroundData)||void 0===l?void 0:l.progressDuration)&&void 0!==i?i:S.progressDuration}}},M=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=j(t);return e.map(e=>{var t;return"image_urls"===(null==e?void 0:null===(t=e.props)||void 0===t?void 0:t.parameterKey)?{...e,props:{...e.props,limitFile:r,isReadOnly:r<=0,note:"Reference images. Available image slots: ".concat(r,"/").concat(l,". Video uses 2 slots and each character_id uses 1 slot.")}}:e})},I=(e,t,r)=>{let a={...e,[t]:r};
1return"audio_ids"===t&&(a.audio_ids=f(r,i)),"video_list"===t&&(a.video_list=g(r),a.character_ids=f(a.character_ids,y(a)),a.image_urls=h(a.image_urls,j(a))),"character_ids"===t&&(a.character_ids=f(r,y(a)),a.image_urls=h(a.image_urls,j(a))),"image_urls"===t&&(a.image_urls=h(r,j(a))),a},O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...e};return t.video_list=g(t.video_list),t.audio_ids=p(t.audio_ids,i),t.character_ids=p(t.character_ids,y(t)),t.image_urls=h(t.image_urls,j(t)),t},_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O(e)},F=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=O(e);return["image_urls","audio_ids","video_list","character_ids"].forEach(e=>{Array.isArray(t[e])&&0!==t[e].length||delete t[e]}),t}},44116:function(e,t,r){r.d(t,{ZP:function(){return k},Zs:function(){return p},oe:function(){return h}});var a=r(39696),l=r(90170),i=r(32324),s=r(2649),n=r(95866),o=r(1993),d=r(38489),c=r(44421),u=r(18492);let m={naturalWidth:0,naturalHeight:0,displayWidth:0,displayHeight:0,offsetLeft:0,offsetTop:0},x=["x1","y1","x2","y2"];function p(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?e:""):"string"==typeof e&&e?[e]:[]}function g(e){if(!Array.isArray(e)||4!==e.length)return null;let t=e.map(e=>Number(e));if(t.some(e=>!Number.isFinite(e)))return null;let[r,a,l,i]=t,s=Math.round(Math.min(r,l)),n=Math.round(Math.min(a,i)),o=Math.round(Math.max(r,l)),d=Math.round(Math.max(a,i));return s<0||n<0||o<=s||d<=n?null:[s,n,o,d]}function h(e,t){return p(t).map((t,r)=>(Array.isArray(null==e?void 0:e[r])?e[r]:[]).map(e=>g(e)).filter(Boolean).slice(0,2))}function f(e,t,r){return Math.min(Math.max(e,t),r)}function b(e,t){return[Math.round(Math.min(e.x,t.x)),Math.round(Math.min(e.y,t.y)),Math.round(Math.max(e.x,t.x)),Math.round(Math.max(e.y,t.y))]}function v(e,t){if(!e||!t.naturalWidth||!t.naturalHeight||!t.displayWidth||!t.displayHeight)return{};let r=t.displayWidth/t.naturalWidth,a=t.displayHeight/t.naturalHeight,[l,i,s,n]=e;return{left:"".concat(t.offsetLeft+l*r,"px"),top:"".concat(t.offsetTop+i*a,"px"),width:"".concat(Math.max((s-l)*r,1),"px"),height:"".concat(Math.max((n-i)*a,1),"px")}}function y(e){if(!e)return m;let t=e.naturalWidth||0,r=e.naturalHeight||0,a=e.clientWidth||0,l=e.clientHeight||0;if(!t||!r||!a||!l)return{naturalWidth:t,naturalHeight:r,displayWidth:0,displayHeight:0,offsetLeft:0,offsetTop:0};let i=t/r,s=a,n=l,o=0,d=0;return i>a/l?d=(l-(n=a/i))/2:o=(a-(s=l*i))/2,{naturalWidth:t,naturalHeight:r,displayWidth:s,displayHeight:n,offsetLeft:o,offsetTop:d}}function j(e){let{label:t,value:r,onChange:l}=e;return(0,a.jsxs)("label",{className:"min-w-0 rounded-lg border border-gray-200 bg-gray-50 px-2.5 py-2 dark:border-gray-700 dark:bg-gray-900/40",children:[(0,a.jsx)("div",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:t}),(0,a.jsx)("input",{type:"number",min:"0",step:"1",value:r,onChange:l,className:"mt-1 w-full bg-transparent text-sm font-medium text-blue-600 outline-none dark:text-blue-300"})]})}function k(e){let{imageUrls:t,value:r,onChange:k,error:w}=e,N=(0,l.useMemo)(()=>p(t),[t]),A=(0,l.useMemo)(()=>h(r,N),[r,N]),[S,C]=(0,l.useState)(0),[M,I]=(0,l.useState)({}),[O,_]=(0,l.useState)(m),[F,E]=(0,l.useState)({isOpen:!1,boxIndex:null}),[P,T]=(0,l.useState)(null),[L,D]=(0,l.useState)(null),[R,U]=(0,l.useState)(null),[z,V]=(0,l.useState)(null),[K,q]=(0,l.useState)(null),B=(0,l.useRef)(null),W=(0,l.useRef)(null),Z=(0,l.useMemo)(()=>({flex:"0 0 calc((100% - 1.5rem) / 3)",width:"calc((100% - 1.5rem) / 3)",minWidth:"calc((100% - 1.5rem) / 3)"}),[]),J=(0,l.useMemo)(()=>A[S]||[],[S,A]),G=A.reduce((e,t)=>e+t.length,0),H=N[S],Y=M[S]||m,$=null===F.boxIndex?J.length:F.boxIndex;(0,l.useEffect)(()=>{S>=N.length&&C(Math.max(0,N.length-1))},[S,N.length]);let X=(0,l.useCallback)(()=>{_(y(B.current))},[]);(0,l.useEffect)(()=>{let e;if(!F.isOpen)return;X();let t=()=>{X()};return window.addEventListener("resize",t),"undefined"!=typeof ResizeObserver&&B.current&&(e=new ResizeObserver(()=>{X()})).observe(B.current),()=>{window.removeEventListener("resize",t),null==e||e.disconnect()}},[F.isOpen,H,X]),(0,l.useEffect)(()=>{F.isOpen&&(T(null),D(null),U(null),V(null),q(null===F.boxIndex?null:J[F.boxIndex]||null))},[F.isOpen,F.boxIndex,J]);let Q=(0,l.useCallback)(e=>{null==k||k(h(e,N))}
1,[N,k]),ee=(0,l.useCallback)(e=>{let t=h(A,N);t[S]=e.map(e=>g(e)).filter(Boolean).slice(0,2),Q(t)},[S,Q,A,N]),et=(0,l.useCallback)(()=>{E({isOpen:!1,boxIndex:null}),T(null),D(null),U(null),V(null),q(null),_(m)},[]),er=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!H){u.Am.error("Please upload or select a valid image first");return}if(null===e&&J.length>=2){u.Am.error("Each image supports up to 2 boxes");return}E({isOpen:!0,boxIndex:e})},[J.length,H]),ea=(0,l.useCallback)(()=>{ee([])},[ee]),el=(0,l.useCallback)(()=>{Q(N.map(()=>[]))},[Q,N]),ei=(0,l.useCallback)(e=>{ee(J.filter((t,r)=>r!==e))},[J,ee]),es=(0,l.useCallback)((e,t)=>{let r=t.currentTarget;I(t=>{let a=y(r),l=t[e];return(null==l?void 0:l.naturalWidth)===a.naturalWidth&&(null==l?void 0:l.naturalHeight)===a.naturalHeight?t:{...t,[e]:a}})},[]),en=(0,l.useCallback)((e,t,r)=>{let a=Number(r);if(!Number.isFinite(a))return;let l=0===t||2===t?Y.naturalWidth>0?Y.naturalWidth:Number.POSITIVE_INFINITY:Y.naturalHeight>0?Y.naturalHeight:Number.POSITIVE_INFINITY,i=Math.min(Math.max(Math.round(a),0),Number.isFinite(l)?l:Math.round(a));ee(J.map((r,a)=>{if(a!==e)return r;let l=[...r];return l[t]=i,g(l)||r}))},[J,Y.naturalHeight,Y.naturalWidth,ee]),eo=(0,l.useCallback)((e,t)=>{if(!K||""===t)return;let r=Number(t);if(!Number.isFinite(r))return;let a=0===e||2===e?O.naturalWidth>0?O.naturalWidth:Number.POSITIVE_INFINITY:O.naturalHeight>0?O.naturalHeight:Number.POSITIVE_INFINITY,l=Math.min(Math.max(Math.round(r),0),Number.isFinite(a)?a:Math.round(r)),i=[...K];i[e]=l;let s=g(i);s&&q(s)},[K,O.naturalHeight,O.naturalWidth]),ed=(0,l.useCallback)(e=>{let t=W.current;if(!t||!O.naturalWidth||!O.naturalHeight||!O.displayWidth||!O.displayHeight)return null;let r=t.getBoundingClientRect(),a=f(e.clientX-r.left,0,r.width),l=f(e.clientY-r.top,0,r.height);return{x:Math.round(a/r.width*O.naturalWidth),y:Math.round(l/r.height*O.naturalHeight)}},[O]),ec=(0,l.useCallback)(e=>{var t,r;let a=ed(e);if(a){if(null===(r=W.current)||void 0===r||null===(t=r.setPointerCapture)||void 0===t||t.call(r,e.pointerId),e.ctrlKey&&K&&function(e,t){if(!e||!t)return!1;let[r,a,l,i]=t;return e.x>=r&&e.x<=l&&e.y>=a&&e.y<=i}(a,K)){D("move"),U(K),T(a),V(null),e.preventDefault();return}D("draw"),U(null),T(a),V([a.x,a.y,a.x,a.y]),e.preventDefault()}},[ed,K]),eu=(0,l.useCallback)(e=>{if(!P||!L)return;let t=ed(e);if(t){if("move"===L){if(!R)return;q(function(e,t,r,a){if(!e)return null;let[l,i,s,n]=e,o=s-l,d=n-i,c=a.naturalWidth>0?Math.max(a.naturalWidth-o,0):1/0,u=a.naturalHeight>0?Math.max(a.naturalHeight-d,0):1/0,m=f(l+t,0,c),x=f(i+r,0,u);return[m,x,m+o,x+d]}(R,t.x-P.x,t.y-P.y,O));return}V(b(P,t))}},[ed,L,P,O,R]),em=(0,l.useCallback)(e=>{var t,r;if(!P||!L)return;if(null===(r=W.current)||void 0===r||null===(t=r.releasePointerCapture)||void 0===t||t.call(r,e.pointerId),"move"===L){T(null),D(null),U(null);return}let a=ed(e),l=a?b(P,a):z;T(null),D(null),U(null),V(null);let i=g(l);i&&q(i)},[ed,z,L,P]),ex=(0,l.useCallback)(()=>{T(null),D(null),U(null),V(null),q(null)},[]),ep=(0,l.useCallback)(()=>{if(!K){u.Am.error("Please draw a valid box first");return}ee(null===F.boxIndex?[...J,K]:J.map((e,t)=>t===F.boxIndex?K:e)),et()},[et,J,K,F.boxIndex,ee]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-4 rounded-xl border border-gray-200 bg-gray-50/70 p-4 dark:border-gray-700 dark:bg-gray-900/20",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-start lg:justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"bbox_list"}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Draw edit regions on each image. Coordinates are saved as [x1, y1, x2, y2] using the original image pixel coordinates. Each image supports up to 2 boxes."})]}),(0,a.jsxs)("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[G," box",1===G?"":"es"," selected"]})]}),N.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"overflow-x-auto pb-2",children:(0,a.jsx)("div",{className:"flex min-w-full gap-3",children:N.map((e,t)=>{var r;let l=(null===(r=A[t])||void 0===r?void 0:r.length)||0,i=A[t]||[],s=t===S,n=M[t]||m;return(0,a.jsx)("button",{type:"button",onClick:()=>C(t),style:Z,className:"relative h-24 w-40 overflow-hidden rounded-xl border text-left transition-all ".concat(s?"border-blue-500 bg-blue-50 shadow-[0_0_0_1px_rgba(59,130,246,0.35)] dark:border-blue-400 dark:bg-blue-900/20":"border-gray-200 bg-white hover:border-blue-300 hover:bg-blue-50 dark:border-gray-600 dark:bg-gray-800 dark:hover:border-blue-500 dark:hover:bg-blue-900/10"),
1children:e?(0,a.jsxs)("div",{className:"relative h-full w-full bg-gray-950/20",children:[(0,a.jsx)("img",{src:e,alt:"BBox thumbnail ".concat(t+1),onLoad:e=>es(t,e),draggable:!1,className:"h-full w-full object-contain"}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0",children:i.map((e,r)=>(0,a.jsx)("div",{className:"absolute rounded border border-blue-400 bg-blue-500/10",style:v(e,n),children:(0,a.jsx)("span",{className:"absolute left-0 top-0 -translate-y-full rounded bg-blue-500 px-1 py-0.5 text-[9px] font-medium text-white",children:r+1})},"bbox-thumbnail-".concat(t,"-").concat(r,"-").concat(e.join("-"))))}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-gray-950/55 via-transparent to-gray-950/35"}),(0,a.jsx)("div",{className:"absolute right-2 top-2 rounded bg-gray-950/70 px-2 py-1 text-[11px] font-medium text-white",children:n.naturalWidth>0?"".concat(n.naturalWidth," x ").concat(n.naturalHeight):"--"}),(0,a.jsxs)("div",{className:"absolute bottom-2 right-2 rounded bg-gray-950/70 px-2 py-1 text-[11px] font-medium text-white",children:[l,"/",2," boxes"]})]}):(0,a.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 text-xs text-gray-500 dark:bg-gray-900/40 dark:text-gray-400",children:"No image"})},"wan-bbox-image-".concat(t))})})}),(0,a.jsx)("div",{className:"space-y-3",children:(0,a.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-800",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Boxes"}),(0,a.jsx)(i.A,{size:"sm",color:"primary",variant:"flat",onPress:()=>er(),isDisabled:!H||J.length>=2,children:"Add box"})]}),0===J.length?(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No boxes selected for this image."}):(0,a.jsx)("div",{className:"space-y-3",children:J.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900/40",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Box ",t+1]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(i.A,{size:"sm",variant:"bordered",onPress:()=>er(t),children:"Edit"}),(0,a.jsx)(i.A,{size:"sm",variant:"flat",color:"danger",onPress:()=>ei(t),children:"Remove"})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2",children:x.map((r,l)=>(0,a.jsx)(j,{label:r,value:e[l],onChange:e=>en(t,l,e.target.value)},"bbox-coordinate-".concat(t,"-").concat(r)))})]},"bbox-values-".concat(S,"-").concat(t,"-").concat(e.join("-"))))}),(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,a.jsx)(i.A,{size:"sm",variant:"bordered",onPress:ea,children:"Clear current image"}),(0,a.jsx)(i.A,{size:"sm",variant:"flat",color:"danger",onPress:el,children:"Clear all"})]})]})})]}):(0,a.jsx)("div",{className:"rounded-xl border border-dashed border-gray-300 bg-white p-4 text-sm text-gray-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400",children:"Upload image(s) first, then add boxes for each image."}),w&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:w})]}),(0,a.jsx)(s.R,{isOpen:F.isOpen,onClose:et,size:"5xl",scrollBehavior:"inside",children:(0,a.jsxs)(n.A,{children:[(0,a.jsxs)(o.k,{children:[null===F.boxIndex?"Add box":"Edit box"," for Image"," ",S+1]}),(0,a.jsx)(d.I,{children:H?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-sm text-gray-500 dark:text-gray-400 md:flex-row md:items-center md:justify-between",children:[(0,a.jsx)("span",{children:"Drag to draw. Hold Ctrl and drag inside the selected box to move it."}),O.naturalWidth>0&&(0,a.jsxs)("span",{children:["Original size: ",O.naturalWidth," x"," ",O.naturalHeight]})]}),(0,a.jsx)("div",{className:"overflow-auto rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900/30",children:(0,a.jsxs)("div",{className:"relative inline-block max-w-full",children:[(0,a.jsx)("img",{ref:B,src:H,alt:"BBox selector image ".concat(S+1),onLoad:X,draggable:!1,
1className:"max-h-[70vh] max-w-full select-none rounded-lg object-contain"}),(0,a.jsxs)("div",{ref:W,className:"absolute inset-0 touch-none rounded-lg",onPointerDown:ec,onPointerMove:eu,onPointerUp:em,onPointerCancel:em,children:[J.map((e,t)=>t===F.boxIndex?null:(0,a.jsx)("div",{className:"pointer-events-none absolute rounded border-2 border-blue-500 bg-blue-500/10",style:v(e,O),children:(0,a.jsxs)("span",{className:"absolute left-0 top-0 -translate-y-full rounded bg-blue-500 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["Box ",t+1]})},"bbox-reference-".concat(S,"-").concat(t,"-").concat(e.join("-")))),K&&(0,a.jsx)("div",{className:"pointer-events-none absolute rounded border-2 border-orange-400 bg-orange-400/10",style:v(K,O),children:(0,a.jsxs)("span",{className:"absolute left-0 top-0 -translate-y-full rounded bg-orange-400 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["Box ",$+1]})}),z&&(0,a.jsx)("div",{className:"pointer-events-none absolute rounded border-2 border-dashed border-orange-400 bg-orange-400/10",style:v(z,O)})]})]})}),K?(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2",children:x.map((e,t)=>(0,a.jsx)(j,{label:e,value:K[t],onChange:e=>eo(t,e.target.value)},"selector-coordinate-".concat(e)))}):(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Draw a rectangle to create the box."})]}):(0,a.jsx)("div",{className:"rounded-xl border border-dashed border-gray-300 bg-gray-50 p-6 text-center text-sm text-gray-500 dark:border-gray-600 dark:bg-gray-900/30 dark:text-gray-400",children:"This image slot does not have a valid URL yet."})}),(0,a.jsxs)(c.R,{children:[(0,a.jsx)(i.A,{variant:"bordered",onPress:ex,children:"Clear selection"}),(0,a.jsx)(i.A,{variant:"light",onPress:et,children:"Cancel"}),(0,a.jsx)(i.A,{color:"primary",onPress:ep,isDisabled:!K,children:"Save box"})]})]})})]})}},30138:function(e,t,r){r.d(t,{ZP:function(){return u}});var a=r(39696),l=r(90170),i=r(32324),s=r(77851),n=r(66193);let o=/^#[0-9A-F]{6}$/,d=["#C2D1E6","#CDD8E9","#B5C8DB","#C0B5B4","#DAE0EC","#636574","#CACAD2","#CBD4E4","#8FA6BF","#E5E7EF"];function c(e){if("string"!=typeof e)return null;let t=e.trim().replace(/%$/,"");if(!t||!/^\d{1,3}(\.\d+)?$/.test(t))return null;let r=Number.parseFloat(t);return!Number.isFinite(r)||r<0||r>100?null:r}function u(e){let{value:t,onChange:r,error:u}=e,m=(0,l.useMemo)(()=>Array.isArray(t)?t.map(e=>({hex:"string"==typeof(null==e?void 0:e.hex)?e.hex:"",ratio:"string"==typeof(null==e?void 0:e.ratio)?e.ratio:""})):[],[t]),x=(0,l.useMemo)(()=>m.reduce((e,t)=>{let r=c(t.ratio);return e+(null!=r?r:0)},0),[m]),p=e=>{null==r||r(e)},g=e=>{p(m.filter((t,r)=>r!==e))},h=(e,t)=>{let r=t.toUpperCase().replace(/[^#0-9A-F]/g,""),a=r?r.startsWith("#")?r.slice(0,7):"#".concat(r.replace(/^#+/,"").slice(0,6)):"",l=[...m];l[e]={...l[e],hex:a},p(l)},f=(e,t)=>{let r=[...m];r[e]={...r[e],hex:t.toUpperCase()},p(r)},b=(e,t)=>{let r=[...m];r[e]={...r[e],ratio:t.replace(/[^\d.%]/g,"")},p(r)},v=e=>{var t,r;let a=[...m],l=function(e){let t="number"==typeof e?e:c(e);return Number.isFinite(t)?"".concat(t.toFixed(2),"%"):""}(null===(t=a[e])||void 0===t?void 0:t.ratio);a[e]={...a[e],ratio:l||(null===(r=a[e])||void 0===r?void 0:r.ratio)||""},p(a)};return(0,a.jsxs)("div",{className:"space-y-4 rounded-2xl border border-gray-200/80 bg-gray-50/40 p-4 dark:border-gray-700 dark:bg-gray-900/20",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:"color_palette"}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Optional custom theme with ",3," to"," ",10," colors. Recommended:"," ",8,"."]})]}),(0,a.jsxs)("div",{className:"rounded-full border border-gray-200 bg-white px-3 py-1 text-xs font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:[m.length," colors / ",x.toFixed(2),"%"]})]}),m.length>0?(0,a.jsx)("div",{className:"space-y-3",children:m.map((e,t)=>{let r=o.test(e.hex.trim().toUpperCase())?e.hex.trim().toUpperCase():"#94A3B8";return(0,a.jsxs)("div",{className:"grid gap-3 rounded-xl border border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-800 md:grid-cols-[auto_minmax(0,1fr)_180px_auto]",children:[(0,a.jsx)("input",{type:"color",value:r,onChange:e=>
1f(t,e.target.value),className:"h-11 w-full min-w-[64px] cursor-pointer rounded-lg border border-gray-200 bg-transparent p-1 dark:border-gray-700"}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Hex"}),(0,a.jsx)("input",{type:"text",value:e.hex,onChange:e=>h(t,e.target.value),placeholder:"#C2D1E6",className:"h-11 w-full rounded-lg border border-gray-300 bg-white px-3 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Ratio"}),(0,a.jsx)("input",{type:"text",value:e.ratio,onChange:e=>b(t,e.target.value),onBlur:()=>v(t),placeholder:"12.50%",className:"h-11 w-full rounded-lg border border-gray-300 bg-white px-3 text-sm text-gray-900 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:focus:border-blue-400 dark:focus:ring-blue-400"})]}),(0,a.jsx)("div",{className:"flex items-end justify-end",children:(0,a.jsx)(i.A,{isIconOnly:!0,variant:"bordered",onPress:()=>g(t),className:"border-rose-300/70 text-rose-500 hover:bg-rose-50 dark:border-rose-500/40 dark:text-rose-300 dark:hover:bg-rose-500/10",children:(0,a.jsx)(s.Z,{className:"h-4 w-4"})})})]},"wan-color-".concat(t))})}):(0,a.jsx)("div",{className:"rounded-xl border border-dashed border-gray-300 px-4 py-6 text-center text-sm text-gray-500 dark:border-gray-600 dark:text-gray-400",children:"Add 3 to 10 colors. Ratios must sum to 100.00%."}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)(i.A,{variant:"bordered",onPress:()=>{m.length>=10||p([...m,{hex:d[m.length%d.length],ratio:""}])},isDisabled:m.length>=10,className:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700",children:[(0,a.jsx)(n.Z,{className:"h-4 w-4"}),"Add color"]}),m.length>0&&(0,a.jsx)(i.A,{variant:"light",onPress:()=>p([]),className:"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",children:"Clear"})]}),u&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:u})]})}},67293:function(e,t,r){r.d(t,{Z:function(){return F}});var a=r(39696),l=r(90170),i=r(2104),s=r(72594),n=r(84140),o=r(18492),d=r(44965),c=r(53070),u=r(73868),m=r(2649),x=r(95866),p=r(1993),g=r(38489),h=r(82045),f=r(32324),b=r(44421);let v=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return null==e||""===e?t:Number(e)/1e3},y=e=>Math.round(1e3*Number(e)),j=e=>new Promise(t=>{let r=document.createElement("video"),a=URL.createObjectURL(e);r.onloadedmetadata=()=>{URL.revokeObjectURL(a),t(r.duration)},r.onerror=()=>{URL.revokeObjectURL(a),t(null)},r.src=a}),k=(e,t,r)=>{let a=Number(e||0),l=Number(t);return Number.isNaN(a)||Number.isNaN(l)?"Please enter valid start and end time":l<=a?"End time must be greater than start time":l-a<3||l-a>8?"Clip duration must be between 3 and 8 seconds":r&&l>r?"End time cannot exceed uploaded video duration":""},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/\.(mp4|mov)(\?|#|$)/i.test(String(e))},N="rounded-[11px] border border-[#e2e8f0] bg-[#f9fafb] p-4 dark:border-[#374151] dark:bg-[#111827]",A="block text-[13.5px] font-medium text-[#020817] dark:text-[#f8fafc]",S="text-[11.5px] leading-relaxed text-[#6b7280] dark:text-[#9ca3af]",C="border-[#e2e8f0] bg-[#f1f5f9] shadow-none dark:border-[#374151] dark:bg-[#1f2937]",M="border-[#e2e8f0] bg-white dark:border-[#374151] dark:bg-[#1f2937]",I=e=>{let t=((null==e?void 0:e.element_input_urls)||[]).filter(Boolean),r=1===t.length&&w(t[0]);return{inputType:t.length>0?r?"video":"images":null,imageUrls:r?[]:t,videoUrls:r?t:[]}};var O=e=>{let{isOpen:t,onClose:r,element:s,onSave:O,onUploadStateChange:_,allElements:F=[],onRemoveElement:E}=e,P=I(s),[T,L]=(0,l.useState)((null==s?void 0:s.name)||""),[D,R]=(0,l.useState)((null==s?void 0:s.description)||""),[U,z]=(0,l.useState)(P.imageUrls),[V,K]=(0,l.useState)(P.videoUrls),[q,B]=(0,l.useState)((null==s?void 0:s.element_input_audio_urls)||[]),[W,Z]=(0,l.useState)(v(null==s?void 0:s.start_time,0)),[J,G]=(0,l.useState)(v(null==s?void 0:s.end_time,"")),[H,Y]=(0,l.useState)(null),[$,X]=(0,l.useState)(P.inputType),[Q,ee]=(0,l.useState)({}),[et,er]=(0,l.useState)(!1),[ea,el]=(0,l.useState)(!1),[ei,es]=(0,l.useState)(null);(0,l.useEffect)(()=>
1{if(t){let e=I(s);L((null==s?void 0:s.name)||""),R((null==s?void 0:s.description)||""),z(e.imageUrls),K(e.videoUrls),B((null==s?void 0:s.element_input_audio_urls)||[]),Z(v(null==s?void 0:s.start_time,0)),G(v(null==s?void 0:s.end_time,"")),Y(null),X(e.inputType),ee({}),es(null)}},[t,s]);let en=(e,t)=>{let r="start"===e?t:W,a="end"===e?t:J;"start"===e?Z(t):G(t);let l=k(r,a,H);ee(e=>{let t={...e};return l?t.cut=l:delete t.cut,t})},eo=async e=>{if(!e||0===e.length)return;let t=Array.from(e),r=t[0],a=r.type.startsWith("image/"),l=r.type.startsWith("video/"),i=r.type.startsWith("audio/");if(!a&&!l&&!i){o.Am.error("Only images, videos, and audio files are supported");return}if(i){await ed(t);return}if(!$&&(a?X("images"):l&&X("video")),"images"===$&&!a){o.Am.error("Please upload images only");return}if("video"===$&&!l){o.Am.error("Please upload video only");return}er(!0),null==_||_(1);try{if(a){let e=e=>new Promise(t=>{let r=new Image,a=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(a);let l=r.width/r.height;r.width<300||r.height<300?t({valid:!1,error:"Image dimensions must be at least ".concat(300,"x").concat(300,"px (current: ").concat(r.width,"x").concat(r.height,"px)")}):l<.4||l>2.5?t({valid:!1,error:"".concat(e.name,": Image ratio must be between 1:2.5 and 2.5:1")}):t({valid:!0})},r.onerror=()=>{URL.revokeObjectURL(a),t({valid:!1,error:"".concat(e.name,": Failed to load image")})},r.src=a}),r=t.filter(e=>e.size>10485760?(o.Am.error("".concat(e.name,": Image size cannot exceed 10MB")),!1):!!["image/png","image/jpeg","image/jpg"].includes(e.type)||(o.Am.error("".concat(e.name,": Only PNG and JPG formats are supported")),!1));if(0===r.length){er(!1),null==_||_(-1);return}let a=await Promise.all(r.map(t=>e(t))),l=r.filter((e,t)=>{let r=a[t];return!!r.valid||(o.Am.error(r.error),!1)});if(0===l.length){er(!1),null==_||_(-1);return}if(U.length+l.length>4){o.Am.error("Maximum 4 images allowed"),er(!1),null==_||_(-1);return}let i=l.map(e=>(0,d._R)(e,"kieai/market")),s=await Promise.all(i);z(e=>[...e,...s]),o.Am.success("Successfully uploaded ".concat(s.length," image(s)"))}else if(l){let e=t.filter(e=>{let t=/\.(mp4|mov)$/i.test(e.name);return!!["video/mp4","video/quicktime"].includes(e.type)||!!t||(o.Am.error("".concat(e.name,": Only MP4 and MOV formats are supported")),!1)});if(1!==e.length||V.length+e.length>1){o.Am.error("Exactly 1 video is allowed"),0===V.length&&X(null),er(!1),null==_||_(-1);return}let r=await j(e[0]);if(!r){o.Am.error("".concat(e[0].name,": Failed to read video duration")),0===V.length&&X(null),er(!1),null==_||_(-1);return}if(r<3){o.Am.error("".concat(e[0].name,": Video duration must be at least 3 seconds")),0===V.length&&X(null),er(!1),null==_||_(-1);return}let a=await Promise.all(e.map(e=>(0,d._R)(e,"kieai/market")));K(a),Y(r),Z(0),G(r>=8?8:3),ee(e=>{let t={...e};return delete t.cut,t}),o.Am.success("Successfully uploaded video")}}catch(e){console.error("Upload error:",e),o.Am.error("Upload failed: "+e.message)}finally{er(!1),null==_||_(-1)}},ed=async e=>{if(q.length>=1){o.Am.error("Only 1 audio reference is allowed");return}if(1!==e.length){o.Am.error("Please upload exactly 1 audio file");return}el(!0),null==_||_(1);try{let t=(await Promise.all(e.map(e=>new Promise(t=>{let r=new Audio,a=URL.createObjectURL(e);r.onloadedmetadata=()=>{URL.revokeObjectURL(a),t({file:e,duration:r.duration})},r.onerror=()=>{URL.revokeObjectURL(a),t({file:e,duration:null})},r.src=a})))).filter(e=>{let{file:t,duration:r}=e;return t.type.startsWith("audio/")?!r||!(r<5)&&!(r>30)||(o.Am.error("".concat(t.name,": Audio duration must be between 5 and 30 seconds")),!1):(o.Am.error("".concat(t.name,": Only audio files are supported")),!1)}).map(e=>{let{file:t}=e;return t});if(0===t.length)return;let r=await Promise.all(t.map(e=>(0,d._R)(e,"kieai/market")));B(r.slice(0,1)),o.Am.success("Successfully uploaded audio reference")}catch(e){console.error("Upload audio error:",e),o.Am.error("Audio upload failed: "+e.message)}finally{el(!1),null==_||_(-1)}};return(0,a.jsx)(m.R,{isOpen:t,onClose:r,size:"2xl",scrollBehavior:"inside",children:(0,a.jsxs)(x.A,{className:"bg-white text-[#020817] dark:bg-[#111827] dark:text-[#f8fafc]",children:[(0,a.jsx)(p.k,{className:"px-[22px] pb-2 pt-[18px] text-lg font-semibold",children:"Create Element"}),(0,a.jsx)(g.I,{className:"px-[22px] py-1",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 roun
1ded-[11px] border border-[#e2e8f0] p-[9px] dark:border-[#374151] md:flex-row",children:[(0,a.jsxs)("div",{className:"w-full md:w-[62%]",children:[(0,a.jsxs)("div",{className:"mb-[18px]",children:[(0,a.jsxs)("label",{className:"".concat(A," mb-[7px]"),children:["Name ",(0,a.jsx)("span",{className:"text-[#dc2626] dark:text-[#f87171]",children:"*"})]}),(0,a.jsx)(h.Y,{value:T,onValueChange:L,placeholder:"Enter element name",isInvalid:!!Q.name,errorMessage:Q.name,classNames:{input:"text-[13.5px] text-[#020817] dark:text-[#f8fafc]",inputWrapper:"min-h-[42px] rounded-[9px] ".concat(C)}})]}),(0,a.jsxs)("div",{className:"mb-[18px]",children:[(0,a.jsxs)("label",{className:"".concat(A," mb-[7px]"),children:["Description ",(0,a.jsx)("span",{className:"text-[#dc2626] dark:text-[#f87171]",children:"*"})]}),(0,a.jsx)(i.Y,{value:D,isInvalid:!!Q.description,errorMessage:Q.description,onValueChange:R,placeholder:"Enter element description",rows:3,classNames:{input:"text-[13.5px] leading-relaxed text-[#020817] dark:text-[#f8fafc]",inputWrapper:"min-h-[70px] rounded-[9px] ".concat(C)}})]}),(0,a.jsxs)("div",{className:"".concat(N," mb-[18px]"),children:[(0,a.jsxs)("div",{className:A,children:["Character media ",(0,a.jsx)("span",{className:"text-[#dc2626] dark:text-[#f87171]",children:"*"}),"images"===$&&(0,a.jsxs)("span",{className:"ml-2 text-[11.5px] font-normal text-[#6b7280] dark:text-[#9ca3af]",children:[U.length,"/4 uploaded"]}),"video"===$&&(0,a.jsxs)("span",{className:"ml-2 text-[11.5px] font-normal text-[#6b7280] dark:text-[#9ca3af]",children:[V.length,"/1 uploaded"]})]}),(0,a.jsx)("p",{className:"".concat(S," my-3 mt-1"),children:"Upload either 2-4 images or 1 video as the visual reference."}),"images"===$&&U.length>0&&(0,a.jsx)("div",{className:"mb-3 flex flex-wrap gap-2",children:U.map((e,t)=>(0,a.jsxs)("div",{className:"relative h-[92px] w-[92px] overflow-hidden rounded-[9px] border-2 border-[#2b7fff] bg-[repeating-linear-gradient(45deg,#f1f5f9_0_8px,transparent_8px_16px)] dark:border-[#60a5fa] dark:bg-[repeating-linear-gradient(45deg,#1f2937_0_8px,transparent_8px_16px)]",children:[(0,a.jsx)("img",{src:e,alt:"Image ".concat(t+1),className:"h-full w-full object-cover"}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=U.filter((e,r)=>r!==t);z(e),0===e.length&&X(null)},className:"absolute right-1 top-1 inline-flex h-5 w-5 items-center justify-center rounded-full bg-[#dc2626] text-white shadow-md hover:opacity-80 dark:bg-[#f87171]",children:(0,a.jsx)(c.Z,{size:12})})]},t))}),"video"===$&&V.length>0&&(0,a.jsxs)("div",{className:"relative mb-3 overflow-hidden rounded-[9px] border border-[#e2e8f0] bg-black dark:border-[#374151]",children:[(0,a.jsx)("video",{src:V[0],controls:!0,className:"h-40 w-full bg-black object-contain"}),(0,a.jsx)("button",{type:"button",onClick:()=>{K([]),Z(0),G(""),Y(null),X(null),ee(e=>{let t={...e};return delete t.cut,t})},className:"absolute right-2 top-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-[#dc2626] text-white shadow-md hover:opacity-80 dark:bg-[#f87171]",children:(0,a.jsx)(c.Z,{size:14})})]}),(null===$||"images"===$&&U.length<4||"video"===$&&V.length<1)&&(0,a.jsx)("div",{className:"flex h-32 w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-[10px] border-2 border-dashed text-center transition duration-300 ".concat(et?"border-[#2b7fff] bg-[#f1f5f9] dark:border-[#60a5fa] dark:bg-[#1f2937]":"border-[#e2e8f0] hover:border-[#2b7fff] dark:border-[#374151] dark:hover:border-[#60a5fa]"),onClick:()=>{let e=document.createElement("input");e.type="file","images"===$?(e.accept="image/png,image/jpeg,image/jpg",e.multiple=!0):"video"===$?(e.accept="video/mp4,video/quicktime,.mp4,.mov",e.multiple=!1):(e.accept="image/png,image/jpeg,image/jpg,video/mp4,video/quicktime,.mp4,.mov",e.multiple=!0),e.onchange=e=>eo(e.target.files),e.click()},children:et?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.Z,{className:"h-6 w-6 animate-spin text-[#2b7fff] dark:text-[#60a5fa]"}),(0,a.jsx)("p",{className:S,children:"Uploading..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.JO,{icon:"mdi:upload",className:"h-7 w-7 text-[#9ca3af] dark:text-[#6b7280]"}),(0,a.jsx)("p",{className:"text-[13.5px] font-medium text-[#020817] dark:text-[#f8fafc]",children:"images"===$?"Upload more images":"video"===$?"Upload video":"Upload images or video"}),(0,a.jsx)("p",{className:S,children:"JPG/PNG for images, MP4/MOV for video"})]})}),Q.media&&(0,a.jsx)("p",{className:"mt-2 text-sm text-[#dc2626]",children:Q.media}),(0,a.jsx)("p",{className:"".concat(S," mt-3"),children:"Images: JPG/PNG, 2-4 files, at least 300*300px, ratio 1:2.5 to 2.5:1. Video: MP4/MOV, exactly 1 file."})]}),"video"===$&&V.length>0&&(0,a.jsxs)("div",{className:"".concat(N," mb-[18px]"),children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:A,children:"Clip timing"}),(0,a.jsx)("p",{className:S,children:"Select a 3-8s segment."})]}),H&&(0,a.jsxs)("p",{className:"rounded-full bg-[#f1f5f9] px-2 py-1 text-[11.5px] text-[#6b7280] dark:bg-[#1f2937] dark:text-[#9ca3af]",children:["Video ",H.toFixed(1),"s"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsx)(h.Y,{type:"number",label:"Start",endContent:(0,a.jsx)("span",{className:"text-xs text-[#9ca3af]",children:"s"}),value:String(W),onValueChange:e=>en("start",e),min:0,step:"0.1",isInvalid:!!Q.cut,classNames:{input:"text-[#020817] dark:text-[#f8fafc]",inputWrapper:"min-h-10 rounded-[9px] ".concat(C),label:"text-xs"}}),(0,a.jsx)(h.Y,{type:"number",label:"End",endContent:(0,a.jsx)("span",{className:"text-xs text-[#9ca3af]",children:"s"}),value:String(J),onValueChange:e=>en("end",e),min:0,step:"0.1",isInvalid:!!Q.cut,classNames:{input:"text-[#020817] dark:text-[#f8fafc]",inputWrapper:"min-h-10 rounded-[9px] ".concat(C),label:"text-xs"}})]}),Q.cut&&(0,a.jsx)("p",{className:"mt-2 text-xs text-[#dc2626]",children:Q.cut}),(0,a.jsx)("p",{className:"".concat(S," mt-2"),children:"End must be greater than start. Duration: 3-8s."})]}),(0,a.jsxs)("div",{className:N,children:[(0,a.jsxs)("div",{className:A,children:["Voice or sound reference",(0,a.jsx)("span",{className:"ml-2 text-[11.5px] font-normal text-[#6b7280] dark:text-[#9ca3af]",children:"optional"})]}),(0,a.jsx)("p",{className:"".concat(S," my-3 mt-1"),children:"Add audio to guide the element voice, tone, or sound."}),q.length>0&&(0,a.jsx)("div",{className:"mb-3 space-y-2",children:q.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-[10px] border p-2 ".concat(M),children:[(0,a.jsx)("audio",{src:e,controls:!0,className:"min-w-0 flex-1"}),(0,a.jsx)("button",{type:"button",onClick:()=>B(e=>e.filter((e,r)=>r!==t)),className:"inline-flex h-6 w-6 items-center justify-center rounded-full bg-[#dc2626] text-white shadow-md hover:opacity-80 dark:bg-[#f87171]",children:(0,a.jsx)(c.Z,{size:14})})]},t))}),0===q.length&&(0,a.jsx)("div",{className:"flex h-[90px] w-full cursor-pointer flex-col items-center justify-center gap-[7px] rounded-[10px] border-2 border-dashed text-center transition duration-300 ".concat(ea?"border-[#2b7fff] bg-[#f1f5f9] dark:border-[#60a5fa] dark:bg-[#1f2937]":"border-[#e2e8f0] hover:border-[#2b7fff] dar
1k:border-[#374151] dark:hover:border-[#60a5fa]"),onClick:()=>{let e=document.createElement("input");e.type="file",e.accept="audio/*",e.multiple=!1,e.onchange=e=>eo(e.target.files),e.click()},children:ea?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.Z,{className:"h-6 w-6 animate-spin text-[#2b7fff] dark:text-[#60a5fa]"}),(0,a.jsx)("p",{className:S,children:"Uploading..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.JO,{icon:"mdi:music-note-plus",className:"h-6 w-6 text-[#9ca3af] dark:text-[#6b7280]"}),(0,a.jsx)("p",{className:"text-[13.5px] font-medium text-[#020817] dark:text-[#f8fafc]",children:"Upload audio reference"})]})}),(0,a.jsx)("p",{className:"".concat(S," mt-3"),children:"Only one audio file can be uploaded. Duration must be 5-30 seconds when parsed."}),Q.audio&&(0,a.jsx)("p",{className:"mt-2 text-sm text-[#dc2626]",children:Q.audio})]})]}),(0,a.jsx)("div",{className:"border-t border-dashed border-[#e2e8f0] dark:border-[#374151] md:border-l md:border-t-0"}),(0,a.jsxs)("div",{className:"w-full md:w-[34%]",children:[(0,a.jsx)("label",{className:"".concat(A," mb-[9px]"),children:"Created Elements"}),(0,a.jsxs)("div",{className:"flex max-h-96 flex-col gap-2 overflow-y-auto rounded-[11px] border border-[#e2e8f0] bg-[#f9fafb] p-3 dark:border-[#374151] dark:bg-[#111827]",children:[0===F.length&&(0,a.jsx)("div",{className:"rounded-[11px] border border-dashed border-[#e2e8f0] bg-white p-4 text-center text-[11.5px] text-[#6b7280] dark:border-[#374151] dark:bg-[#1f2937] dark:text-[#9ca3af]",children:"No elements yet"}),F.map((e,t)=>{var r,l;let i=ei===t,s=(e.element_input_urls||[]).filter(Boolean),o=null===(r=e.element_input_audio_urls)||void 0===r?void 0:r[0],d=1===s.length&&w(s[0])?s[0]:"",u=!!d,m=d?"":s[0];return(0,a.jsxs)("div",{className:"rounded-[11px] border p-2 ".concat(M),children:[(0,a.jsxs)("div",{className:"flex cursor-pointer items-center gap-[11px]",onClick:()=>es(i?null:t),children:[m?(0,a.jsx)("div",{className:"relative h-10 w-10 flex-shrink-0 overflow-hidden rounded-md border border-[#e2e8f0] dark:border-[#374151]",children:(0,a.jsx)("img",{src:m,alt:e.name,className:"h-full w-full object-cover"})}):d?(0,a.jsxs)("div",{className:"relative h-10 w-10 flex-shrink-0 overflow-hidden rounded-md border border-[#e2e8f0] bg-black dark:border-[#374151]",children:[(0,a.jsx)("video",{src:d,muted:!0,playsInline:!0,preload:"metadata",className:"h-full w-full object-cover"}),(0,a.jsx)("div",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5",children:(0,a.jsx)(n.JO,{icon:"mdi:play",className:"h-3 w-3 text-white"})})]}):(0,a.jsx)("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border border-[#e2e8f0] bg-[#f1f5f9] dark:border-[#374151] dark:bg-[#1f2937]",children:(0,a.jsx)(n.JO,{icon:"mdi:file",className:"h-5 w-5 text-[#9ca3af]"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"truncate text-[13px] font-medium text-[#020817] dark:text-[#f8fafc]",children:["@",e.name,o&&(0,a.jsx)("span",{className:"ml-1 text-[#2b7fff] dark:text-[#60a5fa]",children:"âª"})]}),(0,a.jsx)("div",{className:"mt-[3px]",children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-[5px] px-1.5 py-0.5 text-[10px] font-medium ".concat(u?"bg-[#2b7fff]/10 text-[#2b7fff] dark:bg-[#60a5fa]/15 dark:text-[#60a5fa]":"bg-[#0d9488]/10 text-[#0d9488] dark:bg-[#2dd4bf]/15 dark:text-[#2dd4bf]"),children:[(0,a.jsx)(n.JO,{icon:u?"mdi:play":"mdi:image-outline",className:"h-3 w-3"}),u?1:s.length]})})]}),(0,a.jsx)(n.JO,{icon:i?"mdi:chevron-up":"mdi:chevron-down",className:"h-5 w-5 flex-shrink-0 text-[#9ca3af] dark:text-[#6b7280]"})]}),i&&(0,a.jsxs)("div",{className:"mt-[11px] flex flex-col gap-2 border-t border-[#e2e8f0] pt-[11px] dark:border-[#374151]",children:[e.description&&(0,a.jsx)("p",{className:S,children:e.description}),d?(0,a.jsxs)("div",{className:"relative h-12 w-20 overflow-hidden rounded-md border border-[#e2e8f0] bg-black dark:border-[#374151]",children:[(0,a.jsx)("video",{src:d,muted:!0,playsInline:!0,preload:"metadata",className:"h-full w-full object-cover"}),(0,a.jsx)("div",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1 py-0.5",children:(0,a.jsx)(n.JO,{icon:"mdi:play",className:"h-3 w-3 text-white"})})]}):(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:s.map((e,r)=>(0,a.jsx)("img",{src:e,alt:"Element ".concat(t," image ").concat(r),className:"h-12 w-12 rounded-md border border-[#e2e8f0] object-cover dark:border-[#374151]"},r))}),o&&(0,a.jsxs)("div",{className:"rounded-lg border p-2 ".concat(M),children:[(0,a.jsx)("div",{className:"mb-1 text-xs font-medium text-[#6b7280] dark:text-[#9ca3af]",children:"Audio reference"}),(0,a.jsx)("audio",{src:o,controls:!0,className:"h-8 w-full"})]}),d&&void 0!==e.end_time&&(0,a.jsxs)("p",{className:S,children:["Clip: ",v(null!==(l=e.start_time)&&void 0!==l?l:0,0),"s -"," ",v(e.end_time,0),"s"]}),E&&(0,a.jsxs)(f.A,{size:"sm",className:"w-full rounded-lg border-[#2b7fff] text-[#2b7fff] dar
1k:border-[#60a5fa] dark:text-[#60a5fa]",variant:"bordered",onClick:e=>e.stopPropagation(),onPress:()=>{E(t),es(null)},children:[(0,a.jsx)(c.Z,{size:14}),(0,a.jsx)("span",{className:"ml-1",children:"Remove"})]})]})]},t)})]})]})]})}),(0,a.jsxs)(b.R,{className:"px-[22px] pb-[18px] pt-3",children:[(0,a.jsx)(f.A,{variant:"bordered",className:"h-10 rounded-[9px] border-[#e2e8f0] px-[18px] text-[13.5px] font-medium text-[#020817] dark:border-[#374151] dark:text-[#f8fafc]",onPress:r,children:"Cancel"}),(0,a.jsx)(f.A,{className:"h-10 rounded-[9px] bg-[#2b7fff] px-[22px] text-[13.5px] font-semibold text-white dark:bg-[#60a5fa]",onPress:()=>{let e={};if(T.trim()||(e.name="Name is required"),D.trim()||(e.description="Description is required"),q.length>1&&(e.audio="Only 1 audio reference is allowed"),$){if("images"===$)U.length<2?e.media="At least 2 images are required":U.length>4&&(e.media="Maximum 4 images allowed");else if("video"===$){1!==V.length&&(e.media="Exactly 1 video is required");let t=k(W,J,H);t&&(e.cut=t)}}else e.media="Please upload at least one file";if(Object.keys(e).length>0){ee(e);return}let t={name:T.trim(),description:D.trim()};"images"===$?t.element_input_urls=U:"video"===$&&(t.element_input_urls=V,t.start_time=y(W||0),t.end_time=y(J)),q.length>0&&(t.element_input_audio_urls=q),O(t),r()},isDisabled:et||ea||"video"===$&&!!Q.cut,children:"Save"})]})]})})},_=r(44568);function F(e){let{field:t={},onChange:r,error:o,formData:d={},onUploadStateChange:c}=e,u=t.multiShotsKey||"multi_shots",m=t.promptKey||"prompt",x=t.durationKey||"duration",p=t.multiPromptKey||"multi_prompt",g=t.elementsKey||"kling_elements",h=Number(t.maxShots)||5,f=Number(t.totalMax)||15,b=Number(t.perShotMin)||1,v=Number(t.perShotMax)||12,y=Number(t.singleMin)||3,j=Number(t.singleMax)||15,k=Number(t.promptMaxLength)||2500,w=Number(t.multiPromptMaxLength)||500,N=(0,_.pb)(t),A=!!d[u],S=Array.isArray(d[g])?d[g]:[],C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return N?{prompt:e}:{prompt:e,duration:t}},M=Array.isArray(d[p])&&d[p].length?d[p]:[C()],I=M.reduce((e,t)=>e+(Number(null==t?void 0:t.duration)||0),0),F=Math.max(0,f-I),E=!N&&I>f,P=M.length<h&&(N||F>0),[T,L]=(0,l.useState)(!1),[D,R]=(0,l.useState)(null),U=()=>{L(!1),R(null)},z=e=>{r(p,e),N||r(x,e.reduce((e,t)=>e+(Number(null==t?void 0:t.duration)||0),0))},V=(e,t)=>z(M.map((r,a)=>a===e?{...r,...t}:r)),K=e=>{M.length<=1||z(M.filter((t,r)=>r!==e))},q=(0,l.useRef)(A);(0,l.useEffect)(()=>{if(q.current!==A){if(q.current=A,A){let e=Array.isArray(d[p])?d[p]:[];e.length>0?N||r(x,e.reduce((e,t)=>e+(Number(null==t?void 0:t.duration)||0),0)):(r(p,[C(d[m]||"")]),N||r(x,5)),r(m,void 0)}else{let e=(d[p]||[])[0]||{},t=Math.min(j,Math.max(y,Number(e.duration)||10));"string"!=typeof d[m]&&r(m,e.prompt||""),N||r(x,t),r(p,void 0)}}},[A]);let B=d[x],W=Array.isArray(d[p])?d[p]:null,Z=!!(null==W?void 0:W.some(e=>(null==e?void 0:e.duration)!==void 0));(0,l.useEffect)(()=>{N&&(void 0!==B&&r(x,void 0),Z&&r(p,(0,_.so)(W)))},[N,B,Z]);let J=(0,l.useRef)(N);(0,l.useEffect)(()=>{let e=J.current;if(J.current=N,!N&&e){if(A){if(!(null==W?void 0:W.length))return;let e=W.map(e=>({...e,duration:Math.min(v,Math.max(b,Number(null==e?void 0:e.duration)||5))}));r(p,e),r(x,e.reduce((e,t)=>e+t.duration,0))}else null==B&&r(x,Math.min(j,Math.max(y,5)))}},[N]);let G=()=>(0,a.jsxs)("button",{type:"button",onClick:()=>{R(null),L(!0)},className:"border-primary/40 bg-primary/5 hover:bg-primary/10 dark:border-primary/50 inline-flex items-center gap-1 rounded-full border border-dashed px-3 py-1 text-xs font-medium text-primary transition-colors dark:text-primary",children:[(0,a.jsx)(n.JO,{icon:"mingcute:at-line",width:13})," Elements"]}),H=e=>{let{keyId:t,prompt:r,onPrompt:l,maxLen:o,dur:d,min:c,max:u,onDur:m,removable:x,onRemove:p,badge:g}=e;return(0,a.jsxs)("div",{className:"rounded-xl border border-default-200 bg-white dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-default-200 bg-default-50/70 px-4 py-2 dark:border-white/10 dark:bg-white/[0.04]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary text-[11px] font-bold text-primary-foreground",children:g}),(0,a.jsx)("span",{className:"text-xs font-semibold text-default-600",children:"Shot"})]}),x&&(0,a.jsx)("button",{type:"button",onClick:p,className:"flex h-6 w-6 items-center justify-center rounded-md text-default-400 transition-colors hover:bg-danger/10 hover:text-danger",children:(0,a.jsx)(n.JO,{icon:"mingcute:close-line",width:14})})]}),(0,a.jsxs)("div",{className:"space-y-3 p-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1 text-xs font-medium text-default-500",children:[(0,a.jsx)(n.JO,{icon:"mingcute:quill-pen-line",width:13})," Prompt"," ",(0,a.jsx)("span",{className:"text-danger",children:"*"})]}),(0,a.jsxs)("span",{className:"text-[11px] tabular-nums text-default-400",children:[(r||"").length,"/",o]})]}),(0,a.jsx)(i.Y,{variant:"flat",minRows:3,maxLength:o,placeholder:"Describe this shotâ¦",value:r,onValueChange:l,className:"rounded-xl bg-default-100"})]}),!N&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mb-1.5 flex items-center gap-1 text-xs font-medium text-default-500",children:[(0,a.jsx)(n.JO,{icon:"mingcute:time-line",width:13})," Duration"," ",(0,a.jsx)("span",{className:"text-danger",children:"*"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(s.L,{size:"sm","aria-label":"Duration",minValue:c,maxValue:u,step:1,value:d,onChange:e=>m(Array.isArray(e)?e[0]:Number(e)),className:"flex-1"}),(0,a.jsxs)("span",{className:"bg-primary/10 dark:bg-primary/15 rounded-full px-2.5 py-1 text-xs font-semibold tabular-nums text-primary dark:text-primary",children:[d,"s"]})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(()=>{let e=r?[...r.matchAll(/@(\S+)/g)].map(e=>e[1]):[],t=new Set;return S.filter(r=>
1!(!(null==r?void 0:r.name)||t.has(r.name))&&!!e.includes(r.name)&&(t.add(r.name),!0)).map(e=>(0,a.jsxs)("span",{className:"border-primary/40 bg-primary/10 inline-flex items-center gap-1 rounded-full border px-3 py-1 text-xs font-medium text-primary",children:[(0,a.jsx)(n.JO,{icon:"mingcute:at-line",width:13}),e.name]},e.name))})(),G()]})]})]},t)};return(0,a.jsxs)(a.Fragment,{children:[A?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("label",{className:"text-sm font-semibold text-default-700",children:"Shots"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-default-400",children:[M.length," / ",h]}),(0,a.jsxs)("button",{type:"button",disabled:!P,onClick:()=>{P&&z([...M,C("",Math.min(v,Math.max(b,F)))])},className:"flex items-center gap-1 rounded-full bg-primary px-3 py-1 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-40",children:[(0,a.jsx)(n.JO,{icon:"mingcute:add-line",width:14})," Add shot"]})]})]}),!N&&(0,a.jsxs)("div",{className:"space-y-1 rounded-xl border border-default-200 bg-white px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,a.jsx)("span",{className:"text-default-500",children:"Total duration"}),(0,a.jsxs)("span",{className:E?"font-semibold text-danger":"font-medium text-default-600",children:[I," / ",f,"s",E?"":" (".concat(F,"s left)")]})]}),(0,a.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-default-200/60 dark:bg-white/[0.08]",children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all ".concat(E?"bg-danger":"bg-primary"),style:{width:"".concat(Math.min(I/f*100,100),"%")}})})]}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:M.map((e,t)=>{var r;return H({keyId:t,badge:t+1,prompt:null!==(r=null==e?void 0:e.prompt)&&void 0!==r?r:"",onPrompt:e=>V(t,{prompt:e}),maxLen:w,dur:Math.min(v,Math.max(b,Number(null==e?void 0:e.duration)||b)),min:b,max:v,onDur:e=>V(t,{duration:e}),removable:M.length>1,onRemove:()=>K(t)})})})]}):(()=>{var e;let t=Math.min(j,Math.max(y,Number(d[x])||y));return H({badge:"1",prompt:null!==(e=d[m])&&void 0!==e?e:"",onPrompt:e=>r(m,e),maxLen:k,dur:t,min:y,max:j,onDur:e=>r(x,e)})})(),o&&(0,a.jsx)("p",{className:"mt-1.5 text-xs text-danger",children:o}),(0,a.jsx)(O,{isOpen:T,onClose:U,element:null!=D?S[D]:null,onSave:e=>{r(g,null!=D?S.map((t,r)=>r===D?e:t):[...S,e]),U()},allElements:S,onRemoveElement:e=>r(g,S.filter((t,r)=>r!==e)),onUploadStateChange:c})]})}},29109:function(e,t,r){r.d(t,{Z:function(){return _}});var a=r(39696),l=r(90170),i=r(69194),s=r(25411),n=r(67629),o=r(43118),d=r(73102),c=r(27220),u=r(18492),m=r(44965),x=r(38634),p=r(97793);let g={language:"en"},h=e=>{var t,r,a;return null!==(a=null!==(r=null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.data)&&void 0!==r?r:null==e?void 0:e.message)&&void 0!==a?a:"Request failed"},f=e=>new Promise(t=>{let r=new Audio;r.preload="metadata",r.onloadedmetadata=()=>t(Number.isFinite(r.duration)?r.duration:0),r.onerror=()=>t(0),r.src=e});var b=r(49650),v=r(29199),y=r(59689),j=r(30858);let k="flex flex-1 items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-xs font-semibold transition-colors",w="bg-primary text-primary-foreground shadow-sm shadow-primary/30",N="text-default-500 hover:bg-primary/10 hover:text-primary dark:text-white/55 dark:hover:text-primary";function A(e){let{target:t,file:r,previewUrl:i,onFile:s,isRecording:n,recordingTarget:o,recordingSeconds:d,livePeaks:c=[],acceptedExtensions:u=p.VW,onStartRecording:m,onStopRecording:x}=e,[g,h]=(0,l.useState)("upload"),[f,A]=(0,l.useState)(!1),S=(0,l.useRef)(null),C=(null==u?void 0:u.length)?u:p.VW,M=C.map(e=>".".concat(e)).join(","),I=n&&o===t,O=e=>{e&&s(e)};return(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"border-primary/15 bg-primary/[0.04] flex gap-1.5 rounded-xl border p-1 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsxs)("button",{type:"button",className:"".concat(k," ").concat("upload"===g?w:N),onClick:()=>h("upload"),children:[(0,a.jsx)(b.Z,{className:"h-3.5 w-3.5"})," Upload"]}),(0,a.jsxs)("button",{type:"button",className:"".concat(k," ").concat("record"===g?w:N),onClick:()=>h("record"),children:[(0,a.jsx)(v.Z,{className:"h-3.5 w-3.5"})," Record"]})]}),"upload"===g&&(0,a.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>{var e;return null===(e=S.current)||void 0===e?void 0:e.click()},onKeyDown:e=>{var t;
1return("Enter"===e.key||" "===e.key)&&(null===(t=S.current)||void 0===t?void 0:t.click())},onDragOver:e=>{e.preventDefault(),A(!0)},onDragLeave:()=>A(!1),onDrop:e=>{var t;e.preventDefault(),A(!1),O(null===(t=e.dataTransfer.files)||void 0===t?void 0:t[0])},className:"flex cursor-pointer flex-col items-center justify-center gap-1.5 rounded-xl border border-dashed px-4 py-6 text-center transition-colors ".concat(f?"bg-primary/10 border-primary":"border-primary/25 hover:border-primary/50 hover:bg-primary/[0.04] bg-white/40 dark:border-white/15 dark:bg-white/[0.02]"),children:[(0,a.jsx)(b.Z,{className:"h-5 w-5 text-primary"}),(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Drop audio here or click to upload"}),(0,a.jsx)("span",{className:"text-[11px] text-default-400",children:C.join(", ")}),(0,a.jsx)("input",{ref:S,type:"file",accept:M,className:"hidden",onChange:e=>{var t;return O(null===(t=e.target.files)||void 0===t?void 0:t[0])}})]}),"record"===g&&(0,a.jsx)("div",{className:"border-primary/20 flex flex-col items-center gap-3 rounded-xl border bg-white/40 px-4 py-6 dark:border-white/10 dark:bg-white/[0.02]",children:I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex h-9 items-center gap-[3px]",children:c.map((e,t)=>(0,a.jsx)("span",{className:"w-1 rounded-full bg-primary transition-[height] duration-75 ease-out",style:{height:"".concat(Math.max(3,34*e),"px")}},t))}),(0,a.jsx)("span",{className:"font-mono text-sm font-semibold text-primary",children:(0,p.LU)(d)}),(0,a.jsxs)("button",{type:"button",onClick:x,className:"flex items-center gap-1.5 rounded-lg bg-red-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-red-600",children:[(0,a.jsx)(y.Z,{className:"h-3.5 w-3.5"})," Stop"]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",onClick:()=>m(t),className:"shadow-primary/30 flex h-14 w-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg transition-transform hover:scale-105 hover:bg-primary-hover",children:(0,a.jsx)(v.Z,{className:"h-6 w-6"})}),(0,a.jsx)("span",{className:"text-xs text-default-500",children:"Tap to start recording"})]})}),r&&i&&(0,a.jsxs)("div",{className:"border-primary/15 bg-primary/[0.04] flex items-center gap-2 rounded-xl border px-3 py-2 dark:border-white/10 dark:bg-white/[0.03]",children:[(0,a.jsx)(j.Z,{className:"h-4 w-4 shrink-0 text-primary"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-[11px] text-default-600 dark:text-white/70",children:r.name}),(0,a.jsx)("audio",{src:i,controls:!0,className:"h-8 w-[40%] min-w-0 max-w-[150px] shrink-0"})]})]})}async function S(e,t){try{let r=window.AudioContext||window.webkitAudioContext;if(!r||!e)return[];let a=await e.arrayBuffer(),l=new r,i=(await l.decodeAudioData(a)).getChannelData(0),s=Math.floor(i.length/t)||1,n=[];for(let e=0;e<t;e+=1){let t=0;for(let r=0;r<s;r+=1){let a=Math.abs(i[e*s+r]||0);a>t&&(t=a)}n.push(t)}l.close().catch(()=>{});let o=Math.max(...n,.01);return n.map(e=>e/o)}catch(e){return[]}}function C(e){let{file:t,duration:r,start:i,end:s,onChange:n,minSegment:o=p.z5,maxSegment:d=p.QL}=e,[c,u]=(0,l.useState)([]),m=(0,l.useRef)(null),x=(0,l.useRef)(null),g=(0,l.useRef)({});g.current={start:i,end:s,duration:r,onChange:n,minSegment:o,maxSegment:d},(0,l.useEffect)(()=>{let e=!0;return u([]),t&&S(t,90).then(t=>e&&u(t)),()=>{e=!1}},[t]);let h=e=>{var t;let r=null===(t=m.current)||void 0===t?void 0:t.getBoundingClientRect();return r&&0!==r.width?Math.min(1,Math.max(0,(e-r.left)/r.width))*g.current.duration:0};(0,l.useEffect)(()=>{let e=e=>{if(!x.current)return;let{start:t,end:r,duration:a,onChange:l,minSegment:i,maxSegment:s}=g.current,n=h(e.clientX);"start"===x.current?l(Math.min(Math.max(n,Math.max(0,r-s)),r-i),r):l(t,Math.max(Math.min(n,Math.min(a,t+s)),t+i))},t=()=>{x.current=null,document.body.style.userSelect=""};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[]);let f=r?i/r*100:0,b=r?s/r*100:100,v=s-i>=o,y=e=>t=>{t.preventDefault(),x.current=e,document.body.style.userSelect="none"};return(0,a.jsxs)("div",{className:"border-primary/15 bg-primary/[0.03] space-y-1.5 rounded-lg border px-3 py-2.5 dark:border-white/10 dark:bg-white/[0.02]",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-[11px] text-default-500",children:[(0,a.jsxs)("span",{children:["Range:"," ",(0,a.jsxs)("span",{className:"font-medium text-primary",children:[(0,p.LU)(i)," â ",(0,p.LU)(s)]})]}),(0,a.jsx)("span",{className:v?"text-primary":"text-red-500",children:(0,p.LU)(s-i)})]}),(0,a.jsxs)("div",{ref:m,className:"relative h-16 touch-none select-none",children:[(0,a.jsx)("div",{className:"absolute inset-0 flex items-center gap-[2px]",children:(c.length?c:Array(90).fill(.04)).map((e,t)=>{let r=(t+.5)/90*100;return(0,a.jsx)("span",{className:"flex-1 rounded-full transition-colors ".concat(r>=f&&r<=b?"bg-primary":"bg-default-300/70 dark:bg-white/15"),style:{height:"".concat(Math.max(6,100*e),"%")}},t)})}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 rounded-l-md bg-default-200/55 dark:bg-black/45",style:{width:"".concat(f,"%")}}),(0,a.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 rounded-r-md bg-default-200/55 dark:bg-black/45",style:{width:"".concat(100-b,"%")}}),(0,a.jsx)("div",{className:"border-primary/80 bg-primary/[0.08] pointer-events-none absolute inset-y-0 rounded border",style:{left:"".concat(f,"%"),width:"".concat(Math.max(0,b-f),"%")}}),(0,a.jsx)("div",{role:"slider","aria-label":"Range start","aria-valuenow":Math.round(i),tabIndex:0,onPointerDown:y("start"),className:"group absolute top-1/2 z-10 flex h-full w-5 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize items-center justify-center",style:{left:"".concat(f,"%")},children:(0,a.jsx)("span",{className:"h-9 w-[5px] rounded-full bg-primary shadow-md ring-2 ring-white transition-transform group-hover:scale-y-110 dark:ring-white/85"})}),(0,a.jsx)("div",{role:"slider","aria-label":"Range end","aria-valuenow":Math.round(s),tabIndex:0,onPointerDown:y("end"),className:"group absolute top-1/2 z-10 flex h-full w-5 -translate-x-1/2 -translate-y-1/2 cursor-ew-resize items-center justify-center",style:{left:"".concat(b,"%")},children:(0,a.jsx)("span",{className:"h-9 w-[5px] rounded-full bg-primary shadow-md ring-2 ring-white transition-transform group-hover:scale-y-110 dark:ring-white/85"})})]}),(0,a.jsxs)("p",{className:"text-[10px] text-default-400",children:["Drag the handles to pick a ",o,"sâ",d,"s segment."]})]})}let M="flex w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-50",I={trigger:"bg-white border-default-200 data-[hover=true]:border-primary/40 data-[focus=true]:border-primary dark:bg-white/[0.03] dark:border-white/10",value:"text-foreground",popoverContent:"bg-white dark:bg-background"};
1function O(e){let{index:t,title:r,desc:l,active:i,done:s,locked:o,last:d,children:c}=e;return(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-bold transition-colors ".concat(s?"bg-primary text-primary-foreground":i?"bg-primary/15 ring-primary/40 text-primary ring-2":"bg-default-100 text-default-400 dark:bg-white/5 dark:text-white/30"),children:s?(0,a.jsx)(n.Z,{className:"h-4 w-4"}):t}),!d&&(0,a.jsx)("div",{className:"bg-primary/15 mt-1 w-px flex-1 dark:bg-white/10"})]}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 pb-5 ".concat(o?"opacity-50":""),children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-foreground",children:r}),(0,a.jsx)("p",{className:"mb-2.5 text-[11px] text-default-400",children:l}),!o&&c]})]})}var _=function(e){let{field:t={},onChange:r,isPreview:n=!1}=e,{playgroundStore:b}=(0,c.o)(),v={validate:t.endpointValidate,validateInfo:t.endpointValidateInfo,result:t.endpointResult,generate:t.endpointGenerate,regenerate:t.endpointRegenerate},y=Number(t.minDurationS)>0?Number(t.minDurationS):p.z5,j=Number(t.maxDurationS)>0?Number(t.maxDurationS):p.QL,k=(0,l.useMemo)(()=>{let e=(Array.isArray(t.languageOptions)?t.languageOptions:[]).filter(e=>e&&e.value);return e.length?e:p.kJ},[t.languageOptions]),w=(0,l.useMemo)(()=>(0,p.r7)(t.acceptedExtensions),[t.acceptedExtensions]),{form:N,updateForm:S,currentStep:_,taskId:F,validateInfo:E,errorMessage:P,errorPayload:T,sourceFile:L,sourcePreviewUrl:D,sourceDuration:R,vocalStart:U,vocalEnd:z,setVocalStart:V,setVocalEnd:K,handleSourceFile:q,verifyFile:B,verifyPreviewUrl:W,verifyUrl:Z,handleVerifyFile:J,isRecording:G,recordingTarget:H,recordingSeconds:Y,livePeaks:$,startRecording:X,stopRecording:Q,loading:ee,canGenerate:et,prepareSource:er,prepareVerify:ea,regeneratePhrase:el}=function(){let{endpoints:e={},uploadBucket:t=p.oN,minDuration:r=p.z5,maxDuration:a=p.QL,acceptedExtensions:i=p.VW}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[s,n]=(0,l.useState)(g),[o,d]=(0,l.useState)(""),[c,b]=(0,l.useState)(""),[v,y]=(0,l.useState)(""),[j,k]=(0,l.useState)("idle"),[w,N]=(0,l.useState)(""),[A,S]=(0,l.useState)(null),[C,M]=(0,l.useState)(null),[I,O]=(0,l.useState)(!1),[_,F]=(0,l.useState)(null),[E,P]=(0,l.useState)(""),[T,L]=(0,l.useState)(""),[D,R]=(0,l.useState)(0),[U,z]=(0,l.useState)(0),[V,K]=(0,l.useState)(0),[q,B]=(0,l.useState)(null),[W,Z]=(0,l.useState)(""),[J,G]=(0,l.useState)(""),[H,Y]=(0,l.useState)(!1),[$,X]=(0,l.useState)(""),[Q,ee]=(0,l.useState)(0),[et,er]=(0,l.useState)(()=>Array(p.lv).fill(0)),[ea,el]=(0,l.useState)({preparingSource:!1,gettingPhrase:!1,preparingVerify:!1,generating:!1,regenerating:!1}),[ei,es]=(0,l.useState)(!1),en=(0,l.useRef)(null),eo=(0,l.useRef)(null),ed=(0,l.useRef)([]),ec=(0,l.useRef)(null),eu=(0,l.useRef)(0),em=(0,l.useRef)(null),ex=(0,l.useRef)(null),ep=(0,l.useRef)(null),eg=(0,l.useRef)(null),eh=(0,l.useRef)(null),ef=(0,l.useRef)(Array(p.lv).fill(0)),eb=(0,l.useCallback)((e,t)=>{el(r=>({...r,[e]:t}))},[]),ev=(0,l.useMemo)(()=>v||"success"===j||ei||J?"generate":c?"verify":o?"phrase":"source",[v,j,ei,J,c,o]),ey=(0,l.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],l=r?"":(0,p.Ri)(e,i);if(l){u.Am.error(l);return}let s=URL.createObjectURL(e);F(e),P(s),L(""),d(""),b(""),y(""),k("idle"),N(""),M(null),O(!1);let n=await f(s),o=n>0?n:t;R(o),z(0),K(o?Math.min(o,a):0)},[a,i]),ej=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t?"":(0,p.Ri)(e,i);if(r){u.Am.error(r);return}let a=URL.createObjectURL(e);B(e),Z(a),G("")},[i]),ek=(0,l.useCallback)(()=>{ec.current&&(clearInterval(ec.current),ec.current=null)},[]),ew=(0,l.useCallback)(()=>{var e;null===(e=eo.current)||void 0===e||e.getTracks().forEach(e=>e.stop()),eo.current=null},[]),eN=(0,l.useCallback)(()=>{eh.current&&(cancelAnimationFrame(eh.current),eh.current=null),ep.current&&(ep.current.close().catch(()=>{}),ep.current=null),eg.current=null,ef.current=Array(p.lv).fill(0),er(Array(p.lv).fill(0))},[]),eA=(0,l.useCallback)(e=>{try{let t=window.AudioContext||window.webkitAudioContext;if(!t)return;let r=new t,a=r.createMediaStreamSource(e),l=r.createAnalyser();l.fftSize=1024,a.connect(l),ep.current=r,eg.current=l;let i=new Uint8Array(l.fftSize),s=()=>{l.getByteTimeDomainData(i);let e=0;for(let t=0;t<i.length;t+=1){let r=(i[t]-128)/128;e+=r*r}let t=Math.sqrt(e/i.length),r=ef.current.slice(1);r.push(Math.min(1,Math.max(.04,3.2*t))),ef.current=r,er(r),eh.current=requestAnimationFrame(s)};eh.current=requestAnimationFrame(s)}catch(e){}},[]),eS=(0,l.useCallback)(async e=>{var t;if(!H){if("undefined"==typeof navigator||!(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.getUserMedia)){u.Am.error("Recording is not supported in this browser");return}try{let t=await navigator.mediaDevices.getUserMedia({audio:!0});eo.current=t,eA(t);let r=(0,p.ww)(),a=r?new MediaRecorder(t,{mimeType:r}):new MediaRecorder(t);en.current=a,ed.current=[],a.ondataavailable=e=>{e.data&&e.data.size>0&&ed.current.push(e.data)},a.onstop=async()=>{ek(),eN();let t=(Date.now()-eu.current)/1e3;ew(),Y(!1);let r="source"===e?p.H6:p.J8;if(t<r){u.Am.error("Recording must be at least ".concat(r," seconds"));return}let l=a.mimeType||"audio/webm",i=l.includes("mp4")?"mp4":l.includes("ogg")?"ogg":"webm",s=new Blob(ed.current,{type:l}),n=new File([s],"".concat(e,"-").concat(Date.now(),".").concat(i),{t
1ype:l});"source"===e?await ey(n,t,!0):ej(n,!0)},eu.current=Date.now(),X(e),ee(0),Y(!0),a.start(1e3),ec.current=setInterval(()=>ee(e=>e+1),1e3)}catch(e){u.Am.error((null==e?void 0:e.message)||"Microphone permission denied"),eN(),ew()}}},[H,ey,ej,ek,ew,eA,eN]),eC=(0,l.useCallback)(()=>{en.current&&"inactive"!==en.current.state&&en.current.stop()},[]),eM=(0,l.useCallback)(e=>(0,m._R)(e,t),[t]),eI=(0,l.useCallback)(async()=>{if(!_){u.Am.error("Please select or record a source audio first");return}let t=V-U;if(t<r||t>a){u.Am.error("Selected range must be ".concat(r,"sâ").concat(a,"s"));return}eb("preparingSource",!0),N(""),M(null);try{let t=await eM(_);L(t);let r=await (0,x.ry)({endpoint:e.validate,data:{voiceUrl:t,vocalStartS:Math.round(U),vocalEndS:Math.round(V),language:s.language}}),a=(null==r?void 0:r.data)||{};S(r),a.taskId&&d(a.taskId),k(a.status||"wait_processing"),(0,p.eW)(a.status)?(N(a.errorMessage||"Failed to process source audio"),M(r)):a.validateInfo&&b(a.validateInfo)}catch(e){k("fail"),N((null==e?void 0:e.message)||"Failed to create validation task"),M(h(e))}finally{eb("preparingSource",!1)}},[_,U,V,r,a,s.language,e.validate,eM,eb]),eO=(0,l.useCallback)(async function(){let{silent:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o)try{let r=await (0,x.m$)({endpoint:e.validateInfo,taskId:o}),a=(null==r?void 0:r.data)||{};if(S(r),(0,p.eW)(a.status)){k(a.status),N(a.errorMessage||"Validation phrase failed"),M(r),t||u.Am.error(a.errorMessage||"Validation phrase failed");return}(a.validateInfo||"wait_validating"===a.status)&&(a.validateInfo&&b(a.validateInfo),k(a.status||"wait_validating"),!t&&a.validateInfo&&u.Am.success("Validation phrase is ready"))}catch(e){M(h(e)),t||u.Am.error((null==e?void 0:e.message)||"Failed to fetch validation phrase")}},[o,e.validateInfo]),e_=(0,l.useCallback)(async()=>{if(!q){u.Am.error("Please record or upload your validation audio first");return}eb("preparingVerify",!0),N(""),M(null);try{let e=await eM(q);G(e),k("wait_validating")}catch(e){N((null==e?void 0:e.message)||"Failed to upload validation audio"),M(h(e))}finally{eb("preparingVerify",!1)}},[q,eM,eb]),eF=(0,l.useCallback)(async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!o||!c||!J){u.Am.error("Please complete the first three steps before generating");return}O(!0),eb("generating",!0),N("");try{let r=await (0,x.oA)({endpoint:e.generate,data:{taskId:o,verifyUrl:J,...t}}),a=(null==r?void 0:r.data)||{};if(S(r),k(a.status||"wait_processing"),a.voiceId&&y(a.voiceId),(0,p.eW)(a.status)){N(a.errorMessage||"Voice generation failed"),eb("generating",!1);return}es(!0)}catch(e){k("fail"),N((null==e?void 0:e.message)||"Failed to generate voice"),eb("generating",!1)}},[o,c,J,e.generate,eb]),eE=(0,l.useCallback)(async function(){let{silent:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o)try{let r=await (0,x.i8)({endpoint:e.result,taskId:o}),a=(null==r?void 0:r.data)||{};S(r);let l=a.voiceId||"success"===a.status||(0,p.eW)(a.status);a.status&&k(a.status),a.voiceId&&y(a.voiceId),l&&(es(!1),eb("generating",!1),(0,p.eW)(a.status)?N(a.errorMessage||"Voice generation failed"):!t&&a.voiceId&&u.Am.success("Voice generated"))}catch(e){t||u.Am.error((null==e?void 0:e.message)||"Failed to fetch voice result")}},[o,e.result,eb]),eP=(0,l.useCallback)(async()=>{if(o){eb("regenerating",!0),N("");try{let t=await (0,x.HO)({endpoint:e.regenerate,data:{taskId:o}}),r=(null==t?void 0:t.data)||{};S(t),r.taskId&&d(r.taskId),b(""),B(null),Z(""),G(""),k(r.status||"wait_processing")}catch(e){N((null==e?void 0:e.message)||"Failed to regenerate phrase"),M(h(e)),u.Am.error((null==e?void 0:e.message)||"Failed to regenerate phrase")}finally{eb("regenerating",!1)}}},[o,e.regenerate,eb]);return(0,l.useEffect)(()=>{let e=()=>{em.current&&(clearInterval(em.current),em.current=null)};return e(),o&&!c&&["wait_processing","processing_validate"].includes(j)&&(em.current=setInterval(()=>eO({silent:!0}),p.gD)),e},[o,c,j,eO]),(0,l.useEffect)(()=>{let e=()=>{ex.current&&(clearInterval(ex.current),ex.current=null)};return e(),ei&&o&&!v&&["wait_processing","processing_validate","wait_validating"].includes(j)&&(ex.current=setInterval(()=>eE({silent:!0}),p.gD)),e}
1,[ei,o,v,j,eE]),(0,l.useEffect)(()=>()=>{ek(),eN(),ew(),em.current&&clearInterval(em.current),ex.current&&clearInterval(ex.current)},[ek,eN,ew]),{form:s,updateForm:(0,l.useCallback)((e,t)=>{n(r=>({...r,[e]:t}))},[]),currentStep:ev,taskId:o,validateInfo:c,voiceId:v,status:j,errorMessage:w,errorPayload:C,outputJson:A,sourceFile:_,sourcePreviewUrl:E,sourceUrl:T,sourceDuration:D,vocalStart:U,vocalEnd:V,setVocalStart:z,setVocalEnd:K,handleSourceFile:ey,verifyFile:q,verifyPreviewUrl:W,verifyUrl:J,handleVerifyFile:ej,isRecording:H,recordingTarget:$,recordingSeconds:Q,livePeaks:et,startRecording:eS,stopRecording:eC,loading:ea,generationStarted:ei,generateClicked:I,canGenerate:!!o&&!!c&&!!J,prepareSource:eI,prepareVerify:e_,generateVoice:eF,regeneratePhrase:eP}}({endpoints:v,minDuration:y,maxDuration:j,acceptedExtensions:w}),ei=(0,l.useRef)(r);ei.current=r,(0,l.useEffect)(()=>{var e;null===(e=ei.current)||void 0===e||e.call(ei,"taskId",F)},[F]),(0,l.useEffect)(()=>{var e;null===(e=ei.current)||void 0===e||e.call(ei,"verifyUrl",Z)},[Z]),(0,l.useEffect)(()=>{b.setVoiceError(null!=T?T:null)},[b,T]),(0,l.useEffect)(()=>()=>b.setVoiceError(null),[b]);let es=e=>{let t=p.TZ.map(e=>e.key),r=t.indexOf(_),a=t.indexOf(e);return n?{active:0===a,done:!1,locked:!1}:{active:a===r,done:a<r,locked:a>r}},en=z-U>=y;return(0,a.jsx)("div",{className:"w-full min-w-0 space-y-5",children:(0,a.jsxs)("div",{className:"pt-1",children:[(0,a.jsx)(O,{index:1,title:p.TZ[0].title,desc:p.TZ[0].desc,last:!1,...es("source"),children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-default-500 dark:text-white/55",children:"language"}),(0,a.jsx)(i.g,{"aria-label":"language",variant:"bordered",size:"sm",radius:"lg",selectedKeys:N.language?[N.language]:[],onSelectionChange:e=>S("language",Array.from(e)[0]||""),classNames:I,children:k.map(e=>(0,a.jsx)(s.R,{children:e.label},e.value))})]}),(0,a.jsx)(A,{target:"source",file:L,previewUrl:D,onFile:q,isRecording:G,recordingTarget:H,recordingSeconds:Y,livePeaks:$,acceptedExtensions:w,onStartRecording:X,onStopRecording:Q}),R>0&&(0,a.jsx)(C,{file:L,duration:R,start:U,end:z,minSegment:y,maxSegment:j,onChange:(e,t)=>
1{V(e),K(t)}}),(0,a.jsxs)("button",{type:"button",className:M,disabled:!L||!en||ee.preparingSource,onClick:er,children:[ee.preparingSource&&(0,a.jsx)(o.Z,{className:"h-4 w-4 animate-spin"}),ee.preparingSource?"Uploadingâ¦":"Next: get phrase"]})]})}),(0,a.jsx)(O,{index:2,title:p.TZ[1].title,desc:p.TZ[1].desc,last:!1,...es("phrase"),children:E?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"border-primary/20 bg-primary/[0.06] rounded-lg border px-3 py-2.5 text-sm font-medium text-foreground dark:border-white/10 dark:bg-white/[0.04]",children:["â",E,"â"]}),(0,a.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-[11px] font-medium text-primary hover:underline disabled:opacity-50",disabled:ee.regenerating,onClick:el,children:[(0,a.jsx)(d.Z,{className:"h-3 w-3 ".concat(ee.regenerating?"animate-spin":"")}),"Regenerate phrase"]})]}):(0,a.jsxs)("div",{className:"border-primary/15 bg-primary/[0.03] flex items-center gap-2 rounded-lg border px-3 py-2.5 text-xs text-default-500 dark:border-white/10 dark:bg-white/[0.02]",children:[(0,a.jsx)(o.Z,{className:"h-3.5 w-3.5 animate-spin text-primary"}),"Generating your validation phraseâ¦"]})}),(0,a.jsx)(O,{index:3,title:p.TZ[2].title,desc:p.TZ[2].desc,last:!1,...es("verify"),children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(A,{target:"verify",file:B,previewUrl:W,onFile:J,isRecording:G,recordingTarget:H,recordingSeconds:Y,livePeaks:$,acceptedExtensions:w,onStartRecording:X,onStopRecording:Q}),(0,a.jsxs)("button",{type:"button",className:M,disabled:!B||ee.preparingVerify||!!Z,onClick:ea,children:[ee.preparingVerify&&(0,a.jsx)(o.Z,{className:"h-4 w-4 animate-spin"}),Z?"Validation uploaded â":ee.preparingVerify?"Uploadingâ¦":"Confirm validation audio"]})]})}),(0,a.jsxs)(O,{index:4,title:p.TZ[3].title,desc:p.TZ[3].desc,last:!0,...es("generate"),children:[(0,a.jsx)("p",{className:"text-[11px] text-default-400",children:et?"Click Run below to start generation.":"Complete the first three steps to enable generation."}),!n&&F&&Z&&(0,a.jsx)("p",{className:"mt-1 text-[10px] text-default-400",children:"taskId & verifyUrl are ready and will be sent with Run."}),P&&(0,a.jsx)("p",{className:"mt-2 text-[11px] text-red-500 dark:text-red-400",children:P})]})]})})}},97793:function(e,t,r){r.d(t,{H6:function(){return o},J8:function(){return d},LU:function(){return b},QL:function(){return u},Ri:function(){return h},TZ:function(){return a},VW:function(){return i},eW:function(){return p},gD:function(){return m},kJ:function(){return l},lv:function(){return n},oN:function(){return x},r7:function(){return g},ww:function(){return f},z5:function(){return c}});let a=[{key:"source",index:1,title:"Source Audio",desc:"Upload or record a 10sâ4m singing sample."},{key:"phrase",index:2,title:"Validation Phrase",desc:"Read the phrase generated from your sample."},{key:"verify",index:3,title:"Validation Audio",desc:"Record or upload yourself reading the phrase."},{key:"generate",index:4,title:"Generate Voice",desc:"Name your voice and start the build."}],l=[{value:"en",label:"English"},{value:"zh",label:"Chinese"},{value:"es",label:"Spanish"},{value:"fr",label:"French"},{value:"pt",label:"Portuguese"},{value:"de",label:"German"},{value:"ja",label:"Japanese"},{value:"ko",label:"Korean"},{value:"hi",label:"Hindi"},{value:"ru",label:"Russian"}],i=["mp3","wav","ogg","m4a","flac","aac","webm"],s=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"],n=28,o=10,d=3,c=10,u=240,m=3e3,x="emixai/suno",p=e=>"string"==typeof e&&e.toLowerCase().includes("fail"),g=e=>{let t=(Array.isArray(e)?e:String(e||"").split(",")).map(e=>String(e).trim().replace(/^\./,"").toLowerCase()).filter(Boolean);return t.length?t:i},h=function(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;if(!e)return"No file selected";let a=(null==r?void 0:r.length)?r:i,l=(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase())||"";return a.includes(l)?e.size>209715200?"File exceeds ".concat(200,"MB"):"":"Unsupported format. Use: ".concat(a.join(", "))},f=()=>"undefined"==typeof MediaRecorder?"":s.find(e=>{var t,r;
1return null===(t=(r=MediaRecorder).isTypeSupported)||void 0===t?void 0:t.call(r,e)})||"",b=e=>!Number.isFinite(e)||e<0?"0:00":"".concat(Math.floor(e/60),":").concat(String(Math.floor(e%60)).padStart(2,"0"))},15050:function(e,t,r){r.d(t,{Gc:function(){return n},uc:function(){return d},z5:function(){return o}});var a=r(39696),l=r(90170),i=r(30467);let s=(0,l.createContext)(null);function n(e,t,r){let a={visible:!0,disabled:!1,overrideValue:void 0,overrideOptions:void 0,disabledOptions:void 0,patchProps:void 0};return Array.isArray(t)&&t.length>0&&t.forEach(t=>{let l=(0,i.Tl)(t);l.enabled&&((0,i.Nf)(l.conditions,l.match,r)?l.effects:l.elseEffects).forEach(t=>{t.field===e&&(0,i.nC)(t,a)})}),{...a,forcedValue:a.overrideValue}}function o(e){let{rules:t=[],initialValues:r={},children:i}=e,[o,d]=(0,l.useState)(r),c=(0,l.useCallback)((e,t)=>{d(r=>r[e]===t?r:{...r,[e]:t})},[]),u=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};d(e)},[]),m=(0,l.useCallback)(e=>n(e,t,o),[t,o]);return(0,a.jsx)(s.Provider,{value:{formValues:o,setFieldValue:c,resetFormValues:u,getFieldState:m},children:i})}function d(){return(0,l.useContext)(s)}},75871:function(e,t,r){r.d(t,{F:function(){return a}});let a=(e,t)=>{let r="string"==typeof e?e.length:0,a=Number(t),l=Number.isFinite(a)&&a>0;return{hasLimit:l,count:r,limit:a,isAtLimit:l&&r>=a}}},30467:function(e,t,r){r.d(t,{$V:function(){return l},Nf:function(){return f},OB:function(){return d},Tl:function(){return N},W6:function(){return S},fP:function(){return i},h2:function(){return n},jQ:function(){return o},mu:function(){return A},nC:function(){return v},pP:function(){return s},r8:function(){return b}});var a=r(83460);let l={NONE:"none",TEXT:"text",NUMBER:"number",LIST:"list",REGEX:"regex",EITHER:"either"},i=[{label:"çäº (eq)",value:"eq",valueKind:l.EITHER,group:"æ¯è¾"},{label:"ä¸çäº (neq)",value:"neq",valueKind:l.EITHER,group:"æ¯è¾"},{label:"å¤§äº (gt)",value:"gt",valueKind:l.NUMBER,group:"æ¯è¾"},{label:"大äºçäº (gte)",value:"gte",valueKind:l.NUMBER,group:"æ¯è¾"},{label:"å°äº (lt)",value:"lt",valueKind:l.NUMBER,group:"æ¯è¾"},{label:"å°äºçäº (lte)",value:"lte",valueKind:l.NUMBER,group:"æ¯è¾"},{label:"为ç (truthy)",value:"truthy",valueKind:l.NONE,group:"å卿§"},{label:"为å (falsy)",value:"falsy",valueKind:l.NONE,group:"å卿§"},{label:"为空 (empty)",value:"empty",valueKind:l.NONE,group:"å卿§"},{label:"é空 (notEmpty)",value:"notEmpty",valueKind:l.NONE,group:"å卿§"},{label:"çäºå
¶ä¸ä¸é¡¹ (oneOf)",value:"oneOf",valueKind:l.LIST,group:"éå"},{label:"ä¸çäºä»»ä½ä¸é¡¹ (notOneOf)",value:"notOneOf",valueKind:l.LIST,group:"éå"},{label:"æ°ç»å
å« (includes)",value:"includes",valueKind:l.TEXT,group:"éå"},{label:"æ°ç»ä¸å
å« (notIncludes)",value:"notIncludes",valueKind:l.TEXT,group:"éå"},{label:"å
嫿æ¬ï¼å·¦è¾¹å«å³è¾¹ (in)",value:"in",valueKind:l.TEXT,group:"éå"},{label:"ä¸å
嫿æ¬ï¼å·¦è¾¹ä¸å«å³è¾¹ (notIn)",value:"notIn",valueKind:l.TEXT,group:"éå"},{label:"模ç³å¹é
ï¼ä»»ä¸æ¹å«å¦ä¸æ¹ï¼å¿½ç¥å¤§å°åï¼",value:"fuzzy",valueKind:l.TEXT,group:"éå"},{label:"模ç³ä¸å¹é
",value:"notFuzzy",valueKind:l.TEXT,group:"éå"},{label:"é¿åº¦çäº",value:"lengthEq",valueKind:l.NUMBER,group:"é¿åº¦"},{label:"é¿åº¦å¤§äº",value:"lengthGt",valueKind:l.NUMBER,group:"é¿åº¦"},{label:"é¿åº¦å¤§äºçäº",value:"lengthGte",valueKind:l.NUMBER,group:"é¿åº¦"},{label:"é¿åº¦å°äº",value:"lengthLt",valueKind:l.NUMBER,group:"é¿åº¦"},{label:"é¿åº¦å°äºçäº",value:"lengthLte",valueKind:l.NUMBER,group:"é¿åº¦"},{label:"æ£åå¹é
",value:"matches",valueKind:l.REGEX,group:"æ£å"},{label:"æ£åä¸å¹é
",value:"notMatches",valueKind:l.REGEX,group:"æ£å"}],s={NONE:"none",OPTIONAL_VALUE:"optionalValue",VALUE:"value",OPTION_KEYS:"optionKeys",PROPS:"props",JSON:"json"},n=[{label:"éè (hide)",value:"hide",valueKind:s.NONE},{label:"ç¦ç¨ (disable)",value:"disable",valueKind:s.OPTIONAL_VALUE},{label:"强å¶åå¼ (setValue)",value:"setValue",valueKind:s.VALUE},{label:"ç¦ç¨é¨åé项 (disableOptions)",value:"disableOptions",valueKind:s.OPTION_KEYS},{label:"ä¿®æ¹å±æ§ (patchProps)",value:"patchProps",valueKind:s.PROPS},{label:"æ¿æ¢é项 (setOptions)",value:"setOptions",valueKind:s.JSON}],o=e=>i.find(t=>t.value===e),d=e=>n.find(t=>t.value===e),c=e=>Array.isArray(e)||"string"==typeof e?e.length:0,u=e=>null==e||"string"==typeof e&&""===e.trim()||Array.isArray(e)&&e.every(e=>null==e||""===e),m=e=>String(e).split(",").map(e=>e.trim()),x=(e,t)=>{try{return new RegExp(String(t)).test(String(null!=e?e:""))}catch(e){return console.warn("[linkageRuleSchema] éæ³çæ£å表达å¼ï¼è¯¥æ¡ä»¶æä¸å¹é
å¤çï¼",t),null}},p=new Set(["matches","notMatches","in","notIn","includes","notIncludes","fuzzy","notFuzzy"]),g=(e,t,r)=>{if(p.has(t)&&""===(null==r?"":String(r)))return!1;switch(t){case"eq":return e===r;case"neq":return e!==r;case"gt":return Number(e)>Number(r);case"gte":return Number(e)>=Number(r);case"lt":return Number(e)<Number(r);case"lte":return Number(e)<=Number(r);case"in":return String(e).includes(String(r));case"notIn":return!String(e).includes(String(r));case"fuzzy":case"notFuzzy":{let a=String(null!=e?e:"").toLowerCase(),l=String(null!=r?r:"").toLowerCase(),i=""!==a&&""!==l&&(a.includes(l)||l.includes(a));return"fuzzy"===t?i:!i}case"includes":case"notIncludes":{let a=Array.isArray(e)?e.some(e=>String(e)===String(r)):String(null!=e?e:"").includes(String(r));return"includes"===t?a:!a}case"oneOf":return m(r).some(t=>t===String(e));case"notOneOf":return m(r).every(t=>t!==String(e));case"truthy":return!!e;case"falsy":return!e;case"empty":return u(e);case"notEmpty":return!u(e);case"lengthEq":return c(e)===Number(r);case"lengthGt":return c(e)>Number(r);case"lengthGte":return c(e)>=Number(r);case"lengthLt":return c(e)<Number(r);case"lengthLte":return c(e)<=Number(r);case"matches":case"notMatches":{let a=x(e,r);if(null===a)return!1;return"matches"===t?a:!a}default:return!1}},h=(e,t)=>"field"===e.valueSource?(0,a.l2)(t,e.value):e.value,f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!Array.isArray(e)||0===e.length)return!1;let l=e=>g((0,a.l2)(r,e.field),e.operator,h(e,r));return"any"===t?e.some(l):e.every(l)},b=e=>{let t=null==e?void 0:e.raw;if(null==t||""===t)return"";try{return JSON.parse(t)}catch(e){return t}},v=(e,t)=>
1{var r,a,l,i;let{action:s,value:n}=e;switch(s){case"hide":t.visible=!1;break;case"disable":t.disabled=!0,n&&void 0!==n.raw&&null!==n.raw&&(t.overrideValue=b(n));break;case"setValue":t.overrideValue=b(n);break;case"setOptions":try{t.overrideOptions=JSON.parse(null!==(r=null==n?void 0:n.raw)&&void 0!==r?r:n)}catch(e){console.warn("[linkageRuleSchema] setOptions: å¨ä½å¼ä¸æ¯åæ³ç JSON æ°ç»",n)}break;case"disableOptions":{let e=null!==(a=null==n?void 0:n.raw)&&void 0!==a?a:n;if(!e)break;t.disabledOptions=String(e).split(",").map(e=>e.trim()).filter(Boolean);break}case"patchProps":try{let e=JSON.parse(null!==(l=null==n?void 0:n.raw)&&void 0!==l?l:n);e&&"object"==typeof e&&!Array.isArray(e)&&(t.patchProps={...null!==(i=t.patchProps)&&void 0!==i?i:{},...e})}catch(e){console.warn("[linkageRuleSchema] patchProps: å¨ä½å¼ä¸æ¯åæ³ç JSON 对象",n)}}},y=function(){var e,t;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{field:null!==(e=r.field)&&void 0!==e?e:"",operator:null!==(t=r.operator)&&void 0!==t?t:"eq",valueSource:"field"===r.valueSource?"field":"const",value:r.value,valueType:"number"===r.valueType?"number":"string"}},j=e=>Array.isArray(e)?e.filter(Boolean).map(e=>{var t,r,a;return{field:null!==(t=e.field)&&void 0!==t?t:"",action:null!==(r=e.action)&&void 0!==r?r:"hide",value:null!==(a=e.value)&&void 0!==a?a:{raw:""}}}).filter(e=>""!==e.field):[],k=e=>{var t,r,a,l;return{conditions:e.whenField?[y({field:e.whenField,operator:null===(t=e.condition)||void 0===t?void 0:t.operator,value:null===(r=e.condition)||void 0===r?void 0:r.whenValue,valueType:null===(a=e.condition)||void 0===a?void 0:a.valueType})]:[],effects:e.effectField?[{field:e.effectField,action:e.effectAction||"hide",value:null!==(l=e.effectValue)&&void 0!==l?l:{raw:""}}]:[]}},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Array.isArray(null==e?void 0:e.conditions)&&e.conditions.length>0},N=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={name:"string"==typeof(null==e?void 0:e.name)?e.name:"",enabled:(null==e?void 0:e.enabled)!==!1,match:(null==e?void 0:e.match)==="any"?"any":"all"};if(w(e))return{...t,conditions:e.conditions.filter(Boolean).map(y),effects:j(e.effects),elseEffects:j(e.elseEffects)};let r=k(null!=e?e:{});return{...t,match:"all",conditions:r.conditions,effects:r.effects,elseEffects:[]}},A=e=>{if(!Array.isArray(e))return e;let t=!1,r=e.map(e=>{if(w(e))return e;let r=N(e);return r.conditions.length||r.effects.length?(t=!0,{...e,match:r.match,conditions:r.conditions,effects:r.effects,elseEffects:[]}):e});return t?r:e},S=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=N(e),r=t.enabled?"":"[å·²åç¨] ";if(t.name)return"".concat(r).concat(t.name);if(!t.conditions.length)return"".concat(r,"æ°è§å");let a="any"===t.match?" æ ":" ä¸ ",i=t.conditions.map(e=>{var t,r,a;let i=(null!==(a=null===(t=o(e.operator))||void 0===t?void 0:t.label)&&void 0!==a?a:e.operator).replace(/\s*\(.*\)$/,""),s=(null===(r=o(e.operator))||void 0===r?void 0:r.valueKind)===l.NONE||void 0===e.value||""===e.value?"":" ".concat(e.value);return"".concat(e.field," ").concat(i).concat(s)}).join(a),s=t.effects.length,n=t.elseEffects.length,d=n?"".concat(s," 个å¨ä½ / å¦å ").concat(n," 个"):"".concat(s," 个å¨ä½");return"".concat(r).concat(i," â ").concat(d)}},7986:function(e,t,r){r.d(t,{G:function(){return a}});function a(e,t,r,a,l,i){if(null==l||null==i||e<l||e>i)return e;let s=a||1,n=l-s,o=i+s;return Math.max(t,Math.min(r,e-n<=o-e?n:o))}},29193:function(e,t,r){r.d(t,{Z:function(){return U}});var a=r(39696),l=r(90170),i=r(84140),s=r(18492),n=r(44965),o=r(57571),d=r(2104),c=r(92315),u=r(72594),m=r(25411),x=r(69194),p=r(41588),g=r(13805),h=r(9043),f=r(23318),b=r(26972),v=r(78391),y=r(82045),j=r(60183),k=r(40559);let w=(e,t)=>/\.(png|jpe?g|webp|gif|avif|bmp|svg)(\?|#|$)/i.test(e)||(t||"").includes("image"),N=(e,t)=>/\.(mp4|webm|mov|m4v|ogv)(\?|#|$)/i.test(e)||(t||"").includes("video"),A=(e,t)=>/\.(mp3|wav|m4a|aac|ogg|flac)(\?|#|$)/i.test(e)||(t||"").includes("audio"),S=(e,t)=>{try{if(!e)return null;return"datetime"===t?(0,j.wG)(e.length<=16?"".concat(e,":00"):e):(0,j.sG)(e)}catch(e){return null}},C=e=>{try{return e?(0,j.TD)(e.length<=5?"".concat(e,":00"):e):null}catch(e){return null}};function M(e){let{node:t,value:r,disabled:d,onChange:c,onUploadStateChange:u}=e,[m,x]=(0,l.useState)(!1),p=!!t.multiple,g=p?Array.isArray(r)?r:[]:r?[r]:[],h=async e=>{let t=Array.from(e||[]);if(0===t.length)return;x(!0),null==u||u(1);let a=s.Am.loading("Uploading...");try{let e=await Promise.all(t.map(e=>(0,n._R)(e,"kieai/market")));s.Am.dismiss(a),p?c([...Array.isArray(r)?r:[],...e]):c(e[0])}catch(e){s.Am.error("Upload failed",{id:a})}finally{x(!1),null==u||u(-1)}},f=e=>{p?c((Array.isArray(r)?r:[]).filter((t,r)=>r!==e)):c("")};return(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("label",{className:"flex cursor-pointer flex-col items-center justify-center gap-1 rounded-medium border-2 border-dashed border-default-200 bg-default-50 py-4 text-xs text-default-500 transition-colors hover:border-primary hover:text-primary ".concat(d||m?"pointer-events-none opacity-50":""),children:[m?(0,a.jsx)(i.JO,{icon:"mingcute:loading-line",className:"animate-spin",width:18}):(0,a.jsx)(i.JO,{icon:"mingcute:upload-2-line",width:18}),m?"Uploadingâ¦":t.placeholder||"Drag & drop or click to upload",(0,a.jsx)("input",{type:"file",className:"hidden",multiple:p,accept:t.accept,disabled:d||m,onChange:e=>h(e.target.files)})]}),g.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:g.map((e,r)=>w(e,t.accept)?(0,a.jsxs)("div",{className:"group relative h-16 w-16 overflow-hidden rounded-medium border border-default-200",children:[(0,a.jsx)("img",{src:e,alt:"",className:"h-full w-full object-cover"}),(0,a.jsx)("button",{type:"button",disabled:d,onClick:()=>f(r),className:"absolute right-0.5 top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition-opacity group-hover:opacity-100",children:(0,a.jsx)(i.JO,{icon:"mingcute:close-line",width:10})})]},r):N(e,t.accept)?(0,a.jsxs)("div",{className:"group relative w-full overflow-hidden rounded-medium border border-default-200",children:[(0,a.jsx)("video",{src:e,controls:!0,className:"max-h-56 w-full bg-black object-contain"}),(0,a.jsx)("button",{type:"button",disabled:d,onClick:()=>f(r),className:"absolute right-1 top-1 flex h-5 w-5 items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition-opacity group-hover:opacity-100",children:(0,a.jsx)(i.JO,{icon:"mingcute:close-line",width:11})})]},r):A(e,t.accept)?(0,a.jsxs)("div",{className:"flex w-full items-center gap-2 rounded-medium border border-default-200 p-2",children:[(0,a.jsx)("audio",{src:e,controls:!0,className:"h-9 w-full"}),(0,a.jsx)("button",{type:"button",disabled:d,onClick:()=>f(r),className:"flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-default-200 text-default-600 hover:bg-default-300",children:(0,a.jsx)(i.JO,{icon:"mingcute:close-line",width:11})})]},r):(0,a.jsx)(o.z,{size:"sm",variant:"flat",onClose:d?void 0:()=>f(r),classNames:{base:"max-w-full",content:"truncate"},children:e},r))})]})}function I(e){let{node:t,value:r,disabled:i,onChange:s}=e,[n,d]=(0,l.useState)(""),c=Array.isArray(r)?r:[],u=()=>{let e=n.trim();if(!e||c.includes(e))return d("");s([...c,e]),d("")};return(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 rounded-medium border-2 border-default-200 bg-default-100 px-2 py-1.5",children:[c.map((e,t)=>(0,a.jsx)(o.z,{size:"sm",variant:"flat",color:"primary",onClose:i?void 0:()=>s(c.filter((e,r)=>r!==t)),children:e},t)),(0,a.jsx)("input",{value:n,disabled:i,placeholder:t.placeholder||"Type and press Enter",onChange:e=>d(e.target.value),onKeyDown:e=>"Enter"===e.key&&(e.preventDefault(),u()),onBlur:u,className:"min-w-[80px] flex-1 bg-transparent text-sm outline-none"})]})}let O=(()=>{let e=null,t=null,r=new Set,a=()=>
1r.forEach(e=>e()),l=()=>(e||"undefined"==typeof Audio||(e=new Audio).addEventListener("ended",()=>{t=null,a()}),e);return{isPlaying:r=>t===r&&!!e&&!e.paused,toggle:e=>{let r=l();if(!r||!e)return;let i=t===e&&!r.paused;if(r.pause(),i){t=null,a();return}r.currentTime=0,r.src=e,t=e,r.play().catch(()=>{t===e&&(t=null,a())}),a()},subscribe:e=>(r.add(e),()=>r.delete(e))}})();function _(e){let{url:t,disabled:r,width:s=16}=e,[,n]=(0,l.useState)(0),o=(0,l.useRef)(null);if((0,l.useEffect)(()=>O.subscribe(()=>n(e=>e+1)),[]),(0,l.useEffect)(()=>{let e=o.current;if(!e)return;let t=e=>e.stopPropagation();return e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t)}},[t]),!t)return null;let d=O.isPlaying(t);return(0,a.jsx)("button",{ref:o,type:"button",disabled:r,"aria-label":d?"Pause preview":"Play preview",onClick:e=>{e.stopPropagation(),O.toggle(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-default-100 text-default-600 transition-colors hover:bg-default-200 disabled:cursor-not-allowed disabled:opacity-40",children:(0,a.jsx)(i.JO,{icon:d?"mingcute:pause-fill":"mingcute:play-fill",width:s})})}function F(e){let{label:t,size:r=28}=e,l=(t?String(t).trim().charAt(0):"?").toUpperCase()||"?";return(0,a.jsx)("div",{style:{width:r,height:r},className:"flex shrink-0 items-center justify-center rounded-full bg-default-100 text-xs font-semibold text-default-600",children:l})}function E(e){let{option:t}=e;return(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,a.jsx)(F,{label:t.label}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:t.label}),t.description&&(0,a.jsx)("span",{className:"truncate text-tiny text-default-400",children:t.description})]})]})}let P={heading:"px-1 pt-2 pb-1 text-tiny font-semibold uppercase tracking-wide text-default-400"};function T(e){var t,r,l,i,s,n;let o,{node:j,value:w,disabled:N,error:A,required:O,onChange:T,onUploadStateChange:L}=e;if("hidden"===j.type)return null;let D=null!=O?O:j.required,R=j.label||j.key,U={size:"sm",variant:"bordered",isDisabled:N,isInvalid:!!A},z=j.prefix?(0,a.jsx)("span",{className:"text-xs text-default-400",children:j.prefix}):void 0,V=j.suffix||j.unit?(0,a.jsx)("span",{className:"text-xs text-default-400",children:j.suffix||j.unit}):void 0;switch(j.type){case"textarea":o=(0,a.jsx)(d.Y,{...U,value:null!=w?w:"",minRows:j.rows||2,placeholder:j.placeholder,onValueChange:T});break;case"number":o=(0,a.jsx)(c.i,{...U,value:"number"==typeof w?w:void 0,minValue:j.min,maxValue:j.max,step:j.step||1,placeholder:j.placeholder,startContent:z,endContent:V,onValueChange:e=>T(Number.isNaN(e)?"":e)});break;case"slider":{let e=null!==(t=j.min)&&void 0!==t?t:0,l=null!==(r=j.max)&&void 0!==r?r:100;o=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(u.L,{size:"sm","aria-label":R,minValue:e,maxValue:l,step:j.step||1,value:Number(w)||e,isDisabled:N,onChange:e=>T(Array.isArray(e)?e[0]:Number(e)),className:"flex-1"}),(0,a.jsxs)("span",{className:"w-12 shrink-0 text-right text-xs tabular-nums text-default-400",children:[Number(w)||e,j.unit||""]})]});break}case"range":{let e=Array.isArray(w)?w:[null!==(l=j.min)&&void 0!==l?l:0,null!==(i=j.max)&&void 0!==i?i:100];o=(0,a.jsx)(u.L,{size:"sm","aria-label":R,minValue:null!==(s=j.min)&&void 0!==s?s:0,maxValue:null!==(n=j.max)&&void 0!==n?n:100,step:j.step||1,value:e,isDisabled:N,onChange:e=>T(e)});break}case"select":{let{grouped:e,groups:t}=(0,k.hG)(j.options),r=e=>{var t;return(0,a.jsx)(m.R,{children:null!==(t=e.label)&&void 0!==t?t:e.value},String(e.value))};o=(0,a.jsx)(x.g,{...U,"aria-label":R,isVirtualized:!e&&void 0,selectedKeys:null!=w&&""!==w?[String(w)]:[],onSelectionChange:e=>{var t;return T(null!==(t=Array.from(e)[0])&&void 0!==t?t:"")},children:e?t.map(e=>(0,a.jsx)(p.y,{title:e.title,showDivider:!0,classNames:P,children:e.items.map(r)},e.key)):t[0].items.map(r)});break}case"voice":{let{grouped:e,groups:t,flatItems:r}=(0,k.hG)(j.options),l=r.find(e=>String(e.value)===String(w)),i=e=>{var t;return(0,a.jsx)(m.R,{textValue:null!==(t=e.label)&&void 0!==t?t:String(e.value),classNames:{title:"min-w-0"},endContent:(0,a.jsx)(_,{url:e.previewUrl,width:14}),children:(0,a.jsx)(E,{option:e})},String(e.value))};o=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.g,{...U,"aria-label":R,className:"min-w-0 flex-1",classNames:{trigger:"min-w-0",value:"truncate"},placeholder:j.placeholder||"Select a voice",isVirtualized:!e&&void 0,selectedKeys:null!=w&&""!==w?[String(w)]:[],onSelectionChange:e=>{var t;return T(null!==(t=Array.from(e)[0])&&void 0!==t?t:"")},renderValue:()=>l?(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,a.jsx)(F,{label:l.label,size:22}),(0,a.jsx)("span",{className:"truncate text-sm",children:l.label})]}):j.placeholder||"Select a voice",children:e?t.map(e=>(0,a.jsx)(p.y,{title:e.title,showDivider:!0,classNames:P,children:e.items.map(i)},e.key)):t[0].items.map(i)}),(null==l?void 0:l.previewUrl)&&(0,a.jsx)(_,{url:l.previewUrl,disabled:N})]});break}case"multiselect":o=(0,a.jsx)(x.g,{...U,"aria-label":R,selectionMode:"multiple",selectedKeys:new Set((Array.isArray(w)?w:[]).map(String)),onSelectionChange:e=>T(Array.from(e)),children:(j.options||[]).map(e=>{var t;return(0,a.jsx)(m.R,{children:null!==(t=e.label)&&void 0!==t?t:e.value},String(e.value))})});break;case"tags":o=(0,a.jsx)(I,{node:j,value:w,disabled:N,onChange:T});break;case"radio":o=(0,a.jsx)(g.X,{orientation:"horizontal",value:null!=w?String(w):"",isDisabled:N,onValueChange:T,children:(j.options||[]).map(e=>{var t;return(0,a.jsx)(h.J,{value:String(e.value),children:null!==(t=e.label)&&void 0!==t?t:e.value},String(e.value))})});break;case"switch":o=(0,a.jsx)(f.i,{size:"sm",isSelected:!!w,isDisabled:N,onValueChange:T});break;case"date":case"datetime":o=(0,a.jsx)(b.J,{...U,"aria-label":R,granularity:"datetime"===j.type?"minute":"day",value:S(w,j.type),onChange:e=>T(e?e.toString():"")});break;case"time":o=(0,a.jsx)(v.d,{...U,"aria-label":R,value:C(w),onChange:e=>T(e?e.toString():"")});break;case"color":o=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"color",value:w||"#6366f1",disabled:N,onChange:e=>T(e.target.value),className:"h-9 w-11 shrink-0 cursor-pointer rounded-medium border-2 border-default-200"}),(0,a.jsx)(y.Y,{size:"sm",variant:"bordered",value:w||"#6366f1",isDisabled:N,onValueChange:T,className:"flex-1"})]});break;case"computed":o=(0,a.jsx)(y.Y,{size:"sm",variant:"bordered",isReadOnly:!0,value:String(null!=w?w:"")});break;case"file":o=(0,a.jsx)(M,{node:j,value:w,disabled:N,onChange:T,onUploadStateChange:L});break;default:o=(0,a.jsx)(y.Y,{...U,value:null!=w?w:"",maxLength:j.maxLength||void 0,placeholder:j.placeholder,startContent:z,endContent:V,onValueChange:T})}return(0,a.jsxs)("div",{className:"half"===j.width?"w-[calc(50%-0.375rem)]":"w-full",children:[j.label&&(0,a.jsxs)("label",{className:"mb-1 block text-xs font-medium text-default-600",children:[j.label,D&&(0,a.jsx)("span",{className:"ml-0.5 text-danger",children:"*"})]}),o,A&&(0,a.jsx)("p",{className:"mt-1 text-xs text-danger",children:A}),!A&&j.note&&(0,a.jsx)("p",{className:"mt-1 text-xs text-default-400",children:j.note})]})}function L(e){let{node:t,value:r,path:l,disabled:i,errors:s,onChange:n,onUploadStateChange:o,isReadOnly:d,rootValues:c}=e,u=r&&"object"==typeof r?r:{},m=(0,k.fO)(t.fields,t.itemRules,u,c);return(0,a.jsx)("div",{className:"flex flex-wrap gap-3",children:(t.fields||[]).map(e=>{let t=m[e.key]||{};if(t.hidden)return null;let r=void 0!==t.forcedValue?t.forcedValue:u[e.key],x=t.options?{...e,options:t.options}:e;return(0,a.jsx)(R,{node:x,value:r,path:(0,k.Vo)(l,e.key),disabled:i||t.disabled,required:t.required,errors:s,isReadOnly:d,rootValues:c,onUploadStateChange:o,onChange:t=>n({...u,[e.key]:t})},e.key)})})}function D(e){let{node:t,value:r,path:s,disabled:n,errors:o,onChange:d,onUploadStateChange:c,isReadOnly:u,rootValues:m}=e,x=Array.isArray(r)?r:[],[p,g]=(0,l.useState)({}),h=t.minItems||0,f=t.maxItems||0,b=(0,k.UN)(x,t.summaries),v=(0,k.p9)(t),y="object"===v.type,j=(t.constraints||[]).filter(e=>"count"===e.type||"sum"===e.type).some(e=>!1===(0,k.Nf)(e,[...x,(0,k.Jj)(t)])),w=f&&x.length>=f||j,N=(e,t)=>d(x.map((r,a)=>a===e?t:r)),A=e=>d(x.filter((t,r)=>r!==e)),S=e=>{let t=JSON.parse(JSON.stringify(x[e]));d([...x.slice(0,e+1),t,...x.slice(e+1)])},C=(e,t)=>{let r=e+t;if(r<0||r>=x.length)return;let a=[...x];[a[e],a[r]]=[a[r],a[e]],d(a)},M=e=>g(t=>({...t,[e]:!t[e]}));return(0,a.jsxs)("div",{className:"w-full space-y-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[t.label&&(0,a.jsx)("label",{className:"block font-mono text-[13px] font-bold text-gray-800 dark:text-gray-100",children:t.label}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-400",children:[x.length,f?" / ".concat(f):""]}),(0,a.jsxs)("button",{type:"button",disabled:w||u||n,onClick:()=>d([...x,(0,k.Jj)(t)]),className:"flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-1 text-xs font-medium text-blue-600 hover:bg-blue-100 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-blue-900/20 dark:text-blue-400",children:[(0,a.jsx)(i.JO,{icon:"mingcute:add-line",width:13})," ",t.addButtonText||"Add"]})]})]}),b.map(e=>(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,a.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:e.label||e.field}),(0,a.jsxs)("span",{className:e.over?"font-medium text-red-500":"text-gray-500",children:[e.used,null!=e.max?" / ".concat(e.max):"",e.unit||"",null==e.remaining||e.over?"":" (".concat(e.remaining).concat(e.unit||""," left)")]})]}),null!=e.max&&(0,a.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800",children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all ".concat(e.over?"bg-red-400":"bg-blue-400"),style:{width:"".concat(e.percent,"%")}})})]},e.field)),(0,a.jsx)("div",{className:"flex flex-col gap-2",children:0===x.length?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5 rounded-xl border border-dashed border-gray-200 py-4 text-gray-400 dark:border-gray-600",children:[(0,a.jsx)(i.JO,{icon:"mingcute:list-add-line",width:20}),(0,a.jsxs)("span",{className:"text-xs",children:["No items yet. Click ",t.addButtonText||"Add"," to start."]})]}):x.map((e,r)=>{let l=t.collapsible&&p[r];return(0,a.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-3 dark:border-gray-600 dark:bg-gray-800/40",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>t.collapsible&&M(r),className:"flex items-center gap-1 text-xs font-semibold text-gray-500 ".concat(t.collapsible?"hover:text-gray-700":"cursor-default"),children:[t.collapsible&&(0,a.jsx)(i.JO,{icon:l?"mingcute:right-line":"mingcute:down-line",width:13}),(0,k.hD)(t.itemTitle,r,e)]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[t.reorderable&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",disabled:0===r||u,onClick:()=>C(r,-1),className:"flex h-5 w-5 items-center justify-center rounded text-gray-400 hover:bg-gray-100 disabled:opacity-30 dark:hover:bg-gray-700",children:(0,a.jsx)(i.JO,{icon:"mingcute:up-line",width:13})}),(0,a.jsx)("button",{type:"button",disabled:r===x.length-1||u,onClick:()=>C(r,1),className:"flex h-5 w-5 items-center justify-center rounded text-gray-400 hover:bg-gray-100 disabled:opacity-30 dark:hover:bg-gray-700",children:(0,a.jsx)(i.JO,{icon:"mingcute:down-line",width:13})})]}),t.cloneable&&(0,a.jsx)("button",{type:"button",disabled:w||u,onClick:()=>S(r),className:"flex h-5 w-5 items-center justify-center rounded text-gray-400 hover:bg-gray-100 disabled:opacity-30 dark:hover:bg-gray-700",children:(0,a.jsx)(i.JO,{icon:"mingcute:copy-2-line",width:12})}),(0,a.jsx)("button",{type:"button",disabled:x.length<=h||u,onClick:()=>A(r),className:"flex h-5 w-5 items-center justify-center rounded-lg text-gray-400 hover:bg-red-50 hover:text-red-500 disabled:cursor-not-allowed disabled:opacity-30 dark:hover:bg-red-900/20",children:(0,a.jsx)(i.JO,{icon:"mingcute:close-line",width:12})})]})]}),!l&&(y?(0,a.jsx)(L,{node:v,value:e,path:(0,k.Vo)(s,r),disabled:n,errors:o,isReadOnly:u,rootValues:m,onUploadStateChange:c,onChange:e=>N(r,e)}):(0,a.jsx)(T,{node:v,value:e,disabled:n||u,error:o[(0,k.Vo)(s,r)],onUploadStateChange:c,onChange:e=>N(r,e)}))]},r)})})]})}function R(e){let{node:t}=e;if((0,k.UT)(t.type))return(0,a.jsx)(T,{node:t,value:e.value,disabled:e.disabled,required:e.required,error:e.errors[e.path],onChange:e.onChange,onUploadStateChange:e.onUploadStateChange});if("object"===t.type){var r;return(0,a.jsxs)("div",{className:"w-full rounded-xl border border-gray-200 bg-white/40 p-2.5 dark:border-gray-700 dark:bg-transparent",children:[t.label&&(0,a.jsxs)("div",{className:"mb-2 text-xs font-semibold text-gray-500",children:[t.label,(null!==(r=e.required)&&void 0!==r?r:t.required)&&(0,a.jsx)("span",{className:"ml-0.5 text-red-500",children:"*"})]}),(0,a.jsx)(L,{...e})]})}return(0,a.jsx)(D,{...e})}function U(e){let{field:t,value:r,onChange:i,error:s,isReadOnly:n,onUploadStateChange:o}=e,d=(0,l.useMemo)(()=>(0,k.q_)(t),[t]),c=(0,l.useMemo)(()=>(0,k.Iz)(d),[d]),u="object"===c.type,m="array"===c.type,x=!u&&!m,p=u?r&&"object"==typeof r&&!Array.isArray(r)?r:{}:m?Array.isArray(r)?r:[]:void 0!==r?r:(0,k.Fs)(c),g=(0,l.useMemo)(()=>(0,k.Ok)(d,p),[d,p]),h=e=>i(d.parameterKey,e);(0,l.useEffect)(()=>{let[e,t]=function e(t,r,a){let l=null!=a?a:r;if(!t)return[r,!1];if("object"===t.type){let a=r&&"object"==typeof r?r:{},i=(0,k.fO)(t.fields,t.itemRules,a,l),s=!1,n={...a};
1return(t.fields||[]).forEach(t=>{let r=n[t.key],a=i[t.key]||{};if(void 0!==a.forcedValue&&r!==a.forcedValue&&(r=a.forcedValue,s=!0),"computed"===t.type){let e=function(e,t){var r;if(!e.computeExpr)return null!==(r=null==t?void 0:t[e.key])&&void 0!==r?r:"";try{let r=Object.keys(t||{}),a=Function(...r,"return (".concat(e.computeExpr,");"))(...r.map(e=>t[e]));return null==a||Number.isNaN(a)?"":a}catch(e){return""}}(t,n);r!==e&&(r=e,s=!0)}let[o,d]=e(t,r,l);d&&(r=o,s=!0),n[t.key]=r}),[s?n:a,s]}if("array"===t.type){let a=Array.isArray(r)?r:[],i=!1,s=a.map(r=>{let[a,s]=e((0,k.p9)(t),r,l);return s&&(i=!0),s?a:r});return[i?s:a,i]}return[r,!1]}(c,p,p);t&&h(e)},[JSON.stringify(p),JSON.stringify(c)]);let f={node:{...c,label:d.parameterKey},value:p,path:"",disabled:!1,errors:g.errors,isReadOnly:n,rootValues:p,onUploadStateChange:o,onChange:h};return(0,a.jsxs)("div",{className:"space-y-2.5",children:[(u||x)&&d.parameterKey&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("label",{className:"block font-mono text-[13px] font-bold text-gray-800 dark:text-gray-100",children:d.parameterKey}),(d.required||c.required)&&(0,a.jsx)("span",{className:"text-sm text-danger",children:"*"})]}),u?(0,a.jsx)(L,{...f}):m?(0,a.jsx)(D,{...f}):(0,a.jsx)(T,{node:{...c,label:void 0},value:p,disabled:!!n,required:c.required,error:s||g.errors[""],onUploadStateChange:o,onChange:h}),!x&&(s||g.message)&&(0,a.jsx)("p",{className:"text-sm text-red-500 dark:text-red-400",children:s||g.message}),!x&&!s&&!g.message&&d.note&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.note})]})}}}]);
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.