PageSourceSearch

https://verial.ai/assets/animated-theme-toggler-CIBk3pDw.js

js verial.ai collected 2026-09-24 14:07:52 UTC 3,843 bytes, 1 lines download raw bytes

1import{j as l}from"./jsx-runtime-u17CrQMm.js";import{r as a}from"./chunk-UVKPFVEO-DHFSZO06.js";import{r as P}from"./index-CGEc72Sa.js";import{c as R}from"./misc-D_N5Jm87.js";import{p as v,T as E,a as S}from"./theme-iQBJGOW4.js";import{c as T}from"./createLucideIcon-aD15QNAe.js";const W=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],I=T("monitor",W);const V=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],D=T("moon",V);const H=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],q=T("sun",H),g=["light","dark","system"],b=e=>g[(g.indexOf(e)+1)%g.length]??"light";function z(e){return"startViewTransition"in e&&typeof e.startViewTransition=="function"}function f(e){if(e==="system"){const i=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",i);return}document.documentElement.classList.toggle("dark",e==="dark")}function F(e){const i=document.cookie.split(";").map(m=>m.trim()).find(m=>m.startsWith(`${e}=`));return i?decodeURIComponent(i.slice(e.length+1)):null}function K(e){if(e==="system"){document.cookie=`${E}=; path=/; max-age=0`;return}document.cookie=`${E}=${e}; path=/; max-age=${S}`}const B=a.forwardRef(function({className:i,duration:m=400,iconOnly:$=!1,onThemeChange:y,showCurrentIcon:N=!1,..._},u){const[w,k]=a.useState("light"),x=a.useRef(null),t=a.useRef("light"),j=a.useCallback(r=>{x.current=r,typeof u=="function"?u(r):u&&(u.current=r)},[u]);a.useEffect(()=>{const n=v(F(E)??document.documentElement.dataset.themePreference)??(document.documentElement.classList.contains("dark")?"dark":"light");t.current=n,k(n),document.documentElement.dataset.themePreference=n,f(n);const d=()=>{const o=v(document.documentElement.dataset.themePreference);!o||o===t.current||(t.current=o,k(o),f(o))};d();const p=new MutationObserver(d);p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme-preference"]});const s=window.matchMedia("(prefers-color-scheme: dark)"),c=()=>{t.current==="system"&&f("system")};return s.addEventListener?s.addEventListener("change",c):s.addListener(c),()=>{p.disconnect(),s.removeEventListener?s.removeEventListener("change",c):s.removeListener(c)}},[]);const L=a.useCallback(async()=>{if(!x.current)return;const r=()=>{const h=b(t.current);t.current=h,k(h),K(h),document.documentElement.dataset.themePreference=h,f(h)};if(!z(document)){r(),y?.(t.current);return}await document.startViewTransition(()=>{P.flushSync(()=>{r()})}).ready,y?.(t.current);const{top:n,left:d,width:p,height:s}=x.current.getBoundingClientRect(),c=d+p/2,o=n+s/2,O=Math.hypot(Math.max(d,window.innerWidth-d),Math.max(n,window.innerHeight-n)),A={duration:m,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"};document.documentElement.animate({clipPath:[`circle(0px at ${c}px ${o}px)`,`circle(${O}px at ${c}px ${o}px)`]},A)},[m,y]),C=b(w),M=N?w:C;return l.jsxs("button",{ref:j,onClick:L,className:R("flex items-center justify-center",$?"h-5 w-5 rounded-md":"",i),..._,children:[M==="system"?l.jsx(I,{className:"h-4 w-4",strokeWidth:2}):M==="dark"?l.jsx(D,{className:"h-4 w-4",strokeWidth:2}):l.jsx(q,{className:"h-4 w-4",strokeWidth:2}),l.jsx("span",{className:"sr-only",children:"Toggle theme"})]})});B.displayName="AnimatedThemeToggler";export{B as A,D as M,q as S,I as a};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.