1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[858],{1858:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var a=r(5853),n=r(4041),i=r(9193),l=r(627),o=r(508),s=r(6065);function c(){let e=(0,n.useRef)(null),t=(0,n.useRef)(null),r=(0,n.useRef)([]),c=(0,n.useRef)({x:0,y:0,isMoving:!1}),h=(0,n.useRef)(0),[u,f]=(0,n.useState)({width:0,height:0}),p=(0,n.useRef)(0),d=(0,n.useRef)(new Map),m=(0,i.QY)(),M=(0,i.jn)(),g=(0,i.Yy)(),v=(0,n.useRef)(m),y=(0,n.useRef)(M),w=(0,n.useRef)(g);(0,n.useEffect)(()=>{v.current=m},[m]),(0,n.useEffect)(()=>{y.current=M},[M]),(0,n.useEffect)(()=>{w.current=g},[g]);let x=(0,n.useRef)([]);(0,i.X6)(e=>{let{others:t}=e;x.current=t.map(e=>e.presence.cursor).filter(e=>null!==e)}),(0,i.ML)(e=>{let{event:t}=e;if("LAUNCH_FIREWORK"===t.type&&!document.hidden){let e=Date.now();if(e-p.current<100)return;p.current=e,b(t.x,t.y,t.color)}});let b=(0,n.useCallback)((e,t,a)=>{r.current.length>=20&&r.current.shift(),r.current=[...r.current,{particles:[],phase:"launch",launchX:e,launchY:0,trailTailY:0,targetY:t,age:0,opacity:1,trailOpacity:1,color:a}]},[]);return(0,n.useEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=t.getBoundingClientRect();f(t=>t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})};r();let a=new ResizeObserver(r);return a.observe(t),()=>a.disconnect()},[]),(0,n.useEffect)(()=>{let e,a=t.current;if(!a)return;let n=Math.min(window.devicePixelRatio||1,2);a.width=u.width*n,a.height=u.height*n,a.style.width="".concat(u.width,"px"),a.style.height="".concat(u.height,"px");let i=a.getContext("2d");if(!i)return;i.scale(n,n);let f=null,p=null,m=!1,M=(0,o.B)({spacing:s.m}),g=(0,o.B)({spacing:s.m}),E=t=>{if("mouse"!==t.pointerType)return;m=!0;let r=a.getBoundingClientRect(),n=t.clientX-r.left,i=t.clientY-r.top;c.current.x=n,c.current.y=i,c.current.isMoving=!0,M.move(n,i),f={x:n,y:i},null===p&&(p=requestAnimationFrame(()=>{p=null,f&&(v.current({cursor:f}),f=null)})),clearTimeout(e),e=setTimeout(()=>{c.current.isMoving=!1},100)},R=()=>{m=!1,f=null,null!==p&&(cancelAnimationFrame(p),p=null),M.leave(),v.current({cursor:null})},Y=(e,t)=>{var r,a;let n=null==(a=w.current)||null==(r=a.info)?void 0:r.color;b(e,t,n),y.current({type:"LAUNCH_FIREWORK",x:e,y:t,color:n}),(0,l.I)("firework")},A=e=>{let t=a.getBoundingClientRect();Y(e.clientX-t.left,e.clientY-t.top)},L=e=>{if(("Enter"===e.key||" "===e.key)&&!e.repeat)" "===e.key&&e.preventDefault(),Y(.2*u.width+Math.random()*u.width*.6,.2*u.height+Math.random()*u.height*.6)},T=e=>{let{x:t,y:r,color:a}=e.detail;b(t,r,a),(0,l.I)("firework")},O=t=>{let{x:r,y:a,color:n}=t.detail;g.move(r,a,n),m||(c.current.x=r,c.current.y=a,c.current.isMoving=!0,clearTimeout(e),e=setTimeout(()=>{c.current.isMoving=!1},100))},I=()=>{g.leave(),m||(c.current.isMoving=!1)};a.addEventListener("pointermove",E),a.addEventListener("mouseleave",R),a.addEventListener("mousedown",A),a.addEventListener("keydown",L),a.addEventListener("spirit:spawn",T),a.addEventListener("spirit:move",O),a.addEventListener("spirit:leave",I);let k=Math.ceil(u.width/s.m)+1,N=Math.ceil(u.height/s.m)+1,F=N+9,P=Array(k*N),C=(e,t)=>{let r=0x9e3779b1*e^0x85ebca77*t;return((r=((r=(r>>>16^r)*0x45d9f3b)>>>16^r)*0x45d9f3b)>>>16^r)>>>0},S=6+Math.floor(C(42,99)%5),_=[];for(let e=0;e<S;e++){let t=C(17*e+3,31*e+7),r=C(53*e+11,19*e+23),a=C(41*e+5,67*e+13);_.push({cx:t%1e4/1e4*k,cy:r%1e4/1e4*N,r:8+a%1e4/1e4*18,density:.18+C(e+100,e+200)%1e4/1e4*.2})}for(let e=0;e<N;e++)for(let t=0;t<k;t++){let r=e*k+t,a=C(t,e)%1e4/1e4,n=.04;for(let r of _){let a=t-r.cx,i=e-r.cy,l=Math.sqrt(a*a+i*i);if(l<r.r){let e=1-l/r.r;n=Math.max(n,r.density*e*e)}}if(a<n){let a=C(t+999,e+777),n=C(t+333,e+555),i=a%1e4/1e4;P[r]={isStar:!0,baseAlpha:.1+.35*i,speed:.8+n%1e4/1e4*1.2,phase:(a^n)%1e4/1e4*Math.PI*2,baseRadius:.7+.4*i}}else P[r]={isStar:!1,baseAlpha:.15,speed:0,phase:0,baseRadius:.7}}let z=2*Math.PI,q="default",W=[],X=new Map,j=[],B=e=>{let t=X.get(e);if(void 0!==t)return t;if(t=W.length,X.set(e,t),e===q)W.push("rgb(213, 213, 213)");else{let{r:t,g:r,b:a}=function(e){let t=parseInt(e.slice(1),16);return{r:t>>16&255,g:t>>8&255,b:255&t}}(e);W.push("rgb(".concat(t,", ").concat(r,", ").concat(a,")"))}for(let e=0;e<21;e++)j.push([]);return t},K=B(q),U=performance.now()+2e3+3e3*Math.random(),D=e=>{let{width:t,height:n}=u;if(0===t||0===n){h.current=requestAnimationFrame(D);return}i.save(),i.setTransform(1,0,0,1,0,0),i.fillStyle="#171717",i.fillRect(0,0,a.width,a.height),i.restore(
1),((e,t,r)=>{if(e<U)return;let a=.4>Math.random()?1:.6>Math.random()?2:3;for(let e=0;e<a;e++){let a=80+Math.random()*(t-160),n=.15*r+Math.random()*r*.45;0===e?b(a,n):setTimeout(()=>b(a,n),e*(150+300*Math.random()))}U=e+2e3+4e3*Math.random()})(e,t,n),r.current.forEach(e=>{if(e.age++,"launch"===e.phase){0===e.launchY&&(e.launchY=n,e.trailTailY=n);let t=2.4+.4*Math.random();if(e.launchY-=t,e.trailTailY-=.6*t,e.launchY<=e.targetY){e.phase="burst",e.particles=[];let t=e.launchX,r=e.targetY,a=Math.floor(40*(.3+1.5*Math.random())*(.5+.8*Math.random())),n=Math.floor(a*(.15+.2*Math.random())),i=.35+1.1*Math.random(),l=.3+.9*Math.random(),o=45+110*Math.random();for(let n=0;n<a;n++){let s=n/a*Math.PI*2+(Math.random()-.5)*.5,c=i*(.7+.6*Math.random());e.particles.push({x:t,y:r,vx:Math.cos(s)*c,vy:Math.sin(s)*c,size:l*(.5+ +Math.random()),age:0,maxAge:o*(.6+.8*Math.random()),opacity:1,trail:!1})}for(let a=0;a<n;a++){let a=Math.random()*Math.PI*2,n=i*(.2+.4*Math.random());e.particles.push({x:t,y:r,vx:Math.cos(a)*n,vy:Math.sin(a)*n,size:l*(.8+.6*Math.random()),age:0,maxAge:o*(.4+.6*Math.random()),opacity:1,trail:!1})}}}"burst"===e.phase&&e.trailOpacity>0&&(e.trailTailY-=3.5,e.trailTailY<=e.targetY?e.trailOpacity=0:(e.trailOpacity-=.025,e.trailOpacity<0&&(e.trailOpacity=0))),e.particles.forEach(e=>{e.x+=e.vx,e.y+=e.vy,e.vy+=.015,e.vx*=.992,e.vy*=.992,e.age++;let t=e.age/e.maxAge;t<.1?e.opacity=Math.min(1,e.opacity+.15):e.opacity=Math.max(0,1-(t-.1)/.9)}),e.particles=e.particles.filter(e=>e.age<e.maxAge),"burst"===e.phase&&0===e.particles.length&&(e.opacity=0)}),r.current=r.current.filter(e=>e.opacity>0),((e,t)=>{let a=r.current,n=c.current,i=d.current;for(let e of j)e.length=0;let l=[];for(let e of(n.isMoving&&l.push(n),x.current))l.push(e);for(let e of l){let r=Math.round(e.x/s.m),a=Math.round(e.y/s.m);for(let e=-2;e<=2;e++)for(let n=-2;n<=2;n++){let l=a+e,o=r+n;if(l>=0&&l<N&&o>=0&&o<k){let e=l*k+o;P[e].isStar&&!i.has(e)&&i.set(e,t)}}}for(let[e,r]of i)t-r>.6&&i.delete(e);let o=[],h=[];for(let e of a){if(e.trailOpacity>0){let t="launch"===e.phase?e.launchY:e.targetY;e.trailTailY>t&&h.push({x:e.launchX,currentY:t,bottomY:e.trailTailY,opacity:e.trailOpacity,width:4,color:e.color})}for(let t of e.particles)o.push({x:t.x,y:t.y,size:t.size,opacity:t.opacity*e.opacity,isTrail:t.trail,color:e.color})}for(let e=0;e<N;e++)for(let r=0;r<k;r++){let a,n,l,c=r*s.m,u=e*s.m,f=e*k+r,p=P[f],d=0,m=1,M=!1;for(let e=0;e<h.length;e++){let t=h[e];if(u>=t.currentY&&u<=t.bottomY&&Math.abs(c-Math.round(t.x/s.m)*s.m)<t.width){let e=t.bottomY-t.currentY,r=(u-t.currentY)/Math.max(1,e),n=Math.pow(1-r,3)*(r>.25?1-(r-.25)/.75:1)*.9;n>.02&&(M=!0,n>d&&(d=n,m=t.opacity,a=t.color))}}for(let e=0;e<o.length;e++){let t=o[e],r=c-t.x,n=u-t.y,i=20*t.size;if(r>i||r<-i||n>i||n<-i)continue;let l=r*r+n*n,s=t.isTrail?4*t.size:8*t.size;if(l<s*s){M=!0;let e=.9*(1-Math.sqrt(l)/s);e>d&&(d=e,m=t.opacity,a=t.color)}let h=t.isTrail?15*t.size:30*t.size;if(l<h*h){let e=(1-Math.sqrt(l)/h)*.3;e>d&&(d=e,m=t.opacity,a=t.color)}}if(M)n=1.4+.6*d,l=(.85+.15*d)*m;else if(d>0)n=1+.4*d,l=.15+.55*d*m;else if(p.isStar){let e=Math.sin(t*p.speed*1.5+p.phase)+Math.sin(t*p.speed*2.1+1.3*p.phase),r=e<-.5?Math.min(1,(-.5-e)/1.5):0;l=p.baseAlpha*(1-.85*r),n=p.baseRadius*(1-.25*r);let a=i.get(f);if(void 0!==a){let e=Math.min(1,(t-a)/.5),r=(1-e)*(1-e),i=.4*r;i>.01&&(l=Math.max(l,.35+i),n=Math.max(n,1+.2*r))}}else l=p.baseAlpha,n=p.baseRadius;if(!M&&d<=0){let r=.25+.04*Math.sin(.03*t),a=.7+.04*Math.sin(.05*t),n=1.1+.03*Math.sin(.04*t),i=Math.pow(.5*Math.sin(.012*(c*Math.cos(r)+u*Math.sin(r))+.12*t)+.5,5),o=Math.pow(.5*Math.sin(.016*(c*Math.cos(a)+u*Math.sin(a))+.09*t)+.5,5);l+=(Math.max(i,o,Math.pow(.5*Math.sin(.02*(c*Math.cos(n)+u*Math.sin(n))+.14*t)+.5,5))+i*o*.3)*(1-e/F*.4)*.25}j[(a&&(M||d>0)?B(a):K)*21+Math.round(20*Math.max(0,Math.min(1,l)))].push(c,u,n)}for(let t=0;t<j.length;t++){let r=j[t];if(r.length){e.fillStyle=W[t/21|0],e.globalAlpha=t%21/20,e.beginPath();for(let t=0;t<r.length;t+=3){let a=r[t],n=r[t+1],i=r[t+2];e.moveTo(a+i,n),e.arc(a,n,i,0,z)}e.fill()}}e.globalAlpha=1})(i,e/1e3),M.draw(i,e),g.draw(i,e),h.current=requestAnimationFrame(D)},H=new IntersectionObserver(e=>{let[t]=e;t.isIntersecting?h.current||(h.current=requestAnimationFrame(D)):h.current&&(cancelAnimationFrame(h.current),h.current=0)},{rootMargin:"200px"});return H.observe(a),()=>{H.disconnect(),a.removeEventListener("pointermove",E),a.removeEventListener("mouseleave",R),a.removeEventListener("mousedown",A),a.removeEventListener("keydown",L),a.removeEventListener("spirit:spawn",T),a.removeEventListener("spirit:move",O),a.removeEventListener("spirit:leave",I),clearTimeout(e),null!==p&&cancelAnimationFrame(p),h.current&&(cancelAnimationFrame(h.current),h.current=0)}},[u,b]),(0,a.jsx)("div",{ref:e,className:"relative w-full h-full bg-neutral-900",children:(0,a.jsx)("canvas",{ref:t,className:"absolute inset-0 outline-none",tabIndex:0,role:"button","aria-label":"Launch a firework. Everyone on the page sees it."})})}},9193:(e,t,r)=>{r.d(t,{ML:()=>y,QY:()=>u,UL:()=>p,VL:()=>f,X6:()=>d,Yy:()=>M,bg:()=>h,jn:()=>g,nq:()=>m});var a=r(669),n=r(839),i=r(7206),l=r(6380);let o=(0,a.UU)({authEndpoint:async e=>(await fetch("/api/liveblocks-auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({room:e,userId:(0,i.W)()})})).json(),throttle:16,backgroundKeepAliveTimeout:3e4}),s=e=>"number"==typeof e&&Number.isFinite(e),c=e=>"string"==typeof e&&l.Y.includes(e),{RoomProvider:h,useUpdateMyPresence:u,useOthers:f,useOthersMapped:p,useOthersListener:d,useRoom:m,useSelf:M,useBroadcastEvent:g,useEventListener:v}=(0,n.hq)(o);function y(e){v(t=>{(function(e){switch(e.type){case"SPAWN_BIRD":case"PLANT_FLOWER":case"GROW_FLOWER":case"LAUNCH_FIREWORK":case"SPAWN_DOLPHIN":return s(e.x)&&s(e.y)&&
1(void 0===e.color||c(e.color));case"TAP":return s(e.x)&&s(e.y)&&c(e.color);case"PAINT":return Array.isArray(e.points)&&e.points.length<=4096&&e.points.every(s)&&c(e.color);case"KNOCK":return s(e.yaw)&&s(e.pitch)&&(void 0===e.slug||"string"==typeof e.slug&&e.slug.length<=64);default:return!1}})(t.event)&&e(t)})}}}]);
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.