1import{c as M,aj as A,ar as P,ai as o,ak as C,a as D,j as e,o as y}from"./index-cqkptx_s.js";import{r as m}from"./vendor-CAuzEwFh.js";import{u as H,g as U,C as T,M as B,b as K}from"./MobileControlContainer-CJcCYCRd.js";import{g as R}from"./getControlHint-DhmKtGdq.js";import{I as V}from"./IconArrowUp-DxPbHbXH.js";function k(t){if(t.key==="Enter"&&!t.shiftKey){t.preventDefault();const n=t.target.closest("form");n&&n.requestSubmit()}}function W({targetImageId:t,maskFile:n,prompt:i,abortSignal:r,xRequestId:l}){const c=new FormData;return c.append("mask",n),c.append("prompt",i),M.post(`/api/images/${t}/fill`,{body:c,timeout:3e5,signal:r,headers:{"X-Request-ID":l}}).then(s=>s.status===201?s.json():null).then(async s=>{if(s===null)return null;const u=s.image,a=await A({imageId:s.image.imageId,imageAlt:P(s.image.imageId),imageType:"fill",resolution:s.image.resolution,scaleSize:s.image.scaleSize},!1);return a&&(u.binary=a),u})}async function z(){const{exportedBlobUrl:t}=o.getState();if(!t)return null;try{const n=await fetch(t);return n.ok?await n.blob():null}catch{return null}}function v(t){const n=o(f=>f.menu),i="aiImageLayer",r="maskingLayer",{setAiProcess:l,getObjectByType:c,getObjectByLayerLaster:s,addAiApiIdMap:u,removeAiApiIdMap:a,fill:{addPrompt:d}}=o.getState(),{onErrorHandler:p}=H();return{onFillSubmit:()=>{if(n!=="fill")return;const f=s(i),h=c(r,"freehand"),g=crypto.randomUUID();u("fill",g),z().then(b=>{if(b&&f&&h){const w={targetImageId:f.imageId,maskFile:b,prompt:t,abortSignal:void 0,xRequestId:g};W(w).then(x=>{if(x){const{frame:j,addObject:E,removeObject:F,pushAISnapshot:_,setIsImageRequestFinished:N}=o.getState(),[S,L]=x.resolution.split("x").map(Number);F(r,h.id),E(i,{id:crypto.randomUUID(),type:"image",imageId:x.imageId,x:0,y:0,width:j.baseWidth||0,height:j.baseHeight||0,originWidth:S,originHeight:L}),_(),d(t),N(!0)}else l("error")}).catch(x=>p({error:x,finalCallback:()=>{l("error")}})).finally(()=>{a("fill",g),C()})}else l("error")}),l("running")}}}function $(){return{onMounted:()=>{const{setActiveLayer:i,setSelectedEditorTool:r}=o.getState();i("maskingLayer"),r("freehand")},onUnMounted:()=>{const{fill:{resetInputValue:i}}=o.getState();i()}}}function q(){const{t}=D(),{type:n,menu:i,aiProcess:r,fill:{inputValue:l,setInputValue:c}}=o(a=>a),{onFillSubmit:s}=v(l),u=a=>{a.preventDefault(),s()};return e.jsxs("form",{className:"flex w-full flex-col gap-[12px]",onSubmit:u,children:[e.jsx("div",{className:"edit/border-primary edit/bg-input rounded-[8px] border p-[8px_16px_12px]",children:e.jsx("textarea",{placeholder:t("EditorPage_AiRemix_Placeholder"),className:"text/text-primary text/text-disabled m-[4px_0px_10px] max-h-[80px] min-h-[34px] w-full resize-none bg-transparent text-[14px] font-[300] leading-[140%] !outline-none",disabled:r==="running",value:l,onInput:a=>{const d=a.target;d.style.height="auto",d.style.height=`${d.scrollHeight}px`,c(d.value)},onKeyDown:k})}),e.jsx("button",{type:"submit",className:`flex w-full items-center justify-center rounded-[8px] !border-none py-[12px] ${r==="running"||l.length===0?"edit/bg-fill !opacity-100":"background/bg-fill-brand background/bg-fill-brand-hover"}`,disabled:r==="running"||l.length===0,children:e.jsx("span",{className:`text-[14px] font-[400] leading-[120%] ${r==="running"||l.length===0?"text/text-tertiary":"text/text-primary"}`,children:U({type:n,menu:i})})})]})}function I(){const[t,n]=o(i=>[i.type,i.menu]);return e.jsx("span",{className:"text/text-primary break-keep pb-[16px] text-center text-[14px] font-[300] leading-[140%]",children:R({type:t,menu:n})})}function G({prompt:t}){const[n,i]=m.useState(!1),r=()=>{navigator.clipboard.writeText(t),i(!0),setTimeout(()=>{i(!1)},2e3)};return e.jsxs("button",{onClick:r,className:"edit/bg-fill-secondary edit/bg-fill-secondary-hover group relative flex w-full flex-row items-center justify-start gap-[8px] rounded-[10px] !border-none p-[12px_14px]",children:[e.jsx("span",{className:"edit/text-primary overflow-hidden text-ellipsis whitespace-nowrap text-[14px] font-[300] leading-[120%]",children:t}),e.jsx("div",{className:"edit/bg-fill pointer-events-none absolute right-0 top-full z-10 mt-1 flex items-center justify-center rounded-[4px] p-[8px_16px] opacity-0 group-hover:opacity-100",children:e.jsx("span",{className:"text/text-primary text-[12px]",children:n?e.jsx(y,{i18nKey:"EditorPage_AiFill_ClipboardTooltipNormal"}):e.jsx(y,{i18nKey:"EditorPage_AiFill_ClipboardTooltipActive"})})})]},t)}function Y(){const[t]=o(i=>
1[i.fill.prompts]),n=[...t].filter(Boolean);return n.length===0?null:e.jsx("div",{className:"flex w-full flex-1 flex-col items-center justify-start gap-[10px] overflow-y-auto",children:n==null?void 0:n.map(i=>i&&e.jsx(G,{prompt:i}))})}function O(){const[t,n]=m.useState(!1),[i,r]=m.useState(!1),{aiProcess:l,fill:{inputValue:c,setInputValue:s}}=o(d=>d),{onFillSubmit:u}=v(c),a=d=>{d.preventDefault(),u()};return e.jsxs("form",{className:"relative flex w-full flex-col gap-[8px]",onSubmit:a,children:[e.jsxs("div",{className:"flex gap-[8px]",children:[e.jsx("textarea",{placeholder:"ìì í ë´ì©ì ìì±í´ì£¼ì¸ì",className:"text/text-primary text/text-disabled m-[10px_0px_16px] max-h-[96px] min-h-[34px] w-full resize-none bg-transparent text-[16px] font-[300] leading-[140%] !outline-none",disabled:l==="running",value:c,onInput:d=>{const p=d.target;p.style.height="auto",p.style.height=`${p.scrollHeight}px`,s(p.value),p.scrollHeight>=96&&r(!0)},onKeyDown:k}),i&&e.jsx("button",{type:"button",onClick:()=>{n(!t)},children:e.jsx(X,{})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"submit",className:"background/bg-fill-brand background/bg-fill-brand-hover edit/bg-fill-disabled flex items-center justify-center rounded-full !border-none p-[5px]",disabled:l==="running"||c.length===0,children:e.jsx(V,{})})})]})}function X(){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[e.jsxs("g",{clipPath:"url(#clip0_8190_12862)",children:[e.jsx("path",{d:"M3.33073 6.66699V3.33366H6.66406",stroke:"#EEF3FF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8.33203 8.3335L3.33203 3.3335",stroke:"#EEF3FF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.668 13.3332V16.6665H13.3346",stroke:"#EEF3FF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.668 16.6665L11.668 11.6665",stroke:"#EEF3FF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_8190_12862",children:e.jsx("rect",{width:"20",height:"20",fill:"white"})})})]})}function J(){const[t,n]=o(r=>[r.menu,r.aiProcess]);if(m.useEffect(()=>{t==="fill"&&o.getState().fill.resetPrompt()},[t]),t!=="fill")return null;const i=n==="idle"||n==="finished";return e.jsx(T,{children:e.jsxs("div",{className:"flex h-full w-full flex-1 flex-col items-center justify-end gap-[16px] pt-[16px]",children:[e.jsx(Y,{}),i?e.jsx(I,{}):e.jsx(q,{})]})})}function Q(){const[t,n]=o(r=>[r.menu,r.aiProcess]);if(t!=="fill")return null;const i=n==="idle"||n==="finished";return e.jsxs(B,{children:[i&&e.jsx("div",{className:"absolute bottom-full mb-[28px]",children:e.jsx(I,{})}),!i&&e.jsx("div",{className:"w-full p-[10px_20px_20px]",children:e.jsx(O,{})})]})}function le(){const t=$();return K(t),e.jsxs(e.Fragment,{children:[e.jsx(J,{}),e.jsx(Q,{})]})}export{le as default};
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.