From e7d980cf4aa147471e9eb6cea13e3fa2abb1c52b Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:33:51 +0800 Subject: [PATCH] updated sdui --- embd_res/kcpp_sdui.embd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embd_res/kcpp_sdui.embd b/embd_res/kcpp_sdui.embd index e68a726ba..1de8f4ed0 100644 --- a/embd_res/kcpp_sdui.embd +++ b/embd_res/kcpp_sdui.embd @@ -506,7 +506,7 @@ gl_FragColor.rgb *= color.a; `?(s++,f[s]=0):f[s]++;f[0]>0&&(this.insertCharStyleObject(c.lineIndex,c.charIndex,f[0],h),h=h&&h.slice(f[0]+1)),s&&this.insertNewlineStyleObject(c.lineIndex,c.charIndex+f[0],s);for(var d=1;d0?this.insertCharStyleObject(c.lineIndex+d,0,f[d],h):h&&this.styles[c.lineIndex+d]&&h[0]&&(this.styles[c.lineIndex+d][0]=h[0]),h=h&&h.slice(f[d]+1);f[d]>0&&this.insertCharStyleObject(c.lineIndex+d,0,f[d],h)},setSelectionStartEndWithShift:function(a,u,h){h<=a?(u===a?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=a),this.selectionStart=h):h>a&&ha?this.selectionStart=a:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>a?this.selectionEnd=a:this.selectionEnd<0&&(this.selectionEnd=0)}})}(),t.util.object.extend(t.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown)},onMouseDown:function(o){if(!!this.canvas){this.__newClickTime=+new Date;var a=o.pointer;this.isTripleClick(a)&&(this.fire("tripleclick",o),this._stopEvent(o.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=a,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(o){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===o.x&&this.__lastPointer.y===o.y},_stopEvent:function(o){o.preventDefault&&o.preventDefault(),o.stopPropagation&&o.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(o){!this.isEditing||this.selectWord(this.getSelectionStartFromPointer(o.e))},tripleClickHandler:function(o){!this.isEditing||this.selectLine(this.getSelectionStartFromPointer(o.e))},initClicks:function(){this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler)},_mouseDownHandler:function(o){!this.canvas||!this.editable||o.e.button&&o.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(o.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(o){!this.canvas||!this.editable||o.e.button&&o.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on("mouseup",this.mouseUpHandler)},mouseUpHandler:function(o){if(this.__isMousedown=!1,!(!this.editable||this.group||o.transform&&o.transform.actionPerformed||o.e.button&&o.e.button!==1)){if(this.canvas){var a=this.canvas._activeObject;if(a&&a!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(o.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(o){var a=this.getSelectionStartFromPointer(o),u=this.selectionStart,h=this.selectionEnd;o.shiftKey?this.setSelectionStartEndWithShift(u,h,a):(this.selectionStart=a,this.selectionEnd=a),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(o){for(var a=this.getLocalPointer(o),u=0,h=0,c=0,f=0,s=0,d,v,m=0,y=this._textLines.length;m0&&(f+=this._textLines[m-1].length+this.missingNewlineOffset(m-1));d=this._getLineLeftOffset(s),h=d*this.scaleX,v=this._textLines[s],this.direction==="rtl"&&(a.x=this.width*this.scaleX-a.x+h);for(var b=0,_=v.length;b<_&&(u=h,h+=this.__charBounds[s][b].kernedWidth*this.scaleX,h<=a.x);b++)f++;return this._getNewSelectionStartFromOffset(a,u,h,f,_)},_getNewSelectionStartFromOffset:function(o,a,u,h,c){var f=o.x-a,s=u-o.x,d=s>f||s<0?0:1,v=h+d;return this.flipX&&(v=c-v),v>this._text.length&&(v=this._text.length),v}}),t.util.object.extend(t.IText.prototype,{initHiddenTextarea:function(){this.hiddenTextarea=t.document.createElement("textarea"),this.hiddenTextarea.setAttribute("autocapitalize","off"),this.hiddenTextarea.setAttribute("autocorrect","off"),this.hiddenTextarea.setAttribute("autocomplete","off"),this.hiddenTextarea.setAttribute("spellcheck","false"),this.hiddenTextarea.setAttribute("data-fabric-hiddentextarea",""),this.hiddenTextarea.setAttribute("wrap","off");var o=this._calcTextareaPosition();this.hiddenTextarea.style.cssText="position: absolute; top: "+o.top+"; left: "+o.left+"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding\uFF70top: "+o.fontSize+";",this.hiddenTextareaContainer?this.hiddenTextareaContainer.appendChild(this.hiddenTextarea):t.document.body.appendChild(this.hiddenTextarea),t.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this)),t.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this)),t.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this)),t.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this)),t.util.addListener(this.hiddenTextarea,"cut",this.copy.bind(this)),t.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this)),t.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this)),!this._clickHandlerInitialized&&this.canvas&&(t.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this)),this._clickHandlerInitialized=!0)},keysMap:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown"},keysMapRtl:{9:"exitEditing",27:"exitEditing",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorLeft",36:"moveCursorRight",37:"moveCursorRight",38:"moveCursorUp",39:"moveCursorLeft",40:"moveCursorDown"},ctrlKeysMapUp:{67:"copy",88:"cut"},ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(o){if(!!this.isEditing){var a=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(o.keyCode in a)this[a[o.keyCode]](o);else if(o.keyCode in this.ctrlKeysMapDown&&(o.ctrlKey||o.metaKey))this[this.ctrlKeysMapDown[o.keyCode]](o);else return;o.stopImmediatePropagation(),o.preventDefault(),o.keyCode>=33&&o.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}},onKeyUp:function(o){if(!this.isEditing||this._copyDone||this.inCompositionMode){this._copyDone=!1;return}if(o.keyCode in this.ctrlKeysMapUp&&(o.ctrlKey||o.metaKey))this[this.ctrlKeysMapUp[o.keyCode]](o);else return;o.stopImmediatePropagation(),o.preventDefault(),this.canvas&&this.canvas.requestRenderAll()},onInput:function(o){var a=this.fromPaste;if(this.fromPaste=!1,o&&o.stopPropagation(),!!this.isEditing){var u=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,h=this._text.length,c=u.length,f,s,d=c-h,v=this.selectionStart,m=this.selectionEnd,y=v!==m,b,_,w;if(this.hiddenTextarea.value===""){this.styles={},this.updateFromTextArea(),this.fire("changed"),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll());return}var S=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),x=v>S.selectionStart;y?(f=this._text.slice(v,m),d+=m-v):c0&&(h=this.__charBounds[o][a-1],u+=h.left+h.width),u},getDownCursorOffset:function(o,a){var u=this._getSelectionForOffset(o,a),h=this.get2DCursorLocation(u),c=h.lineIndex;if(c===this._textLines.length-1||o.metaKey||o.keyCode===34)return this._text.length-u;var f=h.charIndex,s=this._getWidthBeforeCursor(c,f),d=this._getIndexOnLine(c+1,s),v=this._textLines[c].slice(f);return v.length+d+1+this.missingNewlineOffset(c)},_getSelectionForOffset:function(o,a){return o.shiftKey&&this.selectionStart!==this.selectionEnd&&a?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(o,a){var u=this._getSelectionForOffset(o,a),h=this.get2DCursorLocation(u),c=h.lineIndex;if(c===0||o.metaKey||o.keyCode===33)return-u;var f=h.charIndex,s=this._getWidthBeforeCursor(c,f),d=this._getIndexOnLine(c-1,s),v=this._textLines[c].slice(0,f),m=this.missingNewlineOffset(c-1);return-this._textLines[c-1].length+d-v.length+(1-m)},_getIndexOnLine:function(o,a){for(var u=this._textLines[o],h=this._getLineLeftOffset(o),c=h,f=0,s,d,v=0,m=u.length;va){d=!0;var y=c-s,b=c,_=Math.abs(y-a),w=Math.abs(b-a);f=w<_?v:v-1;break}return d||(f=u.length-1),f},moveCursorDown:function(o){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",o)},moveCursorUp:function(o){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",o)},_moveCursorUpOrDown:function(o,a){var u="get"+o+"CursorOffset",h=this[u](a,this._selectionDirection==="right");a.shiftKey?this.moveCursorWithShift(h):this.moveCursorWithoutShift(h),h!==0&&(this.setSelectionInBoundaries(),this.abortCursorAnimation(),this._currentCursorOpacity=1,this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorWithShift:function(o){var a=this._selectionDirection==="left"?this.selectionStart+o:this.selectionEnd+o;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,a),o!==0},moveCursorWithoutShift:function(o){return o<0?(this.selectionStart+=o,this.selectionEnd=this.selectionStart):(this.selectionEnd+=o,this.selectionStart=this.selectionEnd),o!==0},moveCursorLeft:function(o){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",o)},_move:function(o,a,u){var h;if(o.altKey)h=this["findWordBoundary"+u](this[a]);else if(o.metaKey||o.keyCode===35||o.keyCode===36)h=this["findLineBoundary"+u](this[a]);else return this[a]+=u==="Left"?-1:1,!0;if(typeof h<"u"&&this[a]!==h)return this[a]=h,!0},_moveLeft:function(o,a){return this._move(o,a,"Left")},_moveRight:function(o,a){return this._move(o,a,"Right")},moveCursorLeftWithoutShift:function(o){var a=!0;return this._selectionDirection="left",this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(a=this._moveLeft(o,"selectionStart")),this.selectionEnd=this.selectionStart,a},moveCursorLeftWithShift:function(o){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd)return this._moveLeft(o,"selectionEnd");if(this.selectionStart!==0)return this._selectionDirection="left",this._moveLeft(o,"selectionStart")},moveCursorRight:function(o){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",o)},_moveCursorLeftOrRight:function(o,a){var u="moveCursor"+o+"With";this._currentCursorOpacity=1,a.shiftKey?u+="Shift":u+="outShift",this[u](a)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())},moveCursorRightWithShift:function(o){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd)return this._moveRight(o,"selectionStart");if(this.selectionEnd!==this._text.length)return this._selectionDirection="right",this._moveRight(o,"selectionEnd")},moveCursorRightWithoutShift:function(o){var a=!0;return this._selectionDirection="right",this.selectionStart===this.selectionEnd?(a=this._moveRight(o,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,a},removeChars:function(o,a){typeof a>"u"&&(a=o+1),this.removeStyleFromTo(o,a),this._text.splice(o,a-o),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()},insertChars:function(o,a,u,h){typeof h>"u"&&(h=u),h>u&&this.removeStyleFromTo(u,h);var c=t.util.string.graphemeSplit(o);this.insertNewStyleBlock(c,u,a),this._text=[].concat(this._text.slice(0,u),c,this._text.slice(h)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var o=t.util.toFixed,a=/ +/g;t.util.object.extend(t.Text.prototype,{_toSVG:function(){var u=this._getSVGLeftTopOffsets(),h=this._getSVGTextAndBg(u.textTop,u.textLeft);return this._wrapSVGTextAndBg(h)},toSVG:function(u){return this._createBaseSVGMarkup(this._toSVG(),{reviver:u,noStyle:!0,withShadow:!0})},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(u){var h=!0,c=this.getSvgTextDecoration(this);return[u.textBgRects.join(""),' ",u.textSpans.join(""),` `]},_getSVGTextAndBg:function(u,h){var c=[],f=[],s=u,d;this._setSVGBg(f);for(var v=0,m=this._textLines.length;v",t.util.string.escapeXml(u),""].join("")},_setSVGTextLineText:function(u,h,c,f){var s=this.getHeightOfLine(h),d=this.textAlign.indexOf("justify")!==-1,v,m,y="",b,_,w=0,S=this._textLines[h],x;f+=s*(1-this._fontSizeFraction)/this.lineHeight;for(var T=0,E=S.length-1;T<=E;T++)x=T===E||this.charSpacing,y+=S[T],b=this.__charBounds[h][T],w===0?(c+=b.kernedWidth-b.width,w+=b.width):w+=b.kernedWidth,d&&!x&&this._reSpaceAndTab.test(S[T])&&(x=!0),x||(v=v||this.getCompleteStyleDeclaration(h,T),m=this.getCompleteStyleDeclaration(h,T+1),x=t.util.hasStyleChanged(v,m,!0)),x&&(_=this._getStyleDeclaration(h,T)||{},u.push(this._createTextCharSpan(y,_,c,f)),y="",v=m,c+=w,w=0)},_pushTextBgRect:function(u,h,c,f,s,d){var v=t.Object.NUM_FRACTION_DIGITS;u.push(" `)},_setSVGTextLineBg:function(u,h,c,f){for(var s=this._textLines[h],d=this.getHeightOfLine(h)/this.lineHeight,v=0,m=0,y,b,_=this.getValueOfPropertyAt(h,0,"textBackgroundColor"),w=0,S=s.length;wthis.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(u){for(var h=0,c=0,f=0,s={},d=0;d0?(c=0,f++,h++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&d>0&&(c++,f++),s[d]={line:h,offset:c},f+=u.graphemeLines[d].length,c+=u.graphemeLines[d].length;return s},styleHas:function(u,h){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[h];c&&(h=c.line)}return a.Text.prototype.styleHas.call(this,u,h)},isEmptyStyles:function(u){if(!this.styles)return!0;var h=0,c=u+1,f,s,d=!1,v=this._styleMap[u],m=this._styleMap[u+1];v&&(u=v.line,h=v.offset),m&&(c=m.line,d=c===u,f=m.offset),s=typeof u>"u"?this.styles:{line:this.styles[u]};for(var y in s)for(var b in s[y])if(b>=h&&(!d||bc&&!E?(v.push(m),m=[],s=S,E=!0):s+=A,!E&&!d&&m.push(w),m=m.concat(b),x=d?0:this._measureWord([w],h,_),_++,E=!1,S>T&&(T=S);return N&&v.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-A+D),v},isEndOfWrapping:function(u){return!this._styleMap[u+1]||this._styleMap[u+1].line!==this._styleMap[u].line},missingNewlineOffset:function(u){return this.splitByGrapheme?this.isEndOfWrapping(u)?1:0:1},_splitTextIntoLines:function(u){for(var h=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(h.lines,this.width),f=new Array(c.length),s=0;s{const e=()=>({canvas:void 0,brush:void 0,visibleImageLayer:void 0,imageLayer:void 0,visibleDrawLayer:void 0,drawLayer:void 0,cropPreviewLayer:void 0,maskPathColor:"",maskBackgroundColor:"",imageScale:1,undoHistory:[],redoHistory:[],drawing:!1}),t=oe({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=oe({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>en().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>en().currentImageProps),g=ee({get:()=>i.value.drawing&&!r.value,set:z=>i.value.drawing=z}),o=oe(512),a=oe(512),u=oe(!1),h=oe(30),c=oe(!1),f=new Jn.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=oe("Erase"),d=oe("rgb(0, 0, 0, 1)");function v(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(z=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=z||i.value.brush.color,i.value.brush.width=h.value)}async function b({history:z,erase:M=!1,draw:L=!1}={}){if(!z||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;z.path.selectable=!1,z.path.opacity=1,z.drawPath=await Q(z.path),z.visibleDrawPath=await Q(z.path),M?(z.visibleDrawPath.globalCompositeOperation="destination-out",z.drawPath.stroke=i.value.maskBackgroundColor):(z.visibleDrawPath.globalCompositeOperation="source-over",z.drawPath.stroke=L?d.value:i.value.maskPathColor);let J=await Q(z.drawPath);J=J.scale(i.value.imageScale),J.left=J.left+z.drawPath.left*(i.value.imageScale-1),J.top=J.top+z.drawPath.top*(i.value.imageScale-1),L?(i.value.imageLayer.add(J),i.value.visibleImageLayer.addWithUpdate(z.visibleDrawPath)):(i.value.drawLayer.add(J),i.value.visibleDrawLayer.addWithUpdate(z.visibleDrawPath)),i.value.canvas.remove(z.path),v()}function _(){if(i.value.undoHistory.length===0)return;const z=i.value.undoHistory.pop();b({history:z,erase:!1,draw:g.value}),i.value.redoHistory.push(z)}function w(){if(i.value.redoHistory.length===0||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;const z=i.value.redoHistory.pop();i.value.undoHistory.push(z),g.value?(i.value.imageLayer.remove(z.drawPath),i.value.visibleImageLayer.remove(z.visibleDrawPath)):(i.value.drawLayer.remove(z.drawPath),i.value.visibleDrawLayer.remove(z.visibleDrawPath)),delete z.drawPath,delete z.visibleDrawPath,v()}function S(z){i.value.canvas=new Jn.fabric.Canvas(z,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",y(i.value.maskPathColor),i.value.canvas.on("mouse:move",I),i.value.canvas.on("path:created",ue),v()}function x(z,M,L,J){let V=J,P=J;return M>L?(z.scaleToWidth(J),V=J*(a.value/o.value)):(z.scaleToHeight(J),P=J*(o.value/a.value)),{newHeight:V,newWidth:P}}function T(z){const M=en();if(O(),z.selectable=!1,o.value=z.width,a.value=z.height,o.value>M.maxDimensions||a.value>M.maxDimensions){const{newHeight:J,newWidth:V}=x(z,o.value,a.value,M.maxDimensions);o.value=V,a.value=J}if(o.value{o.value>a.value?i.value.imageScale=o.value/L:i.value.imageScale=a.value/L,i.value.imageLayer=R({image:J,layerHeight:J.height,layerWidth:J.width})}),z.cloneAsImage(J=>{if(!i.value.canvas)return;if(o.value!==L||a.value!==L){const{newHeight:q,newWidth:Z}=x(J,o.value,a.value,L);o.value=Z,a.value=q}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=B(),i.value.visibleImageLayer=B({image:J}),i.value.drawLayer=R();const V=o.value*i.value.imageScale,P=a.value*i.value.imageScale;M.params.width=V-V%64,M.params.height=P-P%64,i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleImageLayer),i.value.canvas.add(i.value.visibleDrawLayer),i.value.canvas.add(f),c.value=!0,D(),E()})}function E(){const z=en();if(!i.value.imageLayer||!i.value.drawLayer)return;const M=i.value.imageLayer.getCenter().left-z.params.width/2,L=z.params.width,J=i.value.imageLayer.getCenter().top-z.params.height/2,V=z.params.height,P={format:"jpeg",quality:1,left:M,top:J,width:L,height:V};l.value.sourceImage=i.value.imageLayer.toDataURL(P),l.value.maskImage=i.value.redoHistory.length===0||g.value?void 0:i.value.drawLayer.toDataURL(P).split(",")[1]}let A;function D(){if(!i.value.canvas)return;const z=en();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=B({layerWidth:z.params.width/i.value.imageScale,layerHeight:z.params.height/i.value.imageScale,fill:"rgba(100, 0, 0, 0.5)"}),i.value.canvas.centerObject(i.value.cropPreviewLayer),i.value.canvas.add(i.value.cropPreviewLayer),A&&clearTimeout(A),A=setTimeout(()=>{c.value=!1,D(),A=void 0},5e3))}function N(z,M){const L="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Jn.fabric.Image.fromURL(L,J=>{J.set({height:z,width:M});const V=J.toDataURL({format:"png"});l.value.sourceImage=V,g.value=!0,T(J)})}function R({image:z,layerWidth:M,layerHeight:L}={}){const J=new Jn.fabric.Canvas(null);return J.selection=!1,J.backgroundColor=i.value.maskBackgroundColor,J.setHeight(L||a.value),J.setWidth(M||o.value),z&&J.add(z),J}function B({image:z,layerWidth:M,layerHeight:L,fill:J,abosolute:V}={}){const P=z||new Jn.fabric.Rect({width:M||o.value,height:L||a.value,left:0,top:0,fill:J||"transparent",absolutePositioned:V||!0,selectable:!1});return new Jn.fabric.Group([P],{selectable:!1,absolutePositioned:V||!0})}function O(){!i.value.canvas||(i.value.visibleImageLayer&&(i.value.canvas.remove(i.value.visibleImageLayer),i.value.visibleImageLayer=void 0),i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),i.value.imageLayer=void 0,i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.canvas.isDrawingMode=!1)}function U(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),g.value){const z=en();N(z.params.height||512,z.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=B(),i.value.drawLayer=R(),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function ne(){var M;E();const z=document.createElement("a");if(g.value){z.href="data:image/png;base64,"+((M=l.value.sourceImage)==null?void 0:M.split(",")[1]),z.download="image_drawing.png",z.click();return}z.href="data:image/png;base64,"+l.value.maskImage,z.download="image_mask.png",z.click()}async function Q(z){return new Promise((M,L)=>{try{z.clone(M)}catch(J){L(J)}})}async function ue(z){const M={path:z.path};b({history:M,erase:u.value,draw:g.value}),i.value.redoHistory.push(M)}function I(z){if(!i.value.canvas)return;const M=i.value.canvas.getPointer(z.e);f.left=M.x,f.top=M.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),g.value?(f.set("fill",d.value),y(d.value)):(f.set("fill","white"),y("white"))),f.set("radius",h.value/2),v()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:h,drawColor:d,drawing:g,imageProps:i,updateCropPreview:D,createNewCanvas:S,downloadMask:ne,resetCanvas:O,resetDrawing:U,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:N,setBrush:y,saveImages:E}});const BH={},FH={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},zH=re("g",{fill:"none"},[re("path",{d:"M11.197 2.44a1.5 1.5 0 0 1 2.121 0l4.243 4.242a1.5 1.5 0 0 1 0 2.121L9.364 17H14.5a.5.5 0 0 1 0 1H7.82a1.496 1.496 0 0 1-1.14-.437L2.437 13.32a1.5 1.5 0 0 1 0-2.121l8.76-8.76zm1.414.706a.5.5 0 0 0-.707 0L5.538 9.512l4.95 4.95l6.366-6.366a.5.5 0 0 0 0-.707L12.61 3.146zM9.781 15.17l-4.95-4.95l-1.687 1.687a.5.5 0 0 0 0 .707l4.243 4.243a.5.5 0 0 0 .707 0l1.687-1.687z",fill:"currentColor"})],-1),NH=[zH];function jH(e,t){return j(),ce("svg",FH,NH)}const VH=Yt(BH,[["render",jH]]);async function UH(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(g=>i.onload=g),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function HH(e,t){const n=e.split(";base64,"),r=t!=null?t:n[0].split(":")[1],i=window.atob(r===n[0].split(":")[1]?n[1]:(await UH(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let g=0;g{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const em=e=>(Qr("data-v-d200c279"),e=e(),ei(),e),WH=em(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),YH={key:0},XH=em(()=>re("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),KH={class:"canvas-container"},GH=em(()=>re("canvas",{id:"canvas"},null,-1)),qH={class:"action-buttons",style:{left:"10px",right:"unset"}},ZH={class:"action-buttons"},JH=Ee({__name:"CustomCanvas",setup(e){const t=en(),n=$t(),r=ys(),i=oe();async function l(o){if(!o.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const a=await d2(o.raw);t.currentImageProps.sourceImage=a,r.drawing=!1,Jn.fabric.Image.fromURL(a,r.newImage)}function g(){t.currentImageProps.sourceImage="",r.resetCanvas()}return qe(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Jn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage)}),(o,a)=>(j(),ce(ze,null,[C(t).currentImageProps.sourceImage?_e("",!0):(j(),we(C(Pp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:pe(()=>[C(t).generatorType==="Img2Img"?(j(),ce("div",YH,[XH,re("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:a[0]||(a[0]=u=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(De),{size:20,style:{"margin-right":"2px"}},{default:pe(()=>[le(u2)]),_:1}),Ne("draw something")])])):_e("",!0)]),default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),WH]),_:1},512)),yt(re("div",null,[re("div",KH,[GH,re("div",qH,[le(C(lt),{onClick:a[1]||(a[1]=u=>C(r).undoAction()),icon:C(t_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(lt),{onClick:a[2]||(a[2]=u=>C(r).redoAction()),icon:C(n_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),re("div",ZH,[le(C(lt),{onClick:a[3]||(a[3]=u=>C(r).resetDrawing()),icon:C(Sr),plain:""},null,8,["icon"]),le(C(lt),{onClick:g,icon:C(Ec),plain:""},null,8,["icon"]),le(C(lt),{onClick:a[4]||(a[4]=u=>C(r).downloadMask()),icon:C(Ls),plain:""},null,8,["icon"]),le(C(lt),{onClick:a[5]||(a[5]=u=>C(r).flipErase()),icon:C(r).erasing?C(zE):VH,plain:""},null,8,["icon"]),C(r).drawing?(j(),we(C(vB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":a[6]||(a[6]=u=>C(r).drawColor=u),"show-alpha":""},null,8,["modelValue"])):_e("",!0)]),le(C(xp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:pe(()=>[le(En,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":a[7]||(a[7]=u=>C(r).brushSize=u),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Rt,C(t).currentImageProps.sourceImage]])],64))}});const M0=Yt(JH,[["__scopeId","data-v-d200c279"]]),QH={class:"centerIcons"},eW={class:"stackedIcons"},tW=Ee({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return gx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(j(),ce("div",QH,[re("div",eW,[le(C(De),{class:"firstIcon",size:e.size},{default:pe(()=>[(j(),we(Ct(t.iconOne)))]),_:1},8,["size"]),le(C(De),{class:"secondIcon",size:e.size},{default:pe(()=>[(j(),we(Ct(t.iconTwo)))]),_:1},8,["size"])])]))}});const nW=Yt(tW,[["__scopeId","data-v-74586a39"]]),rW={key:1,style:{width:"40px"}},nu=Ee({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(j(),we(C(Or),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:pe(()=>[le(C(Ep),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:pe(()=>[e.iconTwo?(j(),we(nW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(j(),ce("div",rW,[le(C(De),{style:{width:"35px"},size:40},{default:pe(()=>[(j(),we(Ct(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const iW=4,L0=0,R0=1,aW=2;function Lo(e){let t=e.length;for(;--t>=0;)e[t]=0}const oW=0,h2=1,sW=2,lW=3,uW=258,tm=29,Tl=256,el=Tl+1+tm,io=30,nm=19,p2=2*el+1,sa=15,Lf=16,cW=7,rm=256,m2=16,g2=17,v2=18,lh=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),fW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),y2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dW=512,Nr=new Array((el+2)*2);Lo(Nr);const bs=new Array(io*2);Lo(bs);const tl=new Array(dW);Lo(tl);const nl=new Array(uW-lW+1);Lo(nl);const im=new Array(tm);Lo(im);const sc=new Array(io);Lo(sc);function Rf(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let b2,_2,w2;function Df(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const C2=e=>e<256?tl[e]:tl[256+(e>>>7)],rl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},yn=(e,t,n)=>{e.bi_valid>Lf-n?(e.bi_buf|=t<>Lf-e.bi_valid,e.bi_valid+=n-Lf):(e.bi_buf|=t<{yn(e,n[t*2],n[t*2+1])},S2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},hW=e=>{e.bi_valid===16?(rl(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},pW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,g=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,h,c,f,s,d,v=0;for(f=0;f<=sa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,v++),n[h*2+1]=f,!(h>r)&&(e.bl_count[f]++,s=0,h>=o&&(s=g[h-o]),d=n[h*2],e.opt_len+=d*(f+s),l&&(e.static_len+=d*(i[h*2+1]+s)));if(v!==0){do{for(f=a-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[a]--,v-=2}while(v>0);for(f=a;f!==0;f--)for(h=e.bl_count[f];h!==0;)c=e.heap[--u],!(c>r)&&(n[c*2+1]!==f&&(e.opt_len+=(f-n[c*2+1])*n[c*2],n[c*2+1]=f),h--)}},x2=(e,t,n)=>{const r=new Array(sa+1);let i=0,l,g;for(l=1;l<=sa;l++)i=i+n[l-1]<<1,r[l]=i;for(g=0;g<=t;g++){let o=e[g*2+1];o!==0&&(e[g*2]=S2(r[o]++,o))}},mW=()=>{let e,t,n,r,i;const l=new Array(sa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?rl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},D0=(e,t,n,r)=>{const i=t*2,l=n*2;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,l=0,g,o;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+l++]&255,r+=(e.pending_buf[e.sym_buf+l++]&255)<<8,i=e.pending_buf[e.sym_buf+l++],r===0?gr(e,i,t):(g=nl[i],gr(e,g+Tl+1,t),o=lh[g],o!==0&&(i-=im[g],yn(e,i,o)),r--,g=C2(r),gr(e,g,n),o=Pu[g],o!==0&&(r-=sc[g],yn(e,r,o)));while(l{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.elems;let g,o,a=-1,u;for(e.heap_len=0,e.heap_max=p2,g=0;g>1;g>=1;g--)$f(e,n,g);u=l;do g=e.heap[1],e.heap[1]=e.heap[e.heap_len--],$f(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=g,e.heap[--e.heap_max]=o,n[u*2]=n[g*2]+n[o*2],e.depth[u]=(e.depth[g]>=e.depth[o]?e.depth[g]:e.depth[o])+1,n[g*2+1]=n[o*2+1]=u,e.heap[1]=u++,$f(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],pW(e,t),x2(n,a,e.bl_count)},B0=(e,t,n)=>{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=g,g=t[(r+1)*2+1],!(++o{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),r=0;r<=n;r++)if(l=g,g=t[(r+1)*2+1],!(++o{let t;for(B0(e,e.dyn_ltree,e.l_desc.max_code),B0(e,e.dyn_dtree,e.d_desc.max_code),uh(e,e.bl_desc),t=nm-1;t>=3&&e.bl_tree[y2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},vW=(e,t,n,r)=>{let i;for(yn(e,t-257,5),yn(e,n-1,5),yn(e,r-4,4),i=0;i{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return L0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return R0;for(n=32;n{z0||(mW(),z0=!0),e.l_desc=new Df(e.dyn_ltree,b2),e.d_desc=new Df(e.dyn_dtree,_2),e.bl_desc=new Df(e.bl_tree,w2),e.bi_buf=0,e.bi_valid=0,T2(e)},E2=(e,t,n,r)=>{yn(e,(oW<<1)+(r?1:0),3),k2(e),rl(e,n),rl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},_W=e=>{yn(e,h2<<1,3),gr(e,rm,Nr),hW(e)},wW=(e,t,n,r)=>{let i,l,g=0;e.level>0?(e.strm.data_type===aW&&(e.strm.data_type=yW(e)),uh(e,e.l_desc),uh(e,e.d_desc),g=gW(e),i=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=i&&(i=l)):i=l=n+5,n+4<=i&&t!==-1?E2(e,t,n,r):e.strategy===iW||l===i?(yn(e,(h2<<1)+(r?1:0),3),$0(e,Nr,bs)):(yn(e,(sW<<1)+(r?1:0),3),vW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,g+1),$0(e,e.dyn_ltree,e.dyn_dtree)),T2(e),r&&k2(e)},CW=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(nl[n]+Tl+1)*2]++,e.dyn_dtree[C2(t)*2]++),e.sym_next===e.sym_end);var SW=bW,xW=E2,TW=wW,kW=CW,EW=_W,OW={_tr_init:SW,_tr_stored_block:xW,_tr_flush_block:TW,_tr_tally:kW,_tr_align:EW};const AW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,g=0;for(;n!==0;){g=n>2e3?2e3:n,n-=g;do i=i+t[r++]|0,l=l+i|0;while(--g);i%=65521,l%=65521}return i|l<<16|0};var il=AW;const PW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},IW=new Uint32Array(PW()),MW=(e,t,n,r)=>{const i=IW,l=r+n;e^=-1;for(let g=r;g>>8^i[(e^t[g])&255];return e^-1};var Vt=MW,Sa={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ro={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:LW,_tr_stored_block:ch,_tr_flush_block:RW,_tr_tally:ki,_tr_align:DW}=OW,{Z_NO_FLUSH:Ei,Z_PARTIAL_FLUSH:$W,Z_FULL_FLUSH:BW,Z_FINISH:jn,Z_BLOCK:N0,Z_OK:Kt,Z_STREAM_END:j0,Z_STREAM_ERROR:wr,Z_DATA_ERROR:FW,Z_BUF_ERROR:Bf,Z_DEFAULT_COMPRESSION:zW,Z_FILTERED:NW,Z_HUFFMAN_ONLY:ru,Z_RLE:jW,Z_FIXED:VW,Z_DEFAULT_STRATEGY:UW,Z_UNKNOWN:HW,Z_DEFLATED:Uc}=Ro,WW=9,YW=15,XW=8,KW=29,GW=256,fh=GW+1+KW,qW=30,ZW=19,JW=2*fh+1,QW=15,nt=3,Ci=258,Cr=Ci+nt+1,eY=32,bo=42,am=57,dh=69,hh=73,ph=91,mh=103,la=113,es=666,dn=1,Do=2,xa=3,$o=4,tY=3,ua=(e,t)=>(e.msg=Sa[t],t),V0=e=>e*2-(e>4?9:0),bi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},nY=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)};let rY=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},Ln=(e,t)=>{RW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,On(e.strm)},dt=(e,t)=>{e.pending_buf[e.pending++]=t},Xo=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},gh=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=il(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},O2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,g=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Cr?e.strstart-(e.w_size-Cr):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+Ci;let s=u[r+g-1],d=u[r+g];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+g]!==d||u[i+g-1]!==s||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&rg){if(e.match_start=t,g=l,l>=o)break;s=u[r+g-1],d=u[r+g]}}while((t=c[t&h])>a&&--n!==0);return g<=e.lookahead?g:e.lookahead},_o=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Cr)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),nY(e),r+=t),e.strm.avail_in===0)break;if(n=gh(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=nt)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Oi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Oi(e,e.ins_h,e.window[i+nt-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,l,g=0,o=e.strm.avail_in;do{if(r=65535,l=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(r=i+e.strm.avail_in),r>l&&(r=l),r>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,On(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(gh(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(g===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_waterl&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,l+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),l>e.strm.avail_in&&(l=e.strm.avail_in),l&&(gh(e.strm,e.window,e.strstart,l),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.high_water>3,l=e.pending_buf_size-l>65535?65535:e.pending_buf_size-l,n=l>e.w_size?e.w_size:l,i=e.strstart-e.block_start,(i>=n||(i||t===jn)&&t!==Ei&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,g=t===jn&&e.strm.avail_in===0&&r===i?1:0,ch(e,e.block_start,r,g),e.block_start+=r,On(e.strm)),g?xa:dn)},Ff=(e,t)=>{let n,r;for(;;){if(e.lookahead=nt&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Cr&&(e.match_length=O2(e,n)),e.match_length>=nt)if(r=ki(e,e.strstart-e.match_start,e.match_length-nt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=nt){e.match_length--;do e.strstart++,e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+1]);else r=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=nt&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=nt-1,n!==0&&e.prev_length4096)&&(e.match_length=nt-1)),e.prev_length>=nt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-nt,r=ki(e,e.strstart-1-e.prev_match,e.prev_length-nt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=nt-1,e.strstart++,r&&(Ln(e,!1),e.strm.avail_out===0))return dn}else if(e.match_available){if(r=ki(e,0,e.window[e.strstart-1]),r&&Ln(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return dn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ki(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const g=e.window;for(;;){if(e.lookahead<=Ci){if(_o(e),e.lookahead<=Ci&&t===Ei)return dn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=nt&&e.strstart>0&&(i=e.strstart-1,r=g[i],r===g[++i]&&r===g[++i]&&r===g[++i])){l=e.strstart+Ci;do;while(r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=nt?(n=ki(e,1,e.match_length-nt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=0,t===jn?(Ln(e,!0),e.strm.avail_out===0?xa:$o):e.sym_next&&(Ln(e,!1),e.strm.avail_out===0)?dn:Do},aY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(_o(e),e.lookahead===0)){if(t===Ei)return dn;break}if(e.match_length=0,n=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=0,t===jn?(Ln(e,!0),e.strm.avail_out===0?xa:$o):e.sym_next&&(Ln(e,!1),e.strm.avail_out===0)?dn:Do};function dr(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const ts=[new dr(0,0,0,0,A2),new dr(4,4,8,4,Ff),new dr(4,5,16,8,Ff),new dr(4,6,32,32,Ff),new dr(4,4,16,16,Ha),new dr(8,16,32,32,Ha),new dr(8,16,128,128,Ha),new dr(8,32,128,256,Ha),new dr(32,128,258,1024,Ha),new dr(32,258,258,4096,Ha)],oY=e=>{e.window_size=2*e.w_size,bi(e.head),e.max_lazy_match=ts[e.level].max_lazy,e.good_match=ts[e.level].good_length,e.nice_match=ts[e.level].nice_length,e.max_chain_length=ts[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=nt-1,e.match_available=0,e.ins_h=0};function sY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Uc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(JW*2),this.dyn_dtree=new Uint16Array((2*qW+1)*2),this.bl_tree=new Uint16Array((2*ZW+1)*2),bi(this.dyn_ltree),bi(this.dyn_dtree),bi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(QW+1),this.heap=new Uint16Array(2*fh+1),bi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*fh+1),bi(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const kl=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==bo&&t.status!==am&&t.status!==dh&&t.status!==hh&&t.status!==ph&&t.status!==mh&&t.status!==la&&t.status!==es?1:0},P2=e=>{if(kl(e))return ua(e,wr);e.total_in=e.total_out=0,e.data_type=HW;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?am:t.wrap?bo:la,e.adler=t.wrap===2?0:1,t.last_flush=-2,LW(t),Kt},I2=e=>{const t=P2(e);return t===Kt&&oY(e.state),t},lY=(e,t)=>kl(e)||e.state.wrap!==2?wr:(e.state.gzhead=t,Kt),M2=(e,t,n,r,i,l)=>{if(!e)return wr;let g=1;if(t===zW&&(t=6),r<0?(g=0,r=-r):r>15&&(g=2,r-=16),i<1||i>WW||n!==Uc||r<8||r>15||t<0||t>9||l<0||l>VW||r===8&&g!==1)return ua(e,wr);r===8&&(r=9);const o=new sY;return e.state=o,o.strm=e,o.status=bo,o.wrap=g,o.gzhead=null,o.w_bits=r,o.w_size=1<M2(e,t,Uc,YW,XW,UW),cY=(e,t)=>{if(kl(e)||t>N0||t<0)return e?ua(e,wr):wr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===es&&t!==jn)return ua(e,e.avail_out===0?Bf:wr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(On(e),e.avail_out===0)return n.last_flush=-1,Kt}else if(e.avail_in===0&&V0(t)<=V0(r)&&t!==jn)return ua(e,Bf);if(n.status===es&&e.avail_in!==0)return ua(e,Bf);if(n.status===bo&&n.wrap===0&&(n.status=la),n.status===bo){let i=Uc+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=ru||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=eY),i+=31-i%31,Xo(n,i),n.strstart!==0&&(Xo(n,e.adler>>>16),Xo(n,e.adler&65535)),e.adler=1,n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(n.status===am){if(e.adler=0,dt(n,31),dt(n,139),dt(n,8),n.gzhead)dt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),dt(n,n.gzhead.time&255),dt(n,n.gzhead.time>>8&255),dt(n,n.gzhead.time>>16&255),dt(n,n.gzhead.time>>24&255),dt(n,n.level===9?2:n.strategy>=ru||n.level<2?4:0),dt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(dt(n,n.gzhead.extra.length&255),dt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=dh;else if(dt(n,0),dt(n,0),dt(n,0),dt(n,0),dt(n,0),dt(n,n.level===9?2:n.strategy>=ru||n.level<2?4:0),dt(n,tY),n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(n.status===dh){if(n.gzhead.extra){let i=n.pending,l=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+l>n.pending_buf_size;){let o=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0,l-=o}let g=new Uint8Array(n.gzhead.extra);n.pending_buf.set(g.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=hh}if(n.status===hh){if(n.gzhead.name){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0}n.gzindexi&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=ph}if(n.status===ph){if(n.gzhead.comment){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0}n.gzindexi&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i))}n.status=mh}if(n.status===mh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(On(e),n.pending!==0))return n.last_flush=-1,Kt;dt(n,e.adler&255),dt(n,e.adler>>8&255),e.adler=0}if(n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(e.avail_in!==0||n.lookahead!==0||t!==Ei&&n.status!==es){let i=n.level===0?A2(n,t):n.strategy===ru?aY(n,t):n.strategy===jW?iY(n,t):ts[n.level].func(n,t);if((i===xa||i===$o)&&(n.status=es),i===dn||i===xa)return e.avail_out===0&&(n.last_flush=-1),Kt;if(i===Do&&(t===$W?DW(n):t!==N0&&(ch(n,0,0,!1),t===BW&&(bi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),On(e),e.avail_out===0))return n.last_flush=-1,Kt}return t!==jn?Kt:n.wrap<=0?j0:(n.wrap===2?(dt(n,e.adler&255),dt(n,e.adler>>8&255),dt(n,e.adler>>16&255),dt(n,e.adler>>24&255),dt(n,e.total_in&255),dt(n,e.total_in>>8&255),dt(n,e.total_in>>16&255),dt(n,e.total_in>>24&255)):(Xo(n,e.adler>>>16),Xo(n,e.adler&65535)),On(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Kt:j0)},fY=e=>{if(kl(e))return wr;const t=e.state.status;return e.state=null,t===la?ua(e,FW):Kt},dY=(e,t)=>{let n=t.length;if(kl(e))return wr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==bo||r.lookahead)return wr;if(i===1&&(e.adler=il(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(bi(r.head),r.strstart=0,r.block_start=0,r.insert=0);let a=new Uint8Array(r.w_size);a.set(t.subarray(n-r.w_size,n),0),t=a,n=r.w_size}const l=e.avail_in,g=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,_o(r);r.lookahead>=nt;){let a=r.strstart,u=r.lookahead-(nt-1);do r.ins_h=Oi(r,r.ins_h,r.window[a+nt-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--u);r.strstart=a,r.lookahead=nt-1,_o(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=nt-1,r.match_available=0,e.next_in=g,e.input=o,e.avail_in=l,r.wrap=i,Kt};var hY=uY,pY=M2,mY=I2,gY=P2,vY=lY,yY=cY,bY=fY,_Y=dY,wY="pako deflate (from Nodeca project)",_s={deflateInit:hY,deflateInit2:pY,deflateReset:mY,deflateResetKeep:gY,deflateSetHeader:vY,deflate:yY,deflateEnd:bY,deflateSetDictionary:_Y,deflateInfo:wY};const CY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var SY=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(!!n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)CY(n,r)&&(e[r]=n[r])}}return e},xY=e=>{let t=0;for(let r=0,i=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;al[254]=al[254]=1;var TY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,g=e.length,o=0;for(i=0;i>>6,t[l++]=128|n&63):n<65536?(t[l++]=224|n>>>12,t[l++]=128|n>>>6&63,t[l++]=128|n&63):(t[l++]=240|n>>>18,t[l++]=128|n>>>12&63,t[l++]=128|n>>>6&63,t[l++]=128|n&63);return t};const kY=(e,t)=>{if(t<65534&&e.subarray&&L2)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i;const l=new Array(n*2);for(i=0,r=0;r4){l[i++]=65533,r+=o-1;continue}for(g&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}g<65536?l[i++]=g:(g-=65536,l[i++]=55296|g>>10&1023,l[i++]=56320|g&1023)}return kY(l,i)},OY=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+al[e[n]]>t?n:t},ol={string2buf:TY,buf2string:EY,utf8border:OY};function AY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var R2=AY;const D2=Object.prototype.toString,{Z_NO_FLUSH:PY,Z_SYNC_FLUSH:IY,Z_FULL_FLUSH:MY,Z_FINISH:LY,Z_OK:lc,Z_STREAM_END:RY,Z_DEFAULT_COMPRESSION:DY,Z_DEFAULT_STRATEGY:$Y,Z_DEFLATED:BY}=Ro;function El(e){this.options=Hc.assign({level:DY,method:BY,chunkSize:16384,windowBits:15,memLevel:8,strategy:$Y},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new R2,this.strm.avail_out=0;let n=_s.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==lc)throw new Error(Sa[n]);if(t.header&&_s.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=ol.string2buf(t.dictionary):D2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=_s.deflateSetDictionary(this.strm,r),n!==lc)throw new Error(Sa[n]);this._dict_set=!0}}El.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,l;if(this.ended)return!1;for(t===~~t?l=t:l=t===!0?LY:PY,typeof e=="string"?n.input=ol.string2buf(e):D2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===IY||l===MY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=_s.deflate(n,l),i===RY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=_s.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===lc;if(n.avail_out===0){this.onData(n.output);continue}if(l>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};El.prototype.onData=function(e){this.chunks.push(e)};El.prototype.onEnd=function(e){e===lc&&(this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function om(e,t){const n=new El(t);if(n.push(e,!0),n.err)throw n.msg||Sa[n.err];return n.result}function FY(e,t){return t=t||{},t.raw=!0,om(e,t)}function zY(e,t){return t=t||{},t.gzip=!0,om(e,t)}var NY=El,jY=om,VY=FY,UY=zY,HY=Ro,WY={Deflate:NY,deflate:jY,deflateRaw:VY,gzip:UY,constants:HY};const iu=16209,YY=16191;var XY=function(t,n){let r,i,l,g,o,a,u,h,c,f,s,d,v,m,y,b,_,w,S,x,T,E,A,D;const N=t.state;r=t.next_in,A=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,g=l-(n-t.avail_out),o=l+(t.avail_out-257),a=N.dmax,u=N.wsize,h=N.whave,c=N.wnext,f=N.window,s=N.hold,d=N.bits,v=N.lencode,m=N.distcode,y=(1<>>24,s>>>=w,d-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(d>>=w,d-=w),d<15&&(s+=A[r++]<>>24,s>>>=w,d-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,da){t.msg="invalid distance too far back",N.mode=iu;break e}if(s>>>=w,d-=w,w=l-g,x>w){if(w=x-w,w>h&&N.sane){t.msg="invalid distance too far back",N.mode=iu;break e}if(T=0,E=f,c===0){if(T+=u-w,w2;)D[l++]=E[T++],D[l++]=E[T++],D[l++]=E[T++],S-=3;S&&(D[l++]=E[T++],S>1&&(D[l++]=E[T++]))}else{T=l-x;do D[l++]=D[T++],D[l++]=D[T++],D[l++]=D[T++],S-=3;while(S>2);S&&(D[l++]=D[T++],S>1&&(D[l++]=D[T++]))}}else if((w&64)===0){_=m[(_&65535)+(s&(1<>3,r-=S,d-=S<<3,s&=(1<{const a=o.bits;let u=0,h=0,c=0,f=0,s=0,d=0,v=0,m=0,y=0,b=0,_,w,S,x,T,E=null,A;const D=new Uint16Array(Wa+1),N=new Uint16Array(Wa+1);let R=null,B,O,U;for(u=0;u<=Wa;u++)D[u]=0;for(h=0;h=1&&D[f]===0;f--);if(s>f&&(s=f),f===0)return i[l++]=1<<24|64<<16|0,i[l++]=1<<24|64<<16|0,o.bits=1,0;for(c=1;c0&&(e===W0||f!==1))return-1;for(N[1]=0,u=1;uU0||e===Y0&&y>H0)return 1;for(;;){B=u-v,g[h]+1=A?(O=R[g[h]-A],U=E[g[h]-A]):(O=32+64,U=0),_=1<>v)+w]=B<<24|O<<16|U|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,h++,--D[u]===0){if(u===f)break;u=t[n+g[h]]}if(u>s&&(b&x)!==S){for(v===0&&(v=s),T+=c,d=u-v,m=1<U0||e===Y0&&y>H0)return 1;S=b&x,i[S]=s<<24|d<<16|T-l|0}}return b!==0&&(i[T+b]=u-v<<24|64<<16|0),o.bits=s,0};var ws=JY;const QY=0,$2=1,B2=2,{Z_FINISH:X0,Z_BLOCK:eX,Z_TREES:au,Z_OK:Ta,Z_STREAM_END:tX,Z_NEED_DICT:nX,Z_STREAM_ERROR:Xn,Z_DATA_ERROR:F2,Z_MEM_ERROR:z2,Z_BUF_ERROR:rX,Z_DEFLATED:K0}=Ro,Wc=16180,G0=16181,q0=16182,Z0=16183,J0=16184,Q0=16185,ey=16186,ty=16187,ny=16188,ry=16189,uc=16190,Rr=16191,Nf=16192,iy=16193,jf=16194,ay=16195,oy=16196,sy=16197,ly=16198,ou=16199,su=16200,uy=16201,cy=16202,fy=16203,dy=16204,hy=16205,Vf=16206,py=16207,my=16208,It=16209,N2=16210,j2=16211,iX=852,aX=592,oX=15,sX=oX,gy=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function lX(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const $a=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modej2?1:0},V2=e=>{if($a(e))return Xn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Wc,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(iX),t.distcode=t.distdyn=new Int32Array(aX),t.sane=1,t.back=-1,Ta},U2=e=>{if($a(e))return Xn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,V2(e)},H2=(e,t)=>{let n;if($a(e))return Xn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Xn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,U2(e))},W2=(e,t)=>{if(!e)return Xn;const n=new lX;e.state=n,n.strm=e,n.window=null,n.mode=Wc;const r=H2(e,t);return r!==Ta&&(e.state=null),r},uX=e=>W2(e,sX);let vy=!0,Uf,Hf;const cX=e=>{if(vy){Uf=new Int32Array(512),Hf=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ws($2,e.lens,0,288,Uf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ws(B2,e.lens,0,32,Hf,0,e.work,{bits:5}),vy=!1}e.lencode=Uf,e.lenbits=9,e.distcode=Hf,e.distbits=5},Y2=(e,t,n,r)=>{let i;const l=e.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(t.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):(i=l.wsize-l.wnext,i>r&&(i=r),l.window.set(t.subarray(n-r,n-r+i),l.wnext),r-=i,r?(l.window.set(t.subarray(n-r,n),0),l.wnext=r,l.whave=l.wsize):(l.wnext+=i,l.wnext===l.wsize&&(l.wnext=0),l.whave{let n,r,i,l,g,o,a,u,h,c,f,s,d,v,m=0,y,b,_,w,S,x,T,E;const A=new Uint8Array(4);let D,N;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($a(e)||!e.output||!e.input&&e.avail_in!==0)return Xn;n=e.state,n.mode===Rr&&(n.mode=Nf),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,c=o,f=a,E=Ta;e:for(;;)switch(n.mode){case Wc:if(n.wrap===0){n.mode=Nf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Vt(n.check,A,2,0),u=0,h=0,n.mode=G0;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=It;break}if((u&15)!==K0){e.msg="unknown compression method",n.mode=It;break}if(u>>>=4,h-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=It;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(A[0]=u&255,A[1]=u>>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0,n.mode=q0;case q0:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,n.check=Vt(n.check,A,4,0)),u=0,h=0,n.mode=Z0;case Z0:for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(A[0]=u&255,A[1]=u>>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0,n.mode=J0;case J0:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=Q0;case Q0:if(n.flags&1024&&(s=n.length,s>o&&(s=o),s&&(n.head&&(T=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(l,l+s),T)),n.flags&512&&n.wrap&4&&(n.check=Vt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=ey;case ey:if(n.flags&2048){if(o===0)break e;s=0;do T=r[l+s++],n.head&&T&&n.length<65536&&(n.head.name+=String.fromCharCode(T));while(T&&s>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Rr;break;case ry:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>=h&7,h-=h&7,n.mode=Vf;break}for(;h<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,h-=1,u&3){case 0:n.mode=iy;break;case 1:if(cX(n),n.mode=ou,t===au){u>>>=2,h-=2;break e}break;case 2:n.mode=oy;break;case 3:e.msg="invalid block type",n.mode=It}u>>>=2,h-=2;break;case iy:for(u>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=It;break}if(n.length=u&65535,u=0,h=0,n.mode=jf,t===au)break e;case jf:n.mode=ay;case ay:if(s=n.length,s){if(s>o&&(s=o),s>a&&(s=a),s===0)break e;i.set(r.subarray(l,l+s),g),o-=s,l+=s,a-=s,g+=s,n.length-=s;break}n.mode=Rr;break;case oy:for(;h<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,h-=5,n.ndist=(u&31)+1,u>>>=5,h-=5,n.ncode=(u&15)+4,u>>>=4,h-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=It;break}n.have=0,n.mode=sy;case sy:for(;n.have>>=3,h-=3}for(;n.have<19;)n.lens[R[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},E=ws(QY,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid code lengths set",n.mode=It;break}n.have=0,n.mode=ly;case ly:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=y,h-=y,n.lens[n.have++]=_;else{if(_===16){for(N=y+2;h>>=y,h-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=It;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,h-=2}else if(_===17){for(N=y+3;h>>=y,h-=y,T=0,s=3+(u&7),u>>>=3,h-=3}else{for(N=y+7;h>>=y,h-=y,T=0,s=11+(u&127),u>>>=7,h-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=It;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===It)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=It;break}if(n.lenbits=9,D={bits:n.lenbits},E=ws($2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid literal/lengths set",n.mode=It;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},E=ws(B2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,E){e.msg="invalid distances set",n.mode=It;break}if(n.mode=ou,t===au)break e;case ou:n.mode=su;case su:if(o>=6&&a>=258){e.next_out=g,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=h,XY(e,f),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,n.mode===Rr&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,n.length=_,b===0){n.mode=hy;break}if(b&32){n.back=-1,n.mode=Rr;break}if(b&64){e.msg="invalid literal/length code",n.mode=It;break}n.extra=b&15,n.mode=uy;case uy:if(n.extra){for(N=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=cy;case cy:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=It;break}n.offset=_,n.extra=b&15,n.mode=fy;case fy:if(n.extra){for(N=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=It;break}n.mode=dy;case dy:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=It;break}s>n.wnext?(s-=n.wnext,d=n.wsize-s):d=n.wnext-s,s>n.length&&(s=n.length),v=n.window}else v=i,d=g-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[g++]=v[d++];while(--s);n.length===0&&(n.mode=su);break;case hy:if(a===0)break e;i[g++]=n.length,a--,n.mode=su;break;case Vf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if($a(e))return Xn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ta},hX=(e,t)=>{if($a(e))return Xn;const n=e.state;return(n.wrap&2)===0?Xn:(n.head=t,t.done=!1,Ta)},pX=(e,t)=>{const n=t.length;let r,i,l;return $a(e)||(r=e.state,r.wrap!==0&&r.mode!==uc)?Xn:r.mode===uc&&(i=1,i=il(i,t,n,0),i!==r.check)?F2:(l=Y2(e,t,n,n),l?(r.mode=N2,z2):(r.havedict=1,Ta))};var mX=U2,gX=H2,vX=V2,yX=uX,bX=W2,_X=fX,wX=dX,CX=hX,SX=pX,xX="pako inflate (from Nodeca project)",jr={inflateReset:mX,inflateReset2:gX,inflateResetKeep:vX,inflateInit:yX,inflateInit2:bX,inflate:_X,inflateEnd:wX,inflateGetHeader:CX,inflateSetDictionary:SX,inflateInfo:xX};function TX(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var kX=TX;const X2=Object.prototype.toString,{Z_NO_FLUSH:EX,Z_FINISH:OX,Z_OK:sl,Z_STREAM_END:Wf,Z_NEED_DICT:Yf,Z_STREAM_ERROR:AX,Z_DATA_ERROR:yy,Z_MEM_ERROR:PX}=Ro;function Ol(e){this.options=Hc.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new R2,this.strm.avail_out=0;let n=jr.inflateInit2(this.strm,t.windowBits);if(n!==sl)throw new Error(Sa[n]);if(this.header=new kX,jr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=ol.string2buf(t.dictionary):X2.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=jr.inflateSetDictionary(this.strm,t.dictionary),n!==sl)))throw new Error(Sa[n])}Ol.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,g,o;if(this.ended)return!1;for(t===~~t?g=t:g=t===!0?OX:EX,X2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),l=jr.inflate(n,g),l===Yf&&i&&(l=jr.inflateSetDictionary(n,i),l===sl?l=jr.inflate(n,g):l===yy&&(l=Yf));n.avail_in>0&&l===Wf&&n.state.wrap>0&&e[n.next_in]!==0;)jr.inflateReset(n),l=jr.inflate(n,g);switch(l){case AX:case yy:case Yf:case PX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Wf))if(this.options.to==="string"){let a=ol.utf8border(n.output,n.next_out),u=n.next_out-a,h=ol.buf2string(n.output,a);n.next_out=u,n.avail_out=r-u,u&&n.output.set(n.output.subarray(a,a+u),0),this.onData(h)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===sl&&o===0)){if(l===Wf)return l=jr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Ol.prototype.onData=function(e){this.chunks.push(e)};Ol.prototype.onEnd=function(e){e===sl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function sm(e,t){const n=new Ol(t);if(n.push(e),n.err)throw n.msg||Sa[n.err];return n.result}function IX(e,t){return t=t||{},t.raw=!0,sm(e,t)}var MX=Ol,LX=sm,RX=IX,DX=sm,$X=Ro,BX={Inflate:MX,inflate:LX,inflateRaw:RX,ungzip:DX,constants:$X};const{Deflate:RG,deflate:DG,deflateRaw:FX,gzip:$G}=WY,{Inflate:BG,inflate:FG,inflateRaw:zX,ungzip:zG}=BX;var NX=FX,jX=zX;function by(e){const t=new Map;for(const n of e){const[r,i]=n.split("="),l=decodeURIComponent(i);t.set(r,l)}return t}const VX=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=by(t);if(console.log("URL params:",n),n.get("share")){const l=jX(new Uint8Array(atob(n.get("share")).split("").map(g=>g.charCodeAt(0))),{to:"string"});if(!l){$t().raiseError("Error when trying to decode share parameter!",!1);return}n=by(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),scheduler:n.get("scheduler")||"default"};en().generateText2Img(r,!1)},UX=10;function vh(e,t,n,r,i=l=>$t().raiseError(l,!1)){if(e.status===n&&t)return!0;if(!t.message)return i(`${r}: Got response code ${e.status}`);if(!t.errors)return i(`${r}: ${t.message}`);const l=Object.entries(t.errors).map(g=>`${g[0]} - ${g[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const HX=Co("interrogate",()=>{const e=oe({}),t=oe(!1);async function n(g){$t().raiseError(g,!1),t.value=!1,e.value={}}async function r(){const g=Gt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!vh(a,u,200,"Failed to get interrogation",n)||(e.value.id=u.id,e.value.status=u.caption)}function i(){e.value={},t.value=!1}function l(){return e.value.status||!1}return{currentInterrogation:e,interrogating:t,interrogateImage:r,getFormStatus:l,resetInterrogation:i}}),lm=e=>(Qr("data-v-db184ac6"),e=e(),ei(),e),WX={key:0,style:{"margin-top":"16px"}},YX=lm(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),XX={key:1,style:{"margin-top":"16px"}},KX={key:2},GX={style:{"margin-top":"8px"}},qX=lm(()=>re("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),ZX={key:0},JX=lm(()=>re("h3",null,"Caption",-1)),QX={key:0},eK={key:1},tK=Ee({__name:"InterrogationView",setup(e){const t=HX(),n=en(),r=$t(),i=oe();async function l(u){if(i.value.clearFiles(),!u.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const h=await d2(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function g(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=c2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(j(),ce("div",KX,[re("div",GX,[le(C(lt),{icon:C(mg),onClick:C(t).resetInterrogation},{default:pe(()=>[Ne("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(j(),we(C(lt),{key:0,icon:C(mg),onClick:g,disabled:!C(o)},{default:pe(()=>[Ne("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):_e("",!0)]),qX,le(C(Tp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(j(),ce("div",ZX,[JX,C(o)?(j(),ce("div",eK,[re("strong",null,Ae(C(o)),1)])):(j(),ce("div",QX,"Processing"+Ae(C(a)),1))])):_e("",!0)])):(j(),ce("div",XX,[re("strong",null,"Uploading image"+Ae(C(a)),1)])):(j(),ce("div",WX,[re("div",null,[le(C(Pp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),YX]),_:1},512)])]))}});const nK=Yt(tK,[["__scopeId","data-v-db184ac6"]]);function rK(e,t,n){if(e===0)return"0"+(t?"s":"seconds");if(e==null)return"?";const r=Math.floor(e/86400),i=Math.floor(e%86400/3600),l=Math.floor(e%86400%3600/60),g=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",u=l>0?l+(t?"m":"minutes"):"",h=g>0?g+(t?"s":"seconds"):"",c=[];return n!=null&&n.days&&c.push(o),n!=null&&n.hours&&c.push(a),n!=null&&n.minutes&&c.push(u),n!=null&&n.seconds&&c.push(h),c.join(" ")}const iK={class:"form"},aK={key:0,style:{"padding-bottom":"50px"}},oK=re("h1",{style:{margin:"0"}},"Interrogation",-1),sK=re("div",null,"Interrogate images to get their predicted descriptions.",-1),lK={class:"sidebar"},uK=re("span",{style:{height:"100%","font-size":"14px"}},[Ne("Reference Image: "),re("br"),Ne("(Photomaker/Kontext) ")],-1),cK=re("h3",{style:{margin:"16px 0 4px 0"}},"Multi Select",-1),fK={class:"main"},dK={class:"image center-horizontal"},hK={key:0},pK=Ee({__name:"GenerateView",setup(e){const n=up(lp).smallerOrEqual("md"),r=en(),i=$t(),l=ys(),g=Gt();let o=[];const a=Qg(async()=>{if(o.length===0)try{o=(await(await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/samplers`)).json()).map(b=>b.name)}catch{o=[]}return o.length===0?[]:f(o)});let u=[];const h=Qg(async()=>{if(u.length===0)try{u=(await(await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/schedulers`)).json()).map(b=>b.name)}catch{u=[]}return u.length===0?[]:s(u)}),c=pt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function f(b){return!r.params||!r.params.sampler_name||b.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=b[0]),b}function s(b){return!r.params||!r.params.scheduler||b.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=b[0]),b}function d(b){return"Elapsed: "+rK(b,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function v(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function m(b){r.generatorType=b,v(),console.log(b)}function y(){l.showCropPreview=!0,l.updateCropPreview()}return v(),VX(),(b,_)=>(j(),ce(ze,null,[le(C(tw),{"default-active":C(r).generatorType,collapse:!0,onSelect:m,mode:C(n)?"horizontal":"vertical",class:fe(C(n)?"mobile-generator-types":"generator-types"),style:Fe(C(n)?"overflow-x: auto":"")},{default:pe(()=>[le(nu,{index:"Text2Img","icon-one":C(oE),"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(nu,{index:"Img2Img","icon-one":C(Fl),"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(nu,{index:"Inpainting","icon-one":u2,"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(nu,{index:"Interrogation","icon-one":oH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),re("div",iK,[C(r).generatorType==="Interrogation"?(j(),ce("div",aK,[oK,sK,le(nK)])):(j(),we(C(xp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:c,onSubmit:_[29]||(_[29]=Ze(()=>{},["prevent"]))},{default:pe(()=>[re("div",lK,[le(C(Y$),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":_[24]||(_[24]=w=>C(i).activeCollapse=w),style:{"margin-bottom":"24px"}},{default:pe(()=>[le(C(X$),{title:"Generation Options",name:"1"},{default:pe(()=>[le(xH),le(sh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":_[0]||(_[0]=w=>C(r).negativePrompt=w),autosize:{maxRows:15},resize:"vertical",type:"textarea",placeholder:"Enter negative prompt here",info:"What to exclude from the image. Not working? Try increasing the guidance.","label-position":"top"},null,8,["modelValue"]),le(sh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":_[2]||(_[2]=w=>C(r).params.seed=w),placeholder:"Enter seed here",clearable:"","clear-icon":C(Gk)},{append:pe(()=>[le(C(Or),{content:"Randomize!",placement:"top"},{default:pe(()=>[le(C(lt),{icon:C(k3),onClick:_[1]||(_[1]=()=>C(r).params.seed=C(K2)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),C(r).multiSelect.sampler.enabled?(j(),we(Au,{key:0,label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":_[3]||(_[3]=w=>C(r).multiSelect.sampler.selected=w),options:C(a),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])):(j(),we(Au,{key:1,label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":_[4]||(_[4]=w=>C(r).params.sampler_name=w),options:C(a),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])),le(En,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":_[5]||(_[5]=w=>C(r).params.n=w),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.enabled?(j(),we(En,{key:2,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":_[6]||(_[6]=w=>C(r).multiSelect.steps.selected=w),min:C(r).minSteps,max:C(r).maxSteps,info:"Multi-select enabled. Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:3,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":_[7]||(_[7]=w=>C(r).params.steps=w),min:C(r).minSteps,max:C(r).maxSteps,info:"Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed."},null,8,["modelValue","min","max"])),le(En,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":_[8]||(_[8]=w=>C(r).params.width=w),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:y},null,8,["modelValue","min","max"]),le(En,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":_[9]||(_[9]=w=>C(r).params.height=w),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:y},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.enabled?(j(),we(En,{key:4,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":_[10]||(_[10]=w=>C(r).multiSelect.guidance.selected=w),min:C(r).minCfgScale,max:C(r).maxCfgScale,info:"Multi-select enabled. Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:5,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":_[11]||(_[11]=w=>C(r).params.cfg_scale=w),min:C(r).minCfgScale,max:C(r).maxCfgScale,step:.5,info:"Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max","step"])),C(r).multiSelect.clipSkip.enabled?(j(),we(En,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":_[12]||(_[12]=w=>C(r).multiSelect.clipSkip.selected=w),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Multi-select enabled. Last layers of CLIP to ignore. For most situations this can be left alone.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":_[13]||(_[13]=w=>C(r).params.clip_skip=w),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])),C(r).sourceGeneratorTypes.includes(C(r).generatorType)?(j(),we(En,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":_[14]||(_[14]=w=>C(r).params.denoising_strength=w),min:C(r).minDenoise,max:C(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values."},null,8,["modelValue","min","max","step"])):_e("",!0),le(En,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":_[15]||(_[15]=w=>C(r).params.frames=w),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). Max 80 frames, about 5 seconds of video."},null,8,["modelValue","min","max"]),le(Au,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":_[16]||(_[16]=w=>C(r).params.scheduler=w),options:C(h),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"]),re("div",null,[uK,re("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:_[17]||(_[17]=w=>C(r).setExtraImage(w)),accept:"image/*",multiple:""},null,32),re("button",{onClick:_[18]||(_[18]=w=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),le(C(r0),null,{default:pe(()=>[le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":_[19]||(_[19]=w=>C(r).params.enable_hr=w),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"])]),_:1})]),cK,le(C(r0),null,{default:pe(()=>[le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Sampler",prop:"multiSamplerSwitch",modelValue:C(r).multiSelect.sampler.enabled,"onUpdate:modelValue":_[20]||(_[20]=w=>C(r).multiSelect.sampler.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Guidance",prop:"multiGuidanceSwitch",modelValue:C(r).multiSelect.guidance.enabled,"onUpdate:modelValue":_[21]||(_[21]=w=>C(r).multiSelect.guidance.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi CLIP Skip",prop:"multiClipSkipSwitch",modelValue:C(r).multiSelect.clipSkip.enabled,"onUpdate:modelValue":_[22]||(_[22]=w=>C(r).multiSelect.clipSkip.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Steps",prop:"multiStepsSwitch",modelValue:C(r).multiSelect.steps.enabled,"onUpdate:modelValue":_[23]||(_[23]=w=>C(r).multiSelect.steps.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),re("div",fK,[le(C(lt),{onClick:_[25]||(_[25]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:pe(()=>[Ne("Reset")]),_:1}),le(C(lt),{type:"primary",class:"generate-cancel-btn",style:Fe(C(r).generating?"width: 55%;":""),onClick:_[26]||(_[26]=()=>C(r).generateImage(C(r).generatorType))},{default:pe(()=>[re("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(j(),we(C(lt),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:_[27]||(_[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:pe(()=>[Ne("Cancel all")]),_:1},8,["disabled"])):_e("",!0)]),re("div",dK,[le(C(KD),{class:"center-both generated-image"},{default:pe(()=>[!C(r).generating&&C(r).outputs.length==0?(j(),ce("div",hK,[/Inpainting/.test(C(r).generatorType)?(j(),we(M0,{key:0})):_e("",!0),/Img2Img/.test(C(r).generatorType)?(j(),we(M0,{key:1})):_e("",!0)])):_e("",!0),!C(i).showGeneratedImages&&C(r).generating?(j(),we(pH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:d(C(r).timer.seconds),onShowGenerated:_[28]||(_[28]=w=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):_e("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(j(),we(RH,{key:2})):_e("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Cs=jT({history:iT("./"),routes:[{path:"/",name:"generate",component:pK},{path:"/images",name:"images",component:()=>If(()=>Promise.resolve().then(()=>fG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>If(()=>Promise.resolve().then(()=>xG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>If(()=>Promise.resolve().then(()=>MG),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function Xf(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,enable_hr:!1,scheduler:"default"}}function K2(){return Math.floor(Math.random()*9999999)+1}const en=Co("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=oe("Text2Img"),r=oe(""),i=Pn("promptHistory",[]),l=oe(""),g=Pn("negativeLibrary",[]),o=oe(Xf()),a=oe({interval:0,seconds:0}),u=oe({sampler:{name:"Sampler",enabled:!1,selected:[o.value.sampler_name],noneMessage:"Failed to generate: No sampler selected.",mapToParam:te=>te.sampler_name},steps:{name:"Steps",enabled:!1,selected:[o.value.steps],noneMessage:"Failed to generate: No steps selected.",mapToParam:te=>te.steps},guidance:{name:"CFG Scale",enabled:!1,selected:[o.value.cfg_scale],noneMessage:"Failed to generate: No guidance selected.",mapToParam:te=>te.cfg_scale},clipSkip:{name:"Clip Skip",enabled:!1,selected:[o.value.clip_skip],noneMessage:"Failed to generate: No CLIP Skip selected.",mapToParam:te=>te.clip_skip}}),h=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=oe({...h(),sourceProcessing:"inpainting"}),f=oe({...h(),sourceProcessing:"img2img"}),s=te=>te==="Inpainting"?c.value:te==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),v=oe(""),m=oe(!1),y=oe(!1),b=oe([]),_=oe([]),w=oe(64),S=ee(()=>Gt().allowLargerParams==="Enabled"?3072:1024),x=oe(1),T=oe(20),E=oe(1),A=ee(()=>Gt().allowLargerParams==="Enabled"?150:50),D=oe(1),N=oe(24),R=oe(.1),B=oe(1),O=oe(0),U=oe(10),ne=oe(1),Q=oe(80),ue=(te,be,Ce)=>Array.from({length:(be-te+1)/Ce},(xe,Ie)=>(Ie+te)*Ce),I=oe(ue(O.value,U.value,1)),z=oe(ue(D.value,N.value,.5)),M=ee(()=>{const te=(Me,Le,ot=1)=>Me*(Le.enabled?Le.selected.length:ot),Ce=o.value.n*Y().length,xe=te(Ce,u.value.sampler),Ie=te(xe,u.value.steps),ve=te(Ie,u.value.guidance);return te(ve,u.value.clipSkip)});function L(){return o.value=Xf(),c.value=h(),f.value=h(),b.value=[],$t().showGeneratedImages=!1,J(),!0}function J(){_.value=[]}function V(){b.value=[]}async function P(te){if(!e.includes(te))return[];if(r.value==="")return Z("Failed to generate: No prompt submitted.");for(const ut of Object.values(u.value))if(ut.enabled&&ut.selected.length===0)return Z(ut.noneMessage);const be=ys(),Ce=$t();be.saveImages();const{sourceImage:xe,maskImage:Ie,sourceProcessing:ve}=s(te);K(r.value);const Se=[],Me=(ut,Qt)=>ut.enabled?ut.selected:Qt,Le=Y(),ot=Me(u.value.guidance,[o.value.cfg_scale]),mt=Me(u.value.steps,[o.value.steps]),st=Me(u.value.clipSkip,[o.value.clip_skip]),Xt=Me(u.value.sampler,[o.value.sampler_name]),Jt=[await W()];for(const ut of ot)for(const Qt of mt)for(const Q2 of st)for(const cm of Le){const fm=cm.split(" ### ");for(const eC of Xt){let Il=parseInt(o.value.seed.toString());(isNaN(Il)||Il<0)&&(Il=K2());for(let Xc=0;Xc0&&(Fn.params.extra_images=G),Gt().alsoRequestAvi==="Enabled"&&Fn.params.frames&&Fn.params.frames>1&&(Fn.params.video_output_type=2),Se.push(Fn)}}}let Pr=!1;m.value||(Pr=!0,b.value=[]),m.value=!0,Ce.showGeneratedImages=!1;let xn=_.value.filter(ut=>!ut.gathered&&!ut.failed).length;for(let ut=0;ut{a.value.seconds++},1e3);!_.value.every(ut=>ut.gathered||ut.failed)&&!y.value;){const ut=_.value.find(Qt=>!Qt.gathered&&!Qt.failed);if(!ut)break;ut.gathered=!0;try{const Qt=await k(ut.params);if(!Qt){ut.failed=!0;continue}q([{...Qt,...ut}])}catch(Qt){ut.failed=!0,console.error("Error fetching image:",Qt)}}}async function q(te){const be=Ca();console.log(te);const Ce=await Promise.all(te.map(async ve=>{const Se=ve.images[0],Le=!!ve.animated?"gif":"png",ot=ve.extra_data?`data:video/avi;base64,${ve.extra_data}`:"";return{id:-1,image:`data:image/${Le};base64,${Se}`,prompt:ve.prompt,clip_skip:ve.params.clip_skip,modelName:ve.models[0],seed:ve.params.seed,steps:ve.params.steps,sampler_name:ve.params.sampler_name,cfg_scale:ve.params.cfg_scale,width:ve.params.width,height:ve.params.height,frames:ve.params.frames,scheduler:ve.params.scheduler,extra_avi:ot,enable_hr:ve.params.enable_hr}})),xe=await be.pushOutputs(Ce),Ie=0;return b.value=[...xe.map(ve=>({type:"image",index:Ie,output:ve})),...b.value].sort((ve,Se)=>ve.index-Se.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,$t().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ce}async function Z(te){const be=$t();return te&&be.raiseError(te,!1),[]}function ie(te,be,Ce,xe){return be<=Ce?be:($t().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${te}' to its default value instead of ${be}.`,!0),xe)}function he(te,be=!0){const Ce=Xf();if(n.value="Text2Img",u.value.guidance.enabled=!1,u.value.sampler.enabled=!1,Cs.push("/"),be&&(te.width=te.width||Ce.width,te.height=te.height||Ce.height),te.prompt){const xe=te.prompt.split(" ### ");r.value=xe[0],l.value=xe[1]||""}te.sampler_name&&(o.value.sampler_name=te.sampler_name),te.steps&&(o.value.steps=ie("steps",te.steps,A.value,Ce.steps)),te.cfg_scale&&(o.value.cfg_scale=te.cfg_scale),te.width&&(o.value.width=ie("width",te.width,S.value,Ce.width)),te.height&&(o.value.height=ie("height",te.height,S.value,Ce.height)),te.seed&&(o.value.seed=te.seed),te.clip_skip&&(o.value.clip_skip=ie("clip_skip",te.clip_skip,U.value,Ce.clip_skip)),te.scheduler&&(o.value.scheduler=te.scheduler),te.frames&&(o.value.frames=ie("frames",te.frames,Q.value,Ce.frames))}function ge(te){const be=ys();n.value="Img2Img",f.value.sourceImage=te,be.drawing=!1,b.value=[],Cs.push("/"),Jn.fabric.Image.fromURL(te,be.newImage)}function ye(te){const be=ys();b.value=[],c.value.sourceImage=te,n.value="Inpainting",Cs.push("/"),Jn.fabric.Image.fromURL(te,be.newImage)}function H(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Y(){const te=H(),be=te.match(/\{(.*?)\}/g)||[];if(be.length===0)return[te];let Ce=[];return be.forEach(xe=>{const Ie=[],ve=xe.replace("{","").replace("}","").split("|");Ce.length===0?ve.forEach(Se=>{const Me=te.replace(xe,Se);Ie.push(Me)}):Ce.forEach(Se=>{ve.forEach(Me=>{const Le=Se.replace(xe,Me);Ie.push(Le)})}),Ce=[...Ie]}),Ce}async function k(te){const be=Gt();try{const Ce=await fetch(`${be.baseURL.length===0?".":be.baseURL}/sdapi/v1/${te.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}),xe=await Ce.json();return vh(Ce,xe,200,"Failed to fetch",X)?xe:!1}catch{return!1}}function X(te){return $t().raiseError(te,!1),y.value=!1,b.value=[],!1}async function W(){const te=Gt(),be=await fetch(`${te.baseURL.length===0?".":te.baseURL}/sdapi/v1/sd-models`),Ce=await be.json();if(!!vh(be,Ce,200,"Failed to get available models"))return Ce.length===0?"(No model loaded)":Ce[0].model_name}function $(te){g.value.indexOf(te)===-1&&(g.value=[...g.value,te])}function F(te){g.value=g.value.filter(be=>be!=te)}function K(te){if(i.value.findIndex(be=>be.prompt===te)===-1){if(i.value.length>=10+i.value.filter(be=>be.starred).length){const be=i.value.filter(xe=>!xe.starred),Ce=i.value.findIndex(xe=>xe===be[be.length-1]);i.value.splice(Ce,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:te}]}}function de(te){i.value=i.value.filter(be=>be.prompt!=te&&be!=te)}function se(){return!1}var G=[];function me(te){let be=te.target;if(G=[],be.files.length>0)for(let Ce=0;Cenew DataView(new ArrayBuffer(e)),Ba=e=>new Uint8Array(e.buffer||e),Za=e=>new TextEncoder().encode(String(e));function mK(e,t){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,o:Za(e)};if(e instanceof Blob)return{t,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,o:Ba(e)};if(Symbol.asyncIterator in e)return{t,o:G2(e)};throw new TypeError("Unsupported input format.")}function G2(e){const t="next"in e?e:e[Symbol.asyncIterator]();return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await t.next();if(!i.value){n.close();break}{const l=gK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function gK(e){return typeof e=="string"?Za(e):e instanceof Uint8Array?e:Ba(e)}function vK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=Za(t)),e instanceof File)return{i:t||Za(e.name),A:e.size};if(e instanceof Response){const r=e.headers.get("content-disposition"),i=r&&r.match(/;\s*filename\*?=["']?(.*?)["']?$/i),l=i&&i[1]||new URL(e.url).pathname.split("/").pop(),g=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||Za(g),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:Za(e).length}:e instanceof Blob?{i:t,A:e.size}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:t,A:e.byteLength}:{i:t,A:n}}var yK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:bK,m:_K}=yK.exports,wK=Ba(_K).subarray(65536);function _y(e,t=0){for(const n of function*(r){for(;r.length>65536;)yield r.subarray(0,65536),r=r.subarray(65536);r.length&&(yield r)}(e))wK.set(n),t=bK(n.length,t);return t}function q2(e,t,n=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,i=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;t.setUint16(n,r,1),t.setUint16(n+2,i,1)}function CK(e){const t=Yc(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),q2(e.t,t,10),t.setUint16(26,e.i.length,1),Ba(t)}async function*SK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=_y(t,0),e.A=t.length;else{e.A=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.u=_y(r,e.u),e.A+=r.length,yield r}}}function xK(e){const t=Yc(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ba(t)}function TK(e,t){const n=Yc(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),q2(e.t,n,12),n.setUint32(16,e.u,1),n.setUint32(20,e.A,1),n.setUint32(24,e.A,1),n.setUint16(28,e.i.length,1),n.setUint16(40,33204,1),n.setUint32(42,t,1),Ba(n)}function kK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function EK(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};return Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=p(t.metadata)),new Response(G2(async function*(r){const i=[];let l=0,g=0;for await(const u of r)yield CK(u),yield u.i,yield*SK(u),yield xK(u),i.push(TK(u,l)),i.push(u.i),g++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=Yc(22);a.setUint32(0,1347093766),a.setUint16(8,g,1),a.setUint16(10,g,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield Ba(a)}(async function*(r){for await(const i of r){const[l,g]=kK(i);yield Object.assign(mK(...g),vK(...l))}}(e))),{headers:n})}async function Z2(e,t=!0,n){const r=Gt();t&&Di({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;u.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await oa(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await oa(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await oa(u,"image/gif")}):i.push({name:f+".webp",input:await oa(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await EK(i).blob(),g=document.createElement("a");g.href=URL.createObjectURL(l),g.download="sdui_images.zip",g.click()}async function OK(e,t){const n=Gt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await oa(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await oa(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await oa(e,"image/gif"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".gif"):(r.href=e,r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".webp"),r.click(),i&&URL.revokeObjectURL(r.href)}const J2=Ee({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=en(),r=Ca(),i=()=>{hw.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{r.deleteOutput(t.imageData.id),t.onDelete!==void 0&&t.onDelete(t.imageData.id),Di({type:"success",message:"Deleted Image"})})},l=()=>{en().clearOutputs(),$t().showGeneratedImages=!1,en().clearQueue()};async function g(o){const a=window.location.origin,u={prompt:o.prompt,width:o.width?o.width:void 0,height:o.height?o.height:void 0,steps:o.steps,cfg_scale:o.cfg_scale,sampler_name:o.sampler_name,model_name:o.modelName,seed:o.seed,clip_skip:o.clip_skip,frames:o.frames,scheduler:o.scheduler,extra_avi:o.extra_avi,enable_hr:o.enable_hr},h=window.location.pathname.replace("images","");let c=`${a}${h}?share=`,f="",s="";for(const[v,m]of Object.entries(u)){if(!m)continue;let y=m;typeof m=="string"?y=encodeURIComponent(m):Array.isArray(m)&&(y=JSON.stringify(m)),f+=`${s}${v}=${y}`,s="&"}c+=btoa(String.fromCharCode.apply(null,Array.from(NX(f)))),await navigator.clipboard.writeText(c),Di({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(j(),ce(ze,null,[le(C(lt),{onClick:i,type:"danger",size:"small",icon:C(Ec),plain:""},{default:pe(()=>[Ne("Delete")]),_:1},8,["icon"]),le(C(lt),{onClick:a[0]||(a[0]=u=>C(OK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Ls),plain:""},{default:pe(()=>[Ne("Download")]),_:1},8,["icon"]),e.imageData.starred?_e("",!0):(j(),we(C(lt),{key:0,onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(e4),plain:""},{default:pe(()=>[Ne("Star")]),_:1},8,["icon"])),e.imageData.starred?(j(),we(C(lt),{key:1,onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(r_),plain:""},{default:pe(()=>[Ne("Unstar")]),_:1},8,["icon"])):_e("",!0),le(C(lt),{onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Txt2img")]),_:1}),le(C(lt),{onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Img2img")]),_:1}),le(C(lt),{onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Inpaint")]),_:1}),e.showDismiss?(j(),we(C(lt),{key:2,onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Dismiss")]),_:1})):_e("",!0),le(C(lt),{onClick:a[7]||(a[7]=u=>g(e.imageData)),type:"success",icon:C(m3),size:"small",plain:""},{default:pe(()=>[Ne("Share")]),_:1},8,["icon"])],64))}}),AK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},PK=["src"],IK={style:{"font-size":"18px","font-weight":"500"}},MK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},LK={key:0},RK=["onClick"],DK=Ee({__name:"ImageDialog",setup(e){const t=Ca(),n=$t(),r=oe();HI(r,{onSwipeEnd(a,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=oe(t.currentOutputs[0]);ke(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await Lt.outputs.get(n.activeModal)||t.currentOutputs[0]});function g(){i.value=!1}function o(){var v,m;if(!((v=l.value)!=null&&v.extra_avi))return;const a=l.value.extra_avi.split(",")[1];if(!a)return;const u=atob(a),h=u.length,c=new Uint8Array(h);for(let y=0;y{var h;return j(),we(C(DB),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:g,"align-center":""},{footer:pe(()=>[le(J2,{"image-data":l.value,"on-delete":g},null,8,["image-data"])]),default:pe(()=>{var c,f,s,d;return[re("div",{class:"main-output-container",ref_key:"target",ref:r},[re("div",AK,[(c=l.value)!=null&&c.image?(j(),ce("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,PK)):_e("",!0)])],512),re("div",IK,Ae(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),re("div",MK,[re("div",null,"Negative Prompt: "+Ae(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),re("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),re("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),re("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),re("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),re("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),re("span",null,"Clip Skip: "+Ae((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),re("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),re("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.extra_avi?(j(),ce("span",LK,[Ne(" - "),re("a",{href:"#",onClick:Ze(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,RK)])):_e("",!0)])]}),_:1},8,["model-value","width"])}}});const $K=e=>(Qr("data-v-8f4d2380"),e=e(),ei(),e),BK=$K(()=>re("div",{style:{"font-size":"20px"}},"Stable UI",-1)),FK={class:"generator-icons"},zK=Ee({__name:"App",setup(e){const n=up(lp).smallerOrEqual("md"),r=$t();Gt();const i=UT(),l=oe();return ke(()=>i.path,g=>{l.value&&l.value.open(g)}),(g,o)=>(j(),ce(ze,null,[re("div",{class:fe({"menu-container":!C(n)})},[le(C(tw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:fe(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:pe(()=>[C(n)?_e("",!0):(j(),we(C(Ep),{key:0,class:"remove-item-styling center-vertical"},{title:pe(()=>[BK]),_:1})),le(Wo,{isMobile:C(n),index:"/"},{icon:pe(()=>[re("div",FK,[le(C(De),null,{default:pe(()=>[le(C(eO))]),_:1}),C(r).showGeneratorBadge?(j(),we(C(De),{key:0,class:"generator-badge",size:10},{default:pe(()=>[le(WU)]),_:1})):_e("",!0)])]),title:pe(()=>[Ne("Generate")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/images"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(M3))]),_:1})]),title:pe(()=>[Ne("Images")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/about"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(Qb))]),_:1})]),title:pe(()=>[Ne("About")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/options"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(f4))]),_:1})]),title:pe(()=>[Ne("Options")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/return"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(Gb))]),_:1})]),title:pe(()=>[Ne("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),re("div",{class:fe({view:!C(n)})},[le(C(Kb))],2),le(DK)],64))}});const NK=Yt(zK,[["__scopeId","data-v-8f4d2380"]]);const um=Lx(NK);um.use($x());um.use(Cs);um.mount("#app");Cs.replace("/");window.addEventListener("beforeunload",e=>{en().generating&&(e.preventDefault(),e.returnValue="")});const jK={key:1,class:"image-action"},VK=Ee({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=$t(),r=oe(null);wI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=oe(!1);UI(r,([{isIntersecting:g}])=>{g&&(i.value=g)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(g,o)=>(j(),ce("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(j(),we(C(Tp),{key:0,class:"thumbnail",src:e.imageData.image,onClick:o[0]||(o[0]=a=>C(n).activeModal=e.imageData.id),fit:"cover",loading:"lazy",style:Fe(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):_e("",!0),i.value?(j(),ce("div",jK,[e.imageData.starred?(j(),we(C(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:pe(()=>[le(C(r_))]),_:1})):_e("",!0),C(n).multiSelect?(j(),ce("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:pe(()=>[C(l)?_e("",!0):(j(),we(C(fl),{key:0})),C(l)?(j(),we(C(Zb),{key:1})):_e("",!0)]),_:1},8,["color"])])):_e("",!0)])):_e("",!0)],512))}});const wy=Yt(VK,[["__scopeId","data-v-b9569bbd"]]);function UK({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=V_(),i=ee(()=>r.value<=e),l=oe(!0),{y:g}=VI(window);let o=g.value,a=0;return ke(g,u=>{if(!i.value)return;const h=u-o;if(o=u,h>0&&u>t){a+=h,a>=n&&(l.value=!1,a=0);return}h<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const HK={},WK={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},YK=re("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),XK=[YK];function KK(e,t){return j(),ce("svg",WK,XK)}const GK=Yt(HK,[["render",KK]]),qK=e=>(Qr("data-v-b39b47c5"),e=e(),ei(),e),ZK={class:"options"},JK=["onClick"],QK=["onClick"],eG=["onClick"],tG={key:1,class:"center-both",style:{gap:"12px"}},nG={key:2},rG=qK(()=>re("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),iG=[rG],aG={key:0},oG={key:0,style:{display:"flex",gap:"8px"}},sG={key:1,class:"images"},lG={key:1},uG=Ee({__name:"ImagesView",setup(e){const{width:t}=V_(),{isVisible:n,isMobile:r}=UK(),i=Ca(),l=Gt(),g=$t();function o(){g.selected=g.selected.filter(d=>!i.currentOutputs.map(v=>v.id).includes(d)),g.selected=[...g.selected,...i.currentOutputs.map(d=>d.id)],g.multiSelect=!0}async function a(){const d=await Lt.outputs.toCollection().primaryKeys();g.selected=d,g.multiSelect=!0}function u(){g.selected=g.selected.filter(d=>!i.currentOutputs.map(v=>v.id).includes(d)),g.selected.length===0&&(g.multiSelect=!1)}function h(){g.selected=[],g.multiSelect=!1}const c=()=>{hw.confirm(`This action will permanently delete ${g.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(g.selected)})};ev(["a","A","ArrowLeft"],g.openModalToLeft),ev(["d","D","ArrowRight"],g.openModalToRight);async function f(){Z2(g.selected)}const s=ee(()=>{let d=2;t.value>1440?d=6:t.value>1280?d=5:t.value>768?d=4:t.value>480&&(d=3);const v=[];for(let m=0;m(j(),ce(ze,null,[re("div",{class:fe(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[re("div",ZK,[le(C(Xl),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(C(UO))]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt(["Newest","Oldest"],m=>re("div",{key:m,onClick:()=>C(i).sortBy=m,class:fe(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,JK)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(C(WE))]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt(["all","favourited","unfavourited","unrated"],m=>re("div",{key:m,onClick:()=>C(i).filterBy=m,class:fe(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,QK)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(GK)]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>re("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:fe(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,eG)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[C(g).multiSelect?(j(),we(C(Zb),{key:0})):(j(),we(C(fl),{key:1}))]),_:1})]),_:1})]),default:pe(()=>[C(g).multiSelect?(j(),ce("div",{key:0,class:"el-select-dropdown__item selected",onClick:v[0]||(v[0]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Disable multi-select")):(j(),ce("div",{key:1,class:"el-select-dropdown__item",onClick:v[1]||(v[1]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Enable multi-select")),C(g).selected.length>0?(j(),ce("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(j(),ce("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(g).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(j(),ce("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(j(),ce("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(j(),we(C(a9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":v[2]||(v[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):_e("",!0),C(g).multiSelect?(j(),ce("div",tG,[re("div",null,Ae(C(g).selected.length)+" selected",1),le(C(lt),{type:"danger",onClick:c,icon:C(Ec),plain:""},{default:pe(()=>[Ne("Delete")]),_:1},8,["icon"]),le(C(lt),{type:"success",onClick:f,icon:C(Ls),plain:"",style:{margin:"0"}},{default:pe(()=>[Ne("Download")]),_:1},8,["icon"])])):(j(),ce("div",nG,iG))],2),C(i).outputsLength!=0?(j(),ce("div",aG,[C(i).currentLayout==="dynamic"?(j(),ce("div",oG,[(j(!0),ce(ze,null,Dt(C(s),(m,y)=>(j(),ce("div",{key:y,style:{flex:"1 1 0%"}},[(j(!0),ce(ze,null,Dt(m,b=>(j(),we(wy,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):_e("",!0),C(i).currentLayout==="grid"?(j(),ce("div",sG,[(j(!0),ce(ze,null,Dt(C(i).currentOutputs,m=>(j(),we(wy,{key:m.id,"image-data":m,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):_e("",!0)])):_e("",!0),C(i).outputsLength==0?(j(),ce("div",lG,[le(C(OF),{description:"No Images Found"})])):_e("",!0)],64))}});const cG=Yt(uG,[["__scopeId","data-v-b39b47c5"]]),fG=Object.freeze(Object.defineProperty({__proto__:null,default:cG},Symbol.toStringTag,{value:"Module"})),dG=["href"],hG=Ee({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=ht("router-link");return j(),ce(ze,null,[e.router?_e("",!0):(j(),ce("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Te(t.$slots,"default",{},void 0,!0)],8,dG)),e.router?(j(),we(r,{key:1,to:e.href},{default:pe(()=>[Te(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):_e("",!0)],64)}}});const pG=Yt(hG,[["__scopeId","data-v-17b53b7d"]]),Al=e=>(Qr("data-v-ecc278c5"),e=e(),ei(),e),mG={class:"about"},gG={class:"about-content"},vG=Al(()=>re("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),yG=Al(()=>re("div",null,[Ne("This tool was originally a front-end for the AI Horde and has since been converted for local generations with the A1111 API, such as in "),re("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),Ne(".")],-1)),bG=Al(()=>re("br",null,null,-1)),_G=Al(()=>re("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),wG=Al(()=>re("br",null,null,-1)),CG=Ee({__name:"AboutView",setup(e){return(t,n)=>(j(),ce("div",mG,[re("div",gG,[vG,yG,bG,_G,wG,re("div",null,[Ne("You can find the KoboldAI community and authors of this fork on the "),le(pG,{href:"https://koboldai.org/discord"},{default:pe(()=>[Ne("KoboldAI Discord")]),_:1})])])]))}});const SG=Yt(CG,[["__scopeId","data-v-ecc278c5"]]),xG=Object.freeze(Object.defineProperty({__proto__:null,default:SG},Symbol.toStringTag,{value:"Module"}));const Ko=Ee({__name:"FormRadio",props:{label:null,modelValue:null,prop:null,useBoolean:{type:Boolean},options:null,disabled:{type:Boolean},info:null,labelStyle:null,change:null},emits:["update:modelValue"],setup(e,{emit:t}){const n=e;function r(l){if(n.useBoolean&&l==="Enabled"?t("update:modelValue",!0):n.useBoolean&&l==="Disabled"?t("update:modelValue",!1):t("update:modelValue",l),!!n.change)return n.useBoolean&&l==="Enabled"?n.change(!0):n.useBoolean&&l==="Disabled"?n.change(!1):n.change(l)}const i=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(l,g)=>(j(),we(C(Ti),{prop:e.prop},{label:pe(()=>[le(xl,{info:e.info,"label-style":e.labelStyle},{default:pe(()=>[Te(l.$slots,"label",{},()=>[Ne(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:pe(()=>[le(C(C$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:pe(()=>[(j(!0),ce(ze,null,Dt(e.options,o=>(j(),we(C(S$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Te(l.$slots,"inline")]),_:3},8,["prop"]))}}),Pl=e=>(Qr("data-v-b37ed090"),e=e(),ei(),e),TG=Pl(()=>re("h1",null,"Options",-1)),kG=Pl(()=>re("h2",null,"Generation Options",-1)),EG=Pl(()=>re("h2",null,"Image Options",-1)),OG=Pl(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),AG=Pl(()=>re("h2",null,"General Options",-1)),PG=Ee({__name:"OptionsView",setup(e){const t=Gt(),n=Ca(),r=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],i=oe([]),l=oe(),g=oe(!1),o=oe(0);async function a(h){n.importFromZip(h),l.value.clearFiles()}async function u(){Di({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),g.value=!0,o.value=0;const h=await Lt.outputs.toCollection().primaryKeys();await Z2(h,!1,()=>{o.value++}),g.value=!1,o.value=0}return(h,c)=>(j(),ce(ze,null,[TG,le(C(xp),{"label-position":"top",model:C(t).options,onSubmit:c[9]||(c[9]=Ze(()=>{},["prevent"]))},{default:pe(()=>[le(C(Aj),{type:"border-card",style:{"min-height":"50vh"}},{default:pe(()=>[le(C(wf),{label:"\u{1F5A8}\uFE0F Generation"},{default:pe(()=>[kG,le(C(Ti),{label:"Base URL"},{default:pe(()=>[le(C(Ra),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":c[0]||(c[0]=f=>C(t).baseURL=f)},null,8,["modelValue"])]),_:1}),le(Ko,{label:"Allow Larger Params",prop:"pageless",modelValue:C(t).allowLargerParams,"onUpdate:modelValue":c[1]||(c[1]=f=>C(t).allowLargerParams=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:C(t).alsoRequestAvi,"onUpdate:modelValue":c[2]||(c[2]=f=>C(t).alsoRequestAvi=f),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),le(C(wf),{label:"\u{1F4F7} Images"},{default:pe(()=>[EG,le(En,{label:"Images Per Page",prop:"pageSize",modelValue:C(t).pageSize,"onUpdate:modelValue":c[3]||(c[3]=f=>C(t).pageSize=f),min:10,max:50,step:5,disabled:C(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),le(Ko,{label:"Pageless Format",prop:"pageless",modelValue:C(t).pageless,"onUpdate:modelValue":c[4]||(c[4]=f=>C(t).pageless=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:C(t).autoCarousel,"onUpdate:modelValue":c[5]||(c[5]=f=>C(t).autoCarousel=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Image Download Format",prop:"downloadType",modelValue:C(t).imageDownloadType,"onUpdate:modelValue":c[6]||(c[6]=f=>C(t).imageDownloadType=f),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),le(C(Ti),{label:"Export Images (ZIP File)"},{default:pe(()=>[g.value?(j(),we(C(lt),{key:1,icon:C(Ls),disabled:""},{default:pe(()=>[Ne("Downloading... ("+Ae(o.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(j(),we(C(lt),{key:0,icon:C(Ls),onClick:c[7]||(c[7]=f=>u())},{default:pe(()=>[Ne("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Ti),{label:"Import Images (ZIP File)"},{default:pe(()=>[le(C(Pp),{drag:"",ref_key:"upload",ref:l,"auto-upload":!1,onChange:a,"file-list":i.value,limit:1,multiple:""},{default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),OG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(wf),{label:"\u2699\uFE0F General"},{default:pe(()=>[AG,le(Au,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":c[8]||(c[8]=f=>C(t).options.colorMode=f),options:r},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const IG=Yt(PG,[["__scopeId","data-v-b37ed090"]]),MG=Object.freeze(Object.defineProperty({__proto__:null,default:IG},Symbol.toStringTag,{value:"Module"})); +`&&d>0?(c=0,f++,h++):!this.splitByGrapheme&&this._reSpaceAndTab.test(u.graphemeText[f])&&d>0&&(c++,f++),s[d]={line:h,offset:c},f+=u.graphemeLines[d].length,c+=u.graphemeLines[d].length;return s},styleHas:function(u,h){if(this._styleMap&&!this.isWrapping){var c=this._styleMap[h];c&&(h=c.line)}return a.Text.prototype.styleHas.call(this,u,h)},isEmptyStyles:function(u){if(!this.styles)return!0;var h=0,c=u+1,f,s,d=!1,v=this._styleMap[u],m=this._styleMap[u+1];v&&(u=v.line,h=v.offset),m&&(c=m.line,d=c===u,f=m.offset),s=typeof u>"u"?this.styles:{line:this.styles[u]};for(var y in s)for(var b in s[y])if(b>=h&&(!d||bc&&!E?(v.push(m),m=[],s=S,E=!0):s+=A,!E&&!d&&m.push(w),m=m.concat(b),x=d?0:this._measureWord([w],h,_),_++,E=!1,S>T&&(T=S);return N&&v.push(m),T+D>this.dynamicMinWidth&&(this.dynamicMinWidth=T-A+D),v},isEndOfWrapping:function(u){return!this._styleMap[u+1]||this._styleMap[u+1].line!==this._styleMap[u].line},missingNewlineOffset:function(u){return this.splitByGrapheme?this.isEndOfWrapping(u)?1:0:1},_splitTextIntoLines:function(u){for(var h=a.Text.prototype._splitTextIntoLines.call(this,u),c=this._wrapText(h.lines,this.width),f=new Array(c.length),s=0;s{const e=()=>({canvas:void 0,brush:void 0,visibleImageLayer:void 0,imageLayer:void 0,visibleDrawLayer:void 0,drawLayer:void 0,cropPreviewLayer:void 0,maskPathColor:"",maskBackgroundColor:"",imageScale:1,undoHistory:[],redoHistory:[],drawing:!1}),t=oe({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=oe({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>en().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>en().currentImageProps),g=ee({get:()=>i.value.drawing&&!r.value,set:z=>i.value.drawing=z}),o=oe(512),a=oe(512),u=oe(!1),h=oe(30),c=oe(!1),f=new Jn.fabric.Circle({radius:h.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=oe("Erase"),d=oe("rgb(0, 0, 0, 1)");function v(){!i.value.canvas||i.value.canvas.renderAll()}function m(){u.value=!u.value,s.value=u.value?"Draw":"Erase"}function y(z=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=z||i.value.brush.color,i.value.brush.width=h.value)}async function b({history:z,erase:M=!1,draw:L=!1}={}){if(!z||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;z.path.selectable=!1,z.path.opacity=1,z.drawPath=await Q(z.path),z.visibleDrawPath=await Q(z.path),M?(z.visibleDrawPath.globalCompositeOperation="destination-out",z.drawPath.stroke=i.value.maskBackgroundColor):(z.visibleDrawPath.globalCompositeOperation="source-over",z.drawPath.stroke=L?d.value:i.value.maskPathColor);let J=await Q(z.drawPath);J=J.scale(i.value.imageScale),J.left=J.left+z.drawPath.left*(i.value.imageScale-1),J.top=J.top+z.drawPath.top*(i.value.imageScale-1),L?(i.value.imageLayer.add(J),i.value.visibleImageLayer.addWithUpdate(z.visibleDrawPath)):(i.value.drawLayer.add(J),i.value.visibleDrawLayer.addWithUpdate(z.visibleDrawPath)),i.value.canvas.remove(z.path),v()}function _(){if(i.value.undoHistory.length===0)return;const z=i.value.undoHistory.pop();b({history:z,erase:!1,draw:g.value}),i.value.redoHistory.push(z)}function w(){if(i.value.redoHistory.length===0||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;const z=i.value.redoHistory.pop();i.value.undoHistory.push(z),g.value?(i.value.imageLayer.remove(z.drawPath),i.value.visibleImageLayer.remove(z.visibleDrawPath)):(i.value.drawLayer.remove(z.drawPath),i.value.visibleDrawLayer.remove(z.visibleDrawPath)),delete z.drawPath,delete z.visibleDrawPath,v()}function S(z){i.value.canvas=new Jn.fabric.Canvas(z,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",y(i.value.maskPathColor),i.value.canvas.on("mouse:move",I),i.value.canvas.on("path:created",ue),v()}function x(z,M,L,J){let V=J,P=J;return M>L?(z.scaleToWidth(J),V=J*(a.value/o.value)):(z.scaleToHeight(J),P=J*(o.value/a.value)),{newHeight:V,newWidth:P}}function T(z){const M=en();if(O(),z.selectable=!1,o.value=z.width,a.value=z.height,o.value>M.maxDimensions||a.value>M.maxDimensions){const{newHeight:J,newWidth:V}=x(z,o.value,a.value,M.maxDimensions);o.value=V,a.value=J}if(o.value{o.value>a.value?i.value.imageScale=o.value/L:i.value.imageScale=a.value/L,i.value.imageLayer=R({image:J,layerHeight:J.height,layerWidth:J.width})}),z.cloneAsImage(J=>{if(!i.value.canvas)return;if(o.value!==L||a.value!==L){const{newHeight:q,newWidth:Z}=x(J,o.value,a.value,L);o.value=Z,a.value=q}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=B(),i.value.visibleImageLayer=B({image:J}),i.value.drawLayer=R();const V=o.value*i.value.imageScale,P=a.value*i.value.imageScale;M.params.width=V-V%64,M.params.height=P-P%64,i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleImageLayer),i.value.canvas.add(i.value.visibleDrawLayer),i.value.canvas.add(f),c.value=!0,D(),E()})}function E(){const z=en();if(!i.value.imageLayer||!i.value.drawLayer)return;const M=i.value.imageLayer.getCenter().left-z.params.width/2,L=z.params.width,J=i.value.imageLayer.getCenter().top-z.params.height/2,V=z.params.height,P={format:"jpeg",quality:1,left:M,top:J,width:L,height:V};l.value.sourceImage=i.value.imageLayer.toDataURL(P),l.value.maskImage=i.value.redoHistory.length===0||g.value?void 0:i.value.drawLayer.toDataURL(P).split(",")[1]}let A;function D(){if(!i.value.canvas)return;const z=en();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),c.value&&(i.value.cropPreviewLayer=B({layerWidth:z.params.width/i.value.imageScale,layerHeight:z.params.height/i.value.imageScale,fill:"rgba(100, 0, 0, 0.5)"}),i.value.canvas.centerObject(i.value.cropPreviewLayer),i.value.canvas.add(i.value.cropPreviewLayer),A&&clearTimeout(A),A=setTimeout(()=>{c.value=!1,D(),A=void 0},5e3))}function N(z,M){const L="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";Jn.fabric.Image.fromURL(L,J=>{J.set({height:z,width:M});const V=J.toDataURL({format:"png"});l.value.sourceImage=V,g.value=!0,T(J)})}function R({image:z,layerWidth:M,layerHeight:L}={}){const J=new Jn.fabric.Canvas(null);return J.selection=!1,J.backgroundColor=i.value.maskBackgroundColor,J.setHeight(L||a.value),J.setWidth(M||o.value),z&&J.add(z),J}function B({image:z,layerWidth:M,layerHeight:L,fill:J,abosolute:V}={}){const P=z||new Jn.fabric.Rect({width:M||o.value,height:L||a.value,left:0,top:0,fill:J||"transparent",absolutePositioned:V||!0,selectable:!1});return new Jn.fabric.Group([P],{selectable:!1,absolutePositioned:V||!0})}function O(){!i.value.canvas||(i.value.visibleImageLayer&&(i.value.canvas.remove(i.value.visibleImageLayer),i.value.visibleImageLayer=void 0),i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),i.value.imageLayer=void 0,i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.canvas.isDrawingMode=!1)}function U(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),g.value){const z=en();N(z.params.height||512,z.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=B(),i.value.drawLayer=R(),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function ne(){var M;E();const z=document.createElement("a");if(g.value){z.href="data:image/png;base64,"+((M=l.value.sourceImage)==null?void 0:M.split(",")[1]),z.download="image_drawing.png",z.click();return}z.href="data:image/png;base64,"+l.value.maskImage,z.download="image_mask.png",z.click()}async function Q(z){return new Promise((M,L)=>{try{z.clone(M)}catch(J){L(J)}})}async function ue(z){const M={path:z.path};b({history:M,erase:u.value,draw:g.value}),i.value.redoHistory.push(M)}function I(z){if(!i.value.canvas)return;const M=i.value.canvas.getPointer(z.e);f.left=M.x,f.top=M.y,f.opacity=.8,u.value?(f.set("strokeWidth",3),f.set("fill",""),y("red")):(f.set("strokeWidth",0),g.value?(f.set("fill",d.value),y(d.value)):(f.set("fill","white"),y("white"))),f.set("radius",h.value/2),v()}return{showCropPreview:c,erasing:u,switchToolText:s,brushSize:h,drawColor:d,drawing:g,imageProps:i,updateCropPreview:D,createNewCanvas:S,downloadMask:ne,resetCanvas:O,resetDrawing:U,flipErase:m,undoAction:w,redoAction:_,newImage:T,newBlankImage:N,setBrush:y,saveImages:E}});const BH={},FH={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"},zH=re("g",{fill:"none"},[re("path",{d:"M11.197 2.44a1.5 1.5 0 0 1 2.121 0l4.243 4.242a1.5 1.5 0 0 1 0 2.121L9.364 17H14.5a.5.5 0 0 1 0 1H7.82a1.496 1.496 0 0 1-1.14-.437L2.437 13.32a1.5 1.5 0 0 1 0-2.121l8.76-8.76zm1.414.706a.5.5 0 0 0-.707 0L5.538 9.512l4.95 4.95l6.366-6.366a.5.5 0 0 0 0-.707L12.61 3.146zM9.781 15.17l-4.95-4.95l-1.687 1.687a.5.5 0 0 0 0 .707l4.243 4.243a.5.5 0 0 0 .707 0l1.687-1.687z",fill:"currentColor"})],-1),NH=[zH];function jH(e,t){return j(),ce("svg",FH,NH)}const VH=Yt(BH,[["render",jH]]);async function UH(e,t){const n=document.createElement("canvas"),r=n.getContext("2d"),i=new Image;return i.src=e,await new Promise(g=>i.onload=g),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function HH(e,t){const n=e.split(";base64,"),r=t!=null?t:n[0].split(":")[1],i=window.atob(r===n[0].split(":")[1]?n[1]:(await UH(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let g=0;g{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}const em=e=>(Qr("data-v-d200c279"),e=e(),ei(),e),WH=em(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),YH={key:0},XH=em(()=>re("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),KH={class:"canvas-container"},GH=em(()=>re("canvas",{id:"canvas"},null,-1)),qH={class:"action-buttons",style:{left:"10px",right:"unset"}},ZH={class:"action-buttons"},JH=Ee({__name:"CustomCanvas",setup(e){const t=en(),n=$t(),r=ys(),i=oe();async function l(o){if(!o.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const a=await d2(o.raw);t.currentImageProps.sourceImage=a,r.drawing=!1,Jn.fabric.Image.fromURL(a,r.newImage)}function g(){t.currentImageProps.sourceImage="",r.resetCanvas()}return qe(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&Jn.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage)}),(o,a)=>(j(),ce(ze,null,[C(t).currentImageProps.sourceImage?_e("",!0):(j(),we(C(Pp),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:pe(()=>[C(t).generatorType==="Img2Img"?(j(),ce("div",YH,[XH,re("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:a[0]||(a[0]=u=>C(r).newBlankImage(C(t).params.height||512,C(t).params.width||512))},[le(C(De),{size:20,style:{"margin-right":"2px"}},{default:pe(()=>[le(u2)]),_:1}),Ne("draw something")])])):_e("",!0)]),default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),WH]),_:1},512)),yt(re("div",null,[re("div",KH,[GH,re("div",qH,[le(C(lt),{onClick:a[1]||(a[1]=u=>C(r).undoAction()),icon:C(t_),plain:"",disabled:C(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),le(C(lt),{onClick:a[2]||(a[2]=u=>C(r).redoAction()),icon:C(n_),plain:"",disabled:C(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),re("div",ZH,[le(C(lt),{onClick:a[3]||(a[3]=u=>C(r).resetDrawing()),icon:C(Sr),plain:""},null,8,["icon"]),le(C(lt),{onClick:g,icon:C(Ec),plain:""},null,8,["icon"]),le(C(lt),{onClick:a[4]||(a[4]=u=>C(r).downloadMask()),icon:C(Ls),plain:""},null,8,["icon"]),le(C(lt),{onClick:a[5]||(a[5]=u=>C(r).flipErase()),icon:C(r).erasing?C(zE):VH,plain:""},null,8,["icon"]),C(r).drawing?(j(),we(C(vB),{key:0,modelValue:C(r).drawColor,"onUpdate:modelValue":a[6]||(a[6]=u=>C(r).drawColor=u),"show-alpha":""},null,8,["modelValue"])):_e("",!0)]),le(C(xp),{"label-width":"110px",style:{"margin-top":"10px"}},{default:pe(()=>[le(En,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:C(r).brushSize,"onUpdate:modelValue":a[7]||(a[7]=u=>C(r).brushSize=u),min:10,max:100,step:10,change:C(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Rt,C(t).currentImageProps.sourceImage]])],64))}});const M0=Yt(JH,[["__scopeId","data-v-d200c279"]]),QH={class:"centerIcons"},eW={class:"stackedIcons"},tW=Ee({__name:"StackedIcon",props:{iconOne:null,iconTwo:null,size:null},setup(e){const t=e;return gx(n=>({"2ad037ca":e.size+"px"})),(n,r)=>(j(),ce("div",QH,[re("div",eW,[le(C(De),{class:"firstIcon",size:e.size},{default:pe(()=>[(j(),we(Ct(t.iconOne)))]),_:1},8,["size"]),le(C(De),{class:"secondIcon",size:e.size},{default:pe(()=>[(j(),we(Ct(t.iconTwo)))]),_:1},8,["size"])])]))}});const nW=Yt(tW,[["__scopeId","data-v-74586a39"]]),rW={key:1,style:{width:"40px"}},nu=Ee({__name:"GeneratorMenuItem",props:{index:null,iconOne:null,iconTwo:null,isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(j(),we(C(Or),{content:e.index,placement:e.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:pe(()=>[le(C(Ep),{index:e.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:pe(()=>[e.iconTwo?(j(),we(nW,{key:0,iconOne:e.iconOne,iconTwo:e.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(j(),ce("div",rW,[le(C(De),{style:{width:"35px"},size:40},{default:pe(()=>[(j(),we(Ct(t.iconOne)))]),_:1})]))]),_:1},8,["index"])]),_:1},8,["content","placement"]))}});/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const iW=4,L0=0,R0=1,aW=2;function Lo(e){let t=e.length;for(;--t>=0;)e[t]=0}const oW=0,h2=1,sW=2,lW=3,uW=258,tm=29,Tl=256,el=Tl+1+tm,io=30,nm=19,p2=2*el+1,sa=15,Lf=16,cW=7,rm=256,m2=16,g2=17,v2=18,lh=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),fW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),y2=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dW=512,Nr=new Array((el+2)*2);Lo(Nr);const bs=new Array(io*2);Lo(bs);const tl=new Array(dW);Lo(tl);const nl=new Array(uW-lW+1);Lo(nl);const im=new Array(tm);Lo(im);const sc=new Array(io);Lo(sc);function Rf(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let b2,_2,w2;function Df(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const C2=e=>e<256?tl[e]:tl[256+(e>>>7)],rl=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},yn=(e,t,n)=>{e.bi_valid>Lf-n?(e.bi_buf|=t<>Lf-e.bi_valid,e.bi_valid+=n-Lf):(e.bi_buf|=t<{yn(e,n[t*2],n[t*2+1])},S2=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},hW=e=>{e.bi_valid===16?(rl(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},pW=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,g=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let u,h,c,f,s,d,v=0;for(f=0;f<=sa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;ua&&(f=a,v++),n[h*2+1]=f,!(h>r)&&(e.bl_count[f]++,s=0,h>=o&&(s=g[h-o]),d=n[h*2],e.opt_len+=d*(f+s),l&&(e.static_len+=d*(i[h*2+1]+s)));if(v!==0){do{for(f=a-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[a]--,v-=2}while(v>0);for(f=a;f!==0;f--)for(h=e.bl_count[f];h!==0;)c=e.heap[--u],!(c>r)&&(n[c*2+1]!==f&&(e.opt_len+=(f-n[c*2+1])*n[c*2],n[c*2+1]=f),h--)}},x2=(e,t,n)=>{const r=new Array(sa+1);let i=0,l,g;for(l=1;l<=sa;l++)i=i+n[l-1]<<1,r[l]=i;for(g=0;g<=t;g++){let o=e[g*2+1];o!==0&&(e[g*2]=S2(r[o]++,o))}},mW=()=>{let e,t,n,r,i;const l=new Array(sa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?rl(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},D0=(e,t,n,r)=>{const i=t*2,l=n*2;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,l=0,g,o;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+l++]&255,r+=(e.pending_buf[e.sym_buf+l++]&255)<<8,i=e.pending_buf[e.sym_buf+l++],r===0?gr(e,i,t):(g=nl[i],gr(e,g+Tl+1,t),o=lh[g],o!==0&&(i-=im[g],yn(e,i,o)),r--,g=C2(r),gr(e,g,n),o=Pu[g],o!==0&&(r-=sc[g],yn(e,r,o)));while(l{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,l=t.stat_desc.elems;let g,o,a=-1,u;for(e.heap_len=0,e.heap_max=p2,g=0;g>1;g>=1;g--)$f(e,n,g);u=l;do g=e.heap[1],e.heap[1]=e.heap[e.heap_len--],$f(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=g,e.heap[--e.heap_max]=o,n[u*2]=n[g*2]+n[o*2],e.depth[u]=(e.depth[g]>=e.depth[o]?e.depth[g]:e.depth[o])+1,n[g*2+1]=n[o*2+1]=u,e.heap[1]=u++,$f(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],pW(e,t),x2(n,a,e.bl_count)},B0=(e,t,n)=>{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=g,g=t[(r+1)*2+1],!(++o{let r,i=-1,l,g=t[0*2+1],o=0,a=7,u=4;for(g===0&&(a=138,u=3),r=0;r<=n;r++)if(l=g,g=t[(r+1)*2+1],!(++o{let t;for(B0(e,e.dyn_ltree,e.l_desc.max_code),B0(e,e.dyn_dtree,e.d_desc.max_code),uh(e,e.bl_desc),t=nm-1;t>=3&&e.bl_tree[y2[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},vW=(e,t,n,r)=>{let i;for(yn(e,t-257,5),yn(e,n-1,5),yn(e,r-4,4),i=0;i{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return L0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return R0;for(n=32;n{z0||(mW(),z0=!0),e.l_desc=new Df(e.dyn_ltree,b2),e.d_desc=new Df(e.dyn_dtree,_2),e.bl_desc=new Df(e.bl_tree,w2),e.bi_buf=0,e.bi_valid=0,T2(e)},E2=(e,t,n,r)=>{yn(e,(oW<<1)+(r?1:0),3),k2(e),rl(e,n),rl(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},_W=e=>{yn(e,h2<<1,3),gr(e,rm,Nr),hW(e)},wW=(e,t,n,r)=>{let i,l,g=0;e.level>0?(e.strm.data_type===aW&&(e.strm.data_type=yW(e)),uh(e,e.l_desc),uh(e,e.d_desc),g=gW(e),i=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=i&&(i=l)):i=l=n+5,n+4<=i&&t!==-1?E2(e,t,n,r):e.strategy===iW||l===i?(yn(e,(h2<<1)+(r?1:0),3),$0(e,Nr,bs)):(yn(e,(sW<<1)+(r?1:0),3),vW(e,e.l_desc.max_code+1,e.d_desc.max_code+1,g+1),$0(e,e.dyn_ltree,e.dyn_dtree)),T2(e),r&&k2(e)},CW=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(nl[n]+Tl+1)*2]++,e.dyn_dtree[C2(t)*2]++),e.sym_next===e.sym_end);var SW=bW,xW=E2,TW=wW,kW=CW,EW=_W,OW={_tr_init:SW,_tr_stored_block:xW,_tr_flush_block:TW,_tr_tally:kW,_tr_align:EW};const AW=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,g=0;for(;n!==0;){g=n>2e3?2e3:n,n-=g;do i=i+t[r++]|0,l=l+i|0;while(--g);i%=65521,l%=65521}return i|l<<16|0};var il=AW;const PW=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},IW=new Uint32Array(PW()),MW=(e,t,n,r)=>{const i=IW,l=r+n;e^=-1;for(let g=r;g>>8^i[(e^t[g])&255];return e^-1};var Vt=MW,Sa={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ro={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:LW,_tr_stored_block:ch,_tr_flush_block:RW,_tr_tally:ki,_tr_align:DW}=OW,{Z_NO_FLUSH:Ei,Z_PARTIAL_FLUSH:$W,Z_FULL_FLUSH:BW,Z_FINISH:jn,Z_BLOCK:N0,Z_OK:Kt,Z_STREAM_END:j0,Z_STREAM_ERROR:wr,Z_DATA_ERROR:FW,Z_BUF_ERROR:Bf,Z_DEFAULT_COMPRESSION:zW,Z_FILTERED:NW,Z_HUFFMAN_ONLY:ru,Z_RLE:jW,Z_FIXED:VW,Z_DEFAULT_STRATEGY:UW,Z_UNKNOWN:HW,Z_DEFLATED:Uc}=Ro,WW=9,YW=15,XW=8,KW=29,GW=256,fh=GW+1+KW,qW=30,ZW=19,JW=2*fh+1,QW=15,nt=3,Ci=258,Cr=Ci+nt+1,eY=32,bo=42,am=57,dh=69,hh=73,ph=91,mh=103,la=113,es=666,dn=1,Do=2,xa=3,$o=4,tY=3,ua=(e,t)=>(e.msg=Sa[t],t),V0=e=>e*2-(e>4?9:0),bi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},nY=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)};let rY=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},Ln=(e,t)=>{RW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,On(e.strm)},dt=(e,t)=>{e.pending_buf[e.pending++]=t},Xo=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},gh=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=il(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},O2=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,g=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Cr?e.strstart-(e.w_size-Cr):0,u=e.window,h=e.w_mask,c=e.prev,f=e.strstart+Ci;let s=u[r+g-1],d=u[r+g];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(u[i+g]!==d||u[i+g-1]!==s||u[i]!==u[r]||u[++i]!==u[r+1])){r+=2,i++;do;while(u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&u[++r]===u[++i]&&rg){if(e.match_start=t,g=l,l>=o)break;s=u[r+g-1],d=u[r+g]}}while((t=c[t&h])>a&&--n!==0);return g<=e.lookahead?g:e.lookahead},_o=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Cr)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),nY(e),r+=t),e.strm.avail_in===0)break;if(n=gh(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=nt)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Oi(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Oi(e,e.ins_h,e.window[i+nt-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,l,g=0,o=e.strm.avail_in;do{if(r=65535,l=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(r=i+e.strm.avail_in),r>l&&(r=l),r>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,On(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(gh(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(g===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_waterl&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,l+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),l>e.strm.avail_in&&(l=e.strm.avail_in),l&&(gh(e.strm,e.window,e.strstart,l),e.strstart+=l,e.insert+=l>e.w_size-e.insert?e.w_size-e.insert:l),e.high_water>3,l=e.pending_buf_size-l>65535?65535:e.pending_buf_size-l,n=l>e.w_size?e.w_size:l,i=e.strstart-e.block_start,(i>=n||(i||t===jn)&&t!==Ei&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,g=t===jn&&e.strm.avail_in===0&&r===i?1:0,ch(e,e.block_start,r,g),e.block_start+=r,On(e.strm)),g?xa:dn)},Ff=(e,t)=>{let n,r;for(;;){if(e.lookahead=nt&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Cr&&(e.match_length=O2(e,n)),e.match_length>=nt)if(r=ki(e,e.strstart-e.match_start,e.match_length-nt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=nt){e.match_length--;do e.strstart++,e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+1]);else r=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=nt&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=nt-1,n!==0&&e.prev_length4096)&&(e.match_length=nt-1)),e.prev_length>=nt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-nt,r=ki(e,e.strstart-1-e.prev_match,e.prev_length-nt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Oi(e,e.ins_h,e.window[e.strstart+nt-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=nt-1,e.strstart++,r&&(Ln(e,!1),e.strm.avail_out===0))return dn}else if(e.match_available){if(r=ki(e,0,e.window[e.strstart-1]),r&&Ln(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return dn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ki(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const g=e.window;for(;;){if(e.lookahead<=Ci){if(_o(e),e.lookahead<=Ci&&t===Ei)return dn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=nt&&e.strstart>0&&(i=e.strstart-1,r=g[i],r===g[++i]&&r===g[++i]&&r===g[++i])){l=e.strstart+Ci;do;while(r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&r===g[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=nt?(n=ki(e,1,e.match_length-nt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=0,t===jn?(Ln(e,!0),e.strm.avail_out===0?xa:$o):e.sym_next&&(Ln(e,!1),e.strm.avail_out===0)?dn:Do},aY=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(_o(e),e.lookahead===0)){if(t===Ei)return dn;break}if(e.match_length=0,n=ki(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Ln(e,!1),e.strm.avail_out===0))return dn}return e.insert=0,t===jn?(Ln(e,!0),e.strm.avail_out===0?xa:$o):e.sym_next&&(Ln(e,!1),e.strm.avail_out===0)?dn:Do};function dr(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const ts=[new dr(0,0,0,0,A2),new dr(4,4,8,4,Ff),new dr(4,5,16,8,Ff),new dr(4,6,32,32,Ff),new dr(4,4,16,16,Ha),new dr(8,16,32,32,Ha),new dr(8,16,128,128,Ha),new dr(8,32,128,256,Ha),new dr(32,128,258,1024,Ha),new dr(32,258,258,4096,Ha)],oY=e=>{e.window_size=2*e.w_size,bi(e.head),e.max_lazy_match=ts[e.level].max_lazy,e.good_match=ts[e.level].good_length,e.nice_match=ts[e.level].nice_length,e.max_chain_length=ts[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=nt-1,e.match_available=0,e.ins_h=0};function sY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Uc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(JW*2),this.dyn_dtree=new Uint16Array((2*qW+1)*2),this.bl_tree=new Uint16Array((2*ZW+1)*2),bi(this.dyn_ltree),bi(this.dyn_dtree),bi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(QW+1),this.heap=new Uint16Array(2*fh+1),bi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*fh+1),bi(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const kl=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==bo&&t.status!==am&&t.status!==dh&&t.status!==hh&&t.status!==ph&&t.status!==mh&&t.status!==la&&t.status!==es?1:0},P2=e=>{if(kl(e))return ua(e,wr);e.total_in=e.total_out=0,e.data_type=HW;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?am:t.wrap?bo:la,e.adler=t.wrap===2?0:1,t.last_flush=-2,LW(t),Kt},I2=e=>{const t=P2(e);return t===Kt&&oY(e.state),t},lY=(e,t)=>kl(e)||e.state.wrap!==2?wr:(e.state.gzhead=t,Kt),M2=(e,t,n,r,i,l)=>{if(!e)return wr;let g=1;if(t===zW&&(t=6),r<0?(g=0,r=-r):r>15&&(g=2,r-=16),i<1||i>WW||n!==Uc||r<8||r>15||t<0||t>9||l<0||l>VW||r===8&&g!==1)return ua(e,wr);r===8&&(r=9);const o=new sY;return e.state=o,o.strm=e,o.status=bo,o.wrap=g,o.gzhead=null,o.w_bits=r,o.w_size=1<M2(e,t,Uc,YW,XW,UW),cY=(e,t)=>{if(kl(e)||t>N0||t<0)return e?ua(e,wr):wr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===es&&t!==jn)return ua(e,e.avail_out===0?Bf:wr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(On(e),e.avail_out===0)return n.last_flush=-1,Kt}else if(e.avail_in===0&&V0(t)<=V0(r)&&t!==jn)return ua(e,Bf);if(n.status===es&&e.avail_in!==0)return ua(e,Bf);if(n.status===bo&&n.wrap===0&&(n.status=la),n.status===bo){let i=Uc+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=ru||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=eY),i+=31-i%31,Xo(n,i),n.strstart!==0&&(Xo(n,e.adler>>>16),Xo(n,e.adler&65535)),e.adler=1,n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(n.status===am){if(e.adler=0,dt(n,31),dt(n,139),dt(n,8),n.gzhead)dt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),dt(n,n.gzhead.time&255),dt(n,n.gzhead.time>>8&255),dt(n,n.gzhead.time>>16&255),dt(n,n.gzhead.time>>24&255),dt(n,n.level===9?2:n.strategy>=ru||n.level<2?4:0),dt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(dt(n,n.gzhead.extra.length&255),dt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=dh;else if(dt(n,0),dt(n,0),dt(n,0),dt(n,0),dt(n,0),dt(n,n.level===9?2:n.strategy>=ru||n.level<2?4:0),dt(n,tY),n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(n.status===dh){if(n.gzhead.extra){let i=n.pending,l=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+l>n.pending_buf_size;){let o=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0,l-=o}let g=new Uint8Array(n.gzhead.extra);n.pending_buf.set(g.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=hh}if(n.status===hh){if(n.gzhead.name){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0}n.gzindexi&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=ph}if(n.status===ph){if(n.gzhead.comment){let i=n.pending,l;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i)),On(e),n.pending!==0)return n.last_flush=-1,Kt;i=0}n.gzindexi&&(e.adler=Vt(e.adler,n.pending_buf,n.pending-i,i))}n.status=mh}if(n.status===mh){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(On(e),n.pending!==0))return n.last_flush=-1,Kt;dt(n,e.adler&255),dt(n,e.adler>>8&255),e.adler=0}if(n.status=la,On(e),n.pending!==0)return n.last_flush=-1,Kt}if(e.avail_in!==0||n.lookahead!==0||t!==Ei&&n.status!==es){let i=n.level===0?A2(n,t):n.strategy===ru?aY(n,t):n.strategy===jW?iY(n,t):ts[n.level].func(n,t);if((i===xa||i===$o)&&(n.status=es),i===dn||i===xa)return e.avail_out===0&&(n.last_flush=-1),Kt;if(i===Do&&(t===$W?DW(n):t!==N0&&(ch(n,0,0,!1),t===BW&&(bi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),On(e),e.avail_out===0))return n.last_flush=-1,Kt}return t!==jn?Kt:n.wrap<=0?j0:(n.wrap===2?(dt(n,e.adler&255),dt(n,e.adler>>8&255),dt(n,e.adler>>16&255),dt(n,e.adler>>24&255),dt(n,e.total_in&255),dt(n,e.total_in>>8&255),dt(n,e.total_in>>16&255),dt(n,e.total_in>>24&255)):(Xo(n,e.adler>>>16),Xo(n,e.adler&65535)),On(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Kt:j0)},fY=e=>{if(kl(e))return wr;const t=e.state.status;return e.state=null,t===la?ua(e,FW):Kt},dY=(e,t)=>{let n=t.length;if(kl(e))return wr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==bo||r.lookahead)return wr;if(i===1&&(e.adler=il(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(bi(r.head),r.strstart=0,r.block_start=0,r.insert=0);let a=new Uint8Array(r.w_size);a.set(t.subarray(n-r.w_size,n),0),t=a,n=r.w_size}const l=e.avail_in,g=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,_o(r);r.lookahead>=nt;){let a=r.strstart,u=r.lookahead-(nt-1);do r.ins_h=Oi(r,r.ins_h,r.window[a+nt-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--u);r.strstart=a,r.lookahead=nt-1,_o(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=nt-1,r.match_available=0,e.next_in=g,e.input=o,e.avail_in=l,r.wrap=i,Kt};var hY=uY,pY=M2,mY=I2,gY=P2,vY=lY,yY=cY,bY=fY,_Y=dY,wY="pako deflate (from Nodeca project)",_s={deflateInit:hY,deflateInit2:pY,deflateReset:mY,deflateResetKeep:gY,deflateSetHeader:vY,deflate:yY,deflateEnd:bY,deflateSetDictionary:_Y,deflateInfo:wY};const CY=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var SY=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(!!n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)CY(n,r)&&(e[r]=n[r])}}return e},xY=e=>{let t=0;for(let r=0,i=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;al[254]=al[254]=1;var TY=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,g=e.length,o=0;for(i=0;i>>6,t[l++]=128|n&63):n<65536?(t[l++]=224|n>>>12,t[l++]=128|n>>>6&63,t[l++]=128|n&63):(t[l++]=240|n>>>18,t[l++]=128|n>>>12&63,t[l++]=128|n>>>6&63,t[l++]=128|n&63);return t};const kY=(e,t)=>{if(t<65534&&e.subarray&&L2)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i;const l=new Array(n*2);for(i=0,r=0;r4){l[i++]=65533,r+=o-1;continue}for(g&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}g<65536?l[i++]=g:(g-=65536,l[i++]=55296|g>>10&1023,l[i++]=56320|g&1023)}return kY(l,i)},OY=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+al[e[n]]>t?n:t},ol={string2buf:TY,buf2string:EY,utf8border:OY};function AY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var R2=AY;const D2=Object.prototype.toString,{Z_NO_FLUSH:PY,Z_SYNC_FLUSH:IY,Z_FULL_FLUSH:MY,Z_FINISH:LY,Z_OK:lc,Z_STREAM_END:RY,Z_DEFAULT_COMPRESSION:DY,Z_DEFAULT_STRATEGY:$Y,Z_DEFLATED:BY}=Ro;function El(e){this.options=Hc.assign({level:DY,method:BY,chunkSize:16384,windowBits:15,memLevel:8,strategy:$Y},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new R2,this.strm.avail_out=0;let n=_s.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==lc)throw new Error(Sa[n]);if(t.header&&_s.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=ol.string2buf(t.dictionary):D2.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=_s.deflateSetDictionary(this.strm,r),n!==lc)throw new Error(Sa[n]);this._dict_set=!0}}El.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,l;if(this.ended)return!1;for(t===~~t?l=t:l=t===!0?LY:PY,typeof e=="string"?n.input=ol.string2buf(e):D2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(l===IY||l===MY)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=_s.deflate(n,l),i===RY)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=_s.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===lc;if(n.avail_out===0){this.onData(n.output);continue}if(l>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};El.prototype.onData=function(e){this.chunks.push(e)};El.prototype.onEnd=function(e){e===lc&&(this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function om(e,t){const n=new El(t);if(n.push(e,!0),n.err)throw n.msg||Sa[n.err];return n.result}function FY(e,t){return t=t||{},t.raw=!0,om(e,t)}function zY(e,t){return t=t||{},t.gzip=!0,om(e,t)}var NY=El,jY=om,VY=FY,UY=zY,HY=Ro,WY={Deflate:NY,deflate:jY,deflateRaw:VY,gzip:UY,constants:HY};const iu=16209,YY=16191;var XY=function(t,n){let r,i,l,g,o,a,u,h,c,f,s,d,v,m,y,b,_,w,S,x,T,E,A,D;const N=t.state;r=t.next_in,A=t.input,i=r+(t.avail_in-5),l=t.next_out,D=t.output,g=l-(n-t.avail_out),o=l+(t.avail_out-257),a=N.dmax,u=N.wsize,h=N.whave,c=N.wnext,f=N.window,s=N.hold,d=N.bits,v=N.lencode,m=N.distcode,y=(1<>>24,s>>>=w,d-=w,w=_>>>16&255,w===0)D[l++]=_&65535;else if(w&16){S=_&65535,w&=15,w&&(d>>=w,d-=w),d<15&&(s+=A[r++]<>>24,s>>>=w,d-=w,w=_>>>16&255,w&16){if(x=_&65535,w&=15,da){t.msg="invalid distance too far back",N.mode=iu;break e}if(s>>>=w,d-=w,w=l-g,x>w){if(w=x-w,w>h&&N.sane){t.msg="invalid distance too far back",N.mode=iu;break e}if(T=0,E=f,c===0){if(T+=u-w,w2;)D[l++]=E[T++],D[l++]=E[T++],D[l++]=E[T++],S-=3;S&&(D[l++]=E[T++],S>1&&(D[l++]=E[T++]))}else{T=l-x;do D[l++]=D[T++],D[l++]=D[T++],D[l++]=D[T++],S-=3;while(S>2);S&&(D[l++]=D[T++],S>1&&(D[l++]=D[T++]))}}else if((w&64)===0){_=m[(_&65535)+(s&(1<>3,r-=S,d-=S<<3,s&=(1<{const a=o.bits;let u=0,h=0,c=0,f=0,s=0,d=0,v=0,m=0,y=0,b=0,_,w,S,x,T,E=null,A;const D=new Uint16Array(Wa+1),N=new Uint16Array(Wa+1);let R=null,B,O,U;for(u=0;u<=Wa;u++)D[u]=0;for(h=0;h=1&&D[f]===0;f--);if(s>f&&(s=f),f===0)return i[l++]=1<<24|64<<16|0,i[l++]=1<<24|64<<16|0,o.bits=1,0;for(c=1;c0&&(e===W0||f!==1))return-1;for(N[1]=0,u=1;uU0||e===Y0&&y>H0)return 1;for(;;){B=u-v,g[h]+1=A?(O=R[g[h]-A],U=E[g[h]-A]):(O=32+64,U=0),_=1<>v)+w]=B<<24|O<<16|U|0;while(w!==0);for(_=1<>=1;if(_!==0?(b&=_-1,b+=_):b=0,h++,--D[u]===0){if(u===f)break;u=t[n+g[h]]}if(u>s&&(b&x)!==S){for(v===0&&(v=s),T+=c,d=u-v,m=1<U0||e===Y0&&y>H0)return 1;S=b&x,i[S]=s<<24|d<<16|T-l|0}}return b!==0&&(i[T+b]=u-v<<24|64<<16|0),o.bits=s,0};var ws=JY;const QY=0,$2=1,B2=2,{Z_FINISH:X0,Z_BLOCK:eX,Z_TREES:au,Z_OK:Ta,Z_STREAM_END:tX,Z_NEED_DICT:nX,Z_STREAM_ERROR:Xn,Z_DATA_ERROR:F2,Z_MEM_ERROR:z2,Z_BUF_ERROR:rX,Z_DEFLATED:K0}=Ro,Wc=16180,G0=16181,q0=16182,Z0=16183,J0=16184,Q0=16185,ey=16186,ty=16187,ny=16188,ry=16189,uc=16190,Rr=16191,Nf=16192,iy=16193,jf=16194,ay=16195,oy=16196,sy=16197,ly=16198,ou=16199,su=16200,uy=16201,cy=16202,fy=16203,dy=16204,hy=16205,Vf=16206,py=16207,my=16208,It=16209,N2=16210,j2=16211,iX=852,aX=592,oX=15,sX=oX,gy=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function lX(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const $a=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modej2?1:0},V2=e=>{if($a(e))return Xn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Wc,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(iX),t.distcode=t.distdyn=new Int32Array(aX),t.sane=1,t.back=-1,Ta},U2=e=>{if($a(e))return Xn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,V2(e)},H2=(e,t)=>{let n;if($a(e))return Xn;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Xn:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,U2(e))},W2=(e,t)=>{if(!e)return Xn;const n=new lX;e.state=n,n.strm=e,n.window=null,n.mode=Wc;const r=H2(e,t);return r!==Ta&&(e.state=null),r},uX=e=>W2(e,sX);let vy=!0,Uf,Hf;const cX=e=>{if(vy){Uf=new Int32Array(512),Hf=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ws($2,e.lens,0,288,Uf,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ws(B2,e.lens,0,32,Hf,0,e.work,{bits:5}),vy=!1}e.lencode=Uf,e.lenbits=9,e.distcode=Hf,e.distbits=5},Y2=(e,t,n,r)=>{let i;const l=e.state;return l.window===null&&(l.wsize=1<=l.wsize?(l.window.set(t.subarray(n-l.wsize,n),0),l.wnext=0,l.whave=l.wsize):(i=l.wsize-l.wnext,i>r&&(i=r),l.window.set(t.subarray(n-r,n-r+i),l.wnext),r-=i,r?(l.window.set(t.subarray(n-r,n),0),l.wnext=r,l.whave=l.wsize):(l.wnext+=i,l.wnext===l.wsize&&(l.wnext=0),l.whave{let n,r,i,l,g,o,a,u,h,c,f,s,d,v,m=0,y,b,_,w,S,x,T,E;const A=new Uint8Array(4);let D,N;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if($a(e)||!e.output||!e.input&&e.avail_in!==0)return Xn;n=e.state,n.mode===Rr&&(n.mode=Nf),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,c=o,f=a,E=Ta;e:for(;;)switch(n.mode){case Wc:if(n.wrap===0){n.mode=Nf;break}for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Vt(n.check,A,2,0),u=0,h=0,n.mode=G0;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=It;break}if((u&15)!==K0){e.msg="unknown compression method",n.mode=It;break}if(u>>>=4,h-=4,T=(u&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=It;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(A[0]=u&255,A[1]=u>>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0,n.mode=q0;case q0:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,n.check=Vt(n.check,A,4,0)),u=0,h=0,n.mode=Z0;case Z0:for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>8),n.flags&512&&n.wrap&4&&(A[0]=u&255,A[1]=u>>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0,n.mode=J0;case J0:if(n.flags&1024){for(;h<16;){if(o===0)break e;o--,u+=r[l++]<>>8&255,n.check=Vt(n.check,A,2,0)),u=0,h=0}else n.head&&(n.head.extra=null);n.mode=Q0;case Q0:if(n.flags&1024&&(s=n.length,s>o&&(s=o),s&&(n.head&&(T=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(l,l+s),T)),n.flags&512&&n.wrap&4&&(n.check=Vt(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=ey;case ey:if(n.flags&2048){if(o===0)break e;s=0;do T=r[l+s++],n.head&&T&&n.length<65536&&(n.head.name+=String.fromCharCode(T));while(T&&s>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Rr;break;case ry:for(;h<32;){if(o===0)break e;o--,u+=r[l++]<>>=h&7,h-=h&7,n.mode=Vf;break}for(;h<3;){if(o===0)break e;o--,u+=r[l++]<>>=1,h-=1,u&3){case 0:n.mode=iy;break;case 1:if(cX(n),n.mode=ou,t===au){u>>>=2,h-=2;break e}break;case 2:n.mode=oy;break;case 3:e.msg="invalid block type",n.mode=It}u>>>=2,h-=2;break;case iy:for(u>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,u+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=It;break}if(n.length=u&65535,u=0,h=0,n.mode=jf,t===au)break e;case jf:n.mode=ay;case ay:if(s=n.length,s){if(s>o&&(s=o),s>a&&(s=a),s===0)break e;i.set(r.subarray(l,l+s),g),o-=s,l+=s,a-=s,g+=s,n.length-=s;break}n.mode=Rr;break;case oy:for(;h<14;){if(o===0)break e;o--,u+=r[l++]<>>=5,h-=5,n.ndist=(u&31)+1,u>>>=5,h-=5,n.ncode=(u&15)+4,u>>>=4,h-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=It;break}n.have=0,n.mode=sy;case sy:for(;n.have>>=3,h-=3}for(;n.have<19;)n.lens[R[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,D={bits:n.lenbits},E=ws(QY,n.lens,0,19,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid code lengths set",n.mode=It;break}n.have=0,n.mode=ly;case ly:for(;n.have>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=y,h-=y,n.lens[n.have++]=_;else{if(_===16){for(N=y+2;h>>=y,h-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=It;break}T=n.lens[n.have-1],s=3+(u&3),u>>>=2,h-=2}else if(_===17){for(N=y+3;h>>=y,h-=y,T=0,s=3+(u&7),u>>>=3,h-=3}else{for(N=y+7;h>>=y,h-=y,T=0,s=11+(u&127),u>>>=7,h-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=It;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===It)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=It;break}if(n.lenbits=9,D={bits:n.lenbits},E=ws($2,n.lens,0,n.nlen,n.lencode,0,n.work,D),n.lenbits=D.bits,E){e.msg="invalid literal/lengths set",n.mode=It;break}if(n.distbits=6,n.distcode=n.distdyn,D={bits:n.distbits},E=ws(B2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,D),n.distbits=D.bits,E){e.msg="invalid distances set",n.mode=It;break}if(n.mode=ou,t===au)break e;case ou:n.mode=su;case su:if(o>=6&&a>=258){e.next_out=g,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=u,n.bits=h,XY(e,f),g=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,u=n.hold,h=n.bits,n.mode===Rr&&(n.back=-1);break}for(n.back=0;m=n.lencode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,n.length=_,b===0){n.mode=hy;break}if(b&32){n.back=-1,n.mode=Rr;break}if(b&64){e.msg="invalid literal/length code",n.mode=It;break}n.extra=b&15,n.mode=uy;case uy:if(n.extra){for(N=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=cy;case cy:for(;m=n.distcode[u&(1<>>24,b=m>>>16&255,_=m&65535,!(y<=h);){if(o===0)break e;o--,u+=r[l++]<>w)],y=m>>>24,b=m>>>16&255,_=m&65535,!(w+y<=h);){if(o===0)break e;o--,u+=r[l++]<>>=w,h-=w,n.back+=w}if(u>>>=y,h-=y,n.back+=y,b&64){e.msg="invalid distance code",n.mode=It;break}n.offset=_,n.extra=b&15,n.mode=fy;case fy:if(n.extra){for(N=n.extra;h>>=n.extra,h-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=It;break}n.mode=dy;case dy:if(a===0)break e;if(s=f-a,n.offset>s){if(s=n.offset-s,s>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=It;break}s>n.wnext?(s-=n.wnext,d=n.wsize-s):d=n.wnext-s,s>n.length&&(s=n.length),v=n.window}else v=i,d=g-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[g++]=v[d++];while(--s);n.length===0&&(n.mode=su);break;case hy:if(a===0)break e;i[g++]=n.length,a--,n.mode=su;break;case Vf:if(n.wrap){for(;h<32;){if(o===0)break e;o--,u|=r[l++]<{if($a(e))return Xn;let t=e.state;return t.window&&(t.window=null),e.state=null,Ta},hX=(e,t)=>{if($a(e))return Xn;const n=e.state;return(n.wrap&2)===0?Xn:(n.head=t,t.done=!1,Ta)},pX=(e,t)=>{const n=t.length;let r,i,l;return $a(e)||(r=e.state,r.wrap!==0&&r.mode!==uc)?Xn:r.mode===uc&&(i=1,i=il(i,t,n,0),i!==r.check)?F2:(l=Y2(e,t,n,n),l?(r.mode=N2,z2):(r.havedict=1,Ta))};var mX=U2,gX=H2,vX=V2,yX=uX,bX=W2,_X=fX,wX=dX,CX=hX,SX=pX,xX="pako inflate (from Nodeca project)",jr={inflateReset:mX,inflateReset2:gX,inflateResetKeep:vX,inflateInit:yX,inflateInit2:bX,inflate:_X,inflateEnd:wX,inflateGetHeader:CX,inflateSetDictionary:SX,inflateInfo:xX};function TX(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var kX=TX;const X2=Object.prototype.toString,{Z_NO_FLUSH:EX,Z_FINISH:OX,Z_OK:sl,Z_STREAM_END:Wf,Z_NEED_DICT:Yf,Z_STREAM_ERROR:AX,Z_DATA_ERROR:yy,Z_MEM_ERROR:PX}=Ro;function Ol(e){this.options=Hc.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new R2,this.strm.avail_out=0;let n=jr.inflateInit2(this.strm,t.windowBits);if(n!==sl)throw new Error(Sa[n]);if(this.header=new kX,jr.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=ol.string2buf(t.dictionary):X2.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=jr.inflateSetDictionary(this.strm,t.dictionary),n!==sl)))throw new Error(Sa[n])}Ol.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,g,o;if(this.ended)return!1;for(t===~~t?g=t:g=t===!0?OX:EX,X2.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),l=jr.inflate(n,g),l===Yf&&i&&(l=jr.inflateSetDictionary(n,i),l===sl?l=jr.inflate(n,g):l===yy&&(l=Yf));n.avail_in>0&&l===Wf&&n.state.wrap>0&&e[n.next_in]!==0;)jr.inflateReset(n),l=jr.inflate(n,g);switch(l){case AX:case yy:case Yf:case PX:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Wf))if(this.options.to==="string"){let a=ol.utf8border(n.output,n.next_out),u=n.next_out-a,h=ol.buf2string(n.output,a);n.next_out=u,n.avail_out=r-u,u&&n.output.set(n.output.subarray(a,a+u),0),this.onData(h)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===sl&&o===0)){if(l===Wf)return l=jr.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Ol.prototype.onData=function(e){this.chunks.push(e)};Ol.prototype.onEnd=function(e){e===sl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function sm(e,t){const n=new Ol(t);if(n.push(e),n.err)throw n.msg||Sa[n.err];return n.result}function IX(e,t){return t=t||{},t.raw=!0,sm(e,t)}var MX=Ol,LX=sm,RX=IX,DX=sm,$X=Ro,BX={Inflate:MX,inflate:LX,inflateRaw:RX,ungzip:DX,constants:$X};const{Deflate:RG,deflate:DG,deflateRaw:FX,gzip:$G}=WY,{Inflate:BG,inflate:FG,inflateRaw:zX,ungzip:zG}=BX;var NX=FX,jX=zX;function by(e){const t=new Map;for(const n of e){const[r,i]=n.split("="),l=decodeURIComponent(i);t.set(r,l)}return t}const VX=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=by(t);if(console.log("URL params:",n),n.get("share")){const l=jX(new Uint8Array(atob(n.get("share")).split("").map(g=>g.charCodeAt(0))),{to:"string"});if(!l){$t().raiseError("Error when trying to decode share parameter!",!1);return}n=by(l.split("&")),console.log("Share URL params:",n)}const r={id:-1,image:"",prompt:n.get("prompt")||"",sampler_name:n.get("sampler_name")||"k_euler",seed:Number(n.get("seed"))||-1,steps:Number(n.get("steps")||20),cfg_scale:Number(n.get("cfg_scale")||5),height:Number(n.get("height")||512),width:Number(n.get("width")||512),clip_skip:Number(n.get("clip_skip")||0),frames:Number(n.get("frames")||1),scheduler:n.get("scheduler")||"default"};en().generateText2Img(r,!1)},UX=10;function vh(e,t,n,r,i=l=>$t().raiseError(l,!1)){if(e.status===n&&t)return!0;if(!t.message)return i(`${r}: Got response code ${e.status}`);if(!t.errors)return i(`${r}: ${t.message}`);const l=Object.entries(t.errors).map(g=>`${g[0]} - ${g[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}const HX=Co("interrogate",()=>{const e=oe({}),t=oe(!1);async function n(g){$t().raiseError(g,!1),t.value=!1,e.value={}}async function r(){const g=Gt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/interrogate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),u=await a.json();!vh(a,u,200,"Failed to get interrogation",n)||(e.value.id=u.id,e.value.status=u.caption)}function i(){e.value={},t.value=!1}function l(){return e.value.status||!1}return{currentInterrogation:e,interrogating:t,interrogateImage:r,getFormStatus:l,resetInterrogation:i}}),lm=e=>(Qr("data-v-db184ac6"),e=e(),ei(),e),WX={key:0,style:{"margin-top":"16px"}},YX=lm(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),XX={key:1,style:{"margin-top":"16px"}},KX={key:2},GX={style:{"margin-top":"8px"}},qX=lm(()=>re("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),ZX={key:0},JX=lm(()=>re("h3",null,"Caption",-1)),QX={key:0},eK={key:1},tK=Ee({__name:"InterrogationView",setup(e){const t=HX(),n=en(),r=$t(),i=oe();async function l(u){if(i.value.clearFiles(),!u.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const h=await d2(u.raw);t.currentInterrogation.source_image=h,t.interrogateImage()}function g(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=c2();return(u,h)=>C(t).currentInterrogation.source_image?C(t).currentInterrogation.status?(j(),ce("div",KX,[re("div",GX,[le(C(lt),{icon:C(mg),onClick:C(t).resetInterrogation},{default:pe(()=>[Ne("New Interrogation")]),_:1},8,["icon","onClick"]),C(o)?(j(),we(C(lt),{key:0,icon:C(mg),onClick:g,disabled:!C(o)},{default:pe(()=>[Ne("Text2Img (Caption)")]),_:1},8,["icon","disabled"])):_e("",!0)]),qX,le(C(Tp),{src:C(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),C(o)?(j(),ce("div",ZX,[JX,C(o)?(j(),ce("div",eK,[re("strong",null,Ae(C(o)),1)])):(j(),ce("div",QX,"Processing"+Ae(C(a)),1))])):_e("",!0)])):(j(),ce("div",XX,[re("strong",null,"Uploading image"+Ae(C(a)),1)])):(j(),ce("div",WX,[re("div",null,[le(C(Pp),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),YX]),_:1},512)])]))}});const nK=Yt(tK,[["__scopeId","data-v-db184ac6"]]);function rK(e,t,n){if(e===0)return"0"+(t?"s":"seconds");if(e==null)return"?";const r=Math.floor(e/86400),i=Math.floor(e%86400/3600),l=Math.floor(e%86400%3600/60),g=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",u=l>0?l+(t?"m":"minutes"):"",h=g>0?g+(t?"s":"seconds"):"",c=[];return n!=null&&n.days&&c.push(o),n!=null&&n.hours&&c.push(a),n!=null&&n.minutes&&c.push(u),n!=null&&n.seconds&&c.push(h),c.join(" ")}const iK={class:"form"},aK={key:0,style:{"padding-bottom":"50px"}},oK=re("h1",{style:{margin:"0"}},"Interrogation",-1),sK=re("div",null,"Interrogate images to get their predicted descriptions.",-1),lK={class:"sidebar"},uK=re("span",{style:{height:"100%","font-size":"14px"}},[Ne("Reference Image: "),re("br"),Ne("(Photomaker/Kontext) ")],-1),cK=re("h3",{style:{margin:"16px 0 4px 0"}},"Multi Select",-1),fK={class:"main"},dK={class:"image center-horizontal"},hK={key:0},pK=Ee({__name:"GenerateView",setup(e){const n=up(lp).smallerOrEqual("md"),r=en(),i=$t(),l=ys(),g=Gt();let o=[];const a=Qg(async()=>{if(o.length===0)try{o=(await(await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/samplers`)).json()).map(b=>b.name)}catch{o=[]}return o.length===0?[]:f(o)});let u=[];const h=Qg(async()=>{if(u.length===0)try{u=(await(await fetch(`${g.baseURL.length===0?".":g.baseURL}/sdapi/v1/schedulers`)).json()).map(b=>b.name)}catch{u=[]}return u.length===0?[]:s(u)}),c=pt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function f(b){return!r.params||!r.params.sampler_name||b.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=b[0]),b}function s(b){return!r.params||!r.params.scheduler||b.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=b[0]),b}function d(b){return"Elapsed: "+rK(b,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function v(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function m(b){r.generatorType=b,v(),console.log(b)}function y(){l.showCropPreview=!0,l.updateCropPreview()}return v(),VX(),(b,_)=>(j(),ce(ze,null,[le(C(tw),{"default-active":C(r).generatorType,collapse:!0,onSelect:m,mode:C(n)?"horizontal":"vertical",class:fe(C(n)?"mobile-generator-types":"generator-types"),style:Fe(C(n)?"overflow-x: auto":"")},{default:pe(()=>[le(nu,{index:"Text2Img","icon-one":C(oE),"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(nu,{index:"Img2Img","icon-one":C(Fl),"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-one","icon-two","isMobile"]),le(nu,{index:"Inpainting","icon-one":u2,"icon-two":C(Fl),isMobile:C(n)},null,8,["icon-two","isMobile"]),le(nu,{index:"Interrogation","icon-one":oH,isMobile:C(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),re("div",iK,[C(r).generatorType==="Interrogation"?(j(),ce("div",aK,[oK,sK,le(nK)])):(j(),we(C(xp),{key:1,"label-position":"left","label-width":"140px",model:C(r),class:"container",rules:c,onSubmit:_[29]||(_[29]=Ze(()=>{},["prevent"]))},{default:pe(()=>[re("div",lK,[le(C(Y$),{modelValue:C(i).activeCollapse,"onUpdate:modelValue":_[24]||(_[24]=w=>C(i).activeCollapse=w),style:{"margin-bottom":"24px"}},{default:pe(()=>[le(C(X$),{title:"Generation Options",name:"1"},{default:pe(()=>[le(xH),le(sh,{label:"Negative Prompt",prop:"negativePrompt",modelValue:C(r).negativePrompt,"onUpdate:modelValue":_[0]||(_[0]=w=>C(r).negativePrompt=w),autosize:{maxRows:15},resize:"vertical",type:"textarea",placeholder:"Enter negative prompt here",info:"What to exclude from the image. Not working? Try increasing the guidance.","label-position":"top"},null,8,["modelValue"]),le(sh,{label:"Seed",prop:"seed",modelValue:C(r).params.seed,"onUpdate:modelValue":_[2]||(_[2]=w=>C(r).params.seed=w),placeholder:"Enter seed here",clearable:"","clear-icon":C(Gk)},{append:pe(()=>[le(C(Or),{content:"Randomize!",placement:"top"},{default:pe(()=>[le(C(lt),{icon:C(k3),onClick:_[1]||(_[1]=()=>C(r).params.seed=C(K2)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),C(r).multiSelect.sampler.enabled?(j(),we(Au,{key:0,label:"Sampler(s)",prop:"samplers",modelValue:C(r).multiSelect.sampler.selected,"onUpdate:modelValue":_[3]||(_[3]=w=>C(r).multiSelect.sampler.selected=w),options:C(a),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])):(j(),we(Au,{key:1,label:"Sampler",prop:"sampler",modelValue:C(r).params.sampler_name,"onUpdate:modelValue":_[4]||(_[4]=w=>C(r).params.sampler_name=w),options:C(a),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])),le(En,{label:"Batch Size",prop:"batchSize",modelValue:C(r).params.n,"onUpdate:modelValue":_[5]||(_[5]=w=>C(r).params.n=w),min:C(r).minImages,max:C(r).maxImages},null,8,["modelValue","min","max"]),C(r).multiSelect.steps.enabled?(j(),we(En,{key:2,label:"Steps(s)",prop:"multiSteps",modelValue:C(r).multiSelect.steps.selected,"onUpdate:modelValue":_[6]||(_[6]=w=>C(r).multiSelect.steps.selected=w),min:C(r).minSteps,max:C(r).maxSteps,info:"Multi-select enabled. Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:3,label:"Steps",prop:"steps",modelValue:C(r).params.steps,"onUpdate:modelValue":_[7]||(_[7]=w=>C(r).params.steps=w),min:C(r).minSteps,max:C(r).maxSteps,info:"Keep step count between 30 to 50 for optimal generation times. Coherence typically peaks between 60 and 90 steps, with a trade-off in speed."},null,8,["modelValue","min","max"])),le(En,{label:"Width",prop:"width",modelValue:C(r).params.width,"onUpdate:modelValue":_[8]||(_[8]=w=>C(r).params.width=w),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:y},null,8,["modelValue","min","max"]),le(En,{label:"Height",prop:"height",modelValue:C(r).params.height,"onUpdate:modelValue":_[9]||(_[9]=w=>C(r).params.height=w),min:C(r).minDimensions,max:C(r).maxDimensions,step:64,change:y},null,8,["modelValue","min","max"]),C(r).multiSelect.guidance.enabled?(j(),we(En,{key:4,label:"Guidance(s)",prop:"cfgScales",modelValue:C(r).multiSelect.guidance.selected,"onUpdate:modelValue":_[10]||(_[10]=w=>C(r).multiSelect.guidance.selected=w),min:C(r).minCfgScale,max:C(r).maxCfgScale,info:"Multi-select enabled. Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:5,label:"Guidance",prop:"cfgScale",modelValue:C(r).params.cfg_scale,"onUpdate:modelValue":_[11]||(_[11]=w=>C(r).params.cfg_scale=w),min:C(r).minCfgScale,max:C(r).maxCfgScale,step:.5,info:"Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max","step"])),C(r).multiSelect.clipSkip.enabled?(j(),we(En,{key:6,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:C(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":_[12]||(_[12]=w=>C(r).multiSelect.clipSkip.selected=w),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Multi-select enabled. Last layers of CLIP to ignore. For most situations this can be left alone.",multiple:""},null,8,["modelValue","min","max"])):(j(),we(En,{key:7,label:"CLIP Skip",prop:"clipSkip",modelValue:C(r).params.clip_skip,"onUpdate:modelValue":_[13]||(_[13]=w=>C(r).params.clip_skip=w),min:C(r).minClipSkip,max:C(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])),C(r).sourceGeneratorTypes.includes(C(r).generatorType)?(j(),we(En,{key:8,label:"Init Strength",prop:"denoise",modelValue:C(r).params.denoising_strength,"onUpdate:modelValue":_[14]||(_[14]=w=>C(r).params.denoising_strength=w),min:C(r).minDenoise,max:C(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values."},null,8,["modelValue","min","max","step"])):_e("",!0),le(En,{label:"Video Frames",prop:"frames",modelValue:C(r).params.frames,"onUpdate:modelValue":_[15]||(_[15]=w=>C(r).params.frames=w),min:C(r).minFrames,max:C(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). Max 80 frames, about 5 seconds of video."},null,8,["modelValue","min","max"]),le(Au,{label:"Scheduler",prop:"scheduler",modelValue:C(r).params.scheduler,"onUpdate:modelValue":_[16]||(_[16]=w=>C(r).params.scheduler=w),options:C(h),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"]),re("div",null,[uK,re("input",{class:"el-button",type:"file",id:"extra_image_input",onChange:_[17]||(_[17]=w=>C(r).setExtraImage(w)),accept:"image/*",multiple:""},null,32),re("button",{onClick:_[18]||(_[18]=w=>C(r).clearExtraImage()),class:"el-button"},"Clear Image"),le(C(r0),null,{default:pe(()=>[le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:C(r).params.enable_hr,"onUpdate:modelValue":_[19]||(_[19]=w=>C(r).params.enable_hr=w),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"])]),_:1})]),cK,le(C(r0),null,{default:pe(()=>[le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Sampler",prop:"multiSamplerSwitch",modelValue:C(r).multiSelect.sampler.enabled,"onUpdate:modelValue":_[20]||(_[20]=w=>C(r).multiSelect.sampler.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Guidance",prop:"multiGuidanceSwitch",modelValue:C(r).multiSelect.guidance.enabled,"onUpdate:modelValue":_[21]||(_[21]=w=>C(r).multiSelect.guidance.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi CLIP Skip",prop:"multiClipSkipSwitch",modelValue:C(r).multiSelect.clipSkip.enabled,"onUpdate:modelValue":_[22]||(_[22]=w=>C(r).multiSelect.clipSkip.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"]),le(C(Uo),{span:C(n)?24:12},{default:pe(()=>[le(Yo,{label:"Multi Steps",prop:"multiStepsSwitch",modelValue:C(r).multiSelect.steps.enabled,"onUpdate:modelValue":_[23]||(_[23]=w=>C(r).multiSelect.steps.enabled=w)},null,8,["modelValue"])]),_:1},8,["span"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),re("div",fK,[le(C(lt),{onClick:_[25]||(_[25]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).resetStore()}),class:"reset-btn"},{default:pe(()=>[Ne("Reset")]),_:1}),le(C(lt),{type:"primary",class:"generate-cancel-btn",style:Fe(C(r).generating?"width: 55%;":""),onClick:_[26]||(_[26]=()=>C(r).generateImage(C(r).generatorType))},{default:pe(()=>[re("span",null," Generate "+Ae(C(r).totalImageCount)+" image"+Ae(C(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),C(r).generating?(j(),we(C(lt),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:C(r).cancelled,onClick:_[27]||(_[27]=()=>{C(r).cancelled=!0,C(r).generating=!1,C(r).clearQueue()})},{default:pe(()=>[Ne("Cancel all")]),_:1},8,["disabled"])):_e("",!0)]),re("div",dK,[le(C(KD),{class:"center-both generated-image"},{default:pe(()=>[!C(r).generating&&C(r).outputs.length==0?(j(),ce("div",hK,[/Inpainting/.test(C(r).generatorType)?(j(),we(M0,{key:0})):_e("",!0),/Img2Img/.test(C(r).generatorType)?(j(),we(M0,{key:1})):_e("",!0)])):_e("",!0),!C(i).showGeneratedImages&&C(r).generating?(j(),we(pH,{key:1,generated:C(r).outputs.length,total:C(r).queue.length,elapsed:d(C(r).timer.seconds),onShowGenerated:_[28]||(_[28]=w=>C(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed"])):_e("",!0),C(i).showGeneratedImages&&C(r).outputs.length!==0?(j(),we(RH,{key:2})):_e("",!0)]),_:1})])]),_:1},8,["model","rules"]))])],64))}});const Cs=jT({history:iT("./"),routes:[{path:"/",name:"generate",component:pK},{path:"/images",name:"images",component:()=>If(()=>Promise.resolve().then(()=>fG),void 0,import.meta.url)},{path:"/about",name:"about",component:()=>If(()=>Promise.resolve().then(()=>xG),void 0,import.meta.url)},{path:"/options",name:"options",component:()=>If(()=>Promise.resolve().then(()=>MG),void 0,import.meta.url)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function Xf(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,enable_hr:!1,scheduler:"default"}}function K2(){return Math.floor(Math.random()*9999999)+1}const en=Co("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=oe("Text2Img"),r=oe(""),i=Pn("promptHistory",[]),l=oe(""),g=Pn("negativeLibrary",[]),o=oe(Xf()),a=oe({interval:0,seconds:0}),u=oe({sampler:{name:"Sampler",enabled:!1,selected:[o.value.sampler_name],noneMessage:"Failed to generate: No sampler selected.",mapToParam:te=>te.sampler_name},steps:{name:"Steps",enabled:!1,selected:[o.value.steps],noneMessage:"Failed to generate: No steps selected.",mapToParam:te=>te.steps},guidance:{name:"CFG Scale",enabled:!1,selected:[o.value.cfg_scale],noneMessage:"Failed to generate: No guidance selected.",mapToParam:te=>te.cfg_scale},clipSkip:{name:"Clip Skip",enabled:!1,selected:[o.value.clip_skip],noneMessage:"Failed to generate: No CLIP Skip selected.",mapToParam:te=>te.clip_skip}}),h=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),c=oe({...h(),sourceProcessing:"inpainting"}),f=oe({...h(),sourceProcessing:"img2img"}),s=te=>te==="Inpainting"?c.value:te==="Img2Img"?f.value:h(),d=ee(()=>s(n.value)),v=oe(""),m=oe(!1),y=oe(!1),b=oe([]),_=oe([]),w=oe(64),S=ee(()=>Gt().allowLargerParams==="Enabled"?3072:1024),x=oe(1),T=oe(20),E=oe(1),A=ee(()=>Gt().allowLargerParams==="Enabled"?150:50),D=oe(1),N=oe(24),R=oe(.1),B=oe(1),O=oe(0),U=oe(10),ne=oe(1),Q=oe(80),ue=(te,be,Ce)=>Array.from({length:(be-te+1)/Ce},(xe,Ie)=>(Ie+te)*Ce),I=oe(ue(O.value,U.value,1)),z=oe(ue(D.value,N.value,.5)),M=ee(()=>{const te=(Me,Le,ot=1)=>Me*(Le.enabled?Le.selected.length:ot),Ce=o.value.n*Y().length,xe=te(Ce,u.value.sampler),Ie=te(xe,u.value.steps),ve=te(Ie,u.value.guidance);return te(ve,u.value.clipSkip)});function L(){return o.value=Xf(),c.value=h(),f.value=h(),b.value=[],$t().showGeneratedImages=!1,J(),!0}function J(){_.value=[]}function V(){b.value=[]}async function P(te){if(!e.includes(te))return[];if(r.value==="")return Z("Failed to generate: No prompt submitted.");for(const ut of Object.values(u.value))if(ut.enabled&&ut.selected.length===0)return Z(ut.noneMessage);const be=ys(),Ce=$t();be.saveImages();const{sourceImage:xe,maskImage:Ie,sourceProcessing:ve}=s(te);K(r.value);const Se=[],Me=(ut,Qt)=>ut.enabled?ut.selected:Qt,Le=Y(),ot=Me(u.value.guidance,[o.value.cfg_scale]),mt=Me(u.value.steps,[o.value.steps]),st=Me(u.value.clipSkip,[o.value.clip_skip]),Xt=Me(u.value.sampler,[o.value.sampler_name]),Jt=[await W()];for(const ut of ot)for(const Qt of mt)for(const Q2 of st)for(const cm of Le){const fm=cm.split(" ### ");for(const eC of Xt){let Il=parseInt(o.value.seed.toString());(isNaN(Il)||Il<0)&&(Il=K2());for(let Xc=0;Xc0&&(Fn.params.extra_images=G),Gt().alsoRequestAvi==="Enabled"&&Fn.params.frames&&Fn.params.frames>1&&(Fn.params.video_output_type=2),Se.push(Fn)}}}let Pr=!1;m.value||(Pr=!0,b.value=[]),m.value=!0,Ce.showGeneratedImages=!1;let xn=_.value.filter(ut=>!ut.gathered&&!ut.failed).length;for(let ut=0;ut{a.value.seconds++},1e3);!_.value.every(ut=>ut.gathered||ut.failed)&&!y.value;){const ut=_.value.find(Qt=>!Qt.gathered&&!Qt.failed);if(!ut)break;ut.gathered=!0;try{const Qt=await k(ut.params);if(!Qt){ut.failed=!0;continue}q([{...Qt,...ut}])}catch(Qt){ut.failed=!0,console.error("Error fetching image:",Qt)}}}async function q(te){const be=Ca();console.log(te);const Ce=await Promise.all(te.map(async ve=>{const Se=ve.images[0],Le=!!ve.animated?"gif":"png",ot=ve.extra_data?`data:video/avi;base64,${ve.extra_data}`:"";return{id:-1,image:`data:image/${Le};base64,${Se}`,prompt:ve.prompt,clip_skip:ve.params.clip_skip,modelName:ve.models[0],seed:ve.params.seed,steps:ve.params.steps,sampler_name:ve.params.sampler_name,cfg_scale:ve.params.cfg_scale,width:ve.params.width,height:ve.params.height,frames:ve.params.frames,scheduler:ve.params.scheduler,extra_avi:ot,enable_hr:ve.params.enable_hr}})),xe=await be.pushOutputs(Ce),Ie=0;return b.value=[...xe.map(ve=>({type:"image",index:Ie,output:ve})),...b.value].sort((ve,Se)=>ve.index-Se.index),b.value.length===_.value.length&&(_.value=[],m.value=!1,$t().showGeneratedImages=!0,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0),Ce}async function Z(te){const be=$t();return te&&be.raiseError(te,!1),[]}function ie(te,be,Ce,xe){return be<=Ce?be:($t().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${te}' to its default value instead of ${be}.`,!0),xe)}function he(te,be=!0){const Ce=Xf();if(n.value="Text2Img",u.value.guidance.enabled=!1,u.value.sampler.enabled=!1,Cs.push("/"),be&&(te.width=te.width||Ce.width,te.height=te.height||Ce.height),te.prompt){const xe=te.prompt.split(" ### ");r.value=xe[0],l.value=xe[1]||""}te.sampler_name&&(o.value.sampler_name=te.sampler_name),te.steps&&(o.value.steps=ie("steps",te.steps,A.value,Ce.steps)),te.cfg_scale&&(o.value.cfg_scale=te.cfg_scale),te.width&&(o.value.width=ie("width",te.width,S.value,Ce.width)),te.height&&(o.value.height=ie("height",te.height,S.value,Ce.height)),te.seed&&(o.value.seed=te.seed),te.clip_skip&&(o.value.clip_skip=ie("clip_skip",te.clip_skip,U.value,Ce.clip_skip)),te.scheduler&&(o.value.scheduler=te.scheduler),te.frames&&(o.value.frames=ie("frames",te.frames,Q.value,Ce.frames))}function ge(te){const be=ys();n.value="Img2Img",f.value.sourceImage=te,be.drawing=!1,b.value=[],Cs.push("/"),Jn.fabric.Image.fromURL(te,be.newImage)}function ye(te){const be=ys();b.value=[],c.value.sourceImage=te,n.value="Inpainting",Cs.push("/"),Jn.fabric.Image.fromURL(te,be.newImage)}function H(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Y(){const te=H(),be=te.match(/\{(.*?)\}/g)||[];if(be.length===0)return[te];let Ce=[];return be.forEach(xe=>{const Ie=[],ve=xe.replace("{","").replace("}","").split("|");Ce.length===0?ve.forEach(Se=>{const Me=te.replace(xe,Se);Ie.push(Me)}):Ce.forEach(Se=>{ve.forEach(Me=>{const Le=Se.replace(xe,Me);Ie.push(Le)})}),Ce=[...Ie]}),Ce}async function k(te){const be=Gt();try{const Ce=await fetch(`${be.baseURL.length===0?".":be.baseURL}/sdapi/v1/${te.init_images.length>0?"img":"txt"}2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)}),xe=await Ce.json();return vh(Ce,xe,200,"Failed to fetch",X)?xe:!1}catch{return!1}}function X(te){return $t().raiseError(te,!1),y.value=!1,b.value=[],!1}async function W(){const te=Gt(),be=await fetch(`${te.baseURL.length===0?".":te.baseURL}/sdapi/v1/sd-models`),Ce=await be.json();if(!!vh(be,Ce,200,"Failed to get available models"))return Ce.length===0?"(No model loaded)":Ce[0].model_name}function $(te){g.value.indexOf(te)===-1&&(g.value=[...g.value,te])}function F(te){g.value=g.value.filter(be=>be!=te)}function K(te){if(i.value.findIndex(be=>be.prompt===te)===-1){if(i.value.length>=10+i.value.filter(be=>be.starred).length){const be=i.value.filter(xe=>!xe.starred),Ce=i.value.findIndex(xe=>xe===be[be.length-1]);i.value.splice(Ce,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:te}]}}function de(te){i.value=i.value.filter(be=>be.prompt!=te&&be!=te)}function se(){return!1}var G=[];function me(te){let be=te.target;if(G=[],be.files.length>0)for(let Ce=0;Cenew DataView(new ArrayBuffer(e)),Ba=e=>new Uint8Array(e.buffer||e),Za=e=>new TextEncoder().encode(String(e));function mK(e,t){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),o:e.stream()};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),o:e.body};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,o:Za(e)};if(e instanceof Blob)return{t,o:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,o:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,o:Ba(e)};if(Symbol.asyncIterator in e)return{t,o:G2(e)};throw new TypeError("Unsupported input format.")}function G2(e){const t="next"in e?e:e[Symbol.asyncIterator]();return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await t.next();if(!i.value){n.close();break}{const l=gK(i.value);n.enqueue(l),r+=l.byteLength}}}})}function gK(e){return typeof e=="string"?Za(e):e instanceof Uint8Array?e:Ba(e)}function vK(e,t,n){if(t===void 0||t instanceof Uint8Array||(t=Za(t)),e instanceof File)return{i:t||Za(e.name),A:e.size};if(e instanceof Response){const r=e.headers.get("content-disposition"),i=r&&r.match(/;\s*filename\*?=["']?(.*?)["']?$/i),l=i&&i[1]||new URL(e.url).pathname.split("/").pop(),g=l&&decodeURIComponent(l),o=n||+e.headers.get("content-length");return{i:t||Za(g),A:o}}if(!t||t.length===0)throw new Error("The file must have a name.");return typeof e=="string"?{i:t,A:Za(e).length}:e instanceof Blob?{i:t,A:e.size}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{i:t,A:e.byteLength}:{i:t,A:n}}var yK=new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"),e=>e.charCodeAt(0)))),{c:bK,m:_K}=yK.exports,wK=Ba(_K).subarray(65536);function _y(e,t=0){for(const n of function*(r){for(;r.length>65536;)yield r.subarray(0,65536),r=r.subarray(65536);r.length&&(yield r)}(e))wK.set(n),t=bK(n.length,t);return t}function q2(e,t,n=0){const r=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,i=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;t.setUint16(n,r,1),t.setUint16(n+2,i,1)}function CK(e){const t=Yc(30);return t.setUint32(0,1347093252),t.setUint32(4,335546368),q2(e.t,t,10),t.setUint16(26,e.i.length,1),Ba(t)}async function*SK(e){let{o:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.u=_y(t,0),e.A=t.length;else{e.A=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.u=_y(r,e.u),e.A+=r.length,yield r}}}function xK(e){const t=Yc(16);return t.setUint32(0,1347094280),t.setUint32(4,e.u,1),t.setUint32(8,e.A,1),t.setUint32(12,e.A,1),Ba(t)}function TK(e,t){const n=Yc(46);return n.setUint32(0,1347092738),n.setUint32(4,352523264),n.setUint16(8,2048),q2(e.t,n,12),n.setUint32(16,e.u,1),n.setUint32(20,e.A,1),n.setUint32(24,e.A,1),n.setUint16(28,e.i.length,1),n.setUint16(40,33204,1),n.setUint32(42,t,1),Ba(n)}function kK(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}function EK(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};return Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=p(t.metadata)),new Response(G2(async function*(r){const i=[];let l=0,g=0;for await(const u of r)yield CK(u),yield u.i,yield*SK(u),yield xK(u),i.push(TK(u,l)),i.push(u.i),g++,l+=46+u.i.length+u.A;let o=0;for(const u of i)yield u,o+=u.length;const a=Yc(22);a.setUint32(0,1347093766),a.setUint16(8,g,1),a.setUint16(10,g,1),a.setUint32(12,o,1),a.setUint32(16,l,1),yield Ba(a)}(async function*(r){for await(const i of r){const[l,g]=kK(i);yield Object.assign(mK(...g),vK(...l))}}(e))),{headers:n})}async function Z2(e,t=!0,n){const r=Gt();t&&Di({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;u.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await oa(u,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await oa(u,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await oa(u,"image/gif")}):i.push({name:f+".webp",input:await oa(u,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(c,void 0,4)}),n&&n()}const l=await EK(i).blob(),g=document.createElement("a");g.href=URL.createObjectURL(l),g.download="sdui_images.zip",g.click()}async function OK(e,t){const n=Gt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await oa(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await oa(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await oa(e,"image/gif"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".gif"):(r.href=e,r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".webp"),r.click(),i&&URL.revokeObjectURL(r.href)}const J2=Ee({__name:"ImageActions",props:{imageData:null,onDelete:null,showDismiss:{type:Boolean}},setup(e){const t=e,n=en(),r=Ca(),i=()=>{hw.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{r.deleteOutput(t.imageData.id),t.onDelete!==void 0&&t.onDelete(t.imageData.id),Di({type:"success",message:"Deleted Image"})})},l=()=>{en().clearOutputs(),$t().showGeneratedImages=!1,en().clearQueue()};async function g(o){const a=window.location.origin,u={prompt:o.prompt,width:o.width?o.width:void 0,height:o.height?o.height:void 0,steps:o.steps,cfg_scale:o.cfg_scale,sampler_name:o.sampler_name,model_name:o.modelName,seed:o.seed,clip_skip:o.clip_skip,frames:o.frames,scheduler:o.scheduler,extra_avi:o.extra_avi,enable_hr:o.enable_hr},h=window.location.pathname.replace("images","");let c=`${a}${h}?share=`,f="",s="";for(const[v,m]of Object.entries(u)){if(!m)continue;let y=m;typeof m=="string"?y=encodeURIComponent(m):Array.isArray(m)&&(y=JSON.stringify(m)),f+=`${s}${v}=${y}`,s="&"}c+=btoa(String.fromCharCode.apply(null,Array.from(NX(f)))),await navigator.clipboard.writeText(c),Di({type:"success",message:"Copied shareable link to clipboard"})}return(o,a)=>(j(),ce(ze,null,[le(C(lt),{onClick:i,type:"danger",size:"small",icon:C(Ec),plain:""},{default:pe(()=>[Ne("Delete")]),_:1},8,["icon"]),le(C(lt),{onClick:a[0]||(a[0]=u=>C(OK)(e.imageData.image,`${e.imageData.seed}-${e.imageData.prompt}`)),type:"success",size:"small",icon:C(Ls),plain:""},{default:pe(()=>[Ne("Download")]),_:1},8,["icon"]),e.imageData.starred?_e("",!0):(j(),we(C(lt),{key:0,onClick:a[1]||(a[1]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(e4),plain:""},{default:pe(()=>[Ne("Star")]),_:1},8,["icon"])),e.imageData.starred?(j(),we(C(lt),{key:1,onClick:a[2]||(a[2]=u=>C(r).toggleStarred(e.imageData.id)),type:"warning",size:"small",icon:C(r_),plain:""},{default:pe(()=>[Ne("Unstar")]),_:1},8,["icon"])):_e("",!0),le(C(lt),{onClick:a[3]||(a[3]=u=>C(n).generateText2Img(e.imageData)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Txt2img")]),_:1}),le(C(lt),{onClick:a[4]||(a[4]=u=>C(n).generateImg2Img(e.imageData.image)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Img2img")]),_:1}),le(C(lt),{onClick:a[5]||(a[5]=u=>C(n).generateInpainting(e.imageData.image)),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Inpaint")]),_:1}),e.showDismiss?(j(),we(C(lt),{key:2,onClick:a[6]||(a[6]=u=>l()),type:"success",size:"small",plain:""},{default:pe(()=>[Ne("Dismiss")]),_:1})):_e("",!0),le(C(lt),{onClick:a[7]||(a[7]=u=>g(e.imageData)),type:"success",icon:C(m3),size:"small",plain:""},{default:pe(()=>[Ne("Share")]),_:1},8,["icon"])],64))}}),AK={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},PK=["src"],IK={style:{"font-size":"18px","font-weight":"500"}},MK={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},LK={key:0},RK=["onClick"],DK=Ee({__name:"ImageDialog",setup(e){const t=Ca(),n=$t(),r=oe();HI(r,{onSwipeEnd(a,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=oe(t.currentOutputs[0]);ke(()=>n.activeModal,async()=>{const a=t.currentOutputs.find(u=>u.id===n.activeModal);if(a)return l.value=a;l.value=await Lt.outputs.get(n.activeModal)||t.currentOutputs[0]});function g(){i.value=!1}function o(){var v,m;if(!((v=l.value)!=null&&v.extra_avi))return;const a=l.value.extra_avi.split(",")[1];if(!a)return;const u=atob(a),h=u.length,c=new Uint8Array(h);for(let y=0;y{var h;return j(),we(C(DB),{"model-value":C(i),width:(h=l.value)==null?void 0:h.width,class:"image-viewer",onClosed:g,"align-center":""},{footer:pe(()=>[le(J2,{"image-data":l.value,"on-delete":g},null,8,["image-data"])]),default:pe(()=>{var c,f,s,d;return[re("div",{class:"main-output-container",ref_key:"target",ref:r},[re("div",AK,[(c=l.value)!=null&&c.image?(j(),ce("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,PK)):_e("",!0)])],512),re("div",IK,Ae(((f=l.value.prompt)==null?void 0:f.split("###")[0])||"Unknown Creation"),1),re("div",MK,[re("div",null,"Negative Prompt: "+Ae(((s=l.value.prompt)==null?void 0:s.split("###")[1])||"None"),1),re("span",null,"Model: "+Ae(l.value.modelName||"Unknown")+" - ",1),re("span",null,"Sampler: "+Ae(l.value.sampler_name||"Unknown")+" - ",1),re("span",null,"Scheduler: "+Ae(l.value.scheduler||"Unknown")+" - ",1),re("span",null,"Seed: "+Ae(l.value.seed||"Unknown")+" - ",1),re("span",null,"Steps: "+Ae(l.value.steps||"Unknown")+" - ",1),re("span",null,"CFG Scale: "+Ae(l.value.cfg_scale||"Unknown")+" - ",1),re("span",null,"Clip Skip: "+Ae((d=l.value.clip_skip)!=null?d:"Unknown")+" - ",1),re("span",null,"Dimensions: "+Ae(l.value.width||"???")+"x"+Ae(l.value.height||"???")+" - ",1),re("span",null,"Frames: "+Ae(l.value.frames||"1"),1),l.value.extra_avi?(j(),ce("span",LK,[Ne(" - "),re("a",{href:"#",onClick:Ze(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]",8,RK)])):_e("",!0)])]}),_:1},8,["model-value","width"])}}});const $K=e=>(Qr("data-v-8f4d2380"),e=e(),ei(),e),BK=$K(()=>re("div",{style:{"font-size":"20px"}},"Stable UI",-1)),FK={class:"generator-icons"},zK=Ee({__name:"App",setup(e){const n=up(lp).smallerOrEqual("md"),r=$t();Gt();const i=UT(),l=oe();return ke(()=>i.path,g=>{l.value&&l.value.open(g)}),(g,o)=>(j(),ce(ze,null,[re("div",{class:fe({"menu-container":!C(n)})},[le(C(tw),{"default-active":C(i).path,mode:"horizontal",router:!0,ellipsis:!C(n),class:fe(C(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:pe(()=>[C(n)?_e("",!0):(j(),we(C(Ep),{key:0,class:"remove-item-styling center-vertical"},{title:pe(()=>[BK]),_:1})),le(Wo,{isMobile:C(n),index:"/"},{icon:pe(()=>[re("div",FK,[le(C(De),null,{default:pe(()=>[le(C(eO))]),_:1}),C(r).showGeneratorBadge?(j(),we(C(De),{key:0,class:"generator-badge",size:10},{default:pe(()=>[le(WU)]),_:1})):_e("",!0)])]),title:pe(()=>[Ne("Generate")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/images"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(M3))]),_:1})]),title:pe(()=>[Ne("Images")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/about"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(Qb))]),_:1})]),title:pe(()=>[Ne("About")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/options"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(f4))]),_:1})]),title:pe(()=>[Ne("Options")]),_:1},8,["isMobile"]),le(Wo,{isMobile:C(n),index:"/return"},{icon:pe(()=>[le(C(De),null,{default:pe(()=>[le(C(Gb))]),_:1})]),title:pe(()=>[Ne("Return to Lite")]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),re("div",{class:fe({view:!C(n)})},[le(C(Kb))],2),le(DK)],64))}});const NK=Yt(zK,[["__scopeId","data-v-8f4d2380"]]);const um=Lx(NK);um.use($x());um.use(Cs);um.mount("#app");Cs.replace("/");window.addEventListener("beforeunload",e=>{en().generating&&(e.preventDefault(),e.returnValue="")});const jK={key:1,class:"image-action"},VK=Ee({__name:"CustomImage",props:{imageData:null},setup(e){const t=e,n=$t(),r=oe(null);wI(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=oe(!1);UI(r,([{isIntersecting:g}])=>{g&&(i.value=g)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(g,o)=>(j(),ce("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(j(),we(C(Tp),{key:0,class:"thumbnail",src:e.imageData.image,onClick:o[0]||(o[0]=a=>C(n).activeModal=e.imageData.id),fit:"cover",loading:"lazy",style:Fe(`${C(l)&&"opacity: 0.5"}`)},null,8,["src","style"])):_e("",!0),i.value?(j(),ce("div",jK,[e.imageData.starred?(j(),we(C(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:pe(()=>[le(C(r_))]),_:1})):_e("",!0),C(n).multiSelect?(j(),ce("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>C(n).toggleSelection(e.imageData.id))},[le(C(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${C(l)?"1":"0.5"})`},{default:pe(()=>[C(l)?_e("",!0):(j(),we(C(fl),{key:0})),C(l)?(j(),we(C(Zb),{key:1})):_e("",!0)]),_:1},8,["color"])])):_e("",!0)])):_e("",!0)],512))}});const wy=Yt(VK,[["__scopeId","data-v-b9569bbd"]]);function UK({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=V_(),i=ee(()=>r.value<=e),l=oe(!0),{y:g}=VI(window);let o=g.value,a=0;return ke(g,u=>{if(!i.value)return;const h=u-o;if(o=u,h>0&&u>t){a+=h,a>=n&&(l.value=!1,a=0);return}h<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const HK={},WK={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"},YK=re("path",{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-696 72h136v656H184V184zm656 656H384V384h456v456zM384 320V184h456v136H384z",fill:"currentColor"},null,-1),XK=[YK];function KK(e,t){return j(),ce("svg",WK,XK)}const GK=Yt(HK,[["render",KK]]),qK=e=>(Qr("data-v-b39b47c5"),e=e(),ei(),e),ZK={class:"options"},JK=["onClick"],QK=["onClick"],eG=["onClick"],tG={key:1,class:"center-both",style:{gap:"12px"}},nG={key:2},rG=qK(()=>re("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)),iG=[rG],aG={key:0},oG={key:0,style:{display:"flex",gap:"8px"}},sG={key:1,class:"images"},lG={key:1},uG=Ee({__name:"ImagesView",setup(e){const{width:t}=V_(),{isVisible:n,isMobile:r}=UK(),i=Ca(),l=Gt(),g=$t();function o(){g.selected=g.selected.filter(d=>!i.currentOutputs.map(v=>v.id).includes(d)),g.selected=[...g.selected,...i.currentOutputs.map(d=>d.id)],g.multiSelect=!0}async function a(){const d=await Lt.outputs.toCollection().primaryKeys();g.selected=d,g.multiSelect=!0}function u(){g.selected=g.selected.filter(d=>!i.currentOutputs.map(v=>v.id).includes(d)),g.selected.length===0&&(g.multiSelect=!1)}function h(){g.selected=[],g.multiSelect=!1}const c=()=>{hw.confirm(`This action will permanently delete ${g.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(g.selected)})};ev(["a","A","ArrowLeft"],g.openModalToLeft),ev(["d","D","ArrowRight"],g.openModalToRight);async function f(){Z2(g.selected)}const s=ee(()=>{let d=2;t.value>1440?d=6:t.value>1280?d=5:t.value>768?d=4:t.value>480&&(d=3);const v=[];for(let m=0;m(j(),ce(ze,null,[re("div",{class:fe(["images-top-bar",{"mobile-hidden":C(r)&&!C(n)}])},[re("div",ZK,[le(C(Xl),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(C(UO))]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt(["Newest","Oldest"],m=>re("div",{key:m,onClick:()=>C(i).sortBy=m,class:fe(`el-select-dropdown__item ${C(i).sortBy===m?"selected":""}`)},Ae(m),11,JK)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(C(WE))]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt(["all","favourited","unfavourited","unrated"],m=>re("div",{key:m,onClick:()=>C(i).filterBy=m,class:fe(`el-select-dropdown__item ${C(i).filterBy===m?"selected":""}`)},Ae(C(i).filterBy===m?"Showing":"Show")+" "+Ae(m),11,QK)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[le(GK)]),_:1})]),_:1})]),default:pe(()=>[(j(),ce(ze,null,Dt([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],m=>re("div",{key:m.value,onClick:()=>C(i).currentLayout=m.value,class:fe(`el-select-dropdown__item ${C(i).currentLayout===m.value?"selected":""}`)},Ae(m.label),11,eG)),64))]),_:1}),le(C(Xl),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:pe(()=>[le(C(lt),{class:"btn-select"},{default:pe(()=>[le(C(De),{size:16},{default:pe(()=>[C(g).multiSelect?(j(),we(C(Zb),{key:0})):(j(),we(C(fl),{key:1}))]),_:1})]),_:1})]),default:pe(()=>[C(g).multiSelect?(j(),ce("div",{key:0,class:"el-select-dropdown__item selected",onClick:v[0]||(v[0]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Disable multi-select")):(j(),ce("div",{key:1,class:"el-select-dropdown__item",onClick:v[1]||(v[1]=(...m)=>C(g).toggleMultiSelect&&C(g).toggleMultiSelect(...m))},"Enable multi-select")),C(g).selected.length>0?(j(),ce("div",{key:2,class:"el-select-dropdown__item selected",onClick:h},"Deselect All")):(j(),ce("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),C(g).selected.every(m=>!C(i).currentOutputs.map(y=>y.id).includes(m))?(j(),ce("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(j(),ce("div",{key:4,class:"el-select-dropdown__item selected",onClick:u},"Deselect Page"))]),_:1})]),C(l).pageless==="Disabled"?(j(),we(C(a9),{key:0,layout:"prev, pager, next",total:C(i).outputsLength,"page-size":C(l).pageSize,"current-page":C(i).currentPage,"onUpdate:currentPage":v[2]||(v[2]=m=>C(i).currentPage=m),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):_e("",!0),C(g).multiSelect?(j(),ce("div",tG,[re("div",null,Ae(C(g).selected.length)+" selected",1),le(C(lt),{type:"danger",onClick:c,icon:C(Ec),plain:""},{default:pe(()=>[Ne("Delete")]),_:1},8,["icon"]),le(C(lt),{type:"success",onClick:f,icon:C(Ls),plain:"",style:{margin:"0"}},{default:pe(()=>[Ne("Download")]),_:1},8,["icon"])])):(j(),ce("div",nG,iG))],2),C(i).outputsLength!=0?(j(),ce("div",aG,[C(i).currentLayout==="dynamic"?(j(),ce("div",oG,[(j(!0),ce(ze,null,Dt(C(s),(m,y)=>(j(),ce("div",{key:y,style:{flex:"1 1 0%"}},[(j(!0),ce(ze,null,Dt(m,b=>(j(),we(wy,{key:b.id,"image-data":b,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):_e("",!0),C(i).currentLayout==="grid"?(j(),ce("div",sG,[(j(!0),ce(ze,null,Dt(C(i).currentOutputs,m=>(j(),we(wy,{key:m.id,"image-data":m,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):_e("",!0)])):_e("",!0),C(i).outputsLength==0?(j(),ce("div",lG,[le(C(OF),{description:"No Images Found"})])):_e("",!0)],64))}});const cG=Yt(uG,[["__scopeId","data-v-b39b47c5"]]),fG=Object.freeze(Object.defineProperty({__proto__:null,default:cG},Symbol.toStringTag,{value:"Module"})),dG=["href"],hG=Ee({__name:"BaseLink",props:{href:null,router:{type:Boolean}},setup(e){return(t,n)=>{const r=ht("router-link");return j(),ce(ze,null,[e.router?_e("",!0):(j(),ce("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:e.href},[Te(t.$slots,"default",{},void 0,!0)],8,dG)),e.router?(j(),we(r,{key:1,to:e.href},{default:pe(()=>[Te(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):_e("",!0)],64)}}});const pG=Yt(hG,[["__scopeId","data-v-17b53b7d"]]),Al=e=>(Qr("data-v-ecc278c5"),e=e(),ei(),e),mG={class:"about"},gG={class:"about-content"},vG=Al(()=>re("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),yG=Al(()=>re("div",null,[Ne("This tool was originally a front-end for the AI Horde and has since been converted for local generations with the A1111 API, such as in "),re("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),Ne(".")],-1)),bG=Al(()=>re("br",null,null,-1)),_G=Al(()=>re("div",null,"If you want to help improve this tool, you can find the currently maintained source code from this modified version on https://github.com/LostRuins/stable-ui and https://github.com/henk717/stable-ui, which is based off https://github.com/ayunami2000/stable-ui, which derives from the original AI Horde version on https://github.com/aqualxx/stable-ui (Original author aqualxx#5004). Feel free to contribute!",-1)),wG=Al(()=>re("br",null,null,-1)),CG=Ee({__name:"AboutView",setup(e){return(t,n)=>(j(),ce("div",mG,[re("div",gG,[vG,yG,bG,_G,wG,re("div",null,[Ne("You can find the KoboldAI community and authors of this fork on the "),le(pG,{href:"https://koboldai.org/discord"},{default:pe(()=>[Ne("KoboldAI Discord")]),_:1})])])]))}});const SG=Yt(CG,[["__scopeId","data-v-ecc278c5"]]),xG=Object.freeze(Object.defineProperty({__proto__:null,default:SG},Symbol.toStringTag,{value:"Module"}));const Ko=Ee({__name:"FormRadio",props:{label:null,modelValue:null,prop:null,useBoolean:{type:Boolean},options:null,disabled:{type:Boolean},info:null,labelStyle:null,change:null},emits:["update:modelValue"],setup(e,{emit:t}){const n=e;function r(l){if(n.useBoolean&&l==="Enabled"?t("update:modelValue",!0):n.useBoolean&&l==="Disabled"?t("update:modelValue",!1):t("update:modelValue",l),!!n.change)return n.useBoolean&&l==="Enabled"?n.change(!0):n.useBoolean&&l==="Disabled"?n.change(!1):n.change(l)}const i=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(l,g)=>(j(),we(C(Ti),{prop:e.prop},{label:pe(()=>[le(xl,{info:e.info,"label-style":e.labelStyle},{default:pe(()=>[Te(l.$slots,"label",{},()=>[Ne(Ae(e.label),1)])]),_:3},8,["info","label-style"])]),default:pe(()=>[le(C(C$),{disabled:e.disabled,"model-value":C(i),onChange:r},{default:pe(()=>[(j(!0),ce(ze,null,Dt(e.options,o=>(j(),we(C(S$),{key:o,label:o},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),Te(l.$slots,"inline")]),_:3},8,["prop"]))}}),Pl=e=>(Qr("data-v-b37ed090"),e=e(),ei(),e),TG=Pl(()=>re("h1",null,"Options",-1)),kG=Pl(()=>re("h2",null,"Generation Options",-1)),EG=Pl(()=>re("h2",null,"Image Options",-1)),OG=Pl(()=>re("div",null,[Ne("Drop file here OR "),re("em",null,"click to upload")],-1)),AG=Pl(()=>re("h2",null,"General Options",-1)),PG=Ee({__name:"OptionsView",setup(e){const t=Gt(),n=Ca(),r=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],i=oe([]),l=oe(),g=oe(!1),o=oe(0);async function a(h){n.importFromZip(h),l.value.clearFiles()}async function u(){Di({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),g.value=!0,o.value=0;const h=await Lt.outputs.toCollection().primaryKeys();await Z2(h,!1,()=>{o.value++}),g.value=!1,o.value=0}return(h,c)=>(j(),ce(ze,null,[TG,le(C(xp),{"label-position":"top",model:C(t).options,onSubmit:c[9]||(c[9]=Ze(()=>{},["prevent"]))},{default:pe(()=>[le(C(Aj),{type:"border-card",style:{"min-height":"50vh"}},{default:pe(()=>[le(C(wf),{label:"\u{1F5A8}\uFE0F Generation"},{default:pe(()=>[kG,le(C(Ti),{label:"Base URL"},{default:pe(()=>[le(C(Ra),{class:"apikey",prop:"baseURL",modelValue:C(t).baseURL,"onUpdate:modelValue":c[0]||(c[0]=f=>C(t).baseURL=f)},null,8,["modelValue"])]),_:1}),le(Ko,{label:"Allow Larger Params",prop:"pageless",modelValue:C(t).allowLargerParams,"onUpdate:modelValue":c[1]||(c[1]=f=>C(t).allowLargerParams=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:C(t).alsoRequestAvi,"onUpdate:modelValue":c[2]||(c[2]=f=>C(t).alsoRequestAvi=f),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),le(C(wf),{label:"\u{1F4F7} Images"},{default:pe(()=>[EG,le(En,{label:"Images Per Page",prop:"pageSize",modelValue:C(t).pageSize,"onUpdate:modelValue":c[3]||(c[3]=f=>C(t).pageSize=f),min:10,max:50,step:5,disabled:C(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),le(Ko,{label:"Pageless Format",prop:"pageless",modelValue:C(t).pageless,"onUpdate:modelValue":c[4]||(c[4]=f=>C(t).pageless=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:C(t).autoCarousel,"onUpdate:modelValue":c[5]||(c[5]=f=>C(t).autoCarousel=f),options:["Enabled","Disabled"]},null,8,["modelValue"]),le(Ko,{label:"Image Download Format",prop:"downloadType",modelValue:C(t).imageDownloadType,"onUpdate:modelValue":c[6]||(c[6]=f=>C(t).imageDownloadType=f),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),le(C(Ti),{label:"Export Images (ZIP File)"},{default:pe(()=>[g.value?(j(),we(C(lt),{key:1,icon:C(Ls),disabled:""},{default:pe(()=>[Ne("Downloading... ("+Ae(o.value)+" / "+Ae(C(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(j(),we(C(lt),{key:0,icon:C(Ls),onClick:c[7]||(c[7]=f=>u())},{default:pe(()=>[Ne("Download "+Ae(C(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),le(C(Ti),{label:"Import Images (ZIP File)"},{default:pe(()=>[le(C(Pp),{drag:"",ref_key:"upload",ref:l,"auto-upload":!1,onChange:a,"file-list":i.value,limit:1,multiple:""},{default:pe(()=>[le(C(De),{size:100},{default:pe(()=>[le(C(Kh))]),_:1}),OG]),_:1},8,["file-list"])]),_:1})]),_:1}),le(C(wf),{label:"\u2699\uFE0F General"},{default:pe(()=>[AG,le(Au,{label:"Color Scheme",prop:"colorScheme",modelValue:C(t).options.colorMode,"onUpdate:modelValue":c[8]||(c[8]=f=>C(t).options.colorMode=f),options:r},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}});const IG=Yt(PG,[["__scopeId","data-v-b37ed090"]]),MG=Object.freeze(Object.defineProperty({__proto__:null,default:IG},Symbol.toStringTag,{value:"Module"}));