sd-webui-infinite-image-bro.../vue/dist/assets/hook-dadee24a.js

3 lines
21 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{c2 as ke,c3 as Se,aK as xe,c4 as Pe,c5 as Ie,c6 as Fe,ao as de,c7 as Me,ai as Y,bd as Ee,c8 as Te,c as _e,ae as Le,c9 as ae,ca as De,cb as Ce,x as Ne,cc as ve,ag as A,bu as D,af as L,cd as V,r as _,y as Z,be as ee,ax as Oe,ce as $,cf as Ae,cg as ne,ch as oe,aj as pe,bq as le,br as $e,ci as B,cj as qe,aB as ze,bp as Re,ck as We,bZ as O,cl as U,B as he,cm as Ue,v as ge,L as Ge,c0 as Ve,ah as j,cn as je,co as He,cp as Be,cq as Ke,cr as Qe,cs as Je}from"./index-2ccb5782.js";import{b as Xe,h as Ye,i as Ze,t as et}from"./db-89fdf46d.js";var ce=1/0,tt=17976931348623157e292;function J(s){if(!s)return s===0?s:0;if(s=ke(s),s===ce||s===-ce){var r=s<0?-1:1;return r*tt}return s===s?s:0}function z(s){var r=s==null?0:s.length;return r?s[r-1]:void 0}function at(s,r,a){if(!Se(a))return!1;var i=typeof r;return(i=="number"?xe(a)&&Pe(r,a.length):i=="string"&&r in a)?Ie(a[r],s):!1}var nt=Math.ceil,st=Math.max;function rt(s,r,a,i){for(var u=-1,h=st(nt((r-s)/(a||1)),0),g=Array(h);h--;)g[i?h:++u]=s,s+=a;return g}function it(s){return function(r,a,i){return i&&typeof i!="number"&&at(r,a,i)&&(a=i=void 0),r=J(r),a===void 0?(a=r,r=0):a=J(a),i=i===void 0?r<a?1:-1:J(i),rt(r,a,i,s)}}var ot=it();const lt=ot;function ct(s,r){return s&&s.length?Fe(s,Xe(r)):[]}const Q=(...s)=>{document.addEventListener(...s),de(()=>document.removeEventListener(...s))},H=new WeakMap;function ut(s,r){return{useHookShareState:i=>{const u=Me();Y(u),H.has(u)||(H.set(u,Ee(s(u,i??(r==null?void 0:r())))),de(()=>{H.delete(u)}));const h=H.get(u);return Y(h),{state:h,toRefs(){return Te(h)}}}}}var ft={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"};const dt=ft;function ue(s){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?Object(arguments[r]):{},i=Object.keys(a);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(a).filter(function(u){return Object.getOwnPropertyDescriptor(a,u).enumerable}))),i.forEach(function(u){vt(s,u,a[u])})}return s}function vt(s,r,a){return r in s?Object.defineProperty(s,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[r]=a,s}var se=function(r,a){var i=ue({},r,a.attrs);return _e(Le,ue({},i,{icon:dt}),null)};se.displayName="DatabaseOutlined";se.inheritAttrs=!1;const pt=se,W=async s=>(await ae.get("/files",{params:{folder_path:s}})).data,ht=async s=>(await ae.post("/delete_files",{file_paths:s})).data,me=async(s,r)=>(await ae.post("/move_files",{file_paths:s,dest:r})).data;var we={exports:{}};/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
* @license MIT */(function(s,r){(function(a,i){s.exports=i})(De,function(){var a={};a.version="0.3.5";var i=a.settings={minimum:.08,easing:"linear",positionUsing:"",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'};a.configure=function(t){var e,n;for(e in t)n=t[e],n!==void 0&&t.hasOwnProperty(e)&&(i[e]=n);return this},a.status=null,a.set=function(t){var e=a.isStarted();t=u(t,i.minimum,1),a.status=t===1?null:t;var n=a.render(!e),l=n.querySelector(i.barSelector),m=i.speed,w=i.easing;return n.offsetWidth,b(function(p){i.positionUsing===""&&(i.positionUsing=a.getPositioningCSS()),I(l,g(t,m,w)),t===1?(I(n,{transition:"none",opacity:1}),n.offsetWidth,setTimeout(function(){I(n,{transition:"all "+m+"ms linear",opacity:0}),setTimeout(function(){a.remove(),p()},m)},m)):setTimeout(p,m)}),this},a.isStarted=function(){return typeof a.status=="number"},a.start=function(){a.status||a.set(0);var t=function(){setTimeout(function(){a.status&&(a.trickle(),t())},i.trickleSpeed)};return i.trickle&&t(),this},a.done=function(t){return!t&&!a.status?this:a.inc(.3+.5*Math.random()).set(1)},a.inc=function(t){var e=a.status;return e?e>1?void 0:(typeof t!="number"&&(e>=0&&e<.2?t=.1:e>=.2&&e<.5?t=.04:e>=.5&&e<.8?t=.02:e>=.8&&e<.99?t=.005:t=0),e=u(e+t,0,.994),a.set(e)):a.start()},a.trickle=function(){return a.inc()},function(){var t=0,e=0;a.promise=function(n){return!n||n.state()==="resolved"?this:(e===0&&a.start(),t++,e++,n.always(function(){e--,e===0?(t=0,a.done()):a.set((t-e)/t)}),this)}}(),a.getElement=function(){var t=a.getParent();if(t){var e=Array.prototype.slice.call(t.querySelectorAll(".nprogress")).filter(function(n){return n.parentElement===t});if(e.length>0)return e[0]}return null},a.getParent=function(){if(i.parent instanceof HTMLElement)return i.parent;if(typeof i.parent=="string")return document.querySelector(i.parent)},a.render=function(t){if(a.isRendered())return a.getElement();T(document.documentElement,"nprogress-busy");var e=document.createElement("div");e.id="nprogress",e.className="nprogress",e.innerHTML=i.template;var n=e.querySelector(i.barSelector),l=t?"-100":h(a.status||0),m=a.getParent(),w;return I(n,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),i.showSpinner||(w=e.querySelector(i.spinnerSelector),w&&F(w)),m!=document.body&&T(m,"nprogress-custom-parent"),m.appendChild(e),e},a.remove=function(){a.status=null,M(document.documentElement,"nprogress-busy"),M(a.getParent(),"nprogress-custom-parent");var t=a.getElement();t&&F(t)},a.isRendered=function(){return!!a.getElement()},a.getPositioningCSS=function(){var t=document.body.style,e="WebkitTransform"in t?"Webkit":"MozTransform"in t?"Moz":"msTransform"in t?"ms":"OTransform"in t?"O":"";return e+"Perspective"in t?"translate3d":e+"Transform"in t?"translate":"margin"};function u(t,e,n){return t<e?e:t>n?n:t}function h(t){return(-1+t)*100}function g(t,e,n){var l;return i.positionUsing==="translate3d"?l={transform:"translate3d("+h(t)+"%,0,0)"}:i.positionUsing==="translate"?l={transform:"translate("+h(t)+"%,0)"}:l={"margin-left":h(t)+"%"},l.transition="all "+e+"ms "+n,l}var b=function(){var t=[];function e(){var n=t.shift();n&&n(e)}return function(n){t.push(n),t.length==1&&e()}}(),I=function(){var t=["Webkit","O","Moz","ms"],e={};function n(p){return p.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(x,o){return o.toUpperCase()})}function l(p){var x=document.body.style;if(p in x)return p;for(var o=t.length,c=p.charAt(0).toUpperCase()+p.slice(1),v;o--;)if(v=t[o]+c,v in x)return v;return p}function m(p){return p=n(p),e[p]||(e[p]=l(p))}function w(p,x,o){x=m(x),p.style[x]=o}return function(p,x){var o=arguments,c,v;if(o.length==2)for(c in x)v=x[c],v!==void 0&&x.hasOwnProperty(c)&&w(p,c,v);else w(p,o[1],o[2])}}();function y(t,e){var n=typeof t=="string"?t:E(t);return n.indexOf(" "+e+" ")>=0}function T(t,e){var n=E(t),l=n+e;y(n,e)||(t.className=l.substring(1))}function M(t,e){var n=E(t),l;y(t,e)&&(l=n.replace(" "+e+" "," "),t.className=l.substring(1,l.length-1))}function E(t){return(" "+(t&&t.className||"")+" ").replace(/\s+/gi," ")}function F(t){t&&t.parentNode&&t.parentNode.removeChild(t)}return a})})(we);var gt=we.exports;const mt=Ce(gt),X=new Map,S=Ne(),fe=new BroadcastChannel("iib-image-transfer-bus"),G=encodeURIComponent,R=(s,r=!1)=>`/infinite_image_browsing/file?path=${G(s.fullpath)}&t=${G(s.date)}${r?`&disposition=${G(s.name)}`:""}`,bt=(s,r)=>`/infinite_image_browsing/image-thumbnail?path=${G(s.fullpath)}&size=${r}&t=${G(s.date)}`,{eventEmitter:K,useEventListen:te}=ve(),{useHookShareState:q}=ut((s,{images:r})=>{const a=_({tabIdx:-1,paneIdx:-1}),i=A(()=>z(u.value)),u=_([]),h=A(()=>{var e;return u.value.map(n=>n.curr).slice((e=S.conf)!=null&&e.is_win?1:0)}),g=A(()=>ne(...h.value)),b=_(S.defaultSortingMethod),I=A(()=>{var w;if(r.value)return r.value;if(!i.value)return[];const e=((w=i.value)==null?void 0:w.files)??[],n=b.value,{walkFiles:l}=i.value,m=p=>S.onlyFoldersAndImages?p.filter(x=>x.type==="dir"||O(x.name)):p;return a.value.walkModePath?l?l.map(p=>U(m(p),n)).flat():U(m(e),n):U(m(e),n)}),y=_([]),T=_(-1),M=_(!0),E=_(!1),F=_(!1),t=()=>S.tabList[a.value.tabIdx].panes[a.value.paneIdx];return{previewing:F,spinning:E,canLoadNext:M,multiSelectedIdxs:y,previewIdx:T,basePath:h,currLocation:g,currPage:i,stack:u,sortMethod:b,sortedFiles:I,scroller:_(),stackViewEl:_(),props:a,getPane:t,...ve()}},()=>({images:_()})),kt=["detailList","largePreviewGrid","previewGrid"];function St(s,r){const{previewIdx:a,eventEmitter:i,canLoadNext:u,previewing:h}=q().toRefs(),{state:g}=q(),b=A(()=>(r==null?void 0:r.files.value)??g.sortedFiles),I=A(()=>(r==null?void 0:r.scroller.value)??g.scroller);let y=null;const T=(t,e)=>{var n;h.value=t,y!=null&&!t&&e&&((n=I.value)==null||n.scrollToItem(y),y=null)},M=()=>{s.walkModePath&&!F("next")&&u&&(D.info(L("loadingNextFolder")),i.value.emit("loadNextDir",!0))};Q("keydown",t=>{var e;if(h.value){let n=a.value;if(["ArrowDown","ArrowRight"].includes(t.key))for(n++;b.value[n]&&!O(b.value[n].name);)n++;else if(["ArrowUp","ArrowLeft"].includes(t.key))for(n--;b.value[n]&&!O(b.value[n].name);)n--;if(O((e=b.value[n])==null?void 0:e.name)??""){a.value=n;const l=I.value;l&&!(n>=l.$_startIndex&&n<=l.$_endIndex)&&(y=n)}M()}});const E=t=>{var n;let e=a.value;if(t==="next")for(e++;b.value[e]&&!O(b.value[e].name);)e++;else if(t==="prev")for(e--;b.value[e]&&!O(b.value[e].name);)e--;if(O((n=b.value[e])==null?void 0:n.name)??""){a.value=e;const l=I.value;l&&!(e>=l.$_startIndex&&e<=l.$_endIndex)&&(y=e)}M()},F=t=>{var n;let e=a.value;if(t==="next")for(e++;b.value[e]&&!O(b.value[e].name);)e++;else if(t==="prev")for(e--;b.value[e]&&!O(b.value[e].name);)e--;return O((n=b.value[e])==null?void 0:n.name)??""};return te("removeFiles",async()=>{var t;h.value&&!g.sortedFiles[a.value]&&(D.info(L("manualExitFullScreen"),5),await V(500),(t=document.querySelector(".ant-image-preview-operations-operation .anticon-close"))==null||t.click(),a.value=-1)}),{previewIdx:a,onPreviewVisibleChange:T,previewing:h,previewImgMove:E,canPreview:F}}function xt(s){const r=_(),{scroller:a,stackViewEl:i,stack:u,currPage:h,currLocation:g,sortMethod:b,useEventListen:I,eventEmitter:y,getPane:T}=q().toRefs();Z(()=>u.value.length,ee((o,c)=>{var v;o!==c&&((v=a.value)==null||v.scrollToItem(0))},300));const M=async o=>{if(await n(o),s.walkModePath){await V();const[c]=U(h.value.files,b.value).filter(v=>v.type==="dir");c&&await n(c.fullpath),await y.value.emit("loadNextDir")}};Oe(async()=>{var o;if(!u.value.length){const c=await W("/");u.value.push({files:c.files,curr:"/"})}r.value=new mt,r.value.configure({parent:i.value}),s.path&&s.path!=="/"?await M(s.walkModePath??s.path):(o=S.conf)!=null&&o.home&&n(S.conf.home)}),Z(g,ee(o=>{const c=T.value();c.path=o;const v=c.path.split("/").pop(),f=(()=>{var k;if(!s.walkModePath){const P=B(o);for(const[C,N]of Object.entries(S.pathAliasMap))if(P.startsWith(N))return P.replace(N,C);return v}return"Walk: "+(((k=S.quickMovePaths.find(P=>P.dir===c.walkModePath))==null?void 0:k.zh)??v)})();c.name=$("div",{style:"display:flex;align-items:center"},[$(pt),$("span",{class:"line-clamp-1",style:"max-width: 256px"},f)]),c.nameFallbackStr=f,S.recent=S.recent.filter(k=>k.key!==c.key),S.recent.unshift({path:o,key:c.key}),S.recent.length>20&&(S.recent=S.recent.slice(0,20))},300));const E=()=>he(g.value),F=async o=>{var c,v;if(o.type==="dir")try{(c=r.value)==null||c.start();const{files:d}=await W(o.fullpath);u.value.push({files:d,curr:o.name})}finally{(v=r.value)==null||v.done()}},t=o=>{for(;o<u.value.length-1;)u.value.pop()},e=(o,c)=>(Y(S.conf,"global.conf load failed"),S.conf.is_win?o.toLowerCase()==c.toLowerCase():o==c),n=async o=>{var v,d;const c=u.value.slice();try{Ae(o)||(o=ne(((v=S.conf)==null?void 0:v.sd_cwd)??"/",o));const f=oe(o),k=u.value.map(P=>P.curr);for(k.shift();k[0]&&f[0]&&e(k[0],f[0]);)k.shift(),f.shift();for(let P=0;P<k.length;P++)u.value.pop();if(!f.length)return l();for(const P of f){const C=(d=h.value)==null?void 0:d.files.find(N=>e(N.name,P));if(!C)throw console.error({frags:f,frag:P,stack:pe(u.value)}),new Error(`${P} not found`);await F(C)}}catch(f){throw D.error(L("moveFailedCheckPath")+(f instanceof Error?f.message:"")),console.error(o,oe(o),h.value),u.value=c,f}},l=le(async()=>{var o,c,v;try{if((o=r.value)==null||o.start(),s.walkModePath)t(0),await M(s.walkModePath);else{const{files:d}=await W(u.value.length===1?"/":g.value);z(u.value).files=d}(c=a.value)==null||c.scrollToItem(0),D.success(L("refreshCompleted"))}finally{(v=r.value)==null||v.done()}});$e("return-to-iib",le(async()=>{var o,c;if(!s.walkModePath)try{(o=r.value)==null||o.start();const{files:v}=await W(u.value.length===1?"/":g.value);z(u.value).files.map(f=>f.date).join()!==v.map(f=>f.date).join()&&(z(u.value).files=v,D.success(L("autoUpdate")))}finally{(c=r.value)==null||c.done()}})),I.value("refresh",l);const m=o=>{s.walkModePath&&(T.value().walkModePath=o),M(o)},w=A(()=>S.quickMovePaths.map(o=>({...o,path:B(o.dir)}))),p=A(()=>{const o=B(g.value);return w.value.find(v=>v.path===o)});return{addToSearchScanPathAndQuickMove:async()=>{const o=p.value;if(o){if(!o.can_delete)return;await Ye(g.value),D.success(L("removeComplete"))}else await Ze(g.value),D.success(L("addComplete"));await Ue.emit("updateGlobalSetting")},searchPathInfo:p,refresh:l,copyLocation:E,back:t,openNext:F,currPage:h,currLocation:g,to:n,stack:u,scroller:a,quickMoveTo:m}}function Pt(s){const{scroller:r,sortedFiles:a,stack:i,sortMethod:u,currLocation:h,currPage:g,stackViewEl:b,canLoadNext:I,previewIdx:y}=q().toRefs(),{state:T}=q(),M=_(!1),E=_(S.defaultViewMode),F=272,t=64,e=F*2,{width:n}=qe(b),l=A(()=>{const c=n.value;if(!(E.value==="detailList"||!c))return~~(c/(E.value==="previewGrid"?F:e))}),m=A(()=>{const c=E.value;if(c==="detailList")return{first:80,second:void 0};const v=c==="previewGrid"?F:e;return{first:v+t,second:v}}),w=_(!1),p=async()=>{var c;if(!(w.value||!s.walkModePath||!I.value))try{w.value=!0;const v=i.value[i.value.length-2],d=U(v.files,u.value),f=d.findIndex(k=>{var P;return k.name===((P=g.value)==null?void 0:P.curr)});if(f!==-1){const k=d[f+1],P=ne(h.value,"../",k.name),C=await W(P),N=g.value;N.curr=k.name,N.walkFiles||(N.walkFiles=[N.files]),N.walkFiles.push(C.files),console.log("curr page files length",(c=g.value)==null?void 0:c.files.length)}}catch(v){console.error("loadNextDir",v),I.value=!1}finally{w.value=!1}},x=async(c=!1)=>{const v=r.value,d=()=>c?y.value:(v==null?void 0:v.$_endIndex)??0;for(;!a.value.length||d()>a.value.length-20&&I.value;)await V(100),await p()};T.useEventListen("loadNextDir",x);const o=ee(()=>x(),300);return{gridItems:l,sortedFiles:a,sortMethodConv:ze,moreActionsDropdownShow:M,viewMode:E,gridSize:F,sortMethod:u,largeGridSize:e,onScroll:o,loadNextDir:p,loadNextDirLoading:w,canLoadNext:I,itemSize:m}}function It(){const{currLocation:s,sortedFiles:r,currPage:a,multiSelectedIdxs:i,eventEmitter:u}=q().toRefs(),h=()=>{i.value=[]};return Q("click",h),Q("blur",h),Z(a,h),{onFileDragStart:(I,y)=>{const T=pe(r.value[y]);console.log("onFileDragStart set drag file ",I,y,T);const M=[T];let E=T.type==="dir";if(i.value.includes(y)){const F=i.value.map(t=>r.value[t]);M.push(...F),E=F.some(t=>t.type==="dir")}I.dataTransfer.setData("text/plain",JSON.stringify({includeDir:E,loc:s.value||"search-result",path:ct(M,"fullpath").map(F=>F.fullpath)}))},onDrop:async I=>{var T;const y=JSON.parse(((T=I.dataTransfer)==null?void 0:T.getData("text"))||"{}");if(console.log(y),y.path&&typeof y.includeDir<"u"&&y.loc){const M=s.value;if(y.loc===M)return;const E=$("div",[$("div",`${L("moveSelectedFilesTo")}${M}`),$("ol",y.path.map(F=>F.split(/[/\\]/).pop()).map(F=>$("li",F)))]);ge.confirm({title:L("confirm"),content:E,maskClosable:!0,async onOk(){await me(y.path,M),K.emit("removeFiles",{paths:y.path,loc:y.loc}),await u.value.emit("refresh")}})}},multiSelectedIdxs:i}}function Ft(s,{openNext:r}){const a=_(!1),i=_(""),{sortedFiles:u,previewIdx:h,multiSelectedIdxs:g,stack:b,currLocation:I,spinning:y,previewing:T}=q().toRefs(),M=B;te("removeFiles",({paths:e,loc:n})=>{if(M(n)!==M(I.value))return;const l=z(b.value);l&&(l.files=l.files.filter(m=>!e.includes(m.fullpath)),l.walkFiles&&(l.walkFiles=l.walkFiles.map(m=>m.filter(w=>!e.includes(w.fullpath)))))}),te("addFiles",({files:e,loc:n})=>{if(M(n)!==M(I.value))return;const l=z(b.value);l&&l.files.unshift(...e)});const E=Re(),F=async(e,n,l)=>{h.value=l,S.fullscreenPreviewInitialUrl=R(n);const m=g.value.indexOf(l);if(e.shiftKey){if(m!==-1)g.value.splice(m,1);else{g.value.push(l),g.value.sort((x,o)=>x-o);const w=g.value[0],p=g.value[g.value.length-1];g.value=lt(w,p+1)}e.stopPropagation()}else e.ctrlKey||e.metaKey?(m!==-1?g.value.splice(m,1):g.value.push(l),e.stopPropagation()):await r(n)},t=async(e,n,l)=>{var o,c,v;const m=R(n),w=I.value,p=()=>{let d=[];return g.value.includes(l)?d=g.value.map(f=>u.value[f]):d.push(n),d},x=async d=>{if(!y.value)try{y.value=!0,await Be(n.fullpath),fe.postMessage("iib_hidden_img_update_trigger");const f=setTimeout(()=>Ke.warn({message:L("long_loading"),duration:20}),5e3);await Qe(),clearTimeout(f),fe.postMessage(`iib_hidden_tab_${d}`)}catch(f){console.error(f),D.error("发送图像失败请携带console的错误消息找开发者")}finally{y.value=!1}};if(`${e.key}`.startsWith("toggle-tag-")){const d=+`${e.key}`.split("toggle-tag-")[1],{is_remove:f}=await et({tag_id:d,img_path:n.fullpath}),k=(c=(o=S.conf)==null?void 0:o.all_custom_tags.find(P=>P.id===d))==null?void 0:c.name;D.success(L(f?"removedTagFromImage":"addedTagToImage",{tag:k}));return}switch(e.key){case"previewInNewWindow":return window.open(m);case"download":return window.open(R(n,!0));case"copyPreviewUrl":return he(parent.document.location.origin+m);case"send2txt2img":return x("txt2img");case"send2img2img":return x("img2img");case"send2inpaint":return x("inpaint");case"send2extras":return x("extras");case"send2savedDir":{const d=S.quickMovePaths.find(P=>P.key==="outdir_save");if(!d)return D.error(L("unknownSavedDir"));const f=He(d.dir,(v=S.conf)==null?void 0:v.sd_cwd),k=p();await me(k.map(P=>P.fullpath),f),K.emit("removeFiles",{paths:k.map(P=>P.fullpath),loc:I.value}),K.emit("addFiles",{files:k,loc:f});break}case"send2controlnet-img2img":case"send2controlnet-txt2img":{const d=je(),f=Je(),k=e.key.split("-")[1];k==="img2img"?f.switch_to_img2img():f.switch_to_txt2img(),await V(100);const C=d.querySelector(`#${k}_controlnet`).querySelector(".label-wrap");C.className.includes("open")||(C.click(),await V(100)),C.scrollIntoView();const re=await(await fetch(R(n))).blob(),ye=new File([re],"image.jpg",{type:re.type,lastModified:Date.now()}),ie=new DataTransfer;ie.items.add(ye);const be=new ClipboardEvent("paste",{clipboardData:ie,bubbles:!0});C.dispatchEvent(be);break}case"openWithWalkMode":{X.set(w,b.value);const d=S.tabList[s.tabIdx],f={type:"local",key:j(),path:n.fullpath,name:L("local"),stackKey:w,walkModePath:n.fullpath};d.panes.push(f),d.key=f.key;break}case"openInNewTab":{X.set(w,b.value);const d=S.tabList[s.tabIdx],f={type:"local",key:j(),path:n.fullpath,name:L("local"),stackKey:w};d.panes.push(f),d.key=f.key;break}case"openOnTheRight":{X.set(w,b.value);let d=S.tabList[s.tabIdx+1];d||(d={panes:[],key:"",id:j()},S.tabList[s.tabIdx+1]=d);const f={type:"local",key:j(),path:n.fullpath,name:L("local"),stackKey:w};d.panes.push(f),d.key=f.key;break}case"viewGenInfo":{a.value=!0,i.value=await E.pushAction(()=>Ve(n.fullpath)).res;break}case"openWithLocalFileBrowser":{await Ge(n.fullpath);break}case"deleteFiles":{const d=p();await new Promise(f=>{ge.confirm({title:L("confirmDelete"),maskClosable:!0,content:$("ol",{style:"max-height:50vh;overflow:auto;"},d.map(k=>k.fullpath.split(/[/\\]/).pop()).map(k=>$("li",k))),async onOk(){const k=d.map(P=>P.fullpath);await ht(k),D.success(L("deleteSuccess")),K.emit("removeFiles",{paths:k,loc:I.value}),f()}})});break}}return{}};return Q("keydown",e=>{var n,l,m;if(T.value){const w=[];if(e.shiftKey&&w.push("Shift"),e.ctrlKey&&w.push("Ctrl"),e.code.startsWith("Key")||e.code.startsWith("Digit")){w.push(e.code);const p=w.join(" + "),x=(n=Object.entries(S.shortcut).find(o=>o[1]===p))==null?void 0:n[0];if(x){e.stopPropagation(),e.preventDefault();const o=h.value,c=u.value[o];switch(x){case"delete":return R(c)===S.fullscreenPreviewInitialUrl?D.warn(L("fullscreenRestriction")):t({key:"deleteFiles"},c,o);default:{const v=(l=/^toggle_tag_(.*)$/.exec(x))==null?void 0:l[1],d=(m=S.conf)==null?void 0:m.all_custom_tags.find(f=>f.name===v);return d?t({key:`toggle-tag-${d.id}`},c,o):void 0}}}}}}),{onFileItemClick:F,onContextMenuClick:t,showGenInfo:a,imageGenInfo:i,q:E}}const Mt=()=>{const{stackViewEl:s}=q().toRefs(),r=_(-1);return We(s,a=>{var u;let i=a.target;for(;i.parentElement;)if(i=i.parentElement,i.tagName.toLowerCase()==="li"&&i.classList.contains("file-item-trigger")){const h=(u=i.dataset)==null?void 0:u.idx;h&&Number.isSafeInteger(+h)&&(r.value=+h);return}}),{showMenuIdx:r}};export{xt as a,Pt as b,It as c,Ft as d,St as e,Mt as f,J as g,te as h,bt as i,z as l,X as s,R as t,q as u,kt as v};