1import{f as A,ai as x,ao as L,ak as M,p as _,j as e,o as d,ap as k,aq as S}from"./index-cqkptx_s.js";import{r as h}from"./vendor-CAuzEwFh.js";import{u as H,C as B,M as U,b as z}from"./MobileControlContainer-CJcCYCRd.js";import{i as R}from"./isSizeOver-CVUsqova.js";import{g as N}from"./getControlHint-DhmKtGdq.js";function W(){const n=A(c=>c.user),{setProgressing:s,setBeforeImgId:a,setAfterImgId:i,setIsBeforeImgCollection:l}=x(c=>c.comparison),{getObjectByLayerLaster:r,pushAISnapshot:t,setAiProcess:m,addAiApiIdMap:b,removeAiApiIdMap:I}=x(c=>c),{onErrorHandler:w}=H(),p="aiImageLayer";return{onEnhance:()=>{const c=r(p);if(c){const f=n==null?void 0:n.Plan.CreditCostInfo.find(o=>o.type.includes("enhance")),u=f==null?void 0:f.type.split("-")[1];if(!u)return;const y=crypto.randomUUID();b("enhance",y),s(!0),m("running"),a(c.imageId),l(c.isCollection||!1),L(c.imageId,u).then(async o=>{if(o){const g=r(p);if(g){const{frame:j,addObject:C}=x.getState(),[E,v]=o.image.resolution.split("x").map(P=>parseInt(P,10));i(o.image.imageId),C(p,{id:crypto.randomUUID(),type:"image",imageId:o.image.imageId,x:g.x,y:g.y,width:j.baseWidth||0,height:j.baseHeight||0,originWidth:E,originHeight:v}),t()}}}).catch(o=>w({error:o,finalCallback:()=>{m("error")}})).finally(()=>{I("enhance",y),M()})}}}}function D(){const{toggle:n}=_(),{onEnhance:s}=W();return{onMounted:()=>{if(R()){n("enhance-down-size",!0);return}s()},onUnMounted:()=>{}}}function O(){const{width:n,height:s,aiProcess:a}=x(r=>{const t=r.getObjectByLayerLaster("aiImageLayer");return{width:t&&(t.originWidth||t.width)||0,height:t&&(t.originHeight||t.height)||0,aiProcess:r.aiProcess}}),[i,l]=h.useState({width:0,height:0});return h.useEffect(()=>{if(!i.width||!i.height){l({width:n,height:s});return}!n||!s||a==="running"||l({width:n,height:s})},[n,s,a]),e.jsxs("section",{className:"flex w-full flex-col gap-[8px]",children:[e.jsx("p",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:e.jsx(d,{i18nKey:"EditorPage_AiEnhance_ResolutionCurrent"})}),e.jsxs("div",{className:"flex items-center gap-[6px]",children:[e.jsxs("div",{className:"flex flex-row items-center gap-[12px]",children:[e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsx("span",{className:"text/text-tertiary text-[14px] font-[500] leading-[120%]",children:"W"}),e.jsx("span",{className:"text/text-primary text-[14px] font-[300] leading-[120%]",children:i.width})]}),e.jsx("span",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:"X"}),e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsx("span",{className:"text/text-tertiary text-[14px] font-[500] leading-[120%]",children:"H"}),e.jsx("span",{className:"text/text-primary text-[14px] font-[300] leading-[120%]",children:i.height})]})]}),e.jsx("span",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:"px"})]})]})}function K(){const{width:n,height:s,aiProcess:a}=x(r=>{const t=r.getObjectByLayerLaster("aiImageLayer");return{width:t&&(t.originWidth||t.width)||0,height:t&&(t.originHeight||t.height)||0,aiProcess:r.aiProcess}}),[i,l]=h.useState({width:0,height:0});return h.useEffect(()=>{if(!i.width||!i.height){l({width:n*2,height:s*2});return}!n||!s||a==="running"||l({width:n*2,height:s*2})},[n,s,a]),a!=="idle"&&a!=="running"?null:e.jsxs("section",{className:"border/border-secondary edit/bg-fill flex w-full flex-col gap-[8px] rounded-[8px] border border-dashed p-[10px_14px]",children:[e.jsx("p",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:e.jsx(d,{i18nKey:"EditorPage_AiEnhance_ResolutionNext"})}),e.jsxs("div",{className:"flex items-center gap-[6px]",children:[e.jsxs("div",{className:"flex flex-row items-center gap-[12px]",children:[e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsx("span",{className:"text/text-tertiary text-[14px] font-[500] leading-[120%]",children:"W"}),e.jsx("span",{className:"text/text-primary text-[14px] font-[300] leading-[120%]",children:i.width})]}),e.jsx("span",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:"X"}),e.jsxs("div",{className:"flex items-center gap-[8px]",children:[e.jsx("span",{className:"text/text-tertiary text-[14px] font-[500] leading-[120%]",children:"H"}),e.jsx("span",{className:"text/text-primary text-[14px] font-[300] leading-[120%]",children:i.height})]})]}),e.jsx("span",{className:"text/text-secondary text-[14px] font-[300] leading-[120%]",children:"px"})]})]})}function X(){const[n,s,a]=x(i=>[i.type,i.menu,i.aiProcess]);return s!=="enhance"?null:e.jsx(B,{children:e.jsxs("div",{className:"flex h-full w-full flex-1 flex-col items-center gap-[16px]",children:[e.jsx(O,{}),e.jsx(K,{}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex w-full items-center justify-center",children:[(a==="idle"||a==="running")&&e.jsx("span",{className:"text/text-primary pb-[16px] text-[14px] font-[300] leading-[120%]",children:N({type:n,menu:s})}),a==="finished"&&e.jsx("div",{className:"flex h-full w-full flex-col items-center justify-end",children:e.jsxs("div",{className:"flex w-full flex-row items-center gap-[8px]",children:[e.jsx("button",{className:"edit/bg-fill-secondary edit/bg-fill-secondary-hover flex flex-1 items-center justify-center rounded-[8px] !border-none py-[12px]",onClick:k,children:e.jsx("span",{className:"text/text-primary text-[14px] font-[400] leading-[120%]",children:e.jsx(d,{i18nKey:"EditorPage_AiEnhance_ButtonCancel"})})}),e.jsx("button",{className:"background/bg-fill-brand background/bg-fill-brand-hover flex flex-1 items-center justify-center rounded-[8px] !border-none py-[12px]",onClick:S,children:e.jsx("span",{className:"text/text-primary text-[14px] font-[400] leading-[120%]",children:e.jsx(d,{i18nKey:"EditorPage_AiEnhance_ButtonConfirm"})})})]})})]})]})})}function q(){const[n,s,a]=x(r=>[r.type,r.menu,r.aiProcess]),{width:i,height:l}=x(r=>{const t=r.getObjectByLayerLaster("aiImageLayer");return{width:t==null?void 0:t.width,height:t==null?void 0:t.height}});return s!=="enhance"?null:e.jsx(U,{children:e.jsx("div",{className:"absolute bottom-full mb-[28px] flex items-center justify-center bg-transparent",children:e.jsx("span",{className:"text/text-primary text-[15px] font-[400] leading-[100%]",children:a==="idle"||a==="running"?N({type:n,menu:s}):`${i??1} X ${l??1}`})})})}function Q(){const n=D();return z(n),e.jsxs(e.Fragment,{children:[e.jsx(X,{}),e.jsx(q,{})]})}
1export{Q 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.