(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{67:function(e,t,n){},74:function(e,t,n){"use strict";n.r(t);n(62);var a=n(0),c=n.n(a),r=n(13),i=n.n(r),o=(n(67),n(6)),s=n(7),l=n.n(s),u=n(12),d=n(3),b=n(57);var j=n(77),f=n(78),h=n(1),p=Object(o.b)({key:"themeState",default:"dark"}),O=function(){var e=Object(o.d)(p),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{className:"theme-toggle-ui",children:Object(h.jsx)("div",{className:"theme-btn",onClick:function(){a("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(h.jsx)(j.a,{}):Object(h.jsx)(f.a,{style:{color:"#ffcc00"}})})})},g=n(2),v=n(9),m=n(86),x=n(87),y=n(88),w=n(89),S=n(51),k=n(95),C=n(54),M=n(96),L=n(8);function I(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],c=0;c0&&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}))};t(),setInterval(t,3e3)}function z(e){return 2===e.nativeEvent.button}function T(e){return 1===e.nativeEvent.button}function R(e,t,n){return fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],t,{type:n})}))}function D(){return P.apply(this,arguments)}function P(){return(P=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 F(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 H=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(L.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 A(e){return Z.apply(this,arguments)}function Z(){return(Z=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,F(t,"image/png");case 2:return n=e.sent,e.prev=3,e.next=6,H(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 V="".concat("");function W(e,t,n,a,c,r,i,o,s){return B.apply(this,arguments)}function B(){return(B=Object(u.a)(l.a.mark((function e(t,n,a,c,r,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",I(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===c?"":c),d.append("negativePrompt",void 0===r?"":r),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("sdMatchHistograms",n.sdMatchHistograms?"true":"false"),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=28,e.next=31,fetch("".concat(V,"/inpaint"),{method:"POST",body:d});case 31:if(!(j=e.sent).ok){e.next=38;break}return e.next=35,j.blob();case 35:return f=e.sent,h=j.headers.get("x-seed"),e.abrupt("return",{blob:URL.createObjectURL(f),seed:h});case 38:return e.next=40,j.text();case 40:throw p=e.sent,new Error(p);case 44:throw e.prev=44,e.t0=e.catch(28),new Error("Something went wrong: ".concat(e.t0));case 47:case"end":return e.stop()}}),e,null,[[28,44]])})))).apply(this,arguments)}function _(e){var t=new FormData;return t.append("name",e),fetch("".concat(V,"/model"),{method:"POST",body:t})}function U(){return fetch("".concat(V,"/model"),{method:"GET"})}function K(e,t,n){return Y.apply(this,arguments)}function Y(){return(Y=Object(u.a)(l.a.mark((function e(t,n,a){var c,r,i,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(c=new FormData).append("image",t),c.append("clicks",JSON.stringify(a)),null!==n&&c.append("mask",n),e.prev=4,e.next=7,fetch("".concat(V,"/interactive_seg"),{method:"POST",body:c});case 7:if(!(r=e.sent).ok){e.next=13;break}return e.next=11,r.blob();case 11:return i=e.sent,e.abrupt("return",{blob:URL.createObjectURL(i)});case 13:return e.next=15,r.text();case 15:throw o=e.sent,new Error(o);case 19:throw e.prev=19,e.t0=e.catch(4),new Error("Something went wrong: ".concat(e.t0));case 22:case"end":return e.stop()}}),e,null,[[4,19]])})))).apply(this,arguments)}var G=function(e){var t=e.children,n=e.border,a=e.className,c=e.disabled,r=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(h.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===c?"btn-primary-disabled":"",i?"info-tooltip":"",o?"info-tooltip-".concat(o):"",a,n?"btn-border":""].join(" "),children:[r,t?Object(h.jsx)("span",{children:t}):null]})};G.defaultProps={disabled:!1,border:!1};var X=G;function J(e){var t=e.value,n=e.onChange,a=e.onClick,c=e.label,r=e.min,i=e.max,o=((i||100)-(r||0))/100;return Object(h.jsxs)("div",{className:"editor-brush-slider",children:[Object(h.jsx)("span",{children:c}),Object(h.jsx)("input",{type:"range",step:o,min:r,max:i,value:t,onChange:function(e){e.preventDefault(),e.stopPropagation(),n(parseInt(e.currentTarget.value,10))},onClick:a})]})}var $=n(81),q=n(82),Q=n(83),ee=n(23),te=function(e){var t=e.width,n=e.value,c=e.chevronDirection,r=e.options,i=e.autoFocusAfterClose,o=e.onChange,s=e.disabled,l=Object(a.useRef)(null);return Object(h.jsxs)(ee.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(h.jsxs)(ee.g,{className:"select-trigger",style:{width:t},ref:l,onKeyDown:function(e){return e.preventDefault()},disabled:s,children:[Object(h.jsx)(ee.h,{}),Object(h.jsx)(ee.b,{children:"up"===c?Object(h.jsx)($.a,{}):Object(h.jsx)(q.a,{})})]}),Object(h.jsx)(ee.a,{className:"select-content",children:Object(h.jsx)(ee.i,{className:"select-viewport",children:r.map((function(e){return Object(h.jsxs)(ee.c,{value:e,className:"select-item",children:[Object(h.jsx)(ee.e,{children:e}),Object(h.jsx)(ee.d,{className:"select-item-indicator",children:Object(h.jsx)(Q.a,{})})]},e)}))})})]})};te.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0,disabled:!1};var ne=te,ae=["720","1080","2000","Original"];function ce(e){var t=e.originalHeight,n=e.originalWidth,c=e.onChange,r=Object(a.useState)("Original"),i=Object(d.a)(r,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 c=Math.ceil(t*a);return"".concat(e,"x").concat(c)}var r=Math.ceil(n*a);return"".concat(r,"x").concat(e)}),[n,t,l]),b=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(s(a[0]),c(parseInt(a[0],10))):(s(a[1]),c(parseInt(a[1],10)))},chevronDirection:"up"})}var re=n(52),ie=n.n(re),oe=n(84),se=n(4),le=["onFocus","onBlur"],ue=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(se.a)(e,le),r=Object(o.d)(Me),i=Object(d.a)(r,2),s=(i[0],i[1]);return Object(h.jsx)("input",Object(g.a)(Object(g.a)({},c),{},{ref:t,type:"text",onFocus:function(e){s((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(g.a)(Object(g.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()}}))})),de=["value","allowFloat","onValue"],be=c.a.forwardRef((function(e,t){var n=e.value,c=e.allowFloat,r=e.onValue,i=Object(se.a)(e,de),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(h.jsx)(ue,Object(g.a)(Object(g.a)({value:l,onInput:function(e){var t=e.target.value;c?(t=t.replace(/[^0-9.]/g,"").replace(/(\..*?)\..*/g,"$1"),null===r||void 0===r||r(t)):(t=t.replace(/\D/g,""),null===r||void 0===r||r(t)),u(t)},className:"number-input"},i),{},{ref:t}))}));be.defaultProps={allowFloat:!1};var je=be,fe=n(28),he=function(e){var t=e.content,n=e.children;return Object(h.jsx)(fe.d,{children:Object(h.jsxs)(fe.c,{children:[Object(h.jsx)(fe.e,{className:"tooltip-trigger",children:n}),Object(h.jsxs)(fe.b,{className:"tooltip-content",children:[t,Object(h.jsx)(fe.a,{className:"tooltip-arrow"})]})]})})};function pe(e){var t=e.title,n=e.titleSuffix,a=e.desc,c=e.input,r=e.optionDesc,i=e.className,o="h"===e.layout?"setting-block-content":"setting-block-content-v";return Object(h.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(h.jsxs)("div",{className:o,children:[Object(h.jsx)("div",{className:"setting-block-content-title",children:Object(h.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(h.jsx)(he,{content:Object(h.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(h.jsx)("span",{children:t})}):Object(h.jsx)("span",{children:t}),n]})}),c]}),r&&Object(h.jsx)("div",{className:"option-desc",children:r})]})}pe.defaultProps={layout:"h"};var Oe=pe;function ge(e){var t=e.title,n=e.allowFloat,c=e.desc,r=e.value,i=e.suffix,o=e.onValue,s=e.width,l=e.widthUnit,u=e.disable,d=Object(a.useRef)(null);return Object(oe.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(h.jsx)(Oe,{className:"sub-setting-block",title:t,desc:c,input:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(h.jsx)(je,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:r,disabled:u,onValue:o,ref:d}),i&&Object(h.jsx)("span",{children:i})]})})}ge.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var ve,me,xe=ge;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(ve||(ve={})),function(e){e.ddim="ddim",e.plms="plms"}(me||(me={}));var ye,we,Se=function(){var e=Object(o.d)($e),t=Object(d.a)(e,2),n=t[0],a=t[1];if(!(null===n||void 0===n?void 0:n.enabled))return Object(h.jsx)(h.Fragment,{});var c=function(e){a({hdStrategy:e})},r=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(h.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(ve.RESIZE)},children:"Resize"})," or ",Object(h.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(ve.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(h.jsx)(Oe,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(h.jsx)(ne,{width:80,value:n.hdStrategy,options:Object.values(ve),onChange:function(e){return c(e)}}),optionDesc:function(){switch(n.hdStrategy){case ve.ORIGINAL:return l();case ve.CROP:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(h.jsx)(xe,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(h.jsx)(xe,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:s})]});case ve.RESIZE:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(h.jsx)(xe,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:r})]});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",e.Mange="manga"}(we||(we={}));var ke,Ce=Object(o.b)({key:"maskState",default:void 0}),Me=Object(o.b)({key:"appState",default:{file:void 0,disableShortCuts:!1,isInpainting:!1,isDisableModelSwitch:!1,isInteractiveSeg:!1,isInteractiveSegRunning:!1,interactiveSegClicks:[]}}),Le=Object(o.b)({key:"promptState",default:""}),Ie=Object(o.b)({key:"negativePromptState",default:""}),Ne=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(Me).isInpainting},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{isInpainting:t}))}}),Ee=Object(o.c)({key:"fileState",get:function(e){return(0,e.get)(Me).file},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{file:t,interactiveSegClicks:[],isInteractiveSeg:!1,isInteractiveSegRunning:!1}))}}),ze=Object(o.c)({key:"isInteractiveSegState",get:function(e){return(0,e.get)(Me).isInteractiveSeg},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{isInteractiveSeg:t}))}}),Te=Object(o.c)({key:"isInteractiveSegRunningState",get:function(e){return(0,e.get)(Me).isInteractiveSegRunning},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{isInteractiveSegRunning:t}))}}),Re=Object(o.c)({key:"interactiveSegClicksState",get:function(e){return(0,e.get)(Me).interactiveSegClicks},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{interactiveSegClicks:t}))}}),De=Object(o.c)({key:"isDisableModelSwitchState",get:function(e){return(0,e.get)(Me).isDisableModelSwitch},set:function(e,t){var n=e.get,a=e.set,c=n(Me);a(Me,Object(g.a)(Object(g.a)({},c),{},{isDisableModelSwitch:t}))}}),Pe=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),Fe=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(Pe).x},set:function(e,t){var n=e.get,a=e.set,c=n(Pe);a(Pe,Object(g.a)(Object(g.a)({},c),{},{x:t}))}}),He=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(Pe).y},set:function(e,t){var n=e.get,a=e.set,c=n(Pe);a(Pe,Object(g.a)(Object(g.a)({},c),{},{y:t}))}}),Ae=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(Pe).height},set:function(e,t){var n=e.get,a=e.set,c=n(Pe);a(Pe,Object(g.a)(Object(g.a)({},c),{},{height:t}))}}),Ze=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(Pe).width},set:function(e,t){var n=e.get,a=e.set,c=n(Pe);a(Pe,Object(g.a)(Object(g.a)({},c),{},{width:t}))}}),Ve=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),We=Object(o.b)({key:"shortcutsState",default:!1});!function(e){e.INPAINT_NS="INPAINT_NS",e.INPAINT_TELEA="INPAINT_TELEA"}(ke||(ke={}));var Be,_e,Ue=(ye={},Object(L.a)(ye,we.LAMA,{hdStrategy:ve.CROP,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:1280,hdStrategyCropMargin:196,enabled:!0}),Object(L.a)(ye,we.LDM,{hdStrategy:ve.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(L.a)(ye,we.ZITS,{hdStrategy:ve.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(L.a)(ye,we.MAT,{hdStrategy:ve.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(L.a)(ye,we.FCF,{hdStrategy:ve.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(L.a)(ye,we.SD15,{hdStrategy:ve.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(L.a)(ye,we.Mange,{hdStrategy:ve.CROP,hdStrategyResizeLimit:1280,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:196,enabled:!0}),Object(L.a)(ye,we.CV2,{hdStrategy:ve.RESIZE,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),ye);!function(e){e.ddim="ddim",e.pndm="pndm",e.klms="k_lms",e.kEuler="k_euler",e.kEulerA="k_euler_a"}(Be||(Be={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(_e||(_e={}));var Ke,Ye={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:we.LAMA,hdSettings:Ue,ldmSteps:25,ldmSampler:me.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:_e.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:Be.pndm,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1,sdMatchHistograms:!1,cv2Radius:5,cv2Flag:ke.INPAINT_NS},Ge="settingsState4",Xe=Object(o.b)({key:Ge,default:Ye,effects:[(Ke=Ge,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(Ke);if(null!=a){var c=JSON.parse(a);c.show=!1,t(ie.a.merge(ie.a.cloneDeep(Ye),c))}n((function(e,t,n){return n?localStorage.removeItem(Ke):localStorage.setItem(Ke,JSON.stringify(e))}))})]}),Je=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(Xe).sdSeed},set:function(e,t){var n=e.get,a=e.set,c=n(Xe);a(Xe,Object(g.a)(Object(g.a)({},c),{},{sdSeed:t}))}}),$e=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(Xe);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,c=n(Xe),r=c.hdSettings[c.model],i=Object(g.a)(Object(g.a)({},r),t);a(Xe,Object(g.a)(Object(g.a)({},c),{},{hdSettings:Object(g.a)(Object(g.a)({},c.hdSettings),{},Object(L.a)({},c.model,i))}))}}),qe=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(Xe).model===we.SD15}}),Qe=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(Xe),a=t(qe);return n.runInpaintingManually||a}}),et=n(58),tt=function(e,t,n,a){var c=Object(o.e)(Me);return Object(et.a)(e,t,Object(g.a)(Object(g.a)({},n),{},{enabled:!c.disableShortCuts}),a)},nt={capture:!0,passive:!1},at=function(e,t,n,a,c,r){if(e!==n&&t===a){if(e<0)return[0,a];if(e+t>r)return[r-a,a]}else{if(tr)return[e,r-e]}return[e,t]},ct=function(e){var t=e.minHeight,n=e.minWidth,c=e.maxHeight,r=e.maxWidth,i=e.scale,s=Object(o.d)(Fe),l=Object(d.a)(s,2),u=l[0],b=l[1],j=Object(o.d)(He),f=Object(d.a)(j,2),p=f[0],O=f[1],g=Object(o.d)(Ae),v=Object(d.a)(g,2),m=v[0],x=v[1],y=Object(o.d)(Ze),w=Object(d.a)(y,2),S=w[0],k=w[1],C=Object(o.e)(Ne),M=Object(a.useState)(!1),L=Object(d.a)(M,2),I=L[0],N=L[1],E=Object(a.useState)(!1),z=Object(d.a)(E,2),T=z[0],R=z[1];Object(a.useEffect)((function(){b(Math.round((r-512)/2)),O(Math.round((c-512)/2))}),[c,r,t,n]);var D=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),P=Object(d.a)(D,2),F=P[0],H=P[1],A=function(){console.log("focus")},Z=function(e,t){return at(e,t,u,S,n,r)},V=function(e,n){return at(e,n,p,m,t,c)},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-F.startResizeY)/i),c=Math.round((t-F.startResizeX)/i),r=function(){var e=F.initHeight-a,t=F.initY+a,n=V(t,e),c=Object(d.a)(n,2),r=c[0],i=c[1];x(i),O(r)},o=function(){var e=F.initHeight+a,t=V(F.initY,e),n=Object(d.a)(t,2),c=n[0],r=n[1];x(r),O(c)},s=function(){var e=F.initWidth-c,t=F.initX+c,n=Z(t,e),a=Object(d.a)(n,2),r=a[0],i=a[1];k(i),b(r)},l=function(){var e=F.initWidth+c,t=Z(F.initX,e),n=Object(d.a)(t,2),a=n[0],r=n[1];k(r),b(a)};if(I)switch(F.ord){case"topleft":r(),s();break;case"topright":r(),l();break;case"bottomleft":o(),s();break;case"bottomright":o(),l();break;case"top":r();break;case"right":l();break;case"bottom":o();break;case"left":s()}if(T){var u=F.initX+c,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){I&&N(!1),T&&R(!1)};Object(a.useEffect)((function(){if(I||T)return document.addEventListener("pointermove",W,nt),document.addEventListener("pointerup",B,nt),document.addEventListener("pointercancel",B,nt),function(){document.removeEventListener("pointermove",W,nt),document.removeEventListener("pointerup",B,nt),document.removeEventListener("pointercancel",B,nt)}}),[I,T,S,m,F]);var _=function(e){var t=e.target.dataset.ord;t&&(N(!0),H({initX:u,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},U=function(e){R(!0),H({initX:u,initY:p,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(h.jsx)("div",{className:"croper-wrapper",children:Object(h.jsxs)("div",{className:"croper",style:{height:m,width:S,left:u,top:p},children:[Object(h.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(h.jsx)("div",{className:"info-bar",onPointerDown:U,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(h.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(h.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:_,children:[Object(h.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(h.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},rt=n(55),it="prompt",ot="custom_mask",st=Object(rt.a)(),lt=function(){var e=Object(a.useState)(window.innerWidth),t=Object(d.a)(e,2),n=t[0],c=t[1],r=Object(a.useCallback)((function(){c(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",r),function(){window.removeEventListener("resize",r)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function ut(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(d.a)(n,2),r=c[0],i=c[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),s=Object(d.a)(o,1)[0],b=lt();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 f(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 g.apply(this,arguments)}function g(){return(g=Object(u.a)(l.a.mark((function e(t){var n,a,c,r,i;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],c=0;c0)){e.next=23;break}if(!(null===(r=a.shift())||void 0===r?void 0:r.isFile)){e.next=12;break}return e.next=8,f(r);case 8:i=e.sent,n.push(i),e.next=21;break;case 12:if(!(null===r||void 0===r?void 0:r.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=v.a,e.next=18,m(r.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(v.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(h.jsx)("label",{htmlFor:s,className:"file-select-label",children:Object(h.jsxs)("div",{className:["file-select-container",r?"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(h.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(h.jsx)("p",{className:"file-select-message",children:"desktop"===b?"Click here or drag an image file":"Tap here to load your picture"})]})})}var dt=function(e){var t=e.x,n=e.y,a=e.positive?"click-item-positive":"click-item-negative";return Object(h.jsx)("div",{className:"click-item ".concat(a),style:{left:t,top:n}})},bt=function(){var e=Object(o.e)(Re);return Object(h.jsx)("div",{className:"interactive-seg-wrapper",children:e.map((function(e){return Object(h.jsx)(dt,{x:e[0],y:e[1],positive:1===e[2]},e[3])}))})},jt=function(e){var t=e.onCancelClick,n=e.onAcceptClick,a=Object(o.d)(ze),c=Object(d.a)(a,2),r=c[0],i=c[1],s=Object(o.d)(Te),l=Object(d.a)(s,2),u=(l[0],l[1]),b=Object(o.d)(Re),j=Object(d.a)(b,2),f=(j[0],j[1]),p=function(){i(!1),u(!1),f([])};return Object(h.jsx)("div",{className:"interactive-seg-confirm-actions",style:{visibility:r?"visible":"hidden"},children:Object(h.jsxs)("div",{className:"action-buttons",children:[Object(h.jsx)(X,{onClick:function(){p(),t()},children:"Cancel"}),Object(h.jsx)(X,{border:!0,onClick:function(){p(),n()},children:"Accept"})]})})},ft=n(85),ht=n(27),pt=c.a.forwardRef((function(e,t){var n=e.show,a=e.children,c=e.onClose,r=e.className,i=e.title,s=e.showCloseIcon,l=Object(o.d)(Me),u=Object(d.a)(l,2),b=(u[0],u[1]);return Object(h.jsx)(ht.d,{open:n,onOpenChange:function(e){e||(null===c||void 0===c||c(),b((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!1})})))},children:Object(h.jsxs)(ht.c,{children:[Object(h.jsx)(ht.b,{className:"modal-mask"}),Object(h.jsxs)(ht.a,{ref:t,className:"modal ".concat(r),children:[Object(h.jsxs)("div",{className:"modal-header",children:[Object(h.jsx)(ht.e,{children:i}),s?Object(h.jsx)(X,{icon:Object(h.jsx)(ft.a,{}),onClick:c}):Object(h.jsx)(h.Fragment,{})]}),a]})]})})}));pt.defaultProps={showCloseIcon:!0};var Ot=pt,gt=function(e){var t=e.show,n=e.onClose,a=e.onCleanClick,c=e.onReplaceClick;return Object(h.jsxs)(Ot,{onClose:n,title:"Mask exists",className:"modal-setting",show:t,showCloseIcon:!0,children:[Object(h.jsx)("h4",{style:{lineHeight:"24px"},children:"Do you want to remove it or create a new one?"}),Object(h.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(h.jsx)(X,{onClick:function(){n(),a()},children:"Remove"}),Object(h.jsx)(X,{onClick:c,border:!0,children:"Create a new one"})]})]})},vt="#ffcc00bb";function mt(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vt;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 xt(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function yt(){var e=Object(o.d)(Ee),t=Object(d.a)(e,2),n=t[0],c=t[1],r=Object(o.e)(Le),i=Object(o.e)(Ie),s=Object(o.e)(Xe),b=Object(o.d)(Je),j=Object(d.a)(b,2),f=(j[0],j[1]),p=Object(o.e)(Pe),O=Object(o.d)(Ve),g=Object(d.a)(O,2),L=(g[0],g[1]),I=Object(o.d)(Ne),E=Object(d.a)(I,2),P=E[0],F=E[1],H=Object(o.e)(Qe),Z=Object(o.e)(qe),V=Object(o.d)(ze),B=Object(d.a)(V,2),_=B[0],U=B[1],Y=Object(o.d)(Te),G=Object(d.a)(Y,2),$=G[0],q=G[1],Q=Object(a.useState)(!1),ee=Object(d.a)(Q,2),te=ee[0],ne=ee[1],ae=Object(a.useState)(null),re=Object(d.a)(ae,2),ie=re[0],oe=re[1],se=Object(a.useState)(null),le=Object(d.a)(se,2),ue=le[0],de=le[1],be=Object(a.useState)(null),je=Object(d.a)(be,2),fe=je[0],he=je[1],pe=Object(o.d)(Re),Oe=Object(d.a)(pe,2),ge=Oe[0],ve=Oe[1],me=Object(a.useState)(40),xe=Object(d.a)(me,2),ye=xe[0],we=xe[1],Se=function(e){var t=Object(a.useState)(new Image),n=Object(d.a)(t,1)[0],c=Object(a.useState)(!1),r=Object(d.a)(c,2),i=r[0],o=r[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),ke=Object(d.a)(Se,2),Ce=ke[0],Me=ke[1],De=Object(a.useState)([]),Fe=Object(d.a)(De,2),He=Fe[0],Ae=Fe[1],Ze=Object(a.useState)(),We=Object(d.a)(Ze,2),Be=We[0],_e=We[1],Ue=Object(a.useState)((function(){return document.createElement("canvas")})),Ke=Object(d.a)(Ue,1)[0],Ye=Object(a.useState)([]),Ge=Object(d.a)(Ye,2),$e=Ge[0],et=Ge[1],nt=Object(a.useState)([]),at=Object(d.a)(nt,2),rt=at[0],lt=at[1],dt=Object(a.useState)([]),ft=Object(d.a)(dt,2),ht=ft[0],pt=ft[1],Ot=Object(a.useState)({x:-1,y:-1}),vt=Object(d.a)(Ot,2),yt=vt[0],wt=yt.x,St=yt.y,kt=vt[1],Ct=Object(a.useState)(!1),Mt=Object(d.a)(Ct,2),Lt=Mt[0],It=Mt[1],Nt=Object(a.useState)(!1),Et=Object(d.a)(Nt,2),zt=Et[0],Tt=Et[1],Rt=Object(a.useState)(!1),Dt=Object(d.a)(Rt,2),Pt=Dt[0],Ft=Dt[1],Ht=Object(a.useState)(!1),At=Object(d.a)(Ht,2),Zt=At[0],Vt=At[1],Wt=Object(a.useState)({x:-1,y:-1,brushSize:20}),Bt=Object(d.a)(Wt,2),_t=Bt[0],Ut=Bt[1],Kt=Object(a.useState)(!1),Yt=Object(d.a)(Kt,2),Gt=Yt[0],Xt=Yt[1],Jt=Object(a.useState)(1),$t=Object(d.a)(Jt,2),qt=$t[0],Qt=$t[1],en=Object(a.useState)(!1),tn=Object(d.a)(en,2),nn=tn[0],an=tn[1],cn=Object(a.useState)(1),rn=Object(d.a)(cn,2),on=rn[0],sn=rn[1],ln=Object(a.useState)(1080),un=Object(d.a)(ln,2),dn=un[0],bn=un[1],jn=Object(k.a)(),fn=jn.width/2,hn=jn.height/2,pn=Object(a.useRef)(),On=Object(a.useState)(!1),gn=Object(d.a)(On,2),vn=gn[0],mn=gn[1],xn=Object(a.useState)(!1),yn=Object(d.a)(xn,2),wn=yn[0],Sn=yn[1],kn=Object(a.useState)(!1),Cn=Object(d.a)(kn,2),Mn=Cn[0],Ln=Cn[1],In=Object(a.useState)(0),Nn=Object(d.a)(In,2),En=Nn[0],zn=Nn[1],Tn=Object(a.useState)([]),Rn=Object(d.a)(Tn,2),Dn=Rn[0],Pn=Rn[1],Fn=Object(a.useState)([]),Hn=Object(d.a)(Fn,2),An=Hn[0],Zn=Hn[1],Vn=Object(a.useState)([]),Wn=Object(d.a)(Vn,2),Bn=Wn[0],_n=Wn[1],Un=Object(a.useCallback)((function(e,t){Be&&(Be.clearRect(0,0,Be.canvas.width,Be.canvas.height),Be.drawImage(e,0,0,Ce.naturalWidth,Ce.naturalHeight),_&&null!==ue&&Be.drawImage(ue,0,0,Ce.naturalWidth,Ce.naturalHeight),_||null===ie||Be.drawImage(ie,0,0,Ce.naturalWidth,Ce.naturalHeight),mt(Be,t))}),[Be,Ce,_,ue,ie]),Kn=Object(a.useCallback)((function(e,t){if(!(null===Be||void 0===Be?void 0:Be.canvas.width)||!(null===Be||void 0===Be?void 0:Be.canvas.height))throw new Error("canvas has invalid size");Ke.width=null===Be||void 0===Be?void 0:Be.canvas.width,Ke.height=null===Be||void 0===Be?void 0:Be.canvas.height;var n=Ke.getContext("2d");if(!n)throw new Error("could not retrieve mask canvas");void 0!==t&&null!==t&&n.drawImage(t,0,0,Ce.naturalWidth,Ce.naturalHeight),e.forEach((function(e){mt(n,e,"white")}))}),[Be,Ke]),Yn=Object(a.useCallback)((function(){return 0!==ht.length}),[ht]),Gn=Object(a.useCallback)((function(e){0===He.length?Un(Ce,e):Un(He[He.length-1],e)}),[Ce,He,Un]),Xn=Object(a.useCallback)(function(){var e=Object(u.a)(l.a.mark((function e(t,a,c){var o,u,d,b,j,h,O,g,m,x,y,w,S,k,C;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(o=void 0!==a&&null!==a,u=void 0!==c&&null!==c,console.log("runInpainting"),console.log({useCustomMask:o,useMaskImage:u}),d=[],!0!==t){e.next=13;break}if(0!==rt.length){e.next=10;break}return e.abrupt("return");case 10:d=rt,e.next=18;break;case 13:if(o){e.next=18;break}if(Yn()||u){e.next=16;break}return e.abrupt("return");case 16:lt(ht),d=ht;case 18:if(b=[].concat(Object(v.a)($e),[d]),pt([]),Sn(!1),F(!0),s.graduallyInpainting?Kn([d],c):Kn(b),j=n,!0!==s.graduallyInpainting){e.next=39;break}if(!0!==t){e.next=33;break}if(!(He.length>1)){e.next=31;break}return h=He[He.length-2],e.next=30,R(h.currentSrc,n.name,n.type);case 30:j=e.sent;case 31:e.next=39;break;case 33:if(!(He.length>0)){e.next=39;break}return console.info("gradually inpainting on last result"),O=He[He.length-1],e.next=38,R(O.currentSrc,n.name,n.type);case 38:j=e.sent;case 39:return g=s.sdSeedFixed?s.sdSeed:-1,console.log({useCustomMask:o}),e.prev=41,e.next=44,W(j,s,p,r,i,dn.toString(),g,o?void 0:Ke.toDataURL(),o?a:void 0);case 44:if(m=e.sent){e.next=47;break}throw new Error("Something went wrong on server side.");case 47:return x=m.blob,(y=m.seed)&&!s.sdSeedFixed&&f(parseInt(y,10)),w=new Image,e.next=52,N(w,x);case 52:!0===t?(S=He.slice(0,-1),k=[].concat(Object(v.a)(S),[w]),Ae(k)):(C=[].concat(Object(v.a)(He),[w]),Ae(C)),Un(w,[]),et(b),Qn(),e.next=62;break;case 58:e.prev=58,e.t0=e.catch(41),L({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),Gn([]);case 62:F(!1),he(c),de(null),oe(null);case 66:case"end":return e.stop()}}),e,null,[[41,58]])})));return function(t,n,a){return e.apply(this,arguments)}}(),[$e,ht,Ke,s.graduallyInpainting,s,p,dn,r,i,Gn,Yn,Kn]);Object(a.useEffect)((function(){return st.on(it,(function(){Yn()||ie?Xn(!1,void 0,ie):0!==rt.length?Xn(!0,void 0,fe):fe?Xn(!1,void 0,fe):L({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){st.off(it)}}),[Yn,Xn,r,ie,fe]),Object(a.useEffect)((function(){return st.on(ot,(function(e){Xn(!1,e.mask)})),function(){st.off(ot)}}),[Xn]);var Jn=function(){return 0!==He.length},$n=function(e){return"Control"===e.key||"Meta"===e.key};Object(C.a)($n,(function(){Mn&&(P||(Ln(!1),H||Xn()))}),{event:"keyup"},[P,Mn,Yn]),Object(C.a)($n,(function(){P||Ln(!0)}),{event:"keydown"},[P]),Object(a.useEffect)((function(){if(Me){var e=jn.width/Ce.naturalWidth,t=(jn.height-200)/Ce.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),sn(n),Qt(n),(null===Be||void 0===Be?void 0:Be.canvas)&&(Be.canvas.width=Ce.naturalWidth,Be.canvas.height=Ce.naturalHeight,Gn([])),!vn){var a;null===(a=pn.current)||void 0===a||a.centerView(n,1),mn(!0);var c=Math.max(Ce.width,Ce.height);bn(c)}}}),[null===Be||void 0===Be?void 0:Be.canvas,pn,Ce,Me,jn,vn,Gn]);var qn=Object(a.useCallback)((function(){if(on&&Ce&&jn){var e=pn.current;if(e){var t=(jn.width-Ce.width*on)/2,n=(jn.height-Ce.height*on)/2;e.setTransform(t,n,on,200,"easeOutQuad"),e.state.scale=on,Qt(on),an(!1)}}}),[pn,jn,Ce,Ce.width,jn.height,on]),Qn=function(){Zn([]),_n([]),Pn([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){qn()})),function(){window.removeEventListener("resize",(function(){qn()}))}}),[jn,qn]),Object(a.useEffect)((function(){return window.addEventListener("blur",(function(){Vt(!1)})),function(){window.removeEventListener("blur",(function(){Vt(!1)}))}}),[]);var ea=Object(a.useCallback)((function(){U(!1),q(!1),ve([]),de(null)}),[]);Object(C.a)("Escape",(function(){P||(_?ea():wn||Mn?(Sn(!1),pt([]),Gn([])):qn())}),{event:"keydown"},[wn,P,Mn,_,ea,qn,Gn]);var ta=function(e){if(Zt){var t=_t.x,n=_t.brushSize+(wt-t);n<=200&&n>=10&&we(n)}else if(!_&&!Pt&&wn&&0!==ht.length){var a=Object(v.a)(ht);a[a.length-1].pts.push(xt(e)),pt(a),Gn(a)}},na=function(){var e=Object(u.a)(l.a.mark((function e(t){var a,c,r,i,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:if(q(!0),a=n,!(He.length>0)){e.next=9;break}return c=He[He.length-1],e.next=8,R(c.currentSrc,n.name,n.type);case 8:a=e.sent;case 9:return null,e.prev=10,e.next=13,K(a,null,t);case 13:if(r=e.sent){e.next=16;break}throw new Error("Something went wrong on server side.");case 16:i=r.blob,(o=new Image).onload=function(){de(o)},o.src=i,e.next=25;break;case 22:e.prev=22,e.t0=e.catch(10),L({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3});case 25:q(!1);case 26:case"end":return e.stop()}}),e,null,[[10,22]])})));return function(t){return e.apply(this,arguments)}}(),aa=function(e){if(_){var t=xt(e),n=Object(v.a)(ge);z(e)?n.push([t.x,t.y,0,n.length]):n.push([t.x,t.y,1,n.length]),na(n),ve(n)}},ca=function(e){if(!_&&(!Zt&&!Pt&&Ce.src&&(null===Be||void 0===Be?void 0:Be.canvas)&&!P&&!z(e)))if(T(e))Ft(!0);else if(!(Z&&s.showCroper&&(t=xt(e),t.xp.x+p.width||t.y>p.y+p.height))){var t;Sn(!0);var n=[];(Mn||H)&&(n=Object(v.a)(ht)),n.push({size:ye,pts:[xt(e)]}),pt(n),Gn(n)}},ra=Object(a.useCallback)((function(){if(0!==ht.length){lt([]);var e=ht.pop(),t=[].concat(Object(v.a)(An),[e]);Zn(t);var n=Object(v.a)(ht);pt(n),Gn(n)}}),[ht,An,Gn]),ia=Object(a.useCallback)((function(){if(He.length){var e=$e.pop();_n([].concat(Object(v.a)(Bn),[e])),Zn([]),et(Object(v.a)($e)),pt([]),Sn(!1);var t=He.pop();Pn([].concat(Object(v.a)(Dn),[t]));var n=Object(v.a)(He);Ae(n),0===n.length?Un(Ce,[]):Un(n[n.length-1],[])}}),[Un,He,Dn,Bn,$e,Ce]),oa=function(){H&&0!==ht.length?ra():ia()};Object(C.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)}),oa,void 0,[ra,ia,Z]);var sa=Object(a.useCallback)((function(){if(0!==An.length){var e=An.pop();Zn(Object(v.a)(An));var t=[].concat(Object(v.a)(ht),[e]);pt(t),Gn(t)}}),[ht,An,Gn]),la=Object(a.useCallback)((function(){if(0!==Dn.length){var e=Bn.pop();_n(Object(v.a)(Bn)),et([].concat(Object(v.a)($e),[e])),pt([]),Sn(!1);var t=Dn.pop(),n=[].concat(Object(v.a)(He),[t]);Ae(n),Un(n[n.length-1],[])}}),[Un,He,Dn,Bn,$e,Ce]),ua=function(){H&&0!==An.length?sa():la()};Object(C.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)}),ua,void 0,[sa,la,Z]);Object(M.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Jn()&&Xt((function(){return window.setTimeout((function(){zn(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Jn()&&(zn(0),window.setTimeout((function(){Xt(!1)}),350))}));var da=function(e){e===Lt||Pt||It(e)},ba=Object(a.useCallback)((function(){return Pt?"grab":Lt?"none":void 0}),[Lt,Pt]);tt("i",(function(){!_&&Me&&(U(!0),null!==ie&&ne(!0))}),{},[_,ie,Me]),tt("[",(function(){we((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),tt("]",(function(){we((function(e){return e+10}))})),tt("shift+r",(function(){H&&Yn()&&Xn()}),{},[H,Xn,Yn]),tt("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,D();case 2:if(!(e.sent&&He.length>0)){e.next=8;break}if(!(null===Be||void 0===Be?void 0:Be.canvas)){e.next=8;break}return e.next=7,A(null===Be||void 0===Be?void 0:Be.canvas);case 7:L({open:!0,desc:"Copy inpainting result to clipboard",state:"success",duration:3e3});case 8:case"end":return e.stop()}}),e)}))),{},[He,Be]),Object(M.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),It(!1),Ft(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),It(!0),Ft(!1)})),Object(M.a)("Alt",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Vt(!0),Ut({x:wt,y:St,brushSize:ye})}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Vt(!1)}));var ja=function(e,t){var n=function(){var e,t,n=on;return void 0!==(null===(e=pn.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=pn.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(ye*n,"px"),height:"".concat(ye*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(h.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;kt({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(T(e)&&Ft(!1),_)||(Pt||Ce.src&&(null===Be||void 0===Be?void 0:Be.canvas)&&(P||wn&&(Mn||H?Sn(!1):Xn())))},children:[Object(h.jsx)(jt,{onAcceptClick:function(){oe(ue),de(null),!H&&ue&&Xn(!1,void 0,ue)},onCancelClick:ea}),void 0===n?Object(h.jsx)("div",{className:"landing-file-selector",children:Object(h.jsx)(ut,{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:c(t);case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()})}):Object(h.jsx)(S.b,{ref:function(e){e&&(pn.current=e)},panning:{disabled:!Pt,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:on,minScale:.6*on,onPanning:function(e){nn||an(!0)},onZoom:function(e){Qt(e.state.scale)},children:Object(h.jsxs)(S.a,{contentClass:P||$?"editor-canvas-loading":"",contentStyle:{visibility:vn?"visible":"hidden"},children:[Object(h.jsxs)("div",{className:"editor-canvas-container",children:[Object(h.jsx)("canvas",{className:"editor-canvas",style:{cursor:ba(),clipPath:"inset(0 ".concat(En,"% 0 0)"),transition:"clip-path 300ms cubic-bezier(0.4, 0, 0.2, 1)"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){da(!0),Tt(!1)},onFocus:function(){return da(!0)},onMouseLeave:function(){return da(!1)},onMouseDown:ca,onMouseUp:aa,onMouseMove:ta,ref:function(e){if(e&&!Be){var t=e.getContext("2d");t&&_e(t)}}}),Object(h.jsxs)("div",{className:"original-image-container",style:{width:"".concat(Ce.naturalWidth,"px"),height:"".concat(Ce.naturalHeight,"px")},children:[Gt&&Object(h.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(En,"%")}}),Object(h.jsx)("img",{className:"original-image",src:Ce.src,alt:"original",style:{width:"".concat(Ce.naturalWidth,"px"),height:"".concat(Ce.naturalHeight,"px")}})]})]}),Z&&s.showCroper?Object(h.jsx)(ct,{maxHeight:Ce.naturalHeight,maxWidth:Ce.naturalWidth,minHeight:Math.min(256,Ce.naturalHeight),minWidth:Math.min(256,Ce.naturalWidth),scale:qt}):Object(h.jsx)(h.Fragment,{}),_?Object(h.jsx)(bt,{}):Object(h.jsx)(h.Fragment,{})]})}),Lt&&!P&&!Pt&&(_?Object(h.jsx)("div",{className:"interactive-seg-cursor",style:{left:"".concat(wt,"px"),top:"".concat(St,"px")},children:Object(h.jsx)(m.a,{})}):Object(h.jsx)("div",{className:"brush-shape",style:ja(Zt?_t.x:wt,Zt?_t.y:St)})),zt&&Object(h.jsx)("div",{className:"brush-shape",style:ja(fn,hn)}),Object(h.jsxs)("div",{className:"editor-toolkit-panel",children:[Z||void 0===n?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(ce,{onChange:function(e){bn(e)},originalWidth:Ce.naturalWidth,originalHeight:Ce.naturalHeight}),Object(h.jsx)(J,{label:"Brush",min:10,max:200,value:ye,onChange:function(e){we(e),zt||(Tt(!0),window.setTimeout((function(){Tt(!1)}),1e4))},onClick:function(){return Tt(!1)}}),Object(h.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(h.jsx)(X,{toolTip:"Interactive Segmentation",tooltipPosition:"top",icon:Object(h.jsx)(m.a,{}),disabled:_||P||!Me,onClick:function(){U(!0),null!==ie&&ne(!0)}}),Object(h.jsx)(X,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(h.jsx)(x.a,{}),disabled:qt===on&&!1===nn,onClick:qn}),Object(h.jsx)(X,{toolTip:"Undo",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.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:oa,disabled:function(){if(_)return!0;if(P)return!0;if(He.length>0)return!1;if(H){if(0===ht.length)return!0}else if(0===He.length)return!0;return!1}()}),Object(h.jsx)(X,{toolTip:"Redo",tooltipPosition:"top",icon:Object(h.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(h.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:ua,disabled:function(){if(_)return!0;if(P)return!0;if(Dn.length>0)return!1;if(H){if(0===An.length)return!0}else if(0===Dn.length)return!0;return!1}()}),Object(h.jsx)(X,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(h.jsx)(y.a,{}),className:Gt?"eyeicon-active":"",onDown:function(e){e.preventDefault(),Xt((function(){return window.setTimeout((function(){zn(100)}),10),!0}))},onUp:function(){zn(0),window.setTimeout((function(){Xt(!1)}),300)},disabled:0===He.length}),Object(h.jsx)(X,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(h.jsx)(w.a,{}),disabled:!He.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)}(He[He.length-1].currentSrc,e),s.downloadMask){var t=n.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");t=t.replace(/\.[^/.]+$/,".jpg"),Kn($e);var a=document.createElement("a");a.download=t,a.href=Ke.toDataURL("image/jpeg"),a.click()}}}}),s.runInpaintingManually&&!Z&&Object(h.jsx)(X,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(h.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.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:P||_||!Yn()&&null===ie,onClick:function(){Xn(!1,void 0,ie)}})]})]}),Object(h.jsx)(gt,{show:te,onClose:function(){ea(),ne(!1)},onCleanClick:function(){ea(),oe(null)},onReplaceClick:function(){ne(!1),U(!0)}})]})}function wt(e){var t=e.content,n=e.keys;return Object(h.jsxs)("div",{className:"shortcut-option",children:[Object(h.jsx)("div",{className:"shortcut-description",children:t}),Object(h.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(h.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var St=/macintosh|mac os x/i.test(navigator.userAgent),kt=(/windows|win32/i.test(navigator.userAgent),St?"Cmd":"Ctrl");function Ct(){var e=Object(o.d)(We),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(Ot,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(h.jsxs)("div",{className:"shortcut-options",children:[Object(h.jsx)(wt,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(kt)]}),Object(h.jsx)(wt,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(h.jsx)(wt,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(h.jsx)(wt,{content:"Interactive Segmentation",keys:["I"]}),Object(h.jsx)(wt,{content:"Undo Inpainting",keys:[kt,"Z"]}),Object(h.jsx)(wt,{content:"Redo Inpainting",keys:[kt,"Shift","Z"]}),Object(h.jsx)(wt,{content:"View Original Image",keys:["Hold Tab"]}),Object(h.jsx)(wt,{content:"Pan",keys:["Space + Drag"]}),Object(h.jsx)(wt,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(h.jsx)(wt,{content:"Decrease Brush Size",keys:["["]}),Object(h.jsx)(wt,{content:"Increase Brush Size",keys:["]"]}),Object(h.jsx)(wt,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(h.jsx)(wt,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(h.jsx)(wt,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var Mt=n(53),Lt=["className"],It=["className"],Nt=c.a.forwardRef((function(e,t){var n=e.className,a=Object(se.a)(e,Lt);return Object(h.jsx)(Mt.a,Object(g.a)(Object(g.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),Et=c.a.forwardRef((function(e,t){var n=e.className,a=Object(se.a)(e,It);return Object(h.jsx)(Mt.b,Object(g.a)(Object(g.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),zt=function(){var e=Object(o.d)(Xe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(Oe,{title:"Manual Inpainting Mode",input:Object(h.jsx)(Nt,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{runInpaintingManually:e})}))},children:Object(h.jsx)(Et,{})})})};var Tt=function(){var e=Object(o.d)(Xe),t=Object(d.a)(e,2),n=t[0],a=t[1],c=Object(o.e)(De),r=function(e,t,n){return Object(h.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(h.jsx)(he,{content:n,children:Object(h.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(h.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(h.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"})})})})})},i=function(){return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(xe,{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);a((function(e){return Object(g.a)(Object(g.a)({},e),{},{ldmSteps:t})}))}}),Object(h.jsx)(Oe,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(ne,{width:80,value:n.ldmSampler,options:Object.values(me),onChange:function(e){return t=e,void a((function(e){return Object(g.a)(Object(g.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(h.jsx)(Oe,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case we.LAMA:return r(0,0,"https://github.com/saic-mdal/lama");case we.LDM:return r(0,0,"https://github.com/CompVis/latent-diffusion");case we.ZITS:return r(0,0,"https://github.com/DQiaole/ZITS_inpainting");case we.MAT:return r(0,0,"https://github.com/fenglinglwb/MAT");case we.FCF:return r(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case we.SD15:return r(0,0,"https://github.com/CompVis/stable-diffusion");case we.Mange:return r(0,0,"https://github.com/msxie92/MangaInpainting");case we.CV2:return r(0,0,"https://docs.opencv.org/4.6.0/df/d3d/tutorial_py_inpainting.html");default:return Object(h.jsx)(h.Fragment,{})}}(),input:Object(h.jsx)(ne,{width:80,value:n.model,options:Object.values(we),onChange:function(e){return t=e,void a((function(e){return Object(g.a)(Object(g.a)({},e),{},{model:t})}));var t},disabled:c}),optionDesc:function(){switch(n.model){case we.LAMA:return;case we.LDM:return i();case we.ZITS:return Object(h.jsx)("div",{children:Object(h.jsx)(Oe,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(h.jsx)(Nt,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{zitsWireframe:e})}))},children:Object(h.jsx)(Et,{})})})});case we.MAT:return;case we.FCF:return Object(h.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 we.SD15:case we.Mange:return;case we.CV2:return Object(h.jsxs)(h.Fragment,{children:[Object(h.jsx)(xe,{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);a((function(e){return Object(g.a)(Object(g.a)({},e),{},{cv2Radius:t})}))}}),Object(h.jsx)(Oe,{className:"sub-setting-block",title:"Flag",desc:"Inpainting method",input:Object(h.jsx)(ne,{width:140,value:n.cv2Flag,options:Object.values(ke),onChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{cv2Flag:e})}))}})})]});default:return Object(h.jsx)(h.Fragment,{})}}()})},Rt=function(){var e=Object(o.d)(Xe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)(Oe,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(h.jsx)(Nt,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(g.a)(Object(g.a)({},t),{},{downloadMask:e})}))},children:Object(h.jsx)(Et,{})})})};function Dt(e){var t=e.onClose,n=Object(o.d)(Xe),a=Object(d.a)(n,2),c=a[0],r=a[1],i=Object(o.e)(qe);return tt("s",(function(){r((function(e){return Object(g.a)(Object(g.a)({},e),{},{show:!e.show})}))}),{},[]),Object(h.jsxs)(Ot,{onClose:function(){r((function(e){return Object(g.a)(Object(g.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:c.show,children:[i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(zt,{}),Object(h.jsx)(Rt,{}),Object(h.jsx)(Tt,{}),i?Object(h.jsx)(h.Fragment,{}):Object(h.jsx)(Se,{})]})}var Pt=n(37),Ft=n(90),Ht=["state","desc"],At=function(){return Object(h.jsx)("span",{className:"loading-icon",children:Object(h.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(h.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(h.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(h.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(h.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(h.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(h.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(h.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(h.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},Zt=a.forwardRef((function(e,t){var n=e.state,a=e.desc,c=Object(se.a)(e,Ht);return Object(h.jsxs)(Pt.b,{children:[Object(h.jsxs)(Pt.c,Object(g.a)(Object(g.a)({},c),{},{ref:t,className:"toast-root ".concat(n),children:[Object(h.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(h.jsx)(Ft.a,{className:"error-icon"});case"success":return Object(h.jsx)(Q.a,{className:"success-icon"});case"loading":return Object(h.jsx)(At,{});default:return Object(h.jsx)(h.Fragment,{})}}()}),Object(h.jsx)(Pt.a,{className:"toast-desc",children:a})]})),Object(h.jsx)(Pt.d,{className:"toast-viewpoint"})]})}));Zt.defaultProps={desc:"",state:"loading"};var Vt=Zt,Wt=n(36),Bt=n(91),_t=["onFocus","onBlur"],Ut=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(se.a)(e,_t),r=Object(o.d)(Me),i=Object(d.a)(r,2),s=(i[0],i[1]);return Object(h.jsx)("textarea",Object(g.a)(Object(g.a)({},c),{},{ref:t,onFocus:function(e){s((function(e){return Object(g.a)(Object(g.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){s((function(e){return Object(g.a)(Object(g.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(Bt.a)(!0),t=Object(d.a)(e,2),n=t[0],a=t[1],c=Object(o.d)(Xe),r=Object(d.a)(c,2),i=r[0],s=r[1],l=Object(o.d)(Ie),u=Object(d.a)(l,2),b=u[0],j=u[1],f=Object(o.e)(Ne),p=Object(o.e)(Le);return Object(h.jsx)("div",{className:"side-panel",children:Object(h.jsxs)(Wt.c,{open:n,children:[Object(h.jsx)(Wt.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Configurations"}),Object(h.jsx)(Wt.b,{children:Object(h.jsxs)(Wt.a,{className:"side-panel-content",children:[Object(h.jsx)(Oe,{title:"Croper",input:Object(h.jsx)(Nt,{checked:i.showCroper,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{showCroper:e})}))},children:Object(h.jsx)(Et,{})})}),Object(h.jsx)(xe,{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(g.a)(Object(g.a)({},e),{},{sdSteps:t})}))}}),Object(h.jsx)(xe,{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(g.a)(Object(g.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(h.jsx)(xe,{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(g.a)(Object(g.a)({},e),{},{sdMaskBlur:t})}))}}),Object(h.jsx)(Oe,{title:"Match Histograms",desc:"Match the inpainting result histogram to the source image histogram, will improves the inpainting quality for some images.",input:Object(h.jsx)(Nt,{checked:i.sdMatchHistograms,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{sdMatchHistograms:e})}))},children:Object(h.jsx)(Et,{})})}),Object(h.jsx)(Oe,{className:"sub-setting-block",title:"Sampler",input:Object(h.jsx)(ne,{width:80,value:i.sdSampler,options:Object.values(Be),onChange:function(e){var t=e;s((function(e){return Object(g.a)(Object(g.a)({},e),{},{sdSampler:t})}))}})}),Object(h.jsx)(Oe,{title:"Seed",input:Object(h.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)(xe,{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(g.a)(Object(g.a)({},e),{},{sdSeed:t})}))}}),Object(h.jsx)(Nt,{checked:i.sdSeedFixed,onCheckedChange:function(e){s((function(t){return Object(g.a)(Object(g.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(h.jsx)(Et,{})})]})}),Object(h.jsx)(Oe,{className:"sub-setting-block",title:"Negative prompt",layout:"v",input:Object(h.jsx)(Ut,{className:"negative-prompt",value:b,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;j(t.value)},onKeyUp:function(e){"Enter"!==e.key||!e.ctrlKey&&!e.metaKey||0===p.length||f||st.emit(it)},placeholder:""})})]})})]})})},Yt=function(){var e=Object(o.d)(Ee),t=Object(d.a)(e,2),n=(t[0],t[1],Object(o.d)(Xe)),c=Object(d.a)(n,2),r=c[0],i=c[1],s=Object(o.d)(Ve),b=Object(d.a)(s,2),j=b[0],f=b[1],p=Object(o.e)(qe),O=function(){var e=Object(u.a)(l.a.mark((function e(){var t,n,a,c,o;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,U().then((function(e){return e.text()}));case 2:if((t=e.sent)!==r.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=r.model,fetch("".concat(V,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=r.model,c="Switching to ".concat(a," model"),o=3e3,"False"===n&&(c="Downloading ".concat(a," model, this may take a while"),o=9999999999),f({open:!0,desc:c,state:"loading",duration:o}),_(a).then((function(e){if(!e.ok)throw new Error("Server error");f({open:!0,desc:"Switch to ".concat(a," model success"),state:"success",duration:3e3})})).catch((function(){f({open:!0,desc:"Switch to ".concat(a," model failed"),state:"error",duration:3e3}),i((function(e){return Object(g.a)(Object(g.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(){U().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(g.a)(Object(g.a)({},t),{},{model:e})}))}))}),[i]),Object(h.jsxs)(h.Fragment,{children:[p?Object(h.jsx)(Kt,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsx)(yt,{}),Object(h.jsx)(Dt,{onClose:O}),Object(h.jsx)(Ct,{}),Object(h.jsx)(Vt,Object(g.a)(Object(g.a)({},j),{},{onOpenChange:function(e){f((function(t){return Object(g.a)(Object(g.a)({},t),{},{open:e})}))}}))]})},Gt=n(93),Xt=n(56),Jt=function(){var e=Object(o.d)(We),t=Object(d.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return tt("h",(function(){c()})),Object(h.jsx)("div",{className:"shortcuts",children:Object(h.jsx)(X,{onClick:c,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(h.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(h.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(h.jsxs)("g",{fill:"currentColor",children:[Object(h.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(h.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"})]})]})})})},$t=function(){var e=Object(o.d)(Xe),t=Object(d.a)(e,2),n=t[0],a=t[1];return Object(h.jsx)("div",{children:Object(h.jsx)(X,{onClick:function(){a(Object(g.a)(Object(g.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(h.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(h.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(h.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},qt=function(){var e=Object(o.d)(Me),t=Object(d.a)(e,2),n=t[0],c=(t[1],Object(o.d)(Le)),r=Object(d.a)(c,2),i=r[0],s=r[1],l=Object(o.e)(Ne),u=Object(a.useRef)(null),b=function(){0===i.length||n.isInpainting||st.emit(it)};Object(oe.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(h.jsxs)("div",{className:"prompt-wrapper",children:[Object(h.jsx)(ue,{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(h.jsx)(X,{border:!0,onClick:b,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},Qt=n(92),en=function(){var e=Object(a.useState)(!1),t=Object(d.a)(e,2),n=t[0],c=t[1];return Object(h.jsxs)("div",{children:[Object(h.jsx)(X,{onClick:function(){c(!0)},toolTip:"Buy me a coffee",tooltipPosition:"bottom",style:{border:0},icon:Object(h.jsx)(Qt.a,{})}),Object(h.jsxs)(Ot,{onClose:function(){return c(!1)},title:"Buy Me a Coffee",className:"modal-setting",show:n,showCloseIcon:!1,children:[Object(h.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(h.jsxs)("div",{style:{display:"flex",width:"100%",justifyContent:"flex-end",alignItems:"center",gap:"12px"},children:[Object(h.jsx)(X,{onClick:function(){return c(!1)},children:" No thanks "}),Object(h.jsx)("a",{href:"https://ko-fi.com/Z8Z1CZJGY",target:"_blank",rel:"noreferrer",children:Object(h.jsx)(X,{border:!0,onClick:function(){return c(!1)},children:Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:["Sure",Object(h.jsx)(Qt.a,{})]})})})]})]})]})},tn=function(){var e=Object(o.e)(Ne),t=Object(o.d)(Ee),n=Object(d.a)(t,2),c=n[0],r=n[1],i=Object(o.d)(Ce),s=Object(d.a)(i,2),l=s[0],u=s[1],b=Object(a.useState)("file-upload-".concat(Math.random().toString())),j=Object(d.a)(b,1)[0],f=Object(a.useState)("mask-upload-".concat(Math.random().toString())),p=Object(d.a)(f,1)[0],g=Object(o.e)(qe);return Object(h.jsxs)("header",{children:[Object(h.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8},children:[Object(h.jsx)("label",{htmlFor:j,children:Object(h.jsxs)(X,{icon:Object(h.jsx)(Gt.a,{}),style:{border:0},disabled:e,toolTip:"Upload image",tooltipPosition:"bottom",children:[Object(h.jsx)("input",{style:{display:"none"},id:j,name:j,type:"file",onChange:function(e){var t,n=null===(t=e.currentTarget.files)||void 0===t?void 0:t[0];n&&r(n)},accept:"image/png, image/jpeg"}),"Image"]})}),Object(h.jsxs)("div",{style:{visibility:c?"visible":"hidden",display:"flex",justifyContent:"center",alignItems:"center"},children:[Object(h.jsx)("label",{htmlFor:p,children:Object(h.jsxs)(X,{style:{border:0},disabled:e,toolTip:"Upload custom mask",tooltipPosition:"bottom",children:[Object(h.jsx)("input",{style:{display:"none"},id:p,name:p,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"),st.emit(ot,{mask:n}),u(n))},accept:"image/png, image/jpeg"}),"Mask"]})}),Object(h.jsx)(X,{style:{visibility:l?"visible":"hidden"},icon:Object(h.jsx)(Xt.a,{}),onClick:function(){l&&st.emit(ot,{mask:l})}})]})]}),g&&c?Object(h.jsx)(qt,{}):Object(h.jsx)(h.Fragment,{}),Object(h.jsxs)("div",{className:"header-icons-wrapper",children:[Object(h.jsx)(en,{}),Object(h.jsx)(O,{}),Object(h.jsxs)("div",{className:"header-icons",children:[Object(h.jsx)(Jt,{}),Object(h.jsx)($t,{})]})]})]})},nn=["image/jpeg","image/png","image/webp","image/bmp","image/tiff"];var an=function(){var e=Object(o.d)(Ee),t=Object(d.a)(e,2),n=t[0],r=t[1],i=Object(o.d)(p),s=Object(d.a)(i,2),j=s[0],f=s[1],O=Object(o.d)(Ve),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],c=t[1],r=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,r,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:(r=e.sent)&&r.type.startsWith("image")&&(i=new File([r],void 0!==a?a:"inputImage"),c(i));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[c]);return Object(a.useEffect)((function(){r()}),[r]),n}(),x=Object(o.d)(De),y=Object(d.a)(x,2),w=(y[0],y[1]);Object(a.useEffect)((function(){r(m)}),[m,r]),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(V,"/is_desktop"),{method:"GET"}).then((function(e){return e.text()}));case 2:"True"===e.sent&&E();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),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(V,"/is_disable_model_switch"),{method:"GET"}).then((function(e){return e.text()}));case 2:t=e.sent,w("true"===t);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();e()}),[]),tt("shift+d",(function(){f("light"===j?"dark":"light")}),{},[j]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",j)}),[j]);var S=Object(a.useMemo)((function(){return Object(b.a)()}),[n]),k=c.a.useState(!1),C=Object(d.a)(k,2),M=(C[0],C[1]),L=c.a.useRef(0),I=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation()}),[]),N=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&M(!0)}),[]),z=c.a.useCallback((function(e){e.preventDefault(),e.stopPropagation(),L.current-=1,L.current>0||M(!1)}),[]),T=c.a.useCallback((function(e){if(e.preventDefault(),e.stopPropagation(),M(!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;nn.includes(n)?r(t):v({open:!0,desc:"Please drag and drop an image file",state:"error",duration:3e3})}e.dataTransfer.clearData()}}),[]),R=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&&r(a)}}}),[]);return c.a.useEffect((function(){return window.addEventListener("dragenter",N),window.addEventListener("dragleave",z),window.addEventListener("dragover",I),window.addEventListener("drop",T),window.addEventListener("paste",R),function(){window.removeEventListener("dragenter",N),window.removeEventListener("dragleave",z),window.removeEventListener("dragover",I),window.removeEventListener("drop",T),window.removeEventListener("paste",R)}})),Object(h.jsxs)("div",{className:"lama-cleaner",children:[Object(h.jsx)(tn,{}),Object(h.jsx)(Yt,{},S)]})};i.a.render(Object(h.jsx)(c.a.StrictMode,{children:Object(h.jsx)(o.a,{children:Object(h.jsx)(an,{})})}),document.getElementById("root"))}},[[74,1,2]]]);