diff --git a/lama_cleaner/app/build/asset-manifest.json b/lama_cleaner/app/build/asset-manifest.json index 9b47427..c072d35 100644 --- a/lama_cleaner/app/build/asset-manifest.json +++ b/lama_cleaner/app/build/asset-manifest.json @@ -1,7 +1,7 @@ { "files": { "main.css": "/static/css/main.cb1a496c.chunk.css", - "main.js": "/static/js/main.28ee900a.chunk.js", + "main.js": "/static/js/main.963ef5f0.chunk.js", "runtime-main.js": "/static/js/runtime-main.5e86ac81.js", "static/js/2.d2131344.chunk.js": "/static/js/2.d2131344.chunk.js", "index.html": "/index.html", @@ -12,6 +12,6 @@ "static/js/runtime-main.5e86ac81.js", "static/js/2.d2131344.chunk.js", "static/css/main.cb1a496c.chunk.css", - "static/js/main.28ee900a.chunk.js" + "static/js/main.963ef5f0.chunk.js" ] } \ No newline at end of file diff --git a/lama_cleaner/app/build/index.html b/lama_cleaner/app/build/index.html index 29a144f..58af6b0 100644 --- a/lama_cleaner/app/build/index.html +++ b/lama_cleaner/app/build/index.html @@ -1 +1 @@ -lama-cleaner - Image inpainting powered by SOTA AI model
\ No newline at end of file +lama-cleaner - Image inpainting powered by SOTA AI model
\ No newline at end of file diff --git a/lama_cleaner/app/build/static/js/main.28ee900a.chunk.js b/lama_cleaner/app/build/static/js/main.28ee900a.chunk.js deleted file mode 100644 index 82704aa..0000000 --- a/lama_cleaner/app/build/static/js/main.28ee900a.chunk.js +++ /dev/null @@ -1 +0,0 @@ -(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{66:function(e,t,n){},73:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(13),i=n.n(c),o=(n(66),n(6)),s=n(3),l=n(57),u=n(7),d=n.n(u),b=n(12);var j=n(16),f=n(1),h=Object(o.b)({key:"themeState",default:"dark"}),p=function(){var e=Object(o.d)(h),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)("div",{className:"theme-toggle-ui",children:Object(f.jsx)("div",{className:"theme-btn",onClick:function(){a("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(f.jsx)(j.h,{}):Object(f.jsx)(j.i,{style:{color:"#ffcc00"}})})})},O=n(2),g=n(9),v=n(51),m=n(82),x=n(54),y=n(83),w=n(8);function S(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],r=0;rt){var r=Math.ceil(t*a);return"".concat(e,"x").concat(r)}var c=Math.ceil(n*a);return"".concat(c,"x").concat(e)}),[n,t,u]),b=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(l(a[0]),r(parseInt(a[0],10))):(l(a[1]),r(parseInt(a[1],10)))},chevronDirection:"up"})}var U=n(52),X=n.n(U),G=n(78),J=n(4),$=["onFocus","onBlur"],q=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object(J.a)(e,$),c=Object(o.d)(pe),i=Object(s.a)(c,2),l=(i[0],i[1]);return Object(f.jsx)("input",Object(O.a)(Object(O.a)({},r),{},{ref:t,type:"text",onFocus:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),Q=["value","allowFloat","onValue"],ee=r.a.forwardRef((function(e,t){var n=e.value,r=e.allowFloat,c=e.onValue,i=Object(J.a)(e,Q),o=Object(a.useState)(n),l=Object(s.a)(o,2),u=l[0],d=l[1];Object(a.useEffect)((function(){d(n)}),[n]);return Object(f.jsx)(q,Object(O.a)(Object(O.a)({value:u,onInput:function(e){var t=e.target.value;r?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===c||void 0===c||c(t)):(t=t.replace(/\D/g,""),null===c||void 0===c||c(t)),d(t)},className:"number-input"},i),{},{ref:t}))}));ee.defaultProps={allowFloat:!1};var te=ee,ne=n(29),ae=function(e){var t=e.content,n=e.children;return Object(f.jsx)(ne.d,{children:Object(f.jsxs)(ne.c,{children:[Object(f.jsx)(ne.e,{className:"tooltip-trigger",children:n}),Object(f.jsxs)(ne.b,{className:"tooltip-content",children:[t,Object(f.jsx)(ne.a,{className:"tooltip-arrow"})]})]})})};function re(e){var t=e.title,n=e.titleSuffix,a=e.desc,r=e.input,c=e.optionDesc,i=e.className,o="h"===e.layout?"setting-block-content":"setting-block-content-v";return Object(f.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(f.jsxs)("div",{className:o,children:[Object(f.jsx)("div",{className:"setting-block-content-title",children:Object(f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(f.jsx)(ae,{content:Object(f.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(f.jsx)("span",{children:t})}):Object(f.jsx)("span",{children:t}),n]})}),r]}),c&&Object(f.jsx)("div",{className:"option-desc",children:c})]})}re.defaultProps={layout:"h"};var ce=re;function ie(e){var t=e.title,n=e.allowFloat,r=e.desc,c=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(G.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(f.jsx)(ce,{className:"sub-setting-block",title:t,desc:r,input:Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(f.jsx)(te,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:c,disabled:u,onValue:o,ref:d}),i&&Object(f.jsx)("span",{children:i})]})})}ie.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var oe,se,le=ie;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(oe||(oe={})),function(e){e.ddim="ddim",e.plms="plms"}(se||(se={}));var ue,de,be=function(){var e=Object(o.d)(Re),t=Object(s.a)(e,2),n=t[0],a=t[1];if(!(null===n||void 0===n?void 0:n.enabled))return Object(f.jsx)(f.Fragment,{});var r=function(e){a({hdStrategy:e})},c=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyResizeLimit:t})},i=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropTrigerSize:t})},l=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},u=function(){return Object(f.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(f.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(oe.RESIZE)},children:"Resize"})," or ",Object(f.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(oe.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(f.jsx)(ce,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(f.jsx)(_,{width:80,value:n.hdStrategy,options:Object.values(oe),onChange:function(e){return r(e)}}),optionDesc:function(){switch(n.hdStrategy){case oe.ORIGINAL:return u();case oe.CROP:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(f.jsx)(le,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(f.jsx)(le,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case oe.RESIZE:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(f.jsx)(le,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:c})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD15="sd1.5",e.CV2="cv2"}(de||(de={}));var je,fe=Object(o.b)({key:"fileState",default:void 0}),he=Object(o.b)({key:"maskState",default:void 0}),pe=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),Oe=Object(o.b)({key:"promptState",default:""}),ge=Object(o.b)({key:"negativePromptState",default:""}),ve=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(pe).isInpainting},set:function(e,t){var n=e.get,a=e.set,r=n(pe);a(pe,Object(O.a)(Object(O.a)({},r),{},{isInpainting:t}))}}),me=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),xe=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(me).x},set:function(e,t){var n=e.get,a=e.set,r=n(me);a(me,Object(O.a)(Object(O.a)({},r),{},{x:t}))}}),ye=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(me).y},set:function(e,t){var n=e.get,a=e.set,r=n(me);a(me,Object(O.a)(Object(O.a)({},r),{},{y:t}))}}),we=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(me).height},set:function(e,t){var n=e.get,a=e.set,r=n(me);a(me,Object(O.a)(Object(O.a)({},r),{},{height:t}))}}),Se=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(me).width},set:function(e,t){var n=e.get,a=e.set,r=n(me);a(me,Object(O.a)(Object(O.a)({},r),{},{width:t}))}}),ke=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),Ce=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(je||(je={}));var Le,Me,Ne=(ue={},Object(w.a)(ue,de.LAMA,{hdStrategy:oe.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(w.a)(ue,de.LDM,{hdStrategy:oe.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(ue,de.ZITS,{hdStrategy:oe.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(ue,de.MAT,{hdStrategy:oe.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(ue,de.FCF,{hdStrategy:oe.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(w.a)(ue,de.SD15,{hdStrategy:oe.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(ue,de.CV2,{hdStrategy:oe.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),ue);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms",e.kEuler="k_euler",e.kEulerA="k_euler_a"}(Le||(Le={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(Me||(Me={}));var Ie,Ee={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:de.LAMA,hdSettings:Ne,ldmSteps:25,ldmSampler:se.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:Me.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Le.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,cv2Radius:5,cv2Flag:je.INPAINT_NS},ze="settingsState4",Te=Object(o.b)({key:ze,default:Ee,effects:[(Ie=ze,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Ie);if(null!=a){var r=JSON.parse(a);r.show=!1,t(X.a.merge(X.a.cloneDeep(Ee),r))}n((function(e,t,n){return n?localStorage.removeItem(Ie):localStorage.setItem(Ie,JSON.stringify(e))}))})]}),De=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(Te).sdSeed},set:function(e,t){var n=e.get,a=e.set,r=n(Te);a(Te,Object(O.a)(Object(O.a)({},r),{},{sdSeed:t}))}}),Re=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(Te);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,r=n(Te),c=r.hdSettings[r.model],i=Object(O.a)(Object(O.a)({},c),t);a(Te,Object(O.a)(Object(O.a)({},r),{},{hdSettings:Object(O.a)(Object(O.a)({},r.hdSettings),{},Object(w.a)({},r.model,i))}))}}),Pe=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(Te).model===de.SD15}}),Fe=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(Te),a=t(Pe);return n.runInpaintingManually||a}}),He=n(58),Ae=function(e,t,n,a){var r=Object(o.e)(pe);return Object(He.a)(e,t,Object(O.a)(Object(O.a)({},n),{},{enabled:!r.disableShortCuts}),a)},Ze={capture:!0,passive:!1},Ve=function(e,t,n,a,r,c){if(e!==n&&t===a){if(e<0)return[0,a];if(e+t>c)return[c-a,a]}else{if(tc)return[e,c-e]}return[e,t]},We=function(e){var t=e.minHeight,n=e.minWidth,r=e.maxHeight,c=e.maxWidth,i=e.scale,l=Object(o.d)(xe),u=Object(s.a)(l,2),d=u[0],b=u[1],j=Object(o.d)(ye),h=Object(s.a)(j,2),p=h[0],O=h[1],g=Object(o.d)(we),v=Object(s.a)(g,2),m=v[0],x=v[1],y=Object(o.d)(Se),w=Object(s.a)(y,2),S=w[0],k=w[1],C=Object(o.e)(ve),L=Object(a.useState)(!1),M=Object(s.a)(L,2),N=M[0],I=M[1],E=Object(a.useState)(!1),z=Object(s.a)(E,2),T=z[0],D=z[1];Object(a.useEffect)((function(){b(Math.round((c-512)/2)),O(Math.round((r-512)/2))}),[r,c,t,n]);var R=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),P=Object(s.a)(R,2),F=P[0],H=P[1],A=function(){console.log("focus")},Z=function(e,t){return Ve(e,t,d,S,n,c)},V=function(e,n){return Ve(e,n,p,m,t,r)},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-F.startResizeY)/i),r=Math.round((t-F.startResizeX)/i),c=function(){var e=F.initHeight-a,t=F.initY+a,n=V(t,e),r=Object(s.a)(n,2),c=r[0],i=r[1];x(i),O(c)},o=function(){var e=F.initHeight+a,t=V(F.initY,e),n=Object(s.a)(t,2),r=n[0],c=n[1];x(c),O(r)},l=function(){var e=F.initWidth-r,t=F.initX+r,n=Z(t,e),a=Object(s.a)(n,2),c=a[0],i=a[1];k(i),b(c)},u=function(){var e=F.initWidth+r,t=Z(F.initX,e),n=Object(s.a)(t,2),a=n[0],c=n[1];k(c),b(a)};if(N)switch(F.ord){case"topleft":c(),l();break;case"topright":c(),u();break;case"bottomleft":o(),l();break;case"bottomright":o(),u();break;case"top":c();break;case"right":u();break;case"bottom":o();break;case"left":l()}if(T){var d=F.initX+r,j=F.initY+a,f=Z(d,F.initWidth),h=Object(s.a)(f,2),p=h[0],g=h[1],v=V(j,F.initHeight),m=Object(s.a)(v,2),y=m[0],w=m[1];k(g),x(w),b(p),O(y)}}},B=function(e){N&&I(!1),T&&D(!1)};Object(a.useEffect)((function(){if(N||T)return document.addEventListener("pointermove",W,Ze),document.addEventListener("pointerup",B,Ze),document.addEventListener("pointercancel",B,Ze),function(){document.removeEventListener("pointermove",W,Ze),document.removeEventListener("pointerup",B,Ze),document.removeEventListener("pointercancel",B,Ze)}}),[N,T,S,m,F]);var _=function(e){var t=e.target.dataset.ord;t&&(I(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},Y=function(e){D(!0),H({initX:d,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(f.jsx)("div",{className:"croper-wrapper",children:Object(f.jsxs)("div",{className:"croper",style:{height:m,width:S,left:d,top:p},children:[Object(f.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(f.jsx)("div",{className:"info-bar",onPointerDown:Y,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(f.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(f.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:_,children:[Object(f.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},Be=n(55),_e="prompt",Ye="custom_mask",Ke=Object(Be.a)(),Ue=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){r(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",c),function(){window.removeEventListener("resize",c)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function Xe(e){var t=e.onSelection,n=Object(a.useState)(!1),r=Object(s.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=Ue();function j(e){if(e&&e.type.match("image.*"))try{if(e.size>20971520)throw new Error("file too large");t(e)}catch(n){alert("error: ".concat(n.message))}}function h(e){return p.apply(this,arguments)}function p(){return(p=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){t.file((function(t){return e(t)}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e){return v.apply(this,arguments)}function v(){return(v=Object(b.a)(d.a.mark((function e(t){var n,a,r,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],r=0;r0)){e.next=23;break}if(!(null===(c=a.shift())||void 0===c?void 0:c.isFile)){e.next=12;break}return e.next=8,h(c);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===c||void 0===c?void 0:c.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=g.a,e.next=18,m(c.createReader());case 18:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.t0.apply.call(e.t0,e.t1,e.t4);case 21:e.next=3;break;case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return x.apply(this,arguments)}function x(){return(x=Object(b.a)(d.a.mark((function e(t){var n,a;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,y(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(g.a)(a)),e.next=8,y(t);case 8:a=e.sent,e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e){return w.apply(this,arguments)}function w(){return(w=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){t.readEntries(e,n)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(){return(S=Object(b.a)(d.a.mark((function e(t){var n;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.next=3,O(t.dataTransfer.items);case 3:n=e.sent,i(!1),j(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(f.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(f.jsxs)("div",{className:["file-select-container",c?"file-select-label-hover":""].join(" "),onDrop:function(e){return S.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(f.jsx)("input",{id:l,name:l,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&j(n)},accept:"image/png, image/jpeg"}),Object(f.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var Ge="#ffcc00bb";function Je(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ge;e.strokeStyle=n,e.lineCap="round",e.lineJoin="round",t.forEach((function(t){(null===t||void 0===t?void 0:t.pts.length)&&t.size&&(e.lineWidth=t.size,e.beginPath(),e.moveTo(t.pts[0].x,t.pts[0].y),t.pts.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}))}function $e(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function qe(){var e=Object(o.d)(fe),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(o.e)(Oe),i=Object(o.e)(ge),l=Object(o.e)(Te),u=Object(o.d)(De),h=Object(s.a)(u,2),p=(h[0],h[1]),O=Object(o.e)(me),w=Object(o.d)(ke),S=Object(s.a)(w,2),N=(S[0],S[1]),I=Object(o.d)(ve),E=Object(s.a)(I,2),T=E[0],D=E[1],P=Object(o.e)(Fe),F=Object(o.e)(Pe),H=Object(a.useState)(40),A=Object(s.a)(H,2),W=A[0],B=A[1],_=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],r=Object(a.useState)(!1),c=Object(s.a)(r,2),i=c[0],o=c[1];return Object(a.useEffect)((function(){if(void 0!==e)return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,i]}(n),Y=Object(s.a)(_,2),U=Y[0],X=Y[1],G=Object(a.useState)([]),J=Object(s.a)(G,2),$=J[0],q=J[1],Q=Object(a.useState)(),ee=Object(s.a)(Q,2),te=ee[0],ne=ee[1],ae=Object(a.useState)((function(){return document.createElement("canvas")})),re=Object(s.a)(ae,1)[0],ce=Object(a.useState)([]),ie=Object(s.a)(ce,2),oe=ie[0],se=ie[1],le=Object(a.useState)([]),ue=Object(s.a)(le,2),de=ue[0],be=ue[1],je=Object(a.useState)([]),he=Object(s.a)(je,2),pe=he[0],xe=he[1],ye=Object(a.useState)({x:-1,y:-1}),we=Object(s.a)(ye,2),Se=we[0],Ce=Se.x,Le=Se.y,Me=we[1],Ne=Object(a.useState)(!1),Ie=Object(s.a)(Ne,2),Ee=Ie[0],ze=Ie[1],Re=Object(a.useState)(!1),He=Object(s.a)(Re,2),Ze=He[0],Ve=He[1],Be=Object(a.useState)(!1),Ue=Object(s.a)(Be,2),Ge=Ue[0],qe=Ue[1],Qe=Object(a.useState)(!1),et=Object(s.a)(Qe,2),tt=et[0],nt=et[1],at=Object(a.useState)({x:-1,y:-1,brushSize:20}),rt=Object(s.a)(at,2),ct=rt[0],it=rt[1],ot=Object(a.useState)(!1),st=Object(s.a)(ot,2),lt=st[0],ut=st[1],dt=Object(a.useState)(1),bt=Object(s.a)(dt,2),jt=bt[0],ft=bt[1],ht=Object(a.useState)(!1),pt=Object(s.a)(ht,2),Ot=pt[0],gt=pt[1],vt=Object(a.useState)(1),mt=Object(s.a)(vt,2),xt=mt[0],yt=mt[1],wt=Object(a.useState)(1080),St=Object(s.a)(wt,2),kt=St[0],Ct=St[1],Lt=Object(m.a)(),Mt=Lt.width/2,Nt=Lt.height/2,It=Object(a.useRef)(),Et=Object(a.useState)(!1),zt=Object(s.a)(Et,2),Tt=zt[0],Dt=zt[1],Rt=Object(a.useState)(!1),Pt=Object(s.a)(Rt,2),Ft=Pt[0],Ht=Pt[1],At=Object(a.useState)(!1),Zt=Object(s.a)(At,2),Vt=Zt[0],Wt=Zt[1],Bt=Object(a.useState)(0),_t=Object(s.a)(Bt,2),Yt=_t[0],Kt=_t[1],Ut=Object(a.useState)([]),Xt=Object(s.a)(Ut,2),Gt=Xt[0],Jt=Xt[1],$t=Object(a.useState)([]),qt=Object(s.a)($t,2),Qt=qt[0],en=qt[1],tn=Object(a.useState)([]),nn=Object(s.a)(tn,2),an=nn[0],rn=nn[1],cn=Object(a.useCallback)((function(e,t){te&&(te.clearRect(0,0,te.canvas.width,te.canvas.height),te.drawImage(e,0,0,U.naturalWidth,U.naturalHeight),Je(te,t))}),[te,U]),on=Object(a.useCallback)((function(e){if(!(null===te||void 0===te?void 0:te.canvas.width)||!(null===te||void 0===te?void 0:te.canvas.height))throw new Error("canvas has invalid size");re.width=null===te||void 0===te?void 0:te.canvas.width,re.height=null===te||void 0===te?void 0:te.canvas.height;var t=re.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){Je(t,e,"white")}))}),[te,re]),sn=Object(a.useCallback)((function(){return 0!==pe.length}),[pe]),ln=Object(a.useCallback)((function(e){0===$.length?cn(U,e):cn($[$.length-1],e)}),[U,$,cn]),un=Object(a.useCallback)(function(){var e=Object(b.a)(d.a.mark((function e(t,a){var r,o,s,u,b,j,f,h,v,m,x,y,w,S;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==n){e.next=2;break}return e.abrupt("return");case 2:if(r=void 0!==a,console.log("runInpainting"),o=[],!0!==t){e.next=11;break}if(0!==de.length){e.next=8;break}return e.abrupt("return");case 8:o=de,e.next=16;break;case 11:if(r){e.next=16;break}if(sn()){e.next=14;break}return e.abrupt("return");case 14:be(pe),o=pe;case 16:if(s=[].concat(Object(g.a)(oe),[o]),xe([]),Ht(!1),D(!0),l.graduallyInpainting?on([o]):on(s),u=n,!0!==l.graduallyInpainting){e.next=37;break}if(!0!==t){e.next=31;break}if(!($.length>1)){e.next=29;break}return b=$[$.length-2],e.next=28,L(b.currentSrc,n.name,n.type);case 28:u=e.sent;case 29:e.next=37;break;case 31:if(!($.length>0)){e.next=37;break}return console.info("gradually inpainting on last result"),j=$[$.length-1],e.next=36,L(j.currentSrc,n.name,n.type);case 36:u=e.sent;case 37:return f=l.sdSeedFixed?l.sdSeed:-1,console.log({useCustomMask:r}),e.prev=39,e.next=42,R(u,l,O,c,i,kt.toString(),f,r?void 0:re.toDataURL(),r?a:void 0);case 42:if(h=e.sent){e.next=45;break}throw new Error("Something went wrong on server side.");case 45:return v=h.blob,(m=h.seed)&&!l.sdSeedFixed&&p(parseInt(m,10)),x=new Image,e.next=50,k(x,v);case 50:!0===t?(y=$.slice(0,-1),w=[].concat(Object(g.a)(y),[x]),q(w)):(S=[].concat(Object(g.a)($),[x]),q(S)),cn(x,[]),se(s),fn(),e.next=60;break;case 56:e.prev=56,e.t0=e.catch(39),N({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),ln([]);case 60:D(!1);case 61:case"end":return e.stop()}}),e,null,[[39,56]])})));return function(t,n){return e.apply(this,arguments)}}(),[oe,pe,re,l.graduallyInpainting,l,O,kt,c,i,ln,sn,on]);Object(a.useEffect)((function(){return Ke.on(_e,(function(){sn()?un():0!==de.length?un(!0):N({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){Ke.off(_e)}}),[sn,un,c]),Object(a.useEffect)((function(){return Ke.on(Ye,(function(e){un(!1,e.mask)})),function(){Ke.off(Ye)}}),[un]);var dn=function(){return 0!==$.length},bn=function(e){return"Control"===e.key||"Meta"===e.key};Object(x.a)(bn,(function(){Vt&&(T||(Wt(!1),P||un()))}),{event:"keyup"},[T,Vt,sn]),Object(x.a)(bn,(function(){T||Wt(!0)}),{event:"keydown"},[T]),Object(a.useEffect)((function(){if(X){var e=Lt.width/U.naturalWidth,t=(Lt.height-200)/U.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),yt(n),ft(n),(null===te||void 0===te?void 0:te.canvas)&&(te.canvas.width=U.naturalWidth,te.canvas.height=U.naturalHeight,ln([])),!Tt){var a;null===(a=It.current)||void 0===a||a.centerView(n,1),Dt(!0);var r=Math.max(U.width,U.height);Ct(r)}}}),[null===te||void 0===te?void 0:te.canvas,It,U,X,Lt,Tt,ln]);var jn=Object(a.useCallback)((function(){if(xt&&U&&Lt){var e=It.current;if(e){var t=(Lt.width-U.width*xt)/2,n=(Lt.height-U.height*xt)/2;e.setTransform(t,n,xt,200,"easeOutQuad"),e.state.scale=xt,ft(xt),gt(!1)}}}),[It,Lt,U,U.width,Lt.height,xt]),fn=function(){en([]),rn([]),Jt([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){jn()})),function(){window.removeEventListener("resize",(function(){jn()}))}}),[Lt,jn]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){nt(!1)})),function(){window.removeEventListener("blur",(function(){nt(!1)}))}}),[]);Object(x.a)("Escape",(function(){T||(Ft||Vt?(Ht(!1),xe([]),ln([])):jn())}),{event:"keydown"},[Ft,T,Vt,jn,ln]);var hn=function(e){if(tt){var t=ct.x,n=ct.brushSize+(Ce-t);n<=200&&n>=10&&B(n)}else if(!Ge&&Ft&&0!==pe.length){var a=Object(g.a)(pe);a[a.length-1].pts.push($e(e)),xe(a),ln(a)}},pn=function(e){if(!tt&&(!Ge&&U.src&&(null===te||void 0===te?void 0:te.canvas)&&!T&&!function(e){return 2===e.nativeEvent.button}(e)))if(C(e))qe(!0);else if(!(F&&l.showCroper&&(t=$e(e),t.xO.x+O.width||t.y>O.y+O.height))){var t;Ht(!0);var n=[];(Vt||P)&&(n=Object(g.a)(pe)),n.push({size:W,pts:[$e(e)]}),xe(n),ln(n)}},On=Object(a.useCallback)((function(){if(0!==pe.length){be([]);var e=pe.pop(),t=[].concat(Object(g.a)(Qt),[e]);en(t);var n=Object(g.a)(pe);xe(n),ln(n)}}),[pe,Qt,ln]),gn=Object(a.useCallback)((function(){if($.length){var e=oe.pop();rn([].concat(Object(g.a)(an),[e])),en([]),se(Object(g.a)(oe)),xe([]),Ht(!1);var t=$.pop();Jt([].concat(Object(g.a)(Gt),[t]));var n=Object(g.a)($);q(n),0===n.length?cn(U,[]):cn(n[n.length-1],[])}}),[cn,$,Gt,an,oe,U]),vn=function(){P&&0!==pe.length?On():gn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("undo"),!0)}),vn,void 0,[On,gn,F]);var mn=Object(a.useCallback)((function(){if(0!==Qt.length){var e=Qt.pop();en(Object(g.a)(Qt));var t=[].concat(Object(g.a)(pe),[e]);xe(t),ln(t)}}),[pe,Qt,ln]),xn=Object(a.useCallback)((function(){if(0!==Gt.length){var e=an.pop();rn(Object(g.a)(an)),se([].concat(Object(g.a)(oe),[e])),xe([]),Ht(!1);var t=Gt.pop(),n=[].concat(Object(g.a)($),[t]);q(n),cn(n[n.length-1],[])}}),[cn,$,Gt,an,oe,U]),yn=function(){P&&0!==Qt.length?mn():xn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&e.shiftKey&&"z"===e.key.toLowerCase();return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("redo"),!0)}),yn,void 0,[mn,xn,F]);Object(y.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),dn()&&ut((function(){return window.setTimeout((function(){Kt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),dn()&&(Kt(0),window.setTimeout((function(){ut(!1)}),350))}));var wn=function(e){e===Ee||Ge||ze(e)},Sn=Object(a.useCallback)((function(){return Ge?"grab":Ee?"none":void 0}),[Ee,Ge]);Ae("[",(function(){B((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Ae("]",(function(){B((function(e){return e+10}))})),Ae("shift+r",(function(){P&&sn()&&un()}),{},[P,un,sn]),Ae("ctrl+c, cmd+c",Object(b.a)(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,M();case 2:if(!(e.sent&&$.length>0)){e.next=8;break}if(!(null===te||void 0===te?void 0:te.canvas)){e.next=8;break}return e.next=7,z(null===te||void 0===te?void 0:te.canvas);case 7:N({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[$,te]),Object(y.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ze(!1),qe(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ze(!0),qe(!1)})),Object(y.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),nt(!0),it({x:Ce,y:Le,brushSize:W})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),nt(!1)}));var kn=function(e,t){var n=function(){var e,t,n=xt;return void 0!==(null===(e=It.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=It.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(W*n,"px"),height:"".concat(W*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(f.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;Me({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(C(e)&&qe(!1),Ge)||U.src&&(null===te||void 0===te?void 0:te.canvas)&&(T||Ft&&(Vt||P?Ht(!1):un()))},children:[void 0===n?Object(f.jsx)("div",{className:"landing-file-selector",children:Object(f.jsx)(Xe,{onSelection:function(){var e=Object(b.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(f.jsx)(v.b,{ref:function(e){e&&(It.current=e)},panning:{disabled:!Ge,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:xt,minScale:.6*xt,onPanning:function(e){Ot||gt(!0)},onZoom:function(e){ft(e.state.scale)},children:Object(f.jsxs)(v.a,{contentClass:T?"editor-canvas-loading":"",contentStyle:{visibility:Tt?"visible":"hidden"},children:[Object(f.jsxs)("div",{className:"editor-canvas-container",children:[Object(f.jsx)("canvas",{className:"editor-canvas",style:{cursor:Sn(),clipPath:"inset(0 ".concat(Yt,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){wn(!0),Ve(!1)},onFocus:function(){return wn(!0)},onMouseLeave:function(){return wn(!1)},onMouseDown:pn,onMouseMove:hn,ref:function(e){if(e&&!te){var t=e.getContext("2d");t&&ne(t)}}}),Object(f.jsxs)("div",{className:"original-image-container",style:{width:"".concat(U.naturalWidth,"px"),height:"".concat(U.naturalHeight,"px")},children:[lt&&Object(f.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Yt,"%")}}),Object(f.jsx)("img",{className:"original-image",src:U.src,alt:"original",style:{width:"".concat(U.naturalWidth,"px"),height:"".concat(U.naturalHeight,"px")}})]})]}),F&&l.showCroper?Object(f.jsx)(We,{maxHeight:U.naturalHeight,maxWidth:U.naturalWidth,minHeight:Math.min(256,U.naturalHeight),minWidth:Math.min(256,U.naturalWidth),scale:jt}):Object(f.jsx)(f.Fragment,{})]})}),Ee&&!T&&!Ge&&Object(f.jsx)("div",{className:"brush-shape",style:kn(tt?ct.x:Ce,tt?ct.y:Le)}),Ze&&Object(f.jsx)("div",{className:"brush-shape",style:kn(Mt,Nt)}),Object(f.jsxs)("div",{className:"editor-toolkit-panel",children:[F||void 0===n?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(K,{onChange:function(e){Ct(e)},originalWidth:U.naturalWidth,originalHeight:U.naturalHeight}),Object(f.jsx)(V,{label:"Brush",min:10,max:200,value:W,onChange:function(e){B(e),Ze||(Ve(!0),window.setTimeout((function(){Ve(!1)}),1e4))},onClick:function(){return Ve(!1)}}),Object(f.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(f.jsx)(Z,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(f.jsx)(j.a,{}),disabled:jt===xt&&!1===Ot,onClick:jn}),Object(f.jsx)(Z,{toolTip:"Undo",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:vn,disabled:function(){if(T)return!0;if($.length>0)return!1;if(P){if(0===pe.length)return!0}else if(0===$.length)return!0;return!1}()}),Object(f.jsx)(Z,{toolTip:"Redo",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:"scale(-1,1)"},children:Object(f.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:yn,disabled:function(){if(T)return!0;if(Gt.length>0)return!1;if(P){if(0===Qt.length)return!0}else if(0===Gt.length)return!0;return!1}()}),Object(f.jsx)(Z,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(f.jsx)(j.g,{}),className:lt?"eyeicon-active":"",onDown:function(e){e.preventDefault(),ut((function(){return window.setTimeout((function(){Kt(100)}),10),!0}))},onUp:function(){Kt(0),window.setTimeout((function(){ut(!1)}),300)},disabled:0===$.length}),Object(f.jsx)(Z,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(f.jsx)(j.e,{}),disabled:!$.length,onClick:function(){if(void 0!==n){var e=n.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");if(function(e,t){var n=document.createElement("a");n.href=e,n.download=t,n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),setTimeout((function(){n.remove()}),100)}($[$.length-1].currentSrc,e),l.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),on(oe);var a=document.createElement("a");a.download=t,a.href=re.toDataURL("image/jpeg"),a.click()}}}}),l.runInpaintingManually&&!F&&Object(f.jsx)(Z,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M2 13L1.34921 12.2407C1.16773 12.3963 1.04797 12.6117 1.01163 12.8479L2 13ZM22.5 4L23.49 4.14142C23.5309 3.85444 23.4454 3.5638 23.2555 3.3448C23.0655 3.1258 22.7899 3 22.5 3V4ZM12.5 4V3C12.2613 3 12.0305 3.08539 11.8492 3.24074L12.5 4ZM1 19.5L0.0116283 19.3479C-0.0327373 19.6363 0.051055 19.9297 0.241035 20.1511C0.431014 20.3726 0.708231 20.5 1 20.5V19.5ZM11.5 19.5V20.5C11.7373 20.5 11.9668 20.4156 12.1476 20.2619L11.5 19.5ZM21.5 11L22.1476 11.7619C22.3337 11.6038 22.4554 11.3831 22.49 11.1414L21.5 11ZM2 14H12.5V12H2V14ZM13.169 13.7433L23.169 4.74329L21.831 3.25671L11.831 12.2567L13.169 13.7433ZM22.5 3H12.5V5H22.5V3ZM11.8492 3.24074L1.34921 12.2407L2.65079 13.7593L13.1508 4.75926L11.8492 3.24074ZM1.01163 12.8479L0.0116283 19.3479L1.98837 19.6521L2.98837 13.1521L1.01163 12.8479ZM1 20.5H11.5V18.5H1V20.5ZM12.4884 19.6521L13.4884 13.1521L11.5116 12.8479L10.5116 19.3479L12.4884 19.6521ZM21.51 3.85858L20.51 10.8586L22.49 11.1414L23.49 4.14142L21.51 3.85858ZM20.8524 10.2381L10.8524 18.7381L12.1476 20.2619L22.1476 11.7619L20.8524 10.2381Z",fill:"currentColor"})}),disabled:!sn()||T,onClick:function(){!T&&sn()&&un()}})]})]})]})}var Qe=n(28),et=r.a.forwardRef((function(e,t){var n=e.show,a=e.children,r=e.onClose,c=e.className,i=e.title,l=e.showCloseIcon,u=Object(o.d)(pe),d=Object(s.a)(u,2),b=(d[0],d[1]);return Object(f.jsx)(Qe.d,{open:n,onOpenChange:function(e){e||(null===r||void 0===r||r(),b((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})))},children:Object(f.jsxs)(Qe.c,{children:[Object(f.jsx)(Qe.b,{className:"modal-mask"}),Object(f.jsxs)(Qe.a,{ref:t,className:"modal ".concat(c),children:[Object(f.jsxs)("div",{className:"modal-header",children:[Object(f.jsx)(Qe.e,{children:i}),l?Object(f.jsx)(Z,{icon:Object(f.jsx)(j.k,{}),onClick:r}):Object(f.jsx)(f.Fragment,{})]}),a]})]})})}));et.defaultProps={showCloseIcon:!0};var tt=et;function nt(e){var t=e.content,n=e.keys;return Object(f.jsxs)("div",{className:"shortcut-option",children:[Object(f.jsx)("div",{className:"shortcut-description",children:t}),Object(f.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(f.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var at=/macintosh|mac os x/i.test(navigator.userAgent),rt=(/windows|win32/i.test(navigator.userAgent),at?"Cmd":"Ctrl");function ct(){var e=Object(o.d)(Ce),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(tt,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(f.jsxs)("div",{className:"shortcut-options",children:[Object(f.jsx)(nt,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(rt)]}),Object(f.jsx)(nt,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(f.jsx)(nt,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(f.jsx)(nt,{content:"Undo Inpainting",keys:[rt,"Z"]}),Object(f.jsx)(nt,{content:"Redo Inpainting",keys:[rt,"Shift","Z"]}),Object(f.jsx)(nt,{content:"View Original Image",keys:["Hold Tab"]}),Object(f.jsx)(nt,{content:"Pan",keys:["Space + Drag"]}),Object(f.jsx)(nt,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(f.jsx)(nt,{content:"Decrease Brush Size",keys:["["]}),Object(f.jsx)(nt,{content:"Increase Brush Size",keys:["]"]}),Object(f.jsx)(nt,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(f.jsx)(nt,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(f.jsx)(nt,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var it=n(53),ot=["className"],st=["className"],lt=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,ot);return Object(f.jsx)(it.a,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),ut=r.a.forwardRef((function(e,t){var n=e.className,a=Object(J.a)(e,st);return Object(f.jsx)(it.b,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),dt=function(){var e=Object(o.d)(Te),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(ce,{title:"Manual Inpainting Mode",input:Object(f.jsx)(lt,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{runInpaintingManually:e})}))},children:Object(f.jsx)(ut,{})})})};var bt=function(){var e=Object(o.d)(Te),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(s.a)(c,2),l=i[0],u=i[1];Object(a.useEffect)((function(){var e=function(){var e=Object(b.a)(d.a.mark((function e(){var t;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(D,"/is_disable_model_switch"),{method:"GET"}).then((function(e){return e.text()}));case 2:t=e.sent,u("true"===t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]);var j=function(e,t,n){return Object(f.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(f.jsx)(ae,{content:n,children:Object(f.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(f.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})})})},h=function(){return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(le,{title:"Steps",value:"".concat(n.ldmSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);r((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSteps:t})}))}}),Object(f.jsx)(ce,{className:"sub-setting-block",title:"Sampler",input:Object(f.jsx)(_,{width:80,value:n.ldmSampler,options:Object.values(se),onChange:function(e){return t=e,void r((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(f.jsx)(ce,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case de.LAMA:return j(0,0,"https://github.com/saic-mdal/lama");case de.LDM:return j(0,0,"https://github.com/CompVis/latent-diffusion");case de.ZITS:return j(0,0,"https://github.com/DQiaole/ZITS_inpainting");case de.MAT:return j(0,0,"https://github.com/fenglinglwb/MAT");case de.FCF:return j(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case de.SD15:return j(0,0,"https://github.com/CompVis/stable-diffusion");case de.CV2:return j(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(f.jsx)(f.Fragment,{})}}(),input:Object(f.jsx)(_,{width:80,value:n.model,options:Object.values(de),onChange:function(e){return t=e,void r((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}));var t},disabled:l}),optionDesc:function(){switch(n.model){case de.LAMA:return;case de.LDM:return h();case de.ZITS:return Object(f.jsx)("div",{children:Object(f.jsx)(ce,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(f.jsx)(lt,{checked:n.zitsWireframe,onCheckedChange:function(e){r((function(t){return Object(O.a)(Object(O.a)({},t),{},{zitsWireframe:e})}))},children:Object(f.jsx)(ut,{})})})});case de.MAT:return;case de.FCF:return Object(f.jsx)("div",{children:"FcF only support fixed size(512x512) image input. Lama Cleaner will take care of resize and crop process, it still recommended applies to small defects."});case de.SD15:return;case de.CV2:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(le,{title:"Radius",value:"".concat(n.cv2Radius),desc:"Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);r((function(e){return Object(O.a)(Object(O.a)({},e),{},{cv2Radius:t})}))}}),Object(f.jsx)(ce,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(f.jsx)(_,{width:140,value:n.cv2Flag,options:Object.values(je),onChange:function(e){r((function(t){return Object(O.a)(Object(O.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(f.jsx)(f.Fragment,{})}}()})},jt=function(){var e=Object(o.d)(Te),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(ce,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(f.jsx)(lt,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{downloadMask:e})}))},children:Object(f.jsx)(ut,{})})})};function ft(e){var t=e.onClose,n=Object(o.d)(Te),a=Object(s.a)(n,2),r=a[0],c=a[1],i=Object(o.e)(Pe);return Ae("s",(function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!e.show})}))}),{},[]),Object(f.jsxs)(tt,{onClose:function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:r.show,children:[i?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(dt,{}),Object(f.jsx)(jt,{}),Object(f.jsx)(bt,{}),i?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(be,{})]})}var ht=n(37),pt=["state","desc"],Ot=function(){return Object(f.jsx)("span",{className:"loading-icon",children:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Object(f.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(f.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(f.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(f.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(f.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(f.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(f.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(f.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},gt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,r=Object(J.a)(e,pt);return Object(f.jsxs)(ht.b,{children:[Object(f.jsxs)(ht.c,Object(O.a)(Object(O.a)({},r),{},{ref:t,className:"toast-root ".concat(n),children:[Object(f.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(f.jsx)(j.f,{className:"error-icon"});case"success":return Object(f.jsx)(j.b,{className:"success-icon"});case"loading":return Object(f.jsx)(Ot,{});default:return Object(f.jsx)(f.Fragment,{})}}()}),Object(f.jsx)(ht.a,{className:"toast-desc",children:a})]})),Object(f.jsx)(ht.d,{className:"toast-viewpoint"})]})}));gt.defaultProps={desc:"",state:"loading"};var vt=gt,mt=n(36),xt=n(79),yt=["onFocus","onBlur"],wt=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object(J.a)(e,yt),c=Object(o.d)(pe),i=Object(s.a)(c,2),l=(i[0],i[1]);return Object(f.jsx)("textarea",Object(O.a)(Object(O.a)({},r),{},{ref:t,onFocus:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),St=function(){var e=Object(xt.a)(!0),t=Object(s.a)(e,2),n=t[0],a=t[1],r=Object(o.d)(Te),c=Object(s.a)(r,2),i=c[0],l=c[1],u=Object(o.d)(ge),d=Object(s.a)(u,2),b=d[0],j=d[1];return Object(f.jsx)("div",{className:"side-panel",children:Object(f.jsxs)(mt.c,{open:n,children:[Object(f.jsx)(mt.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(f.jsx)(mt.b,{children:Object(f.jsxs)(mt.a,{className:"side-panel-content",children:[Object(f.jsx)(ce,{title:"Croper",input:Object(f.jsx)(lt,{checked:i.showCroper,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{showCroper:e})}))},children:Object(f.jsx)(ut,{})})}),Object(f.jsx)(le,{title:"Steps",width:30,value:"".concat(i.sdSteps),desc:"The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSteps:t})}))}}),Object(f.jsx)(le,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(i.sdGuidanceScale),desc:"Higher guidance scale encourages to generate images that are closely linked to the text prompt, usually at the expense of lower image quality.",onValue:function(e){var t=0===e.length?0:parseFloat(e);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(f.jsx)(le,{title:"Mask Blur",width:30,value:"".concat(i.sdMaskBlur),desc:"Blur the edge of mask area. The higher the number the smoother blend with the original image",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdMaskBlur:t})}))}}),Object(f.jsx)(ce,{className:"sub-setting-block",title:"Sampler",input:Object(f.jsx)(_,{width:80,value:i.sdSampler,options:Object.values(Le),onChange:function(e){var t=e;l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSampler:t})}))}})}),Object(f.jsx)(ce,{title:"Seed",input:Object(f.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(f.jsx)(le,{title:"",width:80,value:"".concat(i.sdSeed),desc:"",disable:!i.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSeed:t})}))}}),Object(f.jsx)(lt,{checked:i.sdSeedFixed,onCheckedChange:function(e){l((function(t){return Object(O.a)(Object(O.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(f.jsx)(ut,{})})]})}),Object(f.jsx)(ce,{className:"sub-setting-block",title:"Negative prompt",layout:"v",input:Object(f.jsx)(wt,{className:"negative-prompt",value:b,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;j(t.value)},placeholder:""})})]})})]})})},kt=function(){var e=Object(o.d)(fe),t=Object(s.a)(e,2),n=(t[0],t[1],Object(o.d)(Te)),r=Object(s.a)(n,2),c=r[0],i=r[1],l=Object(o.d)(ke),u=Object(s.a)(l,2),j=u[0],h=u[1],p=Object(o.e)(Pe),g=function(){var e=Object(b.a)(d.a.mark((function e(){var t,n,a,r,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H().then((function(e){return e.text()}));case 2:if((t=e.sent)!==c.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=c.model,fetch("".concat(D,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=c.model,r="Switching to ".concat(a," model"),o=3e3,"False"===n&&(r="Downloading ".concat(a," model, this may take a while"),o=9999999999),h({open:!0,desc:r,state:"loading",duration:o}),F(a).then((function(e){if(!e.ok)throw new Error("Server error");h({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){h({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),i((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}))}));case 14:case"end":return e.stop()}var s}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){H().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(O.a)(Object(O.a)({},t),{},{model:e})}))}))}),[i]),Object(f.jsxs)(f.Fragment,{children:[p?Object(f.jsx)(St,{}):Object(f.jsx)(f.Fragment,{}),Object(f.jsx)(qe,{}),Object(f.jsx)(ft,{onClose:g}),Object(f.jsx)(ct,{}),Object(f.jsx)(vt,Object(O.a)(Object(O.a)({},j),{},{onOpenChange:function(e){h((function(t){return Object(O.a)(Object(O.a)({},t),{},{open:e})}))}}))]})},Ct=n(56),Lt=function(){var e=Object(o.d)(Ce),t=Object(s.a)(e,2),n=t[0],a=t[1],r=function(){a((function(e){return!e}))};return Ae("h",(function(){r()})),Object(f.jsx)("div",{className:"shortcuts",children:Object(f.jsx)(Z,{onClick:r,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"28",height:"28",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 16 16",children:[Object(f.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(f.jsxs)("g",{fill:"currentColor",children:[Object(f.jsx)("path",{d:"M14 5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h12zM2 4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H2z"}),Object(f.jsx)("path",{d:"M13 10.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm0-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5 0A.25.25 0 0 1 8.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 8 8.75v-.5zm2 0a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25v-.5zm1 2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5-2A.25.25 0 0 1 6.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 6 8.75v-.5zm-2 0A.25.25 0 0 1 4.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 4 8.75v-.5zm-2 0A.25.25 0 0 1 2.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 2 8.75v-.5zm11-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0A.25.25 0 0 1 9.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 9 6.75v-.5zm-2 0A.25.25 0 0 1 7.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 7 6.75v-.5zm-2 0A.25.25 0 0 1 5.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 5 6.75v-.5zm-3 0A.25.25 0 0 1 2.25 6h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5A.25.25 0 0 1 2 6.75v-.5zm0 4a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm2 0a.25.25 0 0 1 .25-.25h5.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-5.5a.25.25 0 0 1-.25-.25v-.5z"})]})]})})})},Mt=function(){var e=Object(o.d)(Te),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)("div",{children:Object(f.jsx)(Z,{onClick:function(){a(Object(O.a)(Object(O.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",role:"img",width:"28",height:"28",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[Object(f.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),Object(f.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},Nt=function(){var e=Object(o.d)(pe),t=Object(s.a)(e,2),n=t[0],r=(t[1],Object(o.d)(Oe)),c=Object(s.a)(r,2),i=c[0],l=c[1],u=Object(o.e)(ve),d=Object(a.useRef)(null),b=function(){0===i.length||n.isInpainting||Ke.emit(_e)};Object(G.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()}));return Object(f.jsxs)("div",{className:"prompt-wrapper",children:[Object(f.jsx)(q,{ref:d,value:i,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;l(t.value)},onKeyUp:function(e){"Enter"!==e.key||u||b()},placeholder:"I want to repaint of..."}),Object(f.jsx)(Z,{border:!0,onClick:b,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},It=n(80),Et=function(){var e=Object(a.useState)(!1),t=Object(s.a)(e,2),n=t[0],r=t[1];return Object(f.jsxs)("div",{children:[Object(f.jsx)(Z,{onClick:function(){r(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(f.jsx)(It.a,{})}),Object(f.jsxs)(tt,{onClose:function(){return r(!1)},title:"Buy Me a Coffee",className:"modal-setting",show:n,showCloseIcon:!1,children:[Object(f.jsx)("h4",{style:{lineHeight:"24px"},children:"Hi there, If you found my project is useful, and want to help keep it alive please consider donating! Thank you for your support!"}),Object(f.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(f.jsx)(Z,{onClick:function(){return r(!1)},children:" No thanks "}),Object(f.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(f.jsx)(Z,{border:!0,onClick:function(){return r(!1)},children:Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(f.jsx)(It.a,{})]})})})]})]})]})},zt=function(){var e=Object(o.e)(ve),t=Object(o.d)(fe),n=Object(s.a)(t,2),r=n[0],c=n[1],i=Object(o.d)(he),l=Object(s.a)(i,2),u=l[0],d=l[1],b=Object(a.useState)("file-upload-".concat(Math.random().toString())),h=Object(s.a)(b,1)[0],O=Object(a.useState)("mask-upload-".concat(Math.random().toString())),g=Object(s.a)(O,1)[0],v=Object(o.e)(Pe);return Object(f.jsxs)("header",{children:[Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8},children:[Object(f.jsx)("label",{htmlFor:h,children:Object(f.jsxs)(Z,{icon:Object(f.jsx)(j.j,{}),style:{border:0},disabled:e,children:[Object(f.jsx)("input",{style:{display:"none"},id:h,name:h,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&c(n)},accept:"image/png, image/jpeg"}),"Image"]})}),Object(f.jsxs)("div",{style:{visibility:r?"visible":"hidden",display:"flex",justifyContent:"center",alignItems:"center"},children:[Object(f.jsx)("label",{htmlFor:g,children:Object(f.jsxs)(Z,{style:{border:0},disabled:e,children:[Object(f.jsx)("input",{style:{display:"none"},id:g,name:g,type:"file",onClick:function(e){e.target.value=""},onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&(console.info("Send custom mask"),Ke.emit(Ye,{mask:n}),d(n))},accept:"image/png, image/jpeg"}),"Mask"]})}),Object(f.jsx)(Z,{style:{visibility:u?"visible":"hidden"},icon:Object(f.jsx)(Ct.a,{}),onClick:function(){u&&Ke.emit(Ye,{mask:u})}})]})]}),v&&r?Object(f.jsx)(Nt,{}):Object(f.jsx)(f.Fragment,{}),Object(f.jsxs)("div",{className:"header-icons-wrapper",children:[Object(f.jsx)(Et,{}),Object(f.jsx)(p,{}),Object(f.jsxs)("div",{className:"header-icons",children:[Object(f.jsx)(Lt,{}),Object(f.jsx)(Mt,{})]})]})]})},Tt=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];!function(){function e(){return e=Object(b.a)(d.a.mark((function e(){var t,n,a=arguments;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:"",e.next=3,fetch(t,{method:"GET",cache:"no-cache"});case 3:return n=e.sent,e.abrupt("return",n.json());case 5:case"end":return e.stop()}}),e)}))),e.apply(this,arguments)}var t=function(){(function(){return e.apply(this,arguments)})(document.location+"/flaskwebgui-keep-server-alive").then((function(e){return e}))};document.addEventListener("DOMContentLoaded",(function(){t(),setInterval(t,3e3)}))}();var Dt=function(){var e=Object(o.d)(fe),t=Object(s.a)(e,2),n=t[0],c=t[1],i=Object(o.d)(h),u=Object(s.a)(i,2),j=u[0],p=u[1],O=Object(o.d)(ke),g=Object(s.a)(O,2),v=(g[0],g[1]),m=function(){var e=Object(a.useState)(),t=Object(s.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){var e=new Headers;e.append("pragma","no-cache"),e.append("cache-control","no-cache"),fetch("/inputimage",{headers:e}).then(function(){var e=Object(b.a)(d.a.mark((function e(t){var n,a,c,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null===(n=t.headers.get("content-disposition"))||void 0===n?void 0:n.split("filename=")[1].split(";")[0],e.next=3,t.blob();case 3:(c=e.sent)&&c.type.startsWith("image")&&(i=new File([c],void 0!==a?a:"inputImage"),r(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[r]);return Object(a.useEffect)((function(){c()}),[c]),n}(),x=Object(a.useState)(!1),y=Object(s.a)(x,2);y[0],y[1],Object(a.useEffect)((function(){c(m)}),[m,c]),Ae("shift+d",(function(){p("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var w=Object(a.useMemo)((function(){return Object(l.a)()}),[n]),S=r.a.useState(!1),k=Object(s.a)(S,2),C=(k[0],k[1]),L=r.a.useRef(0),M=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),N=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&C(!0)}),[]),I=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current-=1,L.current>0||C(!1)}),[]),E=r.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),C(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0){if(e.dataTransfer.files.length>1)v({open:!0,desc:"Please drag and drop only one file",state:"error",duration:3e3});else{var t=e.dataTransfer.files[0],n=t.type;Tt.includes(n)?c(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),z=Object(a.useCallback)((function(e){if(e.clipboardData){var t=e.clipboardData.items,n=[].slice.call(t).filter((function(e){return-1!==e.type.indexOf("image")}));if(0!==n.length){e.preventDefault(),e.stopPropagation();var a=n[0].getAsFile();a&&c(a)}}}),[]);return r.a.useEffect((function(){return window.addEventListener("dragenter",N),window.addEventListener("dragleave",I),window.addEventListener("dragover",M),window.addEventListener("drop",E),window.addEventListener("paste",z),function(){window.removeEventListener("dragenter",N),window.removeEventListener("dragleave",I),window.removeEventListener("dragover",M),window.removeEventListener("drop",E),window.removeEventListener("paste",z)}})),Object(f.jsxs)("div",{className:"lama-cleaner",children:[Object(f.jsx)(zt,{}),Object(f.jsx)(kt,{},w)]})};i.a.render(Object(f.jsx)(r.a.StrictMode,{children:Object(f.jsx)(o.a,{children:Object(f.jsx)(Dt,{})})}),document.getElementById("root"))}},[[73,1,2]]]); \ No newline at end of file diff --git a/lama_cleaner/app/build/static/js/main.963ef5f0.chunk.js b/lama_cleaner/app/build/static/js/main.963ef5f0.chunk.js new file mode 100644 index 0000000..a55cd7e --- /dev/null +++ b/lama_cleaner/app/build/static/js/main.963ef5f0.chunk.js @@ -0,0 +1 @@ +(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{66:function(e,t,n){},73:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(13),i=n.n(c),o=(n(66),n(6)),s=n(7),l=n.n(s),u=n(12),d=n(3),b=n(57);var j=n(16),f=n(1),h=Object(o.b)({key:"themeState",default:"dark"}),p=function(){var e=Object(o.d)(h),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)("div",{className:"theme-toggle-ui",children:Object(f.jsx)("div",{className:"theme-btn",onClick:function(){a("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(f.jsx)(j.h,{}):Object(f.jsx)(j.i,{style:{color:"#ffcc00"}})})})},O=n(2),g=n(9),v=n(51),m=n(82),x=n(54),y=n(83),w=n(8);function S(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],r=0;r0&&void 0!==a[0]?a[0]:"",e.next=3,fetch(t,{method:"GET",cache:"no-cache"});case 3:return n=e.sent,e.abrupt("return",n.json());case 5:case"end":return e.stop()}}),e)}))),e.apply(this,arguments)}var t=function(){(function(){return e.apply(this,arguments)})(document.location+"/flaskwebgui-keep-server-alive").then((function(e){return e}))};document.addEventListener("DOMContentLoaded",(function(){t(),setInterval(t,3e3)}))}function L(e){return 1===e.nativeEvent.button}function M(e,t,n){return fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],t,{type:n})}))}function N(){return I.apply(this,arguments)}function I(){return(I=Object(u.a)(l.a.mark((function e(){var t,n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.permissions.query({name:"clipboard-write"});case 3:return t=e.sent,n=t.state,e.abrupt("return","granted"===n);case 8:return e.prev=8,e.t0=e.catch(0),e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}function E(e,t){return new Promise((function(n,a){return e.toBlob(function(){var e=Object(u.a)(l.a.mark((function e(t){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t?n(t):a(new Error("Expected toBlob() to be defined"));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t)}))}var z=function(){var e=Object(u.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[new ClipboardItem(Object(w.a)({},t.type,t))],e.next=3,navigator.clipboard.write(n);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function T(e){return D.apply(this,arguments)}function D(){return(D=Object(u.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,E(t,"image/png");case 2:return n=e.sent,e.prev=3,e.next=6,z(n);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(3),console.log("Copy image failed!");case 11:case"end":return e.stop()}}),e,null,[[3,8]])})))).apply(this,arguments)}var R="".concat("");function P(e,t,n,a,r,c,i,o,s){return F.apply(this,arguments)}function F(){return(F=Object(u.a)(l.a.mark((function e(t,n,a,r,c,i,o,s,u){var d,b,j,f,h,p;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(d=new FormData).append("image",t),void 0!==s?d.append("mask",S(s)):void 0!==u&&d.append("mask",u),b=n.hdSettings[n.model],d.append("ldmSteps",n.ldmSteps.toString()),d.append("ldmSampler",n.ldmSampler.toString()),d.append("zitsWireframe",n.zitsWireframe.toString()),d.append("hdStrategy",b.hdStrategy),d.append("hdStrategyCropMargin",b.hdStrategyCropMargin.toString()),d.append("hdStrategyCropTrigerSize",b.hdStrategyCropTrigerSize.toString()),d.append("hdStrategyResizeLimit",b.hdStrategyResizeLimit.toString()),d.append("prompt",void 0===r?"":r),d.append("negativePrompt",void 0===c?"":c),d.append("croperX",a.x.toString()),d.append("croperY",a.y.toString()),d.append("croperHeight",a.height.toString()),d.append("croperWidth",a.width.toString()),d.append("useCroper",n.showCroper?"true":"false"),d.append("sdMaskBlur",n.sdMaskBlur.toString()),d.append("sdStrength",n.sdStrength.toString()),d.append("sdSteps",n.sdSteps.toString()),d.append("sdGuidanceScale",n.sdGuidanceScale.toString()),d.append("sdSampler",n.sdSampler.toString()),d.append("sdSeed",o?o.toString():"-1"),d.append("cv2Radius",n.cv2Radius.toString()),d.append("cv2Flag",n.cv2Flag.toString()),void 0===i?d.append("sizeLimit","1080"):d.append("sizeLimit",i),e.prev=27,e.next=30,fetch("".concat(R,"/inpaint"),{method:"POST",body:d});case 30:if(!(j=e.sent).ok){e.next=37;break}return e.next=34,j.blob();case 34:return f=e.sent,h=j.headers.get("x-seed"),e.abrupt("return",{blob:URL.createObjectURL(f),seed:h});case 37:return e.next=39,j.text();case 39:throw p=e.sent,new Error(p);case 43:throw e.prev=43,e.t0=e.catch(27),new Error("Something went wrong: ".concat(e.t0));case 46:case"end":return e.stop()}}),e,null,[[27,43]])})))).apply(this,arguments)}function H(e){var t=new FormData;return t.append("name",e),fetch("".concat(R,"/model"),{method:"POST",body:t})}function A(){return fetch("".concat(R,"/model"),{method:"GET"})}var Z=function(e){var t=e.children,n=e.border,a=e.className,r=e.disabled,c=e.icon,i=e.toolTip,o=e.tooltipPosition,s=e.onKeyDown,l=e.onClick,u=e.onDown,d=e.onUp,b=e.style;return Object(f.jsxs)("div",{role:"button","data-tooltip":i,style:b,onKeyDown:s,onClick:function(e){e.currentTarget.blur(),null===l||void 0===l||l()},onPointerDown:function(e){null===u||void 0===u||u(e.nativeEvent)},onPointerUp:function(e){null===d||void 0===d||d(e.nativeEvent)},tabIndex:-1,className:["btn-primary",t?"btn-primary-content":"",!0===r?"btn-primary-disabled":"",i?"info-tooltip":"",o?"info-tooltip-".concat(o):"",a,n?"btn-border":""].join(" "),children:[c,t?Object(f.jsx)("span",{children:t}):null]})};Z.defaultProps={disabled:!1,border:!1};var V=Z;function W(e){var t=e.value,n=e.onChange,a=e.onClick,r=e.label,c=e.min,i=e.max,o=((i||100)-(c||0))/100;return Object(f.jsxs)("div",{className:"editor-brush-slider",children:[Object(f.jsx)("span",{children:r}),Object(f.jsx)("input",{type:"range",step:o,min:c,max:i,value:t,onChange:function(e){e.preventDefault(),e.stopPropagation(),n(parseInt(e.currentTarget.value,10))},onClick:a})]})}var B=n(24),_=function(e){var t=e.width,n=e.value,r=e.chevronDirection,c=e.options,i=e.autoFocusAfterClose,o=e.onChange,s=e.disabled,l=Object(a.useRef)(null);return Object(f.jsxs)(B.f,{value:n,onValueChange:o,onOpenChange:function(e){e||i||window.setTimeout((function(){var e;null===l||void 0===l||null===(e=l.current)||void 0===e||e.blur()}),100)},children:[Object(f.jsxs)(B.g,{className:"select-trigger",style:{width:t},ref:l,onKeyDown:function(e){return e.preventDefault()},disabled:s,children:[Object(f.jsx)(B.h,{}),Object(f.jsx)(B.b,{children:"up"===r?Object(f.jsx)(j.d,{}):Object(f.jsx)(j.c,{})})]}),Object(f.jsx)(B.a,{className:"select-content",children:Object(f.jsx)(B.i,{className:"select-viewport",children:c.map((function(e){return Object(f.jsxs)(B.c,{value:e,className:"select-item",children:[Object(f.jsx)(B.e,{children:e}),Object(f.jsx)(B.d,{className:"select-item-indicator",children:Object(f.jsx)(j.b,{})})]},e)}))})})]})};_.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0,disabled:!1};var Y=_,K=["720","1080","2000","Original"];function U(e){var t=e.originalHeight,n=e.originalWidth,r=e.onChange,c=Object(a.useState)("Original"),i=Object(d.a)(c,2),o=i[0],s=i[1],l=Math.max(n,t),u=Object(a.useCallback)((function(e){if("Original"===e)return"".concat(n,"x").concat(t);var a=parseInt(e,10)/l;if(n>t){var r=Math.ceil(t*a);return"".concat(e,"x").concat(r)}var c=Math.ceil(n*a);return"".concat(c,"x").concat(e)}),[n,t,l]),b=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(s(a[0]),r(parseInt(a[0],10))):(s(a[1]),r(parseInt(a[1],10)))},chevronDirection:"up"})}var G=n(52),X=n.n(G),J=n(78),$=n(4),q=["onFocus","onBlur"],Q=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object($.a)(e,q),c=Object(o.d)(Oe),i=Object(d.a)(c,2),s=(i[0],i[1]);return Object(f.jsx)("input",Object(O.a)(Object(O.a)({},r),{},{ref:t,type:"text",onFocus:function(e){s((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),ee=["value","allowFloat","onValue"],te=r.a.forwardRef((function(e,t){var n=e.value,r=e.allowFloat,c=e.onValue,i=Object($.a)(e,ee),o=Object(a.useState)(n),s=Object(d.a)(o,2),l=s[0],u=s[1];Object(a.useEffect)((function(){u(n)}),[n]);return Object(f.jsx)(Q,Object(O.a)(Object(O.a)({value:l,onInput:function(e){var t=e.target.value;r?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===c||void 0===c||c(t)):(t=t.replace(/\D/g,""),null===c||void 0===c||c(t)),u(t)},className:"number-input"},i),{},{ref:t}))}));te.defaultProps={allowFloat:!1};var ne=te,ae=n(29),re=function(e){var t=e.content,n=e.children;return Object(f.jsx)(ae.d,{children:Object(f.jsxs)(ae.c,{children:[Object(f.jsx)(ae.e,{className:"tooltip-trigger",children:n}),Object(f.jsxs)(ae.b,{className:"tooltip-content",children:[t,Object(f.jsx)(ae.a,{className:"tooltip-arrow"})]})]})})};function ce(e){var t=e.title,n=e.titleSuffix,a=e.desc,r=e.input,c=e.optionDesc,i=e.className,o="h"===e.layout?"setting-block-content":"setting-block-content-v";return Object(f.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(f.jsxs)("div",{className:o,children:[Object(f.jsx)("div",{className:"setting-block-content-title",children:Object(f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(f.jsx)(re,{content:Object(f.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(f.jsx)("span",{children:t})}):Object(f.jsx)("span",{children:t}),n]})}),r]}),c&&Object(f.jsx)("div",{className:"option-desc",children:c})]})}ce.defaultProps={layout:"h"};var ie=ce;function oe(e){var t=e.title,n=e.allowFloat,r=e.desc,c=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(J.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(f.jsx)(ie,{className:"sub-setting-block",title:t,desc:r,input:Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(f.jsx)(ne,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:c,disabled:u,onValue:o,ref:d}),i&&Object(f.jsx)("span",{children:i})]})})}oe.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var se,le,ue=oe;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(se||(se={})),function(e){e.ddim="ddim",e.plms="plms"}(le||(le={}));var de,be,je=function(){var e=Object(o.d)(Pe),t=Object(d.a)(e,2),n=t[0],a=t[1];if(!(null===n||void 0===n?void 0:n.enabled))return Object(f.jsx)(f.Fragment,{});var r=function(e){a({hdStrategy:e})},c=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyResizeLimit:t})},i=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropTrigerSize:t})},s=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},l=function(){return Object(f.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(f.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(se.RESIZE)},children:"Resize"})," or ",Object(f.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return r(se.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(f.jsx)(ie,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(f.jsx)(Y,{width:80,value:n.hdStrategy,options:Object.values(se),onChange:function(e){return r(e)}}),optionDesc:function(){switch(n.hdStrategy){case se.ORIGINAL:return l();case se.CROP:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(f.jsx)(ue,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(f.jsx)(ue,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:s})]});case se.RESIZE:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(f.jsx)(ue,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:c})]});default:return l()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD15="sd1.5",e.CV2="cv2"}(be||(be={}));var fe,he=Object(o.b)({key:"fileState",default:void 0}),pe=Object(o.b)({key:"maskState",default:void 0}),Oe=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),ge=Object(o.b)({key:"promptState",default:""}),ve=Object(o.b)({key:"negativePromptState",default:""}),me=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(Oe).isInpainting},set:function(e,t){var n=e.get,a=e.set,r=n(Oe);a(Oe,Object(O.a)(Object(O.a)({},r),{},{isInpainting:t}))}}),xe=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),ye=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(xe).x},set:function(e,t){var n=e.get,a=e.set,r=n(xe);a(xe,Object(O.a)(Object(O.a)({},r),{},{x:t}))}}),we=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(xe).y},set:function(e,t){var n=e.get,a=e.set,r=n(xe);a(xe,Object(O.a)(Object(O.a)({},r),{},{y:t}))}}),Se=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(xe).height},set:function(e,t){var n=e.get,a=e.set,r=n(xe);a(xe,Object(O.a)(Object(O.a)({},r),{},{height:t}))}}),ke=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(xe).width},set:function(e,t){var n=e.get,a=e.set,r=n(xe);a(xe,Object(O.a)(Object(O.a)({},r),{},{width:t}))}}),Ce=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),Le=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(fe||(fe={}));var Me,Ne,Ie=(de={},Object(w.a)(de,be.LAMA,{hdStrategy:se.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(w.a)(de,be.LDM,{hdStrategy:se.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(de,be.ZITS,{hdStrategy:se.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(de,be.MAT,{hdStrategy:se.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(de,be.FCF,{hdStrategy:se.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(w.a)(de,be.SD15,{hdStrategy:se.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(w.a)(de,be.CV2,{hdStrategy:se.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),de);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms",e.kEuler="k_euler",e.kEulerA="k_euler_a"}(Me||(Me={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(Ne||(Ne={}));var Ee,ze={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:be.LAMA,hdSettings:Ie,ldmSteps:25,ldmSampler:le.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:Ne.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Me.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,cv2Radius:5,cv2Flag:fe.INPAINT_NS},Te="settingsState4",De=Object(o.b)({key:Te,default:ze,effects:[(Ee=Te,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Ee);if(null!=a){var r=JSON.parse(a);r.show=!1,t(X.a.merge(X.a.cloneDeep(ze),r))}n((function(e,t,n){return n?localStorage.removeItem(Ee):localStorage.setItem(Ee,JSON.stringify(e))}))})]}),Re=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(De).sdSeed},set:function(e,t){var n=e.get,a=e.set,r=n(De);a(De,Object(O.a)(Object(O.a)({},r),{},{sdSeed:t}))}}),Pe=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(De);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,r=n(De),c=r.hdSettings[r.model],i=Object(O.a)(Object(O.a)({},c),t);a(De,Object(O.a)(Object(O.a)({},r),{},{hdSettings:Object(O.a)(Object(O.a)({},r.hdSettings),{},Object(w.a)({},r.model,i))}))}}),Fe=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(De).model===be.SD15}}),He=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(De),a=t(Fe);return n.runInpaintingManually||a}}),Ae=n(58),Ze=function(e,t,n,a){var r=Object(o.e)(Oe);return Object(Ae.a)(e,t,Object(O.a)(Object(O.a)({},n),{},{enabled:!r.disableShortCuts}),a)},Ve={capture:!0,passive:!1},We=function(e,t,n,a,r,c){if(e!==n&&t===a){if(e<0)return[0,a];if(e+t>c)return[c-a,a]}else{if(tc)return[e,c-e]}return[e,t]},Be=function(e){var t=e.minHeight,n=e.minWidth,r=e.maxHeight,c=e.maxWidth,i=e.scale,s=Object(o.d)(ye),l=Object(d.a)(s,2),u=l[0],b=l[1],j=Object(o.d)(we),h=Object(d.a)(j,2),p=h[0],O=h[1],g=Object(o.d)(Se),v=Object(d.a)(g,2),m=v[0],x=v[1],y=Object(o.d)(ke),w=Object(d.a)(y,2),S=w[0],k=w[1],C=Object(o.e)(me),L=Object(a.useState)(!1),M=Object(d.a)(L,2),N=M[0],I=M[1],E=Object(a.useState)(!1),z=Object(d.a)(E,2),T=z[0],D=z[1];Object(a.useEffect)((function(){b(Math.round((c-512)/2)),O(Math.round((r-512)/2))}),[r,c,t,n]);var R=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),P=Object(d.a)(R,2),F=P[0],H=P[1],A=function(){console.log("focus")},Z=function(e,t){return We(e,t,u,S,n,c)},V=function(e,n){return We(e,n,p,m,t,r)},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-F.startResizeY)/i),r=Math.round((t-F.startResizeX)/i),c=function(){var e=F.initHeight-a,t=F.initY+a,n=V(t,e),r=Object(d.a)(n,2),c=r[0],i=r[1];x(i),O(c)},o=function(){var e=F.initHeight+a,t=V(F.initY,e),n=Object(d.a)(t,2),r=n[0],c=n[1];x(c),O(r)},s=function(){var e=F.initWidth-r,t=F.initX+r,n=Z(t,e),a=Object(d.a)(n,2),c=a[0],i=a[1];k(i),b(c)},l=function(){var e=F.initWidth+r,t=Z(F.initX,e),n=Object(d.a)(t,2),a=n[0],c=n[1];k(c),b(a)};if(N)switch(F.ord){case"topleft":c(),s();break;case"topright":c(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":c();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(T){var u=F.initX+r,j=F.initY+a,f=Z(u,F.initWidth),h=Object(d.a)(f,2),p=h[0],g=h[1],v=V(j,F.initHeight),m=Object(d.a)(v,2),y=m[0],w=m[1];k(g),x(w),b(p),O(y)}}},B=function(e){N&&I(!1),T&&D(!1)};Object(a.useEffect)((function(){if(N||T)return document.addEventListener("pointermove",W,Ve),document.addEventListener("pointerup",B,Ve),document.addEventListener("pointercancel",B,Ve),function(){document.removeEventListener("pointermove",W,Ve),document.removeEventListener("pointerup",B,Ve),document.removeEventListener("pointercancel",B,Ve)}}),[N,T,S,m,F]);var _=function(e){var t=e.target.dataset.ord;t&&(I(!0),H({initX:u,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},Y=function(e){D(!0),H({initX:u,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(f.jsx)("div",{className:"croper-wrapper",children:Object(f.jsxs)("div",{className:"croper",style:{height:m,width:S,left:u,top:p},children:[Object(f.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(f.jsx)("div",{className:"info-bar",onPointerDown:Y,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(f.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(f.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:_,children:[Object(f.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(f.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},_e=n(55),Ye="prompt",Ke="custom_mask",Ue=Object(_e.a)(),Ge=function(){var e=Object(a.useState)(window.innerWidth),t=Object(d.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){r(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",c),function(){window.removeEventListener("resize",c)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function Xe(e){var t=e.onSelection,n=Object(a.useState)(!1),r=Object(d.a)(n,2),c=r[0],i=r[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),s=Object(d.a)(o,1)[0],b=Ge();function j(e){if(e&&e.type.match("image.*"))try{if(e.size>20971520)throw new Error("file too large");t(e)}catch(n){alert("error: ".concat(n.message))}}function h(e){return p.apply(this,arguments)}function p(){return(p=Object(u.a)(l.a.mark((function e(t){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){t.file((function(t){return e(t)}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e){return v.apply(this,arguments)}function v(){return(v=Object(u.a)(l.a.mark((function e(t){var n,a,r,c,i;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],r=0;r0)){e.next=23;break}if(!(null===(c=a.shift())||void 0===c?void 0:c.isFile)){e.next=12;break}return e.next=8,h(c);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===c||void 0===c?void 0:c.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=g.a,e.next=18,m(c.createReader());case 18:e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.t0.apply.call(e.t0,e.t1,e.t4);case 21:e.next=3;break;case 23:return e.abrupt("return",n);case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return x.apply(this,arguments)}function x(){return(x=Object(u.a)(l.a.mark((function e(t){var n,a;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,y(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(g.a)(a)),e.next=8,y(t);case 8:a=e.sent,e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e){return w.apply(this,arguments)}function w(){return(w=Object(u.a)(l.a.mark((function e(t){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){t.readEntries(e,n)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(){return(S=Object(u.a)(l.a.mark((function e(t){var n;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.next=3,O(t.dataTransfer.items);case 3:n=e.sent,i(!1),j(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(f.jsx)("label",{htmlFor:s,className:"file-select-label",children:Object(f.jsxs)("div",{className:["file-select-container",c?"file-select-label-hover":""].join(" "),onDrop:function(e){return S.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(f.jsx)("input",{id:s,name:s,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&j(n)},accept:"image/png, image/jpeg"}),Object(f.jsx)("p",{className:"file-select-message",children:"desktop"===b?"Click here or drag an image file":"Tap here to load your picture"})]})})}var Je="#ffcc00bb";function $e(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Je;e.strokeStyle=n,e.lineCap="round",e.lineJoin="round",t.forEach((function(t){(null===t||void 0===t?void 0:t.pts.length)&&t.size&&(e.lineWidth=t.size,e.beginPath(),e.moveTo(t.pts[0].x,t.pts[0].y),t.pts.forEach((function(t){return e.lineTo(t.x,t.y)})),e.stroke())}))}function qe(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function Qe(){var e=Object(o.d)(he),t=Object(d.a)(e,2),n=t[0],r=t[1],c=Object(o.e)(ge),i=Object(o.e)(ve),s=Object(o.e)(De),b=Object(o.d)(Re),h=Object(d.a)(b,2),p=(h[0],h[1]),O=Object(o.e)(xe),w=Object(o.d)(Ce),S=Object(d.a)(w,2),C=(S[0],S[1]),I=Object(o.d)(me),E=Object(d.a)(I,2),z=E[0],D=E[1],R=Object(o.e)(He),F=Object(o.e)(Fe),H=Object(a.useState)(40),A=Object(d.a)(H,2),Z=A[0],B=A[1],_=function(e){var t=Object(a.useState)(new Image),n=Object(d.a)(t,1)[0],r=Object(a.useState)(!1),c=Object(d.a)(r,2),i=c[0],o=c[1];return Object(a.useEffect)((function(){if(void 0!==e)return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,i]}(n),Y=Object(d.a)(_,2),K=Y[0],G=Y[1],X=Object(a.useState)([]),J=Object(d.a)(X,2),$=J[0],q=J[1],Q=Object(a.useState)(),ee=Object(d.a)(Q,2),te=ee[0],ne=ee[1],ae=Object(a.useState)((function(){return document.createElement("canvas")})),re=Object(d.a)(ae,1)[0],ce=Object(a.useState)([]),ie=Object(d.a)(ce,2),oe=ie[0],se=ie[1],le=Object(a.useState)([]),ue=Object(d.a)(le,2),de=ue[0],be=ue[1],je=Object(a.useState)([]),fe=Object(d.a)(je,2),pe=fe[0],Oe=fe[1],ye=Object(a.useState)({x:-1,y:-1}),we=Object(d.a)(ye,2),Se=we[0],ke=Se.x,Le=Se.y,Me=we[1],Ne=Object(a.useState)(!1),Ie=Object(d.a)(Ne,2),Ee=Ie[0],ze=Ie[1],Te=Object(a.useState)(!1),Pe=Object(d.a)(Te,2),Ae=Pe[0],Ve=Pe[1],We=Object(a.useState)(!1),_e=Object(d.a)(We,2),Ge=_e[0],Je=_e[1],Qe=Object(a.useState)(!1),et=Object(d.a)(Qe,2),tt=et[0],nt=et[1],at=Object(a.useState)({x:-1,y:-1,brushSize:20}),rt=Object(d.a)(at,2),ct=rt[0],it=rt[1],ot=Object(a.useState)(!1),st=Object(d.a)(ot,2),lt=st[0],ut=st[1],dt=Object(a.useState)(1),bt=Object(d.a)(dt,2),jt=bt[0],ft=bt[1],ht=Object(a.useState)(!1),pt=Object(d.a)(ht,2),Ot=pt[0],gt=pt[1],vt=Object(a.useState)(1),mt=Object(d.a)(vt,2),xt=mt[0],yt=mt[1],wt=Object(a.useState)(1080),St=Object(d.a)(wt,2),kt=St[0],Ct=St[1],Lt=Object(m.a)(),Mt=Lt.width/2,Nt=Lt.height/2,It=Object(a.useRef)(),Et=Object(a.useState)(!1),zt=Object(d.a)(Et,2),Tt=zt[0],Dt=zt[1],Rt=Object(a.useState)(!1),Pt=Object(d.a)(Rt,2),Ft=Pt[0],Ht=Pt[1],At=Object(a.useState)(!1),Zt=Object(d.a)(At,2),Vt=Zt[0],Wt=Zt[1],Bt=Object(a.useState)(0),_t=Object(d.a)(Bt,2),Yt=_t[0],Kt=_t[1],Ut=Object(a.useState)([]),Gt=Object(d.a)(Ut,2),Xt=Gt[0],Jt=Gt[1],$t=Object(a.useState)([]),qt=Object(d.a)($t,2),Qt=qt[0],en=qt[1],tn=Object(a.useState)([]),nn=Object(d.a)(tn,2),an=nn[0],rn=nn[1],cn=Object(a.useCallback)((function(e,t){te&&(te.clearRect(0,0,te.canvas.width,te.canvas.height),te.drawImage(e,0,0,K.naturalWidth,K.naturalHeight),$e(te,t))}),[te,K]),on=Object(a.useCallback)((function(e){if(!(null===te||void 0===te?void 0:te.canvas.width)||!(null===te||void 0===te?void 0:te.canvas.height))throw new Error("canvas has invalid size");re.width=null===te||void 0===te?void 0:te.canvas.width,re.height=null===te||void 0===te?void 0:te.canvas.height;var t=re.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){$e(t,e,"white")}))}),[te,re]),sn=Object(a.useCallback)((function(){return 0!==pe.length}),[pe]),ln=Object(a.useCallback)((function(e){0===$.length?cn(K,e):cn($[$.length-1],e)}),[K,$,cn]),un=Object(a.useCallback)(function(){var e=Object(u.a)(l.a.mark((function e(t,a){var r,o,u,d,b,j,f,h,v,m,x,y,w,S;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==n){e.next=2;break}return e.abrupt("return");case 2:if(r=void 0!==a,console.log("runInpainting"),o=[],!0!==t){e.next=11;break}if(0!==de.length){e.next=8;break}return e.abrupt("return");case 8:o=de,e.next=16;break;case 11:if(r){e.next=16;break}if(sn()){e.next=14;break}return e.abrupt("return");case 14:be(pe),o=pe;case 16:if(u=[].concat(Object(g.a)(oe),[o]),Oe([]),Ht(!1),D(!0),s.graduallyInpainting?on([o]):on(u),d=n,!0!==s.graduallyInpainting){e.next=37;break}if(!0!==t){e.next=31;break}if(!($.length>1)){e.next=29;break}return b=$[$.length-2],e.next=28,M(b.currentSrc,n.name,n.type);case 28:d=e.sent;case 29:e.next=37;break;case 31:if(!($.length>0)){e.next=37;break}return console.info("gradually inpainting on last result"),j=$[$.length-1],e.next=36,M(j.currentSrc,n.name,n.type);case 36:d=e.sent;case 37:return f=s.sdSeedFixed?s.sdSeed:-1,console.log({useCustomMask:r}),e.prev=39,e.next=42,P(d,s,O,c,i,kt.toString(),f,r?void 0:re.toDataURL(),r?a:void 0);case 42:if(h=e.sent){e.next=45;break}throw new Error("Something went wrong on server side.");case 45:return v=h.blob,(m=h.seed)&&!s.sdSeedFixed&&p(parseInt(m,10)),x=new Image,e.next=50,k(x,v);case 50:!0===t?(y=$.slice(0,-1),w=[].concat(Object(g.a)(y),[x]),q(w)):(S=[].concat(Object(g.a)($),[x]),q(S)),cn(x,[]),se(u),fn(),e.next=60;break;case 56:e.prev=56,e.t0=e.catch(39),C({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),ln([]);case 60:D(!1);case 61:case"end":return e.stop()}}),e,null,[[39,56]])})));return function(t,n){return e.apply(this,arguments)}}(),[oe,pe,re,s.graduallyInpainting,s,O,kt,c,i,ln,sn,on]);Object(a.useEffect)((function(){return Ue.on(Ye,(function(){sn()?un():0!==de.length?un(!0):C({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){Ue.off(Ye)}}),[sn,un,c]),Object(a.useEffect)((function(){return Ue.on(Ke,(function(e){un(!1,e.mask)})),function(){Ue.off(Ke)}}),[un]);var dn=function(){return 0!==$.length},bn=function(e){return"Control"===e.key||"Meta"===e.key};Object(x.a)(bn,(function(){Vt&&(z||(Wt(!1),R||un()))}),{event:"keyup"},[z,Vt,sn]),Object(x.a)(bn,(function(){z||Wt(!0)}),{event:"keydown"},[z]),Object(a.useEffect)((function(){if(G){var e=Lt.width/K.naturalWidth,t=(Lt.height-200)/K.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),yt(n),ft(n),(null===te||void 0===te?void 0:te.canvas)&&(te.canvas.width=K.naturalWidth,te.canvas.height=K.naturalHeight,ln([])),!Tt){var a;null===(a=It.current)||void 0===a||a.centerView(n,1),Dt(!0);var r=Math.max(K.width,K.height);Ct(r)}}}),[null===te||void 0===te?void 0:te.canvas,It,K,G,Lt,Tt,ln]);var jn=Object(a.useCallback)((function(){if(xt&&K&&Lt){var e=It.current;if(e){var t=(Lt.width-K.width*xt)/2,n=(Lt.height-K.height*xt)/2;e.setTransform(t,n,xt,200,"easeOutQuad"),e.state.scale=xt,ft(xt),gt(!1)}}}),[It,Lt,K,K.width,Lt.height,xt]),fn=function(){en([]),rn([]),Jt([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){jn()})),function(){window.removeEventListener("resize",(function(){jn()}))}}),[Lt,jn]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){nt(!1)})),function(){window.removeEventListener("blur",(function(){nt(!1)}))}}),[]);Object(x.a)("Escape",(function(){z||(Ft||Vt?(Ht(!1),Oe([]),ln([])):jn())}),{event:"keydown"},[Ft,z,Vt,jn,ln]);var hn=function(e){if(tt){var t=ct.x,n=ct.brushSize+(ke-t);n<=200&&n>=10&&B(n)}else if(!Ge&&Ft&&0!==pe.length){var a=Object(g.a)(pe);a[a.length-1].pts.push(qe(e)),Oe(a),ln(a)}},pn=function(e){if(!tt&&(!Ge&&K.src&&(null===te||void 0===te?void 0:te.canvas)&&!z&&!function(e){return 2===e.nativeEvent.button}(e)))if(L(e))Je(!0);else if(!(F&&s.showCroper&&(t=qe(e),t.xO.x+O.width||t.y>O.y+O.height))){var t;Ht(!0);var n=[];(Vt||R)&&(n=Object(g.a)(pe)),n.push({size:Z,pts:[qe(e)]}),Oe(n),ln(n)}},On=Object(a.useCallback)((function(){if(0!==pe.length){be([]);var e=pe.pop(),t=[].concat(Object(g.a)(Qt),[e]);en(t);var n=Object(g.a)(pe);Oe(n),ln(n)}}),[pe,Qt,ln]),gn=Object(a.useCallback)((function(){if($.length){var e=oe.pop();rn([].concat(Object(g.a)(an),[e])),en([]),se(Object(g.a)(oe)),Oe([]),Ht(!1);var t=$.pop();Jt([].concat(Object(g.a)(Xt),[t]));var n=Object(g.a)($);q(n),0===n.length?cn(K,[]):cn(n[n.length-1],[])}}),[cn,$,Xt,an,oe,K]),vn=function(){R&&0!==pe.length?On():gn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&!e.shiftKey&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("undo"),!0)}),vn,void 0,[On,gn,F]);var mn=Object(a.useCallback)((function(){if(0!==Qt.length){var e=Qt.pop();en(Object(g.a)(Qt));var t=[].concat(Object(g.a)(pe),[e]);Oe(t),ln(t)}}),[pe,Qt,ln]),xn=Object(a.useCallback)((function(){if(0!==Xt.length){var e=an.pop();rn(Object(g.a)(an)),se([].concat(Object(g.a)(oe),[e])),Oe([]),Ht(!1);var t=Xt.pop(),n=[].concat(Object(g.a)($),[t]);q(n),cn(n[n.length-1],[])}}),[cn,$,Xt,an,oe,K]),yn=function(){R&&0!==Qt.length?mn():xn()};Object(x.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&e.shiftKey&&"z"===e.key.toLowerCase();return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),console.log("redo"),!0)}),yn,void 0,[mn,xn,F]);Object(y.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),dn()&&ut((function(){return window.setTimeout((function(){Kt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),dn()&&(Kt(0),window.setTimeout((function(){ut(!1)}),350))}));var wn=function(e){e===Ee||Ge||ze(e)},Sn=Object(a.useCallback)((function(){return Ge?"grab":Ee?"none":void 0}),[Ee,Ge]);Ze("[",(function(){B((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Ze("]",(function(){B((function(e){return e+10}))})),Ze("shift+r",(function(){R&&sn()&&un()}),{},[R,un,sn]),Ze("ctrl+c, cmd+c",Object(u.a)(l.a.mark((function e(){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N();case 2:if(!(e.sent&&$.length>0)){e.next=8;break}if(!(null===te||void 0===te?void 0:te.canvas)){e.next=8;break}return e.next=7,T(null===te||void 0===te?void 0:te.canvas);case 7:C({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[$,te]),Object(y.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ze(!1),Je(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),ze(!0),Je(!1)})),Object(y.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),nt(!0),it({x:ke,y:Le,brushSize:Z})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),nt(!1)}));var kn=function(e,t){var n=function(){var e,t,n=xt;return void 0!==(null===(e=It.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=It.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(Z*n,"px"),height:"".concat(Z*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(f.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;Me({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(L(e)&&Je(!1),Ge)||K.src&&(null===te||void 0===te?void 0:te.canvas)&&(z||Ft&&(Vt||R?Ht(!1):un()))},children:[void 0===n?Object(f.jsx)("div",{className:"landing-file-selector",children:Object(f.jsx)(Xe,{onSelection:function(){var e=Object(u.a)(l.a.mark((function e(t){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(f.jsx)(v.b,{ref:function(e){e&&(It.current=e)},panning:{disabled:!Ge,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:xt,minScale:.6*xt,onPanning:function(e){Ot||gt(!0)},onZoom:function(e){ft(e.state.scale)},children:Object(f.jsxs)(v.a,{contentClass:z?"editor-canvas-loading":"",contentStyle:{visibility:Tt?"visible":"hidden"},children:[Object(f.jsxs)("div",{className:"editor-canvas-container",children:[Object(f.jsx)("canvas",{className:"editor-canvas",style:{cursor:Sn(),clipPath:"inset(0 ".concat(Yt,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){wn(!0),Ve(!1)},onFocus:function(){return wn(!0)},onMouseLeave:function(){return wn(!1)},onMouseDown:pn,onMouseMove:hn,ref:function(e){if(e&&!te){var t=e.getContext("2d");t&&ne(t)}}}),Object(f.jsxs)("div",{className:"original-image-container",style:{width:"".concat(K.naturalWidth,"px"),height:"".concat(K.naturalHeight,"px")},children:[lt&&Object(f.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Yt,"%")}}),Object(f.jsx)("img",{className:"original-image",src:K.src,alt:"original",style:{width:"".concat(K.naturalWidth,"px"),height:"".concat(K.naturalHeight,"px")}})]})]}),F&&s.showCroper?Object(f.jsx)(Be,{maxHeight:K.naturalHeight,maxWidth:K.naturalWidth,minHeight:Math.min(256,K.naturalHeight),minWidth:Math.min(256,K.naturalWidth),scale:jt}):Object(f.jsx)(f.Fragment,{})]})}),Ee&&!z&&!Ge&&Object(f.jsx)("div",{className:"brush-shape",style:kn(tt?ct.x:ke,tt?ct.y:Le)}),Ae&&Object(f.jsx)("div",{className:"brush-shape",style:kn(Mt,Nt)}),Object(f.jsxs)("div",{className:"editor-toolkit-panel",children:[F||void 0===n?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(U,{onChange:function(e){Ct(e)},originalWidth:K.naturalWidth,originalHeight:K.naturalHeight}),Object(f.jsx)(W,{label:"Brush",min:10,max:200,value:Z,onChange:function(e){B(e),Ae||(Ve(!0),window.setTimeout((function(){Ve(!1)}),1e4))},onClick:function(){return Ve(!1)}}),Object(f.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(f.jsx)(V,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(f.jsx)(j.a,{}),disabled:jt===xt&&!1===Ot,onClick:jn}),Object(f.jsx)(V,{toolTip:"Undo",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:vn,disabled:function(){if(z)return!0;if($.length>0)return!1;if(R){if(0===pe.length)return!0}else if(0===$.length)return!0;return!1}()}),Object(f.jsx)(V,{toolTip:"Redo",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:"scale(-1,1)"},children:Object(f.jsx)("path",{d:"M2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1H2ZM1 8H0V9H1V8ZM8 9C8.55228 9 9 8.55229 9 8C9 7.44771 8.55228 7 8 7V9ZM16.5963 7.42809C16.8327 7.92721 17.429 8.14016 17.9281 7.90374C18.4272 7.66731 18.6402 7.07103 18.4037 6.57191L16.5963 7.42809ZM16.9468 5.83205L17.8505 5.40396L16.9468 5.83205ZM0 1V8H2V1H0ZM1 9H8V7H1V9ZM1.66896 8.74329L6.66896 4.24329L5.33104 2.75671L0.331035 7.25671L1.66896 8.74329ZM16.043 6.26014L16.5963 7.42809L18.4037 6.57191L17.8505 5.40396L16.043 6.26014ZM6.65079 4.25926C9.67554 1.66661 14.3376 2.65979 16.043 6.26014L17.8505 5.40396C15.5805 0.61182 9.37523 -0.710131 5.34921 2.74074L6.65079 4.25926Z",fill:"currentColor"})}),onClick:yn,disabled:function(){if(z)return!0;if(Xt.length>0)return!1;if(R){if(0===Qt.length)return!0}else if(0===Xt.length)return!0;return!1}()}),Object(f.jsx)(V,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(f.jsx)(j.g,{}),className:lt?"eyeicon-active":"",onDown:function(e){e.preventDefault(),ut((function(){return window.setTimeout((function(){Kt(100)}),10),!0}))},onUp:function(){Kt(0),window.setTimeout((function(){ut(!1)}),300)},disabled:0===$.length}),Object(f.jsx)(V,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(f.jsx)(j.e,{}),disabled:!$.length,onClick:function(){if(void 0!==n){var e=n.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");if(function(e,t){var n=document.createElement("a");n.href=e,n.download=t,n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),setTimeout((function(){n.remove()}),100)}($[$.length-1].currentSrc,e),s.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),on(oe);var a=document.createElement("a");a.download=t,a.href=re.toDataURL("image/jpeg"),a.click()}}}}),s.runInpaintingManually&&!F&&Object(f.jsx)(V,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(f.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M2 13L1.34921 12.2407C1.16773 12.3963 1.04797 12.6117 1.01163 12.8479L2 13ZM22.5 4L23.49 4.14142C23.5309 3.85444 23.4454 3.5638 23.2555 3.3448C23.0655 3.1258 22.7899 3 22.5 3V4ZM12.5 4V3C12.2613 3 12.0305 3.08539 11.8492 3.24074L12.5 4ZM1 19.5L0.0116283 19.3479C-0.0327373 19.6363 0.051055 19.9297 0.241035 20.1511C0.431014 20.3726 0.708231 20.5 1 20.5V19.5ZM11.5 19.5V20.5C11.7373 20.5 11.9668 20.4156 12.1476 20.2619L11.5 19.5ZM21.5 11L22.1476 11.7619C22.3337 11.6038 22.4554 11.3831 22.49 11.1414L21.5 11ZM2 14H12.5V12H2V14ZM13.169 13.7433L23.169 4.74329L21.831 3.25671L11.831 12.2567L13.169 13.7433ZM22.5 3H12.5V5H22.5V3ZM11.8492 3.24074L1.34921 12.2407L2.65079 13.7593L13.1508 4.75926L11.8492 3.24074ZM1.01163 12.8479L0.0116283 19.3479L1.98837 19.6521L2.98837 13.1521L1.01163 12.8479ZM1 20.5H11.5V18.5H1V20.5ZM12.4884 19.6521L13.4884 13.1521L11.5116 12.8479L10.5116 19.3479L12.4884 19.6521ZM21.51 3.85858L20.51 10.8586L22.49 11.1414L23.49 4.14142L21.51 3.85858ZM20.8524 10.2381L10.8524 18.7381L12.1476 20.2619L22.1476 11.7619L20.8524 10.2381Z",fill:"currentColor"})}),disabled:!sn()||z,onClick:function(){!z&&sn()&&un()}})]})]})]})}var et=n(28),tt=r.a.forwardRef((function(e,t){var n=e.show,a=e.children,r=e.onClose,c=e.className,i=e.title,s=e.showCloseIcon,l=Object(o.d)(Oe),u=Object(d.a)(l,2),b=(u[0],u[1]);return Object(f.jsx)(et.d,{open:n,onOpenChange:function(e){e||(null===r||void 0===r||r(),b((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})))},children:Object(f.jsxs)(et.c,{children:[Object(f.jsx)(et.b,{className:"modal-mask"}),Object(f.jsxs)(et.a,{ref:t,className:"modal ".concat(c),children:[Object(f.jsxs)("div",{className:"modal-header",children:[Object(f.jsx)(et.e,{children:i}),s?Object(f.jsx)(V,{icon:Object(f.jsx)(j.k,{}),onClick:r}):Object(f.jsx)(f.Fragment,{})]}),a]})]})})}));tt.defaultProps={showCloseIcon:!0};var nt=tt;function at(e){var t=e.content,n=e.keys;return Object(f.jsxs)("div",{className:"shortcut-option",children:[Object(f.jsx)("div",{className:"shortcut-description",children:t}),Object(f.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(f.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var rt=/macintosh|mac os x/i.test(navigator.userAgent),ct=(/windows|win32/i.test(navigator.userAgent),rt?"Cmd":"Ctrl");function it(){var e=Object(o.d)(Le),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(nt,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(f.jsxs)("div",{className:"shortcut-options",children:[Object(f.jsx)(at,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(ct)]}),Object(f.jsx)(at,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(f.jsx)(at,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(f.jsx)(at,{content:"Undo Inpainting",keys:[ct,"Z"]}),Object(f.jsx)(at,{content:"Redo Inpainting",keys:[ct,"Shift","Z"]}),Object(f.jsx)(at,{content:"View Original Image",keys:["Hold Tab"]}),Object(f.jsx)(at,{content:"Pan",keys:["Space + Drag"]}),Object(f.jsx)(at,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(f.jsx)(at,{content:"Decrease Brush Size",keys:["["]}),Object(f.jsx)(at,{content:"Increase Brush Size",keys:["]"]}),Object(f.jsx)(at,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(f.jsx)(at,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(f.jsx)(at,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var ot=n(53),st=["className"],lt=["className"],ut=r.a.forwardRef((function(e,t){var n=e.className,a=Object($.a)(e,st);return Object(f.jsx)(ot.a,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),dt=r.a.forwardRef((function(e,t){var n=e.className,a=Object($.a)(e,lt);return Object(f.jsx)(ot.b,Object(O.a)(Object(O.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),bt=function(){var e=Object(o.d)(De),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(ie,{title:"Manual Inpainting Mode",input:Object(f.jsx)(ut,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{runInpaintingManually:e})}))},children:Object(f.jsx)(dt,{})})})};var jt=function(){var e=Object(o.d)(De),t=Object(d.a)(e,2),n=t[0],r=t[1],c=Object(a.useState)(!1),i=Object(d.a)(c,2),s=i[0],b=i[1];Object(a.useEffect)((function(){var e=function(){var e=Object(u.a)(l.a.mark((function e(){var t;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(R,"/is_disable_model_switch"),{method:"GET"}).then((function(e){return e.text()}));case 2:t=e.sent,b("true"===t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]);var j=function(e,t,n){return Object(f.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(f.jsx)(re,{content:n,children:Object(f.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(f.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(f.jsx)("path",{d:"M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})})})},h=function(){return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(ue,{title:"Steps",value:"".concat(n.ldmSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);r((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSteps:t})}))}}),Object(f.jsx)(ie,{className:"sub-setting-block",title:"Sampler",input:Object(f.jsx)(Y,{width:80,value:n.ldmSampler,options:Object.values(le),onChange:function(e){return t=e,void r((function(e){return Object(O.a)(Object(O.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(f.jsx)(ie,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case be.LAMA:return j(0,0,"https://github.com/saic-mdal/lama");case be.LDM:return j(0,0,"https://github.com/CompVis/latent-diffusion");case be.ZITS:return j(0,0,"https://github.com/DQiaole/ZITS_inpainting");case be.MAT:return j(0,0,"https://github.com/fenglinglwb/MAT");case be.FCF:return j(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case be.SD15:return j(0,0,"https://github.com/CompVis/stable-diffusion");case be.CV2:return j(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(f.jsx)(f.Fragment,{})}}(),input:Object(f.jsx)(Y,{width:80,value:n.model,options:Object.values(be),onChange:function(e){return t=e,void r((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}));var t},disabled:s}),optionDesc:function(){switch(n.model){case be.LAMA:return;case be.LDM:return h();case be.ZITS:return Object(f.jsx)("div",{children:Object(f.jsx)(ie,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(f.jsx)(ut,{checked:n.zitsWireframe,onCheckedChange:function(e){r((function(t){return Object(O.a)(Object(O.a)({},t),{},{zitsWireframe:e})}))},children:Object(f.jsx)(dt,{})})})});case be.MAT:return;case be.FCF:return Object(f.jsx)("div",{children:"FcF only support fixed size(512x512) image input. Lama Cleaner will take care of resize and crop process, it still recommended applies to small defects."});case be.SD15:return;case be.CV2:return Object(f.jsxs)(f.Fragment,{children:[Object(f.jsx)(ue,{title:"Radius",value:"".concat(n.cv2Radius),desc:"Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);r((function(e){return Object(O.a)(Object(O.a)({},e),{},{cv2Radius:t})}))}}),Object(f.jsx)(ie,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(f.jsx)(Y,{width:140,value:n.cv2Flag,options:Object.values(fe),onChange:function(e){r((function(t){return Object(O.a)(Object(O.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(f.jsx)(f.Fragment,{})}}()})},ft=function(){var e=Object(o.d)(De),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)(ie,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(f.jsx)(ut,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(O.a)(Object(O.a)({},t),{},{downloadMask:e})}))},children:Object(f.jsx)(dt,{})})})};function ht(e){var t=e.onClose,n=Object(o.d)(De),a=Object(d.a)(n,2),r=a[0],c=a[1],i=Object(o.e)(Fe);return Ze("s",(function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!e.show})}))}),{},[]),Object(f.jsxs)(nt,{onClose:function(){c((function(e){return Object(O.a)(Object(O.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:r.show,children:[i?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(bt,{}),Object(f.jsx)(ft,{}),Object(f.jsx)(jt,{}),i?Object(f.jsx)(f.Fragment,{}):Object(f.jsx)(je,{})]})}var pt=n(37),Ot=["state","desc"],gt=function(){return Object(f.jsx)("span",{className:"loading-icon",children:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Object(f.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(f.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(f.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(f.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(f.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(f.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(f.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(f.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},vt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,r=Object($.a)(e,Ot);return Object(f.jsxs)(pt.b,{children:[Object(f.jsxs)(pt.c,Object(O.a)(Object(O.a)({},r),{},{ref:t,className:"toast-root ".concat(n),children:[Object(f.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(f.jsx)(j.f,{className:"error-icon"});case"success":return Object(f.jsx)(j.b,{className:"success-icon"});case"loading":return Object(f.jsx)(gt,{});default:return Object(f.jsx)(f.Fragment,{})}}()}),Object(f.jsx)(pt.a,{className:"toast-desc",children:a})]})),Object(f.jsx)(pt.d,{className:"toast-viewpoint"})]})}));vt.defaultProps={desc:"",state:"loading"};var mt=vt,xt=n(36),yt=n(79),wt=["onFocus","onBlur"],St=r.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,r=Object($.a)(e,wt),c=Object(o.d)(Oe),i=Object(d.a)(c,2),s=(i[0],i[1]);return Object(f.jsx)("textarea",Object(O.a)(Object(O.a)({},r),{},{ref:t,onFocus:function(e){s((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(O.a)(Object(O.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onPaste:function(e){return e.stopPropagation()},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur(),(e.ctrlKey||e.metaKey)&&"z"===e.key&&e.stopPropagation()}}))})),kt=function(){var e=Object(yt.a)(!0),t=Object(d.a)(e,2),n=t[0],a=t[1],r=Object(o.d)(De),c=Object(d.a)(r,2),i=c[0],s=c[1],l=Object(o.d)(ve),u=Object(d.a)(l,2),b=u[0],j=u[1];return Object(f.jsx)("div",{className:"side-panel",children:Object(f.jsxs)(xt.c,{open:n,children:[Object(f.jsx)(xt.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(f.jsx)(xt.b,{children:Object(f.jsxs)(xt.a,{className:"side-panel-content",children:[Object(f.jsx)(ie,{title:"Croper",input:Object(f.jsx)(ut,{checked:i.showCroper,onCheckedChange:function(e){s((function(t){return Object(O.a)(Object(O.a)({},t),{},{showCroper:e})}))},children:Object(f.jsx)(dt,{})})}),Object(f.jsx)(ue,{title:"Steps",width:30,value:"".concat(i.sdSteps),desc:"The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.",onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSteps:t})}))}}),Object(f.jsx)(ue,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(i.sdGuidanceScale),desc:"Higher guidance scale encourages to generate images that are closely linked to the text prompt, usually at the expense of lower image quality.",onValue:function(e){var t=0===e.length?0:parseFloat(e);s((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(f.jsx)(ue,{title:"Mask Blur",width:30,value:"".concat(i.sdMaskBlur),desc:"Blur the edge of mask area. The higher the number the smoother blend with the original image",onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdMaskBlur:t})}))}}),Object(f.jsx)(ie,{className:"sub-setting-block",title:"Sampler",input:Object(f.jsx)(Y,{width:80,value:i.sdSampler,options:Object.values(Me),onChange:function(e){var t=e;s((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSampler:t})}))}})}),Object(f.jsx)(ie,{title:"Seed",input:Object(f.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(f.jsx)(ue,{title:"",width:80,value:"".concat(i.sdSeed),desc:"",disable:!i.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);s((function(e){return Object(O.a)(Object(O.a)({},e),{},{sdSeed:t})}))}}),Object(f.jsx)(ut,{checked:i.sdSeedFixed,onCheckedChange:function(e){s((function(t){return Object(O.a)(Object(O.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(f.jsx)(dt,{})})]})}),Object(f.jsx)(ie,{className:"sub-setting-block",title:"Negative prompt",layout:"v",input:Object(f.jsx)(St,{className:"negative-prompt",value:b,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;j(t.value)},placeholder:""})})]})})]})})},Ct=function(){var e=Object(o.d)(he),t=Object(d.a)(e,2),n=(t[0],t[1],Object(o.d)(De)),r=Object(d.a)(n,2),c=r[0],i=r[1],s=Object(o.d)(Ce),b=Object(d.a)(s,2),j=b[0],h=b[1],p=Object(o.e)(Fe),g=function(){var e=Object(u.a)(l.a.mark((function e(){var t,n,a,r,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A().then((function(e){return e.text()}));case 2:if((t=e.sent)!==c.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=c.model,fetch("".concat(R,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=c.model,r="Switching to ".concat(a," model"),o=3e3,"False"===n&&(r="Downloading ".concat(a," model, this may take a while"),o=9999999999),h({open:!0,desc:r,state:"loading",duration:o}),H(a).then((function(e){if(!e.ok)throw new Error("Server error");h({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){h({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),i((function(e){return Object(O.a)(Object(O.a)({},e),{},{model:t})}))}));case 14:case"end":return e.stop()}var s}),e)})));return function(){return e.apply(this,arguments)}}();return Object(a.useEffect)((function(){A().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(O.a)(Object(O.a)({},t),{},{model:e})}))}))}),[i]),Object(f.jsxs)(f.Fragment,{children:[p?Object(f.jsx)(kt,{}):Object(f.jsx)(f.Fragment,{}),Object(f.jsx)(Qe,{}),Object(f.jsx)(ht,{onClose:g}),Object(f.jsx)(it,{}),Object(f.jsx)(mt,Object(O.a)(Object(O.a)({},j),{},{onOpenChange:function(e){h((function(t){return Object(O.a)(Object(O.a)({},t),{},{open:e})}))}}))]})},Lt=n(56),Mt=function(){var e=Object(o.d)(Le),t=Object(d.a)(e,2),n=t[0],a=t[1],r=function(){a((function(e){return!e}))};return Ze("h",(function(){r()})),Object(f.jsx)("div",{className:"shortcuts",children:Object(f.jsx)(V,{onClick:r,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"28",height:"28",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 16 16",children:[Object(f.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(f.jsxs)("g",{fill:"currentColor",children:[Object(f.jsx)("path",{d:"M14 5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h12zM2 4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H2z"}),Object(f.jsx)("path",{d:"M13 10.25a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm0-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5 0A.25.25 0 0 1 8.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 8 8.75v-.5zm2 0a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25v-.5zm1 2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-5-2A.25.25 0 0 1 6.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 6 8.75v-.5zm-2 0A.25.25 0 0 1 4.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 4 8.75v-.5zm-2 0A.25.25 0 0 1 2.25 8h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 2 8.75v-.5zm11-2a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm-2 0A.25.25 0 0 1 9.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 9 6.75v-.5zm-2 0A.25.25 0 0 1 7.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 7 6.75v-.5zm-2 0A.25.25 0 0 1 5.25 6h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5A.25.25 0 0 1 5 6.75v-.5zm-3 0A.25.25 0 0 1 2.25 6h1.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-1.5A.25.25 0 0 1 2 6.75v-.5zm0 4a.25.25 0 0 1 .25-.25h.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-.5a.25.25 0 0 1-.25-.25v-.5zm2 0a.25.25 0 0 1 .25-.25h5.5a.25.25 0 0 1 .25.25v.5a.25.25 0 0 1-.25.25h-5.5a.25.25 0 0 1-.25-.25v-.5z"})]})]})})})},Nt=function(){var e=Object(o.d)(De),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(f.jsx)("div",{children:Object(f.jsx)(V,{onClick:function(){a(Object(O.a)(Object(O.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(f.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",role:"img",width:"28",height:"28",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[Object(f.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),Object(f.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},It=function(){var e=Object(o.d)(Oe),t=Object(d.a)(e,2),n=t[0],r=(t[1],Object(o.d)(ge)),c=Object(d.a)(r,2),i=c[0],s=c[1],l=Object(o.e)(me),u=Object(a.useRef)(null),b=function(){0===i.length||n.isInpainting||Ue.emit(Ye)};Object(J.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(f.jsxs)("div",{className:"prompt-wrapper",children:[Object(f.jsx)(Q,{ref:u,value:i,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s(t.value)},onKeyUp:function(e){"Enter"!==e.key||l||b()},placeholder:"I want to repaint of..."}),Object(f.jsx)(V,{border:!0,onClick:b,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},Et=n(80),zt=function(){var e=Object(a.useState)(!1),t=Object(d.a)(e,2),n=t[0],r=t[1];return Object(f.jsxs)("div",{children:[Object(f.jsx)(V,{onClick:function(){r(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(f.jsx)(Et.a,{})}),Object(f.jsxs)(nt,{onClose:function(){return r(!1)},title:"Buy Me a Coffee",className:"modal-setting",show:n,showCloseIcon:!1,children:[Object(f.jsx)("h4",{style:{lineHeight:"24px"},children:"Hi there, If you found my project is useful, and want to help keep it alive please consider donating! Thank you for your support!"}),Object(f.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(f.jsx)(V,{onClick:function(){return r(!1)},children:" No thanks "}),Object(f.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(f.jsx)(V,{border:!0,onClick:function(){return r(!1)},children:Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(f.jsx)(Et.a,{})]})})})]})]})]})},Tt=function(){var e=Object(o.e)(me),t=Object(o.d)(he),n=Object(d.a)(t,2),r=n[0],c=n[1],i=Object(o.d)(pe),s=Object(d.a)(i,2),l=s[0],u=s[1],b=Object(a.useState)("file-upload-".concat(Math.random().toString())),h=Object(d.a)(b,1)[0],O=Object(a.useState)("mask-upload-".concat(Math.random().toString())),g=Object(d.a)(O,1)[0],v=Object(o.e)(Fe);return Object(f.jsxs)("header",{children:[Object(f.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8},children:[Object(f.jsx)("label",{htmlFor:h,children:Object(f.jsxs)(V,{icon:Object(f.jsx)(j.j,{}),style:{border:0},disabled:e,children:[Object(f.jsx)("input",{style:{display:"none"},id:h,name:h,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&c(n)},accept:"image/png, image/jpeg"}),"Image"]})}),Object(f.jsxs)("div",{style:{visibility:r?"visible":"hidden",display:"flex",justifyContent:"center",alignItems:"center"},children:[Object(f.jsx)("label",{htmlFor:g,children:Object(f.jsxs)(V,{style:{border:0},disabled:e,children:[Object(f.jsx)("input",{style:{display:"none"},id:g,name:g,type:"file",onClick:function(e){e.target.value=""},onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&(console.info("Send custom mask"),Ue.emit(Ke,{mask:n}),u(n))},accept:"image/png, image/jpeg"}),"Mask"]})}),Object(f.jsx)(V,{style:{visibility:l?"visible":"hidden"},icon:Object(f.jsx)(Lt.a,{}),onClick:function(){l&&Ue.emit(Ke,{mask:l})}})]})]}),v&&r?Object(f.jsx)(It,{}):Object(f.jsx)(f.Fragment,{}),Object(f.jsxs)("div",{className:"header-icons-wrapper",children:[Object(f.jsx)(zt,{}),Object(f.jsx)(p,{}),Object(f.jsxs)("div",{className:"header-icons",children:[Object(f.jsx)(Mt,{}),Object(f.jsx)(Nt,{})]})]})]})},Dt=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];var Rt=function(){var e=Object(o.d)(he),t=Object(d.a)(e,2),n=t[0],c=t[1],i=Object(o.d)(h),s=Object(d.a)(i,2),j=s[0],p=s[1],O=Object(o.d)(Ce),g=Object(d.a)(O,2),v=(g[0],g[1]),m=function(){var e=Object(a.useState)(),t=Object(d.a)(e,2),n=t[0],r=t[1],c=Object(a.useCallback)((function(){var e=new Headers;e.append("pragma","no-cache"),e.append("cache-control","no-cache"),fetch("/inputimage",{headers:e}).then(function(){var e=Object(u.a)(l.a.mark((function e(t){var n,a,c,i;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null===(n=t.headers.get("content-disposition"))||void 0===n?void 0:n.split("filename=")[1].split(";")[0],e.next=3,t.blob();case 3:(c=e.sent)&&c.type.startsWith("image")&&(i=new File([c],void 0!==a?a:"inputImage"),r(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[r]);return Object(a.useEffect)((function(){c()}),[c]),n}(),x=Object(a.useState)(!1),y=Object(d.a)(x,2);y[0],y[1],Object(a.useEffect)((function(){c(m)}),[m,c]),Object(a.useEffect)((function(){var e=function(){var e=Object(u.a)(l.a.mark((function e(){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("".concat(R,"/is_desktop"),{method:"GET"}).then((function(e){return e.text()}));case 2:"True"===e.sent&&C();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),Ze("shift+d",(function(){p("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var w=Object(a.useMemo)((function(){return Object(b.a)()}),[n]),S=r.a.useState(!1),k=Object(d.a)(S,2),L=(k[0],k[1]),M=r.a.useRef(0),N=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),I=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),M.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&L(!0)}),[]),E=r.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),M.current-=1,M.current>0||L(!1)}),[]),z=r.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),L(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0){if(e.dataTransfer.files.length>1)v({open:!0,desc:"Please drag and drop only one file",state:"error",duration:3e3});else{var t=e.dataTransfer.files[0],n=t.type;Dt.includes(n)?c(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),T=Object(a.useCallback)((function(e){if(e.clipboardData){var t=e.clipboardData.items,n=[].slice.call(t).filter((function(e){return-1!==e.type.indexOf("image")}));if(0!==n.length){e.preventDefault(),e.stopPropagation();var a=n[0].getAsFile();a&&c(a)}}}),[]);return r.a.useEffect((function(){return window.addEventListener("dragenter",I),window.addEventListener("dragleave",E),window.addEventListener("dragover",N),window.addEventListener("drop",z),window.addEventListener("paste",T),function(){window.removeEventListener("dragenter",I),window.removeEventListener("dragleave",E),window.removeEventListener("dragover",N),window.removeEventListener("drop",z),window.removeEventListener("paste",T)}})),Object(f.jsxs)("div",{className:"lama-cleaner",children:[Object(f.jsx)(Tt,{}),Object(f.jsx)(Ct,{},w)]})};i.a.render(Object(f.jsx)(r.a.StrictMode,{children:Object(f.jsx)(o.a,{children:Object(f.jsx)(Rt,{})})}),document.getElementById("root"))}},[[73,1,2]]]); \ No newline at end of file