import{r as e,u as t,o as n,b as o,h as a,n as s,q as i,I as l,F as r,i as c,t as m,e as u,v as h,w as v,an as d,f as p}from"./vendor-jA_NIjzi.js";import{k as w,u as x,q as g}from"./common-utils-RDWuRZ1M.js";import{_ as f}from"./common-store-kFD1YPwN.js";import"./vendor-crypto-Vtl7-GZS.js";import"./vendor-mqtt-lYGapirz.js";const b={class:"theme-menu"},M=["onClick"],I=f({__name:"index",setup(f){const I=w(),k=e(!1),{theme:y,setTheme:E}=x(),L=e((()=>{const e=localStorage.getItem("theme-switcher-position");if(e)try{return JSON.parse(e)}catch(t){return{right:"40px",bottom:"120px"}}return{right:"40px",bottom:"120px"}})());let _=!1,j=0,S=0,X=0,Y=0;const q=[{label:"蓝紫",value:"light",index:0},{label:"黑金",value:"dark",index:1},{label:"红色",value:"red",index:2},{label:"白金",value:"whiteGold",index:3},{label:"紫罗兰",value:"violet",index:4}],C=()=>{k.value=!k.value},H=e=>{e.target.closest(".menu-item")||(_=!0,j=e.clientX,S=e.clientY,X=parseInt(L.value.right),Y=parseInt(L.value.bottom),document.addEventListener("mousemove",J),document.addEventListener("mouseup",N))},J=e=>{if(!_)return;const t=j-e.clientX,n=e.clientY-S;let o=X+t,a=Y-n;const s=window.innerWidth,i=window.innerHeight;o=Math.min(Math.max(15,o),s-24-15),a=Math.min(Math.max(15,a),i-24-15),L.value={right:"".concat(o,"px"),bottom:"".concat(a,"px")}},N=()=>{_=!1,document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",N),localStorage.setItem("theme-switcher-position",JSON.stringify(L.value))},O=e=>{e.target.closest(".menu-item")||(_=!0,j=e.touches[0].clientX,S=e.touches[0].clientY,X=parseInt(L.value.right),Y=parseInt(L.value.bottom),document.addEventListener("touchmove",W,{passive:!1}),document.addEventListener("touchend",A))},W=e=>{if(!_)return;e.preventDefault();const t=j-e.touches[0].clientX,n=e.touches[0].clientY-S;let o=X+t,a=Y-n;const s=window.innerWidth,i=window.innerHeight;o=Math.min(Math.max(15,o),s-24-15),a=Math.min(Math.max(15,a),i-24-15),L.value={right:"".concat(o,"px"),bottom:"".concat(a,"px")}},A=()=>{_=!1,document.removeEventListener("touchmove",W),document.removeEventListener("touchend",A),localStorage.setItem("theme-switcher-position",JSON.stringify(L.value))},P=e=>{const t=parseInt(L.value.right)<window.innerWidth/2,n=parseInt(L.value.bottom),o=n>window.innerHeight-200,a=n<200;let s;s=t&&a?180:t&&o?90:!t&&a||!t&&o?0:t?180:0;const i=!t&&a?(s-45*e)*(Math.PI/180):(s+45*e)*(Math.PI/180);return{transform:"\n\t\t\ttranslate(\n\t\t\t\t".concat(60*Math.cos(i),"px,\n\t\t\t\t").concat(60*Math.sin(i),"px\n\t\t\t)\n\t\t")}};return(e,w)=>[600,1003,1004,617,2011].includes(t(I))&&!t(g)()?(n(),o("div",{key:0,class:"theme-switcher",style:c(L.value),onMousedown:H,onTouchstart:O},[a("div",{class:s(["theme-button",{"is-active":k.value}]),onClick:C},w[0]||(w[0]=[a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"14",height:"14"},[a("g",{fill:"none"},[a("path",{class:"theme-icon-fill",d:"M2.75 12A9.25 9.25 0 0 0 12 21.25V2.75A9.25 9.25 0 0 0 2.75 12"}),a("path",{class:"theme-icon-stroke","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M12 21.25a9.25 9.25 0 0 0 0-18.5m0 18.5a9.25 9.25 0 0 1 0-18.5m0 18.5V2.75"})])],-1)]),2),i(d,{name:"fade"},{default:l((()=>[v(a("div",b,[(n(),o(r,null,u(q,(e=>a("div",{key:e.value,class:s(["menu-item",["item-".concat(e.value),{active:t(y)===e.value}]]),style:c(P(e.index)),onClick:t=>(e=>{E(e),k.value=!1})(e.value)},m(e.label),15,M))),64))],512),[[h,k.value]])])),_:1})],36)):p("",!0)}},[["__scopeId","data-v-60895944"],["__file","index.vue"]]);export{I as default};
