var i=Object.defineProperty,t=(t,e,s)=>(((t,e,s)=>{e in t?i(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s})(t,"symbol"!=typeof e?e+"":e,s),s);import{q as e,P as s}from"./index.1705848582155.js";const n={"tab://setting":()=>{e.emit("openController")},"tab://addSearchEngine":(i={})=>{i.size={width:window.innerWidth<500?"380px":"600px",height:"400px",top:window.innerHeight>700?"260px":"15vh"},i.component="addSearchEngine",e.emit("openPlugin",i)},"tab://addicon":(i={})=>{i.full=!1,i.size={width:"1000px",height:"550px"},i.component="addicon",e.emit("openPlugin",i)},"tab://editAll":(i={})=>{setTimeout((()=>{s.state.editStatus=!0}),100)}};var h=[];const a={subject:[],closeLast(){const i=h.pop();return i?(i.close(),!0):(this.emit("refresh",h),!1)},closeAll(){let i=this.closeLast();for(;i;)i=this.closeLast();this.emit("refresh",h)},on(i,t){this.subject.push({event:i,callback:t})},off(i,t){if(i)for(let e=0;e"xxxxxxxx-xxx-xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(i){const t=16*Math.random()|0;return("x"===i?t:3&t|8).toString(16)})))),t(this,"windowMove",(i=>{if(this.isMove){const{x:t,y:e}=i;this.isFull||this.setPosition(t-this.movePoint.layerX,e-this.movePoint.layerY)}})),t(this,"windowMouseUp",(()=>{this.isMove=!1,this.iframeHandle.style.pointerEvents="",this.frameHandle.style.cursor=""})),this.lastClickTime=(new Date).getTime(),this.uid=this.uuid();const{url:e=!1,ico:s=!1,width:n=!1,height:a=!1,top:l=!1,left:M=!1,title:o="",origin:d={},minHeight:g=0,minWidth:r=0}=i;e&&(this.url=e),this.ico=s,n&&(this.width=n),a&&(this.height=a),r&&(this.minWidth=r),g&&(this.minHeight=g),window.innerWidth<500&&(this.width=window.innerWidth,this.height=window.innerHeight,this.borderRadius="0px"),this.origin=d,this.title=o,h.push(this)}setTitle(i=""){this.title=i.length>0?i:this.title,this.titleHandle=document.createElement("div"),this.titleHandle.innerHTML=`${this.ico?`ico`:""}${this.title}`,Object.assign(this.titleHandle.style,{position:"absolute",left:"5px",display:"flex",fontSize:"15px",pointerEvents:"none",alignItems:"center",height:this.px(this.headerHeight)}),this.frameHandle.appendChild(this.titleHandle)}Frame(){return this.frameHandle=document.createElement("div"),this.frameHandle.dataset.drag="move",Object.assign(this.frameHandle.style,{position:"absolute",background:"rgba(255,255,255,1)",top:"0px",left:"0px",borderRadius:"8px 8px 0px 0px",width:"100%",height:this.px(this.headerHeight),userSelect:"none"}),this.frameHandle.onmousedown=i=>{const{drag:t=""}=i.target.dataset;if("move"===t){if(this.lastClickTime>(new Date).getTime()-500)return void this.setFull();this.lastClickTime=(new Date).getTime();const{x:t,y:e,layerX:s,layerY:n}=i;this.movePoint.x=t,this.movePoint.y=e,this.movePoint.layerX=s,this.movePoint.layerY=n,this.iframeHandle.style.pointerEvents="none",this.isMove=!0,this.frameHandle.style.cursor="move"}this.resetIndex()},this.miniFrame(),this.fullFrame(),this.closeFrame(),this.frameHandle}closeFrame(){let i=document.createElement("div");i.className="window-close",i.innerHTML='close',i.title="关闭窗口",Object.assign(i.style,{width:"50px",position:"absolute",height:this.px(this.headerHeight),display:"flex",right:"0px"}),i.onclick=i=>{this.close(),i.stopPropagation()},this.frameHandle.appendChild(i)}fullFrame(){let i=document.createElement("div");i.className="window-full",i.innerHTML='close',i.title="最大化窗口",Object.assign(i.style,{width:"50px",position:"absolute",height:this.px(this.headerHeight),display:"flex",userSelect:"none",right:"50px"}),i.onclick=()=>{this.setFull()},this.frameHandle.appendChild(i)}refreshFrame(){if(/^http/.test(this.url))return!1;let i=document.createElement("div");i.className="window-refresh",i.innerHTML='refresh',i.title="刷新",Object.assign(i.style,{width:"50px",position:"absolute",height:this.px(this.headerHeight),display:"flex",userSelect:"none",right:"150px"}),i.onclick=()=>{this.iframeHandle.contentWindow.location.reload()},this.frameHandle.appendChild(i)}setFull(){this.tmpTime&&this.tmpTime>(new Date).getTime()-500||(this.tmpTime=(new Date).getTime(),this.isFull?(Object.assign(this.dialogHandle.style,{width:this.px(this.lastSize.width),height:this.px(this.lastSize.height),left:this.px(this.lastSize.left),top:this.px(this.lastSize.top)}),setTimeout((()=>{Object.assign(this.dialogHandle.style,{transition:"none"})}),300),this.isFull=!1):(Object.assign(this.dialogHandle.style,{transition:"all .3s"}),Object.assign(this.dialogHandle.style,{width:"100%",height:`calc(100% - ${this.footerHeight}px)`,left:"0px",top:"0px"}),this.lastSize={left:this.left,top:this.top,width:this.width,height:this.height},this.isFull=!0))}miniFrame(){let i=document.createElement("div");i.className="window-mini",i.innerHTML='close',i.title="最小化",i.onclick=()=>{this.setMineSize()},Object.assign(i.style,{width:"50px",position:"absolute",height:this.px(this.headerHeight),display:"flex",userSelect:"none",right:"100px"}),this.frameHandle.appendChild(i)}resetIndex(){let i=0,t=null;h.forEach((e=>{e.zIndex>i&&(i=e.zIndex,t=e)})),t.uid!==this.uid&&(i+=1),this.setZIndex(i)}Iframe(){return this.iframeHandle=document.createElement("iframe"),this.iframeHandle.src=this.url,this.iframeHandle.dataset.uid=this.uid,Object.assign(this.iframeHandle.style,{position:"absolute",top:this.px(this.headerHeight),border:"none",outline:"none",transform:"scale(1)",width:"100%",height:`calc(100% - ${this.px(this.headerHeight)})`}),this.iframeHandle}px(i){return i+"px"}getElementCenterPosition(i,t){const e=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,s=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;return{x:Math.floor((e-i)/2),y:Math.floor((s-t)/2)}}setPosition(i=0,t=0){i<0&&(i=0),i>window.innerWidth-this.width&&(i=window.innerWidth-this.width),t<0&&(t=0),t>window.innerHeight-this.height&&(t=window.innerHeight-this.height),this.left=i,this.top=t,Object.assign(this.dialogHandle.style,{left:this.px(i),top:this.px(t)})}setZIndex(i=1e3){this.zIndex=i,this.dialogHandle.style.zIndex=this.zIndex}append(){document.body.appendChild(this.dialogHandle),a.emit("refresh",h)}setMineSize(){!0===this.isMinimize?(this.dialogHandle.style.display="block",this.isMinimize=!1):(this.dialogHandle.style.display="none",this.isMinimize=!0)}open(){this.dialogHandle=document.createElement("div");const{x:i,y:t}=this.getElementCenterPosition(this.width,this.height);this.left=i,this.top=t,this.dialogHandle.className="mtabUi-dialog",Object.assign(this.dialogHandle.style,{position:"fixed",background:"#fff",width:this.px(this.width),height:this.px(this.height),left:this.px(i),top:this.px(t),minWidth:this.px(this.minWidth),minHeight:this.px(this.minHeight),resize:"auto",borderRadius:this.borderRadius}),this.dialogHandle.appendChild(this.Frame()),this.dialogHandle.appendChild(this.Iframe()),this.setTitle(this.title),this.resetIndex(),this.refreshFrame(),this.append(),this.bindEvent(),this.resetIndex()}bindEvent(){window.addEventListener("mousemove",this.windowMove),window.addEventListener("mouseup",this.windowMouseUp);new MutationObserver((i=>{i.forEach((i=>{this.width=this.dialogHandle.clientWidth,this.height=this.dialogHandle.clientHeight}))})).observe(this.dialogHandle,{attributes:!0,childList:!1,subtree:!1})}close(){window.removeEventListener("mousemove",this.windowMove),window.removeEventListener("mouseup",this.windowMouseUp),h.forEach(((i,t)=>{i.uid===this.uid&&h.splice(t,1)})),document.body.removeChild(this.dialogHandle),a.emit("refresh",h)}}window.MtabManager=a,window.MtabUi=M,window.openCard=function(i){const{width:t=null,height:e=null,minHeight:s=null,minWidth:n=null}=i;new M({width:null==t?window.innerWidth<1250?850:1200:t,height:null==e?window.innerHeight<750?550:700:e,title:i.name,ico:i.src,url:i.url,minHeight:s,minWidth:n}).open()};const o=i=>{window.openCard({name:i.name,src:i.src,url:i.window})},d=(i,t=0)=>{const e=s.getters.find(i);if(e){const{app:i=0}=e;if(1===i){let i="";i=(/^http/.test(e.url),e.url),window.openCard({name:e.name,src:e.src,url:i})}else r(e.url)}},g=i=>{let t=document.createElement("a");t.href=i,t.target="_blank",t.click(),t.remove()},r=(i,t=!1)=>{if(n[i])n[i]();else if(t)g(i);else if(s.state.config.openType.linkOpen)g(i);else{let t=document.createElement("a");t.href=i,t.click(),t.remove()}};export{n as C,a as M,g as a,r as b,h as d,o,d as r};