(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{48:function(e,t,n){},51:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),i=n(15),r=n.n(i),o=(n(48),n(10)),s=n(2),l=n(55),u=n(8),d=n.n(u),j=n(14);var b=n(3),h=n(16),f=n(21),p=n(1),v=function(e){var t=e.width,n=e.value,c=e.chevronDirection,i=e.options,r=e.autoFocusAfterClose,o=e.onChange,s=Object(a.useRef)(null);return Object(p.jsxs)(f.f,{value:n,onValueChange:o,onOpenChange:function(e){e||r||window.setTimeout((function(){var e;null===s||void 0===s||null===(e=s.current)||void 0===e||e.blur()}),100)},children:[Object(p.jsxs)(f.g,{className:"select-trigger",style:{width:t},ref:s,children:[Object(p.jsx)(f.h,{}),Object(p.jsx)(f.b,{children:"up"===c?Object(p.jsx)(h.e,{}):Object(p.jsx)(h.d,{})})]}),Object(p.jsx)(f.a,{className:"select-content",children:Object(p.jsx)(f.i,{className:"select-viewport",children:i.map((function(e){return Object(p.jsxs)(f.c,{value:e,className:"select-item",children:[Object(p.jsx)(f.e,{children:e}),Object(p.jsx)(f.d,{className:"select-item-indicator",children:Object(p.jsx)(h.c,{})})]},e)}))})})]})};v.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0};var O=v,g=n(4),m=["value","onValue"],x=c.a.forwardRef((function(e,t){var n=e.value,a=e.onValue,c=Object(g.a)(e,m);return Object(p.jsx)("input",Object(b.a)(Object(b.a)({value:n,onInput:function(e){var t=e.target.value.replace(/\D/g,"");null===a||void 0===a||a(t)},className:"number-input"},c),{},{ref:t,type:"text"}))}));var w=function(e){var t=e.title,n=e.desc,a=e.input,c=e.optionDesc,i=e.className;return Object(p.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(p.jsxs)("div",{className:"setting-block-content",children:[Object(p.jsxs)("div",{className:"setting-block-content-title",children:[Object(p.jsx)("span",{children:t}),n&&Object(p.jsx)("span",{className:"setting-block-desc",children:n})]}),a]}),c&&Object(p.jsx)("div",{className:"option-desc",children:c})]})};var y,k,S=function(e){var t=e.title,n=e.value,a=e.suffix,c=e.onValue;return Object(p.jsx)(w,{className:"sub-setting-block",title:t,input:Object(p.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(p.jsx)(x,{style:{width:"80px"},value:"".concat(n),onValue:c}),a&&Object(p.jsx)("span",{children:a})]})})};!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(y||(y={})),function(e){e.ddim="ddim",e.plms="plms"}(k||(k={}));var C,M=function(){var e=Object(o.c)(R),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(e){a((function(t){return Object(b.a)(Object(b.a)({},t),{},{hdStrategy:e})}))},i=function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(b.a)(Object(b.a)({},e),{},{hdStrategyResizeLimit:t})}))},r=function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(b.a)(Object(b.a)({},e),{},{hdStrategyCropTrigerSize:t})}))},l=function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(b.a)(Object(b.a)({},e),{},{hdStrategyCropMargin:t})}))},u=function(){return Object(p.jsxs)("div",{children:["Use the original resolution of the picture, suitable for picture size below 2K. Try"," ",Object(p.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(y.RESIZE)},children:"Resize Strategy"})," ","if you do not get good results on high resolution images."]})};return Object(p.jsx)(w,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(p.jsx)(O,{width:80,value:n.hdStrategy,options:Object.values(y),onChange:function(e){return c(e)}}),optionDesc:function(){switch(n.hdStrategy){case y.ORIGINAL:return u();case y.CROP:return Object(p.jsxs)("div",{children:[Object(p.jsx)("div",{children:"Crop masking area from the original image to do inpainting, and paste the result back. Mainly for performance and memory reasons on high resolution image."}),Object(p.jsx)(S,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:r}),Object(p.jsx)(S,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case y.RESIZE:return Object(p.jsxs)("div",{children:[Object(p.jsx)("div",{children:"Resize the longer side of the image to a specific size(keep ratio), then do inpainting on the resized image."}),Object(p.jsx)(S,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:i})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm"}(C||(C={}));var L,N=function(){var e=Object(o.c)(R),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(e,t,n){return Object(p.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[Object(p.jsx)("a",{className:"model-desc-link",href:t,target:"_blank",rel:"noreferrer noopener",children:e}),Object(p.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:n})]})},i=function(){return Object(p.jsxs)("div",{children:[c("High-Resolution Image Synthesis with Latent Diffusion Models","https://arxiv.org/abs/2112.10752","https://github.com/CompVis/latent-diffusion"),Object(p.jsx)(S,{title:"Steps",value:"".concat(n.ldmSteps),onValue:function(e){var t=0===e.length?0:parseInt(e,10);a((function(e){return Object(b.a)(Object(b.a)({},e),{},{ldmSteps:t})}))}}),Object(p.jsx)(w,{className:"sub-setting-block",title:"Sampler",input:Object(p.jsx)(O,{width:80,value:n.ldmSampler,options:Object.values(k),onChange:function(e){return t=e,void a((function(e){return Object(b.a)(Object(b.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(p.jsx)(w,{className:"model-setting-block",title:"Inpainting Model",input:Object(p.jsx)(O,{width:80,value:n.model,options:Object.values(C),onChange:function(e){return t=e,void a((function(e){return Object(b.a)(Object(b.a)({},e),{},{model:t})}));var t}}),optionDesc:function(){switch(n.model){case C.LAMA:return c("Resolution-robust Large Mask Inpainting with Fourier Convolutions","https://arxiv.org/abs/2109.07161","https://github.com/saic-mdal/lama");case C.LDM:return i();default:return Object(p.jsx)(p.Fragment,{})}}()})},z=Object(o.b)({key:"fileState",default:void 0}),E=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),I=Object(o.b)({key:"shortcutsState",default:!1}),D={show:!1,runInpaintingManually:!1,model:C.LAMA,ldmSteps:50,ldmSampler:k.plms,hdStrategy:y.RESIZE,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:2048,hdStrategyCropMargin:128},R=Object(o.b)({key:"settingsState",default:D,effects:[(L="settingsState",function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(L);if(null!=a){var c=JSON.parse(a);c.show=!1,t(c)}n((function(e,t,n){return n?localStorage.removeItem(L):localStorage.setItem(L,JSON.stringify(e))}))})]}),T=n(9),A=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.a)(e,2),n=t[0],c=t[1],i=Object(a.useCallback)((function(){c(window.innerWidth)}),[]);return Object(a.useEffect)((function(){return window.addEventListener("resize",i),function(){window.removeEventListener("resize",i)}})),n<768?"mobile":n>=768&&n<1224?"tablet":n>=1224?"desktop":void 0};function Z(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(s.a)(n,2),i=c[0],r=c[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=A();function b(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 f.apply(this,arguments)}function f(){return(f=Object(j.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 v(e){return O.apply(this,arguments)}function O(){return(O=Object(j.a)(d.a.mark((function e(t){var n,a,c,i,r;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],c=0;c0)){e.next=23;break}if(!(null===(i=a.shift())||void 0===i?void 0:i.isFile)){e.next=12;break}return e.next=8,h(i);case 8:r=e.sent,n.push(r),e.next=21;break;case 12:if(!(null===i||void 0===i?void 0:i.isDirectory)){e.next=21;break}return e.t0=a.push,e.t1=a,e.t2=T.a,e.next=18,g(i.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 g(e){return m.apply(this,arguments)}function m(){return(m=Object(j.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,x(t);case 3:a=e.sent;case 4:if(!(a.length>0)){e.next=11;break}return n.push.apply(n,Object(T.a)(a)),e.next=8,x(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 x(e){return w.apply(this,arguments)}function w(){return(w=Object(j.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 y(){return(y=Object(j.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,v(t.dataTransfer.items);case 3:n=e.sent,r(!1),b(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(p.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(p.jsxs)("div",{className:["file-select-container",i?"file-select-label-hover":""].join(" "),onDrop:function(e){return y.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),r(!0)},onDragLeave:function(){return r(!1)},children:[Object(p.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&&b(n)},accept:"image/png, image/jpeg"}),Object(p.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var P=function(){var e=Object(o.e)(z);return Object(p.jsxs)("div",{className:"landing-page",children:[Object(p.jsxs)("h1",{children:["Image inpainting powered by \ud83e\udd99",Object(p.jsx)("a",{href:"https://github.com/saic-mdal/lama",children:"LaMa"})]}),Object(p.jsx)("div",{className:"landing-file-selector",children:Object(p.jsx)(Z,{onSelection:function(){var t=Object(j.a)(d.a.mark((function t(n){return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e(n);case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()})})]})},H=Object(o.b)({key:"themeState",default:"light"}),V=function(){var e=Object(o.c)(H),t=Object(s.a)(e,2),n=t[0],c=t[1];Object(a.useEffect)((function(){window.matchMedia("(prefers-color-scheme: dark)").matches?c("dark"):c("light")}),[c]);return Object(p.jsx)("div",{className:"theme-toggle-ui",children:Object(p.jsx)("div",{className:"theme-btn",onClick:function(){c("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(p.jsx)(h.i,{}):Object(p.jsx)(h.j,{style:{color:"#ffcc00"}})})})},F=n(38),W=n(54),U=n(40);function B(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],c=0;ct){var c=Math.ceil(t*a);return"".concat(e,"x").concat(c)}var i=Math.ceil(n*a);return"".concat(i,"x").concat(e)}),[n,t,u]),j=Object(a.useCallback)((function(){for(var e=[],t=0;tt?(l(a[0]),c(parseInt(a[0],10))):(l(a[1]),c(parseInt(a[1],10)))},chevronDirection:"up"})}var ae="#ffcc00bb";function ce(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ae;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 ie(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function re(e){var t=e.file,n=Object(o.d)(R),c=Object(o.c)(E),i=Object(s.a)(c,2),r=(i[0],i[1]),u=Object(a.useState)(40),b=Object(s.a)(u,2),f=b[0],v=b[1],O=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],c=Object(a.useState)(!1),i=Object(s.a)(c,2),r=i[0],o=i[1];return Object(a.useEffect)((function(){return n.onload=function(){o(!0)},o(!1),n.src=URL.createObjectURL(e),function(){n.onload=null}}),[e,n]),[n,r]}(t),g=Object(s.a)(O,2),m=g[0],x=g[1],w=Object(a.useState)([]),y=Object(s.a)(w,2),k=y[0],S=y[1],C=Object(a.useState)(),M=Object(s.a)(C,2),L=M[0],N=M[1],z=Object(a.useState)((function(){return document.createElement("canvas")})),I=Object(s.a)(z,1)[0],D=Object(a.useState)([]),A=Object(s.a)(D,2),Z=A[0],P=A[1],H=Object(a.useState)([]),V=Object(s.a)(H,2),B=V[0],K=V[1],Y=Object(a.useState)({x:-1,y:-1}),X=Object(s.a)(Y,2),$=X[0],Q=$.x,te=$.y,ae=X[1],re=Object(a.useState)(!1),oe=Object(s.a)(re,2),se=oe[0],le=oe[1],ue=Object(a.useState)(!1),de=Object(s.a)(ue,2),je=de[0],be=de[1],he=Object(a.useState)(!1),fe=Object(s.a)(he,2),pe=fe[0],ve=fe[1],Oe=Object(a.useState)(!1),ge=Object(s.a)(Oe,2),me=ge[0],xe=ge[1],we=Object(a.useState)(!1),ye=Object(s.a)(we,2),ke=ye[0],Se=ye[1],Ce=Object(a.useState)(1),Me=Object(s.a)(Ce,2),Le=Me[0],Ne=Me[1],ze=Object(a.useState)(!1),Ee=Object(s.a)(ze,2),Ie=Ee[0],De=Ee[1],Re=Object(a.useState)(1),Te=Object(s.a)(Re,2),Ae=Te[0],Ze=Te[1],Pe=Object(a.useState)(1080),He=Object(s.a)(Pe,2),Ve=He[0],Fe=He[1],We=Object(W.a)(),Ue=We.width/2,Be=We.height/2,Ge=Object(a.useRef)(),Je=Object(a.useState)(!1),Ke=Object(s.a)(Je,2),_e=Ke[0],Ye=Ke[1],Xe=Object(a.useState)(!1),$e=Object(s.a)(Xe,2),Qe=$e[0],qe=$e[1],et=Object(a.useState)(!1),tt=Object(s.a)(et,2),nt=tt[0],at=tt[1],ct=Object(a.useState)(0),it=Object(s.a)(ct,2),rt=it[0],ot=it[1],st=Object(a.useCallback)((function(e,t){L&&(L.clearRect(0,0,L.canvas.width,L.canvas.height),L.drawImage(e,0,0,m.naturalWidth,m.naturalHeight),ce(L,t))}),[L,m]),lt=function(e){if(!(null===L||void 0===L?void 0:L.canvas.width)||!(null===L||void 0===L?void 0:L.canvas.height))throw new Error("canvas has invalid size");I.width=null===L||void 0===L?void 0:L.canvas.width,I.height=null===L||void 0===L?void 0:L.canvas.height;var t=I.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){ce(t,e,"white")}))},ut=function(){var e=Object(j.a)(d.a.mark((function e(){var a,c,i,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(dt()){e.next=2;break}return e.abrupt("return");case 2:return a=[].concat(Object(T.a)(Z),[B]),K([]),qe(!1),Se(!0),lt(a),e.prev=7,e.next=10,_(t,I.toDataURL(),n,Ve.toString());case 10:if(c=e.sent){e.next=13;break}throw new Error("empty response");case 13:return i=new Image,e.next=16,G(i,c);case 16:o=[].concat(Object(T.a)(k),[i]),S(o),st(i,[]),P(a),e.next=26;break;case 22:e.prev=22,e.t0=e.catch(7),r({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:2e3}),bt([]);case 26:Se(!1);case 27:case"end":return e.stop()}}),e,null,[[7,22]])})));return function(){return e.apply(this,arguments)}}(),dt=function(){return 0!==B.length},jt=function(){return 0!==k.length},bt=Object(a.useCallback)((function(e){0===k.length?st(m,e):st(k[k.length-1],e)}),[m,k,st]),ht=function(e){return"Control"===e.key||"Meta"===e.key};Object(U.a)(ht,(function(){nt&&(ke||(at(!1),n.runInpaintingManually||ut()))}),{event:"keyup"},[ke,nt,dt]),Object(U.a)(ht,(function(){ke||at(!0)}),{event:"keydown"},[ke]),Object(a.useEffect)((function(){if(x){var e=We.width/m.naturalWidth,t=(We.height-200)/m.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),Ze(n),Ne(n),(null===L||void 0===L?void 0:L.canvas)&&(L.canvas.width=m.naturalWidth,L.canvas.height=m.naturalHeight,bt([])),!_e){var a;null===(a=Ge.current)||void 0===a||a.centerView(n,1),Ye(!0);var c=Math.max(m.width,m.height);Fe(c)}}}),[null===L||void 0===L?void 0:L.canvas,Ge,m,x,We,_e,bt]);var ft=Object(a.useCallback)((function(){if(Ae&&m&&We){var e=Ge.current;if(!e)throw new Error("no viewport");var t=(We.width-m.width*Ae)/2,n=(We.height-m.height*Ae)/2;e.setTransform(t,n,Ae,200,"easeOutQuad"),e.state.scale=Ae,Ne(Ae),De(!1)}}),[Ge,Ae,m,We]);Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){ft()})),function(){window.removeEventListener("resize",(function(){ft()}))}}),[We,ft]);Object(U.a)("Escape",(function(){ke||(Qe||nt?(qe(!1),K([]),bt([])):ft())}),{event:"keydown"},[Qe,ke,nt,ft,bt]);var pt=Object(a.useCallback)((function(){if(0!==B.length){var e=B.slice(0,B.length-1);K(e),bt(e)}}),[B,bt]),vt=Object(a.useCallback)((function(){if(k.length){var e=Z.slice(0,Z.length-1);P(e),K([]),qe(!1);var t=k.slice(0,k.length-1);S(t),0===t.length?st(m,[]):st(t[t.length-1],[])}}),[st,k,Z,m]),Ot=function(){n.runInpaintingManually&&0!==B.length?pt():vt()};Object(U.a)((function(e){var t=(e.metaKey||e.ctrlKey)&&"z"===e.key;return"Tab"===e.key&&e.preventDefault(),!!t&&(e.preventDefault(),!0)}),Ot,void 0,[pt,vt]);Object(l.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),jt()&&xe((function(){return window.setTimeout((function(){ot(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),jt()&&(ot(0),window.setTimeout((function(){xe(!1)}),350))}));var gt=function(e){e===se||pe||le(e)},mt=Object(a.useCallback)((function(){return pe?"grab":se?"none":void 0}),[se,pe]);Object(l.a)("[",(function(){v((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),Object(l.a)("]",(function(){v((function(e){return e+10}))})),Object(l.a)("R",(function(){n.runInpaintingManually&&dt()&&ut()})),Object(l.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),le(!1),ve(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),le(!0),ve(!1)}));var xt=function(e,t){var n=function(){var e,t,n=Ae;return void 0!==(null===(e=Ge.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=Ge.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(f*n,"px"),height:"".concat(f*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(p.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;ae({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(J(e)&&ve(!1),pe)||m.src&&(null===L||void 0===L?void 0:L.canvas)&&(ke||Qe&&(nt||n.runInpaintingManually?qe(!1):ut()))},children:[Object(p.jsx)(F.b,{ref:function(e){e&&(Ge.current=e)},panning:{disabled:!pe,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:Ae,minScale:Ae,onPanning:function(e){Ie||De(!0)},onZoom:function(e){Ne(e.state.scale)},children:Object(p.jsx)(F.a,{contentClass:ke?"editor-canvas-loading":"",contentStyle:{visibility:_e?"visible":"hidden"},children:Object(p.jsxs)("div",{className:"editor-canvas-container",children:[Object(p.jsx)("canvas",{className:"editor-canvas",style:{cursor:mt(),clipPath:"inset(0 ".concat(rt,"% 0 0)"),transition:"clip-path 350ms ease-in-out"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){gt(!0),be(!1)},onFocus:function(){return gt(!0)},onMouseLeave:function(){return gt(!1)},onMouseDown:function(e){if(!pe&&(m.src&&(null===L||void 0===L?void 0:L.canvas)&&!ke&&!function(e){return 2===e.nativeEvent.button}(e)))if(J(e))ve(!0);else{qe(!0);var t=[];(nt||n.runInpaintingManually)&&(t=Object(T.a)(B)),t.push({size:f,pts:[ie(e)]}),K(t),bt(t)}},onMouseMove:function(e){if(!pe&&Qe&&0!==B.length){var t=Object(T.a)(B);t[t.length-1].pts.push(ie(e)),K(t),bt(t)}},ref:function(e){if(e&&!L){var t=e.getContext("2d");t&&N(t)}}}),Object(p.jsxs)("div",{className:"original-image-container",style:{width:"".concat(m.naturalWidth,"px"),height:"".concat(m.naturalHeight,"px")},children:[me&&Object(p.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(rt,"%")}}),Object(p.jsx)("img",{className:"original-image",src:m.src,alt:"original",style:{width:"".concat(m.naturalWidth,"px"),height:"".concat(m.naturalHeight,"px")}})]})]})})}),se&&!ke&&!pe&&Object(p.jsx)("div",{className:"brush-shape",style:xt(Q,te)}),je&&Object(p.jsx)("div",{className:"brush-shape",style:xt(Ue,Be)}),Object(p.jsxs)("div",{className:"editor-toolkit-panel",children:[Object(p.jsx)(ne,{onChange:function(e){Fe(e)},originalWidth:m.naturalWidth,originalHeight:m.naturalHeight}),Object(p.jsx)(ee,{label:"Brush",min:10,max:150,value:f,onChange:function(e){v(e),je||(be(!0),window.setTimeout((function(){be(!1)}),1e4))},onClick:function(){return be(!1)}}),Object(p.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(p.jsx)(q,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(p.jsx)(h.b,{}),disabled:Le===Ae&&!1===Ie,onClick:ft}),Object(p.jsx)(q,{toolTip:"Undo",tooltipPosition:"top",icon:Object(p.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(p.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:Ot,disabled:function(){if(k.length>0)return!1;if(n.runInpaintingManually){if(0===B.length)return!0}else if(0===k.length)return!0;return!1}()}),Object(p.jsx)(q,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(p.jsx)(h.h,{}),className:me?"eyeicon-active":"",onDown:function(e){e.preventDefault(),xe((function(){return window.setTimeout((function(){ot(100)}),10),!0}))},onUp:function(){ot(0),window.setTimeout((function(){xe(!1)}),350)},disabled:0===k.length}),Object(p.jsx)(q,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(p.jsx)(h.f,{}),disabled:!k.length,onClick:function(){var e=t.name.replace(/(\.[\w\d_-]+)$/i,"_cleanup$1");!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)}(k[k.length-1].currentSrc,e)}}),n.runInpaintingManually&&Object(p.jsx)(q,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(p.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(p.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:!dt()||ke,onClick:function(){!ke&&dt()&&ut()}})]})]})]})}var oe=n(25),se=c.a.forwardRef((function(e,t){var n=e.show,a=e.children,c=e.onClose,i=e.className,r=e.title;return Object(p.jsx)(oe.d,{open:n,onOpenChange:function(e){e||null===c||void 0===c||c()},children:Object(p.jsxs)(oe.c,{children:[Object(p.jsx)(oe.b,{className:"modal-mask"}),Object(p.jsxs)(oe.a,{ref:t,className:"modal ".concat(i),children:[Object(p.jsxs)("div",{className:"modal-header",children:[Object(p.jsx)(oe.e,{children:r}),Object(p.jsx)(q,{icon:Object(p.jsx)(h.k,{}),onClick:c})]}),a]})]})})}));function le(e){var t=e.content,n=e.keys;return Object(p.jsxs)("div",{className:"shortcut-option",children:[Object(p.jsx)("div",{className:"shortcut-description",children:t}),Object(p.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(p.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var ue=/macintosh|mac os x/i.test(navigator.userAgent),de=(/windows|win32/i.test(navigator.userAgent),ue?"Cmd":"Ctrl");function je(){var e=Object(o.c)(I),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(p.jsx)(se,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(p.jsxs)("div",{className:"shortcut-options",children:[Object(p.jsx)(le,{content:"Enable Multi-Stroke Mask Drawing",keys:["Hold ".concat(de)]}),Object(p.jsx)(le,{content:"Undo Inpainting",keys:[de,"Z"]}),Object(p.jsx)(le,{content:"Pan",keys:["Space & Drag"]}),Object(p.jsx)(le,{content:"View Original Image",keys:["Hold Tab"]}),Object(p.jsx)(le,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(p.jsx)(le,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(p.jsx)(le,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(p.jsx)(le,{content:"Decrease Brush Size",keys:["["]}),Object(p.jsx)(le,{content:"Increase Brush Size",keys:["]"]}),Object(p.jsx)(le,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(p.jsx)(le,{content:"Toggle Hotkeys Panel",keys:["H"]})]})})}var be=n(39),he=["className"],fe=["className"],pe=c.a.forwardRef((function(e,t){var n=e.className,a=Object(g.a)(e,he);return Object(p.jsx)(be.a,Object(b.a)(Object(b.a)({},a),{},{ref:t,className:"switch-root ".concat(n)}))})),ve=c.a.forwardRef((function(e,t){var n=e.className,a=Object(g.a)(e,fe);return Object(p.jsx)(be.b,Object(b.a)(Object(b.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),Oe=function(){var e=Object(o.c)(R),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(p.jsx)(w,{title:"Manual Inpainting Mode",input:Object(p.jsx)(pe,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(b.a)(Object(b.a)({},t),{},{runInpaintingManually:e})}))},children:Object(p.jsx)(ve,{})})})};function ge(e){var t=e.onClose,n=Object(o.c)(R),a=Object(s.a)(n,2),c=a[0],i=a[1];return Object(p.jsxs)(se,{onClose:function(){i((function(e){return Object(b.a)(Object(b.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:c.show,children:[Object(p.jsx)(Oe,{}),Object(p.jsx)(N,{}),Object(p.jsx)(M,{})]})}var me=n(28),xe=["state","desc"],we=function(){return Object(p.jsx)("span",{className:"loading-icon",children:Object(p.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(p.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(p.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(p.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(p.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(p.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(p.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(p.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(p.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},ye=a.forwardRef((function(e,t){var n=e.state,a=e.desc,c=Object(g.a)(e,xe);return Object(p.jsxs)(me.b,{children:[Object(p.jsxs)(me.c,Object(b.a)(Object(b.a)({},c),{},{ref:t,className:"toast-root ".concat(n),children:[Object(p.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(p.jsx)(h.g,{className:"error-icon"});case"success":return Object(p.jsx)(h.c,{className:"success-icon"});case"loading":return Object(p.jsx)(we,{});default:return Object(p.jsx)(p.Fragment,{})}}()}),Object(p.jsx)(me.a,{className:"toast-desc",children:a})]})),Object(p.jsx)(me.d,{className:"toast-viewpoint"})]})}));ye.defaultProps={desc:"",state:"loading"};var ke=ye,Se=function(e){var t=e.file,n=Object(o.c)(R),c=Object(s.a)(n,2),i=c[0],r=c[1],l=Object(o.c)(E),u=Object(s.a)(l,2),h=u[0],f=u[1],v=function(){var e=Object(j.a)(d.a.mark((function e(){var t,n,a,c,o;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,$().then((function(e){return e.text()}));case 2:if((t=e.sent)!==i.model){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,(s=i.model,fetch("".concat(K,"/model_downloaded/").concat(s),{method:"GET"})).then((function(e){return e.text()}));case 7:n=e.sent,a=i.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}),X(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}),r((function(e){return Object(b.a)(Object(b.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(){$().then((function(e){return e.text()})).then((function(e){r((function(t){return Object(b.a)(Object(b.a)({},t),{},{model:e})}))}))}),[r]),Object(p.jsxs)(p.Fragment,{children:[Object(p.jsx)(re,{file:t}),Object(p.jsx)(ge,{onClose:v}),Object(p.jsx)(je,{}),Object(p.jsx)(ke,Object(b.a)(Object(b.a)({},h),{},{onOpenChange:function(e){f((function(t){return Object(b.a)(Object(b.a)({},t),{},{open:e})}))}}))]})},Ce=function(){var e=Object(o.c)(I),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return Object(l.a)("h",(function(e){null===e||void 0===e||e.preventDefault(),c()})),Object(p.jsx)("div",{className:"shortcuts",children:Object(p.jsx)(q,{onClick:c,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(p.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(p.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(p.jsxs)("g",{fill:"currentColor",children:[Object(p.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(p.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"})]})]})})})},Me=function(){var e=Object(o.c)(R),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(p.jsx)("div",{children:Object(p.jsx)(q,{onClick:function(){a(Object(b.a)(Object(b.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(p.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(p.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(p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},Le=function(){var e=Object(o.c)(z),t=Object(s.a)(e,2),n=t[0],a=t[1],c=A();return Object(p.jsxs)("header",{children:[Object(p.jsx)("div",{style:{visibility:n?"visible":"hidden"},children:Object(p.jsx)(q,{icon:Object(p.jsx)(h.a,{}),onClick:function(){a(void 0)},style:{border:0},children:"desktop"===c?"Start New":void 0})}),Object(p.jsxs)("div",{className:"header-icons-wrapper",children:[Object(p.jsx)(V,{}),n&&Object(p.jsxs)("div",{className:"header-icons",children:[Object(p.jsx)(Ce,{}),Object(p.jsx)(Me,{})]})]})]})};!function(){function e(){return e=Object(j.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 Ne=function(){var e=Object(o.c)(z),t=Object(s.a)(e,2),n=t[0],c=t[1],i=Object(o.c)(H),r=Object(s.a)(i,2),u=r[0],b=r[1],h=function(){var e=Object(a.useState)(),t=Object(s.a)(e,2),n=t[0],c=t[1],i=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(j.a)(d.a.mark((function e(t){var n,a,i,r;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:(i=e.sent)&&i.type.startsWith("image")&&(r=new File([i],void 0!==a?a:"inputImage"),c(r));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}),[c]);return Object(a.useEffect)((function(){i()}),[i]),n}();return Object(a.useEffect)((function(){c(h)}),[h,c]),Object(l.a)("D",(function(e){null===e||void 0===e||e.preventDefault(),b("light"===u?"dark":"light")})),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",u)}),[u]),Object(p.jsxs)("div",{className:"lama-cleaner",children:[Object(p.jsx)(Le,{}),n?Object(p.jsx)(Se,{file:n}):Object(p.jsx)(P,{})]})};r.a.render(Object(p.jsx)(c.a.StrictMode,{children:Object(p.jsx)(o.a,{children:Object(p.jsx)(Ne,{})})}),document.getElementById("root"))}},[[51,1,2]]]);