IOPaint/lama_cleaner/app/build/static/js/main.c616fe99.chunk.js
2022-09-22 22:59:30 +08:00

1 line
58 KiB
JavaScript

(this["webpackJsonplama-cleaner"]=this["webpackJsonplama-cleaner"]||[]).push([[0],{64:function(e,t,n){},69:function(e,t,n){"use strict";n.r(t);var a=n(0),c=n.n(a),r=n(12),i=n.n(r),o=(n(64),n(6)),s=n(3),l=n(55),u=n(9),d=n.n(u),j=n(13);var b=n(8),h=n(2),f=n(50),p=n.n(f),O=n(16),g=n(24),v=n(1),m=function(e){var t=e.width,n=e.value,c=e.chevronDirection,r=e.options,i=e.autoFocusAfterClose,o=e.onChange,s=Object(a.useRef)(null);return Object(v.jsxs)(g.f,{value:n,onValueChange:o,onOpenChange:function(e){e||i||window.setTimeout((function(){var e;null===s||void 0===s||null===(e=s.current)||void 0===e||e.blur()}),100)},children:[Object(v.jsxs)(g.g,{className:"select-trigger",style:{width:t},ref:s,onKeyDown:function(e){return e.preventDefault()},children:[Object(v.jsx)(g.h,{}),Object(v.jsx)(g.b,{children:"up"===c?Object(v.jsx)(O.d,{}):Object(v.jsx)(O.c,{})})]}),Object(v.jsx)(g.a,{className:"select-content",children:Object(v.jsx)(g.i,{className:"select-viewport",children:r.map((function(e){return Object(v.jsxs)(g.c,{value:e,className:"select-item",children:[Object(v.jsx)(g.e,{children:e}),Object(v.jsx)(g.d,{className:"select-item-indicator",children:Object(v.jsx)(O.b,{})})]},e)}))})})]})};m.defaultProps={chevronDirection:"down",autoFocusAfterClose:!0};var x=m,w=n(73),y=n(4),S=["onFocus","onBlur"],k=c.a.forwardRef((function(e,t){var n=e.onFocus,a=e.onBlur,c=Object(y.a)(e,S),r=Object(o.d)(W),i=Object(s.a)(r,2),l=(i[0],i[1]);return Object(v.jsx)("input",Object(h.a)(Object(h.a)({},c),{},{ref:t,type:"text",onFocus:function(e){l((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!0})})),null===n||void 0===n||n(e)},onBlur:function(e){l((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!1})})),null===a||void 0===a||a(e)},onKeyDown:function(e){"Escape"===e.key&&e.currentTarget.blur()}}))})),C=["value","allowFloat","onValue"],M=c.a.forwardRef((function(e,t){var n=e.value,c=e.allowFloat,r=e.onValue,i=Object(y.a)(e,C),o=Object(a.useState)(n),l=Object(s.a)(o,2),u=l[0],d=l[1];Object(a.useEffect)((function(){d(n)}),[n]);return Object(v.jsx)(k,Object(h.a)(Object(h.a)({value:u,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)),d(t)},className:"number-input"},i),{},{ref:t}))}));M.defaultProps={allowFloat:!1};var L=M,N=n(29),I=function(e){var t=e.content,n=e.children;return Object(v.jsx)(N.d,{children:Object(v.jsxs)(N.c,{children:[Object(v.jsx)(N.e,{className:"tooltip-trigger",children:n}),Object(v.jsxs)(N.b,{className:"tooltip-content",children:[t,Object(v.jsx)(N.a,{className:"tooltip-arrow"})]})]})})};var z=function(e){var t=e.title,n=e.titleSuffix,a=e.desc,c=e.input,r=e.optionDesc,i=e.className;return Object(v.jsxs)("div",{className:"setting-block ".concat(i),children:[Object(v.jsxs)("div",{className:"setting-block-content",children:[Object(v.jsx)("div",{className:"setting-block-content-title",children:Object(v.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[a?Object(v.jsx)(I,{content:Object(v.jsx)("div",{style:{maxWidth:400},children:a}),children:Object(v.jsx)("span",{children:t})}):Object(v.jsx)("span",{children:t}),n]})}),c]}),r&&Object(v.jsx)("div",{className:"option-desc",children:r})]})};function D(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(w.a)(d,(function(){(null===d||void 0===d?void 0:d.current)&&d.current.blur()})),Object(v.jsx)(z,{className:"sub-setting-block",title:t,desc:c,input:Object(v.jsxs)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"8px"},children:[Object(v.jsx)(L,{allowFloat:n,style:{width:"".concat(s).concat(l)},value:r,disabled:u,onValue:o,ref:d}),i&&Object(v.jsx)("span",{children:i})]})})}D.defaultProps={allowFloat:!1,width:80,widthUnit:"px",disable:!1};var R,E,T=D;!function(e){e.ORIGINAL="Original",e.RESIZE="Resize",e.CROP="Crop"}(R||(R={})),function(e){e.ddim="ddim",e.plms="plms"}(E||(E={}));var F,H,Z=function(){var e=Object(o.d)(ce),t=Object(s.a)(e,2),n=t[0],a=t[1];if(!n.enabled)return Object(v.jsx)(v.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})},l=function(e){var t=0===e.length?0:parseInt(e,10);a({hdStrategyCropMargin:t})},u=function(){return Object(v.jsxs)("div",{children:["Use original picture, suitable for picture size below 2K. Try"," ",Object(v.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(R.RESIZE)},children:"Resize"})," or ",Object(v.jsx)("div",{tabIndex:0,role:"button",className:"inline-tip",onClick:function(){return c(R.CROP)},children:"Crop"})," ","if you didn't get good results or have GPU memory issue."]})};return Object(v.jsx)(z,{className:"hd-setting-block",title:"High Resolution Strategy",input:Object(v.jsx)(x,{width:80,value:n.hdStrategy,options:Object.values(R),onChange:function(e){return c(e)}}),optionDesc:function(){switch(n.hdStrategy){case R.ORIGINAL:return u();case R.CROP:return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("div",{children:"Crop masking area from the original image to do inpainting."}),Object(v.jsx)(T,{title:"Trigger size",value:"".concat(n.hdStrategyCropTrigerSize),suffix:"pixel",onValue:i}),Object(v.jsx)(T,{title:"Crop margin",value:"".concat(n.hdStrategyCropMargin),suffix:"pixel",onValue:l})]});case R.RESIZE:return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)("div",{children:"Resize the longer side of the image to a specific size, then do inpainting on the resized image."}),Object(v.jsx)(T,{title:"Size limit",value:"".concat(n.hdStrategyResizeLimit),suffix:"pixel",onValue:r})]});default:return u()}}()})};!function(e){e.LAMA="lama",e.LDM="ldm",e.ZITS="zits",e.MAT="mat",e.FCF="fcf",e.SD14="sd1.4"}(H||(H={}));var A,P,V=Object(o.b)({key:"fileState",default:void 0}),W=Object(o.b)({key:"appState",default:{disableShortCuts:!1,isInpainting:!1}}),B=Object(o.b)({key:"promptState",default:""}),U=Object(o.c)({key:"isInpainting",get:function(e){return(0,e.get)(W).isInpainting},set:function(e,t){var n=e.get,a=e.set,c=n(W);a(W,Object(h.a)(Object(h.a)({},c),{},{isInpainting:t}))}}),Y=Object(o.b)({key:"croperState",default:{x:0,y:0,width:512,height:512}}),X=Object(o.c)({key:"croperX",get:function(e){return(0,e.get)(Y).x},set:function(e,t){var n=e.get,a=e.set,c=n(Y);a(Y,Object(h.a)(Object(h.a)({},c),{},{x:t}))}}),G=Object(o.c)({key:"croperY",get:function(e){return(0,e.get)(Y).y},set:function(e,t){var n=e.get,a=e.set,c=n(Y);a(Y,Object(h.a)(Object(h.a)({},c),{},{y:t}))}}),K=Object(o.c)({key:"croperHeight",get:function(e){return(0,e.get)(Y).height},set:function(e,t){var n=e.get,a=e.set,c=n(Y);a(Y,Object(h.a)(Object(h.a)({},c),{},{height:t}))}}),_=Object(o.c)({key:"croperWidth",get:function(e){return(0,e.get)(Y).width},set:function(e,t){var n=e.get,a=e.set,c=n(Y);a(Y,Object(h.a)(Object(h.a)({},c),{},{width:t}))}}),$=Object(o.b)({key:"toastState",default:{open:!1,desc:"",state:"default",duration:3e3}}),J=Object(o.b)({key:"shortcutsState",default:!1}),Q=(F={},Object(b.a)(F,H.LAMA,{hdStrategy:R.RESIZE,hdStrategyResizeLimit:2048,hdStrategyCropTrigerSize:2048,hdStrategyCropMargin:128,enabled:!0}),Object(b.a)(F,H.LDM,{hdStrategy:R.CROP,hdStrategyResizeLimit:1080,hdStrategyCropTrigerSize:1080,hdStrategyCropMargin:128,enabled:!0}),Object(b.a)(F,H.ZITS,{hdStrategy:R.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:1024,hdStrategyCropMargin:128,enabled:!0}),Object(b.a)(F,H.MAT,{hdStrategy:R.CROP,hdStrategyResizeLimit:1024,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),Object(b.a)(F,H.FCF,{hdStrategy:R.CROP,hdStrategyResizeLimit:512,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!1}),Object(b.a)(F,H.SD14,{hdStrategy:R.ORIGINAL,hdStrategyResizeLimit:768,hdStrategyCropTrigerSize:512,hdStrategyCropMargin:128,enabled:!0}),F);!function(e){e.ddim="ddim",e.pndm="pndm"}(A||(A={})),function(e){e.text2img="text2img",e.img2img="img2img",e.inpainting="inpainting"}(P||(P={}));var q,ee={show:!1,showCroper:!1,downloadMask:!1,graduallyInpainting:!0,runInpaintingManually:!1,model:H.LAMA,hdSettings:Q,ldmSteps:25,ldmSampler:E.plms,zitsWireframe:!0,sdMaskBlur:5,sdMode:P.inpainting,sdStrength:.75,sdSteps:50,sdGuidanceScale:7.5,sdSampler:A.ddim,sdSeed:42,sdSeedFixed:!0,sdNumSamples:1},te="settingsState3",ne=Object(o.b)({key:te,default:ee,effects:[(q=te,function(e){var t=e.setSelf,n=e.onSet,a=localStorage.getItem(q);if(null!=a){var c=JSON.parse(a);c.show=!1,t(p.a.merge(p.a.cloneDeep(ee),c))}n((function(e,t,n){return n?localStorage.removeItem(q):localStorage.setItem(q,JSON.stringify(e))}))})]}),ae=Object(o.c)({key:"seed",get:function(e){return(0,e.get)(ne).sdSeed},set:function(e,t){var n=e.get,a=e.set,c=n(ne);a(ne,Object(h.a)(Object(h.a)({},c),{},{sdSeed:t}))}}),ce=Object(o.c)({key:"hdSettings",get:function(e){var t=(0,e.get)(ne);return t.hdSettings[t.model]},set:function(e,t){var n=e.get,a=e.set,c=n(ne),r=c.hdSettings[c.model],i=Object(h.a)(Object(h.a)({},r),t);a(ne,Object(h.a)(Object(h.a)({},c),{},{hdSettings:Object(h.a)(Object(h.a)({},c.hdSettings),{},Object(b.a)({},c.model,i))}))}}),re=Object(o.c)({key:"isSD",get:function(e){return(0,e.get)(ne).model===H.SD14}}),ie=Object(o.c)({key:"runManuallyState",get:function(e){var t=e.get,n=t(ne),a=t(re);return n.runInpaintingManually||a}}),oe=n(7),se=function(){var e=Object(a.useState)(window.innerWidth),t=Object(s.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 le(e){var t=e.onSelection,n=Object(a.useState)(!1),c=Object(s.a)(n,2),r=c[0],i=c[1],o=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(o,1)[0],u=se();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 p(e){return O.apply(this,arguments)}function O(){return(O=Object(j.a)(d.a.mark((function e(t){var n,a,c,r,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],a=[],c=0;c<t.length;c+=1)a.push(t[c].webkitGetAsEntry());case 3:if(!(a.length>0)){e.next=23;break}if(!(null===(r=a.shift())||void 0===r?void 0:r.isFile)){e.next=12;break}return e.next=8,h(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=oe.a,e.next=18,g(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 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(oe.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,p(t.dataTransfer.items);case 3:n=e.sent,i(!1),b(n[0]);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return Object(v.jsx)("label",{htmlFor:l,className:"file-select-label",children:Object(v.jsxs)("div",{className:["file-select-container",r?"file-select-label-hover":""].join(" "),onDrop:function(e){return y.apply(this,arguments)},onDragOver:function(e){e.stopPropagation(),e.preventDefault(),i(!0)},onDragLeave:function(){return i(!1)},children:[Object(v.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(v.jsx)("p",{className:"file-select-message",children:"desktop"===u?"Click here or drag an image file":"Tap here to load your picture"})]})})}var ue=function(){var e=Object(o.f)(V);return Object(v.jsxs)("div",{className:"landing-page",children:[Object(v.jsxs)("h1",{children:["Image inpainting powered by \ud83e\udd99",Object(v.jsx)("a",{href:"https://github.com/saic-mdal/lama",children:"LaMa"})]}),Object(v.jsx)("div",{className:"landing-file-selector",children:Object(v.jsx)(le,{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)}}()})})]})},de=Object(o.b)({key:"themeState",default:"light"}),je=function(){var e=Object(o.d)(de),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(v.jsx)("div",{className:"theme-toggle-ui",children:Object(v.jsx)("div",{className:"theme-btn",onClick:function(){c("light"===n?"dark":"light")},role:"button",tabIndex:0,"aria-hidden":"true",children:"light"===n?Object(v.jsx)(O.h,{}):Object(v.jsx)(O.i,{style:{color:"#ffcc00"}})})})},be=n(51),he=n(76),fe=n(53),pe=n(77);function Oe(e){for(var t=e.split(",")[0].split(":")[1].split(";")[0],n=atob(e.split(",")[1]),a=[],c=0;c<n.length;c+=1)a.push(n.charCodeAt(c));return new Blob([new Uint8Array(a)],{type:t})}function ge(e,t){return new Promise((function(n,a){var c=e.src,r=e;r.onload=n,r.onerror=function(e){r.src=c,a(e)},r.src=t}))}function ve(e){return 1===e.nativeEvent.button}function me(e,t,n){return fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],t,{type:n})}))}var xe="".concat("");function we(e,t,n,a,c,r,i){return ye.apply(this,arguments)}function ye(){return(ye=Object(j.a)(d.a.mark((function e(t,n,a,c,r,i,o){var s,l,u,j,b,h;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(s=new FormData).append("image",t),l=Oe(n),s.append("mask",l),u=a.hdSettings[a.model],s.append("ldmSteps",a.ldmSteps.toString()),s.append("ldmSampler",a.ldmSampler.toString()),s.append("zitsWireframe",a.zitsWireframe.toString()),s.append("hdStrategy",u.hdStrategy),s.append("hdStrategyCropMargin",u.hdStrategyCropMargin.toString()),s.append("hdStrategyCropTrigerSize",u.hdStrategyCropTrigerSize.toString()),s.append("hdStrategyResizeLimit",u.hdStrategyResizeLimit.toString()),s.append("prompt",void 0===r?"":r),s.append("croperX",c.x.toString()),s.append("croperY",c.y.toString()),s.append("croperHeight",c.height.toString()),s.append("croperWidth",c.width.toString()),s.append("useCroper",a.showCroper?"true":"false"),s.append("sdMaskBlur",a.sdMaskBlur.toString()),s.append("sdStrength",a.sdStrength.toString()),s.append("sdSteps",a.sdSteps.toString()),s.append("sdGuidanceScale",a.sdGuidanceScale.toString()),s.append("sdSampler",a.sdSampler.toString()),s.append("sdSeed",o?o.toString():"-1"),void 0===i?s.append("sizeLimit","1080"):s.append("sizeLimit",i),e.prev=25,e.next=28,fetch("".concat(xe,"/inpaint"),{method:"POST",body:s});case 28:if(!(j=e.sent).ok){e.next=35;break}return e.next=32,j.blob();case 32:return b=e.sent,h=j.headers.get("x-seed"),e.abrupt("return",{blob:URL.createObjectURL(b),seed:h});case 35:e.next=40;break;case 37:throw e.prev=37,e.t0=e.catch(25),new Error("Something went wrong on server side.");case 40:case"end":return e.stop()}}),e,null,[[25,37]])})))).apply(this,arguments)}function Se(e){var t=new FormData;return t.append("name",e),fetch("".concat(xe,"/model"),{method:"POST",body:t})}function ke(){return fetch("".concat(xe,"/model"),{method:"GET"})}var Ce=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,j=e.style;return Object(v.jsxs)("div",{role:"button","data-tooltip":i,style:j,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(v.jsx)("span",{children:t}):null]})};Ce.defaultProps={disabled:!1,border:!1};var Me=Ce;function Le(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(v.jsxs)("div",{className:"editor-brush-slider",children:[Object(v.jsx)("span",{children:c}),Object(v.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 Ne=["720","1080","2000","Original"];function Ie(e){var t=e.originalHeight,n=e.originalWidth,c=e.onChange,r=Object(a.useState)("Original"),i=Object(s.a)(r,2),o=i[0],l=i[1],u=Math.max(n,t),d=Object(a.useCallback)((function(e){if("Original"===e)return"".concat(n,"x").concat(t);var a=parseInt(e,10)/u;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,u]),j=Object(a.useCallback)((function(){for(var e=[],t=0;t<Ne.length;t+=1)"Original"===Ne[t]&&e.push(d(Ne[t])),parseInt(Ne[t],10)<u&&e.push(d(Ne[t]));return e}),[u,d]);return Object(v.jsx)(x,{width:100,autoFocusAfterClose:!1,value:d(o.toString()),options:j(),onChange:function(e){var a=e.split("x");n>t?(l(a[0]),c(parseInt(a[0],10))):(l(a[1]),c(parseInt(a[1],10)))},chevronDirection:"up"})}var ze=n(56),De=function(e,t,n,a){var c=Object(o.e)(W);return Object(ze.a)(e,t,Object(h.a)(Object(h.a)({},n),{},{enabled:!c.disableShortCuts}),a)},Re={capture:!0,passive:!1},Ee=function(e){var t=e.minHeight,n=e.minWidth,c=e.maxHeight,r=e.maxWidth,i=e.scale,l=Object(o.d)(X),u=Object(s.a)(l,2),d=u[0],j=u[1],b=Object(o.d)(G),h=Object(s.a)(b,2),f=h[0],p=h[1],O=Object(o.d)(K),g=Object(s.a)(O,2),m=g[0],x=g[1],w=Object(o.d)(_),y=Object(s.a)(w,2),S=y[0],k=y[1],C=Object(o.e)(U),M=Object(a.useState)(!1),L=Object(s.a)(M,2),N=L[0],I=L[1],z=Object(a.useState)(!1),D=Object(s.a)(z,2),R=D[0],E=D[1];Object(a.useEffect)((function(){j(Math.round((r-512)/2)),p(Math.round((c-512)/2))}),[c,r,t,n]);var T=Object(a.useState)({initX:0,initY:0,initHeight:0,initWidth:0,startResizeX:0,startResizeY:0,ord:"top"}),F=Object(s.a)(T,2),H=F[0],Z=F[1],A=function(){console.log("focus")},P=function(e,n){return e>0&&n>t&&e+n<=c},V=function(e,t){return e>0&&t>n&&e+t<=r},W=function(e){if(!C){var t=e.clientX,n=e.clientY,a=Math.round((n-H.startResizeY)/i),c=Math.round((t-H.startResizeX)/i),r=function(){var e=H.initHeight-a,t=H.initY+a;P(t,e)&&(x(e),p(t))},o=function(){var e=H.initHeight+a;P(H.initY,e)&&x(e)},s=function(){var e=H.initWidth-c,t=H.initX+c;V(t,e)&&(k(e),j(t))},l=function(){var e=H.initWidth+c;V(H.initX,e)&&k(e)};if(N)switch(H.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(R){var u=H.initX+c,d=H.initY+a;V(u,H.initWidth)&&P(d,H.initHeight)&&(j(u),p(d))}}},B=function(e){N&&I(!1),R&&E(!1)};Object(a.useEffect)((function(){if(N||R)return document.addEventListener("pointermove",W,Re),document.addEventListener("pointerup",B,Re),document.addEventListener("pointercancel",B,Re),function(){document.removeEventListener("pointermove",W,Re),document.removeEventListener("pointerup",B,Re),document.removeEventListener("pointercancel",B,Re)}}),[N,R,S,m,H]);var Y=function(e){var t=e.target.dataset.ord;t&&(I(!0),Z({initX:d,initY:f,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:t}))},$=function(e){E(!0),Z({initX:d,initY:f,initHeight:m,initWidth:S,startResizeX:e.clientX,startResizeY:e.clientY,ord:""})};return Object(v.jsx)("div",{className:"croper-wrapper",children:Object(v.jsxs)("div",{className:"croper",style:{height:m,width:S,left:d,top:f},children:[Object(v.jsx)("div",{className:"crop-border",style:{height:m,width:S,outlineWidth:"".concat(2/i,"px")}}),Object(v.jsx)("div",{className:"info-bar",onPointerDown:$,style:{transform:"scale(".concat(1/i,")"),top:"".concat(10/i,"px"),left:"".concat(10/i,"px")},children:Object(v.jsxs)("div",{className:"crop-size",children:[S," x ",m]})}),Object(v.jsxs)("div",{className:"drag-elements",onFocus:A,onPointerDown:Y,children:[Object(v.jsx)("div",{className:"drag-bar ord-top","data-ord":"top",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-right","data-ord":"right",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-bottom","data-ord":"bottom",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-bar ord-left","data-ord":"left",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-topleft","data-ord":"topleft","aria-label":"topleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-topright","data-ord":"topright","aria-label":"topright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottomleft","data-ord":"bottomleft","aria-label":"bottomleft",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottomright","data-ord":"bottomright","aria-label":"bottomright",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-top","data-ord":"top","aria-label":"top",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-right","data-ord":"right","aria-label":"right",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-bottom","data-ord":"bottom","aria-label":"bottom",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}}),Object(v.jsx)("div",{className:"drag-handle ord-left","data-ord":"left","aria-label":"left",tabIndex:0,role:"button",style:{transform:"scale(".concat(1/i,")")}})]})]})})},Te=n(54),Fe="prompt",He=Object(Te.a)(),Ze="#ffcc00bb";function Ae(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ze;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 Pe(e){var t=e.nativeEvent;return{x:t.offsetX,y:t.offsetY}}function Ve(e){var t=e.file,n=Object(o.e)(B),c=Object(o.e)(ne),r=Object(o.d)(ae),i=Object(s.a)(r,2),l=(i[0],i[1]),u=Object(o.e)(Y),b=Object(o.d)($),h=Object(s.a)(b,2),f=(h[0],h[1]),p=Object(o.d)(U),g=Object(s.a)(p,2),m=g[0],x=g[1],w=Object(o.e)(ie),y=Object(o.e)(re),S=Object(a.useState)(40),k=Object(s.a)(S,2),C=k[0],M=k[1],L=function(e){var t=Object(a.useState)(new Image),n=Object(s.a)(t,1)[0],c=Object(a.useState)(!1),r=Object(s.a)(c,2),i=r[0],o=r[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,i]}(t),N=Object(s.a)(L,2),I=N[0],z=N[1],D=Object(a.useState)([]),R=Object(s.a)(D,2),E=R[0],T=R[1],F=Object(a.useState)(),H=Object(s.a)(F,2),Z=H[0],A=H[1],P=Object(a.useState)((function(){return document.createElement("canvas")})),V=Object(s.a)(P,1)[0],W=Object(a.useState)([]),X=Object(s.a)(W,2),G=X[0],K=X[1],_=Object(a.useState)([]),J=Object(s.a)(_,2),Q=J[0],q=J[1],ee=Object(a.useState)([]),te=Object(s.a)(ee,2),ce=te[0],se=te[1],le=Object(a.useState)({x:-1,y:-1}),ue=Object(s.a)(le,2),de=ue[0],je=de.x,Oe=de.y,xe=ue[1],ye=Object(a.useState)(!1),Se=Object(s.a)(ye,2),ke=Se[0],Ce=Se[1],Ne=Object(a.useState)(!1),ze=Object(s.a)(Ne,2),Re=ze[0],Te=ze[1],Ze=Object(a.useState)(!1),Ve=Object(s.a)(Ze,2),We=Ve[0],Be=Ve[1],Ue=Object(a.useState)(!1),Ye=Object(s.a)(Ue,2),Xe=Ye[0],Ge=Ye[1],Ke=Object(a.useState)(1),_e=Object(s.a)(Ke,2),$e=_e[0],Je=_e[1],Qe=Object(a.useState)(!1),qe=Object(s.a)(Qe,2),et=qe[0],tt=qe[1],nt=Object(a.useState)(1),at=Object(s.a)(nt,2),ct=at[0],rt=at[1],it=Object(a.useState)(1080),ot=Object(s.a)(it,2),st=ot[0],lt=ot[1],ut=Object(he.a)(),dt=ut.width/2,jt=ut.height/2,bt=Object(a.useRef)(),ht=Object(a.useState)(!1),ft=Object(s.a)(ht,2),pt=ft[0],Ot=ft[1],gt=Object(a.useState)(!1),vt=Object(s.a)(gt,2),mt=vt[0],xt=vt[1],wt=Object(a.useState)(!1),yt=Object(s.a)(wt,2),St=yt[0],kt=yt[1],Ct=Object(a.useState)(0),Mt=Object(s.a)(Ct,2),Lt=Mt[0],Nt=Mt[1],It=Object(a.useState)([]),zt=Object(s.a)(It,2),Dt=zt[0],Rt=zt[1],Et=Object(a.useState)([]),Tt=Object(s.a)(Et,2),Ft=Tt[0],Ht=Tt[1],Zt=Object(a.useState)([]),At=Object(s.a)(Zt,2),Pt=At[0],Vt=At[1],Wt=Object(a.useCallback)((function(e,t){Z&&(Z.clearRect(0,0,Z.canvas.width,Z.canvas.height),Z.drawImage(e,0,0,I.naturalWidth,I.naturalHeight),Ae(Z,t))}),[Z,I]),Bt=Object(a.useCallback)((function(e){if(!(null===Z||void 0===Z?void 0:Z.canvas.width)||!(null===Z||void 0===Z?void 0:Z.canvas.height))throw new Error("canvas has invalid size");V.width=null===Z||void 0===Z?void 0:Z.canvas.width,V.height=null===Z||void 0===Z?void 0:Z.canvas.height;var t=V.getContext("2d");if(!t)throw new Error("could not retrieve mask canvas");e.forEach((function(e){Ae(t,e,"white")}))}),[Z,V]),Ut=Object(a.useCallback)((function(){return 0!==ce.length}),[ce]),Yt=Object(a.useCallback)((function(e){0===E.length?Wt(I,e):Wt(E[E.length-1],e)}),[I,E,Wt]),Xt=Object(a.useCallback)(function(){var e=Object(j.a)(d.a.mark((function e(n,a){var r,i,o,s,j,b,h,p,O,g,v,m,w;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(console.log("runInpainting"),r=[],!0!==a){e.next=8;break}if(0!==Q.length){e.next=5;break}return e.abrupt("return");case 5:r=Q,e.next=12;break;case 8:if(Ut()){e.next=10;break}return e.abrupt("return");case 10:q(ce),r=ce;case 12:if(i=[].concat(Object(oe.a)(G),[r]),se([]),xt(!1),x(!0),c.graduallyInpainting?Bt([r]):Bt(i),o=t,!0!==c.graduallyInpainting){e.next=33;break}if(!0!==a){e.next=27;break}if(!(E.length>1)){e.next=25;break}return s=E[E.length-2],e.next=24,me(s.currentSrc,t.name,t.type);case 24:o=e.sent;case 25:e.next=33;break;case 27:if(!(E.length>0)){e.next=33;break}return console.info("gradually inpainting on last result"),j=E[E.length-1],e.next=32,me(j.currentSrc,t.name,t.type);case 32:o=e.sent;case 33:return b=c.sdSeedFixed?c.sdSeed:-1,e.prev=34,e.next=37,we(o,V.toDataURL(),c,u,n,st.toString(),b);case 37:if(h=e.sent){e.next=40;break}throw new Error("empty response");case 40:return p=h.blob,O=h.seed,console.log(O),console.log(c.sdSeedFixed),O&&!c.sdSeedFixed&&l(parseInt(O,10)),g=new Image,e.next=47,ge(g,p);case 47:!0===a?(v=E.slice(0,-1),m=[].concat(Object(oe.a)(v),[g]),T(m)):(w=[].concat(Object(oe.a)(E),[g]),T(w)),Wt(g,[]),K(i),$t(),e.next=57;break;case 53:e.prev=53,e.t0=e.catch(34),f({open:!0,desc:e.t0.message?e.t0.message:e.t0.toString(),state:"error",duration:4e3}),Yt([]);case 57:x(!1);case 58:case"end":return e.stop()}}),e,null,[[34,53]])})));return function(t,n){return e.apply(this,arguments)}}(),[G,ce,V,c.graduallyInpainting,c,u,st,n,Yt,Ut,Bt]);Object(a.useEffect)((function(){return He.on(Fe,(function(){Ut()?Xt(n):0!==Q.length?Xt(n,!0):f({open:!0,desc:"Please draw mask on picture",state:"error",duration:1500})})),function(){He.off(Fe)}}),[Ut,Xt,prompt]);var Gt=function(){return 0!==E.length},Kt=function(e){return"Control"===e.key||"Meta"===e.key};Object(fe.a)(Kt,(function(){St&&(m||(kt(!1),w||Xt()))}),{event:"keyup"},[m,St,Ut]),Object(fe.a)(Kt,(function(){m||kt(!0)}),{event:"keydown"},[m]),Object(a.useEffect)((function(){if(z){var e=ut.width/I.naturalWidth,t=(ut.height-200)/I.naturalHeight,n=1;if((e<1||t<1)&&(n=Math.min(e,t)),rt(n),Je(n),(null===Z||void 0===Z?void 0:Z.canvas)&&(Z.canvas.width=I.naturalWidth,Z.canvas.height=I.naturalHeight,Yt([])),!pt){var a;null===(a=bt.current)||void 0===a||a.centerView(n,1),Ot(!0);var c=Math.max(I.width,I.height);lt(c)}}}),[null===Z||void 0===Z?void 0:Z.canvas,bt,I,z,ut,pt,Yt]);var _t=Object(a.useCallback)((function(){if(ct&&I&&ut){var e=bt.current;if(e){var t=(ut.width-I.width*ct)/2,n=(ut.height-I.height*ct)/2;e.setTransform(t,n,ct,200,"easeOutQuad"),e.state.scale=ct,Je(ct),tt(!1)}}}),[bt,ut,I,I.width,ut.height,ct]),$t=function(){Ht([]),Vt([]),Rt([])};Object(a.useEffect)((function(){return window.addEventListener("resize",(function(){_t()})),function(){window.removeEventListener("resize",(function(){_t()}))}}),[ut,_t]);Object(fe.a)("Escape",(function(){m||(mt||St?(xt(!1),se([]),Yt([])):_t())}),{event:"keydown"},[mt,m,St,_t,Yt]);var Jt=Object(a.useCallback)((function(){if(0!==ce.length){q([]);var e=ce.pop(),t=[].concat(Object(oe.a)(Ft),[e]);Ht(t);var n=Object(oe.a)(ce);se(n),Yt(n)}}),[ce,Ft,Yt]),Qt=Object(a.useCallback)((function(){if(E.length){var e=G.pop();Vt([].concat(Object(oe.a)(Pt),[e])),Ht([]),K(Object(oe.a)(G)),se([]),xt(!1);var t=E.pop();Rt([].concat(Object(oe.a)(Dt),[t]));var n=Object(oe.a)(E);T(n),0===n.length?Wt(I,[]):Wt(n[n.length-1],[])}}),[Wt,E,Dt,Pt,G,I]),qt=function(){w&&0!==ce.length?Jt():Qt()};Object(fe.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)}),qt,void 0,[Jt,Qt,y]);var en=Object(a.useCallback)((function(){if(0!==Ft.length){var e=Ft.pop();Ht(Object(oe.a)(Ft));var t=[].concat(Object(oe.a)(ce),[e]);se(t),Yt(t)}}),[ce,Ft,Yt]),tn=Object(a.useCallback)((function(){if(0!==Dt.length){var e=Pt.pop();Vt(Object(oe.a)(Pt)),K([].concat(Object(oe.a)(G),[e])),se([]),xt(!1);var t=Dt.pop(),n=[].concat(Object(oe.a)(E),[t]);T(n),Wt(n[n.length-1],[])}}),[Wt,E,Dt,Pt,G,I]),nn=function(){w&&0!==Ft.length?en():tn()};Object(fe.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)}),nn,void 0,[en,tn,y]);Object(pe.a)("Tab",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Gt()&&Ge((function(){return window.setTimeout((function(){Nt(100)}),10),!0}))}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Gt()&&(Nt(0),window.setTimeout((function(){Ge(!1)}),350))}));var an=function(e){e===ke||We||Ce(e)},cn=Object(a.useCallback)((function(){return We?"grab":ke?"none":void 0}),[ke,We]);De("[",(function(){M((function(e){return e>10?e-10:e<=10&&e>0?e-5:e}))})),De("]",(function(){M((function(e){return e+10}))})),De("shift+r",(function(){w&&Ut()&&Xt()}),{},[w]),Object(pe.a)(" ",(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ce(!1),Be(!0)}),(function(e){null===e||void 0===e||e.preventDefault(),null===e||void 0===e||e.stopPropagation(),Ce(!0),Be(!1)}));var rn=function(e,t){var n=function(){var e,t,n=ct;return void 0!==(null===(e=bt.current)||void 0===e?void 0:e.state.scale)&&(n=null===(t=bt.current)||void 0===t?void 0:t.state.scale),n}();return{width:"".concat(C*n,"px"),height:"".concat(C*n,"px"),left:"".concat(e,"px"),top:"".concat(t,"px"),transform:"translate(-50%, -50%)"}};return Object(v.jsxs)("div",{className:"editor-container","aria-hidden":"true",onMouseMove:function(e){var t=e.nativeEvent;xe({x:t.pageX,y:t.pageY})},onMouseUp:function(e){(ve(e)&&Be(!1),We)||I.src&&(null===Z||void 0===Z?void 0:Z.canvas)&&(m||mt&&(St||w?xt(!1):Xt()))},children:[Object(v.jsx)(be.b,{ref:function(e){e&&(bt.current=e)},panning:{disabled:!We,velocityDisabled:!0},wheel:{step:.05},centerZoomedOut:!0,alignmentAnimation:{disabled:!0},limitToBounds:!1,doubleClick:{disabled:!0},initialScale:ct,minScale:ct,onPanning:function(e){et||tt(!0)},onZoom:function(e){Je(e.state.scale)},children:Object(v.jsxs)(be.a,{contentClass:m?"editor-canvas-loading":"",contentStyle:{visibility:pt?"visible":"hidden"},children:[Object(v.jsxs)("div",{className:"editor-canvas-container",children:[Object(v.jsx)("canvas",{className:"editor-canvas",style:{cursor:cn(),clipPath:"inset(0 ".concat(Lt,"% 0 0)"),transition:"clip-path 350ms ease-in-out"},onContextMenu:function(e){e.preventDefault()},onMouseOver:function(){an(!0),Te(!1)},onFocus:function(){return an(!0)},onMouseLeave:function(){return an(!1)},onMouseDown:function(e){if(!We&&(I.src&&(null===Z||void 0===Z?void 0:Z.canvas)&&!m&&!function(e){return 2===e.nativeEvent.button}(e)))if(ve(e))Be(!0);else if(!(y&&c.showCroper&&(t=Pe(e),t.x<u.x||t.y<u.y||t.x>u.x+u.width||t.y>u.y+u.height))){var t;xt(!0);var n=[];(St||w)&&(n=Object(oe.a)(ce)),n.push({size:C,pts:[Pe(e)]}),se(n),Yt(n)}},onMouseMove:function(e){if(!We&&mt&&0!==ce.length){var t=Object(oe.a)(ce);t[t.length-1].pts.push(Pe(e)),se(t),Yt(t)}},ref:function(e){if(e&&!Z){var t=e.getContext("2d");t&&A(t)}}}),Object(v.jsxs)("div",{className:"original-image-container",style:{width:"".concat(I.naturalWidth,"px"),height:"".concat(I.naturalHeight,"px")},children:[Xe&&Object(v.jsx)("div",{className:"editor-slider",style:{marginRight:"".concat(Lt,"%")}}),Object(v.jsx)("img",{className:"original-image",src:I.src,alt:"original",style:{width:"".concat(I.naturalWidth,"px"),height:"".concat(I.naturalHeight,"px")}})]})]}),c.showCroper?Object(v.jsx)(Ee,{maxHeight:I.naturalHeight,maxWidth:I.naturalWidth,minHeight:Math.min(256,I.naturalHeight),minWidth:Math.min(256,I.naturalWidth),scale:$e}):Object(v.jsx)(v.Fragment,{})]})}),ke&&!m&&!We&&Object(v.jsx)("div",{className:"brush-shape",style:rn(je,Oe)}),Re&&Object(v.jsx)("div",{className:"brush-shape",style:rn(dt,jt)}),Object(v.jsxs)("div",{className:"editor-toolkit-panel",children:[y?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(Ie,{onChange:function(e){lt(e)},originalWidth:I.naturalWidth,originalHeight:I.naturalHeight}),Object(v.jsx)(Le,{label:"Brush",min:10,max:150,value:C,onChange:function(e){M(e),Re||(Te(!0),window.setTimeout((function(){Te(!1)}),1e4))},onClick:function(){return Te(!1)}}),Object(v.jsxs)("div",{className:"editor-toolkit-btns",children:[Object(v.jsx)(Me,{toolTip:"Reset Zoom & Pan",tooltipPosition:"top",icon:Object(v.jsx)(O.a,{}),disabled:$e===ct&&!1===et,onClick:_t}),Object(v.jsx)(Me,{toolTip:"Undo",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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:qt,disabled:function(){if(m)return!0;if(E.length>0)return!1;if(w){if(0===ce.length)return!0}else if(0===E.length)return!0;return!1}()}),Object(v.jsx)(Me,{toolTip:"Redo",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"19",height:"9",viewBox:"0 0 19 9",fill:"none",xmlns:"http://www.w3.org/2000/svg",transform:"scale(-1,1)",children:Object(v.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:nn,disabled:function(){if(m)return!0;if(Dt.length>0)return!1;if(w){if(0===Ft.length)return!0}else if(0===Dt.length)return!0;return!1}()}),Object(v.jsx)(Me,{toolTip:"Show Original",tooltipPosition:"top",icon:Object(v.jsx)(O.g,{}),className:Xe?"eyeicon-active":"",onDown:function(e){e.preventDefault(),Ge((function(){return window.setTimeout((function(){Nt(100)}),10),!0}))},onUp:function(){Nt(0),window.setTimeout((function(){Ge(!1)}),350)},disabled:0===E.length}),Object(v.jsx)(Me,{toolTip:"Save Image",tooltipPosition:"top",icon:Object(v.jsx)(O.e,{}),disabled:!E.length,onClick:function(){var e=t.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)}(E[E.length-1].currentSrc,e),c.downloadMask){var n=t.name.replace(/(\.[\w\d_-]+)$/i,"_mask$1");n=n.replace(/\.[^/.]+$/,".jpg"),Bt(G);var a=document.createElement("a");a.download=n,a.href=V.toDataURL("image/jpeg"),a.click()}}}),c.runInpaintingManually&&Object(v.jsx)(Me,{toolTip:"Run Inpainting",tooltipPosition:"top",icon:Object(v.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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:!Ut()||m,onClick:function(){!m&&Ut()&&Xt()}})]})]})]})}var We=n(28),Be=c.a.forwardRef((function(e,t){var n=e.show,a=e.children,c=e.onClose,r=e.className,i=e.title,l=Object(o.d)(W),u=Object(s.a)(l,2),d=(u[0],u[1]);return Object(v.jsx)(We.d,{open:n,onOpenChange:function(e){e||(null===c||void 0===c||c(),d((function(e){return Object(h.a)(Object(h.a)({},e),{},{disableShortCuts:!1})})))},children:Object(v.jsxs)(We.c,{children:[Object(v.jsx)(We.b,{className:"modal-mask"}),Object(v.jsxs)(We.a,{ref:t,className:"modal ".concat(r),children:[Object(v.jsxs)("div",{className:"modal-header",children:[Object(v.jsx)(We.e,{children:i}),Object(v.jsx)(Me,{icon:Object(v.jsx)(O.k,{}),onClick:c})]}),a]})]})})}));function Ue(e){var t=e.content,n=e.keys;return Object(v.jsxs)("div",{className:"shortcut-option",children:[Object(v.jsx)("div",{className:"shortcut-description",children:t}),Object(v.jsx)("div",{style:{display:"flex",justifySelf:"end",gap:"8px"},children:n.map((function(e,t){return Object(v.jsx)("div",{className:"shortcut-key",children:e},e)}))})]})}var Ye=/macintosh|mac os x/i.test(navigator.userAgent),Xe=(/windows|win32/i.test(navigator.userAgent),Ye?"Cmd":"Ctrl");function Ge(){var e=Object(o.d)(J),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)(Be,{onClose:function(){a(!1)},title:"Hotkeys",className:"modal-shortcuts",show:n,children:Object(v.jsxs)("div",{className:"shortcut-options",children:[Object(v.jsx)(Ue,{content:"Multi-Stroke Mask Drawing",keys:["Hold ".concat(Xe)]}),Object(v.jsx)(Ue,{content:"Cancel Mask Drawing",keys:["Esc"]}),Object(v.jsx)(Ue,{content:"Run Inpainting Manually",keys:["Shift","R"]}),Object(v.jsx)(Ue,{content:"Undo Inpainting",keys:[Xe,"Z"]}),Object(v.jsx)(Ue,{content:"Redo Inpainting",keys:[Xe,"Shift","Z"]}),Object(v.jsx)(Ue,{content:"View Original Image",keys:["Hold Tab"]}),Object(v.jsx)(Ue,{content:"Pan",keys:["Space + Drag"]}),Object(v.jsx)(Ue,{content:"Reset Zoom/Pan",keys:["Esc"]}),Object(v.jsx)(Ue,{content:"Decrease Brush Size",keys:["["]}),Object(v.jsx)(Ue,{content:"Increase Brush Size",keys:["]"]}),Object(v.jsx)(Ue,{content:"Toggle Dark Mode",keys:["Shift","D"]}),Object(v.jsx)(Ue,{content:"Toggle Hotkeys Dialog",keys:["H"]}),Object(v.jsx)(Ue,{content:"Toggle Settings Dialog",keys:["S"]})]})})}var Ke=n(52),_e=["className"],$e=["className"],Je=c.a.forwardRef((function(e,t){var n=e.className,a=Object(y.a)(e,_e);return Object(v.jsx)(Ke.a,Object(h.a)(Object(h.a)({},a),{},{ref:t,className:"switch-root ".concat(n),onKeyDown:function(e){return e.preventDefault()}}))})),Qe=c.a.forwardRef((function(e,t){var n=e.className,a=Object(y.a)(e,$e);return Object(v.jsx)(Ke.b,Object(h.a)(Object(h.a)({},a),{},{ref:t,className:"switch-thumb ".concat(n)}))})),qe=function(){var e=Object(o.d)(ne),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)(z,{title:"Manual Inpainting Mode",input:Object(v.jsx)(Je,{checked:n.runInpaintingManually,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{runInpaintingManually:e})}))},children:Object(v.jsx)(Qe,{})})})};var et=function(){var e=Object(o.d)(ne),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(e,t,n){return Object(v.jsx)("div",{style:{display:"flex",gap:"12px"},children:Object(v.jsx)(I,{content:n,children:Object(v.jsx)("a",{className:"model-desc-link",href:n,target:"_blank",rel:"noreferrer noopener",children:Object(v.jsx)("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Object(v.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"})})})})})},r=function(){return Object(v.jsxs)(v.Fragment,{children:[Object(v.jsx)(T,{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(h.a)(Object(h.a)({},e),{},{ldmSteps:t})}))}}),Object(v.jsx)(z,{className:"sub-setting-block",title:"Sampler",input:Object(v.jsx)(x,{width:80,value:n.ldmSampler,options:Object.values(E),onChange:function(e){return t=e,void a((function(e){return Object(h.a)(Object(h.a)({},e),{},{ldmSampler:t})}));var t}})})]})};return Object(v.jsx)(z,{className:"model-setting-block",title:"Model",titleSuffix:function(){switch(n.model){case H.LAMA:return c(0,0,"https://github.com/saic-mdal/lama");case H.LDM:return c(0,0,"https://github.com/CompVis/latent-diffusion");case H.ZITS:return c(0,0,"https://github.com/DQiaole/ZITS_inpainting");case H.MAT:return c(0,0,"https://github.com/fenglinglwb/MAT");case H.FCF:return c(0,0,"https://github.com/SHI-Labs/FcF-Inpainting");case H.SD14:return c(0,0,"https://github.com/CompVis/stable-diffusion");default:return Object(v.jsx)(v.Fragment,{})}}(),input:Object(v.jsx)(x,{width:80,value:n.model,options:Object.values(H),onChange:function(e){return t=e,void a((function(e){return Object(h.a)(Object(h.a)({},e),{},{model:t})}));var t}}),optionDesc:function(){switch(n.model){case H.LAMA:return;case H.LDM:return r();case H.ZITS:return Object(v.jsx)("div",{children:Object(v.jsx)(z,{className:"sub-setting-block",title:"Wireframe",desc:"Enable edge and line detect",input:Object(v.jsx)(Je,{checked:n.zitsWireframe,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{zitsWireframe:e})}))},children:Object(v.jsx)(Qe,{})})})});case H.MAT:return;case H.FCF:return Object(v.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 H.SD14:return;default:return Object(v.jsx)(v.Fragment,{})}}()})},tt=function(){var e=Object(o.d)(ne),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)(z,{title:"Download Mask",desc:"Download inpainting result and mask",input:Object(v.jsx)(Je,{checked:n.downloadMask,onCheckedChange:function(e){a((function(t){return Object(h.a)(Object(h.a)({},t),{},{downloadMask:e})}))},children:Object(v.jsx)(Qe,{})})})};function nt(e){var t=e.onClose,n=Object(o.d)(ne),a=Object(s.a)(n,2),c=a[0],r=a[1],i=Object(o.e)(re);return De("s",(function(){r((function(e){return Object(h.a)(Object(h.a)({},e),{},{show:!e.show})}))}),{},[]),Object(v.jsxs)(Be,{onClose:function(){r((function(e){return Object(h.a)(Object(h.a)({},e),{},{show:!1})})),t()},title:"Settings",className:"modal-setting",show:c.show,children:[i?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(qe,{}),Object(v.jsx)(tt,{}),Object(v.jsx)(et,{}),i?Object(v.jsx)(v.Fragment,{}):Object(v.jsx)(Z,{})]})}var at=n(36),ct=["state","desc"],rt=function(){return Object(v.jsx)("span",{className:"loading-icon",children:Object(v.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(v.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),Object(v.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),Object(v.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),Object(v.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),Object(v.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),Object(v.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),Object(v.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),Object(v.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})})},it=a.forwardRef((function(e,t){var n=e.state,a=e.desc,c=Object(y.a)(e,ct);return Object(v.jsxs)(at.b,{children:[Object(v.jsxs)(at.c,Object(h.a)(Object(h.a)({},c),{},{ref:t,className:"toast-root ".concat(n),children:[Object(v.jsx)("div",{className:"toast-icon",children:function(){switch(n){case"error":return Object(v.jsx)(O.f,{className:"error-icon"});case"success":return Object(v.jsx)(O.b,{className:"success-icon"});case"loading":return Object(v.jsx)(rt,{});default:return Object(v.jsx)(v.Fragment,{})}}()}),Object(v.jsx)(at.a,{className:"toast-desc",children:a})]})),Object(v.jsx)(at.d,{className:"toast-viewpoint"})]})}));it.defaultProps={desc:"",state:"loading"};var ot=it,st=n(35),lt=n(74),ut=function(){var e=Object(lt.a)(!0),t=Object(s.a)(e,2),n=t[0],a=t[1],c=Object(o.d)(ne),r=Object(s.a)(c,2),i=r[0],l=r[1];return Object(v.jsx)("div",{className:"side-panel",children:Object(v.jsxs)(st.c,{open:n,children:[Object(v.jsx)(st.d,{className:"btn-primary side-panel-trigger",onClick:function(){return a()},children:"Stable Diffusion"}),Object(v.jsx)(st.b,{children:Object(v.jsxs)(st.a,{className:"side-panel-content",children:[Object(v.jsx)(z,{title:"Show Croper",input:Object(v.jsx)(Je,{checked:i.showCroper,onCheckedChange:function(e){l((function(t){return Object(h.a)(Object(h.a)({},t),{},{showCroper:e})}))},children:Object(v.jsx)(Qe,{})})}),Object(v.jsx)(T,{title:"Steps",width:30,value:"".concat(i.sdSteps),desc:"Large steps result in better result, but more time-consuming",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdSteps:t})}))}}),Object(v.jsx)(T,{title:"Strength",width:30,allowFloat:!0,value:"".concat(i.sdStrength),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseFloat(e);console.log(t),l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdStrength:t})}))}}),Object(v.jsx)(T,{title:"Guidance Scale",width:30,allowFloat:!0,value:"".concat(i.sdGuidanceScale),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseFloat(e);l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdGuidanceScale:t})}))}}),Object(v.jsx)(T,{title:"Mask Blur",width:30,value:"".concat(i.sdMaskBlur),desc:"TODO",onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdMaskBlur:t})}))}}),Object(v.jsx)(z,{className:"sub-setting-block",title:"Sampler",input:Object(v.jsx)(x,{width:80,value:i.sdSampler,options:Object.values(A),onChange:function(e){var t=e;l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdSampler:t})}))}})}),Object(v.jsx)(z,{title:"Seed",input:Object(v.jsxs)("div",{style:{display:"flex",gap:0,justifyContent:"center",alignItems:"center"},children:[Object(v.jsx)(T,{title:"",width:80,value:"".concat(i.sdSeed),desc:"",disable:!i.sdSeedFixed,onValue:function(e){var t=0===e.length?0:parseInt(e,10);l((function(e){return Object(h.a)(Object(h.a)({},e),{},{sdSeed:t})}))}}),Object(v.jsx)(Je,{checked:i.sdSeedFixed,onCheckedChange:function(e){l((function(t){return Object(h.a)(Object(h.a)({},t),{},{sdSeedFixed:e})}))},style:{marginLeft:"8px"},children:Object(v.jsx)(Qe,{})})]})})]})})]})})},dt=function(e){var t=e.file,n=Object(o.d)(ne),c=Object(s.a)(n,2),r=c[0],i=c[1],l=Object(o.d)($),u=Object(s.a)(l,2),b=u[0],f=u[1],p=Object(o.e)(re),O=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,ke().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(xe,"/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}),Se(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(h.a)(Object(h.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(){ke().then((function(e){return e.text()})).then((function(e){i((function(t){return Object(h.a)(Object(h.a)({},t),{},{model:e})}))}))}),[i]),Object(v.jsxs)(v.Fragment,{children:[p?Object(v.jsx)(ut,{}):Object(v.jsx)(v.Fragment,{}),Object(v.jsx)(Ve,{file:t}),Object(v.jsx)(nt,{onClose:O}),Object(v.jsx)(Ge,{}),Object(v.jsx)(ot,Object(h.a)(Object(h.a)({},b),{},{onOpenChange:function(e){f((function(t){return Object(h.a)(Object(h.a)({},t),{},{open:e})}))}}))]})},jt=function(){var e=Object(o.d)(J),t=Object(s.a)(e,2),n=t[0],a=t[1],c=function(){a((function(e){return!e}))};return De("h",(function(){c()})),Object(v.jsx)("div",{className:"shortcuts",children:Object(v.jsx)(Me,{onClick:c,toolTip:"Hotkeys",tooltipPosition:"bottom",disabled:n,style:{border:0},icon:Object(v.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(v.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",fill:"none",stroke:"none"}),Object(v.jsxs)("g",{fill:"currentColor",children:[Object(v.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(v.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"})]})]})})})},bt=function(){var e=Object(o.d)(ne),t=Object(s.a)(e,2),n=t[0],a=t[1];return Object(v.jsx)("div",{children:Object(v.jsx)(Me,{onClick:function(){a(Object(h.a)(Object(h.a)({},n),{},{show:!n.show}))},toolTip:"Settings",tooltipPosition:"bottom",style:{border:0},icon:Object(v.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(v.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(v.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})})},ht=function(){var e=Object(o.d)(W),t=Object(s.a)(e,2),n=t[0],c=(t[1],Object(o.d)(B)),r=Object(s.a)(c,2),i=r[0],l=r[1],u=Object(a.useRef)(null),d=function(){0===i.length||n.isInpainting||He.emit(Fe)};Object(w.a)(u,(function(){(null===u||void 0===u?void 0:u.current)&&u.current.blur()}));return Object(v.jsxs)("div",{className:"prompt-wrapper",children:[Object(v.jsx)(k,{ref:u,value:i,onInput:function(e){e.preventDefault(),e.stopPropagation();var t=e.target;l(t.value)},onKeyUp:function(e){"Enter"===e.key&&d()},placeholder:"I want to repaint of..."}),Object(v.jsx)(Me,{border:!0,onClick:d,disabled:0===i.length||n.isInpainting,children:"Dream"})]})},ft=function(){var e=Object(o.d)(V),t=Object(s.a)(e,2),n=t[0],c=t[1],r=se(),i=Object(a.useState)("file-upload-".concat(Math.random().toString())),l=Object(s.a)(i,1)[0],u=Object(o.e)(re);return Object(v.jsxs)("header",{children:[Object(v.jsx)("div",{style:{visibility:n?"visible":"hidden"},children:Object(v.jsx)("label",{htmlFor:l,children:Object(v.jsxs)(Me,{icon:Object(v.jsx)(O.j,{}),style:{border:0},children:[Object(v.jsx)("input",{style:{display:"none"},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&&c(n)},accept:"image/png, image/jpeg"}),"desktop"===r?"Upload New":void 0]})})}),u&&n?Object(v.jsx)(ht,{}):Object(v.jsx)(v.Fragment,{}),Object(v.jsxs)("div",{className:"header-icons-wrapper",children:[Object(v.jsx)(je,{}),n&&Object(v.jsxs)("div",{className:"header-icons",children:[Object(v.jsx)(jt,{}),Object(v.jsx)(bt,{})]})]})]})};!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 pt=function(){var e=Object(o.d)(V),t=Object(s.a)(e,2),n=t[0],c=t[1],r=Object(o.d)(de),i=Object(s.a)(r,2),u=i[0],b=i[1],h=function(){var e=Object(a.useState)(),t=Object(s.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(j.a)(d.a.mark((function e(t){var n,a,r,i;return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=null===(n=t.headers.get("content-disposition"))||void 0===n?void 0:n.split("filename=")[1].split(";")[0],e.next=3,t.blob();case 3:(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}();Object(a.useEffect)((function(){c(h)}),[h,c]),De("shift+d",(function(){b("light"===u?"dark":"light")}),{},[u]),Object(a.useEffect)((function(){document.body.setAttribute("data-theme",u)}),[u]);var f=Object(a.useMemo)((function(){return Object(l.a)()}),[n]);return Object(v.jsxs)("div",{className:"lama-cleaner",children:[Object(v.jsx)(ft,{}),n?Object(v.jsx)(dt,{file:n},f):Object(v.jsx)(ue,{})]})};i.a.render(Object(v.jsx)(c.a.StrictMode,{children:Object(v.jsx)(o.a,{children:Object(v.jsx)(pt,{})})}),document.getElementById("root"))}},[[69,1,2]]]);