diff --git a/README.md b/README.md index 3609ea719..ae066cd57 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ KoboldCpp is an easy-to-use AI text-generation software for GGML and GGUF models - Single file executable, with no installation required and no external dependencies - Runs on CPU or GPU, supports full or partial offloaded - LLM text generation (Supports all GGML and GGUF models, backwards compatibility with ALL past models) -- Image Generation and Image Editing (Stable Diffusion 1.5, SDXL, SD3, Flux, Qwen Image, Z-Image, Klein) -- Video Generation (WAN 2.2) +- Image Generation and Image Editing (Stable Diffusion 1.5, SDXL, SD3, Flux, Qwen Image, Z-Image, Klein, Krea2) +- Video Generation (WAN 2.2, LTX2.3, Minimax H3) - Speech-To-Text (Voice Recognition) via Whisper - Text-To-Speech (Voice Generation) via Qwen3TTS, Kokoro, OuteTTS, Parler and Dia -- Music Generation (Ace Step 1.5) +- Music Generation (Ace Step 1.5, Ace Step XL) - Image Recognition (Multimodal Vision) - MCP Server support and tool calling - Provides many compatible APIs endpoints for many popular webservices (KoboldCppApi OpenAiApi OllamaApi A1111ForgeApi ComfyUiApi WhisperTranscribeApi XttsApi OpenAiSpeechApi) diff --git a/embd_res/kcpp_sdui.embd b/embd_res/kcpp_sdui.embd index ca556eb09..134d69764 100644 --- a/embd_res/kcpp_sdui.embd +++ b/embd_res/kcpp_sdui.embd @@ -520,7 +520,7 @@ gl_FragColor.rgb *= color.a; `?(s++,f[s]=0):f[s]++;f[0]>0&&(this.insertCharStyleObject(u.lineIndex,u.charIndex,f[0],d),d=d&&d.slice(f[0]+1)),s&&this.insertNewlineStyleObject(u.lineIndex,u.charIndex+f[0],s);for(var h=1;h0?this.insertCharStyleObject(u.lineIndex+h,0,f[h],d):d&&this.styles[u.lineIndex+h]&&d[0]&&(this.styles[u.lineIndex+h][0]=d[0]),d=d&&d.slice(f[h]+1);f[h]>0&&this.insertCharStyleObject(u.lineIndex+h,0,f[h],d)},setSelectionStartEndWithShift:function(a,c,d){d<=a?(c===a?this._selectionDirection="left":this._selectionDirection==="right"&&(this._selectionDirection="left",this.selectionEnd=a),this.selectionStart=d):d>a&&da?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),c=this.selectionStart,d=this.selectionEnd;o.shiftKey?this.setSelectionStartEndWithShift(c,d,a):(this.selectionStart=a,this.selectionEnd=a),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(o){for(var a=this.getLocalPointer(o),c=0,d=0,u=0,f=0,s=0,h,g,p=0,v=this._textLines.length;p0&&(f+=this._textLines[p-1].length+this.missingNewlineOffset(p-1));h=this._getLineLeftOffset(s),d=h*this.scaleX,g=this._textLines[s],this.direction==="rtl"&&(a.x=this.width*this.scaleX-a.x+d);for(var y=0,b=g.length;yf||s<0?0:1,g=d+h;return this.flipX&&(g=u-g),g>this._text.length&&(g=this._text.length),g}}),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-top: "+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 c=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,d=this._text.length,u=c.length,f,s,h=u-d,g=this.selectionStart,p=this.selectionEnd,v=g!==p,y,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),C=g>S.selectionStart;v?(f=this._text.slice(g,p),h+=p-g):u0&&(d=this.__charBounds[o][a-1],c+=d.left+d.width),c},getDownCursorOffset:function(o,a){var c=this._getSelectionForOffset(o,a),d=this.get2DCursorLocation(c),u=d.lineIndex;if(u===this._textLines.length-1||o.metaKey||o.keyCode===34)return this._text.length-c;var f=d.charIndex,s=this._getWidthBeforeCursor(u,f),h=this._getIndexOnLine(u+1,s),g=this._textLines[u].slice(f);return g.length+h+1+this.missingNewlineOffset(u)},_getSelectionForOffset:function(o,a){return o.shiftKey&&this.selectionStart!==this.selectionEnd&&a?this.selectionEnd:this.selectionStart},getUpCursorOffset:function(o,a){var c=this._getSelectionForOffset(o,a),d=this.get2DCursorLocation(c),u=d.lineIndex;if(u===0||o.metaKey||o.keyCode===33)return-c;var f=d.charIndex,s=this._getWidthBeforeCursor(u,f),h=this._getIndexOnLine(u-1,s),g=this._textLines[u].slice(0,f),p=this.missingNewlineOffset(u-1);return-this._textLines[u-1].length+h-g.length+(1-p)},_getIndexOnLine:function(o,a){for(var c=this._textLines[o],d=this._getLineLeftOffset(o),u=d,f=0,s,h,g=0,p=c.length;ga){h=!0;var v=u-s,y=u,b=Math.abs(v-a),w=Math.abs(y-a);f=w=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 c="get"+o+"CursorOffset",d=this[c](a,this._selectionDirection==="right");a.shiftKey?this.moveCursorWithShift(d):this.moveCursorWithoutShift(d),d!==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,c){var d;if(o.altKey)d=this["findWordBoundary"+c](this[a]);else if(o.metaKey||o.keyCode===35||o.keyCode===36)d=this["findLineBoundary"+c](this[a]);else return this[a]+=c==="Left"?-1:1,!0;if(typeof d<"u"&&this[a]!==d)return this[a]=d,!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 c="moveCursor"+o+"With";this._currentCursorOpacity=1,a.shiftKey?c+="Shift":c+="outShift",this[c](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,c,d){typeof d>"u"&&(d=c),d>c&&this.removeStyleFromTo(c,d);var u=t.util.string.graphemeSplit(o);this.insertNewStyleBlock(u,c,a),this._text=[].concat(this._text.slice(0,c),u,this._text.slice(d)),this.text=this._text.join(""),this.set("dirty",!0),this._shouldClearDimensionCache()&&(this.initDimensions(),this.setCoords()),this._removeExtraneousStyles()}}),function(){var o=t.util.toFixed,a=t.util.radiansToDegrees,c=t.util.calcRotateMatrix,d=t.util.transformPoint,u=/ +/g;t.util.object.extend(t.Text.prototype,{_toSVG:function(){var f=this._getSVGLeftTopOffsets(),s=this._getSVGTextAndBg(f.textTop,f.textLeft);return this._wrapSVGTextAndBg(s)},toSVG:function(f){var s=this._createBaseSVGMarkup(this._toSVG(),{reviver:f,noStyle:!0,withShadow:!0}),h=this.path;return h?s+h._createBaseSVGMarkup(h._toSVG(),{reviver:f,withShadow:!0}):s},_getSVGLeftTopOffsets:function(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}},_wrapSVGTextAndBg:function(f){var s=!0,h=this.getSvgTextDecoration(this);return[f.textBgRects.join(""),' ",f.textSpans.join(""),` `]},_getSVGTextAndBg:function(f,s){var h=[],g=[],p=f,v;this._setSVGBg(g);for(var y=0,b=this._textLines.length;y",t.util.string.escapeXml(f),""].join("")},_setSVGTextLineText:function(f,s,h,g){var p=this.getHeightOfLine(s),v=this.textAlign.indexOf("justify")!==-1,y,b,w="",S,C,T=0,k=this._textLines[s],A;g+=p*(1-this._fontSizeFraction)/this.lineHeight;for(var P=0,z=k.length-1;P<=z;P++)A=P===z||this.charSpacing||this.path,w+=k[P],S=this.__charBounds[s][P],T===0?(h+=S.kernedWidth-S.width,T+=S.width):T+=S.kernedWidth,v&&!A&&this._reSpaceAndTab.test(k[P])&&(A=!0),A||(y=y||this.getCompleteStyleDeclaration(s,P),b=this.getCompleteStyleDeclaration(s,P+1),A=t.util.hasStyleChanged(y,b,!0)),A&&(C=this._getStyleDeclaration(s,P)||{},f.push(this._createTextCharSpan(w,C,h,g,S)),w="",y=b,h+=T,T=0)},_pushTextBgRect:function(f,s,h,g,p,v){var y=t.Object.NUM_FRACTION_DIGITS;f.push(" `)},_setSVGTextLineBg:function(f,s,h,g){for(var p=this._textLines[s],v=this.getHeightOfLine(s)/this.lineHeight,y=0,b=0,w,S,C=this.getValueOfPropertyAt(s,0,"textBackgroundColor"),T=0,k=p.length;Tthis.width&&this._set("width",this.dynamicMinWidth),this.textAlign.indexOf("justify")!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:"_dimensionAffectingProps"}))},_generateStyleMap:function(c){for(var d=0,u=0,f=0,s={},h=0;h0?(u=0,f++,d++):!this.splitByGrapheme&&this._reSpaceAndTab.test(c.graphemeText[f])&&h>0&&(u++,f++),s[h]={line:d,offset:u},f+=c.graphemeLines[h].length,u+=c.graphemeLines[h].length;return s},styleHas:function(c,d){if(this._styleMap&&!this.isWrapping){var u=this._styleMap[d];u&&(d=u.line)}return a.Text.prototype.styleHas.call(this,c,d)},isEmptyStyles:function(c){if(!this.styles)return!0;var d=0,u=c+1,f,s,h=!1,g=this._styleMap[c],p=this._styleMap[c+1];g&&(c=g.line,d=g.offset),p&&(u=p.line,h=u===c,f=p.offset),s=typeof c>"u"?this.styles:{line:this.styles[c]};for(var v in s)for(var y in s[v])if(y>=d&&(!h||yu&&!k?(g.push(p),p=[],s=S,k=!0):s+=A,!k&&!h&&p.push(w),p=p.concat(y),C=h?0:this._measureWord([w],d,b),b++,k=!1,S>T&&(T=S);return z&&g.push(p),T+P>this.dynamicMinWidth&&(this.dynamicMinWidth=T-A+P),g},isEndOfWrapping:function(c){return!this._styleMap[c+1]||this._styleMap[c+1].line!==this._styleMap[c].line},missingNewlineOffset:function(c,d){return this.splitByGrapheme&&!d?this.isEndOfWrapping(c)?1:0:1},_splitTextIntoLines:function(c){for(var d=a.Text.prototype._splitTextIntoLines.call(this,c),u=this._wrapText(d.lines,this.width),f=new Array(u.length),s=0;si.onload=m),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function X7(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 K7(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let m=0;m{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var Df=e=>new DataView(new ArrayBuffer(e)),co=e=>new Uint8Array(e.buffer||e),Lo=e=>new TextEncoder().encode(String(e));function q7(e,t,n=436){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),bytes:e.stream(),mode:n};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),bytes:e.body,mode:n};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,bytes:Lo(e),mode:n};if(e instanceof Blob)return{t,bytes:e.stream(),mode:n};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,bytes:e,mode:n};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,bytes:co(e),mode:n};if(Symbol.asyncIterator in e)return{t,bytes:VS(e[Symbol.asyncIterator]()),mode:n};throw new TypeError("Unsupported input format.")}function VS(e,t=e){return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await e.next();if(!i.value){n.close();break}{const l=Z7(i.value);n.enqueue(l),r+=l.byteLength}}},cancel(n){var r;(r=t.throw)==null||r.call(t,n)}})}function Z7(e){return typeof e=="string"?Lo(e):e instanceof Uint8Array?e:co(e)}function US(e,t,n){let[r,i]=function(l){return l?l instanceof Uint8Array?[l,1]:ArrayBuffer.isView(l)||l instanceof ArrayBuffer?[co(l),1]:[Lo(l),0]:[void 0,0]}(t);if(e instanceof File)return{o:Dd(r||Lo(e.name)),i:e.size,u:i};if(e instanceof Response){const l=e.headers.get("content-disposition"),m=l&&l.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),o=m&&m[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),a=o&&decodeURIComponent(o),c=n||+e.headers.get("content-length");return{o:Dd(r||Lo(a)),i:c,u:i}}return r=Dd(r),typeof e=="string"?{o:r,i:Lo(e).length,u:i}:e instanceof Blob?{o:r,i:e.size,u:i}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:r,i:e.byteLength,u:i}:{o:r,i:J7(e,n),u:i}}function J7(e,t){return t>-1?t:e?void 0:0}function Dd(e){if(!e||e.every(t=>t===47))throw new Error("The file must have a name.");for(;e[e.length-1]===47;)e=e.subarray(0,-1);return e}var HS=new Uint32Array(256);for(let e=0;e<256;++e){let t=e;for(let n=0;n<8;++n)t=t>>>1^(1&t&&3988292384);HS[e]=t}function Wy(e,t=0){t=~t;for(var n=0,r=e.length;n>>8^HS[255&t^e[n]];return~t>>>0}function WS(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 Q7({o:e,u:t},n){return 8*(!t||(n!=null?n:function(r){try{eU.decode(r)}catch{return 0}return 1}(e)))}var eU=new TextDecoder("utf8",{fatal:1});function tU(e,t=0){const n=Df(30);return n.setUint32(0,1347093252),n.setUint32(4,335546368|t),WS(e.t,n,10),n.setUint16(26,e.o.length,1),co(n)}async function*nU(e){let{bytes:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.l=Wy(t,0),e.i=t.length;else{e.i=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.l=Wy(r,e.l),e.i+=r.length,yield r}}}function rU(e){const t=Df(16);return t.setUint32(0,1347094280),t.setUint32(4,e.l,1),t.setUint32(8,e.i,1),t.setUint32(12,e.i,1),co(t)}function iU(e,t,n=0){const r=Df(46);return r.setUint32(0,1347092738),r.setUint32(4,352523264),r.setUint16(8,2048|n),WS(e.t,r,12),r.setUint32(16,e.l,1),r.setUint32(20,e.i,1),r.setUint32(24,e.i,1),r.setUint16(28,e.o.length,1),r.setUint16(40,32768|e.mode,1),r.setUint32(42,t,1),co(r)}function GS(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified,e.mode]]}var aU=e=>function(t){var n;let r=22;for(const i of t){if(!i.o)throw new Error("Every file must have a non-empty name.");if(isNaN((n=i.i)!=null?n:NaN))throw new Error(`Missing size for file "${new TextDecoder().decode(i.o)}".`);r+=2*i.o.length+i.i+92}return r}(function*(t){for(const n of t)yield US(...GS(n)[0])}(e));function oU(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=aU(t.metadata));const r=function(i){var l;const m=i[Symbol.iterator in i?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const o=await m.next();if(o.done)return o;const[a,c]=GS(o.value);return{done:0,value:Object.assign(q7(...c),US(...a))}},throw:(l=m.throw)==null?void 0:l.bind(m),[Symbol.asyncIterator](){return this}}}(e);return new Response(VS(async function*(i,l){const m=[];let o=0,a=0;for await(const u of i){const f=Q7(u,l.buffersAreUTF8);yield tU(u,f),yield new Uint8Array(u.o),yield*nU(u),yield rU(u),m.push(iU(u,o,f)),m.push(u.o),a++,o+=46+u.o.length+u.i}let c=0;for(const u of m)yield u,c+=u.length;const d=Df(22);d.setUint32(0,1347093766),d.setUint16(8,a,1),d.setUint16(10,a,1),d.setUint32(12,c,1),d.setUint32(16,o,1),yield co(d)}(r,t),r),{headers:n})}async function YS(e,t=!0,n){const r=Rt();t&&sa({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;c.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await Da(c,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await Da(c,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await Da(c,"image/gif")}):i.push({name:f+".webp",input:await Da(c,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(u,void 0,4)}),n&&n()}const l=await oU(i).blob(),m=document.createElement("a");m.href=URL.createObjectURL(l),m.download="sdui_images.zip",m.click()}async function rg(e,t){const n=Rt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await Da(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await Da(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await Da(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)}function KS(e,t){const n=e;if(!n)return;const r=atob(n),i=r.length,l=new Uint8Array(i);for(let c=0;c{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=ie({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ie({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>nn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>nn().currentImageProps),m=ee({get:()=>i.value.drawing&&!r.value,set:W=>i.value.drawing=W}),o=ie(512),a=ie(512),c=ie(!1),d=ie(30),u=ie(!1),f=new cr.fabric.Circle({radius:d.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ie("Erase"),h=ie("rgb(0, 0, 0, 1)");function g(){!i.value.canvas||i.value.canvas.renderAll()}function p(){c.value=!c.value,s.value=c.value?"Draw":"Erase"}function v(W=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=W||i.value.brush.color,i.value.brush.width=d.value)}async function y({history:W,erase:D=!1,draw:B=!1}={}){if(!W||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;W.path.selectable=!1,W.path.opacity=1,W.drawPath=await V(W.path),W.visibleDrawPath=await V(W.path),D?(W.visibleDrawPath.globalCompositeOperation="destination-out",W.drawPath.stroke=i.value.maskBackgroundColor):(W.visibleDrawPath.globalCompositeOperation="source-over",W.drawPath.stroke=B?h.value:i.value.maskPathColor);let Z=await V(W.drawPath);Z=Z.scale(i.value.imageScale),Z.left=Z.left+W.drawPath.left*(i.value.imageScale-1),Z.top=Z.top+W.drawPath.top*(i.value.imageScale-1),B?(i.value.imageLayer.add(Z),i.value.visibleImageLayer.addWithUpdate(W.visibleDrawPath)):(i.value.drawLayer.add(Z),i.value.visibleDrawLayer.addWithUpdate(W.visibleDrawPath)),i.value.canvas.remove(W.path),g()}function b(){if(i.value.undoHistory.length===0)return;const W=i.value.undoHistory.pop();y({history:W,erase:!1,draw:m.value}),i.value.redoHistory.push(W)}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 W=i.value.redoHistory.pop();i.value.undoHistory.push(W),m.value?(i.value.imageLayer.remove(W.drawPath),i.value.visibleImageLayer.remove(W.visibleDrawPath)):(i.value.drawLayer.remove(W.drawPath),i.value.visibleDrawLayer.remove(W.visibleDrawPath)),delete W.drawPath,delete W.visibleDrawPath,g()}function S(W){i.value.canvas=new cr.fabric.Canvas(W,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",v(i.value.maskPathColor),i.value.canvas.on("mouse:move",R),i.value.canvas.on("path:created",M),g()}function C(W,D,B,Z){let H=Z,Q=Z;return D>B?(W.scaleToWidth(Z),H=Z*(a.value/o.value)):(W.scaleToHeight(Z),Q=Z*(o.value/a.value)),{newHeight:H,newWidth:Q}}function T(W){const D=nn();if(ae(),W.selectable=!1,o.value=W.width,a.value=W.height,o.value>D.maxDimensions||a.value>D.maxDimensions){const{newHeight:Q,newWidth:te}=C(W,o.value,a.value,D.maxDimensions);o.value=te,a.value=Q}if(o.value{i.value.imageLayer=$({image:Q,layerHeight:H,layerWidth:Z})}),W.cloneAsImage(Q=>{if(!i.value.canvas)return;if(o.value!==B||a.value!==B){const{newHeight:me,newWidth:_e}=C(Q,o.value,a.value,B);o.value=_e,a.value=me}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=Y(),i.value.visibleImageLayer=Y({image:Q}),i.value.drawLayer=$({layerHeight:H,layerWidth:Z});const te=o.value*i.value.imageScale,fe=a.value*i.value.imageScale;D.params.width=te-te%64,D.params.height=fe-fe%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),u.value=!0,z(),A()})}function k(W,D,B,Z,H,Q){const te=Q?Q.width:W.width,fe=Q?Q.height:W.height;if(H==="Original")return W;const me=document.createElement("canvas");me.width=D,me.height=B;const _e=me.getContext("2d");_e.fillStyle=Z,_e.fillRect(0,0,me.width,me.height);let j=0,x=0,U=W.width,K=W.height,L=0,F=0,X=me.width,de=me.height;switch(H){case"Stretch":break;case"ScaleAndCrop":{const le=me.width/te,G=me.height/fe;le>G?(K=me.height/le,x=(W.height-K)/2):(U=me.width/G,j=(W.width-U)/2);break}case"ScaleAndPad":{const le=me.width/te,G=me.height/fe;leD?(U=D,j=le-D/2):(X=te,L=D/2-le),fe>B?(K=B,x=G-B/2):(de=fe,F=B/2-G);break}}return _e.drawImage(W,j,x,U,K,L,F,X,de),me}function A(){const W=nn(),D=Rt();if(!i.value.imageLayer||!i.value.drawLayer)return;const B=W.params.width,Z=W.params.height,H=i.value.imageLayer.backgroundColor||"#FFFFFF",Q=D.imageResizeMode,te=i.value.imageLayer.toCanvasElement(),fe=k(te,B,Z,H,Q,te);if(l.value.sourceImage=fe.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!m.value){const _e=i.value.drawLayer.toCanvasElement(),j=k(_e,B,Z,H,Q,te);l.value.maskImage=j.toDataURL("image/jpeg",1).split(",")[1]}}let P;function z(){if(!i.value.canvas)return;const W=nn();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),u.value&&(i.value.cropPreviewLayer=Y({layerWidth:W.params.width/i.value.imageScale,layerHeight:W.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),P&&clearTimeout(P),P=setTimeout(()=>{u.value=!1,z(),P=void 0},5e3))}function I(W,D){const B="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";cr.fabric.Image.fromURL(B,Z=>{Z.set({height:W,width:D});const H=Z.toDataURL({format:"png"});l.value.sourceImage=H,m.value=!0,T(Z)})}function $({image:W,layerWidth:D,layerHeight:B}={}){const Z=new cr.fabric.Canvas(null);return Z.selection=!1,Z.backgroundColor=i.value.maskBackgroundColor,Z.setHeight(B||a.value),Z.setWidth(D||o.value),W&&Z.add(W),Z}function O(){return i.value.imageLayer?{layerHeight:i.value.imageLayer.getHeight(),layerWidth:i.value.imageLayer.getWidth()}:{}}function Y({image:W,layerWidth:D,layerHeight:B,fill:Z,abosolute:H}={}){const Q=W||new cr.fabric.Rect({width:D||o.value,height:B||a.value,left:0,top:0,fill:Z||"transparent",absolutePositioned:H||!0,selectable:!1});return new cr.fabric.Group([Q],{selectable:!1,absolutePositioned:H||!0})}function ae(){!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 q(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),m.value){const W=nn();I(W.params.height||512,W.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=Y(),i.value.drawLayer=$(O()),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function J(){var D;A();const W=document.createElement("a");if(m.value){W.href="data:image/png;base64,"+((D=l.value.sourceImage)==null?void 0:D.split(",")[1]),W.download="image_drawing.png",W.click();return}W.href="data:image/png;base64,"+l.value.maskImage,W.download="image_mask.png",W.click()}function E(){A();const W=nn(),D=l.value.sourceImage;!D||rg(D,`${W.generatorType.toLowerCase()}-reference`)}async function V(W){return new Promise((D,B)=>{try{W.clone(D)}catch(Z){B(Z)}})}async function M(W){const D={path:W.path};y({history:D,erase:c.value,draw:m.value}),i.value.redoHistory.push(D)}function R(W){if(!i.value.canvas)return;const D=i.value.canvas.getPointer(W.e);f.left=D.x,f.top=D.y,f.opacity=.8,c.value?(f.set("strokeWidth",3),f.set("fill",""),v("red")):(f.set("strokeWidth",0),m.value?(f.set("fill",h.value),v(h.value)):(f.set("fill","white"),v("white"))),f.set("radius",d.value/2),g()}return{showCropPreview:u,erasing:c,switchToolText:s,brushSize:d,drawColor:h,drawing:m,imageProps:i,updateCropPreview:z,createNewCanvas:S,downloadMask:J,downloadSourceImage:E,resetCanvas:ae,resetDrawing:q,flipErase:p,undoAction:w,redoAction:b,newImage:T,newBlankImage:I,setBrush:v,saveImages:A}}),sU={},lU={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"};function uU(e,t){return N(),se("svg",lU,[...t[0]||(t[0]=[ne("g",{fill:"none"},[ne("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)])])}const cU=on(sU,[["render",uU]]),fU={key:0},dU={class:"canvas-container"},hU={class:"action-buttons",style:{left:"10px",right:"unset"}},pU={class:"action-buttons"},mU=be({__name:"CustomCanvas",setup(e){const t=nn(),n=Yt(),r=il(),i=ie();async function l(a){if(!a.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const c=await Nl(a.raw);t.currentImageProps.sourceImage=c,r.drawing=!1,cr.fabric.Image.fromURL(c,r.newImage)}function m(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&cr.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Jt(()=>{window.removeEventListener("paste",o)});async function o(a){var d;const c=(d=a.clipboardData)==null?void 0:d.items;if(!!c)for(let u=0;u(N(),se($e,null,[_(t).currentImageProps.sourceImage?ge("",!0):(N(),ve(_(Lm),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:ue(()=>[_(t).generatorType==="Img2Img"?(N(),se("div",fU,[c[9]||(c[9]=ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:c[0]||(c[0]=d=>_(r).newBlankImage(_(t).params.height||512,_(t).params.width||512))},[oe(_(De),{size:20,style:{"margin-right":"2px"}},{default:ue(()=>[oe(zS)]),_:1}),c[8]||(c[8]=Ne("draw something",-1))])])):ge("",!0)]),default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),c[10]||(c[10]=ne("div",null,[Ne("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1))]),_:1},512)),xt(ne("div",null,[ne("div",dU,[c[11]||(c[11]=ne("canvas",{id:"canvas"},null,-1)),ne("div",hU,[oe(_(Ze),{onClick:c[1]||(c[1]=d=>_(r).undoAction()),icon:_(R1),plain:"",disabled:_(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),oe(_(Ze),{onClick:c[2]||(c[2]=d=>_(r).redoAction()),icon:_(D1),plain:"",disabled:_(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",pU,[oe(_(Ze),{onClick:c[3]||(c[3]=d=>_(r).resetDrawing()),icon:_(Kr),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:m,icon:_(Yi),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:c[4]||(c[4]=d=>_(r).downloadSourceImage()),icon:_(yl),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:c[5]||(c[5]=d=>_(r).flipErase()),icon:_(r).erasing?_(sO):cU,plain:""},null,8,["icon"]),_(r).drawing?(N(),ve(_(ID),{key:0,modelValue:_(r).drawColor,"onUpdate:modelValue":c[6]||(c[6]=d=>_(r).drawColor=d),"show-alpha":""},null,8,["modelValue"])):ge("",!0)]),oe(_(Em),{"label-width":"110px",style:{"margin-top":"10px"}},{default:ue(()=>[oe(bn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:_(r).brushSize,"onUpdate:modelValue":c[7]||(c[7]=d=>_(r).brushSize=d),min:10,max:100,step:10,change:_(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Gt,_(t).currentImageProps.sourceImage]])],64))}}),Gy=on(mU,[["__scopeId","data-v-0cdc2bf8"]]),gU={class:"centerIcons"},vU={class:"stackedIcons"},yU=be({__name:"StackedIcon",props:{iconOne:{type:[Object,Function]},iconTwo:{type:[Object,Function]},size:{}},setup(e){JT(n=>({"2ad037ca":n.size+"px"}));const t=e;return(n,r)=>(N(),se("div",gU,[ne("div",vU,[oe(_(De),{class:"firstIcon",size:n.size},{default:ue(()=>[(N(),ve(Ct(t.iconOne)))]),_:1},8,["size"]),oe(_(De),{class:"secondIcon",size:n.size},{default:ue(()=>[(N(),ve(Ct(t.iconTwo)))]),_:1},8,["size"])])]))}}),bU=on(yU,[["__scopeId","data-v-74586a39"]]),_U={key:1,style:{width:"40px"}},Uu=be({__name:"GeneratorMenuItem",props:{index:{},iconOne:{type:[Object,Function]},iconTwo:{type:[Object,Function]},isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(N(),ve(_(fn),{content:n.index,placement:n.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:ue(()=>[oe(_(Am),{index:n.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:ue(()=>[n.iconTwo?(N(),ve(bU,{key:0,iconOne:n.iconOne,iconTwo:n.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(N(),se("div",_U,[oe(_(De),{style:{width:"35px"},size:40},{default:ue(()=>[(N(),ve(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 wU=4,Yy=0,Ky=1,SU=2;function ys(e){let t=e.length;for(;--t>=0;)e[t]=0}const CU=0,XS=1,xU=2,TU=3,kU=258,ig=29,hu=256,zl=hu+1+ig,Uo=30,ag=19,qS=2*zl+1,Fa=15,Fd=16,EU=7,og=256,ZS=16,JS=17,QS=18,cp=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]),yc=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]),OU=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),eC=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),AU=512,ci=new Array((zl+2)*2);ys(ci);const al=new Array(Uo*2);ys(al);const jl=new Array(AU);ys(jl);const Vl=new Array(kU-TU+1);ys(Vl);const sg=new Array(ig);ys(sg);const nf=new Array(Uo);ys(nf);function Bd(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 tC,nC,rC;function $d(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const iC=e=>e<256?jl[e]:jl[256+(e>>>7)],Ul=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Nn=(e,t,n)=>{e.bi_valid>Fd-n?(e.bi_buf|=t<>Fd-e.bi_valid,e.bi_valid+=n-Fd):(e.bi_buf|=t<{Nn(e,n[t*2],n[t*2+1])},aC=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},PU=e=>{e.bi_valid===16?(Ul(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)},IU=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,m=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let c,d,u,f,s,h,g=0;for(f=0;f<=Fa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;ca&&(f=a,g++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,s=0,d>=o&&(s=m[d-o]),h=n[d*2],e.opt_len+=h*(f+s),l&&(e.static_len+=h*(i[d*2+1]+s)));if(g!==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]--,g-=2}while(g>0);for(f=a;f!==0;f--)for(d=e.bl_count[f];d!==0;)u=e.heap[--c],!(u>r)&&(n[u*2+1]!==f&&(e.opt_len+=(f-n[u*2+1])*n[u*2],n[u*2+1]=f),d--)}},oC=(e,t,n)=>{const r=new Array(Fa+1);let i=0,l,m;for(l=1;l<=Fa;l++)i=i+n[l-1]<<1,r[l]=i;for(m=0;m<=t;m++){let o=e[m*2+1];o!==0&&(e[m*2]=aC(r[o]++,o))}},MU=()=>{let e,t,n,r,i;const l=new Array(Fa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?Ul(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Xy=(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,m,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?Vr(e,i,t):(m=Vl[i],Vr(e,m+hu+1,t),o=cp[m],o!==0&&(i-=sg[m],Nn(e,i,o)),r--,m=iC(r),Vr(e,m,n),o=yc[m],o!==0&&(r-=nf[m],Nn(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 m,o,a=-1,c;for(e.heap_len=0,e.heap_max=qS,m=0;m>1;m>=1;m--)Nd(e,n,m);c=l;do m=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Nd(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=m,e.heap[--e.heap_max]=o,n[c*2]=n[m*2]+n[o*2],e.depth[c]=(e.depth[m]>=e.depth[o]?e.depth[m]:e.depth[o])+1,n[m*2+1]=n[o*2+1]=c,e.heap[1]=c++,Nd(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],IU(e,t),oC(n,a,e.bl_count)},Zy=(e,t,n)=>{let r,i=-1,l,m=t[0*2+1],o=0,a=7,c=4;for(m===0&&(a=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=m,m=t[(r+1)*2+1],!(++o{let r,i=-1,l,m=t[0*2+1],o=0,a=7,c=4;for(m===0&&(a=138,c=3),r=0;r<=n;r++)if(l=m,m=t[(r+1)*2+1],!(++o{let t;for(Zy(e,e.dyn_ltree,e.l_desc.max_code),Zy(e,e.dyn_dtree,e.d_desc.max_code),fp(e,e.bl_desc),t=ag-1;t>=3&&e.bl_tree[eC[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},RU=(e,t,n,r)=>{let i;for(Nn(e,t-257,5),Nn(e,n-1,5),Nn(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 Yy;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Ky;for(n=32;n{Qy||(MU(),Qy=!0),e.l_desc=new $d(e.dyn_ltree,tC),e.d_desc=new $d(e.dyn_dtree,nC),e.bl_desc=new $d(e.bl_tree,rC),e.bi_buf=0,e.bi_valid=0,sC(e)},uC=(e,t,n,r)=>{Nn(e,(CU<<1)+(r?1:0),3),lC(e),Ul(e,n),Ul(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},BU=e=>{Nn(e,XS<<1,3),Vr(e,og,ci),PU(e)},$U=(e,t,n,r)=>{let i,l,m=0;e.level>0?(e.strm.data_type===SU&&(e.strm.data_type=DU(e)),fp(e,e.l_desc),fp(e,e.d_desc),m=LU(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?uC(e,t,n,r):e.strategy===wU||l===i?(Nn(e,(XS<<1)+(r?1:0),3),qy(e,ci,al)):(Nn(e,(xU<<1)+(r?1:0),3),RU(e,e.l_desc.max_code+1,e.d_desc.max_code+1,m+1),qy(e,e.dyn_ltree,e.dyn_dtree)),sC(e),r&&lC(e)},NU=(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[(Vl[n]+hu+1)*2]++,e.dyn_dtree[iC(t)*2]++),e.sym_next===e.sym_end);var zU=FU,jU=uC,VU=$U,UU=NU,HU=BU,WU={_tr_init:zU,_tr_stored_block:jU,_tr_flush_block:VU,_tr_tally:UU,_tr_align:HU};const GU=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,m=0;for(;n!==0;){m=n>2e3?2e3:n,n-=m;do i=i+t[r++]|0,l=l+i|0;while(--m);i%=65521,l%=65521}return i|l<<16|0};var Hl=GU;const YU=()=>{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},KU=new Uint32Array(YU()),XU=(e,t,n,r)=>{const i=KU,l=r+n;e^=-1;for(let m=r;m>>8^i[(e^t[m])&255];return e^-1};var sn=XU,Qa={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"},bs={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:qU,_tr_stored_block:dp,_tr_flush_block:ZU,_tr_tally:ea,_tr_align:JU}=WU,{Z_NO_FLUSH:ta,Z_PARTIAL_FLUSH:QU,Z_FULL_FLUSH:eH,Z_FINISH:fr,Z_BLOCK:eb,Z_OK:cn,Z_STREAM_END:tb,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:tH,Z_BUF_ERROR:zd,Z_DEFAULT_COMPRESSION:nH,Z_FILTERED:rH,Z_HUFFMAN_ONLY:Hu,Z_RLE:iH,Z_FIXED:aH,Z_DEFAULT_STRATEGY:oH,Z_UNKNOWN:sH,Z_DEFLATED:Ff}=bs,lH=9,uH=15,cH=8,fH=29,dH=256,hp=dH+1+fH,hH=30,pH=19,mH=2*hp+1,gH=15,ct=3,qi=258,Yr=qi+ct+1,vH=32,rs=42,lg=57,pp=69,mp=73,gp=91,vp=103,Ba=113,Bs=666,Mn=1,_s=2,eo=3,ws=4,yH=3,$a=(e,t)=>(e.msg=Qa[t],t),nb=e=>e*2-(e>4?9:0),Gi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},bH=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 _H=(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))},Jn=(e,t)=>{ZU(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Kn(e.strm)},vt=(e,t)=>{e.pending_buf[e.pending++]=t},Is=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},yp=(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=Hl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=sn(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},cC=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,m=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Yr?e.strstart-(e.w_size-Yr):0,c=e.window,d=e.w_mask,u=e.prev,f=e.strstart+qi;let s=c[r+m-1],h=c[r+m];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(c[i+m]!==h||c[i+m-1]!==s||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&rm){if(e.match_start=t,m=l,l>=o)break;s=c[r+m-1],h=c[r+m]}}while((t=u[t&d])>a&&--n!==0);return m<=e.lookahead?m:e.lookahead},is=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Yr)&&(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),bH(e),r+=t),e.strm.avail_in===0)break;if(n=yp(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=ct)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=na(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=na(e,e.ins_h,e.window[i+ct-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,m=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,Kn(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&&(yp(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(m===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&&(yp(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===fr)&&t!==ta&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,m=t===fr&&e.strm.avail_in===0&&r===i?1:0,dp(e,e.block_start,r,m),e.block_start+=r,Kn(e.strm)),m?eo:Mn)},jd=(e,t)=>{let n,r;for(;;){if(e.lookahead=ct&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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-Yr&&(e.match_length=cC(e,n)),e.match_length>=ct)if(r=ea(e,e.strstart-e.match_start,e.match_length-ct),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=ct){e.match_length--;do e.strstart++,e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=na(e,e.ins_h,e.window[e.strstart+1]);else r=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ct&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=ct-1,n!==0&&e.prev_length4096)&&(e.match_length=ct-1)),e.prev_length>=ct&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-ct,r=ea(e,e.strstart-1-e.prev_match,e.prev_length-ct),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=ct-1,e.strstart++,r&&(Jn(e,!1),e.strm.avail_out===0))return Mn}else if(e.match_available){if(r=ea(e,0,e.window[e.strstart-1]),r&&Jn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Mn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ea(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const m=e.window;for(;;){if(e.lookahead<=qi){if(is(e),e.lookahead<=qi&&t===ta)return Mn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=ct&&e.strstart>0&&(i=e.strstart-1,r=m[i],r===m[++i]&&r===m[++i]&&r===m[++i])){l=e.strstart+qi;do;while(r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=ct?(n=ea(e,1,e.match_length-ct),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=0,t===fr?(Jn(e,!0),e.strm.avail_out===0?eo:ws):e.sym_next&&(Jn(e,!1),e.strm.avail_out===0)?Mn:_s},SH=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(is(e),e.lookahead===0)){if(t===ta)return Mn;break}if(e.match_length=0,n=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=0,t===fr?(Jn(e,!0),e.strm.avail_out===0?eo:ws):e.sym_next&&(Jn(e,!1),e.strm.avail_out===0)?Mn:_s};function Br(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 $s=[new Br(0,0,0,0,fC),new Br(4,4,8,4,jd),new Br(4,5,16,8,jd),new Br(4,6,32,32,jd),new Br(4,4,16,16,xo),new Br(8,16,32,32,xo),new Br(8,16,128,128,xo),new Br(8,32,128,256,xo),new Br(32,128,258,1024,xo),new Br(32,258,258,4096,xo)],CH=e=>{e.window_size=2*e.w_size,Gi(e.head),e.max_lazy_match=$s[e.level].max_lazy,e.good_match=$s[e.level].good_length,e.nice_match=$s[e.level].nice_length,e.max_chain_length=$s[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=ct-1,e.match_available=0,e.ins_h=0};function xH(){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=Ff,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(mH*2),this.dyn_dtree=new Uint16Array((2*hH+1)*2),this.bl_tree=new Uint16Array((2*pH+1)*2),Gi(this.dyn_ltree),Gi(this.dyn_dtree),Gi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(gH+1),this.heap=new Uint16Array(2*hp+1),Gi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*hp+1),Gi(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 pu=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rs&&t.status!==lg&&t.status!==pp&&t.status!==mp&&t.status!==gp&&t.status!==vp&&t.status!==Ba&&t.status!==Bs?1:0},dC=e=>{if(pu(e))return $a(e,Gr);e.total_in=e.total_out=0,e.data_type=sH;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?lg:t.wrap?rs:Ba,e.adler=t.wrap===2?0:1,t.last_flush=-2,qU(t),cn},hC=e=>{const t=dC(e);return t===cn&&CH(e.state),t},TH=(e,t)=>pu(e)||e.state.wrap!==2?Gr:(e.state.gzhead=t,cn),pC=(e,t,n,r,i,l)=>{if(!e)return Gr;let m=1;if(t===nH&&(t=6),r<0?(m=0,r=-r):r>15&&(m=2,r-=16),i<1||i>lH||n!==Ff||r<8||r>15||t<0||t>9||l<0||l>aH||r===8&&m!==1)return $a(e,Gr);r===8&&(r=9);const o=new xH;return e.state=o,o.strm=e,o.status=rs,o.wrap=m,o.gzhead=null,o.w_bits=r,o.w_size=1<pC(e,t,Ff,uH,cH,oH),EH=(e,t)=>{if(pu(e)||t>eb||t<0)return e?$a(e,Gr):Gr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===Bs&&t!==fr)return $a(e,e.avail_out===0?zd:Gr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Kn(e),e.avail_out===0)return n.last_flush=-1,cn}else if(e.avail_in===0&&nb(t)<=nb(r)&&t!==fr)return $a(e,zd);if(n.status===Bs&&e.avail_in!==0)return $a(e,zd);if(n.status===rs&&n.wrap===0&&(n.status=Ba),n.status===rs){let i=Ff+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=Hu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=vH),i+=31-i%31,Is(n,i),n.strstart!==0&&(Is(n,e.adler>>>16),Is(n,e.adler&65535)),e.adler=1,n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(n.status===lg){if(e.adler=0,vt(n,31),vt(n,139),vt(n,8),n.gzhead)vt(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)),vt(n,n.gzhead.time&255),vt(n,n.gzhead.time>>8&255),vt(n,n.gzhead.time>>16&255),vt(n,n.gzhead.time>>24&255),vt(n,n.level===9?2:n.strategy>=Hu||n.level<2?4:0),vt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(vt(n,n.gzhead.extra.length&255),vt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=sn(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=pp;else if(vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,n.level===9?2:n.strategy>=Hu||n.level<2?4:0),vt(n,yH),n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(n.status===pp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0,l-=o}let m=new Uint8Array(n.gzhead.extra);n.pending_buf.set(m.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=mp}if(n.status===mp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0}n.gzindexi&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=gp}if(n.status===gp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0}n.gzindexi&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i))}n.status=vp}if(n.status===vp){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Kn(e),n.pending!==0))return n.last_flush=-1,cn;vt(n,e.adler&255),vt(n,e.adler>>8&255),e.adler=0}if(n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(e.avail_in!==0||n.lookahead!==0||t!==ta&&n.status!==Bs){let i=n.level===0?fC(n,t):n.strategy===Hu?SH(n,t):n.strategy===iH?wH(n,t):$s[n.level].func(n,t);if((i===eo||i===ws)&&(n.status=Bs),i===Mn||i===eo)return e.avail_out===0&&(n.last_flush=-1),cn;if(i===_s&&(t===QU?JU(n):t!==eb&&(dp(n,0,0,!1),t===eH&&(Gi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Kn(e),e.avail_out===0))return n.last_flush=-1,cn}return t!==fr?cn:n.wrap<=0?tb:(n.wrap===2?(vt(n,e.adler&255),vt(n,e.adler>>8&255),vt(n,e.adler>>16&255),vt(n,e.adler>>24&255),vt(n,e.total_in&255),vt(n,e.total_in>>8&255),vt(n,e.total_in>>16&255),vt(n,e.total_in>>24&255)):(Is(n,e.adler>>>16),Is(n,e.adler&65535)),Kn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?cn:tb)},OH=e=>{if(pu(e))return Gr;const t=e.state.status;return e.state=null,t===Ba?$a(e,tH):cn},AH=(e,t)=>{let n=t.length;if(pu(e))return Gr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==rs||r.lookahead)return Gr;if(i===1&&(e.adler=Hl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Gi(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,m=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,is(r);r.lookahead>=ct;){let a=r.strstart,c=r.lookahead-(ct-1);do r.ins_h=na(r,r.ins_h,r.window[a+ct-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--c);r.strstart=a,r.lookahead=ct-1,is(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=ct-1,r.match_available=0,e.next_in=m,e.input=o,e.avail_in=l,r.wrap=i,cn};var PH=kH,IH=pC,MH=hC,LH=dC,RH=TH,DH=EH,FH=OH,BH=AH,$H="pako deflate (from Nodeca project)",ol={deflateInit:PH,deflateInit2:IH,deflateReset:MH,deflateResetKeep:LH,deflateSetHeader:RH,deflate:DH,deflateEnd:FH,deflateSetDictionary:BH,deflateInfo:$H};const NH=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var zH=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)NH(n,r)&&(e[r]=n[r])}}return e},jH=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;Wl[254]=Wl[254]=1;var VH=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,m=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 UH=(e,t)=>{if(t<65534&&e.subarray&&mC)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(m&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}m<65536?l[i++]=m:(m-=65536,l[i++]=55296|m>>10&1023,l[i++]=56320|m&1023)}return UH(l,i)},WH=(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+Wl[e[n]]>t?n:t},Gl={string2buf:VH,buf2string:HH,utf8border:WH};function GH(){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 gC=GH;const vC=Object.prototype.toString,{Z_NO_FLUSH:YH,Z_SYNC_FLUSH:KH,Z_FULL_FLUSH:XH,Z_FINISH:qH,Z_OK:rf,Z_STREAM_END:ZH,Z_DEFAULT_COMPRESSION:JH,Z_DEFAULT_STRATEGY:QH,Z_DEFLATED:eW}=bs;function mu(e){this.options=Bf.assign({level:JH,method:eW,chunkSize:16384,windowBits:15,memLevel:8,strategy:QH},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 gC,this.strm.avail_out=0;let n=ol.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==rf)throw new Error(Qa[n]);if(t.header&&ol.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=Gl.string2buf(t.dictionary):vC.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=ol.deflateSetDictionary(this.strm,r),n!==rf)throw new Error(Qa[n]);this._dict_set=!0}}mu.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?qH:YH,typeof e=="string"?n.input=Gl.string2buf(e):vC.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===KH||l===XH)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=ol.deflate(n,l),i===ZH)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=ol.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===rf;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};mu.prototype.onData=function(e){this.chunks.push(e)};mu.prototype.onEnd=function(e){e===rf&&(this.result=Bf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function ug(e,t){const n=new mu(t);if(n.push(e,!0),n.err)throw n.msg||Qa[n.err];return n.result}function tW(e,t){return t=t||{},t.raw=!0,ug(e,t)}function nW(e,t){return t=t||{},t.gzip=!0,ug(e,t)}var rW=mu,iW=ug,aW=tW,oW=nW,sW=bs,lW={Deflate:rW,deflate:iW,deflateRaw:aW,gzip:oW,constants:sW};const Wu=16209,uW=16191;var cW=function(t,n){let r,i,l,m,o,a,c,d,u,f,s,h,g,p,v,y,b,w,S,C,T,k,A,P;const z=t.state;r=t.next_in,A=t.input,i=r+(t.avail_in-5),l=t.next_out,P=t.output,m=l-(n-t.avail_out),o=l+(t.avail_out-257),a=z.dmax,c=z.wsize,d=z.whave,u=z.wnext,f=z.window,s=z.hold,h=z.bits,g=z.lencode,p=z.distcode,v=(1<>>24,s>>>=w,h-=w,w=b>>>16&255,w===0)P[l++]=b&65535;else if(w&16){S=b&65535,w&=15,w&&(h>>=w,h-=w),h<15&&(s+=A[r++]<>>24,s>>>=w,h-=w,w=b>>>16&255,w&16){if(C=b&65535,w&=15,ha){t.msg="invalid distance too far back",z.mode=Wu;break e}if(s>>>=w,h-=w,w=l-m,C>w){if(w=C-w,w>d&&z.sane){t.msg="invalid distance too far back",z.mode=Wu;break e}if(T=0,k=f,u===0){if(T+=c-w,w2;)P[l++]=k[T++],P[l++]=k[T++],P[l++]=k[T++],S-=3;S&&(P[l++]=k[T++],S>1&&(P[l++]=k[T++]))}else{T=l-C;do P[l++]=P[T++],P[l++]=P[T++],P[l++]=P[T++],S-=3;while(S>2);S&&(P[l++]=P[T++],S>1&&(P[l++]=P[T++]))}}else if((w&64)===0){b=p[(b&65535)+(s&(1<>3,r-=S,h-=S<<3,s&=(1<{const a=o.bits;let c=0,d=0,u=0,f=0,s=0,h=0,g=0,p=0,v=0,y=0,b,w,S,C,T,k=null,A;const P=new Uint16Array(To+1),z=new Uint16Array(To+1);let I=null,$,O,Y;for(c=0;c<=To;c++)P[c]=0;for(d=0;d=1&&P[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(u=1;u0&&(e===ab||f!==1))return-1;for(z[1]=0,c=1;crb||e===ob&&v>ib)return 1;for(;;){$=c-g,m[d]+1=A?(O=I[m[d]-A],Y=k[m[d]-A]):(O=32+64,Y=0),b=1<>g)+w]=$<<24|O<<16|Y|0;while(w!==0);for(b=1<>=1;if(b!==0?(y&=b-1,y+=b):y=0,d++,--P[c]===0){if(c===f)break;c=t[n+m[d]]}if(c>s&&(y&C)!==S){for(g===0&&(g=s),T+=u,h=c-g,p=1<rb||e===ob&&v>ib)return 1;S=y&C,i[S]=s<<24|h<<16|T-l|0}}return y!==0&&(i[T+y]=c-g<<24|64<<16|0),o.bits=s,0};var sl=mW;const gW=0,yC=1,bC=2,{Z_FINISH:sb,Z_BLOCK:vW,Z_TREES:Gu,Z_OK:to,Z_STREAM_END:yW,Z_NEED_DICT:bW,Z_STREAM_ERROR:vr,Z_DATA_ERROR:_C,Z_MEM_ERROR:wC,Z_BUF_ERROR:_W,Z_DEFLATED:lb}=bs,$f=16180,ub=16181,cb=16182,fb=16183,db=16184,hb=16185,pb=16186,mb=16187,gb=16188,vb=16189,af=16190,ai=16191,Ud=16192,yb=16193,Hd=16194,bb=16195,_b=16196,wb=16197,Sb=16198,Yu=16199,Ku=16200,Cb=16201,xb=16202,Tb=16203,kb=16204,Eb=16205,Wd=16206,Ob=16207,Ab=16208,jt=16209,SC=16210,CC=16211,wW=852,SW=592,CW=15,xW=CW,Pb=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function TW(){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 fo=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<$f||t.mode>CC?1:0},xC=e=>{if(fo(e))return vr;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=$f,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(wW),t.distcode=t.distdyn=new Int32Array(SW),t.sane=1,t.back=-1,to},TC=e=>{if(fo(e))return vr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xC(e)},kC=(e,t)=>{let n;if(fo(e))return vr;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?vr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,TC(e))},EC=(e,t)=>{if(!e)return vr;const n=new TW;e.state=n,n.strm=e,n.window=null,n.mode=$f;const r=kC(e,t);return r!==to&&(e.state=null),r},kW=e=>EC(e,xW);let Ib=!0,Gd,Yd;const EW=e=>{if(Ib){Gd=new Int32Array(512),Yd=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(sl(yC,e.lens,0,288,Gd,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sl(bC,e.lens,0,32,Yd,0,e.work,{bits:5}),Ib=!1}e.lencode=Gd,e.lenbits=9,e.distcode=Yd,e.distbits=5},OC=(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,m,o,a,c,d,u,f,s,h,g,p=0,v,y,b,w,S,C,T,k;const A=new Uint8Array(4);let P,z;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(fo(e)||!e.output||!e.input&&e.avail_in!==0)return vr;n=e.state,n.mode===ai&&(n.mode=Ud),m=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,c=n.hold,d=n.bits,u=o,f=a,k=to;e:for(;;)switch(n.mode){case $f:if(n.wrap===0){n.mode=Ud;break}for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>>8&255,n.check=sn(n.check,A,2,0),c=0,d=0,n.mode=ub;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=jt;break}if((c&15)!==lb){e.msg="unknown compression method",n.mode=jt;break}if(c>>>=4,d-=4,T=(c&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=jt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0,n.mode=cb;case cb:for(;d<32;){if(o===0)break e;o--,c+=r[l++]<>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,n.check=sn(n.check,A,4,0)),c=0,d=0,n.mode=fb;case fb:for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>8),n.flags&512&&n.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0,n.mode=db;case db:if(n.flags&1024){for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=hb;case hb: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=sn(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=pb;case pb: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=ai;break;case vb:for(;d<32;){if(o===0)break e;o--,c+=r[l++]<>>=d&7,d-=d&7,n.mode=Wd;break}for(;d<3;){if(o===0)break e;o--,c+=r[l++]<>>=1,d-=1,c&3){case 0:n.mode=yb;break;case 1:if(EW(n),n.mode=Yu,t===Gu){c>>>=2,d-=2;break e}break;case 2:n.mode=_b;break;case 3:e.msg="invalid block type",n.mode=jt}c>>>=2,d-=2;break;case yb:for(c>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,c+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=jt;break}if(n.length=c&65535,c=0,d=0,n.mode=Hd,t===Gu)break e;case Hd:n.mode=bb;case bb: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),m),o-=s,l+=s,a-=s,m+=s,n.length-=s;break}n.mode=ai;break;case _b:for(;d<14;){if(o===0)break e;o--,c+=r[l++]<>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=jt;break}n.have=0,n.mode=wb;case wb:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},k=sl(gW,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,k){e.msg="invalid code lengths set",n.mode=jt;break}n.have=0,n.mode=Sb;case Sb:for(;n.have>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=v,d-=v,n.lens[n.have++]=b;else{if(b===16){for(z=v+2;d>>=v,d-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=jt;break}T=n.lens[n.have-1],s=3+(c&3),c>>>=2,d-=2}else if(b===17){for(z=v+3;d>>=v,d-=v,T=0,s=3+(c&7),c>>>=3,d-=3}else{for(z=v+7;d>>=v,d-=v,T=0,s=11+(c&127),c>>>=7,d-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=jt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===jt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=jt;break}if(n.lenbits=9,P={bits:n.lenbits},k=sl(yC,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,k){e.msg="invalid literal/lengths set",n.mode=jt;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},k=sl(bC,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,k){e.msg="invalid distances set",n.mode=jt;break}if(n.mode=Yu,t===Gu)break e;case Yu:n.mode=Ku;case Ku:if(o>=6&&a>=258){e.next_out=m,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=c,n.bits=d,cW(e,f),m=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,c=n.hold,d=n.bits,n.mode===ai&&(n.back=-1);break}for(n.back=0;p=n.lencode[c&(1<>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>w)],v=p>>>24,y=p>>>16&255,b=p&65535,!(w+v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=w,d-=w,n.back+=w}if(c>>>=v,d-=v,n.back+=v,n.length=b,y===0){n.mode=Eb;break}if(y&32){n.back=-1,n.mode=ai;break}if(y&64){e.msg="invalid literal/length code",n.mode=jt;break}n.extra=y&15,n.mode=Cb;case Cb:if(n.extra){for(z=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=xb;case xb:for(;p=n.distcode[c&(1<>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>w)],v=p>>>24,y=p>>>16&255,b=p&65535,!(w+v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=w,d-=w,n.back+=w}if(c>>>=v,d-=v,n.back+=v,y&64){e.msg="invalid distance code",n.mode=jt;break}n.offset=b,n.extra=y&15,n.mode=Tb;case Tb:if(n.extra){for(z=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=jt;break}n.mode=kb;case kb: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=jt;break}s>n.wnext?(s-=n.wnext,h=n.wsize-s):h=n.wnext-s,s>n.length&&(s=n.length),g=n.window}else g=i,h=m-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[m++]=g[h++];while(--s);n.length===0&&(n.mode=Ku);break;case Eb:if(a===0)break e;i[m++]=n.length,a--,n.mode=Ku;break;case Wd:if(n.wrap){for(;d<32;){if(o===0)break e;o--,c|=r[l++]<{if(fo(e))return vr;let t=e.state;return t.window&&(t.window=null),e.state=null,to},PW=(e,t)=>{if(fo(e))return vr;const n=e.state;return(n.wrap&2)===0?vr:(n.head=t,t.done=!1,to)},IW=(e,t)=>{const n=t.length;let r,i,l;return fo(e)||(r=e.state,r.wrap!==0&&r.mode!==af)?vr:r.mode===af&&(i=1,i=Hl(i,t,n,0),i!==r.check)?_C:(l=OC(e,t,n,n),l?(r.mode=SC,wC):(r.havedict=1,to))};var MW=TC,LW=kC,RW=xC,DW=kW,FW=EC,BW=OW,$W=AW,NW=PW,zW=IW,jW="pako inflate (from Nodeca project)",fi={inflateReset:MW,inflateReset2:LW,inflateResetKeep:RW,inflateInit:DW,inflateInit2:FW,inflate:BW,inflateEnd:$W,inflateGetHeader:NW,inflateSetDictionary:zW,inflateInfo:jW};function VW(){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 UW=VW;const AC=Object.prototype.toString,{Z_NO_FLUSH:HW,Z_FINISH:WW,Z_OK:Yl,Z_STREAM_END:Kd,Z_NEED_DICT:Xd,Z_STREAM_ERROR:GW,Z_DATA_ERROR:Mb,Z_MEM_ERROR:YW}=bs;function gu(e){this.options=Bf.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 gC,this.strm.avail_out=0;let n=fi.inflateInit2(this.strm,t.windowBits);if(n!==Yl)throw new Error(Qa[n]);if(this.header=new UW,fi.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Gl.string2buf(t.dictionary):AC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=fi.inflateSetDictionary(this.strm,t.dictionary),n!==Yl)))throw new Error(Qa[n])}gu.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,m,o;if(this.ended)return!1;for(t===~~t?m=t:m=t===!0?WW:HW,AC.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=fi.inflate(n,m),l===Xd&&i&&(l=fi.inflateSetDictionary(n,i),l===Yl?l=fi.inflate(n,m):l===Mb&&(l=Xd));n.avail_in>0&&l===Kd&&n.state.wrap>0&&e[n.next_in]!==0;)fi.inflateReset(n),l=fi.inflate(n,m);switch(l){case GW:case Mb:case Xd:case YW:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Kd))if(this.options.to==="string"){let a=Gl.utf8border(n.output,n.next_out),c=n.next_out-a,d=Gl.buf2string(n.output,a);n.next_out=c,n.avail_out=r-c,c&&n.output.set(n.output.subarray(a,a+c),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===Yl&&o===0)){if(l===Kd)return l=fi.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};gu.prototype.onData=function(e){this.chunks.push(e)};gu.prototype.onEnd=function(e){e===Yl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Bf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function cg(e,t){const n=new gu(t);if(n.push(e),n.err)throw n.msg||Qa[n.err];return n.result}function KW(e,t){return t=t||{},t.raw=!0,cg(e,t)}var XW=gu,qW=cg,ZW=KW,JW=cg,QW=bs,eG={Inflate:XW,inflate:qW,inflateRaw:ZW,ungzip:JW,constants:QW};const{Deflate:UY,deflate:HY,deflateRaw:tG,gzip:WY}=lW,{Inflate:GY,inflate:YY,inflateRaw:nG,ungzip:KY}=eG;var rG=tG,iG=nG;function Lb(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 aG=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Lb(t);if(console.log("URL params:",n),n.get("share")){const l=iG(new Uint8Array(atob(n.get("share")).split("").map(m=>m.charCodeAt(0))),{to:"string"});if(!l){Yt().raiseError("Error when trying to decode share parameter!",!1);return}n=Lb(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),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};nn().generateText2Img(r,!1)},oG=10,sG=!1;function bp(e,t,n,r,i=l=>Yt().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(m=>`${m[0]} - ${m[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}function Ta(e,t){const n=e.trim().replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return n.length===0?r:`${n}${r}`}const lG=ls("interrogate",()=>{const e=ie({}),t=ie(!1);async function n(m){Yt().raiseError(m,!1),t.value=!1,e.value={}}async function r(){const m=Rt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(Ta(m.baseURL,"/sdapi/v1/interrogate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),c=await a.json();!bp(a,c,200,"Failed to get interrogation",n)||(e.value.id=c.id,e.value.status=c.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}}),uG={key:0,style:{"margin-top":"16px"}},cG={key:1,style:{"margin-top":"16px"}},fG={key:2},dG={style:{"margin-top":"8px"}},hG={key:0},pG={key:0},mG={key:1},gG=be({__name:"InterrogationView",setup(e){const t=lG(),n=nn(),r=Yt(),i=ie();async function l(c){if(i.value.clearFiles(),!c.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const d=await Nl(c.raw);t.currentInterrogation.source_image=d,t.interrogateImage()}function m(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=jS();return(c,d)=>_(t).currentInterrogation.source_image?_(t).currentInterrogation.status?(N(),se("div",fG,[ne("div",dG,[oe(_(Ze),{icon:_(mh),onClick:_(t).resetInterrogation},{default:ue(()=>[...d[1]||(d[1]=[Ne("New Interrogation",-1)])]),_:1},8,["icon","onClick"]),o.value?(N(),ve(_(Ze),{key:0,icon:_(mh),onClick:m,disabled:!o.value},{default:ue(()=>[...d[2]||(d[2]=[Ne("Text2Img (Caption)",-1)])]),_:1},8,["icon","disabled"])):ge("",!0)]),d[4]||(d[4]=ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),oe(_(zo),{src:_(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),o.value?(N(),se("div",hG,[d[3]||(d[3]=ne("h3",null,"Caption",-1)),o.value?(N(),se("div",mG,[ne("strong",null,Ee(o.value),1)])):(N(),se("div",pG,"Processing"+Ee(_(a)),1))])):ge("",!0)])):(N(),se("div",cG,[ne("strong",null,"Uploading image"+Ee(_(a)),1)])):(N(),se("div",uG,[ne("div",null,[oe(_(Lm),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),d[0]||(d[0]=ne("div",null,[Ne("Drop file here OR "),ne("em",null,"click to upload")],-1))]),_:1},512)])]))}}),vG=on(gG,[["__scopeId","data-v-db184ac6"]]);function yG(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),m=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",c=l>0?l+(t?"m":"minutes"):"",d=m>0?m+(t?"s":"seconds"):"",u=[];return n!=null&&n.days&&u.push(o),n!=null&&n.hours&&u.push(a),n!=null&&n.minutes&&u.push(c),n!=null&&n.seconds&&u.push(d),u.join(" ")}function _p(e){const t=[];let n=0;for(let r=0;rn&&t.push({type:"literal",text:e.slice(n,r),start:n,end:r});const i=e.indexOf("}",r+1);if(i===-1){t.push({type:"literal",text:e.slice(r),start:r,end:e.length}),n=e.length;break}t.push({type:"expansion",options:e.slice(r+1,i).split("|"),start:r,end:i+1}),n=i+1,r=i}return n{const r=n.type==="literal"?[n.text]:n.options;return t.flatMap(i=>r.map(l=>[...i,l]))},[[]]).map(t=>t.join(""))}function Rb(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,m)=>{if(m.trim()==="")return"";const o=Number(m);if(isNaN(o))return"";let a=l,c=!1;const d="|high_noise|";return a.startsWith(d)&&(a=a.substring(d.length),c=!0),t.push({name:a,multiplier:o,...c?{is_high_noise:!0}:{}}),""}),t]}function Db(e,t){const n=e.indexOf(" ### "),r=n===-1?e:e.slice(0,n),i=n===-1?"":e.slice(n),l=/]+):([^>]+)>/g,m="|high_noise|",o=[];for(const c of t)if(c.type==="literal"){if(c.start>=r.length)break;for(const d of c.text.matchAll(l)){const u=d.index;if(u===void 0)continue;const f=c.start+u;if(f>=r.length||d[2].trim()==="")continue;const s=Number(d[2]);if(isNaN(s))continue;const h=d[1];h.startsWith(m)||h.trim()!==""&&o.push({name:h,multiplier:s,start:f,end:Math.min(f+d[0].length,r.length)})}}if(o.length===0)return[e,[]];let a=r;for(let c=o.length-1;c>=0;c--)a=a.slice(0,o[c].start)+a.slice(o[c].end);return[a.replace(/ +/g," ").trim()+i,o.map(c=>({name:c.name,multiplier:c.multiplier}))]}function _G(e,t){const n=e.map(i=>({...i}));let r=n.length;for(;r>0&&n[r-1].lora===""&&n[r-1].multiplier===0;)r--;return t.forEach((i,l)=>{const m=r+l;m{const J=r.cacheVersion,V=(await r.getAvailableSamplers()).map(M=>M.name);return V.length===0?[]:C(V)},[]),o=f0(async()=>{const J=r.cacheVersion,V=(await r.getAvailableSchedulers()).map(M=>M.name);return V.length===0?[]:T(V)},[]),a=ie(""),c=ie([]),d=ie(!1),u=ie(!1);function f(){d.value||u.value||(u.value=!0,r.fetchLoras().then(J=>{J!==null&&(c.value=J,d.value=!0)}).finally(()=>{u.value=!1}))}function s(){c.value=[],d.value=!1}const h=ee(()=>r.loraList.filter(J=>{const E=Number(J.multiplier);return J.lora&&J.lora.trim()!==""&&!isNaN(E)&&E!==0}).length);Te(()=>a.value!==""||h.value>0,J=>{J&&f()},{immediate:!0}),Te(()=>r.cacheVersion,()=>{s(),(a.value!==""||h.value>0)&&f()});const g=ee(()=>{const J=h.value,E=c.value.length;return J===0?d.value?`${E} available`:"":d.value?`${J} enabled, ${E} available`:`${J} enabled`}),p=J=>!!J.lora&&J.lora.trim()!=="",v=ee(()=>r.loraList.filter(p).length);function y(){const J=r.loraList.filter(p);if(J.length===0)return;const E=J.map(V=>{const M=c.value.find(D=>D.path===V.lora||D.name===V.lora),R=Number(V.multiplier),W=isNaN(R)?0:Math.round(R*1e4)/1e4;return``});r.loraList=r.loraList.filter(V=>!p(V)),r.prompt=r.prompt===""?E.join(" "):`${r.prompt} ${E.join(" ")}`}const b=ee(()=>Db(r.prompt,_p(r.prompt))[1].length);function w(){const[J,E]=Db(r.prompt,_p(r.prompt));if(E.length===0)return;const V=E.map(M=>{const R=c.value.find(W=>W.path===M.name||W.name===M.name);return{lora:R?R.path:M.name,multiplier:M.multiplier}});r.loraList=_G(r.loraList,V),r.prompt=J}const S=Tt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function C(J){return!r.params||!r.params.sampler_name||J.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=J[0]),J}function T(J){return!r.params||!r.params.scheduler||J.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=J[0]),J}function k(J){return"Elapsed: "+yG(J,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function A(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function P(J){r.generatorType=J,A(),console.log(J)}function z(){l.showCropPreview=!0,l.updateCropPreview()}function I(){var J;(J=document.getElementById("extra_image_input"))==null||J.click()}function $(){var J;(J=document.getElementById("video_start_frame_input"))==null||J.click()}function O(){var J;(J=document.getElementById("video_end_frame_input"))==null||J.click()}function Y(J){var E;return(E=J.dataUrl)==null?void 0:E.startsWith("data:image")}function ae(){return r.referenceImages.filter(Y).map(J=>J.dataUrl)}function q(J){return r.referenceImages.slice(0,J).filter(Y).length}return A(),aG(),(J,E)=>(N(),se($e,null,[oe(_(R2),{"default-active":_(r).generatorType,collapse:!0,onSelect:P,mode:_(n)?"horizontal":"vertical",class:ce(_(n)?"mobile-generator-types":"generator-types"),style:ze(_(n)?"overflow-x: auto":"")},{default:ue(()=>[oe(Uu,{index:"Text2Img","icon-one":_(JE),"icon-two":_(xu),isMobile:_(n)},null,8,["icon-one","icon-two","isMobile"]),oe(Uu,{index:"Img2Img","icon-one":_(xu),"icon-two":_(xu),isMobile:_(n)},null,8,["icon-one","icon-two","isMobile"]),oe(Uu,{index:"Inpainting","icon-one":zS,"icon-two":_(xu),isMobile:_(n)},null,8,["icon-two","isMobile"]),oe(Uu,{index:"Interrogation","icon-one":v7,isMobile:_(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",wG,[_(r).generatorType==="Interrogation"?(N(),se("div",SG,[E[39]||(E[39]=ne("h1",{style:{margin:"0"}},"Interrogation",-1)),E[40]||(E[40]=ne("div",null,"Interrogate images to get their predicted descriptions.",-1)),oe(vG)])):(N(),ve(_(Em),{key:1,"label-position":"left","label-width":"140px",model:_(r),class:"container",rules:S,onSubmit:E[38]||(E[38]=Qe(()=>{},["prevent"]))},{default:ue(()=>{var V,M,R,W;return[ne("div",CG,[oe(B7),oe(up,{label:"Negative Prompt",prop:"negativePrompt",modelValue:_(r).negativePrompt,"onUpdate:modelValue":E[0]||(E[0]=D=>_(r).negativePrompt=D),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"]),oe(up,{label:"Seed",prop:"seed",modelValue:_(r).params.seed,"onUpdate:modelValue":E[2]||(E[2]=D=>_(r).params.seed=D),placeholder:"Enter seed here",clearable:"","clear-icon":_(XE)},{append:ue(()=>[oe(_(fn),{content:"Randomize!",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(bO),onClick:E[1]||(E[1]=()=>_(r).params.seed=_(PC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(N(),ve(_(vy),{key:0,gutter:10},{default:ue(()=>[_(r).multiSelect.sampler.state==="Multiple"?(N(),ve(_(_o),{key:0,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Sampler(s)",prop:"samplers",modelValue:_(r).multiSelect.sampler.selected,"onUpdate:modelValue":E[3]||(E[3]=D=>_(r).multiSelect.sampler.selected=D),options:_(m),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.sampler.state==="Enabled"?(N(),ve(_(_o),{key:1,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Sampler",prop:"sampler",modelValue:_(r).params.sampler_name,"onUpdate:modelValue":E[4]||(E[4]=D=>_(r).params.sampler_name=D),options:_(m),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.scheduler.state==="Multiple"?(N(),ve(_(_o),{key:2,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Scheduler(s)",prop:"schedulers",modelValue:_(r).multiSelect.scheduler.selected,"onUpdate:modelValue":E[5]||(E[5]=D=>_(r).multiSelect.scheduler.selected=D),options:_(o),info:"Multi-select enabled. Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.scheduler.state==="Enabled"?(N(),ve(_(_o),{key:3,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Scheduler",prop:"scheduler",modelValue:_(r).params.scheduler,"onUpdate:modelValue":E[6]||(E[6]=D=>_(r).params.scheduler=D),options:_(o),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0)]),_:1})),oe(bn,{label:"Batch Size",prop:"batchSize",modelValue:_(r).params.n,"onUpdate:modelValue":E[7]||(E[7]=D=>_(r).params.n=D),min:_(r).minImages,max:_(r).maxImages},null,8,["modelValue","min","max"]),_(r).multiSelect.steps.state==="Multiple"?(N(),ve(bn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:_(r).multiSelect.steps.selected,"onUpdate:modelValue":E[8]||(E[8]=D=>_(r).multiSelect.steps.selected=D),min:_(r).minSteps,max:_(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"])):_(r).multiSelect.steps.state==="Enabled"?(N(),ve(bn,{key:2,label:"Steps",prop:"steps",modelValue:_(r).params.steps,"onUpdate:modelValue":E[9]||(E[9]=D=>_(r).params.steps=D),min:_(r).minSteps,max:_(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"])):ge("",!0),oe(bn,{label:"Width",prop:"width",modelValue:_(r).params.width,"onUpdate:modelValue":E[10]||(E[10]=D=>_(r).params.width=D),min:_(r).minDimensions,max:_(r).maxDimensions,step:64,change:z},null,8,["modelValue","min","max"]),oe(bn,{label:"Height",prop:"height",modelValue:_(r).params.height,"onUpdate:modelValue":E[11]||(E[11]=D=>_(r).params.height=D),min:_(r).minDimensions,max:_(r).maxDimensions,step:64,change:z},null,8,["modelValue","min","max"]),_(r).multiSelect.guidance.state==="Multiple"?(N(),ve(bn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:_(r).multiSelect.guidance.selected,"onUpdate:modelValue":E[12]||(E[12]=D=>_(r).multiSelect.guidance.selected=D),min:_(r).minCfgScale,max:_(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"])):_(r).multiSelect.guidance.state==="Enabled"?(N(),ve(bn,{key:4,label:"Guidance (CFG)",prop:"cfgScale",modelValue:_(r).params.cfg_scale,"onUpdate:modelValue":E[13]||(E[13]=D=>_(r).params.cfg_scale=D),min:_(r).minCfgScale,max:_(r).maxCfgScale,step:.5,info:"Classifier Free Guidance (CFG Scale). Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.eta.state==="Enabled"?(N(),ve(bn,{key:5,label:"Eta",prop:"eta",modelValue:_(r).params.eta,"onUpdate:modelValue":E[14]||(E[14]=D=>_(r).params.eta=D),min:_(r).minEta,max:_(r).maxEta,step:.1,info:"Noise multiplier for ancestral samplers. 0 disables noise injection."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.flowShift.state==="Enabled"?(N(),ve(bn,{key:6,label:"Flow Shift",prop:"flowShift",modelValue:_(r).params.flow_shift,"onUpdate:modelValue":E[15]||(E[15]=D=>_(r).params.flow_shift=D),min:_(r).minFlowShift,max:_(r).maxFlowShift,step:.5,info:"Override shift value for flow models."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.clipSkip.state==="Multiple"?(N(),ve(bn,{key:7,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:_(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":E[16]||(E[16]=D=>_(r).multiSelect.clipSkip.selected=D),min:_(r).minClipSkip,max:_(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"])):_(r).multiSelect.clipSkip.state==="Enabled"?(N(),ve(bn,{key:8,label:"CLIP Skip",prop:"clipSkip",modelValue:_(r).params.clip_skip,"onUpdate:modelValue":E[17]||(E[17]=D=>_(r).params.clip_skip=D),min:_(r).minClipSkip,max:_(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])):ge("",!0),_(r).sourceGeneratorTypes.includes(_(r).generatorType)?(N(),ve(bn,{key:9,label:"Init Strength",prop:"denoise",modelValue:_(r).params.denoising_strength,"onUpdate:modelValue":E[18]||(E[18]=D=>_(r).params.denoising_strength=D),min:_(r).minDenoise,max:_(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values. 0=unchanged, 1=fullychanged"},null,8,["modelValue","min","max"])):ge("",!0),oe(bn,{label:"Video Frames",prop:"frames",modelValue:_(r).params.frames,"onUpdate:modelValue":E[19]||(E[19]=D=>_(r).params.frames=D),min:_(r).minFrames,max:_(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). More frames increases memory usage."},null,8,["modelValue","min","max"]),_(r).params.frames>1?(N(),ve(bn,{key:10,label:"FPS",prop:"fps",modelValue:_(r).params.fps,"onUpdate:modelValue":E[20]||(E[20]=D=>_(r).params.fps=D),min:_(r).minFps,max:_(r).maxFps,disabled:_(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ge("",!0),_(r).generatorType==="Text2Img"?(N(),se("div",{key:11,class:"reference-images",onDragover:E[23]||(E[23]=Qe(()=>{},["prevent"])),onDrop:E[24]||(E[24]=Qe(D=>_(r).setExtraImage(D),["prevent"]))},[ne("div",xG,[E[43]||(E[43]=ne("span",{class:"reference-images-label"},"Reference Images",-1)),ne("div",TG,[ne("input",{class:"reference-images-input",type:"file",id:"extra_image_input",onChange:E[21]||(E[21]=D=>_(r).setExtraImage(D)),accept:"image/*",multiple:""},null,32),oe(_(Ze),{onClick:I},{default:ue(()=>[...E[41]||(E[41]=[Ne(" Select or Drag Files ",-1)])]),_:1}),oe(_(Ze),{onClick:E[22]||(E[22]=D=>_(r).clearExtraImage()),disabled:_(r).referenceImages.length===0},{default:ue(()=>[...E[42]||(E[42]=[Ne(" Clear Images ",-1)])]),_:1},8,["disabled"])])]),_(r).referenceImages.length>0?(N(),se("div",kG,[(N(!0),se($e,null,$t(_(r).referenceImages,(D,B)=>(N(),se("div",{class:ce(["reference-image-item",{"reference-file-item":!Y(D)}]),key:D.id},[ne("span",EG,Ee(B+1),1),Y(D)?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:D.dataUrl,fit:"cover","preview-src-list":ae(),"initial-index":q(B),"preview-teleported":""},null,8,["src","preview-src-list","initial-index"])):ge("",!0),ne("span",{class:"reference-image-name",title:D.name},Ee(D.name),9,OG),ne("div",AG,[oe(_(fn),{content:"Move up",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",icon:_(ph),disabled:B===0,onClick:Z=>_(r).moveExtraImage(B,-1)},null,8,["icon","disabled","onClick"])]),_:2},1024),oe(_(fn),{content:"Move down",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",icon:_(Yo),disabled:B===_(r).referenceImages.length-1,onClick:Z=>_(r).moveExtraImage(B,1)},null,8,["icon","disabled","onClick"])]),_:2},1024),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",onClick:Z=>_(r).removeExtraImage(B)},null,8,["icon","onClick"])]),_:2},1024)])],2))),128))])):(N(),se("div",PG," No reference images selected. "))],32)):ge("",!0),_(r).generatorType==="Text2Img"&&_(r).params.frames>1?(N(),se("div",IG,[ne("div",MG,[ne("input",{class:"reference-images-input",type:"file",id:"video_start_frame_input",onChange:E[25]||(E[25]=D=>_(r).setVideoStartFrame(D)),accept:"image/*"},null,32),E[45]||(E[45]=ne("span",{class:"video-frame-label"},"Video Start Frame",-1)),_(r).videoStartFrame?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:_(r).videoStartFrame.dataUrl,fit:"cover","preview-teleported":""},null,8,["src"])):(N(),se("div",LG)),ne("span",{class:"video-frame-name",title:((V=_(r).videoStartFrame)==null?void 0:V.name)||"No image selected"},Ee(((M=_(r).videoStartFrame)==null?void 0:M.name)||"No image selected"),9,RG),ne("div",DG,[oe(_(Ze),{onClick:$},{default:ue(()=>[...E[44]||(E[44]=[Ne(" Select Image ",-1)])]),_:1}),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",disabled:!_(r).videoStartFrame,onClick:E[26]||(E[26]=D=>_(r).clearVideoStartFrame())},null,8,["icon","disabled"])]),_:1})])]),ne("div",FG,[ne("input",{class:"reference-images-input",type:"file",id:"video_end_frame_input",onChange:E[27]||(E[27]=D=>_(r).setVideoEndFrame(D)),accept:"image/*"},null,32),E[47]||(E[47]=ne("span",{class:"video-frame-label"},"Video End Frame",-1)),_(r).videoEndFrame?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:_(r).videoEndFrame.dataUrl,fit:"cover","preview-teleported":""},null,8,["src"])):(N(),se("div",BG)),ne("span",{class:"video-frame-name",title:((R=_(r).videoEndFrame)==null?void 0:R.name)||"No image selected"},Ee(((W=_(r).videoEndFrame)==null?void 0:W.name)||"No image selected"),9,$G),ne("div",NG,[oe(_(Ze),{onClick:O},{default:ue(()=>[...E[46]||(E[46]=[Ne(" Select Image ",-1)])]),_:1}),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",disabled:!_(r).videoEndFrame,onClick:E[28]||(E[28]=D=>_(r).clearVideoEndFrame())},null,8,["icon","disabled"])]),_:1})])])])):ge("",!0),oe(_(vy),null,{default:ue(()=>[oe(_(_o),{span:_(n)?24:12},{default:ue(()=>[oe(Hy,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:_(r).params.enable_hr,"onUpdate:modelValue":E[29]||(E[29]=D=>_(r).params.enable_hr=D),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),oe(_(_o),{span:_(n)?24:12},{default:ue(()=>[_(r).generatorType==="Img2Img"?(N(),ve(Hy,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:_(r).params.send_as_refimg,"onUpdate:modelValue":E[30]||(E[30]=D=>_(r).params.send_as_refimg=D),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ge("",!0)]),_:1},8,["span"])]),_:1}),oe(_(oD),{modelValue:a.value,"onUpdate:modelValue":E[32]||(E[32]=D=>a.value=D),class:"lora-list-collapse"},{default:ue(()=>[oe(_(sD),{name:"lora-list"},{title:ue(()=>[E[48]||(E[48]=ne("span",{class:"lora-list-title"},"LoRAs",-1)),ne("span",zG,Ee(g.value),1)]),default:ue(()=>[d.value&&c.value.length===0?(N(),se("div",jG," No LoRAs were returned by the server. ")):ge("",!0),(N(!0),se($e,null,$t(_(r).loraList,(D,B)=>(N(),se("div",{key:B,class:"lora-list-row"},[oe(_(Im),{modelValue:D.lora,"onUpdate:modelValue":Z=>D.lora=Z,class:"lora-list-select",filterable:"",placeholder:"Select a LoRA"},{default:ue(()=>[oe(_(Hc),{value:""}),(N(!0),se($e,null,$t(c.value,Z=>(N(),ve(_(Hc),{key:Z.path,label:Z.name,value:Z.path},null,8,["label","value"]))),128))]),_:1},8,["modelValue","onUpdate:modelValue"]),oe(_(Uc),{modelValue:D.multiplier,"onUpdate:modelValue":Z=>D.multiplier=Z,step:.05,precision:2,"controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"]),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(Yi),plain:"",onClick:Z=>_(r).removeLoraRow(B)},null,8,["icon","onClick"])]),_:2},1024)]))),128)),ne("div",VG,[oe(_(Ze),{icon:_(bf),onClick:E[31]||(E[31]=D=>_(r).addLoraRow()),disabled:c.value.length===0},{default:ue(()=>[...E[49]||(E[49]=[Ne(" Add LoRA ",-1)])]),_:1},8,["icon","disabled"]),oe(_(Ze),{icon:_(ph),onClick:y,disabled:v.value===0},{default:ue(()=>[...E[50]||(E[50]=[Ne(" To Prompt ",-1)])]),_:1},8,["icon","disabled"]),oe(_(Ze),{icon:_(Yo),onClick:w,disabled:b.value===0},{default:ue(()=>[...E[51]||(E[51]=[Ne(" From Prompt ",-1)])]),_:1},8,["icon","disabled"])])]),_:1})]),_:1},8,["modelValue"])]),ne("div",UG,[oe(_(Ze),{onClick:E[33]||(E[33]=()=>{_(r).cancelled=!0,_(r).generating=!1,_(r).resetStore()}),class:"reset-btn"},{default:ue(()=>[...E[52]||(E[52]=[Ne("Reset",-1)])]),_:1}),oe(_(Ze),{type:"primary",class:"generate-cancel-btn",style:ze(_(r).generating?"width: 55%;":""),onClick:E[34]||(E[34]=()=>_(r).generateImage(_(r).generatorType))},{default:ue(()=>[ne("span",null," Generate "+Ee(_(r).totalImageCount)+" image"+Ee(_(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),_(r).generating?(N(),ve(_(Ze),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:_(r).cancelled,onClick:E[35]||(E[35]=()=>{var D;(D=_(r).abortController)==null||D.abort(),_(r).cancelled=!0,_(r).generating=!1,_(r).clearQueue(),_(r).clearLastImageGenkey(),_(r).stopProgressPolling()})},{default:ue(()=>[...E[53]||(E[53]=[Ne("Cancel all",-1)])]),_:1},8,["disabled"])):ge("",!0)]),ne("div",HG,[oe(_(lR),{class:"center-both generated-image"},{default:ue(()=>{var D,B,Z,H,Q;return[!_(r).generating&&_(r).outputs.length==0?(N(),se("div",WG,[/Inpainting/.test(_(r).generatorType)?(N(),ve(Gy,{key:0})):ge("",!0),/Img2Img/.test(_(r).generatorType)?(N(),ve(Gy,{key:1})):ge("",!0)])):ge("",!0),!_(i).showGeneratedImages&&_(r).generating?(N(),ve(A7,{key:1,generated:_(r).outputs.length,total:_(r).queue.length,elapsed:k(_(r).timer.seconds),"progress-percentage":(D=_(r).progressInfo)==null?void 0:D.percentage,"text-info":(B=_(r).progressInfo)==null?void 0:B.textInfo,"current-step":(Z=_(r).progressInfo)==null?void 0:Z.currentStep,"total-steps":(H=_(r).progressInfo)==null?void 0:H.totalSteps,"preview-image":(Q=_(r).progressInfo)==null?void 0:Q.previewImage,generating:_(r).generating,onShowGenerated:E[36]||(E[36]=te=>_(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed","progress-percentage","text-info","current-step","total-steps","preview-image","generating"])):ge("",!0),_(i).showGeneratedImages&&_(r).outputs.length!==0?(N(),ve(W7,{key:2})):ge("",!0)]}),_:1}),_(r).lastImageRecoveryAvailable?(N(),ve(_(o$),{key:0,class:"last-image-recovery",href:_(r).lastImageRecoveryUrl,target:"_blank",type:"primary",onClick:E[37]||(E[37]=Qe(D=>_(r).openLastImageRecovery(),["prevent"]))},{default:ue(()=>[...E[54]||(E[54]=[Ne(" Recover last generated image ",-1)])]),_:1},8,["href"])):ge("",!0)])]}),_:1},8,["model","rules"]))])],64))}}),ll=DE({history:fE("/"),routes:[{path:"/",name:"generate",component:GG},{path:"/images",name:"images",component:()=>Ld(()=>Promise.resolve().then(()=>EY),void 0)},{path:"/about",name:"about",component:()=>Ld(()=>Promise.resolve().then(()=>DY),void 0)},{path:"/options",name:"options",component:()=>Ld(()=>Promise.resolve().then(()=>$Y),void 0)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function Xu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,flow_shift:0,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function PC(){return Math.floor(Math.random()*9999999)+1}function YG(){return Math.floor(Math.random()*9e5+1e5).toString()}const nn=ls("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ie("Text2Img"),r=ie(""),i=un("promptHistory",[]),l=ie(""),m=un("negativeLibrary",[]),o=ie(Xu()),a=ie({interval:0,seconds:0}),c=ie(null),d=ie(0),u=ie({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:we=>we.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:we=>we.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:we=>we.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:we=>we.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:we=>we.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:we=>we.eta},flowShift:{name:"Flow Shift",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.flow_shift],mapToParam:we=>we.flow_shift}}),f=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),s=ie({...f(),sourceProcessing:"inpainting"}),h=ie({...f(),sourceProcessing:"img2img"}),g=we=>we==="Inpainting"?s.value:we==="Img2Img"?h.value:f(),p=ee(()=>g(n.value)),v=ie(""),y=ie(!1),b=ie(!1),w=ie([]),S=ie(null),C=ie([]),T=un("lastImageGenkey",""),k=ee(()=>T.value?Ta(Rt().baseURL,`/sdapi/v1/get_last.png?genkey=${encodeURIComponent(T.value)}`):""),A=ee(()=>k.value!==""&&!y.value);function P(){T.value=""}function z(){!k.value||(window.open(k.value,"_blank","noopener"),P())}const I=ie(64),$=ee(()=>Rt().allowLargerParams==="Enabled"?3072:1024),O=ie(1),Y=ie(20),ae=ie(1),q=ee(()=>Rt().allowLargerParams==="Enabled"?150:50),J=ie(1),E=ie(24),V=ie(0),M=ie(1),R=ie(0),W=ie(20),D=ie(0),B=ie(1),Z=ie(0),H=ie(10),Q=ie(1),te=ee(()=>Rt().allowLargerParams==="Enabled"?400:200),fe=ie(16),me=ee(()=>Rt().allowLargerParams==="Enabled"?32:24),_e=(we,je,He)=>Array.from({length:(je-we+1)/He},(et,ot)=>(ot+we)*He),j=ie(_e(Z.value,H.value,1)),x=ie(_e(J.value,E.value,.5)),U=ee(()=>{const we=(Dn,tn,Ii=1)=>Dn*(tn.state==="Multiple"&&tn.selected.length>0?tn.selected.length:Ii),He=o.value.n*Oe().length,et=we(He,u.value.sampler),ot=we(et,u.value.scheduler),Je=we(ot,u.value.steps),It=we(Je,u.value.guidance);return we(It,u.value.clipSkip)});function K(){return o.value=Xu(),s.value=f(),h.value=f(),ho.value=null,po.value=null,w.value=[],kn.value=[],Yt().showGeneratedImages=!1,L(),P(),!0}function L(){C.value=[]}function F(){w.value=[]}async function X(){const we=await Ut("/sdapi/v1/loras");return Array.isArray(we)?we:null}async function de(we){var yg,bg;if(!e.includes(we))return[];if(r.value==="")return G("Failed to generate: No prompt submitted.");const je=il(),He=Yt();je.saveImages();const{sourceImage:et,maskImage:ot,sourceProcessing:Je}=g(we);yn(r.value);const It=[],Dn=Oe().map(We=>{const pt=We.split(" ### ");return{prompt:pt[0],negative_prompt:pt[1]||""}}).map(We=>{const[pt,Xt]=Rb(We.prompt);return{...We,prompt:pt,extractedLoras:Xt}}),tn=Dn.some(We=>We.extractedLoras.length>0)||kn.value.some(We=>We.lora&&We.lora.trim()!=="")?(yg=await X())!=null?yg:[]:[],Ii=kn.value.filter(We=>We.lora&&We.lora.trim()!=="").flatMap(We=>{const pt=tn.find(Bn=>Bn.name===We.lora||Bn.path===We.lora),Xt=Number(We.multiplier);return[{name:pt?pt.name:We.lora,multiplier:isNaN(Xt)?0:Xt,allowUnresolved:!1}]}),Fn=We=>{const pt=new Map;for(const Xt of We){if(!Xt.name||Xt.name.trim()==="")continue;const Bn=`${Xt.name}\0${Xt.is_high_noise?1:0}`,sr=pt.get(Bn);sr?(sr.multiplier=Math.round((sr.multiplier+Xt.multiplier)*1e4)/1e4,sr.allowUnresolved=sr.allowUnresolved||Xt.allowUnresolved):pt.set(Bn,{...Xt})}return[...pt.values()]},ga=Dn.map(({extractedLoras:We,...pt})=>{const Xt=Fn([...We.map(Ht=>({name:Ht.name,multiplier:Ht.multiplier,...Ht.is_high_noise?{is_high_noise:!0}:{},allowUnresolved:!0})),...Ii]),Bn=Xt.flatMap(Ht=>{if(Ht.multiplier===0)return[];const yu=tn.find(wg=>wg.name===Ht.name||wg.path===Ht.name),_g=yu?yu.path:Ht.allowUnresolved?Ht.name:"";return _g?[{path:_g,multiplier:Ht.multiplier,...Ht.is_high_noise?{is_high_noise:!0}:{}}]:[]}),sr=Xt.map(Ht=>``),va=[sr.length>0?pt.prompt.replace(/ +/g," ").trim():pt.prompt,sr.join(" ")].filter(Ht=>Ht!=="").join(" "),go=pt.negative_prompt!==""?`${va} ### ${pt.negative_prompt}`:va;return{...pt,full_prompt:go,...Bn.length>0?{lora:Bn}:{}}}),{seed:vu,cfg_scale:or,eta:hg,steps:ei,clip_skip:WC,flow_shift:pg,sampler_name:GC,scheduler:YC,n:KC,...mg}=o.value,Vf=parseInt(vu.toString()),XC=isNaN(Vf)||Vf<0?PC():Vf,qC=Array.from({length:KC},(We,pt)=>XC+pt),mo=(We,pt)=>We.state==="Disabled"?[]:We.state==="Enabled"?[pt]:We.state==="Multiple"&&We.selected.length===0?[]:We.selected,ZC={promptVariant:ga,seed:qC,cfg_scale:mo(u.value.guidance,or),eta:mo(u.value.eta,hg),steps:mo(u.value.steps,ei),clip_skip:mo(u.value.clipSkip,WC),sampler_name:mo(u.value.sampler,GC),scheduler:mo(u.value.scheduler,YC)},JC=(We=>Object.entries(We).filter(([Xt,Bn])=>Bn.length>0).reduce((Xt,[Bn,sr])=>{const zt=[];for(const va of Xt)for(const go of sr)zt.push({...va,[Bn]:go});return zt},[{}]))(ZC),QC=[await Ce()];for(const We of JC){const{promptVariant:{full_prompt:pt,...Xt},...Bn}=We,sr=we==="Img2Img"?mg.send_as_refimg:!1,zt={prompt:pt,params:{...mg,send_as_refimg:sr,...Bn,...Xt,init_images:et?[et.split(",")[1]]:[],mask:ot,inpainting_mask_invert:ot?0:null,inpainting_fill:ot?1:null},source_image:et==null?void 0:et.split(",")[1],source_mask:ot,source_processing:Je,models:QC};zt.params.sampler_name=="default"&&delete zt.params.sampler_name,zt.params.scheduler=="default"&&delete zt.params.scheduler,!zt.params.frames||zt.params.frames<=1?(delete zt.params.frames,delete zt.params.fps):zt.params.fps=Math.min(me.value,Math.max(fe.value,Math.round(Number(zt.params.fps)||Xu().fps)));const va=we==="Text2Img",go=va?Dr.value.map(yu=>yu.base64):[];go.length>0&&(zt.params.extra_images=go),va&&zt.params.frames&&zt.params.frames>1&&(ho.value&&(zt.params.video_start_frame=ho.value.base64),po.value&&(zt.params.video_end_frame=po.value.base64)),Rt().alsoRequestAvi==="Enabled"&&zt.params.frames&&zt.params.frames>1&&(zt.params.video_output_type=2);const Ht={};u.value.flowShift.state==="Enabled"&&pg>0&&(Ht.params={flow_shift:pg}),Rt().keepImageGenOnDisconnect==="Enabled"&&(Ht.keep_image_gen_on_disconnect=!0),Object.keys(Ht).length>0&&(zt.params.kcpp_extra_args=Ht),It.push(zt)}let gg=!1;y.value||(gg=!0,w.value=[]),y.value=!0,He.showGeneratedImages=!1;let vg=C.value.filter(We=>!We.gathered&&!We.failed).length;for(let We=0;We{a.value.seconds++},1e3),HC();!C.value.every(We=>We.gathered||We.failed)&&!b.value;){const We=C.value.find(pt=>!pt.gathered&&!pt.failed);if(!We)break;We.gathered=!0;try{const pt=await Le(We.params,(bg=S.value)==null?void 0:bg.signal);if(!pt){We.failed=!0;continue}le([{...pt,...We}])}catch(pt){We.failed=!0,console.error("Error fetching image:",pt)}}C.value.some(We=>We.failed)&&C.value.every(We=>We.gathered||We.failed)&&(y.value=!1,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0,jf(),C.value=[])}}async function le(we){const je=Ja();console.log(we);const He=await Promise.all(we.map(async Je=>{var ga,vu;const It=Je.images[0],Dn=!!Je.animated?"gif":"png",tn=Je.extra_data?`data:video/avi;base64,${Je.extra_data}`:"",Ii=Je.final_frame?`data:image/jpeg;base64,${Je.final_frame}`:"",Fn={id:-1,image:`data:image/${Dn};base64,${It}`,prompt:Je.prompt,modelName:Je.models[0],frames:Je.params.frames,fps:Je.params.fps,extra_avi:tn,final_frame:Ii,enable_hr:Je.params.enable_hr,send_as_refimg:Je.params.send_as_refimg,flow_shift:(vu=(ga=Je.params.kcpp_extra_args)==null?void 0:ga.params)==null?void 0:vu.flow_shift,lora_meta:""};if(Je.info&&typeof Je.info=="string"&&Je.info.trim()!=="")try{const or=JSON.parse(Je.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach(ei=>{or[ei]!=null&&or[ei]!=null?Fn[ei]=or[ei]:Je.params[ei]!=null&&(Fn[ei]=Je.params[ei])}),or.extra_generation_params&&or.extra_generation_params["Schedule type"]?Fn.scheduler=or.extra_generation_params["Schedule type"]:Fn.scheduler=Je.params.scheduler,or.lora_meta&&(Fn.lora_meta=or.lora_meta)}catch(or){console.warn("Failed to parse info JSON:",or)}return Fn})),et=await je.pushOutputs(He),ot=0;return w.value=[...et.map(Je=>({type:"image",index:ot,output:Je})),...w.value].sort((Je,It)=>Je.index-It.index),w.value.length===C.value.length&&(C.value=[],y.value=!1,Yt().showGeneratedImages=!0,P(),clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0,jf()),He}async function G(we){const je=Yt();return we&&je.raiseError(we,!1),[]}function pe(we,je,He,et){return je<=He?je:(Yt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${je}.`,!0),et)}async function re(we,je=!0){var et;const He=Xu();if(n.value="Text2Img",u.value.guidance.state="Enabled",u.value.sampler.state="Enabled",u.value.steps.state="Enabled",u.value.clipSkip.state="Disabled",u.value.scheduler.state="Enabled",ll.push("/"),je&&(we.width=we.width||He.width,we.height=we.height||He.height),we.prompt){const ot=we.prompt.split(" ### ");r.value=ot[0],l.value=ot[1]||"";const[,Je]=Rb(r.value);if(Je.length>0){const It=(et=await X())!=null?et:[];kn.value=kn.value.filter(en=>!en.lora||en.lora.trim()===""?!0:!Je.some(Dn=>Dn.name===en.lora||It.some(tn=>tn.name===Dn.name&&tn.path===en.lora)))}}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const Je=(await it()).find(It=>It.aliases&&It.aliases.includes(we.sampler_name));Je&&(o.value.sampler_name=Je.name)}we.steps&&(o.value.steps=pe("steps",we.steps,q.value,He.steps)),we.cfg_scale&&(o.value.cfg_scale=we.cfg_scale),(we.eta||we.eta===0)&&(o.value.eta=we.eta),(we.flow_shift||we.flow_shift===0)&&(o.value.flow_shift=we.flow_shift,u.value.flowShift.state=we.flow_shift>0?"Enabled":"Disabled"),we.width&&(o.value.width=pe("width",we.width,$.value,He.width)),we.height&&(o.value.height=pe("height",we.height,$.value,He.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=pe("clip_skip",we.clip_skip,H.value,He.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=pe("frames",we.frames,te.value,He.frames)),we.fps&&(o.value.fps=Math.min(me.value,Math.max(fe.value,Math.round(pe("fps",we.fps,me.value,He.fps)))))}function he(we){const je=il();n.value="Img2Img",h.value.sourceImage=we,je.drawing=!1,w.value=[],ll.push("/"),cr.fabric.Image.fromURL(we,je.newImage)}function Se(we){const je=il();w.value=[],s.value.sourceImage=we,n.value="Inpainting",ll.push("/"),cr.fabric.Image.fromURL(we,je.newImage)}function xe(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Oe(){const we=xe();return bG(_p(we))}async function Le(we,je){const He=Rt();try{const et=YG();T.value=et;const ot={...we,genkey:et},Je=await fetch(Ta(He.baseURL,`/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ot),signal:je}),It=await Je.json();return bp(Je,It,200,"Failed to fetch",ye)?It:!1}catch{return!1}}function ye(we){return Yt().raiseError(we,!1),b.value=!1,w.value=[],!1}async function Ce(){const we=Rt(),je=await fetch(Ta(we.baseURL,"/sdapi/v1/sd-models")),He=await je.json();if(!!bp(je,He,200,"Failed to get available models"))return He.length===0?"(No model loaded)":He[0].model_name}const Me=ie(0),Ie=new Map;function ht(){Ie.clear(),Me.value++}Te(()=>Rt().baseURL,()=>{ht()});async function Ut(we){const je=Rt(),He=Ta(je.baseURL,we);if(Ie.has(He))return Ie.get(He);const et=(async()=>{try{const ot=await fetch(He);if(ot.ok)return await ot.json();console.error(`API Error: ${ot.status} ${ot.statusText} at ${He}`)}catch(ot){console.error(`Fetch error for ${He}:`,ot)}return Ie.delete(He),null})();return Ie.set(He,et),et}async function it(){const we=await Ut("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function Ft(){const we=await Ut("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Qt(we){m.value.indexOf(we)===-1&&(m.value=[...m.value,we])}function _r(we){m.value=m.value.filter(je=>je!=we)}function yn(we){if(i.value.findIndex(je=>je.prompt===we)===-1){if(i.value.length>=10+i.value.filter(je=>je.starred).length){const je=i.value.filter(et=>!et.starred),He=i.value.findIndex(et=>et===je[je.length-1]);i.value.splice(He,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function ar(we){i.value=i.value.filter(je=>je.prompt!=we&&je!=we)}function ma(){return!1}const kn=ie([]);function MC(){kn.value=[...kn.value,{lora:"",multiplier:0}]}function LC(we){kn.value=kn.value.filter((je,He)=>He!==we)}const Dr=ie([]),ho=ie(null),po=ie(null);async function dg(we){var Je,It;const He=(It=we.target.files)!=null?It:(Je=we.dataTransfer)==null?void 0:Je.files,et=Array.from(He!=null?He:[])[0];if(!et)return null;const ot=await Nl(et);return{id:`${Date.now()}-${et.name}`,name:et.name,size:et.size,dataUrl:ot,base64:ot.includes("data:image")?ot.split(",")[1]:ot}}async function RC(we){ho.value=await dg(we);const je=we.target;je.value!==void 0&&(je.value="")}async function DC(we){po.value=await dg(we);const je=we.target;je.value!==void 0&&(je.value="")}function FC(){ho.value=null;const we=document.getElementById("video_start_frame_input");we&&(we.value="")}function BC(){po.value=null;const we=document.getElementById("video_end_frame_input");we&&(we.value="")}async function $C(we){var Je,It;const je=we.target,He=(It=je.files)!=null?It:(Je=we.dataTransfer)==null?void 0:Je.files,et=Array.from(He!=null?He:[]);if(et.length===0)return;const ot=await Promise.all(et.map(async(en,Dn)=>{const tn=await Nl(en);return{id:`${Date.now()}-${Dn}-${en.name}`,name:en.name,size:en.size,dataUrl:tn,base64:tn.includes("data:image")?tn.split(",")[1]:tn}}));Dr.value||(Dr.value=[]);for(let en=0;en=Dr.value.length)return;const et=[...Dr.value],[ot]=et.splice(we,1);et.splice(He,0,ot),Dr.value=et}function jC(){Dr.value=[];const we=document.getElementById("extra_image_input");we&&(we.value="")}const Nf=ie(""),zf=ie(-1);async function VC(){var je,He,et,ot,Je,It,en,Dn,tn;const we=Rt();try{const Ii=await fetch(Ta(we.baseURL,`/sdapi/v1/progress?skip_current_image=true&genkey=${encodeURIComponent(T.value)}`));if(!Ii.ok)return;const Fn=await Ii.json();c.value={percentage:Math.round(((je=Fn.progress)!=null?je:0)*100),textInfo:Fn.textinfo||null,currentStep:(et=(He=Fn.state)==null?void 0:He.sampling_step)!=null?et:0,totalSteps:(Je=(ot=Fn.state)==null?void 0:ot.sampling_steps)!=null?Je:0,previewImage:(en=(It=c.value)==null?void 0:It.previewImage)!=null?en:null},Nf.value!=T.value&&(Nf.value=T.value,zf.value=-1);const ga=(tn=(Dn=Fn.state)==null?void 0:Dn.sampling_step)!=null?tn:0;zf.value!=ga&&(zf.value=ga,we.fetchGenerationProgress==="Image"&&UC())}catch{}}async function UC(){const we=Rt();try{const je=await fetch(Ta(we.baseURL,`/sdapi/v1/progress?genkey=${encodeURIComponent(T.value)}`));if(!je.ok)return;const He=await je.json();He.current_image&&c.value&&(c.value.previewImage=He.current_image)}catch{}}function HC(){Nf.value="",!d.value&&Rt().fetchGenerationProgress!=="Off"&&(c.value={percentage:0,textInfo:null,currentStep:0,totalSteps:0,previewImage:null},d.value=setInterval(VC,2e3))}function jf(){d.value&&(clearInterval(d.value),d.value=0),c.value=null}return{generatorType:n,prompt:r,params:o,outputs:w,inpainting:s,img2img:h,uploadDimensions:v,cancelled:b,abortController:S,multiSelect:u,referenceImages:Dr,videoStartFrame:ho,videoEndFrame:po,loraList:kn,addLoraRow:MC,removeLoraRow:LC,negativePrompt:l,generating:y,negativePromptLibrary:m,minDimensions:I,maxDimensions:$,minImages:O,maxImages:Y,minSteps:ae,maxSteps:q,minCfgScale:J,maxCfgScale:E,minDenoise:D,maxDenoise:B,minClipSkip:Z,maxClipSkip:H,minFrames:Q,maxFrames:te,minFps:fe,maxFps:me,minEta:V,maxEta:M,minFlowShift:R,maxFlowShift:W,clipSkipList:j,cfgList:x,queue:C,promptHistory:i,timer:a,progressInfo:c,progressInterval:d,lastImageGenkey:T,lastImageRecoveryUrl:k,lastImageRecoveryAvailable:A,clearLastImageGenkey:P,openLastImageRecovery:z,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:p,totalImageCount:U,generateImage:de,generateText2Img:re,generateImg2Img:he,generateInpainting:Se,getPrompt:ma,resetStore:K,clearQueue:L,clearOutputs:F,stopProgressPolling:jf,pushToNegativeLibrary:Qt,removeFromNegativeLibrary:_r,pushToPromptHistory:yn,removeFromPromptHistory:ar,setExtraImage:$C,removeExtraImage:NC,moveExtraImage:zC,clearExtraImage:jC,setVideoStartFrame:RC,setVideoEndFrame:DC,clearVideoStartFrame:FC,clearVideoEndFrame:BC,getAvailableSamplers:it,getAvailableSchedulers:Ft,fetchLoras:X,cacheVersion:Me,invalidateApiCaches:ht,getCachedEndpoint:Ut}}),KG=be({__name:"ImageActions",props:{imageData:{},onDelete:{type:Function},showDismiss:{type:Boolean}},setup(e){const t=nn(),n=Ja(),r=e,i=()=>{H2.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{n.deleteOutput(r.imageData.id),r.onDelete!==void 0&&r.onDelete(r.imageData.id),sa({type:"success",message:"Deleted Image"})})},l=a=>{if(a.extra_avi){const c=a.extra_avi.split(",")[1];if(!c)return;const d=`${a.seed}-${a.prompt}.avi`;KS(c,d);return}else rg(a.image,`${a.seed}-${a.prompt}`)},m=()=>{nn().clearOutputs(),Yt().showGeneratedImages=!1,nn().clearQueue()};async function o(a){const c=window.location.origin,d={prompt:a.prompt,width:a.width?a.width:void 0,height:a.height?a.height:void 0,steps:a.steps,cfg_scale:a.cfg_scale,sampler_name:a.sampler_name,model_name:a.modelName,seed:a.seed,clip_skip:a.clip_skip,frames:a.frames,fps:a.fps,scheduler:a.scheduler,extra_avi:a.extra_avi,final_frame:a.final_frame,enable_hr:a.enable_hr,send_as_refimg:a.send_as_refimg,lora_meta:a.lora_meta},u=window.location.pathname.replace("images","");let f=`${c}${u}?share=`,s="",h="";for(const[p,v]of Object.entries(d)){if(!v)continue;let y=v;typeof v=="string"?y=encodeURIComponent(v):Array.isArray(v)&&(y=JSON.stringify(v)),s+=`${h}${p}=${y}`,h="&"}const g=btoa(String.fromCharCode.apply(null,Array.from(rG(s))));f+=g,await navigator.clipboard.writeText(f),sa({type:"success",message:"Copied shareable link to clipboard"})}return(a,c)=>(N(),se($e,null,[oe(_(Ze),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:_(Yi),plain:""},{default:ue(()=>[...c[8]||(c[8]=[Ne("Delete",-1)])]),_:1},8,["icon"]),oe(_(Ze),{class:"compact-button",onClick:c[0]||(c[0]=d=>l(a.imageData)),type:"success",size:"small",icon:_(yl),plain:""},{default:ue(()=>[...c[9]||(c[9]=[Ne("Download",-1)])]),_:1},8,["icon"]),a.imageData.starred?ge("",!0):(N(),ve(_(Ze),{key:0,class:"compact-button",onClick:c[1]||(c[1]=d=>_(n).toggleStarred(a.imageData.id)),type:"warning",size:"small",icon:_(jO),plain:""},{default:ue(()=>[...c[10]||(c[10]=[Ne("Star",-1)])]),_:1},8,["icon"])),a.imageData.starred?(N(),ve(_(Ze),{key:1,class:"compact-button",onClick:c[2]||(c[2]=d=>_(n).toggleStarred(a.imageData.id)),type:"warning",size:"small",icon:_(F1),plain:""},{default:ue(()=>[...c[11]||(c[11]=[Ne("Unstar",-1)])]),_:1},8,["icon"])):ge("",!0),oe(_(Ze),{class:"compact-button",onClick:c[3]||(c[3]=d=>_(t).generateText2Img(a.imageData)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[12]||(c[12]=[Ne("Txt2img",-1)])]),_:1}),oe(_(Ze),{class:"compact-button",onClick:c[4]||(c[4]=d=>_(t).generateImg2Img(a.imageData.image)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[13]||(c[13]=[Ne("Img2img",-1)])]),_:1}),oe(_(Ze),{class:"compact-button",onClick:c[5]||(c[5]=d=>_(t).generateInpainting(a.imageData.image)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[14]||(c[14]=[Ne("Inpaint",-1)])]),_:1}),a.showDismiss?(N(),ve(_(Ze),{key:2,class:"compact-button",onClick:c[6]||(c[6]=d=>m()),type:"success",size:"small",plain:""},{default:ue(()=>[...c[15]||(c[15]=[Ne("Dismiss",-1)])]),_:1})):ge("",!0),oe(_(Ze),{class:"compact-button",onClick:c[7]||(c[7]=d=>o(a.imageData)),type:"success",icon:_(gO),size:"small",plain:""},{default:ue(()=>[...c[16]||(c[16]=[Ne("Share",-1)])]),_:1},8,["icon"])],64))}}),IC=on(KG,[["__scopeId","data-v-24447e4b"]]),XG={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},qG=["src"],ZG={style:{"font-size":"16px","font-weight":"500"}},JG={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},QG={key:0},eY={key:1},tY={key:0},nY={key:1},rY={key:2},iY=be({__name:"ImageDialog",setup(e){const t=Ja(),n=Yt(),r=ie();i6(r,{onSwipeEnd(d,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=ie(t.currentOutputs[0]);Te(()=>n.activeModal,async()=>{const d=t.currentOutputs.find(u=>u.id===n.activeModal);if(d)return l.value=d;l.value=await Wt.outputs.get(n.activeModal)||t.currentOutputs[0]});function m(){i.value=!1}function o(){var f;if(!((f=l.value)!=null&&f.final_frame))return;const d=l.value.final_frame;nn().generateImg2Img(d)}function a(){var d;!((d=l.value)!=null&&d.image)||rg(l.value.image,`${l.value.seed}-${l.value.prompt}`)}function c(){var f,s;if(!((f=l.value)!=null&&f.extra_avi))return;const d=l.value.extra_avi.split(",")[1];if(!d)return;const u=`output-${(s=l.value.id)!=null?s:"video"}.avi`;KS(d,u)}return(d,u)=>{var f;return N(),ve(_(XD),{"model-value":i.value,width:(f=l.value)==null?void 0:f.width,class:"image-viewer",onClosed:m,"align-center":""},{footer:ue(()=>[oe(IC,{"image-data":l.value,"on-delete":m},null,8,["image-data"])]),default:ue(()=>{var s,h,g,p;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",XG,[(s=l.value)!=null&&s.image?(N(),se("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,qG)):ge("",!0)])],512),ne("div",ZG,Ee(((h=l.value.prompt)==null?void 0:h.split("###")[0])||"Unknown Creation"),1),ne("div",JG,[ne("div",null,"Negative Prompt: "+Ee(((g=l.value.prompt)==null?void 0:g.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ee(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ee(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ee(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ee(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ee(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ee(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ee((p=l.value.clip_skip)!=null?p:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ee(l.value.width||"???")+"x"+Ee(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ee(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(N(),se("span",QG," - FPS: "+Ee(l.value.fps||"Unknown"),1)):ge("",!0),l.value.lora_meta?(N(),se("span",eY," - LoRA: "+Ee(l.value.lora_meta),1)):ge("",!0),u[2]||(u[2]=ne("br",null,null,-1)),ne("b",null,[l.value.frames&&l.value.frames>1?(N(),se("span",tY,[ne("a",{href:"#",onClick:Qe(a,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download GIF]")])):ge("",!0),l.value.extra_avi?(N(),se("span",nY,[u[0]||(u[0]=Ne(" - ",-1)),ne("a",{href:"#",onClick:Qe(c,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]")])):ge("",!0),l.value.final_frame?(N(),se("span",rY,[u[1]||(u[1]=Ne(" - ",-1)),ne("a",{href:"#",onClick:Qe(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Extend Video]")])):ge("",!0)])])]}),_:1},8,["model-value","width"])}}}),aY={class:"generator-icons"},oY=be({__name:"App",setup(e){const n=dm(fm).smallerOrEqual("md"),r=Yt();Rt();const i=BE(),l=ie();return Te(()=>i.path,m=>{l.value&&l.value.open(m)}),(m,o)=>(N(),se($e,null,[ne("div",{class:ce({"menu-container":!_(n)})},[oe(_(R2),{"default-active":_(i).path,mode:"horizontal",router:!0,ellipsis:!_(n),class:ce(_(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:ue(()=>[_(n)?ge("",!0):(N(),ve(_(Am),{key:0,class:"remove-item-styling center-vertical"},{title:ue(()=>[...o[0]||(o[0]=[ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)])]),_:1})),oe(Ps,{isMobile:_(n),index:"/"},{icon:ue(()=>[ne("div",aY,[oe(_(De),null,{default:ue(()=>[oe(_(EO))]),_:1}),_(r).showGeneratorBadge?(N(),ve(_(De),{key:0,class:"generator-badge",size:10},{default:ue(()=>[oe(l7)]),_:1})):ge("",!0)])]),title:ue(()=>[...o[1]||(o[1]=[Ne("Generate",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/images"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(wO))]),_:1})]),title:ue(()=>[...o[2]||(o[2]=[Ne("Images",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/about"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(M1))]),_:1})]),title:ue(()=>[...o[3]||(o[3]=[Ne("About",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/options"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(HO))]),_:1})]),title:ue(()=>[...o[4]||(o[4]=[Ne("Options",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/return"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(O1))]),_:1})]),title:ue(()=>[...o[5]||(o[5]=[Ne("Return to Lite",-1)])]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!_(n)})},[oe(_(E1))],2),oe(iY)],64))}}),sY=on(oY,[["__scopeId","data-v-8f4d2380"]]),fg=Tk(sY);fg.use(Ak());fg.use(ll);fg.mount("#app");ll.replace("/");window.addEventListener("beforeunload",e=>{nn().generating&&(e.preventDefault(),e.returnValue="")});const lY={key:1,class:"image-action"},uY=be({__name:"CustomImage",props:{imageData:{}},setup(e){const t=e,n=Yt(),r=ie(null);D5(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ie(!1);r6(r,([{isIntersecting:m}])=>{m&&(i.value=m)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(m,o)=>(N(),se("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(N(),ve(_(zo),{key:0,class:"thumbnail",src:m.imageData.image,onClick:o[0]||(o[0]=a=>_(n).activeModal=m.imageData.id),fit:"cover",loading:"lazy",style:ze(`${l.value&&"opacity: 0.5"}`)},null,8,["src","style"])):ge("",!0),i.value?(N(),se("div",lY,[m.imageData.starred?(N(),ve(_(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:ue(()=>[oe(_(F1))]),_:1})):ge("",!0),_(n).multiSelect?(N(),se("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>_(n).toggleSelection(m.imageData.id))},[oe(_(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${l.value?"1":"0.5"})`},{default:ue(()=>[l.value?ge("",!0):(N(),ve(_(Ql),{key:0})),l.value?(N(),ve(_(P1),{key:1})):ge("",!0)]),_:1},8,["color"])])):ge("",!0)])):ge("",!0)],512))}}),Fb=on(uY,[["__scopeId","data-v-b9569bbd"]]);function cY({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=ww(),i=ee(()=>r.value<=e),l=ie(!0),{y:m}=n6(window);let o=m.value,a=0;return Te(m,c=>{if(!i.value)return;const d=c-o;if(o=c,d>0&&c>t){a+=d,a>=n&&(l.value=!1,a=0);return}d<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const fY={},dY={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"};function hY(e,t){return N(),se("svg",dY,[...t[0]||(t[0]=[ne("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)])])}const pY=on(fY,[["render",hY]]),mY={class:"options"},gY=["onClick"],vY=["onClick"],yY=["onClick"],bY={key:1,class:"center-both",style:{gap:"12px"}},_Y={key:2},wY={key:0},SY={key:0,style:{display:"flex",gap:"8px"}},CY={key:1,class:"images"},xY={key:1},TY=be({__name:"ImagesView",setup(e){const{width:t}=ww(),{isVisible:n,isMobile:r}=cY(),i=Ja(),l=Rt(),m=Yt();function o(){m.selected=m.selected.filter(h=>!i.currentOutputs.map(g=>g.id).includes(h)),m.selected=[...m.selected,...i.currentOutputs.map(h=>h.id)],m.multiSelect=!0}async function a(){const h=await Wt.outputs.toCollection().primaryKeys();m.selected=h,m.multiSelect=!0}function c(){m.selected=m.selected.filter(h=>!i.currentOutputs.map(g=>g.id).includes(h)),m.selected.length===0&&(m.multiSelect=!1)}function d(){m.selected=[],m.multiSelect=!1}const u=()=>{H2.confirm(`This action will permanently delete ${m.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(m.selected)})};h0(["a","A","ArrowLeft"],m.openModalToLeft),h0(["d","D","ArrowRight"],m.openModalToRight);async function f(){YS(m.selected)}const s=ee(()=>{let h=2;t.value>1440?h=6:t.value>1280?h=5:t.value>768?h=4:t.value>480&&(h=3);const g=[];for(let p=0;p(N(),se($e,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":_(r)&&!_(n)}])},[ne("div",mY,[oe(_(Lu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(_($O))]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t(["Newest","Oldest"],p=>ne("div",{key:p,onClick:()=>_(i).sortBy=p,class:ce(`el-select-dropdown__item ${_(i).sortBy===p?"selected":""}`)},Ee(p),11,gY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(_(uO))]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t(["all","favourited","unfavourited","unrated"],p=>ne("div",{key:p,onClick:()=>_(i).filterBy=p,class:ce(`el-select-dropdown__item ${_(i).filterBy===p?"selected":""}`)},Ee(_(i).filterBy===p?"Showing":"Show")+" "+Ee(p),11,vY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(pY)]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],p=>ne("div",{key:p.value,onClick:()=>_(i).currentLayout=p.value,class:ce(`el-select-dropdown__item ${_(i).currentLayout===p.value?"selected":""}`)},Ee(p.label),11,yY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[_(m).multiSelect?(N(),ve(_(P1),{key:0})):(N(),ve(_(Ql),{key:1}))]),_:1})]),_:1})]),default:ue(()=>[_(m).multiSelect?(N(),se("div",{key:0,class:"el-select-dropdown__item selected",onClick:g[0]||(g[0]=(...p)=>_(m).toggleMultiSelect&&_(m).toggleMultiSelect(...p))},"Disable multi-select")):(N(),se("div",{key:1,class:"el-select-dropdown__item",onClick:g[1]||(g[1]=(...p)=>_(m).toggleMultiSelect&&_(m).toggleMultiSelect(...p))},"Enable multi-select")),_(m).selected.length>0?(N(),se("div",{key:2,class:"el-select-dropdown__item selected",onClick:d},"Deselect All")):(N(),se("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),_(m).selected.every(p=>!_(i).currentOutputs.map(v=>v.id).includes(p))?(N(),se("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(N(),se("div",{key:4,class:"el-select-dropdown__item selected",onClick:c},"Deselect Page"))]),_:1})]),_(l).pageless==="Disabled"?(N(),ve(_(kN),{key:0,layout:"prev, pager, next",total:_(i).outputsLength,"page-size":_(l).pageSize,"current-page":_(i).currentPage,"onUpdate:currentPage":g[2]||(g[2]=p=>_(i).currentPage=p),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ge("",!0),_(m).multiSelect?(N(),se("div",bY,[ne("div",null,Ee(_(m).selected.length)+" selected",1),oe(_(Ze),{type:"danger",onClick:u,icon:_(Yi),plain:""},{default:ue(()=>[...g[3]||(g[3]=[Ne("Delete",-1)])]),_:1},8,["icon"]),oe(_(Ze),{type:"success",onClick:f,icon:_(yl),plain:"",style:{margin:"0"}},{default:ue(()=>[...g[4]||(g[4]=[Ne("Download",-1)])]),_:1},8,["icon"])])):(N(),se("div",_Y,[...g[5]||(g[5]=[ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)])]))],2),_(i).outputsLength!=0?(N(),se("div",wY,[_(i).currentLayout==="dynamic"?(N(),se("div",SY,[(N(!0),se($e,null,$t(s.value,(p,v)=>(N(),se("div",{key:v,style:{flex:"1 1 0%"}},[(N(!0),se($e,null,$t(p,y=>(N(),ve(Fb,{key:y.id,"image-data":y,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ge("",!0),_(i).currentLayout==="grid"?(N(),se("div",CY,[(N(!0),se($e,null,$t(_(i).currentOutputs,p=>(N(),ve(Fb,{key:p.id,"image-data":p,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):ge("",!0)])):ge("",!0),_(i).outputsLength==0?(N(),se("div",xY,[oe(_(VF),{description:"No Images Found"})])):ge("",!0)],64))}}),kY=on(TY,[["__scopeId","data-v-b39b47c5"]]),EY=Object.freeze(Object.defineProperty({__proto__:null,default:kY},Symbol.toStringTag,{value:"Module"})),OY=["href"],AY=be({__name:"BaseLink",props:{href:{},router:{type:Boolean}},setup(e){return(t,n)=>{const r=yt("router-link");return N(),se($e,null,[t.router?ge("",!0):(N(),se("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:t.href},[ke(t.$slots,"default",{},void 0,!0)],8,OY)),t.router?(N(),ve(r,{key:1,to:t.href},{default:ue(()=>[ke(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ge("",!0)],64)}}}),PY=on(AY,[["__scopeId","data-v-17b53b7d"]]),IY={class:"about"},MY={class:"about-content"},LY=be({__name:"AboutView",setup(e){return(t,n)=>(N(),se("div",IY,[ne("div",MY,[n[2]||(n[2]=ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),n[3]||(n[3]=ne("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 "),ne("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),Ne(".")],-1)),n[4]||(n[4]=ne("br",null,null,-1)),n[5]||(n[5]=ne("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)),n[6]||(n[6]=ne("br",null,null,-1)),ne("div",null,[n[1]||(n[1]=Ne("You can find the KoboldAI community and authors of this fork on the ",-1)),oe(PY,{href:"https://koboldai.org/discord"},{default:ue(()=>[...n[0]||(n[0]=[Ne("KoboldAI Discord",-1)])]),_:1})])])]))}}),RY=on(LY,[["__scopeId","data-v-ecc278c5"]]),DY=Object.freeze(Object.defineProperty({__proto__:null,default:RY},Symbol.toStringTag,{value:"Module"})),Di=be({__name:"FormRadio",props:{label:{},modelValue:{},prop:{},useBoolean:{type:Boolean},options:{},disabled:{type:Boolean},info:{},labelStyle:{},change:{type:Function}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,r=t;function i(m){if(n.useBoolean&&m==="Enabled"?r("update:modelValue",!0):n.useBoolean&&m==="Disabled"?r("update:modelValue",!1):r("update:modelValue",m),!!n.change)return n.useBoolean&&m==="Enabled"?n.change(!0):n.useBoolean&&m==="Disabled"?n.change(!1):n.change(m)}const l=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(m,o)=>(N(),ve(_(Qi),{prop:m.prop},{label:ue(()=>[oe(du,{info:m.info,"label-style":m.labelStyle},{default:ue(()=>[ke(m.$slots,"label",{},()=>[Ne(Ee(m.label),1)])]),_:3},8,["info","label-style"])]),default:ue(()=>[oe(_(FR),{disabled:m.disabled,"model-value":l.value,onChange:i},{default:ue(()=>[(N(!0),se($e,null,$t(m.options,a=>(N(),ve(_(BR),{key:a,label:a},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),ke(m.$slots,"inline")]),_:3},8,["prop"]))}}),FY=be({__name:"OptionsView",setup(e){const t=Rt(),n=Ja(),r=nn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ie([]),m=ie(),o=ie(!1),a=ie(0);async function c(u){n.importFromZip(u),m.value.clearFiles()}async function d(){sa({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const u=await Wt.outputs.toCollection().primaryKeys();await YS(u,!1,()=>{a.value++}),o.value=!1,a.value=0}return(u,f)=>(N(),se($e,null,[f[19]||(f[19]=ne("h1",null,"Options",-1)),oe(_(Em),{"label-position":"top",model:_(t).options,onSubmit:f[13]||(f[13]=Qe(()=>{},["prevent"]))},{default:ue(()=>[oe(_(qz),{type:"border-card",style:{"min-height":"50vh"}},{default:ue(()=>[oe(_(Cd),{label:"\u{1F5A8}\uFE0F Generation"},{default:ue(()=>[f[14]||(f[14]=ne("h2",null,"Generation Options",-1)),oe(_(Qi),{label:"Base URL"},{default:ue(()=>[oe(_(lo),{class:"apikey",prop:"baseURL",modelValue:_(t).baseURL,"onUpdate:modelValue":f[1]||(f[1]=s=>_(t).baseURL=s)},{append:ue(()=>[oe(_(fn),{content:"Invalidate all cached information for this server (LoRAs, samplers, schedulers, ...)",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(mh),onClick:f[0]||(f[0]=s=>_(r).invalidateApiCaches())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue"])]),_:1}),f[15]||(f[15]=ne("h3",null,"Parameter Controls",-1)),(N(!0),se($e,null,$t(_(r).multiSelect,(s,h)=>{var g;return N(),se("div",{key:h},[oe(Di,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":p=>s.state=p,options:(g=s.allowedStates)!=null?g:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),oe(Di,{label:"Allow Larger Params",prop:"pageless",modelValue:_(t).allowLargerParams,"onUpdate:modelValue":f[2]||(f[2]=s=>_(t).allowLargerParams=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Keep generation on disconnect",prop:"keepImageGenOnDisconnect",modelValue:_(t).keepImageGenOnDisconnect,"onUpdate:modelValue":f[3]||(f[3]=s=>_(t).keepImageGenOnDisconnect=s),options:["Enabled","Disabled"],info:"By default, a client disconnect or an abort action causes the ongoing generation to be interrupted as soon as possible and discarded. Enabling this option overrides that behavior, allowing the generation to finish, and making the image available to be downloaded by the UI when ready."},null,8,["modelValue"]),oe(Di,{label:"Fetch generation progres",prop:"fetchGenerationProgress",modelValue:_(t).fetchGenerationProgress,"onUpdate:modelValue":f[4]||(f[4]=s=>_(t).fetchGenerationProgress=s),options:["Off","Text","Image"],info:"Off: no progress polling. Text: fetch textual progress info only. Image: fetch textual info and live image preview."},null,8,["modelValue"]),oe(Mo,{label:"Image Resize Mode",prop:"imageResizeMode",modelValue:_(t).imageResizeMode,"onUpdate:modelValue":f[5]||(f[5]=s=>_(t).imageResizeMode=s),options:[{label:"No Scale",value:"NoScale"},{label:"Scale and Crop",value:"ScaleAndCrop"},{label:"Scale and Pad",value:"ScaleAndPad"},{label:"Stretch",value:"Stretch"},{label:"Original",value:"Original"}],info:"How to adapt input image dimensions to the requested image size. No Scale: do not scale, just crop or pad each dimension to fit (default behavior). Scale and Crop: scale to match the smaller dimension, preserving aspect ratio, then crop to fit. Scale and Pad: scale to match the larger dimension, preserving aspect ratio, then pad to fit. Stretch: stretch both dimensions to fit, possibly not preserving aspect ratio. Original: send the input image as-is to the server, with no scaling, cropping or padding."},null,8,["modelValue"]),oe(Di,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:_(t).alsoRequestAvi,"onUpdate:modelValue":f[6]||(f[6]=s=>_(t).alsoRequestAvi=s),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),oe(_(Cd),{label:"\u{1F4F7} Images"},{default:ue(()=>[f[17]||(f[17]=ne("h2",null,"Image Options",-1)),oe(bn,{label:"Images Per Page",prop:"pageSize",modelValue:_(t).pageSize,"onUpdate:modelValue":f[7]||(f[7]=s=>_(t).pageSize=s),min:10,max:50,step:5,disabled:_(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),oe(Di,{label:"Pageless Format",prop:"pageless",modelValue:_(t).pageless,"onUpdate:modelValue":f[8]||(f[8]=s=>_(t).pageless=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:_(t).autoCarousel,"onUpdate:modelValue":f[9]||(f[9]=s=>_(t).autoCarousel=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Image Download Format",prop:"downloadType",modelValue:_(t).imageDownloadType,"onUpdate:modelValue":f[10]||(f[10]=s=>_(t).imageDownloadType=s),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),oe(_(Qi),{label:"Export Images (ZIP File)"},{default:ue(()=>[o.value?(N(),ve(_(Ze),{key:1,icon:_(yl),disabled:""},{default:ue(()=>[Ne("Downloading... ("+Ee(a.value)+" / "+Ee(_(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(N(),ve(_(Ze),{key:0,icon:_(yl),onClick:f[11]||(f[11]=s=>d())},{default:ue(()=>[Ne("Download "+Ee(_(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),oe(_(Qi),{label:"Import Images (ZIP File)"},{default:ue(()=>[oe(_(Lm),{drag:"",ref_key:"upload",ref:m,"auto-upload":!1,onChange:c,"file-list":l.value,limit:1,multiple:""},{default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),f[16]||(f[16]=ne("div",null,[Ne("Drop file here OR "),ne("em",null,"click to upload")],-1))]),_:1},8,["file-list"])]),_:1})]),_:1}),oe(_(Cd),{label:"\u2699\uFE0F General"},{default:ue(()=>[f[18]||(f[18]=ne("h2",null,"General Options",-1)),oe(Mo,{label:"Color Scheme",prop:"colorScheme",modelValue:_(t).options.colorMode,"onUpdate:modelValue":f[12]||(f[12]=s=>_(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}}),BY=on(FY,[["__scopeId","data-v-679e7af1"]]),$Y=Object.freeze(Object.defineProperty({__proto__:null,default:BY},Symbol.toStringTag,{value:"Module"}))});export default NY(); +`&&h>0?(u=0,f++,d++):!this.splitByGrapheme&&this._reSpaceAndTab.test(c.graphemeText[f])&&h>0&&(u++,f++),s[h]={line:d,offset:u},f+=c.graphemeLines[h].length,u+=c.graphemeLines[h].length;return s},styleHas:function(c,d){if(this._styleMap&&!this.isWrapping){var u=this._styleMap[d];u&&(d=u.line)}return a.Text.prototype.styleHas.call(this,c,d)},isEmptyStyles:function(c){if(!this.styles)return!0;var d=0,u=c+1,f,s,h=!1,g=this._styleMap[c],p=this._styleMap[c+1];g&&(c=g.line,d=g.offset),p&&(u=p.line,h=u===c,f=p.offset),s=typeof c>"u"?this.styles:{line:this.styles[c]};for(var v in s)for(var y in s[v])if(y>=d&&(!h||yu&&!k?(g.push(p),p=[],s=S,k=!0):s+=A,!k&&!h&&p.push(w),p=p.concat(y),C=h?0:this._measureWord([w],d,b),b++,k=!1,S>T&&(T=S);return z&&g.push(p),T+P>this.dynamicMinWidth&&(this.dynamicMinWidth=T-A+P),g},isEndOfWrapping:function(c){return!this._styleMap[c+1]||this._styleMap[c+1].line!==this._styleMap[c].line},missingNewlineOffset:function(c,d){return this.splitByGrapheme&&!d?this.isEndOfWrapping(c)?1:0:1},_splitTextIntoLines:function(c){for(var d=a.Text.prototype._splitTextIntoLines.call(this,c),u=this._wrapText(d.lines,this.width),f=new Array(u.length),s=0;si.onload=m),n.width=i.width,n.height=i.height,r==null||r.drawImage(i,0,0),n.toDataURL(t)}async function X7(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 K7(e,r)).split(",")[1]),l=new Uint8Array(i.length);for(let m=0;m{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=i=>n(i),r.readAsDataURL(e)})}"stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}});var Df=e=>new DataView(new ArrayBuffer(e)),co=e=>new Uint8Array(e.buffer||e),Lo=e=>new TextEncoder().encode(String(e));function q7(e,t,n=436){if(t===void 0||t instanceof Date||(t=new Date(t)),e instanceof File)return{t:t||new Date(e.lastModified),bytes:e.stream(),mode:n};if(e instanceof Response)return{t:t||new Date(e.headers.get("Last-Modified")||Date.now()),bytes:e.body,mode:n};if(t===void 0)t=new Date;else if(isNaN(t))throw new Error("Invalid modification date.");if(typeof e=="string")return{t,bytes:Lo(e),mode:n};if(e instanceof Blob)return{t,bytes:e.stream(),mode:n};if(e instanceof Uint8Array||e instanceof ReadableStream)return{t,bytes:e,mode:n};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{t,bytes:co(e),mode:n};if(Symbol.asyncIterator in e)return{t,bytes:VS(e[Symbol.asyncIterator]()),mode:n};throw new TypeError("Unsupported input format.")}function VS(e,t=e){return new ReadableStream({async pull(n){let r=0;for(;n.desiredSize>r;){const i=await e.next();if(!i.value){n.close();break}{const l=Z7(i.value);n.enqueue(l),r+=l.byteLength}}},cancel(n){var r;(r=t.throw)==null||r.call(t,n)}})}function Z7(e){return typeof e=="string"?Lo(e):e instanceof Uint8Array?e:co(e)}function US(e,t,n){let[r,i]=function(l){return l?l instanceof Uint8Array?[l,1]:ArrayBuffer.isView(l)||l instanceof ArrayBuffer?[co(l),1]:[Lo(l),0]:[void 0,0]}(t);if(e instanceof File)return{o:Dd(r||Lo(e.name)),i:e.size,u:i};if(e instanceof Response){const l=e.headers.get("content-disposition"),m=l&&l.match(/;\s*filename\*?\s*=\s*(?:UTF-\d+''|)["']?([^;"'\r\n]*)["']?(?:;|$)/i),o=m&&m[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),a=o&&decodeURIComponent(o),c=n||+e.headers.get("content-length");return{o:Dd(r||Lo(a)),i:c,u:i}}return r=Dd(r),typeof e=="string"?{o:r,i:Lo(e).length,u:i}:e instanceof Blob?{o:r,i:e.size,u:i}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:r,i:e.byteLength,u:i}:{o:r,i:J7(e,n),u:i}}function J7(e,t){return t>-1?t:e?void 0:0}function Dd(e){if(!e||e.every(t=>t===47))throw new Error("The file must have a name.");for(;e[e.length-1]===47;)e=e.subarray(0,-1);return e}var HS=new Uint32Array(256);for(let e=0;e<256;++e){let t=e;for(let n=0;n<8;++n)t=t>>>1^(1&t&&3988292384);HS[e]=t}function Wy(e,t=0){t=~t;for(var n=0,r=e.length;n>>8^HS[255&t^e[n]];return~t>>>0}function WS(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 Q7({o:e,u:t},n){return 8*(!t||(n!=null?n:function(r){try{eU.decode(r)}catch{return 0}return 1}(e)))}var eU=new TextDecoder("utf8",{fatal:1});function tU(e,t=0){const n=Df(30);return n.setUint32(0,1347093252),n.setUint32(4,335546368|t),WS(e.t,n,10),n.setUint16(26,e.o.length,1),co(n)}async function*nU(e){let{bytes:t}=e;if("then"in t&&(t=await t),t instanceof Uint8Array)yield t,e.l=Wy(t,0),e.i=t.length;else{e.i=0;const n=t.getReader();for(;;){const{value:r,done:i}=await n.read();if(i)break;e.l=Wy(r,e.l),e.i+=r.length,yield r}}}function rU(e){const t=Df(16);return t.setUint32(0,1347094280),t.setUint32(4,e.l,1),t.setUint32(8,e.i,1),t.setUint32(12,e.i,1),co(t)}function iU(e,t,n=0){const r=Df(46);return r.setUint32(0,1347092738),r.setUint32(4,352523264),r.setUint16(8,2048|n),WS(e.t,r,12),r.setUint32(16,e.l,1),r.setUint32(20,e.i,1),r.setUint32(24,e.i,1),r.setUint16(28,e.o.length,1),r.setUint16(40,32768|e.mode,1),r.setUint32(42,t,1),co(r)}function GS(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified,e.mode]]}var aU=e=>function(t){var n;let r=22;for(const i of t){if(!i.o)throw new Error("Every file must have a non-empty name.");if(isNaN((n=i.i)!=null?n:NaN))throw new Error(`Missing size for file "${new TextDecoder().decode(i.o)}".`);r+=2*i.o.length+i.i+92}return r}(function*(t){for(const n of t)yield US(...GS(n)[0])}(e));function oU(e,t={}){const n={"Content-Type":"application/zip","Content-Disposition":"attachment"};Number.isInteger(t.length)&&t.length>0&&(n["Content-Length"]=t.length),t.metadata&&(n["Content-Length"]=aU(t.metadata));const r=function(i){var l;const m=i[Symbol.iterator in i?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const o=await m.next();if(o.done)return o;const[a,c]=GS(o.value);return{done:0,value:Object.assign(q7(...c),US(...a))}},throw:(l=m.throw)==null?void 0:l.bind(m),[Symbol.asyncIterator](){return this}}}(e);return new Response(VS(async function*(i,l){const m=[];let o=0,a=0;for await(const u of i){const f=Q7(u,l.buffersAreUTF8);yield tU(u,f),yield new Uint8Array(u.o),yield*nU(u),yield rU(u),m.push(iU(u,o,f)),m.push(u.o),a++,o+=46+u.o.length+u.i}let c=0;for(const u of m)yield u,c+=u.length;const d=Df(22);d.setUint32(0,1347093766),d.setUint16(8,a,1),d.setUint16(10,a,1),d.setUint32(12,c,1),d.setUint32(16,o,1),yield co(d)}(r,t),r),{headers:n})}async function YS(e,t=!0,n){const r=Rt();t&&sa({message:`Downloading ${e.length} image(s)...`,type:"info"});const i=[];for(let o=0;o]/g,"").substring(0,128).trimEnd();let s=r.imageDownloadType;c.startsWith("data:image/gif")&&(s="GIF"),s==="PNG"?i.push({name:f+".png",input:await Da(c,"image/png")}):s==="JPG"?i.push({name:f+".jpg",input:await Da(c,"image/jpeg")}):s==="GIF"?i.push({name:f+".gif",input:await Da(c,"image/gif")}):i.push({name:f+".webp",input:await Da(c,"image/webp")}),i.push({name:f+".json",input:JSON.stringify(u,void 0,4)}),n&&n()}const l=await oU(i).blob(),m=document.createElement("a");m.href=URL.createObjectURL(l),m.download="sdui_images.zip",m.click()}async function rg(e,t){const n=Rt(),r=document.createElement("a");let i,l=n.imageDownloadType;e.startsWith("data:image/gif")&&(l="GIF"),l==="PNG"?(i=await Da(e,"image/png"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".png"):l==="JPG"?(i=await Da(e,"image/jpeg"),r.href=URL.createObjectURL(i),r.download=t.replace(/[/\\:*?"<>]/g,"").substring(0,128).trimEnd()+".jpg"):l==="GIF"?(i=await Da(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)}function KS(e,t){const n=e;if(!n)return;const r=atob(n),i=r.length,l=new Uint8Array(i);for(let c=0;c{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=ie({...e(),maskPathColor:"white",maskBackgroundColor:"black"}),n=ie({...e(),maskPathColor:"black",maskBackgroundColor:"white"}),r=ee(()=>nn().generatorType==="Inpainting"),i=ee(()=>r.value?t.value:n.value),l=ee(()=>nn().currentImageProps),m=ee({get:()=>i.value.drawing&&!r.value,set:W=>i.value.drawing=W}),o=ie(512),a=ie(512),c=ie(!1),d=ie(30),u=ie(!1),f=new cr.fabric.Circle({radius:d.value,left:0,originX:"center",originY:"center",angle:0,fill:"",stroke:"red",strokeWidth:3,opacity:0}),s=ie("Erase"),h=ie("rgb(0, 0, 0, 1)");function g(){!i.value.canvas||i.value.canvas.renderAll()}function p(){c.value=!c.value,s.value=c.value?"Draw":"Erase"}function v(W=null){!i.value.canvas||(i.value.brush=i.value.canvas.freeDrawingBrush,i.value.brush.color=W||i.value.brush.color,i.value.brush.width=d.value)}async function y({history:W,erase:D=!1,draw:B=!1}={}){if(!W||!i.value.drawLayer||!i.value.visibleDrawLayer||!i.value.imageLayer||!i.value.visibleImageLayer||!i.value.canvas)return;W.path.selectable=!1,W.path.opacity=1,W.drawPath=await V(W.path),W.visibleDrawPath=await V(W.path),D?(W.visibleDrawPath.globalCompositeOperation="destination-out",W.drawPath.stroke=i.value.maskBackgroundColor):(W.visibleDrawPath.globalCompositeOperation="source-over",W.drawPath.stroke=B?h.value:i.value.maskPathColor);let Z=await V(W.drawPath);Z=Z.scale(i.value.imageScale),Z.left=Z.left+W.drawPath.left*(i.value.imageScale-1),Z.top=Z.top+W.drawPath.top*(i.value.imageScale-1),B?(i.value.imageLayer.add(Z),i.value.visibleImageLayer.addWithUpdate(W.visibleDrawPath)):(i.value.drawLayer.add(Z),i.value.visibleDrawLayer.addWithUpdate(W.visibleDrawPath)),i.value.canvas.remove(W.path),g()}function b(){if(i.value.undoHistory.length===0)return;const W=i.value.undoHistory.pop();y({history:W,erase:!1,draw:m.value}),i.value.redoHistory.push(W)}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 W=i.value.redoHistory.pop();i.value.undoHistory.push(W),m.value?(i.value.imageLayer.remove(W.drawPath),i.value.visibleImageLayer.remove(W.visibleDrawPath)):(i.value.drawLayer.remove(W.drawPath),i.value.visibleDrawLayer.remove(W.visibleDrawPath)),delete W.drawPath,delete W.visibleDrawPath,g()}function S(W){i.value.canvas=new cr.fabric.Canvas(W,{isDrawingMode:!1,width:o.value,height:a.value,backgroundColor:"white"}),i.value.canvas.selection=!1,i.value.canvas.freeDrawingCursor="crosshair",v(i.value.maskPathColor),i.value.canvas.on("mouse:move",R),i.value.canvas.on("path:created",M),g()}function C(W,D,B,Z){let H=Z,Q=Z;return D>B?(W.scaleToWidth(Z),H=Z*(a.value/o.value)):(W.scaleToHeight(Z),Q=Z*(o.value/a.value)),{newHeight:H,newWidth:Q}}function T(W){const D=nn();if(ae(),W.selectable=!1,o.value=W.width,a.value=W.height,o.value>D.maxDimensions||a.value>D.maxDimensions){const{newHeight:Q,newWidth:te}=C(W,o.value,a.value,D.maxDimensions);o.value=te,a.value=Q}if(o.value{i.value.imageLayer=$({image:Q,layerHeight:H,layerWidth:Z})}),W.cloneAsImage(Q=>{if(!i.value.canvas)return;if(o.value!==B||a.value!==B){const{newHeight:me,newWidth:_e}=C(Q,o.value,a.value,B);o.value=_e,a.value=me}i.value.canvas.setWidth(o.value),i.value.canvas.setHeight(a.value),i.value.canvas.isDrawingMode=!0,i.value.visibleDrawLayer=Y(),i.value.visibleImageLayer=Y({image:Q}),i.value.drawLayer=$({layerHeight:H,layerWidth:Z});const te=o.value*i.value.imageScale,fe=a.value*i.value.imageScale;D.params.width=te-te%64,D.params.height=fe-fe%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),u.value=!0,z(),A()})}function k(W,D,B,Z,H,Q){const te=Q?Q.width:W.width,fe=Q?Q.height:W.height;if(H==="Original")return W;const me=document.createElement("canvas");me.width=D,me.height=B;const _e=me.getContext("2d");_e.fillStyle=Z,_e.fillRect(0,0,me.width,me.height);let j=0,x=0,U=W.width,K=W.height,L=0,F=0,X=me.width,de=me.height;switch(H){case"Stretch":break;case"ScaleAndCrop":{const le=me.width/te,G=me.height/fe;le>G?(K=me.height/le,x=(W.height-K)/2):(U=me.width/G,j=(W.width-U)/2);break}case"ScaleAndPad":{const le=me.width/te,G=me.height/fe;leD?(U=D,j=le-D/2):(X=te,L=D/2-le),fe>B?(K=B,x=G-B/2):(de=fe,F=B/2-G);break}}return _e.drawImage(W,j,x,U,K,L,F,X,de),me}function A(){const W=nn(),D=Rt();if(!i.value.imageLayer||!i.value.drawLayer)return;const B=W.params.width,Z=W.params.height,H=i.value.imageLayer.backgroundColor||"#FFFFFF",Q=D.imageResizeMode,te=i.value.imageLayer.toCanvasElement(),fe=k(te,B,Z,H,Q,te);if(l.value.sourceImage=fe.toDataURL("image/jpeg",1),l.value.maskImage=void 0,i.value.redoHistory.length>0&&!m.value){const _e=i.value.drawLayer.toCanvasElement(),j=k(_e,B,Z,H,Q,te);l.value.maskImage=j.toDataURL("image/jpeg",1).split(",")[1]}}let P;function z(){if(!i.value.canvas)return;const W=nn();i.value.cropPreviewLayer&&(i.value.canvas.remove(i.value.cropPreviewLayer),i.value.cropPreviewLayer=void 0),u.value&&(i.value.cropPreviewLayer=Y({layerWidth:W.params.width/i.value.imageScale,layerHeight:W.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),P&&clearTimeout(P),P=setTimeout(()=>{u.value=!1,z(),P=void 0},5e3))}function I(W,D){const B="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";cr.fabric.Image.fromURL(B,Z=>{Z.set({height:W,width:D});const H=Z.toDataURL({format:"png"});l.value.sourceImage=H,m.value=!0,T(Z)})}function $({image:W,layerWidth:D,layerHeight:B}={}){const Z=new cr.fabric.Canvas(null);return Z.selection=!1,Z.backgroundColor=i.value.maskBackgroundColor,Z.setHeight(B||a.value),Z.setWidth(D||o.value),W&&Z.add(W),Z}function O(){return i.value.imageLayer?{layerHeight:i.value.imageLayer.getHeight(),layerWidth:i.value.imageLayer.getWidth()}:{}}function Y({image:W,layerWidth:D,layerHeight:B,fill:Z,abosolute:H}={}){const Q=W||new cr.fabric.Rect({width:D||o.value,height:B||a.value,left:0,top:0,fill:Z||"transparent",absolutePositioned:H||!0,selectable:!1});return new cr.fabric.Group([Q],{selectable:!1,absolutePositioned:H||!0})}function ae(){!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 q(){if(!!i.value.canvas){if(i.value.visibleDrawLayer&&(i.value.canvas.remove(i.value.visibleDrawLayer),i.value.visibleDrawLayer=void 0),m.value){const W=nn();I(W.params.height||512,W.params.width||512)}i.value.drawLayer=void 0,i.value.redoHistory=[],i.value.undoHistory=[],i.value.visibleDrawLayer=Y(),i.value.drawLayer=$(O()),i.value.visibleDrawLayer.set("opacity",.8),i.value.canvas.add(i.value.visibleDrawLayer)}}function J(){var D;A();const W=document.createElement("a");if(m.value){W.href="data:image/png;base64,"+((D=l.value.sourceImage)==null?void 0:D.split(",")[1]),W.download="image_drawing.png",W.click();return}W.href="data:image/png;base64,"+l.value.maskImage,W.download="image_mask.png",W.click()}function E(){A();const W=nn(),D=l.value.sourceImage;!D||rg(D,`${W.generatorType.toLowerCase()}-reference`)}async function V(W){return new Promise((D,B)=>{try{W.clone(D)}catch(Z){B(Z)}})}async function M(W){const D={path:W.path};y({history:D,erase:c.value,draw:m.value}),i.value.redoHistory.push(D)}function R(W){if(!i.value.canvas)return;const D=i.value.canvas.getPointer(W.e);f.left=D.x,f.top=D.y,f.opacity=.8,c.value?(f.set("strokeWidth",3),f.set("fill",""),v("red")):(f.set("strokeWidth",0),m.value?(f.set("fill",h.value),v(h.value)):(f.set("fill","white"),v("white"))),f.set("radius",d.value/2),g()}return{showCropPreview:u,erasing:c,switchToolText:s,brushSize:d,drawColor:h,drawing:m,imageProps:i,updateCropPreview:z,createNewCanvas:S,downloadMask:J,downloadSourceImage:E,resetCanvas:ae,resetDrawing:q,flipErase:p,undoAction:w,redoAction:b,newImage:T,newBlankImage:I,setBrush:v,saveImages:A}}),sU={},lU={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 20 20"};function uU(e,t){return N(),se("svg",lU,[...t[0]||(t[0]=[ne("g",{fill:"none"},[ne("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)])])}const cU=on(sU,[["render",uU]]),fU={key:0},dU={class:"canvas-container"},hU={class:"action-buttons",style:{left:"10px",right:"unset"}},pU={class:"action-buttons"},mU=be({__name:"CustomCanvas",setup(e){const t=nn(),n=Yt(),r=il(),i=ie();async function l(a){if(!a.raw.type.includes("image")){n.raiseError("Uploaded file needs to be a image!",!1),i.value.clearFiles();return}const c=await Nl(a.raw);t.currentImageProps.sourceImage=c,r.drawing=!1,cr.fabric.Image.fromURL(c,r.newImage)}function m(){t.currentImageProps.sourceImage="",r.resetCanvas()}tt(()=>{r.createNewCanvas("canvas"),t.currentImageProps.sourceImage&&cr.fabric.Image.fromURL(t.currentImageProps.sourceImage,r.newImage),window.addEventListener("paste",o)}),Jt(()=>{window.removeEventListener("paste",o)});async function o(a){var d;const c=(d=a.clipboardData)==null?void 0:d.items;if(!!c)for(let u=0;u(N(),se($e,null,[_(t).currentImageProps.sourceImage?ge("",!0):(N(),ve(_(Lm),{key:0,drag:"",ref_key:"upload",ref:i,"auto-upload":!1,onChange:l,limit:1,multiple:""},{tip:ue(()=>[_(t).generatorType==="Img2Img"?(N(),se("div",fU,[c[9]||(c[9]=ne("div",{class:"center-horizontal",style:{"margin-top":"5px"}},"OR",-1)),ne("div",{class:"center-both",style:{cursor:"pointer","text-decoration":"underline","font-size":"1rem"},onClick:c[0]||(c[0]=d=>_(r).newBlankImage(_(t).params.height||512,_(t).params.width||512))},[oe(_(De),{size:20,style:{"margin-right":"2px"}},{default:ue(()=>[oe(zS)]),_:1}),c[8]||(c[8]=Ne("draw something",-1))])])):ge("",!0)]),default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),c[10]||(c[10]=ne("div",null,[Ne("Drop file here, paste an image OR "),ne("em",null,"click to upload")],-1))]),_:1},512)),xt(ne("div",null,[ne("div",dU,[c[11]||(c[11]=ne("canvas",{id:"canvas"},null,-1)),ne("div",hU,[oe(_(Ze),{onClick:c[1]||(c[1]=d=>_(r).undoAction()),icon:_(R1),plain:"",disabled:_(r).imageProps.redoHistory.length===0},null,8,["icon","disabled"]),oe(_(Ze),{onClick:c[2]||(c[2]=d=>_(r).redoAction()),icon:_(D1),plain:"",disabled:_(r).imageProps.undoHistory.length===0},null,8,["icon","disabled"])]),ne("div",pU,[oe(_(Ze),{onClick:c[3]||(c[3]=d=>_(r).resetDrawing()),icon:_(Kr),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:m,icon:_(Yi),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:c[4]||(c[4]=d=>_(r).downloadSourceImage()),icon:_(yl),plain:""},null,8,["icon"]),oe(_(Ze),{onClick:c[5]||(c[5]=d=>_(r).flipErase()),icon:_(r).erasing?_(sO):cU,plain:""},null,8,["icon"]),_(r).drawing?(N(),ve(_(ID),{key:0,modelValue:_(r).drawColor,"onUpdate:modelValue":c[6]||(c[6]=d=>_(r).drawColor=d),"show-alpha":""},null,8,["modelValue"])):ge("",!0)]),oe(_(Em),{"label-width":"110px",style:{"margin-top":"10px"}},{default:ue(()=>[oe(bn,{style:{"margin-bottom":"5px"},label:"Brush Size",prop:"brushSize",modelValue:_(r).brushSize,"onUpdate:modelValue":c[7]||(c[7]=d=>_(r).brushSize=d),min:10,max:100,step:10,change:_(r).setBrush},null,8,["modelValue","change"])]),_:1})])],512),[[Gt,_(t).currentImageProps.sourceImage]])],64))}}),Gy=on(mU,[["__scopeId","data-v-0cdc2bf8"]]),gU={class:"centerIcons"},vU={class:"stackedIcons"},yU=be({__name:"StackedIcon",props:{iconOne:{type:[Object,Function]},iconTwo:{type:[Object,Function]},size:{}},setup(e){JT(n=>({"2ad037ca":n.size+"px"}));const t=e;return(n,r)=>(N(),se("div",gU,[ne("div",vU,[oe(_(De),{class:"firstIcon",size:n.size},{default:ue(()=>[(N(),ve(Ct(t.iconOne)))]),_:1},8,["size"]),oe(_(De),{class:"secondIcon",size:n.size},{default:ue(()=>[(N(),ve(Ct(t.iconTwo)))]),_:1},8,["size"])])]))}}),bU=on(yU,[["__scopeId","data-v-74586a39"]]),_U={key:1,style:{width:"40px"}},Uu=be({__name:"GeneratorMenuItem",props:{index:{},iconOne:{type:[Object,Function]},iconTwo:{type:[Object,Function]},isMobile:{type:Boolean}},setup(e){const t=e;return(n,r)=>(N(),ve(_(fn),{content:n.index,placement:n.isMobile?"bottom":"right",enterable:!1,"hide-after":100},{default:ue(()=>[oe(_(Am),{index:n.index,style:{height:"60px",display:"flex","justify-content":"center"}},{default:ue(()=>[n.iconTwo?(N(),ve(bU,{key:0,iconOne:n.iconOne,iconTwo:n.iconTwo,size:40},null,8,["iconOne","iconTwo"])):(N(),se("div",_U,[oe(_(De),{style:{width:"35px"},size:40},{default:ue(()=>[(N(),ve(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 wU=4,Yy=0,Ky=1,SU=2;function ys(e){let t=e.length;for(;--t>=0;)e[t]=0}const CU=0,XS=1,xU=2,TU=3,kU=258,ig=29,hu=256,zl=hu+1+ig,Uo=30,ag=19,qS=2*zl+1,Fa=15,Fd=16,EU=7,og=256,ZS=16,JS=17,QS=18,cp=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]),yc=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]),OU=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),eC=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),AU=512,ci=new Array((zl+2)*2);ys(ci);const al=new Array(Uo*2);ys(al);const jl=new Array(AU);ys(jl);const Vl=new Array(kU-TU+1);ys(Vl);const sg=new Array(ig);ys(sg);const nf=new Array(Uo);ys(nf);function Bd(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 tC,nC,rC;function $d(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const iC=e=>e<256?jl[e]:jl[256+(e>>>7)],Ul=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Nn=(e,t,n)=>{e.bi_valid>Fd-n?(e.bi_buf|=t<>Fd-e.bi_valid,e.bi_valid+=n-Fd):(e.bi_buf|=t<{Nn(e,n[t*2],n[t*2+1])},aC=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},PU=e=>{e.bi_valid===16?(Ul(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)},IU=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,l=t.stat_desc.has_stree,m=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,a=t.stat_desc.max_length;let c,d,u,f,s,h,g=0;for(f=0;f<=Fa;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;ca&&(f=a,g++),n[d*2+1]=f,!(d>r)&&(e.bl_count[f]++,s=0,d>=o&&(s=m[d-o]),h=n[d*2],e.opt_len+=h*(f+s),l&&(e.static_len+=h*(i[d*2+1]+s)));if(g!==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]--,g-=2}while(g>0);for(f=a;f!==0;f--)for(d=e.bl_count[f];d!==0;)u=e.heap[--c],!(u>r)&&(n[u*2+1]!==f&&(e.opt_len+=(f-n[u*2+1])*n[u*2],n[u*2+1]=f),d--)}},oC=(e,t,n)=>{const r=new Array(Fa+1);let i=0,l,m;for(l=1;l<=Fa;l++)i=i+n[l-1]<<1,r[l]=i;for(m=0;m<=t;m++){let o=e[m*2+1];o!==0&&(e[m*2]=aC(r[o]++,o))}},MU=()=>{let e,t,n,r,i;const l=new Array(Fa+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?Ul(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Xy=(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,m,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?Vr(e,i,t):(m=Vl[i],Vr(e,m+hu+1,t),o=cp[m],o!==0&&(i-=sg[m],Nn(e,i,o)),r--,m=iC(r),Vr(e,m,n),o=yc[m],o!==0&&(r-=nf[m],Nn(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 m,o,a=-1,c;for(e.heap_len=0,e.heap_max=qS,m=0;m>1;m>=1;m--)Nd(e,n,m);c=l;do m=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Nd(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=m,e.heap[--e.heap_max]=o,n[c*2]=n[m*2]+n[o*2],e.depth[c]=(e.depth[m]>=e.depth[o]?e.depth[m]:e.depth[o])+1,n[m*2+1]=n[o*2+1]=c,e.heap[1]=c++,Nd(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],IU(e,t),oC(n,a,e.bl_count)},Zy=(e,t,n)=>{let r,i=-1,l,m=t[0*2+1],o=0,a=7,c=4;for(m===0&&(a=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)l=m,m=t[(r+1)*2+1],!(++o{let r,i=-1,l,m=t[0*2+1],o=0,a=7,c=4;for(m===0&&(a=138,c=3),r=0;r<=n;r++)if(l=m,m=t[(r+1)*2+1],!(++o{let t;for(Zy(e,e.dyn_ltree,e.l_desc.max_code),Zy(e,e.dyn_dtree,e.d_desc.max_code),fp(e,e.bl_desc),t=ag-1;t>=3&&e.bl_tree[eC[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},RU=(e,t,n,r)=>{let i;for(Nn(e,t-257,5),Nn(e,n-1,5),Nn(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 Yy;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Ky;for(n=32;n{Qy||(MU(),Qy=!0),e.l_desc=new $d(e.dyn_ltree,tC),e.d_desc=new $d(e.dyn_dtree,nC),e.bl_desc=new $d(e.bl_tree,rC),e.bi_buf=0,e.bi_valid=0,sC(e)},uC=(e,t,n,r)=>{Nn(e,(CU<<1)+(r?1:0),3),lC(e),Ul(e,n),Ul(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},BU=e=>{Nn(e,XS<<1,3),Vr(e,og,ci),PU(e)},$U=(e,t,n,r)=>{let i,l,m=0;e.level>0?(e.strm.data_type===SU&&(e.strm.data_type=DU(e)),fp(e,e.l_desc),fp(e,e.d_desc),m=LU(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?uC(e,t,n,r):e.strategy===wU||l===i?(Nn(e,(XS<<1)+(r?1:0),3),qy(e,ci,al)):(Nn(e,(xU<<1)+(r?1:0),3),RU(e,e.l_desc.max_code+1,e.d_desc.max_code+1,m+1),qy(e,e.dyn_ltree,e.dyn_dtree)),sC(e),r&&lC(e)},NU=(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[(Vl[n]+hu+1)*2]++,e.dyn_dtree[iC(t)*2]++),e.sym_next===e.sym_end);var zU=FU,jU=uC,VU=$U,UU=NU,HU=BU,WU={_tr_init:zU,_tr_stored_block:jU,_tr_flush_block:VU,_tr_tally:UU,_tr_align:HU};const GU=(e,t,n,r)=>{let i=e&65535|0,l=e>>>16&65535|0,m=0;for(;n!==0;){m=n>2e3?2e3:n,n-=m;do i=i+t[r++]|0,l=l+i|0;while(--m);i%=65521,l%=65521}return i|l<<16|0};var Hl=GU;const YU=()=>{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},KU=new Uint32Array(YU()),XU=(e,t,n,r)=>{const i=KU,l=r+n;e^=-1;for(let m=r;m>>8^i[(e^t[m])&255];return e^-1};var sn=XU,Qa={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"},bs={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:qU,_tr_stored_block:dp,_tr_flush_block:ZU,_tr_tally:ea,_tr_align:JU}=WU,{Z_NO_FLUSH:ta,Z_PARTIAL_FLUSH:QU,Z_FULL_FLUSH:eH,Z_FINISH:fr,Z_BLOCK:eb,Z_OK:cn,Z_STREAM_END:tb,Z_STREAM_ERROR:Gr,Z_DATA_ERROR:tH,Z_BUF_ERROR:zd,Z_DEFAULT_COMPRESSION:nH,Z_FILTERED:rH,Z_HUFFMAN_ONLY:Hu,Z_RLE:iH,Z_FIXED:aH,Z_DEFAULT_STRATEGY:oH,Z_UNKNOWN:sH,Z_DEFLATED:Ff}=bs,lH=9,uH=15,cH=8,fH=29,dH=256,hp=dH+1+fH,hH=30,pH=19,mH=2*hp+1,gH=15,ct=3,qi=258,Yr=qi+ct+1,vH=32,rs=42,lg=57,pp=69,mp=73,gp=91,vp=103,Ba=113,Bs=666,Mn=1,_s=2,eo=3,ws=4,yH=3,$a=(e,t)=>(e.msg=Qa[t],t),nb=e=>e*2-(e>4?9:0),Gi=e=>{let t=e.length;for(;--t>=0;)e[t]=0},bH=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 _H=(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))},Jn=(e,t)=>{ZU(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Kn(e.strm)},vt=(e,t)=>{e.pending_buf[e.pending++]=t},Is=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},yp=(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=Hl(e.adler,t,i,n):e.state.wrap===2&&(e.adler=sn(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},cC=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,l,m=e.prev_length,o=e.nice_match;const a=e.strstart>e.w_size-Yr?e.strstart-(e.w_size-Yr):0,c=e.window,d=e.w_mask,u=e.prev,f=e.strstart+qi;let s=c[r+m-1],h=c[r+m];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(c[i+m]!==h||c[i+m-1]!==s||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&rm){if(e.match_start=t,m=l,l>=o)break;s=c[r+m-1],h=c[r+m]}}while((t=u[t&d])>a&&--n!==0);return m<=e.lookahead?m:e.lookahead},is=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Yr)&&(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),bH(e),r+=t),e.strm.avail_in===0)break;if(n=yp(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=ct)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=na(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=na(e,e.ins_h,e.window[i+ct-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,m=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,Kn(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&&(yp(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(m===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&&(yp(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===fr)&&t!==ta&&e.strm.avail_in===0&&i<=l)&&(r=i>l?l:i,m=t===fr&&e.strm.avail_in===0&&r===i?1:0,dp(e,e.block_start,r,m),e.block_start+=r,Kn(e.strm)),m?eo:Mn)},jd=(e,t)=>{let n,r;for(;;){if(e.lookahead=ct&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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-Yr&&(e.match_length=cC(e,n)),e.match_length>=ct)if(r=ea(e,e.strstart-e.match_start,e.match_length-ct),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=ct){e.match_length--;do e.strstart++,e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=na(e,e.ins_h,e.window[e.strstart+1]);else r=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=ct&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=ct-1,n!==0&&e.prev_length4096)&&(e.match_length=ct-1)),e.prev_length>=ct&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-ct,r=ea(e,e.strstart-1-e.prev_match,e.prev_length-ct),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=na(e,e.ins_h,e.window[e.strstart+ct-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=ct-1,e.strstart++,r&&(Jn(e,!1),e.strm.avail_out===0))return Mn}else if(e.match_available){if(r=ea(e,0,e.window[e.strstart-1]),r&&Jn(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Mn}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=ea(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,l;const m=e.window;for(;;){if(e.lookahead<=qi){if(is(e),e.lookahead<=qi&&t===ta)return Mn;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=ct&&e.strstart>0&&(i=e.strstart-1,r=m[i],r===m[++i]&&r===m[++i]&&r===m[++i])){l=e.strstart+qi;do;while(r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&r===m[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=ct?(n=ea(e,1,e.match_length-ct),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=0,t===fr?(Jn(e,!0),e.strm.avail_out===0?eo:ws):e.sym_next&&(Jn(e,!1),e.strm.avail_out===0)?Mn:_s},SH=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(is(e),e.lookahead===0)){if(t===ta)return Mn;break}if(e.match_length=0,n=ea(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Jn(e,!1),e.strm.avail_out===0))return Mn}return e.insert=0,t===fr?(Jn(e,!0),e.strm.avail_out===0?eo:ws):e.sym_next&&(Jn(e,!1),e.strm.avail_out===0)?Mn:_s};function Br(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 $s=[new Br(0,0,0,0,fC),new Br(4,4,8,4,jd),new Br(4,5,16,8,jd),new Br(4,6,32,32,jd),new Br(4,4,16,16,xo),new Br(8,16,32,32,xo),new Br(8,16,128,128,xo),new Br(8,32,128,256,xo),new Br(32,128,258,1024,xo),new Br(32,258,258,4096,xo)],CH=e=>{e.window_size=2*e.w_size,Gi(e.head),e.max_lazy_match=$s[e.level].max_lazy,e.good_match=$s[e.level].good_length,e.nice_match=$s[e.level].nice_length,e.max_chain_length=$s[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=ct-1,e.match_available=0,e.ins_h=0};function xH(){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=Ff,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(mH*2),this.dyn_dtree=new Uint16Array((2*hH+1)*2),this.bl_tree=new Uint16Array((2*pH+1)*2),Gi(this.dyn_ltree),Gi(this.dyn_dtree),Gi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(gH+1),this.heap=new Uint16Array(2*hp+1),Gi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*hp+1),Gi(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 pu=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==rs&&t.status!==lg&&t.status!==pp&&t.status!==mp&&t.status!==gp&&t.status!==vp&&t.status!==Ba&&t.status!==Bs?1:0},dC=e=>{if(pu(e))return $a(e,Gr);e.total_in=e.total_out=0,e.data_type=sH;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?lg:t.wrap?rs:Ba,e.adler=t.wrap===2?0:1,t.last_flush=-2,qU(t),cn},hC=e=>{const t=dC(e);return t===cn&&CH(e.state),t},TH=(e,t)=>pu(e)||e.state.wrap!==2?Gr:(e.state.gzhead=t,cn),pC=(e,t,n,r,i,l)=>{if(!e)return Gr;let m=1;if(t===nH&&(t=6),r<0?(m=0,r=-r):r>15&&(m=2,r-=16),i<1||i>lH||n!==Ff||r<8||r>15||t<0||t>9||l<0||l>aH||r===8&&m!==1)return $a(e,Gr);r===8&&(r=9);const o=new xH;return e.state=o,o.strm=e,o.status=rs,o.wrap=m,o.gzhead=null,o.w_bits=r,o.w_size=1<pC(e,t,Ff,uH,cH,oH),EH=(e,t)=>{if(pu(e)||t>eb||t<0)return e?$a(e,Gr):Gr;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===Bs&&t!==fr)return $a(e,e.avail_out===0?zd:Gr);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Kn(e),e.avail_out===0)return n.last_flush=-1,cn}else if(e.avail_in===0&&nb(t)<=nb(r)&&t!==fr)return $a(e,zd);if(n.status===Bs&&e.avail_in!==0)return $a(e,zd);if(n.status===rs&&n.wrap===0&&(n.status=Ba),n.status===rs){let i=Ff+(n.w_bits-8<<4)<<8,l=-1;if(n.strategy>=Hu||n.level<2?l=0:n.level<6?l=1:n.level===6?l=2:l=3,i|=l<<6,n.strstart!==0&&(i|=vH),i+=31-i%31,Is(n,i),n.strstart!==0&&(Is(n,e.adler>>>16),Is(n,e.adler&65535)),e.adler=1,n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(n.status===lg){if(e.adler=0,vt(n,31),vt(n,139),vt(n,8),n.gzhead)vt(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)),vt(n,n.gzhead.time&255),vt(n,n.gzhead.time>>8&255),vt(n,n.gzhead.time>>16&255),vt(n,n.gzhead.time>>24&255),vt(n,n.level===9?2:n.strategy>=Hu||n.level<2?4:0),vt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(vt(n,n.gzhead.extra.length&255),vt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=sn(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=pp;else if(vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,0),vt(n,n.level===9?2:n.strategy>=Hu||n.level<2?4:0),vt(n,yH),n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(n.status===pp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex+=o,Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0,l-=o}let m=new Uint8Array(n.gzhead.extra);n.pending_buf.set(m.subarray(n.gzindex,n.gzindex+l),n.pending),n.pending+=l,n.gzhead.hcrc&&n.pending>i&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=mp}if(n.status===mp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0}n.gzindexi&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=gp}if(n.status===gp){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=sn(e.adler,n.pending_buf,n.pending-i,i)),Kn(e),n.pending!==0)return n.last_flush=-1,cn;i=0}n.gzindexi&&(e.adler=sn(e.adler,n.pending_buf,n.pending-i,i))}n.status=vp}if(n.status===vp){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Kn(e),n.pending!==0))return n.last_flush=-1,cn;vt(n,e.adler&255),vt(n,e.adler>>8&255),e.adler=0}if(n.status=Ba,Kn(e),n.pending!==0)return n.last_flush=-1,cn}if(e.avail_in!==0||n.lookahead!==0||t!==ta&&n.status!==Bs){let i=n.level===0?fC(n,t):n.strategy===Hu?SH(n,t):n.strategy===iH?wH(n,t):$s[n.level].func(n,t);if((i===eo||i===ws)&&(n.status=Bs),i===Mn||i===eo)return e.avail_out===0&&(n.last_flush=-1),cn;if(i===_s&&(t===QU?JU(n):t!==eb&&(dp(n,0,0,!1),t===eH&&(Gi(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Kn(e),e.avail_out===0))return n.last_flush=-1,cn}return t!==fr?cn:n.wrap<=0?tb:(n.wrap===2?(vt(n,e.adler&255),vt(n,e.adler>>8&255),vt(n,e.adler>>16&255),vt(n,e.adler>>24&255),vt(n,e.total_in&255),vt(n,e.total_in>>8&255),vt(n,e.total_in>>16&255),vt(n,e.total_in>>24&255)):(Is(n,e.adler>>>16),Is(n,e.adler&65535)),Kn(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?cn:tb)},OH=e=>{if(pu(e))return Gr;const t=e.state.status;return e.state=null,t===Ba?$a(e,tH):cn},AH=(e,t)=>{let n=t.length;if(pu(e))return Gr;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==rs||r.lookahead)return Gr;if(i===1&&(e.adler=Hl(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Gi(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,m=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,is(r);r.lookahead>=ct;){let a=r.strstart,c=r.lookahead-(ct-1);do r.ins_h=na(r,r.ins_h,r.window[a+ct-1]),r.prev[a&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=a,a++;while(--c);r.strstart=a,r.lookahead=ct-1,is(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=ct-1,r.match_available=0,e.next_in=m,e.input=o,e.avail_in=l,r.wrap=i,cn};var PH=kH,IH=pC,MH=hC,LH=dC,RH=TH,DH=EH,FH=OH,BH=AH,$H="pako deflate (from Nodeca project)",ol={deflateInit:PH,deflateInit2:IH,deflateReset:MH,deflateResetKeep:LH,deflateSetHeader:RH,deflate:DH,deflateEnd:FH,deflateSetDictionary:BH,deflateInfo:$H};const NH=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var zH=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)NH(n,r)&&(e[r]=n[r])}}return e},jH=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;Wl[254]=Wl[254]=1;var VH=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,l,m=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 UH=(e,t)=>{if(t<65534&&e.subarray&&mC)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(m&=o===2?31:o===3?15:7;o>1&&r1){l[i++]=65533;continue}m<65536?l[i++]=m:(m-=65536,l[i++]=55296|m>>10&1023,l[i++]=56320|m&1023)}return UH(l,i)},WH=(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+Wl[e[n]]>t?n:t},Gl={string2buf:VH,buf2string:HH,utf8border:WH};function GH(){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 gC=GH;const vC=Object.prototype.toString,{Z_NO_FLUSH:YH,Z_SYNC_FLUSH:KH,Z_FULL_FLUSH:XH,Z_FINISH:qH,Z_OK:rf,Z_STREAM_END:ZH,Z_DEFAULT_COMPRESSION:JH,Z_DEFAULT_STRATEGY:QH,Z_DEFLATED:eW}=bs;function mu(e){this.options=Bf.assign({level:JH,method:eW,chunkSize:16384,windowBits:15,memLevel:8,strategy:QH},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 gC,this.strm.avail_out=0;let n=ol.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==rf)throw new Error(Qa[n]);if(t.header&&ol.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=Gl.string2buf(t.dictionary):vC.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=ol.deflateSetDictionary(this.strm,r),n!==rf)throw new Error(Qa[n]);this._dict_set=!0}}mu.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?qH:YH,typeof e=="string"?n.input=Gl.string2buf(e):vC.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===KH||l===XH)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=ol.deflate(n,l),i===ZH)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=ol.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===rf;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};mu.prototype.onData=function(e){this.chunks.push(e)};mu.prototype.onEnd=function(e){e===rf&&(this.result=Bf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function ug(e,t){const n=new mu(t);if(n.push(e,!0),n.err)throw n.msg||Qa[n.err];return n.result}function tW(e,t){return t=t||{},t.raw=!0,ug(e,t)}function nW(e,t){return t=t||{},t.gzip=!0,ug(e,t)}var rW=mu,iW=ug,aW=tW,oW=nW,sW=bs,lW={Deflate:rW,deflate:iW,deflateRaw:aW,gzip:oW,constants:sW};const Wu=16209,uW=16191;var cW=function(t,n){let r,i,l,m,o,a,c,d,u,f,s,h,g,p,v,y,b,w,S,C,T,k,A,P;const z=t.state;r=t.next_in,A=t.input,i=r+(t.avail_in-5),l=t.next_out,P=t.output,m=l-(n-t.avail_out),o=l+(t.avail_out-257),a=z.dmax,c=z.wsize,d=z.whave,u=z.wnext,f=z.window,s=z.hold,h=z.bits,g=z.lencode,p=z.distcode,v=(1<>>24,s>>>=w,h-=w,w=b>>>16&255,w===0)P[l++]=b&65535;else if(w&16){S=b&65535,w&=15,w&&(h>>=w,h-=w),h<15&&(s+=A[r++]<>>24,s>>>=w,h-=w,w=b>>>16&255,w&16){if(C=b&65535,w&=15,ha){t.msg="invalid distance too far back",z.mode=Wu;break e}if(s>>>=w,h-=w,w=l-m,C>w){if(w=C-w,w>d&&z.sane){t.msg="invalid distance too far back",z.mode=Wu;break e}if(T=0,k=f,u===0){if(T+=c-w,w2;)P[l++]=k[T++],P[l++]=k[T++],P[l++]=k[T++],S-=3;S&&(P[l++]=k[T++],S>1&&(P[l++]=k[T++]))}else{T=l-C;do P[l++]=P[T++],P[l++]=P[T++],P[l++]=P[T++],S-=3;while(S>2);S&&(P[l++]=P[T++],S>1&&(P[l++]=P[T++]))}}else if((w&64)===0){b=p[(b&65535)+(s&(1<>3,r-=S,h-=S<<3,s&=(1<{const a=o.bits;let c=0,d=0,u=0,f=0,s=0,h=0,g=0,p=0,v=0,y=0,b,w,S,C,T,k=null,A;const P=new Uint16Array(To+1),z=new Uint16Array(To+1);let I=null,$,O,Y;for(c=0;c<=To;c++)P[c]=0;for(d=0;d=1&&P[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(u=1;u0&&(e===ab||f!==1))return-1;for(z[1]=0,c=1;crb||e===ob&&v>ib)return 1;for(;;){$=c-g,m[d]+1=A?(O=I[m[d]-A],Y=k[m[d]-A]):(O=32+64,Y=0),b=1<>g)+w]=$<<24|O<<16|Y|0;while(w!==0);for(b=1<>=1;if(b!==0?(y&=b-1,y+=b):y=0,d++,--P[c]===0){if(c===f)break;c=t[n+m[d]]}if(c>s&&(y&C)!==S){for(g===0&&(g=s),T+=u,h=c-g,p=1<rb||e===ob&&v>ib)return 1;S=y&C,i[S]=s<<24|h<<16|T-l|0}}return y!==0&&(i[T+y]=c-g<<24|64<<16|0),o.bits=s,0};var sl=mW;const gW=0,yC=1,bC=2,{Z_FINISH:sb,Z_BLOCK:vW,Z_TREES:Gu,Z_OK:to,Z_STREAM_END:yW,Z_NEED_DICT:bW,Z_STREAM_ERROR:vr,Z_DATA_ERROR:_C,Z_MEM_ERROR:wC,Z_BUF_ERROR:_W,Z_DEFLATED:lb}=bs,$f=16180,ub=16181,cb=16182,fb=16183,db=16184,hb=16185,pb=16186,mb=16187,gb=16188,vb=16189,af=16190,ai=16191,Ud=16192,yb=16193,Hd=16194,bb=16195,_b=16196,wb=16197,Sb=16198,Yu=16199,Ku=16200,Cb=16201,xb=16202,Tb=16203,kb=16204,Eb=16205,Wd=16206,Ob=16207,Ab=16208,jt=16209,SC=16210,CC=16211,wW=852,SW=592,CW=15,xW=CW,Pb=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function TW(){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 fo=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<$f||t.mode>CC?1:0},xC=e=>{if(fo(e))return vr;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=$f,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(wW),t.distcode=t.distdyn=new Int32Array(SW),t.sane=1,t.back=-1,to},TC=e=>{if(fo(e))return vr;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xC(e)},kC=(e,t)=>{let n;if(fo(e))return vr;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?vr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,TC(e))},EC=(e,t)=>{if(!e)return vr;const n=new TW;e.state=n,n.strm=e,n.window=null,n.mode=$f;const r=kC(e,t);return r!==to&&(e.state=null),r},kW=e=>EC(e,xW);let Ib=!0,Gd,Yd;const EW=e=>{if(Ib){Gd=new Int32Array(512),Yd=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(sl(yC,e.lens,0,288,Gd,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;sl(bC,e.lens,0,32,Yd,0,e.work,{bits:5}),Ib=!1}e.lencode=Gd,e.lenbits=9,e.distcode=Yd,e.distbits=5},OC=(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,m,o,a,c,d,u,f,s,h,g,p=0,v,y,b,w,S,C,T,k;const A=new Uint8Array(4);let P,z;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(fo(e)||!e.output||!e.input&&e.avail_in!==0)return vr;n=e.state,n.mode===ai&&(n.mode=Ud),m=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,c=n.hold,d=n.bits,u=o,f=a,k=to;e:for(;;)switch(n.mode){case $f:if(n.wrap===0){n.mode=Ud;break}for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>>8&255,n.check=sn(n.check,A,2,0),c=0,d=0,n.mode=ub;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=jt;break}if((c&15)!==lb){e.msg="unknown compression method",n.mode=jt;break}if(c>>>=4,d-=4,T=(c&15)+8,n.wbits===0&&(n.wbits=T),T>15||T>n.wbits){e.msg="invalid window size",n.mode=jt;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0,n.mode=cb;case cb:for(;d<32;){if(o===0)break e;o--,c+=r[l++]<>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,n.check=sn(n.check,A,4,0)),c=0,d=0,n.mode=fb;case fb:for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>8),n.flags&512&&n.wrap&4&&(A[0]=c&255,A[1]=c>>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0,n.mode=db;case db:if(n.flags&1024){for(;d<16;){if(o===0)break e;o--,c+=r[l++]<>>8&255,n.check=sn(n.check,A,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=hb;case hb: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=sn(n.check,r,s,l)),o-=s,l+=s,n.length-=s),n.length))break e;n.length=0,n.mode=pb;case pb: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=ai;break;case vb:for(;d<32;){if(o===0)break e;o--,c+=r[l++]<>>=d&7,d-=d&7,n.mode=Wd;break}for(;d<3;){if(o===0)break e;o--,c+=r[l++]<>>=1,d-=1,c&3){case 0:n.mode=yb;break;case 1:if(EW(n),n.mode=Yu,t===Gu){c>>>=2,d-=2;break e}break;case 2:n.mode=_b;break;case 3:e.msg="invalid block type",n.mode=jt}c>>>=2,d-=2;break;case yb:for(c>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,c+=r[l++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=jt;break}if(n.length=c&65535,c=0,d=0,n.mode=Hd,t===Gu)break e;case Hd:n.mode=bb;case bb: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),m),o-=s,l+=s,a-=s,m+=s,n.length-=s;break}n.mode=ai;break;case _b:for(;d<14;){if(o===0)break e;o--,c+=r[l++]<>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=jt;break}n.have=0,n.mode=wb;case wb:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[I[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},k=sl(gW,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,k){e.msg="invalid code lengths set",n.mode=jt;break}n.have=0,n.mode=Sb;case Sb:for(;n.have>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=v,d-=v,n.lens[n.have++]=b;else{if(b===16){for(z=v+2;d>>=v,d-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=jt;break}T=n.lens[n.have-1],s=3+(c&3),c>>>=2,d-=2}else if(b===17){for(z=v+3;d>>=v,d-=v,T=0,s=3+(c&7),c>>>=3,d-=3}else{for(z=v+7;d>>=v,d-=v,T=0,s=11+(c&127),c>>>=7,d-=7}if(n.have+s>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=jt;break}for(;s--;)n.lens[n.have++]=T}}if(n.mode===jt)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=jt;break}if(n.lenbits=9,P={bits:n.lenbits},k=sl(yC,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,k){e.msg="invalid literal/lengths set",n.mode=jt;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},k=sl(bC,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,k){e.msg="invalid distances set",n.mode=jt;break}if(n.mode=Yu,t===Gu)break e;case Yu:n.mode=Ku;case Ku:if(o>=6&&a>=258){e.next_out=m,e.avail_out=a,e.next_in=l,e.avail_in=o,n.hold=c,n.bits=d,cW(e,f),m=e.next_out,i=e.output,a=e.avail_out,l=e.next_in,r=e.input,o=e.avail_in,c=n.hold,d=n.bits,n.mode===ai&&(n.back=-1);break}for(n.back=0;p=n.lencode[c&(1<>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>w)],v=p>>>24,y=p>>>16&255,b=p&65535,!(w+v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=w,d-=w,n.back+=w}if(c>>>=v,d-=v,n.back+=v,n.length=b,y===0){n.mode=Eb;break}if(y&32){n.back=-1,n.mode=ai;break}if(y&64){e.msg="invalid literal/length code",n.mode=jt;break}n.extra=y&15,n.mode=Cb;case Cb:if(n.extra){for(z=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=xb;case xb:for(;p=n.distcode[c&(1<>>24,y=p>>>16&255,b=p&65535,!(v<=d);){if(o===0)break e;o--,c+=r[l++]<>w)],v=p>>>24,y=p>>>16&255,b=p&65535,!(w+v<=d);){if(o===0)break e;o--,c+=r[l++]<>>=w,d-=w,n.back+=w}if(c>>>=v,d-=v,n.back+=v,y&64){e.msg="invalid distance code",n.mode=jt;break}n.offset=b,n.extra=y&15,n.mode=Tb;case Tb:if(n.extra){for(z=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=jt;break}n.mode=kb;case kb: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=jt;break}s>n.wnext?(s-=n.wnext,h=n.wsize-s):h=n.wnext-s,s>n.length&&(s=n.length),g=n.window}else g=i,h=m-n.offset,s=n.length;s>a&&(s=a),a-=s,n.length-=s;do i[m++]=g[h++];while(--s);n.length===0&&(n.mode=Ku);break;case Eb:if(a===0)break e;i[m++]=n.length,a--,n.mode=Ku;break;case Wd:if(n.wrap){for(;d<32;){if(o===0)break e;o--,c|=r[l++]<{if(fo(e))return vr;let t=e.state;return t.window&&(t.window=null),e.state=null,to},PW=(e,t)=>{if(fo(e))return vr;const n=e.state;return(n.wrap&2)===0?vr:(n.head=t,t.done=!1,to)},IW=(e,t)=>{const n=t.length;let r,i,l;return fo(e)||(r=e.state,r.wrap!==0&&r.mode!==af)?vr:r.mode===af&&(i=1,i=Hl(i,t,n,0),i!==r.check)?_C:(l=OC(e,t,n,n),l?(r.mode=SC,wC):(r.havedict=1,to))};var MW=TC,LW=kC,RW=xC,DW=kW,FW=EC,BW=OW,$W=AW,NW=PW,zW=IW,jW="pako inflate (from Nodeca project)",fi={inflateReset:MW,inflateReset2:LW,inflateResetKeep:RW,inflateInit:DW,inflateInit2:FW,inflate:BW,inflateEnd:$W,inflateGetHeader:NW,inflateSetDictionary:zW,inflateInfo:jW};function VW(){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 UW=VW;const AC=Object.prototype.toString,{Z_NO_FLUSH:HW,Z_FINISH:WW,Z_OK:Yl,Z_STREAM_END:Kd,Z_NEED_DICT:Xd,Z_STREAM_ERROR:GW,Z_DATA_ERROR:Mb,Z_MEM_ERROR:YW}=bs;function gu(e){this.options=Bf.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 gC,this.strm.avail_out=0;let n=fi.inflateInit2(this.strm,t.windowBits);if(n!==Yl)throw new Error(Qa[n]);if(this.header=new UW,fi.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Gl.string2buf(t.dictionary):AC.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=fi.inflateSetDictionary(this.strm,t.dictionary),n!==Yl)))throw new Error(Qa[n])}gu.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let l,m,o;if(this.ended)return!1;for(t===~~t?m=t:m=t===!0?WW:HW,AC.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=fi.inflate(n,m),l===Xd&&i&&(l=fi.inflateSetDictionary(n,i),l===Yl?l=fi.inflate(n,m):l===Mb&&(l=Xd));n.avail_in>0&&l===Kd&&n.state.wrap>0&&e[n.next_in]!==0;)fi.inflateReset(n),l=fi.inflate(n,m);switch(l){case GW:case Mb:case Xd:case YW:return this.onEnd(l),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||l===Kd))if(this.options.to==="string"){let a=Gl.utf8border(n.output,n.next_out),c=n.next_out-a,d=Gl.buf2string(n.output,a);n.next_out=c,n.avail_out=r-c,c&&n.output.set(n.output.subarray(a,a+c),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(l===Yl&&o===0)){if(l===Kd)return l=fi.inflateEnd(this.strm),this.onEnd(l),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};gu.prototype.onData=function(e){this.chunks.push(e)};gu.prototype.onEnd=function(e){e===Yl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Bf.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function cg(e,t){const n=new gu(t);if(n.push(e),n.err)throw n.msg||Qa[n.err];return n.result}function KW(e,t){return t=t||{},t.raw=!0,cg(e,t)}var XW=gu,qW=cg,ZW=KW,JW=cg,QW=bs,eG={Inflate:XW,inflate:qW,inflateRaw:ZW,ungzip:JW,constants:QW};const{Deflate:UY,deflate:HY,deflateRaw:tG,gzip:WY}=lW,{Inflate:GY,inflate:YY,inflateRaw:nG,ungzip:KY}=eG;var rG=tG,iG=nG;function Lb(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 aG=function(){if(!window.location.search.includes("?"))return;const t=window.location.search.replace("?","").split("&");let n=Lb(t);if(console.log("URL params:",n),n.get("share")){const l=iG(new Uint8Array(atob(n.get("share")).split("").map(m=>m.charCodeAt(0))),{to:"string"});if(!l){Yt().raiseError("Error when trying to decode share parameter!",!1);return}n=Lb(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),fps:Number(n.get("fps")||16),scheduler:n.get("scheduler")||"default"};nn().generateText2Img(r,!1)},oG=10,sG=!1;function bp(e,t,n,r,i=l=>Yt().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(m=>`${m[0]} - ${m[1]}`).join(" | ");return i(`${r}: ${t.message} (${l})`)}function Ta(e,t){const n=e.trim().replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return n.length===0?r:`${n}${r}`}const lG=ls("interrogate",()=>{const e=ie({}),t=ie(!1);async function n(m){Yt().raiseError(m,!1),t.value=!1,e.value={}}async function r(){const m=Rt(),{source_image:o}=e.value;if(!o)return n("Failed to get interrogation ID: No image supplied.");t.value=!0;const a=await fetch(Ta(m.baseURL,"/sdapi/v1/interrogate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image:o.split(",")[1],model:"clip"})}),c=await a.json();!bp(a,c,200,"Failed to get interrogation",n)||(e.value.id=c.id,e.value.status=c.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}}),uG={key:0,style:{"margin-top":"16px"}},cG={key:1,style:{"margin-top":"16px"}},fG={key:2},dG={style:{"margin-top":"8px"}},hG={key:0},pG={key:0},mG={key:1},gG=be({__name:"InterrogationView",setup(e){const t=lG(),n=nn(),r=Yt(),i=ie();async function l(c){if(i.value.clearFiles(),!c.raw.type.includes("image")){r.raiseError("Uploaded file needs to be a image!",!1);return}const d=await Nl(c.raw);t.currentInterrogation.source_image=d,t.interrogateImage()}function m(){n.generateText2Img({prompt:o.value})}const o=ee(()=>t.getFormStatus()),{ellipsis:a}=jS();return(c,d)=>_(t).currentInterrogation.source_image?_(t).currentInterrogation.status?(N(),se("div",fG,[ne("div",dG,[oe(_(Ze),{icon:_(mh),onClick:_(t).resetInterrogation},{default:ue(()=>[...d[1]||(d[1]=[Ne("New Interrogation",-1)])]),_:1},8,["icon","onClick"]),o.value?(N(),ve(_(Ze),{key:0,icon:_(mh),onClick:m,disabled:!o.value},{default:ue(()=>[...d[2]||(d[2]=[Ne("Text2Img (Caption)",-1)])]),_:1},8,["icon","disabled"])):ge("",!0)]),d[4]||(d[4]=ne("h2",{style:{margin:"16px 0 8px 0"}},"Interrogation Results",-1)),oe(_(zo),{src:_(t).currentInterrogation.source_image,alt:"Uploaded Image"},null,8,["src"]),o.value?(N(),se("div",hG,[d[3]||(d[3]=ne("h3",null,"Caption",-1)),o.value?(N(),se("div",mG,[ne("strong",null,Ee(o.value),1)])):(N(),se("div",pG,"Processing"+Ee(_(a)),1))])):ge("",!0)])):(N(),se("div",cG,[ne("strong",null,"Uploading image"+Ee(_(a)),1)])):(N(),se("div",uG,[ne("div",null,[oe(_(Lm),{onChange:l,"auto-upload":!1,limit:1,class:"interrogation-upload",ref_key:"upload",ref:i,multiple:"",drag:""},{default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),d[0]||(d[0]=ne("div",null,[Ne("Drop file here OR "),ne("em",null,"click to upload")],-1))]),_:1},512)])]))}}),vG=on(gG,[["__scopeId","data-v-db184ac6"]]);function yG(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),m=Math.floor(e%86400%3600%60),o=r>0?r+(t?"d":"days"):"",a=i>0?i+(t?"h":"hours"):"",c=l>0?l+(t?"m":"minutes"):"",d=m>0?m+(t?"s":"seconds"):"",u=[];return n!=null&&n.days&&u.push(o),n!=null&&n.hours&&u.push(a),n!=null&&n.minutes&&u.push(c),n!=null&&n.seconds&&u.push(d),u.join(" ")}function _p(e){const t=[];let n=0;for(let r=0;rn&&t.push({type:"literal",text:e.slice(n,r),start:n,end:r});const i=e.indexOf("}",r+1);if(i===-1){t.push({type:"literal",text:e.slice(r),start:r,end:e.length}),n=e.length;break}t.push({type:"expansion",options:e.slice(r+1,i).split("|"),start:r,end:i+1}),n=i+1,r=i}return n{const r=n.type==="literal"?[n.text]:n.options;return t.flatMap(i=>r.map(l=>[...i,l]))},[[]]).map(t=>t.join(""))}function Rb(e){const t=[],n=/]+):([^>]+)>/g;return[e.replace(n,(i,l,m)=>{if(m.trim()==="")return"";const o=Number(m);if(isNaN(o))return"";let a=l,c=!1;const d="|high_noise|";return a.startsWith(d)&&(a=a.substring(d.length),c=!0),t.push({name:a,multiplier:o,...c?{is_high_noise:!0}:{}}),""}),t]}function Db(e,t){const n=e.indexOf(" ### "),r=n===-1?e:e.slice(0,n),i=n===-1?"":e.slice(n),l=/]+):([^>]+)>/g,m="|high_noise|",o=[];for(const c of t)if(c.type==="literal"){if(c.start>=r.length)break;for(const d of c.text.matchAll(l)){const u=d.index;if(u===void 0)continue;const f=c.start+u;if(f>=r.length||d[2].trim()==="")continue;const s=Number(d[2]);if(isNaN(s))continue;const h=d[1];h.startsWith(m)||h.trim()!==""&&o.push({name:h,multiplier:s,start:f,end:Math.min(f+d[0].length,r.length)})}}if(o.length===0)return[e,[]];let a=r;for(let c=o.length-1;c>=0;c--)a=a.slice(0,o[c].start)+a.slice(o[c].end);return[a.replace(/ +/g," ").trim()+i,o.map(c=>({name:c.name,multiplier:c.multiplier}))]}function _G(e,t){const n=e.map(i=>({...i}));let r=n.length;for(;r>0&&n[r-1].lora===""&&n[r-1].multiplier===0;)r--;return t.forEach((i,l)=>{const m=r+l;m{const J=r.cacheVersion,V=(await r.getAvailableSamplers()).map(M=>M.name);return V.length===0?[]:C(V)},[]),o=f0(async()=>{const J=r.cacheVersion,V=(await r.getAvailableSchedulers()).map(M=>M.name);return V.length===0?[]:T(V)},[]),a=ie(""),c=ie([]),d=ie(!1),u=ie(!1);function f(){d.value||u.value||(u.value=!0,r.fetchLoras().then(J=>{J!==null&&(c.value=J,d.value=!0)}).finally(()=>{u.value=!1}))}function s(){c.value=[],d.value=!1}const h=ee(()=>r.loraList.filter(J=>{const E=Number(J.multiplier);return J.lora&&J.lora.trim()!==""&&!isNaN(E)&&E!==0}).length);Te(()=>a.value!==""||h.value>0,J=>{J&&f()},{immediate:!0}),Te(()=>r.cacheVersion,()=>{s(),(a.value!==""||h.value>0)&&f()});const g=ee(()=>{const J=h.value,E=c.value.length;return J===0?d.value?`${E} available`:"":d.value?`${J} enabled, ${E} available`:`${J} enabled`}),p=J=>!!J.lora&&J.lora.trim()!=="",v=ee(()=>r.loraList.filter(p).length);function y(){const J=r.loraList.filter(p);if(J.length===0)return;const E=J.map(V=>{const M=c.value.find(D=>D.path===V.lora||D.name===V.lora),R=Number(V.multiplier),W=isNaN(R)?0:Math.round(R*1e4)/1e4;return``});r.loraList=r.loraList.filter(V=>!p(V)),r.prompt=r.prompt===""?E.join(" "):`${r.prompt} ${E.join(" ")}`}const b=ee(()=>Db(r.prompt,_p(r.prompt))[1].length);function w(){const[J,E]=Db(r.prompt,_p(r.prompt));if(E.length===0)return;const V=E.map(M=>{const R=c.value.find(W=>W.path===M.name||W.name===M.name);return{lora:R?R.path:M.name,multiplier:M.multiplier}});r.loraList=_G(r.loraList,V),r.prompt=J}const S=Tt({prompt:[{required:!0,message:"Please input prompt",trigger:"change"}]});function C(J){return!r.params||!r.params.sampler_name||J.indexOf(r.params.sampler_name)===-1&&(r.params.sampler_name=J[0]),J}function T(J){return!r.params||!r.params.scheduler||J.indexOf(r.params.scheduler)===-1&&(r.params.scheduler=J[0]),J}function k(J){return"Elapsed: "+yG(J,!0,{days:!0,hours:!0,minutes:!0,seconds:!0})}function A(){r.validGeneratorTypes.includes(r.generatorType)||(i.showGeneratorBadge=!1)}function P(J){r.generatorType=J,A(),console.log(J)}function z(){l.showCropPreview=!0,l.updateCropPreview()}function I(){var J;(J=document.getElementById("extra_image_input"))==null||J.click()}function $(){var J;(J=document.getElementById("video_start_frame_input"))==null||J.click()}function O(){var J;(J=document.getElementById("video_end_frame_input"))==null||J.click()}function Y(J){var E;return(E=J.dataUrl)==null?void 0:E.startsWith("data:image")}function ae(){return r.referenceImages.filter(Y).map(J=>J.dataUrl)}function q(J){return r.referenceImages.slice(0,J).filter(Y).length}return A(),aG(),(J,E)=>(N(),se($e,null,[oe(_(R2),{"default-active":_(r).generatorType,collapse:!0,onSelect:P,mode:_(n)?"horizontal":"vertical",class:ce(_(n)?"mobile-generator-types":"generator-types"),style:ze(_(n)?"overflow-x: auto":"")},{default:ue(()=>[oe(Uu,{index:"Text2Img","icon-one":_(JE),"icon-two":_(xu),isMobile:_(n)},null,8,["icon-one","icon-two","isMobile"]),oe(Uu,{index:"Img2Img","icon-one":_(xu),"icon-two":_(xu),isMobile:_(n)},null,8,["icon-one","icon-two","isMobile"]),oe(Uu,{index:"Inpainting","icon-one":zS,"icon-two":_(xu),isMobile:_(n)},null,8,["icon-two","isMobile"]),oe(Uu,{index:"Interrogation","icon-one":v7,isMobile:_(n)},null,8,["isMobile"])]),_:1},8,["default-active","mode","class","style"]),ne("div",wG,[_(r).generatorType==="Interrogation"?(N(),se("div",SG,[E[39]||(E[39]=ne("h1",{style:{margin:"0"}},"Interrogation",-1)),E[40]||(E[40]=ne("div",null,"Interrogate images to get their predicted descriptions.",-1)),oe(vG)])):(N(),ve(_(Em),{key:1,"label-position":"left","label-width":"140px",model:_(r),class:"container",rules:S,onSubmit:E[38]||(E[38]=Qe(()=>{},["prevent"]))},{default:ue(()=>{var V,M,R,W;return[ne("div",CG,[oe(B7),oe(up,{label:"Negative Prompt",prop:"negativePrompt",modelValue:_(r).negativePrompt,"onUpdate:modelValue":E[0]||(E[0]=D=>_(r).negativePrompt=D),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"]),oe(up,{label:"Seed",prop:"seed",modelValue:_(r).params.seed,"onUpdate:modelValue":E[2]||(E[2]=D=>_(r).params.seed=D),placeholder:"Enter seed here",clearable:"","clear-icon":_(XE)},{append:ue(()=>[oe(_(fn),{content:"Randomize!",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(bO),onClick:E[1]||(E[1]=()=>_(r).params.seed=_(PC)())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue","clear-icon"]),(N(),ve(_(vy),{key:0,gutter:10},{default:ue(()=>[_(r).multiSelect.sampler.state==="Multiple"?(N(),ve(_(_o),{key:0,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Sampler(s)",prop:"samplers",modelValue:_(r).multiSelect.sampler.selected,"onUpdate:modelValue":E[3]||(E[3]=D=>_(r).multiSelect.sampler.selected=D),options:_(m),info:"Multi-select enabled. Heun and DPM2 double generation time per step, but converge twice as fast.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.sampler.state==="Enabled"?(N(),ve(_(_o),{key:1,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Sampler",prop:"sampler",modelValue:_(r).params.sampler_name,"onUpdate:modelValue":E[4]||(E[4]=D=>_(r).params.sampler_name=D),options:_(m),info:"Heun and DPM2 double generation time per step, but converge twice as fast."},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.scheduler.state==="Multiple"?(N(),ve(_(_o),{key:2,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Scheduler(s)",prop:"schedulers",modelValue:_(r).multiSelect.scheduler.selected,"onUpdate:modelValue":E[5]||(E[5]=D=>_(r).multiSelect.scheduler.selected=D),options:_(o),info:"Multi-select enabled. Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise.",multiple:""},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0),_(r).multiSelect.scheduler.state==="Enabled"?(N(),ve(_(_o),{key:3,span:_(n)?24:12},{default:ue(()=>[oe(Mo,{label:"Scheduler",prop:"scheduler",modelValue:_(r).params.scheduler,"onUpdate:modelValue":E[6]||(E[6]=D=>_(r).params.scheduler=D),options:_(o),info:"Experimental! KoboldCpp only, allows you to use a different scheduler. Leave as default otherwise."},null,8,["modelValue","options"])]),_:1},8,["span"])):ge("",!0)]),_:1})),oe(bn,{label:"Batch Size",prop:"batchSize",modelValue:_(r).params.n,"onUpdate:modelValue":E[7]||(E[7]=D=>_(r).params.n=D),min:_(r).minImages,max:_(r).maxImages},null,8,["modelValue","min","max"]),_(r).multiSelect.steps.state==="Multiple"?(N(),ve(bn,{key:1,label:"Steps(s)",prop:"multiSteps",modelValue:_(r).multiSelect.steps.selected,"onUpdate:modelValue":E[8]||(E[8]=D=>_(r).multiSelect.steps.selected=D),min:_(r).minSteps,max:_(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"])):_(r).multiSelect.steps.state==="Enabled"?(N(),ve(bn,{key:2,label:"Steps",prop:"steps",modelValue:_(r).params.steps,"onUpdate:modelValue":E[9]||(E[9]=D=>_(r).params.steps=D),min:_(r).minSteps,max:_(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"])):ge("",!0),oe(bn,{label:"Width",prop:"width",modelValue:_(r).params.width,"onUpdate:modelValue":E[10]||(E[10]=D=>_(r).params.width=D),min:_(r).minDimensions,max:_(r).maxDimensions,step:64,change:z},null,8,["modelValue","min","max"]),oe(bn,{label:"Height",prop:"height",modelValue:_(r).params.height,"onUpdate:modelValue":E[11]||(E[11]=D=>_(r).params.height=D),min:_(r).minDimensions,max:_(r).maxDimensions,step:64,change:z},null,8,["modelValue","min","max"]),_(r).multiSelect.guidance.state==="Multiple"?(N(),ve(bn,{key:3,label:"Guidance(s)",prop:"cfgScales",modelValue:_(r).multiSelect.guidance.selected,"onUpdate:modelValue":E[12]||(E[12]=D=>_(r).multiSelect.guidance.selected=D),min:_(r).minCfgScale,max:_(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"])):_(r).multiSelect.guidance.state==="Enabled"?(N(),ve(bn,{key:4,label:"Guidance (CFG)",prop:"cfgScale",modelValue:_(r).params.cfg_scale,"onUpdate:modelValue":E[13]||(E[13]=D=>_(r).params.cfg_scale=D),min:_(r).minCfgScale,max:_(r).maxCfgScale,step:.5,info:"Classifier Free Guidance (CFG Scale). Higher values will make the AI respect your prompt more. Lower values allow the AI to be more creative."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.eta.state==="Enabled"?(N(),ve(bn,{key:5,label:"Eta",prop:"eta",modelValue:_(r).params.eta,"onUpdate:modelValue":E[14]||(E[14]=D=>_(r).params.eta=D),min:_(r).minEta,max:_(r).maxEta,step:.1,info:"Noise multiplier for ancestral samplers. 0 disables noise injection."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.flowShift.state==="Enabled"?(N(),ve(bn,{key:6,label:"Flow Shift",prop:"flowShift",modelValue:_(r).params.flow_shift,"onUpdate:modelValue":E[15]||(E[15]=D=>_(r).params.flow_shift=D),min:_(r).minFlowShift,max:_(r).maxFlowShift,step:.5,info:"Override shift value for flow models."},null,8,["modelValue","min","max"])):ge("",!0),_(r).multiSelect.clipSkip.state==="Multiple"?(N(),ve(bn,{key:7,label:"CLIP Skip(s)",prop:"clipSkips",modelValue:_(r).multiSelect.clipSkip.selected,"onUpdate:modelValue":E[16]||(E[16]=D=>_(r).multiSelect.clipSkip.selected=D),min:_(r).minClipSkip,max:_(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"])):_(r).multiSelect.clipSkip.state==="Enabled"?(N(),ve(bn,{key:8,label:"CLIP Skip",prop:"clipSkip",modelValue:_(r).params.clip_skip,"onUpdate:modelValue":E[17]||(E[17]=D=>_(r).params.clip_skip=D),min:_(r).minClipSkip,max:_(r).maxClipSkip,info:"Last layers of CLIP to ignore. For most situations this can be left alone."},null,8,["modelValue","min","max"])):ge("",!0),_(r).sourceGeneratorTypes.includes(_(r).generatorType)?(N(),ve(bn,{key:9,label:"Init Strength",prop:"denoise",modelValue:_(r).params.denoising_strength,"onUpdate:modelValue":E[18]||(E[18]=D=>_(r).params.denoising_strength=D),min:_(r).minDenoise,max:_(r).maxDenoise,step:.01,info:"The final image will diverge from the starting image at higher values. 0=unchanged, 1=fullychanged"},null,8,["modelValue","min","max"])):ge("",!0),oe(bn,{label:"Video Frames",prop:"frames",modelValue:_(r).params.frames,"onUpdate:modelValue":E[19]||(E[19]=D=>_(r).params.frames=D),min:_(r).minFrames,max:_(r).maxFrames,info:"Number of consecutive video frames to generate (Video models only). More frames increases memory usage."},null,8,["modelValue","min","max"]),_(r).params.frames>1?(N(),ve(bn,{key:10,label:"FPS",prop:"fps",modelValue:_(r).params.fps,"onUpdate:modelValue":E[20]||(E[20]=D=>_(r).params.fps=D),min:_(r).minFps,max:_(r).maxFps,disabled:_(r).params.frames<=1,info:"Frames per second for video generation."},null,8,["modelValue","min","max","disabled"])):ge("",!0),_(r).generatorType==="Text2Img"?(N(),se("div",{key:11,class:"reference-images",onDragover:E[23]||(E[23]=Qe(()=>{},["prevent"])),onDrop:E[24]||(E[24]=Qe(D=>_(r).setExtraImage(D),["prevent"]))},[ne("div",xG,[E[43]||(E[43]=ne("span",{class:"reference-images-label"},"Reference Media",-1)),ne("div",TG,[ne("input",{class:"reference-images-input",type:"file",id:"extra_image_input",onChange:E[21]||(E[21]=D=>_(r).setExtraImage(D)),accept:"image/*,audio/*",multiple:""},null,32),oe(_(Ze),{onClick:I},{default:ue(()=>[...E[41]||(E[41]=[Ne(" Select or Drag Files ",-1)])]),_:1}),oe(_(Ze),{onClick:E[22]||(E[22]=D=>_(r).clearExtraImage()),disabled:_(r).referenceImages.length===0},{default:ue(()=>[...E[42]||(E[42]=[Ne(" Clear Files ",-1)])]),_:1},8,["disabled"])])]),_(r).referenceImages.length>0?(N(),se("div",kG,[(N(!0),se($e,null,$t(_(r).referenceImages,(D,B)=>(N(),se("div",{class:ce(["reference-image-item",{"reference-file-item":!Y(D)}]),key:D.id},[ne("span",EG,Ee(B+1),1),Y(D)?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:D.dataUrl,fit:"cover","preview-src-list":ae(),"initial-index":q(B),"preview-teleported":""},null,8,["src","preview-src-list","initial-index"])):ge("",!0),ne("span",{class:"reference-image-name",title:D.name},Ee(D.name),9,OG),ne("div",AG,[oe(_(fn),{content:"Move up",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",icon:_(ph),disabled:B===0,onClick:Z=>_(r).moveExtraImage(B,-1)},null,8,["icon","disabled","onClick"])]),_:2},1024),oe(_(fn),{content:"Move down",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",icon:_(Yo),disabled:B===_(r).referenceImages.length-1,onClick:Z=>_(r).moveExtraImage(B,1)},null,8,["icon","disabled","onClick"])]),_:2},1024),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",onClick:Z=>_(r).removeExtraImage(B)},null,8,["icon","onClick"])]),_:2},1024)])],2))),128))])):(N(),se("div",PG," No reference images selected. "))],32)):ge("",!0),_(r).generatorType==="Text2Img"&&_(r).params.frames>1?(N(),se("div",IG,[ne("div",MG,[ne("input",{class:"reference-images-input",type:"file",id:"video_start_frame_input",onChange:E[25]||(E[25]=D=>_(r).setVideoStartFrame(D)),accept:"image/*"},null,32),E[45]||(E[45]=ne("span",{class:"video-frame-label"},"Video Start Frame",-1)),_(r).videoStartFrame?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:_(r).videoStartFrame.dataUrl,fit:"cover","preview-teleported":""},null,8,["src"])):(N(),se("div",LG)),ne("span",{class:"video-frame-name",title:((V=_(r).videoStartFrame)==null?void 0:V.name)||"No image selected"},Ee(((M=_(r).videoStartFrame)==null?void 0:M.name)||"No image selected"),9,RG),ne("div",DG,[oe(_(Ze),{onClick:$},{default:ue(()=>[...E[44]||(E[44]=[Ne(" Select Image ",-1)])]),_:1}),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",disabled:!_(r).videoStartFrame,onClick:E[26]||(E[26]=D=>_(r).clearVideoStartFrame())},null,8,["icon","disabled"])]),_:1})])]),ne("div",FG,[ne("input",{class:"reference-images-input",type:"file",id:"video_end_frame_input",onChange:E[27]||(E[27]=D=>_(r).setVideoEndFrame(D)),accept:"image/*"},null,32),E[47]||(E[47]=ne("span",{class:"video-frame-label"},"Video End Frame",-1)),_(r).videoEndFrame?(N(),ve(_(zo),{key:0,class:"reference-image-thumb",src:_(r).videoEndFrame.dataUrl,fit:"cover","preview-teleported":""},null,8,["src"])):(N(),se("div",BG)),ne("span",{class:"video-frame-name",title:((R=_(r).videoEndFrame)==null?void 0:R.name)||"No image selected"},Ee(((W=_(r).videoEndFrame)==null?void 0:W.name)||"No image selected"),9,$G),ne("div",NG,[oe(_(Ze),{onClick:O},{default:ue(()=>[...E[46]||(E[46]=[Ne(" Select Image ",-1)])]),_:1}),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{class:"small-btn",type:"danger",icon:_(Yi),plain:"",disabled:!_(r).videoEndFrame,onClick:E[28]||(E[28]=D=>_(r).clearVideoEndFrame())},null,8,["icon","disabled"])]),_:1})])])])):ge("",!0),oe(_(vy),null,{default:ue(()=>[oe(_(_o),{span:_(n)?24:12},{default:ue(()=>[oe(Hy,{label:"ESRGAN Upscale",prop:"enable_hr",modelValue:_(r).params.enable_hr,"onUpdate:modelValue":E[29]||(E[29]=D=>_(r).params.enable_hr=D),info:"Enable upscale with ESRGAN."},null,8,["modelValue"])]),_:1},8,["span"]),oe(_(_o),{span:_(n)?24:12},{default:ue(()=>[_(r).generatorType==="Img2Img"?(N(),ve(Hy,{key:0,label:"Send as RefImg",prop:"send_as_refimg",modelValue:_(r).params.send_as_refimg,"onUpdate:modelValue":E[30]||(E[30]=D=>_(r).params.send_as_refimg=D),info:"Instead of regular Img2Img, send the image as a reference image for edit models."},null,8,["modelValue"])):ge("",!0)]),_:1},8,["span"])]),_:1}),oe(_(oD),{modelValue:a.value,"onUpdate:modelValue":E[32]||(E[32]=D=>a.value=D),class:"lora-list-collapse"},{default:ue(()=>[oe(_(sD),{name:"lora-list"},{title:ue(()=>[E[48]||(E[48]=ne("span",{class:"lora-list-title"},"LoRAs",-1)),ne("span",zG,Ee(g.value),1)]),default:ue(()=>[d.value&&c.value.length===0?(N(),se("div",jG," No LoRAs were returned by the server. ")):ge("",!0),(N(!0),se($e,null,$t(_(r).loraList,(D,B)=>(N(),se("div",{key:B,class:"lora-list-row"},[oe(_(Im),{modelValue:D.lora,"onUpdate:modelValue":Z=>D.lora=Z,class:"lora-list-select",filterable:"",placeholder:"Select a LoRA"},{default:ue(()=>[oe(_(Hc),{value:""}),(N(!0),se($e,null,$t(c.value,Z=>(N(),ve(_(Hc),{key:Z.path,label:Z.name,value:Z.path},null,8,["label","value"]))),128))]),_:1},8,["modelValue","onUpdate:modelValue"]),oe(_(Uc),{modelValue:D.multiplier,"onUpdate:modelValue":Z=>D.multiplier=Z,step:.05,precision:2,"controls-position":"right"},null,8,["modelValue","onUpdate:modelValue"]),oe(_(fn),{content:"Remove",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(Yi),plain:"",onClick:Z=>_(r).removeLoraRow(B)},null,8,["icon","onClick"])]),_:2},1024)]))),128)),ne("div",VG,[oe(_(Ze),{icon:_(bf),onClick:E[31]||(E[31]=D=>_(r).addLoraRow()),disabled:c.value.length===0},{default:ue(()=>[...E[49]||(E[49]=[Ne(" Add LoRA ",-1)])]),_:1},8,["icon","disabled"]),oe(_(Ze),{icon:_(ph),onClick:y,disabled:v.value===0},{default:ue(()=>[...E[50]||(E[50]=[Ne(" To Prompt ",-1)])]),_:1},8,["icon","disabled"]),oe(_(Ze),{icon:_(Yo),onClick:w,disabled:b.value===0},{default:ue(()=>[...E[51]||(E[51]=[Ne(" From Prompt ",-1)])]),_:1},8,["icon","disabled"])])]),_:1})]),_:1},8,["modelValue"])]),ne("div",UG,[oe(_(Ze),{onClick:E[33]||(E[33]=()=>{_(r).cancelled=!0,_(r).generating=!1,_(r).resetStore()}),class:"reset-btn"},{default:ue(()=>[...E[52]||(E[52]=[Ne("Reset",-1)])]),_:1}),oe(_(Ze),{type:"primary",class:"generate-cancel-btn",style:ze(_(r).generating?"width: 55%;":""),onClick:E[34]||(E[34]=()=>_(r).generateImage(_(r).generatorType))},{default:ue(()=>[ne("span",null," Generate "+Ee(_(r).totalImageCount)+" image"+Ee(_(r).totalImageCount===1?"":"s"),1)]),_:1},8,["style"]),_(r).generating?(N(),ve(_(Ze),{key:0,type:"danger",class:"generate-cancel-btn",style:{width:"25%"},disabled:_(r).cancelled,onClick:E[35]||(E[35]=()=>{var D;(D=_(r).abortController)==null||D.abort(),_(r).cancelled=!0,_(r).generating=!1,_(r).clearQueue(),_(r).clearLastImageGenkey(),_(r).stopProgressPolling()})},{default:ue(()=>[...E[53]||(E[53]=[Ne("Cancel all",-1)])]),_:1},8,["disabled"])):ge("",!0)]),ne("div",HG,[oe(_(lR),{class:"center-both generated-image"},{default:ue(()=>{var D,B,Z,H,Q;return[!_(r).generating&&_(r).outputs.length==0?(N(),se("div",WG,[/Inpainting/.test(_(r).generatorType)?(N(),ve(Gy,{key:0})):ge("",!0),/Img2Img/.test(_(r).generatorType)?(N(),ve(Gy,{key:1})):ge("",!0)])):ge("",!0),!_(i).showGeneratedImages&&_(r).generating?(N(),ve(A7,{key:1,generated:_(r).outputs.length,total:_(r).queue.length,elapsed:k(_(r).timer.seconds),"progress-percentage":(D=_(r).progressInfo)==null?void 0:D.percentage,"text-info":(B=_(r).progressInfo)==null?void 0:B.textInfo,"current-step":(Z=_(r).progressInfo)==null?void 0:Z.currentStep,"total-steps":(H=_(r).progressInfo)==null?void 0:H.totalSteps,"preview-image":(Q=_(r).progressInfo)==null?void 0:Q.previewImage,generating:_(r).generating,onShowGenerated:E[36]||(E[36]=te=>_(i).showGeneratedImages=!0)},null,8,["generated","total","elapsed","progress-percentage","text-info","current-step","total-steps","preview-image","generating"])):ge("",!0),_(i).showGeneratedImages&&_(r).outputs.length!==0?(N(),ve(W7,{key:2})):ge("",!0)]}),_:1}),_(r).lastImageRecoveryAvailable?(N(),ve(_(o$),{key:0,class:"last-image-recovery",href:_(r).lastImageRecoveryUrl,target:"_blank",type:"primary",onClick:E[37]||(E[37]=Qe(D=>_(r).openLastImageRecovery(),["prevent"]))},{default:ue(()=>[...E[54]||(E[54]=[Ne(" Recover last generated image ",-1)])]),_:1},8,["href"])):ge("",!0)])]}),_:1},8,["model","rules"]))])],64))}}),ll=DE({history:fE("/"),routes:[{path:"/",name:"generate",component:GG},{path:"/images",name:"images",component:()=>Ld(()=>Promise.resolve().then(()=>EY),void 0)},{path:"/about",name:"about",component:()=>Ld(()=>Promise.resolve().then(()=>DY),void 0)},{path:"/options",name:"options",component:()=>Ld(()=>Promise.resolve().then(()=>$Y),void 0)},{path:"/return",name:"return",redirect:e=>(window.location.href=window.location.pathname.endsWith("/")?"..":".","/")}]});function Xu(){return{steps:20,n:1,sampler_name:"Euler",width:512,height:512,cfg_scale:5,eta:1,flow_shift:0,clip_skip:0,seed:-1,denoising_strength:.6,frames:1,fps:16,enable_hr:!1,send_as_refimg:!0,scheduler:"default"}}function PC(){return Math.floor(Math.random()*9999999)+1}function YG(){return Math.floor(Math.random()*9e5+1e5).toString()}const nn=ls("generator",()=>{const e=["Text2Img","Img2Img","Inpainting"],t=["Img2Img","Inpainting"],n=ie("Text2Img"),r=ie(""),i=un("promptHistory",[]),l=ie(""),m=un("negativeLibrary",[]),o=ie(Xu()),a=ie({interval:0,seconds:0}),c=ie(null),d=ie(0),u=ie({sampler:{name:"Sampler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.sampler_name],mapToParam:we=>we.sampler_name},scheduler:{name:"Scheduler",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.scheduler],mapToParam:we=>we.scheduler},steps:{name:"Steps",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.steps],mapToParam:we=>we.steps},guidance:{name:"CFG Scale",state:"Enabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.cfg_scale],mapToParam:we=>we.cfg_scale},clipSkip:{name:"Clip Skip",state:"Disabled",allowedStates:["Disabled","Enabled","Multiple"],selected:[o.value.clip_skip],mapToParam:we=>we.clip_skip},eta:{name:"Eta",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.eta],mapToParam:we=>we.eta},flowShift:{name:"Flow Shift",state:"Disabled",allowedStates:["Disabled","Enabled"],selected:[o.value.flow_shift],mapToParam:we=>we.flow_shift}}),f=()=>({sourceProcessing:void 0,sourceImage:void 0,maskImage:void 0}),s=ie({...f(),sourceProcessing:"inpainting"}),h=ie({...f(),sourceProcessing:"img2img"}),g=we=>we==="Inpainting"?s.value:we==="Img2Img"?h.value:f(),p=ee(()=>g(n.value)),v=ie(""),y=ie(!1),b=ie(!1),w=ie([]),S=ie(null),C=ie([]),T=un("lastImageGenkey",""),k=ee(()=>T.value?Ta(Rt().baseURL,`/sdapi/v1/get_last.png?genkey=${encodeURIComponent(T.value)}`):""),A=ee(()=>k.value!==""&&!y.value);function P(){T.value=""}function z(){!k.value||(window.open(k.value,"_blank","noopener"),P())}const I=ie(64),$=ee(()=>Rt().allowLargerParams==="Enabled"?3072:1024),O=ie(1),Y=ie(20),ae=ie(1),q=ee(()=>Rt().allowLargerParams==="Enabled"?150:50),J=ie(1),E=ie(24),V=ie(0),M=ie(1),R=ie(0),W=ie(20),D=ie(0),B=ie(1),Z=ie(0),H=ie(10),Q=ie(1),te=ee(()=>Rt().allowLargerParams==="Enabled"?400:200),fe=ie(16),me=ee(()=>Rt().allowLargerParams==="Enabled"?32:24),_e=(we,je,He)=>Array.from({length:(je-we+1)/He},(et,ot)=>(ot+we)*He),j=ie(_e(Z.value,H.value,1)),x=ie(_e(J.value,E.value,.5)),U=ee(()=>{const we=(Dn,tn,Ii=1)=>Dn*(tn.state==="Multiple"&&tn.selected.length>0?tn.selected.length:Ii),He=o.value.n*Oe().length,et=we(He,u.value.sampler),ot=we(et,u.value.scheduler),Je=we(ot,u.value.steps),It=we(Je,u.value.guidance);return we(It,u.value.clipSkip)});function K(){return o.value=Xu(),s.value=f(),h.value=f(),ho.value=null,po.value=null,w.value=[],kn.value=[],Yt().showGeneratedImages=!1,L(),P(),!0}function L(){C.value=[]}function F(){w.value=[]}async function X(){const we=await Ut("/sdapi/v1/loras");return Array.isArray(we)?we:null}async function de(we){var yg,bg;if(!e.includes(we))return[];if(r.value==="")return G("Failed to generate: No prompt submitted.");const je=il(),He=Yt();je.saveImages();const{sourceImage:et,maskImage:ot,sourceProcessing:Je}=g(we);yn(r.value);const It=[],Dn=Oe().map(We=>{const pt=We.split(" ### ");return{prompt:pt[0],negative_prompt:pt[1]||""}}).map(We=>{const[pt,Xt]=Rb(We.prompt);return{...We,prompt:pt,extractedLoras:Xt}}),tn=Dn.some(We=>We.extractedLoras.length>0)||kn.value.some(We=>We.lora&&We.lora.trim()!=="")?(yg=await X())!=null?yg:[]:[],Ii=kn.value.filter(We=>We.lora&&We.lora.trim()!=="").flatMap(We=>{const pt=tn.find(Bn=>Bn.name===We.lora||Bn.path===We.lora),Xt=Number(We.multiplier);return[{name:pt?pt.name:We.lora,multiplier:isNaN(Xt)?0:Xt,allowUnresolved:!1}]}),Fn=We=>{const pt=new Map;for(const Xt of We){if(!Xt.name||Xt.name.trim()==="")continue;const Bn=`${Xt.name}\0${Xt.is_high_noise?1:0}`,sr=pt.get(Bn);sr?(sr.multiplier=Math.round((sr.multiplier+Xt.multiplier)*1e4)/1e4,sr.allowUnresolved=sr.allowUnresolved||Xt.allowUnresolved):pt.set(Bn,{...Xt})}return[...pt.values()]},ga=Dn.map(({extractedLoras:We,...pt})=>{const Xt=Fn([...We.map(Ht=>({name:Ht.name,multiplier:Ht.multiplier,...Ht.is_high_noise?{is_high_noise:!0}:{},allowUnresolved:!0})),...Ii]),Bn=Xt.flatMap(Ht=>{if(Ht.multiplier===0)return[];const yu=tn.find(wg=>wg.name===Ht.name||wg.path===Ht.name),_g=yu?yu.path:Ht.allowUnresolved?Ht.name:"";return _g?[{path:_g,multiplier:Ht.multiplier,...Ht.is_high_noise?{is_high_noise:!0}:{}}]:[]}),sr=Xt.map(Ht=>``),va=[sr.length>0?pt.prompt.replace(/ +/g," ").trim():pt.prompt,sr.join(" ")].filter(Ht=>Ht!=="").join(" "),go=pt.negative_prompt!==""?`${va} ### ${pt.negative_prompt}`:va;return{...pt,full_prompt:go,...Bn.length>0?{lora:Bn}:{}}}),{seed:vu,cfg_scale:or,eta:hg,steps:ei,clip_skip:WC,flow_shift:pg,sampler_name:GC,scheduler:YC,n:KC,...mg}=o.value,Vf=parseInt(vu.toString()),XC=isNaN(Vf)||Vf<0?PC():Vf,qC=Array.from({length:KC},(We,pt)=>XC+pt),mo=(We,pt)=>We.state==="Disabled"?[]:We.state==="Enabled"?[pt]:We.state==="Multiple"&&We.selected.length===0?[]:We.selected,ZC={promptVariant:ga,seed:qC,cfg_scale:mo(u.value.guidance,or),eta:mo(u.value.eta,hg),steps:mo(u.value.steps,ei),clip_skip:mo(u.value.clipSkip,WC),sampler_name:mo(u.value.sampler,GC),scheduler:mo(u.value.scheduler,YC)},JC=(We=>Object.entries(We).filter(([Xt,Bn])=>Bn.length>0).reduce((Xt,[Bn,sr])=>{const zt=[];for(const va of Xt)for(const go of sr)zt.push({...va,[Bn]:go});return zt},[{}]))(ZC),QC=[await Ce()];for(const We of JC){const{promptVariant:{full_prompt:pt,...Xt},...Bn}=We,sr=we==="Img2Img"?mg.send_as_refimg:!1,zt={prompt:pt,params:{...mg,send_as_refimg:sr,...Bn,...Xt,init_images:et?[et.split(",")[1]]:[],mask:ot,inpainting_mask_invert:ot?0:null,inpainting_fill:ot?1:null},source_image:et==null?void 0:et.split(",")[1],source_mask:ot,source_processing:Je,models:QC};zt.params.sampler_name=="default"&&delete zt.params.sampler_name,zt.params.scheduler=="default"&&delete zt.params.scheduler,!zt.params.frames||zt.params.frames<=1?(delete zt.params.frames,delete zt.params.fps):zt.params.fps=Math.min(me.value,Math.max(fe.value,Math.round(Number(zt.params.fps)||Xu().fps)));const va=we==="Text2Img",go=va?Dr.value.map(yu=>yu.base64):[];go.length>0&&(zt.params.extra_images=go),va&&zt.params.frames&&zt.params.frames>1&&(ho.value&&(zt.params.video_start_frame=ho.value.base64),po.value&&(zt.params.video_end_frame=po.value.base64)),Rt().alsoRequestAvi==="Enabled"&&zt.params.frames&&zt.params.frames>1&&(zt.params.video_output_type=2);const Ht={};u.value.flowShift.state==="Enabled"&&pg>0&&(Ht.params={flow_shift:pg}),Rt().keepImageGenOnDisconnect==="Enabled"&&(Ht.keep_image_gen_on_disconnect=!0),Object.keys(Ht).length>0&&(zt.params.kcpp_extra_args=Ht),It.push(zt)}let gg=!1;y.value||(gg=!0,w.value=[]),y.value=!0,He.showGeneratedImages=!1;let vg=C.value.filter(We=>!We.gathered&&!We.failed).length;for(let We=0;We{a.value.seconds++},1e3),HC();!C.value.every(We=>We.gathered||We.failed)&&!b.value;){const We=C.value.find(pt=>!pt.gathered&&!pt.failed);if(!We)break;We.gathered=!0;try{const pt=await Le(We.params,(bg=S.value)==null?void 0:bg.signal);if(!pt){We.failed=!0;continue}le([{...pt,...We}])}catch(pt){We.failed=!0,console.error("Error fetching image:",pt)}}C.value.some(We=>We.failed)&&C.value.every(We=>We.gathered||We.failed)&&(y.value=!1,clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0,jf(),C.value=[])}}async function le(we){const je=Ja();console.log(we);const He=await Promise.all(we.map(async Je=>{var ga,vu;const It=Je.images[0],Dn=!!Je.animated?"gif":"png",tn=Je.extra_data?`data:video/avi;base64,${Je.extra_data}`:"",Ii=Je.final_frame?`data:image/jpeg;base64,${Je.final_frame}`:"",Fn={id:-1,image:`data:image/${Dn};base64,${It}`,prompt:Je.prompt,modelName:Je.models[0],frames:Je.params.frames,fps:Je.params.fps,extra_avi:tn,final_frame:Ii,enable_hr:Je.params.enable_hr,send_as_refimg:Je.params.send_as_refimg,flow_shift:(vu=(ga=Je.params.kcpp_extra_args)==null?void 0:ga.params)==null?void 0:vu.flow_shift,lora_meta:""};if(Je.info&&typeof Je.info=="string"&&Je.info.trim()!=="")try{const or=JSON.parse(Je.info);["seed","steps","sampler_name","cfg_scale","eta","width","height","clip_skip","fps"].forEach(ei=>{or[ei]!=null&&or[ei]!=null?Fn[ei]=or[ei]:Je.params[ei]!=null&&(Fn[ei]=Je.params[ei])}),or.extra_generation_params&&or.extra_generation_params["Schedule type"]?Fn.scheduler=or.extra_generation_params["Schedule type"]:Fn.scheduler=Je.params.scheduler,or.lora_meta&&(Fn.lora_meta=or.lora_meta)}catch(or){console.warn("Failed to parse info JSON:",or)}return Fn})),et=await je.pushOutputs(He),ot=0;return w.value=[...et.map(Je=>({type:"image",index:ot,output:Je})),...w.value].sort((Je,It)=>Je.index-It.index),w.value.length===C.value.length&&(C.value=[],y.value=!1,Yt().showGeneratedImages=!0,P(),clearInterval(a.value.interval),a.value.interval=0,a.value.seconds=0,jf()),He}async function G(we){const je=Yt();return we&&je.raiseError(we,!1),[]}function pe(we,je,He,et){return je<=He?je:(Yt().raiseWarning(`This image was generated using the 'Larger Values' option. Setting '${we}' to its default value instead of ${je}.`,!0),et)}async function re(we,je=!0){var et;const He=Xu();if(n.value="Text2Img",u.value.guidance.state="Enabled",u.value.sampler.state="Enabled",u.value.steps.state="Enabled",u.value.clipSkip.state="Disabled",u.value.scheduler.state="Enabled",ll.push("/"),je&&(we.width=we.width||He.width,we.height=we.height||He.height),we.prompt){const ot=we.prompt.split(" ### ");r.value=ot[0],l.value=ot[1]||"";const[,Je]=Rb(r.value);if(Je.length>0){const It=(et=await X())!=null?et:[];kn.value=kn.value.filter(en=>!en.lora||en.lora.trim()===""?!0:!Je.some(Dn=>Dn.name===en.lora||It.some(tn=>tn.name===Dn.name&&tn.path===en.lora)))}}if(we.sampler_name){o.value.sampler_name=we.sampler_name;const Je=(await it()).find(It=>It.aliases&&It.aliases.includes(we.sampler_name));Je&&(o.value.sampler_name=Je.name)}we.steps&&(o.value.steps=pe("steps",we.steps,q.value,He.steps)),we.cfg_scale&&(o.value.cfg_scale=we.cfg_scale),(we.eta||we.eta===0)&&(o.value.eta=we.eta),(we.flow_shift||we.flow_shift===0)&&(o.value.flow_shift=we.flow_shift,u.value.flowShift.state=we.flow_shift>0?"Enabled":"Disabled"),we.width&&(o.value.width=pe("width",we.width,$.value,He.width)),we.height&&(o.value.height=pe("height",we.height,$.value,He.height)),we.seed&&(o.value.seed=we.seed),we.clip_skip&&(o.value.clip_skip=pe("clip_skip",we.clip_skip,H.value,He.clip_skip)),we.scheduler&&(o.value.scheduler=we.scheduler),we.frames&&(o.value.frames=pe("frames",we.frames,te.value,He.frames)),we.fps&&(o.value.fps=Math.min(me.value,Math.max(fe.value,Math.round(pe("fps",we.fps,me.value,He.fps)))))}function he(we){const je=il();n.value="Img2Img",h.value.sourceImage=we,je.drawing=!1,w.value=[],ll.push("/"),cr.fabric.Image.fromURL(we,je.newImage)}function Se(we){const je=il();w.value=[],s.value.sourceImage=we,n.value="Inpainting",ll.push("/"),cr.fabric.Image.fromURL(we,je.newImage)}function xe(){return l.value===""?r.value:`${r.value} ### ${l.value}`}function Oe(){const we=xe();return bG(_p(we))}async function Le(we,je){const He=Rt();try{const et=YG();T.value=et;const ot={...we,genkey:et},Je=await fetch(Ta(He.baseURL,`/sdapi/v1/${we.init_images.length>0?"img":"txt"}2img`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ot),signal:je}),It=await Je.json();return bp(Je,It,200,"Failed to fetch",ye)?It:!1}catch{return!1}}function ye(we){return Yt().raiseError(we,!1),b.value=!1,w.value=[],!1}async function Ce(){const we=Rt(),je=await fetch(Ta(we.baseURL,"/sdapi/v1/sd-models")),He=await je.json();if(!!bp(je,He,200,"Failed to get available models"))return He.length===0?"(No model loaded)":He[0].model_name}const Me=ie(0),Ie=new Map;function ht(){Ie.clear(),Me.value++}Te(()=>Rt().baseURL,()=>{ht()});async function Ut(we){const je=Rt(),He=Ta(je.baseURL,we);if(Ie.has(He))return Ie.get(He);const et=(async()=>{try{const ot=await fetch(He);if(ot.ok)return await ot.json();console.error(`API Error: ${ot.status} ${ot.statusText} at ${He}`)}catch(ot){console.error(`Fetch error for ${He}:`,ot)}return Ie.delete(He),null})();return Ie.set(He,et),et}async function it(){const we=await Ut("/sdapi/v1/samplers");return Array.isArray(we)?we:[]}async function Ft(){const we=await Ut("/sdapi/v1/schedulers");return Array.isArray(we)?we:[]}function Qt(we){m.value.indexOf(we)===-1&&(m.value=[...m.value,we])}function _r(we){m.value=m.value.filter(je=>je!=we)}function yn(we){if(i.value.findIndex(je=>je.prompt===we)===-1){if(i.value.length>=10+i.value.filter(je=>je.starred).length){const je=i.value.filter(et=>!et.starred),He=i.value.findIndex(et=>et===je[je.length-1]);i.value.splice(He,1)}i.value=[...i.value,{starred:!1,timestamp:Date.now(),prompt:we}]}}function ar(we){i.value=i.value.filter(je=>je.prompt!=we&&je!=we)}function ma(){return!1}const kn=ie([]);function MC(){kn.value=[...kn.value,{lora:"",multiplier:0}]}function LC(we){kn.value=kn.value.filter((je,He)=>He!==we)}const Dr=ie([]),ho=ie(null),po=ie(null);async function dg(we){var Je,It;const He=(It=we.target.files)!=null?It:(Je=we.dataTransfer)==null?void 0:Je.files,et=Array.from(He!=null?He:[])[0];if(!et)return null;const ot=await Nl(et);return{id:`${Date.now()}-${et.name}`,name:et.name,size:et.size,dataUrl:ot,base64:ot.includes("data:image")?ot.split(",")[1]:ot}}async function RC(we){ho.value=await dg(we);const je=we.target;je.value!==void 0&&(je.value="")}async function DC(we){po.value=await dg(we);const je=we.target;je.value!==void 0&&(je.value="")}function FC(){ho.value=null;const we=document.getElementById("video_start_frame_input");we&&(we.value="")}function BC(){po.value=null;const we=document.getElementById("video_end_frame_input");we&&(we.value="")}async function $C(we){var Je,It;const je=we.target,He=(It=je.files)!=null?It:(Je=we.dataTransfer)==null?void 0:Je.files,et=Array.from(He!=null?He:[]);if(et.length===0)return;const ot=await Promise.all(et.map(async(en,Dn)=>{const tn=await Nl(en);return{id:`${Date.now()}-${Dn}-${en.name}`,name:en.name,size:en.size,dataUrl:tn,base64:tn.includes("data:image")?tn.split(",")[1]:tn}}));Dr.value||(Dr.value=[]);for(let en=0;en=Dr.value.length)return;const et=[...Dr.value],[ot]=et.splice(we,1);et.splice(He,0,ot),Dr.value=et}function jC(){Dr.value=[];const we=document.getElementById("extra_image_input");we&&(we.value="")}const Nf=ie(""),zf=ie(-1);async function VC(){var je,He,et,ot,Je,It,en,Dn,tn;const we=Rt();try{const Ii=await fetch(Ta(we.baseURL,`/sdapi/v1/progress?skip_current_image=true&genkey=${encodeURIComponent(T.value)}`));if(!Ii.ok)return;const Fn=await Ii.json();c.value={percentage:Math.round(((je=Fn.progress)!=null?je:0)*100),textInfo:Fn.textinfo||null,currentStep:(et=(He=Fn.state)==null?void 0:He.sampling_step)!=null?et:0,totalSteps:(Je=(ot=Fn.state)==null?void 0:ot.sampling_steps)!=null?Je:0,previewImage:(en=(It=c.value)==null?void 0:It.previewImage)!=null?en:null},Nf.value!=T.value&&(Nf.value=T.value,zf.value=-1);const ga=(tn=(Dn=Fn.state)==null?void 0:Dn.sampling_step)!=null?tn:0;zf.value!=ga&&(zf.value=ga,we.fetchGenerationProgress==="Image"&&UC())}catch{}}async function UC(){const we=Rt();try{const je=await fetch(Ta(we.baseURL,`/sdapi/v1/progress?genkey=${encodeURIComponent(T.value)}`));if(!je.ok)return;const He=await je.json();He.current_image&&c.value&&(c.value.previewImage=He.current_image)}catch{}}function HC(){Nf.value="",!d.value&&Rt().fetchGenerationProgress!=="Off"&&(c.value={percentage:0,textInfo:null,currentStep:0,totalSteps:0,previewImage:null},d.value=setInterval(VC,2e3))}function jf(){d.value&&(clearInterval(d.value),d.value=0),c.value=null}return{generatorType:n,prompt:r,params:o,outputs:w,inpainting:s,img2img:h,uploadDimensions:v,cancelled:b,abortController:S,multiSelect:u,referenceImages:Dr,videoStartFrame:ho,videoEndFrame:po,loraList:kn,addLoraRow:MC,removeLoraRow:LC,negativePrompt:l,generating:y,negativePromptLibrary:m,minDimensions:I,maxDimensions:$,minImages:O,maxImages:Y,minSteps:ae,maxSteps:q,minCfgScale:J,maxCfgScale:E,minDenoise:D,maxDenoise:B,minClipSkip:Z,maxClipSkip:H,minFrames:Q,maxFrames:te,minFps:fe,maxFps:me,minEta:V,maxEta:M,minFlowShift:R,maxFlowShift:W,clipSkipList:j,cfgList:x,queue:C,promptHistory:i,timer:a,progressInfo:c,progressInterval:d,lastImageGenkey:T,lastImageRecoveryUrl:k,lastImageRecoveryAvailable:A,clearLastImageGenkey:P,openLastImageRecovery:z,validGeneratorTypes:e,sourceGeneratorTypes:t,currentImageProps:p,totalImageCount:U,generateImage:de,generateText2Img:re,generateImg2Img:he,generateInpainting:Se,getPrompt:ma,resetStore:K,clearQueue:L,clearOutputs:F,stopProgressPolling:jf,pushToNegativeLibrary:Qt,removeFromNegativeLibrary:_r,pushToPromptHistory:yn,removeFromPromptHistory:ar,setExtraImage:$C,removeExtraImage:NC,moveExtraImage:zC,clearExtraImage:jC,setVideoStartFrame:RC,setVideoEndFrame:DC,clearVideoStartFrame:FC,clearVideoEndFrame:BC,getAvailableSamplers:it,getAvailableSchedulers:Ft,fetchLoras:X,cacheVersion:Me,invalidateApiCaches:ht,getCachedEndpoint:Ut}}),KG=be({__name:"ImageActions",props:{imageData:{},onDelete:{type:Function},showDismiss:{type:Boolean}},setup(e){const t=nn(),n=Ja(),r=e,i=()=>{H2.confirm("This action will permanently delete this image. Continue?","Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{n.deleteOutput(r.imageData.id),r.onDelete!==void 0&&r.onDelete(r.imageData.id),sa({type:"success",message:"Deleted Image"})})},l=a=>{if(a.extra_avi){const c=a.extra_avi.split(",")[1];if(!c)return;const d=`${a.seed}-${a.prompt}.avi`;KS(c,d);return}else rg(a.image,`${a.seed}-${a.prompt}`)},m=()=>{nn().clearOutputs(),Yt().showGeneratedImages=!1,nn().clearQueue()};async function o(a){const c=window.location.origin,d={prompt:a.prompt,width:a.width?a.width:void 0,height:a.height?a.height:void 0,steps:a.steps,cfg_scale:a.cfg_scale,sampler_name:a.sampler_name,model_name:a.modelName,seed:a.seed,clip_skip:a.clip_skip,frames:a.frames,fps:a.fps,scheduler:a.scheduler,extra_avi:a.extra_avi,final_frame:a.final_frame,enable_hr:a.enable_hr,send_as_refimg:a.send_as_refimg,lora_meta:a.lora_meta},u=window.location.pathname.replace("images","");let f=`${c}${u}?share=`,s="",h="";for(const[p,v]of Object.entries(d)){if(!v)continue;let y=v;typeof v=="string"?y=encodeURIComponent(v):Array.isArray(v)&&(y=JSON.stringify(v)),s+=`${h}${p}=${y}`,h="&"}const g=btoa(String.fromCharCode.apply(null,Array.from(rG(s))));f+=g,await navigator.clipboard.writeText(f),sa({type:"success",message:"Copied shareable link to clipboard"})}return(a,c)=>(N(),se($e,null,[oe(_(Ze),{class:"compact-button",onClick:i,type:"danger",size:"small",icon:_(Yi),plain:""},{default:ue(()=>[...c[8]||(c[8]=[Ne("Delete",-1)])]),_:1},8,["icon"]),oe(_(Ze),{class:"compact-button",onClick:c[0]||(c[0]=d=>l(a.imageData)),type:"success",size:"small",icon:_(yl),plain:""},{default:ue(()=>[...c[9]||(c[9]=[Ne("Download",-1)])]),_:1},8,["icon"]),a.imageData.starred?ge("",!0):(N(),ve(_(Ze),{key:0,class:"compact-button",onClick:c[1]||(c[1]=d=>_(n).toggleStarred(a.imageData.id)),type:"warning",size:"small",icon:_(jO),plain:""},{default:ue(()=>[...c[10]||(c[10]=[Ne("Star",-1)])]),_:1},8,["icon"])),a.imageData.starred?(N(),ve(_(Ze),{key:1,class:"compact-button",onClick:c[2]||(c[2]=d=>_(n).toggleStarred(a.imageData.id)),type:"warning",size:"small",icon:_(F1),plain:""},{default:ue(()=>[...c[11]||(c[11]=[Ne("Unstar",-1)])]),_:1},8,["icon"])):ge("",!0),oe(_(Ze),{class:"compact-button",onClick:c[3]||(c[3]=d=>_(t).generateText2Img(a.imageData)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[12]||(c[12]=[Ne("Txt2img",-1)])]),_:1}),oe(_(Ze),{class:"compact-button",onClick:c[4]||(c[4]=d=>_(t).generateImg2Img(a.imageData.image)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[13]||(c[13]=[Ne("Img2img",-1)])]),_:1}),oe(_(Ze),{class:"compact-button",onClick:c[5]||(c[5]=d=>_(t).generateInpainting(a.imageData.image)),type:"success",size:"small",plain:""},{default:ue(()=>[...c[14]||(c[14]=[Ne("Inpaint",-1)])]),_:1}),a.showDismiss?(N(),ve(_(Ze),{key:2,class:"compact-button",onClick:c[6]||(c[6]=d=>m()),type:"success",size:"small",plain:""},{default:ue(()=>[...c[15]||(c[15]=[Ne("Dismiss",-1)])]),_:1})):ge("",!0),oe(_(Ze),{class:"compact-button",onClick:c[7]||(c[7]=d=>o(a.imageData)),type:"success",icon:_(gO),size:"small",plain:""},{default:ue(()=>[...c[16]||(c[16]=[Ne("Share",-1)])]),_:1},8,["icon"])],64))}}),IC=on(KG,[["__scopeId","data-v-24447e4b"]]),XG={class:"main-output",style:{position:"relative",display:"flex","align-items":"center","justify-content":"center"}},qG=["src"],ZG={style:{"font-size":"16px","font-weight":"500"}},JG={style:{"font-family":"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif","letter-spacing":"0.025em"}},QG={key:0},eY={key:1},tY={key:0},nY={key:1},rY={key:2},iY=be({__name:"ImageDialog",setup(e){const t=Ja(),n=Yt(),r=ie();i6(r,{onSwipeEnd(d,u){u==="RIGHT"&&n.openModalToLeft(),u==="LEFT"&&n.openModalToRight()}});const i=ee({get(){return n.activeModal!==-1},set(){n.activeModal=-1}}),l=ie(t.currentOutputs[0]);Te(()=>n.activeModal,async()=>{const d=t.currentOutputs.find(u=>u.id===n.activeModal);if(d)return l.value=d;l.value=await Wt.outputs.get(n.activeModal)||t.currentOutputs[0]});function m(){i.value=!1}function o(){var f;if(!((f=l.value)!=null&&f.final_frame))return;const d=l.value.final_frame;nn().generateImg2Img(d)}function a(){var d;!((d=l.value)!=null&&d.image)||rg(l.value.image,`${l.value.seed}-${l.value.prompt}`)}function c(){var f,s;if(!((f=l.value)!=null&&f.extra_avi))return;const d=l.value.extra_avi.split(",")[1];if(!d)return;const u=`output-${(s=l.value.id)!=null?s:"video"}.avi`;KS(d,u)}return(d,u)=>{var f;return N(),ve(_(XD),{"model-value":i.value,width:(f=l.value)==null?void 0:f.width,class:"image-viewer",onClosed:m,"align-center":""},{footer:ue(()=>[oe(IC,{"image-data":l.value,"on-delete":m},null,8,["image-data"])]),default:ue(()=>{var s,h,g,p;return[ne("div",{class:"main-output-container",ref_key:"target",ref:r},[ne("div",XG,[(s=l.value)!=null&&s.image?(N(),se("img",{key:0,src:l.value.image,alt:"Output image",style:{"max-width":"100%","max-height":"100%","object-fit":"contain"}},null,8,qG)):ge("",!0)])],512),ne("div",ZG,Ee(((h=l.value.prompt)==null?void 0:h.split("###")[0])||"Unknown Creation"),1),ne("div",JG,[ne("div",null,"Negative Prompt: "+Ee(((g=l.value.prompt)==null?void 0:g.split("###")[1])||"None"),1),ne("span",null,"Model: "+Ee(l.value.modelName||"Unknown")+" - ",1),ne("span",null,"Sampler: "+Ee(l.value.sampler_name||"Unknown")+" - ",1),ne("span",null,"Scheduler: "+Ee(l.value.scheduler||"Unknown")+" - ",1),ne("span",null,"Seed: "+Ee(l.value.seed||"Unknown")+" - ",1),ne("span",null,"Steps: "+Ee(l.value.steps||"Unknown")+" - ",1),ne("span",null,"CFG Scale: "+Ee(l.value.cfg_scale||"Unknown")+" - ",1),ne("span",null,"Clip Skip: "+Ee((p=l.value.clip_skip)!=null?p:"Unknown")+" - ",1),ne("span",null,"Dimensions: "+Ee(l.value.width||"???")+"x"+Ee(l.value.height||"???")+" - ",1),ne("span",null,"Frames: "+Ee(l.value.frames||"1"),1),l.value.frames&&l.value.frames>1?(N(),se("span",QG," - FPS: "+Ee(l.value.fps||"Unknown"),1)):ge("",!0),l.value.lora_meta?(N(),se("span",eY," - LoRA: "+Ee(l.value.lora_meta),1)):ge("",!0),u[2]||(u[2]=ne("br",null,null,-1)),ne("b",null,[l.value.frames&&l.value.frames>1?(N(),se("span",tY,[ne("a",{href:"#",onClick:Qe(a,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download GIF]")])):ge("",!0),l.value.extra_avi?(N(),se("span",nY,[u[0]||(u[0]=Ne(" - ",-1)),ne("a",{href:"#",onClick:Qe(c,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Download AVI]")])):ge("",!0),l.value.final_frame?(N(),se("span",rY,[u[1]||(u[1]=Ne(" - ",-1)),ne("a",{href:"#",onClick:Qe(o,["prevent"]),style:{cursor:"pointer",color:"var(--el-color-primary)"}},"[Extend Video]")])):ge("",!0)])])]}),_:1},8,["model-value","width"])}}}),aY={class:"generator-icons"},oY=be({__name:"App",setup(e){const n=dm(fm).smallerOrEqual("md"),r=Yt();Rt();const i=BE(),l=ie();return Te(()=>i.path,m=>{l.value&&l.value.open(m)}),(m,o)=>(N(),se($e,null,[ne("div",{class:ce({"menu-container":!_(n)})},[oe(_(R2),{"default-active":_(i).path,mode:"horizontal",router:!0,ellipsis:!_(n),class:ce(_(n)?"mobile-menu":"menu"),ref_key:"menuRef",ref:l},{default:ue(()=>[_(n)?ge("",!0):(N(),ve(_(Am),{key:0,class:"remove-item-styling center-vertical"},{title:ue(()=>[...o[0]||(o[0]=[ne("div",{style:{"font-size":"20px"}},"Stable UI",-1)])]),_:1})),oe(Ps,{isMobile:_(n),index:"/"},{icon:ue(()=>[ne("div",aY,[oe(_(De),null,{default:ue(()=>[oe(_(EO))]),_:1}),_(r).showGeneratorBadge?(N(),ve(_(De),{key:0,class:"generator-badge",size:10},{default:ue(()=>[oe(l7)]),_:1})):ge("",!0)])]),title:ue(()=>[...o[1]||(o[1]=[Ne("Generate",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/images"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(wO))]),_:1})]),title:ue(()=>[...o[2]||(o[2]=[Ne("Images",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/about"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(M1))]),_:1})]),title:ue(()=>[...o[3]||(o[3]=[Ne("About",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/options"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(HO))]),_:1})]),title:ue(()=>[...o[4]||(o[4]=[Ne("Options",-1)])]),_:1},8,["isMobile"]),oe(Ps,{isMobile:_(n),index:"/return"},{icon:ue(()=>[oe(_(De),null,{default:ue(()=>[oe(_(O1))]),_:1})]),title:ue(()=>[...o[5]||(o[5]=[Ne("Return to Lite",-1)])]),_:1},8,["isMobile"])]),_:1},8,["default-active","ellipsis","class"])],2),ne("div",{class:ce({view:!_(n)})},[oe(_(E1))],2),oe(iY)],64))}}),sY=on(oY,[["__scopeId","data-v-8f4d2380"]]),fg=Tk(sY);fg.use(Ak());fg.use(ll);fg.mount("#app");ll.replace("/");window.addEventListener("beforeunload",e=>{nn().generating&&(e.preventDefault(),e.returnValue="")});const lY={key:1,class:"image-action"},uY=be({__name:"CustomImage",props:{imageData:{}},setup(e){const t=e,n=Yt(),r=ie(null);D5(r,n.toggleMultiSelect,{modifiers:{prevent:!0}});const i=ie(!1);r6(r,([{isIntersecting:m}])=>{m&&(i.value=m)},{rootMargin:"500px"});const l=ee(()=>n.selected.includes(t.imageData.id));return(m,o)=>(N(),se("div",{class:"relative",ref_key:"containerRef",ref:r},[i.value?(N(),ve(_(zo),{key:0,class:"thumbnail",src:m.imageData.image,onClick:o[0]||(o[0]=a=>_(n).activeModal=m.imageData.id),fit:"cover",loading:"lazy",style:ze(`${l.value&&"opacity: 0.5"}`)},null,8,["src","style"])):ge("",!0),i.value?(N(),se("div",lY,[m.imageData.starred?(N(),ve(_(De),{key:0,class:"starred-icon",size:35,color:"var(--el-color-warning)"},{default:ue(()=>[oe(_(F1))]),_:1})):ge("",!0),_(n).multiSelect?(N(),se("div",{key:1,class:"select-container",onClick:o[1]||(o[1]=a=>_(n).toggleSelection(m.imageData.id))},[oe(_(De),{class:"select-icon",size:35,color:`rgba(255, 255, 255, ${l.value?"1":"0.5"})`},{default:ue(()=>[l.value?ge("",!0):(N(),ve(_(Ql),{key:0})),l.value?(N(),ve(_(P1),{key:1})):ge("",!0)]),_:1},8,["color"])])):ge("",!0)])):ge("",!0)],512))}}),Fb=on(uY,[["__scopeId","data-v-b9569bbd"]]);function cY({mobileWidth:e=768,hideAfterDistanceFromTop:t=100,hideAfterScroll:n=100}={}){const{width:r}=ww(),i=ee(()=>r.value<=e),l=ie(!0),{y:m}=n6(window);let o=m.value,a=0;return Te(m,c=>{if(!i.value)return;const d=c-o;if(o=c,d>0&&c>t){a+=d,a>=n&&(l.value=!1,a=0);return}d<0&&(a=0,l.value=!0)}),{isVisible:l,isMobile:i}}const fY={},dY={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",viewBox:"0 0 1024 1024"};function hY(e,t){return N(),se("svg",dY,[...t[0]||(t[0]=[ne("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)])])}const pY=on(fY,[["render",hY]]),mY={class:"options"},gY=["onClick"],vY=["onClick"],yY=["onClick"],bY={key:1,class:"center-both",style:{gap:"12px"}},_Y={key:2},wY={key:0},SY={key:0,style:{display:"flex",gap:"8px"}},CY={key:1,class:"images"},xY={key:1},TY=be({__name:"ImagesView",setup(e){const{width:t}=ww(),{isVisible:n,isMobile:r}=cY(),i=Ja(),l=Rt(),m=Yt();function o(){m.selected=m.selected.filter(h=>!i.currentOutputs.map(g=>g.id).includes(h)),m.selected=[...m.selected,...i.currentOutputs.map(h=>h.id)],m.multiSelect=!0}async function a(){const h=await Wt.outputs.toCollection().primaryKeys();m.selected=h,m.multiSelect=!0}function c(){m.selected=m.selected.filter(h=>!i.currentOutputs.map(g=>g.id).includes(h)),m.selected.length===0&&(m.multiSelect=!1)}function d(){m.selected=[],m.multiSelect=!1}const u=()=>{H2.confirm(`This action will permanently delete ${m.selected.length} images. Continue?`,"Warning",{confirmButtonText:"OK",cancelButtonText:"Cancel",type:"warning"}).then(()=>{i.deleteMultipleOutputs(m.selected)})};h0(["a","A","ArrowLeft"],m.openModalToLeft),h0(["d","D","ArrowRight"],m.openModalToRight);async function f(){YS(m.selected)}const s=ee(()=>{let h=2;t.value>1440?h=6:t.value>1280?h=5:t.value>768?h=4:t.value>480&&(h=3);const g=[];for(let p=0;p(N(),se($e,null,[ne("div",{class:ce(["images-top-bar",{"mobile-hidden":_(r)&&!_(n)}])},[ne("div",mY,[oe(_(Lu),{placement:"bottom",title:"Sort By",trigger:"click",width:200,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(_($O))]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t(["Newest","Oldest"],p=>ne("div",{key:p,onClick:()=>_(i).sortBy=p,class:ce(`el-select-dropdown__item ${_(i).sortBy===p?"selected":""}`)},Ee(p),11,gY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Filter By",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(_(uO))]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t(["all","favourited","unfavourited","unrated"],p=>ne("div",{key:p,onClick:()=>_(i).filterBy=p,class:ce(`el-select-dropdown__item ${_(i).filterBy===p?"selected":""}`)},Ee(_(i).filterBy===p?"Showing":"Show")+" "+Ee(p),11,vY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Image Layout",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[oe(pY)]),_:1})]),_:1})]),default:ue(()=>[(N(),se($e,null,$t([{label:"Square Grid",value:"grid"},{label:"Dynamic Layout",value:"dynamic"}],p=>ne("div",{key:p.value,onClick:()=>_(i).currentLayout=p.value,class:ce(`el-select-dropdown__item ${_(i).currentLayout===p.value?"selected":""}`)},Ee(p.label),11,yY)),64))]),_:1}),oe(_(Lu),{placement:"bottom",title:"Selection",trigger:"click",width:240,transition:"none","hide-after":0},{reference:ue(()=>[oe(_(Ze),{class:"btn-select"},{default:ue(()=>[oe(_(De),{size:16},{default:ue(()=>[_(m).multiSelect?(N(),ve(_(P1),{key:0})):(N(),ve(_(Ql),{key:1}))]),_:1})]),_:1})]),default:ue(()=>[_(m).multiSelect?(N(),se("div",{key:0,class:"el-select-dropdown__item selected",onClick:g[0]||(g[0]=(...p)=>_(m).toggleMultiSelect&&_(m).toggleMultiSelect(...p))},"Disable multi-select")):(N(),se("div",{key:1,class:"el-select-dropdown__item",onClick:g[1]||(g[1]=(...p)=>_(m).toggleMultiSelect&&_(m).toggleMultiSelect(...p))},"Enable multi-select")),_(m).selected.length>0?(N(),se("div",{key:2,class:"el-select-dropdown__item selected",onClick:d},"Deselect All")):(N(),se("div",{key:3,class:"el-select-dropdown__item",onClick:a},"Select All")),_(m).selected.every(p=>!_(i).currentOutputs.map(v=>v.id).includes(p))?(N(),se("div",{key:5,class:"el-select-dropdown__item",onClick:o},"Select Page")):(N(),se("div",{key:4,class:"el-select-dropdown__item selected",onClick:c},"Deselect Page"))]),_:1})]),_(l).pageless==="Disabled"?(N(),ve(_(kN),{key:0,layout:"prev, pager, next",total:_(i).outputsLength,"page-size":_(l).pageSize,"current-page":_(i).currentPage,"onUpdate:currentPage":g[2]||(g[2]=p=>_(i).currentPage=p),"hide-on-single-page":""},null,8,["total","page-size","current-page"])):ge("",!0),_(m).multiSelect?(N(),se("div",bY,[ne("div",null,Ee(_(m).selected.length)+" selected",1),oe(_(Ze),{type:"danger",onClick:u,icon:_(Yi),plain:""},{default:ue(()=>[...g[3]||(g[3]=[Ne("Delete",-1)])]),_:1},8,["icon"]),oe(_(Ze),{type:"success",onClick:f,icon:_(yl),plain:"",style:{margin:"0"}},{default:ue(()=>[...g[4]||(g[4]=[Ne("Download",-1)])]),_:1},8,["icon"])])):(N(),se("div",_Y,[...g[5]||(g[5]=[ne("em",{style:{"font-size":"14px"}},"(long press to select multiple images)",-1)])]))],2),_(i).outputsLength!=0?(N(),se("div",wY,[_(i).currentLayout==="dynamic"?(N(),se("div",SY,[(N(!0),se($e,null,$t(s.value,(p,v)=>(N(),se("div",{key:v,style:{flex:"1 1 0%"}},[(N(!0),se($e,null,$t(p,y=>(N(),ve(Fb,{key:y.id,"image-data":y,style:{"margin-bottom":"8px"}},null,8,["image-data"]))),128))]))),128))])):ge("",!0),_(i).currentLayout==="grid"?(N(),se("div",CY,[(N(!0),se($e,null,$t(_(i).currentOutputs,p=>(N(),ve(Fb,{key:p.id,"image-data":p,style:{width:"200px",height:"200px"}},null,8,["image-data"]))),128))])):ge("",!0)])):ge("",!0),_(i).outputsLength==0?(N(),se("div",xY,[oe(_(VF),{description:"No Images Found"})])):ge("",!0)],64))}}),kY=on(TY,[["__scopeId","data-v-b39b47c5"]]),EY=Object.freeze(Object.defineProperty({__proto__:null,default:kY},Symbol.toStringTag,{value:"Module"})),OY=["href"],AY=be({__name:"BaseLink",props:{href:{},router:{type:Boolean}},setup(e){return(t,n)=>{const r=yt("router-link");return N(),se($e,null,[t.router?ge("",!0):(N(),se("a",{key:0,target:"_blank",rel:"noreferrer noopener",href:t.href},[ke(t.$slots,"default",{},void 0,!0)],8,OY)),t.router?(N(),ve(r,{key:1,to:t.href},{default:ue(()=>[ke(t.$slots,"default",{},void 0,!0)]),_:3},8,["to"])):ge("",!0)],64)}}}),PY=on(AY,[["__scopeId","data-v-17b53b7d"]]),IY={class:"about"},MY={class:"about-content"},LY=be({__name:"AboutView",setup(e){return(t,n)=>(N(),se("div",IY,[ne("div",MY,[n[2]||(n[2]=ne("h1",{style:{"margin-top":"0"}},"Stable UI",-1)),n[3]||(n[3]=ne("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 "),ne("a",{href:"https://github.com/LostRuins/koboldcpp"},"KoboldCpp"),Ne(".")],-1)),n[4]||(n[4]=ne("br",null,null,-1)),n[5]||(n[5]=ne("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)),n[6]||(n[6]=ne("br",null,null,-1)),ne("div",null,[n[1]||(n[1]=Ne("You can find the KoboldAI community and authors of this fork on the ",-1)),oe(PY,{href:"https://koboldai.org/discord"},{default:ue(()=>[...n[0]||(n[0]=[Ne("KoboldAI Discord",-1)])]),_:1})])])]))}}),RY=on(LY,[["__scopeId","data-v-ecc278c5"]]),DY=Object.freeze(Object.defineProperty({__proto__:null,default:RY},Symbol.toStringTag,{value:"Module"})),Di=be({__name:"FormRadio",props:{label:{},modelValue:{},prop:{},useBoolean:{type:Boolean},options:{},disabled:{type:Boolean},info:{},labelStyle:{},change:{type:Function}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,r=t;function i(m){if(n.useBoolean&&m==="Enabled"?r("update:modelValue",!0):n.useBoolean&&m==="Disabled"?r("update:modelValue",!1):r("update:modelValue",m),!!n.change)return n.useBoolean&&m==="Enabled"?n.change(!0):n.useBoolean&&m==="Disabled"?n.change(!1):n.change(m)}const l=ee(()=>n.useBoolean?n.modelValue===!0?"Enabled":n.modelValue===!1?"Disabled":n.modelValue:n.modelValue);return(m,o)=>(N(),ve(_(Qi),{prop:m.prop},{label:ue(()=>[oe(du,{info:m.info,"label-style":m.labelStyle},{default:ue(()=>[ke(m.$slots,"label",{},()=>[Ne(Ee(m.label),1)])]),_:3},8,["info","label-style"])]),default:ue(()=>[oe(_(FR),{disabled:m.disabled,"model-value":l.value,onChange:i},{default:ue(()=>[(N(!0),se($e,null,$t(m.options,a=>(N(),ve(_(BR),{key:a,label:a},null,8,["label"]))),128))]),_:1},8,["disabled","model-value"]),ke(m.$slots,"inline")]),_:3},8,["prop"]))}}),FY=be({__name:"OptionsView",setup(e){const t=Rt(),n=Ja(),r=nn(),i=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"auto",label:"Auto"}],l=ie([]),m=ie(),o=ie(!1),a=ie(0);async function c(u){n.importFromZip(u),m.value.clearFiles()}async function d(){sa({message:`Downloading ${n.outputsLength} image(s)... (this may take a while)`,type:"info"}),o.value=!0,a.value=0;const u=await Wt.outputs.toCollection().primaryKeys();await YS(u,!1,()=>{a.value++}),o.value=!1,a.value=0}return(u,f)=>(N(),se($e,null,[f[19]||(f[19]=ne("h1",null,"Options",-1)),oe(_(Em),{"label-position":"top",model:_(t).options,onSubmit:f[13]||(f[13]=Qe(()=>{},["prevent"]))},{default:ue(()=>[oe(_(qz),{type:"border-card",style:{"min-height":"50vh"}},{default:ue(()=>[oe(_(Cd),{label:"\u{1F5A8}\uFE0F Generation"},{default:ue(()=>[f[14]||(f[14]=ne("h2",null,"Generation Options",-1)),oe(_(Qi),{label:"Base URL"},{default:ue(()=>[oe(_(lo),{class:"apikey",prop:"baseURL",modelValue:_(t).baseURL,"onUpdate:modelValue":f[1]||(f[1]=s=>_(t).baseURL=s)},{append:ue(()=>[oe(_(fn),{content:"Invalidate all cached information for this server (LoRAs, samplers, schedulers, ...)",placement:"top"},{default:ue(()=>[oe(_(Ze),{icon:_(mh),onClick:f[0]||(f[0]=s=>_(r).invalidateApiCaches())},null,8,["icon"])]),_:1})]),_:1},8,["modelValue"])]),_:1}),f[15]||(f[15]=ne("h3",null,"Parameter Controls",-1)),(N(!0),se($e,null,$t(_(r).multiSelect,(s,h)=>{var g;return N(),se("div",{key:h},[oe(Di,{label:s.name,prop:"pageless",modelValue:s.state,"onUpdate:modelValue":p=>s.state=p,options:(g=s.allowedStates)!=null?g:[]},null,8,["label","modelValue","onUpdate:modelValue","options"])])}),128)),oe(Di,{label:"Allow Larger Params",prop:"pageless",modelValue:_(t).allowLargerParams,"onUpdate:modelValue":f[2]||(f[2]=s=>_(t).allowLargerParams=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Keep generation on disconnect",prop:"keepImageGenOnDisconnect",modelValue:_(t).keepImageGenOnDisconnect,"onUpdate:modelValue":f[3]||(f[3]=s=>_(t).keepImageGenOnDisconnect=s),options:["Enabled","Disabled"],info:"By default, a client disconnect or an abort action causes the ongoing generation to be interrupted as soon as possible and discarded. Enabling this option overrides that behavior, allowing the generation to finish, and making the image available to be downloaded by the UI when ready."},null,8,["modelValue"]),oe(Di,{label:"Fetch generation progres",prop:"fetchGenerationProgress",modelValue:_(t).fetchGenerationProgress,"onUpdate:modelValue":f[4]||(f[4]=s=>_(t).fetchGenerationProgress=s),options:["Off","Text","Image"],info:"Off: no progress polling. Text: fetch textual progress info only. Image: fetch textual info and live image preview."},null,8,["modelValue"]),oe(Mo,{label:"Image Resize Mode",prop:"imageResizeMode",modelValue:_(t).imageResizeMode,"onUpdate:modelValue":f[5]||(f[5]=s=>_(t).imageResizeMode=s),options:[{label:"No Scale",value:"NoScale"},{label:"Scale and Crop",value:"ScaleAndCrop"},{label:"Scale and Pad",value:"ScaleAndPad"},{label:"Stretch",value:"Stretch"},{label:"Original",value:"Original"}],info:"How to adapt input image dimensions to the requested image size. No Scale: do not scale, just crop or pad each dimension to fit (default behavior). Scale and Crop: scale to match the smaller dimension, preserving aspect ratio, then crop to fit. Scale and Pad: scale to match the larger dimension, preserving aspect ratio, then pad to fit. Stretch: stretch both dimensions to fit, possibly not preserving aspect ratio. Original: send the input image as-is to the server, with no scaling, cropping or padding."},null,8,["modelValue"]),oe(Di,{label:"Video Gen: Request AVI download",prop:"pageless",modelValue:_(t).alsoRequestAvi,"onUpdate:modelValue":f[6]||(f[6]=s=>_(t).alsoRequestAvi=s),options:["Enabled","Disabled"]},null,8,["modelValue"])]),_:1}),oe(_(Cd),{label:"\u{1F4F7} Images"},{default:ue(()=>[f[17]||(f[17]=ne("h2",null,"Image Options",-1)),oe(bn,{label:"Images Per Page",prop:"pageSize",modelValue:_(t).pageSize,"onUpdate:modelValue":f[7]||(f[7]=s=>_(t).pageSize=s),min:10,max:50,step:5,disabled:_(t).pageless==="Enabled"},null,8,["modelValue","disabled"]),oe(Di,{label:"Pageless Format",prop:"pageless",modelValue:_(t).pageless,"onUpdate:modelValue":f[8]||(f[8]=s=>_(t).pageless=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Carousel Auto Cycle",prop:"autoCarousel",modelValue:_(t).autoCarousel,"onUpdate:modelValue":f[9]||(f[9]=s=>_(t).autoCarousel=s),options:["Enabled","Disabled"]},null,8,["modelValue"]),oe(Di,{label:"Image Download Format",prop:"downloadType",modelValue:_(t).imageDownloadType,"onUpdate:modelValue":f[10]||(f[10]=s=>_(t).imageDownloadType=s),options:["PNG","JPG","WEBP","GIF"]},null,8,["modelValue"]),oe(_(Qi),{label:"Export Images (ZIP File)"},{default:ue(()=>[o.value?(N(),ve(_(Ze),{key:1,icon:_(yl),disabled:""},{default:ue(()=>[Ne("Downloading... ("+Ee(a.value)+" / "+Ee(_(n).outputsLength)+" image(s))",1)]),_:1},8,["icon"])):(N(),ve(_(Ze),{key:0,icon:_(yl),onClick:f[11]||(f[11]=s=>d())},{default:ue(()=>[Ne("Download "+Ee(_(n).outputsLength)+" image(s)",1)]),_:1},8,["icon"]))]),_:1}),oe(_(Qi),{label:"Import Images (ZIP File)"},{default:ue(()=>[oe(_(Lm),{drag:"",ref_key:"upload",ref:m,"auto-upload":!1,onChange:c,"file-list":l.value,limit:1,multiple:""},{default:ue(()=>[oe(_(De),{size:100},{default:ue(()=>[oe(_(Zp))]),_:1}),f[16]||(f[16]=ne("div",null,[Ne("Drop file here OR "),ne("em",null,"click to upload")],-1))]),_:1},8,["file-list"])]),_:1})]),_:1}),oe(_(Cd),{label:"\u2699\uFE0F General"},{default:ue(()=>[f[18]||(f[18]=ne("h2",null,"General Options",-1)),oe(Mo,{label:"Color Scheme",prop:"colorScheme",modelValue:_(t).options.colorMode,"onUpdate:modelValue":f[12]||(f[12]=s=>_(t).options.colorMode=s),options:i},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["model"])],64))}}),BY=on(FY,[["__scopeId","data-v-679e7af1"]]),$Y=Object.freeze(Object.defineProperty({__proto__:null,default:BY},Symbol.toStringTag,{value:"Module"}))});export default NY();