import{c as Q,o as he,h as ge,g as S,t as C,a as X,s as n,i as $,b as re,S as ue,m as Z,e as H,k as ne,l as Be,d as je,u as He,r as Te,D as Ke}from"./web.gEHESIx2.js";var Ve=C('
'),Je=C('
');function Ze(e){const[t,r]=Q(""),i=()=>{const o=new Date,s=e.settings.format||"24h",a=e.settings.timeFormat||"HH:MM:SS";let c=o.getHours();const l=o.getMinutes().toString().padStart(2,"0"),m=o.getSeconds().toString().padStart(2,"0");let x="",v="";s==="12h"&&(v=c>=12?" PM":" AM",c=c%12||12);const b=s==="24h"?c.toString().padStart(2,"0"):c.toString();switch(a){case"HH:MM:SS":x=`${b}:${l}:${m}${v}`;break;case"HH:MM":x=`${b}:${l}${v}`;break;case"HH only":x=`${b}${v}`;break;default:x=`${b}:${l}:${m}${v}`}e.settings.showDate&&(x=`${o.toLocaleDateString()} ${x}`),r(x)};return he(()=>{i();const o=e.settings.refreshRate||1,s=setInterval(i,o*1e3);ge(()=>clearInterval(s))}),(()=>{var o=S(Je),s=o.firstChild,a=s.nextSibling,[c,l]=X(a.nextSibling);return n(o,"border","1px solid var(--border)"),n(o,"padding","1rem"),n(o,"width","100%"),n(o,"height","100%"),n(o,"display","flex"),n(o,"background","var(--bg, #fff)"),$(s,t),$(o,re(ue,{get when(){return e.settings.showLabel},get children(){var m=S(Ve);return n(m,"color","var(--gray)"),$(m,()=>e.settings.label||"Current Time"),m}}),c,l),o})()}const et={name:"Clock",description:"Display current time and date",settingsSchema:{format:{type:"select",label:"Time Format",default:"24h",options:["12h","24h"],required:!0},timeFormat:{type:"select",label:"Display Format",default:"HH:MM:SS",options:["HH:MM:SS","HH:MM","HH only"]},showDate:{type:"boolean",label:"Show Date",default:!0},showLabel:{type:"boolean",label:"Show Label",default:!0},label:{type:"string",label:"Custom Label",default:"Current Time"},refreshRate:{type:"number",label:"Refresh Rate (seconds)",default:1}}};function tt(e,t){return e*({seconds:1e3,minutes:6e4,hours:36e5,days:864e5}[t]||1e3)}function qe(e,t=60,r="minutes"){const i=e.refreshIntervalValue||t,o=e.refreshIntervalUnit||r;return tt(i,o)}var nt=C('
'),it=C('
');const Oe=new Map,ke=new Map,ve=new Map;function rt(e){const t=`${e.settings.symbol}-${e.settings.currency}`,r=5e3,[i,o]=Q(ke.get(t)||"Loading..."),[s,a]=Q(ve.get(t)||""),c=async()=>{const l=Date.now(),m=Oe.get(t)||0;if(l-m{ke.has(t)||c();const l=qe(e.settings,1,"minutes"),m=setInterval(()=>{c()},l);ge(()=>{clearInterval(m)})}),(()=>{var l=S(nt),m=l.firstChild,x=m.nextSibling,v=x.nextSibling,[b,g]=X(v.nextSibling);return n(l,"border","1px solid var(--border)"),n(l,"padding","1rem"),n(l,"width","100%"),n(l,"height","100%"),n(l,"display","flex"),n(l,"background","var(--bg, #fff)"),$(m,()=>e.settings.symbol||"BTC"),$(x,()=>s()||i()),$(l,(()=>{var h=Z(()=>!!e.settings.showLabel);return()=>h()&&(()=>{var p=S(it);return n(p,"color","var(--gray)"),$(p,()=>e.settings.label||"Price"),p})()})(),b,g),l})()}const ot={name:"Crypto Price",description:"Display cryptocurrency price from CoinGecko API",settingsSchema:{symbol:{type:"string",label:"Crypto Symbol (e.g., bitcoin, ethereum)",default:"bitcoin",required:!0},currency:{type:"string",label:"Currency (e.g., USD, EUR)",default:"USD",required:!0},refreshIntervalValue:{type:"number",label:"Refresh Interval",default:1,required:!0},refreshIntervalUnit:{type:"select",label:"Unit",options:["seconds","minutes","hours","days"],default:"minutes",required:!0},showLabel:{type:"boolean",label:"Show Label",default:!0},label:{type:"string",label:"Custom Label",default:"Price"}}};var at=C('
'),lt=C('
'),st=C('
°'),dt=C('
'),ct=C('
💧 %
💨 m/s'),ut=C("
");function ht(e){const[t,r]=Q(null),[i,o]=Q(""),s=async()=>{try{const a=e.settings.city||"London",c=e.settings.lat||"",l=e.settings.lon||"",m=e.settings.apiKey||"",x=e.settings.units||"metric";if(!m){o("API key required");return}let v=`/api/weather?apiKey=${encodeURIComponent(m)}&units=${x}`;c&&l?v+=`&lat=${encodeURIComponent(c)}&lon=${encodeURIComponent(l)}`:v+=`&city=${encodeURIComponent(a)}`;const b=await fetch(v);if(!b.ok)throw new Error("Failed to fetch weather");const g=await b.json();r({temp:Math.round(g.main.temp),description:g.weather[0].description,humidity:g.main.humidity,windSpeed:g.wind.speed}),o("")}catch(a){o("Error fetching weather"),console.error(a)}};return he(()=>{s();const a=qe(e.settings,10,"minutes"),c=setInterval(s,a);ge(()=>clearInterval(c))}),(()=>{var a=S(ut),c=a.firstChild,[l,m]=X(c.nextSibling),x=l.nextSibling,[v,b]=X(x.nextSibling);return n(a,"border","1px solid var(--border)"),n(a,"padding","1rem"),n(a,"width","100%"),n(a,"height","100%"),n(a,"display","flex"),n(a,"background","var(--bg, #fff)"),$(a,re(ue,{get when(){return i()},get children(){var g=S(at);return n(g,"color","#ff4444"),$(g,i),g}}),l,m),$(a,re(ue,{get when(){return Z(()=>!i())()&&t()},get children(){return[(()=>{var g=S(lt);return $(g,(()=>{var h=Z(()=>!!(e.settings.lat&&e.settings.lon));return()=>h()?`${e.settings.lat}, ${e.settings.lon}`:e.settings.city||"London"})()),g})(),(()=>{var g=S(st),h=g.firstChild,[p,L]=X(h.nextSibling),z=p.nextSibling,P=z.nextSibling,[w,q]=X(P.nextSibling);return $(g,()=>t()?.temp,p,L),$(g,()=>e.settings.units==="metric"?"C":"F",w,q),g})(),(()=>{var g=S(dt);return n(g,"color","var(--gray)"),$(g,()=>t()?.description),g})(),re(ue,{get when(){return e.settings.showDetails},get children(){var g=S(ct),h=g.firstChild,p=h.firstChild,L=p.nextSibling,[z,P]=X(L.nextSibling);z.nextSibling;var w=h.nextSibling,q=w.firstChild,B=q.nextSibling,[f,d]=X(B.nextSibling);return f.nextSibling,n(g,"display","flex"),n(g,"gap","1rem"),n(g,"color","var(--gray)"),$(h,()=>t()?.humidity,z,P),$(w,()=>t()?.windSpeed,f,d),g}})]}}),v,b),a})()}const gt={name:"Weather",description:"Display current weather from OpenWeatherMap API",settingsSchema:{city:{type:"string",label:"City Name",default:"London",required:!1},lat:{type:"string",label:"Latitude (optional, overrides city)",default:"",required:!1},lon:{type:"string",label:"Longitude (optional, overrides city)",default:"",required:!1},apiKey:{type:"string",label:"OpenWeatherMap API Key",default:"",required:!0},units:{type:"select",label:"Temperature Units",default:"metric",options:["metric","imperial"]},showDetails:{type:"boolean",label:"Show Humidity & Wind",default:!0},refreshIntervalValue:{type:"number",label:"Refresh Interval",default:10,required:!0},refreshIntervalUnit:{type:"select",label:"Unit",options:["seconds","minutes","hours","days"],default:"minutes",required:!0}}};var mt=C('
Σ
Stoic Wisdom'),ft=C("
"),vt=C('
""'),bt=C("
");const Ue=new Map,De=new Map;function yt(e){const t="stoic-quote",i=De.get(t)||{text:"Loading wisdom...",author:""},[o,s]=Q(i),[a,c]=Q(""),[l,m]=Q(0),x=async(h=!1)=>{const p=Date.now(),L=Ue.get(t)||0;if(!h&&p-L<1e4){console.log("[StoicQuote] Cooldown active, skipping manual refresh");return}Ue.set(t,p),console.log("[StoicQuote] Fetching quote from API...");try{const z=await fetch("https://stoic-quotes.com/api/quote");if(!z.ok)throw new Error("Failed to fetch quote");const P=await z.json(),w={text:P.text,author:P.author};console.log("[StoicQuote] ✨ New quote received:",{author:w.author,preview:w.text.substring(0,50)+"...",timestamp:new Date().toLocaleTimeString()}),s(w),c(""),De.set(t,w),m(q=>q+1),console.log("[StoicQuote] ✅ Quote state updated, render key incremented, forcing re-render")}catch(z){console.error("[StoicQuote] Error:",z),c("Failed to load quote")}};he(()=>{De.has(t)||x(!0);const h=qe(e.settings,1,"hours");console.log(`[StoicQuote] Setting up interval: ${h}ms`);const p=setInterval(()=>{console.log("[StoicQuote] Interval tick - fetching new quote"),x(!0)},h);ge(()=>{console.log("[StoicQuote] Cleaning up interval"),clearInterval(p)})});const v=()=>e.settings.showAuthor!==!1,b=()=>e.settings.fontSize||"medium",g=()=>{const h={small:{quote:"clamp(0.7rem, 1.5vw, 1.2rem)",author:"clamp(0.6rem, 1.2vw, 0.9rem)"},medium:{quote:"clamp(0.9rem, 2vw, 1.5rem)",author:"clamp(0.7rem, 1.5vw, 1.1rem)"},large:{quote:"clamp(1.1rem, 2.5vw, 2rem)",author:"clamp(0.8rem, 1.8vw, 1.3rem)"}};return h[b()]||h.medium};return(()=>{var h=S(mt),p=h.firstChild,L=p.nextSibling,z=L.nextSibling;return n(h,"border","1px solid var(--border)"),n(h,"padding","1rem"),n(h,"width","100%"),n(h,"height","100%"),n(h,"display","flex"),n(h,"background","var(--bg, #fff)"),n(h,"position","relative"),n(p,"position","absolute"),n(p,"top","0.5rem"),n(p,"left","0.5rem"),n(p,"color","var(--border, #ccc)"),n(p,"opacity","0.3"),$(L,(()=>{var P=Z(()=>!!a());return()=>P()?(()=>{var w=S(ft);return n(w,"color","var(--gray, #999)"),$(w,a),w})():[(()=>{var w=S(vt),q=w.firstChild,B=q.nextSibling,[f,d]=X(B.nextSibling);return f.nextSibling,$(w,()=>o().text,f,d),H(k=>n(w,"font-size",g().quote)),w})(),Z(()=>Z(()=>!!(v()&&o().author))()&&(()=>{var w=S(bt),q=w.firstChild,B=q.nextSibling,[f,d]=X(B.nextSibling);return n(w,"color","var(--gray, #666)"),$(w,()=>o().author,f,d),H(k=>n(w,"font-size",g().author)),w})())]})()),n(z,"position","absolute"),n(z,"bottom","8px"),n(z,"left","8px"),n(z,"color","var(--gray, #999)"),n(z,"opacity","0.5"),H(()=>ne(h,"data-render-key",l())),h})()}const xt={name:"Stoic Quote",description:"Display stoic wisdom from Marcus Aurelius, Seneca, and Epictetus",settingsSchema:{fontSize:{type:"select",label:"Font Size",options:["small","medium","large"],default:"medium"},showAuthor:{type:"boolean",label:"Show Author",default:!0},refreshIntervalValue:{type:"number",label:"Refresh Interval",default:1,required:!0},refreshIntervalUnit:{type:"select",label:"Unit",options:["seconds","minutes","hours","days"],default:"hours",required:!0}}},pt={"crypto-price":{schema:ot,Component:rt},clock:{schema:et,Component:Ze},weather:{schema:gt,Component:ht},"stoic-quote":{schema:xt,Component:yt}};function wt(e){return pt[e]}var Me={dragStart:!0},ze={delay:0,distance:3};function $t(e,t={}){let r,i,{bounds:o,axis:s="both",gpuAcceleration:a=!0,legacyTranslate:c=!1,transform:l,applyUserSelectHack:m=!0,disabled:x=!1,ignoreMultitouch:v=!1,recomputeBounds:b=Me,grid:g,threshold:h=ze,position:p,cancel:L,handle:z,defaultClass:P="neodrag",defaultClassDragging:w="neodrag-dragging",defaultClassDragged:q="neodrag-dragged",defaultPosition:B={x:0,y:0},onDragStart:f,onDrag:d,onDragEnd:k}=t,M=!1,I=!1,U=0,A=!1,E=!1,N=0,Y=0,_=0,y=0,K=0,ie=0,{x:ee,y:te}=p?{x:p?.x??0,y:p?.y??0}:B;$e(ee,te);let W,G,oe,xe,pe,Pe="",Qe=!!p;b={...Me,...b},h={...ze,...h??{}};let me=new Set;function Ae(u){M&&!I&&E&&A&&pe&&(I=!0,(function(R){Se("neodrag:start",f,R)})(u),V.add(w),m&&(Pe=we.userSelect,we.userSelect="none"))}const we=document.body.style,V=e.classList;function $e(u=N,R=Y){if(!l){if(c){let O=`${+u}px, ${+R}px`;return be(e,"transform",a?`translate3d(${O}, 0)`:`translate(${O})`)}return be(e,"translate",`${+u}px ${+R}px`)}const T=l({offsetX:u,offsetY:R,rootNode:e});Ie(T)&&be(e,"transform",T)}function Se(u,R,T){const O=(function(F){return{offsetX:N,offsetY:Y,rootNode:e,currentNode:pe,event:F}})(T);e.dispatchEvent(new CustomEvent(u,{detail:O})),R?.(O)}const fe=addEventListener,Ce=new AbortController,_e={signal:Ce.signal,capture:!1};function Fe(){let u=e.offsetWidth/G.width;return isNaN(u)&&(u=1),u}return be(e,"touch-action","none"),fe("pointerdown",(u=>{if(x||u.button===2)return;if(me.add(u.pointerId),v&&me.size>1)return u.preventDefault();if(b.dragStart&&(W=Re(o,e)),Ie(z)&&Ie(L)&&z===L)throw new Error("`handle` selector can't be same as `cancel` selector");if(V.add(P),oe=(function(D,J){if(!D)return[J];if(Le(D))return[D];if(Array.isArray(D))return D;const j=J.querySelectorAll(D);if(j===null)throw new Error("Selector passed for `handle` option should be child of the element on which the action is applied");return Array.from(j.values())})(z,e),xe=(function(D,J){if(!D)return[];if(Le(D))return[D];if(Array.isArray(D))return D;const j=J.querySelectorAll(D);if(j===null)throw new Error("Selector passed for `cancel` option should be child of the element on which the action is applied");return Array.from(j.values())})(L,e),r=/(both|x)/.test(s),i=/(both|y)/.test(s),We(xe,oe))throw new Error("Element being dragged can't be a child of the element on which `cancel` is applied");const R=u.composedPath()[0];if(!oe.some((D=>D.contains(R)||D.shadowRoot?.contains(R)))||We(xe,[R]))return;pe=oe.length===1?e:oe.find((D=>D.contains(R))),M=!0,U=Date.now(),h.delay||(A=!0),G=e.getBoundingClientRect();const{clientX:T,clientY:O}=u,F=Fe();r&&(_=T-ee/F),i&&(y=O-te/F),W&&(K=T-G.left,ie=O-G.top)}),_e),fe("pointermove",(u=>{if(!M||v&&me.size>1)return;if(!I){if(A||Date.now()-U>=h.delay&&(A=!0,Ae(u)),!E){const F=u.clientX-_,D=u.clientY-y;Math.sqrt(F**2+D**2)>=h.distance&&(E=!0,Ae(u))}if(!I)return}b.drag&&(W=Re(o,e)),u.preventDefault(),G=e.getBoundingClientRect();let R=u.clientX,T=u.clientY;const O=Fe();if(W){const F={left:W.left+K,top:W.top+ie,right:W.right+K-G.width,bottom:W.bottom+ie-G.height};R=Ne(R,F.left,F.right),T=Ne(T,F.top,F.bottom)}if(Array.isArray(g)){let[F,D]=g;if(isNaN(+F)||F<0)throw new Error("1st argument of `grid` must be a valid positive number");if(isNaN(+D)||D<0)throw new Error("2nd argument of `grid` must be a valid positive number");let J=R-_,j=T-y;[J,j]=St([F/O,D/O],J,j),R=_+J,T=y+j}r&&(N=Math.round((R-_)*O)),i&&(Y=Math.round((T-y)*O)),ee=N,te=Y,Se("neodrag",d,u),$e()}),_e),fe("pointerup",(u=>{me.delete(u.pointerId),M&&(I&&(fe("click",(R=>R.stopPropagation()),{once:!0,signal:Ce.signal,capture:!0}),b.dragEnd&&(W=Re(o,e)),V.remove(w),V.add(q),m&&(we.userSelect=Pe),Se("neodrag:end",k,u),r&&(_=N),i&&(y=Y)),M=!1,I=!1,A=!1,E=!1)}),_e),{destroy:()=>Ce.abort(),update:u=>{s=u.axis||"both",x=u.disabled??!1,v=u.ignoreMultitouch??!1,z=u.handle,o=u.bounds,b=u.recomputeBounds??Me,L=u.cancel,m=u.applyUserSelectHack??!0,g=u.grid,a=u.gpuAcceleration??!0,c=u.legacyTranslate??!1,l=u.transform,h={...ze,...u.threshold??{}};const R=V.contains(q);V.remove(P,q),P=u.defaultClass??"neodrag",w=u.defaultClassDragging??"neodrag-dragging",q=u.defaultClassDragged??"neodrag-dragged",V.add(P),R&&V.add(q),Qe&&(ee=N=u.position?.x??N,te=Y=u.position?.y??Y,$e())}}}var Ne=(e,t,r)=>Math.min(Math.max(e,t),r),Ie=e=>typeof e=="string",St=([e,t],r,i)=>{const o=(s,a)=>a===0?0:Math.ceil(s/a)*a;return[o(r,e),o(i,t)]},We=(e,t)=>e.some((r=>t.some((i=>r.contains(i)))));function Re(e,t){if(e===void 0)return;if(Le(e))return e.getBoundingClientRect();if(typeof e=="object"){const{top:i=0,left:o=0,right:s=0,bottom:a=0}=e;return{top:i,right:window.innerWidth-s,bottom:window.innerHeight-a,left:o}}if(e==="parent")return t.parentNode.getBoundingClientRect();const r=document.querySelector(e);if(r===null)throw new Error("The selector provided for bound doesn't exists in the document.");return r.getBoundingClientRect()}var be=(e,t,r)=>e.style.setProperty(t,r),Le=e=>e instanceof HTMLElement,Ct=()=>({draggable:(e,t)=>{const{update:r,destroy:i}=$t(e,t());ge(i),Be((()=>r(t())))}}),_t=C("
"),kt=C("