1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9655],{99655:function(e,t,r){r.r(t),r.d(t,{default:function(){return j}});var n=r(27573),o=r(7653),c=r(97551),u=r(92929),a=r(34789),i=r(17610),s=r(78813);class l extends s.BufferGeometry{constructor(e,t,r,n){super();let o=[],c=[],u=[],a=new s.Vector3,i=new s.Matrix4;i.makeRotationFromEuler(r),i.setPosition(t);let l=new s.Matrix4;function h(t,r,n){r.applyMatrix4(e.matrixWorld),r.applyMatrix4(l),n.transformDirection(e.matrixWorld),t.push(new f(r.clone(),n.clone()))}function p(e,t){let r=[],o=.5*Math.abs(n.dot(t));for(let n=0;n<e.length;n+=3){let c,u,a,i,s,l,f;let h=e[n+0].position.dot(t)-o,p=e[n+1].position.dot(t)-o,d=e[n+2].position.dot(t)-o;switch(((s=h>0)?1:0)+((l=p>0)?1:0)+((f=d>0)?1:0)){case 0:r.push(e[n]),r.push(e[n+1]),r.push(e[n+2]);break;case 1:if(s&&(c=e[n+1],u=e[n+2],a=m(e[n],c,t,o),i=m(e[n],u,t,o)),l){c=e[n],u=e[n+2],a=m(e[n+1],c,t,o),i=m(e[n+1],u,t,o),r.push(a),r.push(u.clone()),r.push(c.clone()),r.push(u.clone()),r.push(a.clone()),r.push(i);break}f&&(c=e[n],u=e[n+1],a=m(e[n+2],c,t,o),i=m(e[n+2],u,t,o)),r.push(c.clone()),r.push(u.clone()),r.push(a),r.push(i),r.push(a.clone()),r.push(u.clone());break;case 2:s||(u=m(c=e[n].clone(),e[n+1],t,o),a=m(c,e[n+2],t,o),r.push(c),r.push(u),r.push(a)),l||(u=m(c=e[n+1].clone(),e[n+2],t,o),a=m(c,e[n],t,o),r.push(c),r.push(u),r.push(a)),f||(u=m(c=e[n+2].clone(),e[n],t,o),a=m(c,e[n+1],t,o),r.push(c),r.push(u),r.push(a))}}return r}function m(e,t,r,n){let o=e.position.dot(r)-n,c=o/(o-(t.position.dot(r)-n));return new f(new s.Vector3(e.position.x+c*(t.position.x-e.position.x),e.position.y+c*(t.position.y-e.position.y),e.position.z+c*(t.position.z-e.position.z)),new s.Vector3(e.normal.x+c*(t.normal.x-e.normal.x),e.normal.y+c*(t.normal.y-e.normal.y),e.normal.z+c*(t.normal.z-e.normal.z)))}l.copy(i).invert(),function(){let t;let r=[],l=new s.Vector3,f=new s.Vector3;if(!0===e.geometry.isGeometry){console.error("THREE.DecalGeometry no longer supports THREE.Geometry. Use BufferGeometry instead.");return}let m=e.geometry,d=m.attributes.position,y=m.attributes.normal;if(null!==m.index){let e=m.index;for(t=0;t<e.count;t++)l.fromBufferAttribute(d,e.getX(t)),f.fromBufferAttribute(y,e.getX(t)),h(r,l,f)}else for(t=0;t<d.count;t++)l.fromBufferAttribute(d,t),f.fromBufferAttribute(y,t),h(r,l,f);for(t=0,r=p(r,a.set(1,0,0)),r=p(r,a.set(-1,0,0)),r=p(r,a.set(0,1,0)),r=p(r,a.set(0,-1,0)),r=p(r,a.set(0,0,1)),r=p(r,a.set(0,0,-1));t<r.length;t++){let e=r[t];u.push(.5+e.position.x/n.x,.5+e.position.y/n.y),e.position.applyMatrix4(i),o.push(e.position.x,e.position.y,e.position.z),c.push(e.normal.x,e.normal.y,e.normal.z)}}(),this.setAttribute("position",new s.Float32BufferAttribute(o,3)),this.setAttribute("normal",new s.Float32BufferAttribute(c,3)),this.setAttribute("uv",new s.Float32BufferAttribute(u,2))}}class f{constructor(e,t){this.position=e,this.normal=t}clone(){return new this.constructor(this.position.clone(),this.normal.clone())}}function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0];return Array.isArray(e)?e:e instanceof s.Vector3||e instanceof s.Euler?[e.x,e.y,e.z]:[e,e,e]}let p=o.forwardRef(function(e,t){let{debug:r,depthTest:n=!1,polygonOffsetFactor:u=-10,map:a,mesh:f,children:p,position:m,rotation:d,scale:y,...x}=e,g=o.useRef(null);o.useImperativeHandle(t,()=>g.current);let w=o.useRef(null),M=o.useRef({position:new s.Vector3,rotation:new s.Euler,scale:new s.Vector3(1,1,1)});return o.useLayoutEffect(()=>{let e=(null==f?void 0:f.current)||g.current.parent,t=g.current;if(!(e instanceof s.Mesh))throw Error('Decal must have a Mesh as parent or specify its "mesh" prop');if(e){(0,c.k)(M.current,{position:m,scale:y});let r=e.matrixWorld.clone();if(e.matrixWorld.identity(),d&&"number"!=typeof d)(0,c.k)(M.current,{rotation:d});else{let t=new s.Object3D;t.position.copy(M.current.position);let r=e.geometry.attributes.position.array;void 0===e.geometry.attributes.normal&&e.geometry.computeVertexNormals();let n=e.geometry.attributes.normal.array,o=1/0;new s.Vector3;let u=new s.Vector3,a=t.position.x,i=t.position.y,l=t.position.z,f=r.length,h=-1;for(let e=0;e<f;e+=3){let t=r[e],n=r[e+1],c=r[e+2],u=t-a,s=n-i,f=c-l,p=u*u+s*s+f*f;p<o&&(o=p,h=e)}u.fromArray(n,h),t.lookAt(t.position.clone().add(u)),t.rotateZ(Math.PI),t.rotateY(Math.PI),"number"==typeof d&&t.rotateZ(d),(0,c.k)(M.current,{rotation:t.rotation})}return t.geometry=new l(e,M.current.position,M.current.rotation,M.current.scale),e.matrixWorld=r,()=>{t.geometry.dispose()}}},[f,...h(m),...h(y),...h(d)]),o.useLayoutEffect(()=>{w.current&&((0,c.k)(w.current,M.current),w.current.traverse(e=>e.raycast=()=>null))},[r]),o.createElement("mesh",(0,i.Z)({ref:g,"material-transparent":!0,"material-polygonOffset":!0,"material-polygonOffsetFactor":u,"material-depthTest":n,"material-map":a},x),p,r&&o.createElement("mesh",{ref:w},o.createElement("boxGeometry",null),o.createElement("meshNormalMaterial",{wireframe:!0}),o.createElement("axesHelper",null)))});var m=r(85515);let d=[{pos:[0,0,.124],rot:[0,0,0]},{pos:[0,0,-.124],rot:[0,Math.PI,0]},{pos:[.124,0,0],rot:[0,Math.PI/2,0]},{pos:[-.124,0,0],rot:[0,-Math.PI/2,0]},{pos:[0,.124,0],rot:[-Math.PI/2,0,0]},{pos:[0,-.124,0],rot:[Math.PI/2,0,0]}],y=[[0,0,0],[0,Math.PI,0],[0,-Math.PI/2,0],[0,Math.PI/2,0],[Math.PI/2,0,0],[-Math.PI/2,0,0]],x=[.18,.18,.18],g=new s.Vector3,w="/sounds/dice/DICE_CLICK.mp3",M="/sounds/dice/DICE_REVEAL.mp3",v=navigator.maxTouchPoints>0?1:4,b={top:Array.from({length:v},(e,t)=>"/sounds/dice/impacts/top/DICE_TOP_".concat(t+1,".mp3")),bottom:Array.from({length:v},(e,t)=>"/sounds/dice/impacts/bottom/DICE_BOTTOM_".concat(t+1,".mp3")),left:Array.from({length:v},(e,t)=>
1"/sounds/dice/impacts/left/DICE_LEFT_".concat(t+1,".mp3")),right:Array.from({length:v},(e,t)=>"/sounds/dice/impacts/right/DICE_RIGHT_".concat(t+1,".mp3"))},E={top:Array.from({length:v},(e,t)=>t),bottom:Array.from({length:v},(e,t)=>t),left:Array.from({length:v},(e,t)=>t),right:Array.from({length:v},(e,t)=>t)},I=null,R=new Map,A=!1,P=!0;function z(){if(I)return I;let e=window.AudioContext||window.webkitAudioContext;if(!e)return null;try{return I=new e}catch(e){return null}}async function C(){if(A)return;A=!0;let e=z();if(!e)return;let t=[w,M,...b.top,...b.bottom,...b.left,...b.right];for(let r of(await Promise.all(t.map(async e=>{try{let t=await fetch(e);if(!t.ok)return null;let r=await t.arrayBuffer();return{src:e,ab:r}}catch(e){return null}}))))if(r)try{let t=await e.decodeAudioData(r.ab.slice(0));R.set(r.src,t)}catch(e){}}function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;if(P)return;let r=z(),n=R.get(e);if(r&&n)try{let e=r.createBufferSource();e.buffer=n;let o=r.createGain();o.gain.value=t,e.connect(o).connect(r.destination),e.start(0)}catch(e){}}function S(e){0===E[e].length&&(E[e]=Array.from({length:v},(e,t)=>t));let t=Math.floor(Math.random()*E[e].length),[r]=E[e].splice(t,1);k(b[e][r])}let D={active:!1,screenX:0,screenY:0,velX:0,velY:0,releaseSignal:0};function L(){if("undefined"==typeof document)return"monospace";let e=getComputedStyle(document.documentElement).getPropertyValue("--font-polysans-mono").trim();return e?"".concat(e,', "SF Mono", "Courier New", monospace'):"monospace"}function T(e){let{phrases:t,onScreenPos:r,dragState:u}=e,{scene:i}=(0,a.L)("/models/dice.glb"),l=(0,o.useRef)(null),f=(0,o.useRef)(null),{viewport:h,camera:m,size:w}=(0,c.D)(),{geometry:v,material:b}=(0,o.useMemo)(()=>{let e=new s.BoxGeometry;i.traverse(t=>{t instanceof s.Mesh&&(e=t.geometry.clone()).computeVertexNormals()});let t=document.createElement("canvas");t.width=512,t.height=512;let r=t.getContext("2d"),n=r.createImageData(512,512);for(let e=0;e<n.data.length;e+=4){let t=255*Math.random();n.data[e]=t,n.data[e+1]=t,n.data[e+2]=t,n.data[e+3]=255}r.putImageData(n,0,0);let o=new s.CanvasTexture(t);o.wrapS=o.wrapT=s.RepeatWrapping,o.repeat.set(6,6);let c=new s.MeshStandardMaterial({color:new s.Color("#ff66ea"),roughness:.85,metalness:0,emissive:new s.Color("#ff00d9"),emissiveIntensity:.45,bumpMap:o,bumpScale:.44});return{geometry:e,material:c}},[i]),[E,I]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1,r=[];return(async()=>{if("undefined"!=typeof document&&"fonts"in document)try{let e=L().split(",")[0].trim();await document.fonts.load("400 53px ".concat(e))}catch(e){}if(!e){for(let e of t)r.push(function(e){let t=document.createElement("canvas");t.width=512,t.height=512;let r=t.getContext("2d");r.clearRect(0,0,512,512),r.fillStyle="#000000",r.textAlign="center",r.textBaseline="middle",r.font="400 ".concat(52.8,"px ").concat(L());let n=e.toUpperCase().split(" "),o=[],c="";for(let e of n){let t=c?"".concat(c," ").concat(e):e;r.measureText(t).width>419.84&&c?(o.push(c),c=e):c=t}c&&o.push(c);let u=(512-66*o.length)/2+33;for(let e=0;e<o.length;e++)r.fillText(o[e],256,u+66*e);let a=new s.CanvasTexture(t);return a.needsUpdate=!0,a}(e));I(r)}})(),()=>{e=!0,r.forEach(e=>e.dispose())}},[t]);let R=(0,o.useRef)({x:0,y:0}),A=(0,o.useRef)({x:1.2*(Math.random()>.5?1:-1),y:.9*(Math.random()>.5?1:-1)}),P=(0,o.useRef)({x:0,y:0}),z=(0,o.useRef)({x:.81,y:.95,z:.27}),C=(0,o.useRef)({x:0,y:0,z:0}),D=(0,o.useRef)(!1),T=(0,o.useRef)(0),X=(0,o.useRef)(-1),j=(0,o.useRef)(0),V=(0,o.useRef)(!1),Y=(0,o.useRef)(0),B=(0,o.useRef)(!1),_=h.width<6?2.8:3.8,F=.186*_,G=(0,o.useCallback)((e,t)=>({x:(e/w.width*2-1)*(h.width/2),y:(-(t/w.height*2)+1)*(h.height/2)}),[w,h]);return(0,c.F)((e,t)=>{if(!l.current)return;let n=Math.min(t,.05),o=u.current;if(o.active){B.current=!0,D.current=!1;let e=G(o.screenX,o.screenY);R.current.x+=(e.x-R.current.x)*.3,R.current.y+=(e.y-R.current.y)*.3,P.current.x=R.current.x,P.current.y=R.current.y,A.current.x=0,A.current.y=0;let t=h.width/w.width;z.current.x=o.velY*t*.3,z.current.y=-o.velX*t*.3}if(o.releaseSignal!==j.current&&(j.current=o.releaseSignal,B.current)){B.current=!1;let e=h.width/w.width,t=o.velX*e,r=-o.velY*e,n=Math.sqrt(t**2+r**2);if(n>.5){A.current.x=.7*t,A.current.y=.7*r;let e=Math.min(n/3,1);z.current.x=(4+6*Math.random())*e*(Math.random()>.5?1:-1),z.current.y=(4+6*Math.random())*e*(Math.random()>.5?1:-1),z.current.z=(2+4*Math.random())*e*(Math.random()>.5?1:-1),D.current=!0,T.current=0,V.current=!1;let o=X.current;for(;o===X.current;)o=Math.floor(6*Math.random());X.current=o}else{let e=Math.random()*Math.PI*2;A.current.x=.8*Math.cos(e),A.current.y=.6*Math.sin(e),z.current.x=.105,z.current.y=.175,z.current.z=.035}}if(D.current){T.current+=n;let e=Math.min(T.current/2.5,1),t=1-e*e*e,r=.97*t+(1-t)*.85;z.current.x*=r,z.current.y*=r,z.current.z*=r;let o=.98*t+(1-t)*.92;if(A.current.x*=o,A.current.y*=o,e>.6){V.current||(V.current=!0,k(M));let t=(e-.6)/.4,[r,n,o]=y[X.current],c=r+Math.round((C.current.x-r)/(2*Math.PI))*Math.PI*2,u=n+Math.round((C.current.y-n)/(2*Math.PI))*Math.PI*2,a=o+Math.round((C.current.z-o)/(2*Math.PI))*Math.PI*2,i=1-Math.pow(1-t*t*(3-2*t),3);
1C.current.x+=(c-C.current.x)*i*.15,C.current.y+=(u-C.current.y)*i*.15,C.current.z+=(a-C.current.z)*i*.15}if(e>=1){D.current=!1;let[e,t,r]=y[X.current];C.current.x=e,C.current.y=t,C.current.z=r,z.current.x=0,z.current.y=0,z.current.z=0,Y.current=0;let n=Math.random()*Math.PI*2;A.current.x=.8*Math.cos(n),A.current.y=.6*Math.sin(n)}}if(!D.current&&!o.active&&Y.current<1.5&&(Y.current+=n,Y.current>=1.5&&(z.current.x=.105,z.current.y=.175,z.current.z=.035)),C.current.x+=z.current.x*n,C.current.y+=z.current.y*n,C.current.z+=z.current.z*n,l.current.rotation.set(C.current.x,C.current.y,C.current.z),!o.active){let e=h.width/2-F,t=h.height/2-F;R.current.x+=A.current.x*n,R.current.y+=A.current.y*n;let r=D.current;R.current.x>e?(R.current.x=e,A.current.x=-(.85*Math.abs(A.current.x)),z.current.y+=.5*A.current.x,r&&S("right")):R.current.x<-e&&(R.current.x=-e,A.current.x=.85*Math.abs(A.current.x),z.current.y-=.5*A.current.x,r&&S("left")),R.current.y>t?(R.current.y=t,A.current.y=-(.85*Math.abs(A.current.y)),z.current.x+=.5*A.current.y,r&&S("top")):R.current.y<-t&&(R.current.y=-t,A.current.y=.85*Math.abs(A.current.y),z.current.x-=.5*A.current.y,r&&S("bottom"));let o=1-Math.pow(D.current?1e-30:.02,n);P.current.x+=(R.current.x-P.current.x)*o,P.current.y+=(R.current.y-P.current.y)*o}l.current.position.x=P.current.x,l.current.position.y=P.current.y,g.set(P.current.x,P.current.y,0),g.project(m),r.current.x=(g.x+1)/2*w.width,r.current.y=(1-g.y)/2*w.height;let c=.248*_;r.current.scale=c/h.width*w.width}),(0,n.jsx)("group",{ref:l,scale:_,children:(0,n.jsx)("mesh",{ref:f,geometry:v,material:b,children:E.map((e,t)=>(0,n.jsx)(p,{position:d[t].pos,rotation:d[t].rot,scale:x,children:(0,n.jsx)("meshStandardMaterial",{map:e,transparent:!0,depthTest:!0,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-4})},t))})})}function X(e){let{screenPos:t,dragState:r}=e,c=(0,o.useRef)(null),u=(0,o.useRef)(!1),a=(0,o.useRef)({x:0,y:0,time:0}),i=(0,o.useRef)([]);(0,o.useEffect)(()=>{let e;let r=()=>{if(c.current){let e=Math.max(1.8*t.current.scale,100);c.current.style.transform="translate(".concat(t.current.x,"px, ").concat(t.current.y,"px) translate(-50%, -50%)"),c.current.style.width="".concat(e,"px"),c.current.style.height="".concat(e,"px")}e=requestAnimationFrame(r)};return e=requestAnimationFrame(r),()=>cancelAnimationFrame(e)},[t]);let s=(0,o.useCallback)(e=>{e.preventDefault(),function(){let e=z();e&&e.resume().catch(()=>{})}(),k(w),u.current=!0,i.current=[],a.current={x:e.clientX,y:e.clientY,time:performance.now()},r.current.active=!0,r.current.screenX=e.clientX,r.current.screenY=e.clientY,r.current.velX=0,r.current.velY=0;let t=e=>{if(!u.current)return;let t=performance.now(),n=(t-a.current.time)/1e3;if(n>0){let t=(e.clientX-a.current.x)/n,r=(e.clientY-a.current.y)/n;i.current.push({vx:t,vy:r}),i.current.length>4&&i.current.shift()}a.current={x:e.clientX,y:e.clientY,time:t},r.current.screenX=e.clientX,r.current.screenY=e.clientY;let o=i.current;o.length>0&&(r.current.velX=o.reduce((e,t)=>e+t.vx,0)/o.length,r.current.velY=o.reduce((e,t)=>e+t.vy,0)/o.length)},n=()=>{u.current=!1,r.current.active=!1,r.current.releaseSignal+=1,window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n)},[r]);return(0,n.jsx)("div",{ref:c,role:"button",tabIndex:0,"aria-label":"Drag to throw the dice",className:"absolute top-0 left-0 rounded-full cursor-grab active:cursor-grabbing z-10 pointer-events-auto touch-none",style:{willChange:"transform"},onPointerDown:s})}function j(e){let{phrases:t}=e,[r,c]=(0,o.useState)(!1),[a,i]=(0,o.useState)(!1),s=(0,o.useRef)(null),l=(0,o.useRef)({x:0,y:0,scale:100}),f=(0,o.useRef)({...D}),{state:h}=(0,m.useSound)();return(0,o.useEffect)(()=>{P="on"!==h},[h]),(0,o.useEffect)(()=>{let e=setTimeout(()=>c(!0),300);return()=>clearTimeout(e)},[]),(0,o.useEffect)(()=>{let e=s.current;if(!e)return;let t=new IntersectionObserver(e=>{let[t]=e;return i(t.isIntersecting)},{threshold:0});return t.observe(e),()=>t.disconnect()},[]),(0,o.useEffect)(()=>{C()},[]),(0,n.jsxs)("div",{ref:s,className:"sticky top-0 h-screen w-full z-20 pointer-events-none",style:{opacity:r?1:0,transition:"opacity 0.6s ease"},children:[(0,n.jsx)(X,{screenPos:l,dragState:f}),(0,n.jsxs)(u.Xz,{camera:{position:[0,0,5],fov:45,near:.1,far:100},gl:{antialias:!0,alpha:!0},frameloop:a?"always":"never",style:{background:"transparent",pointerEvents:"none"},children:[(0,n.jsx)("ambientLight",{intensity:.6}),(0,n.jsx)("directionalLight",{position:[4,6,5],intensity:4.5,color:"#ffffff"}),(0,n.jsx)("directionalLight",{position:[-3,1,-4],intensity:1,color:"#ffaaff"}),(0,n.jsx)("pointLight",{position:[0,-3,3],intensity:.4,color:"#ff66ee"}),(0,n.jsx)(T,{phrases:t,onScreenPos:l,dragState:f})]})]})}a.L.preload("/models/dice.glb")}}]);
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.