text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("@babel/runtime/helpers/objectWithoutPropertiesLoose"),r=require("react"),n=require("three"),o=require("@react-three/fiber");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=a(e),u=a(t),c=i(r),l=new n.Vector3,d=new n.Vector3,f=new n.Vector3,m=function(){throw new Error("Html component requires a 'react-dom' package, please install it")},p={unmountComponentAtNode:m,render:m};try{p=require("react-dom")}catch(e){}function h(e,t,r){var n=l.setFromMatrixPosition(e.matrixWorld);n.project(t);var o=r.width/2,a=r.height/2;return[n.x*o+o,-n.y*a+a]}var v=function(e){return Math.abs(e)<1e-10?0:e};function x(e,t,r){void 0===r&&(r="");for(var n="matrix3d(",o=0;16!==o;o++)n+=v(t[o]*e.elements[o])+(15!==o?",":")");return r+n}var y,b=(y=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],function(e){return x(e,y)}),g=function(e,t){return x(e,[1/(r=t),1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1],"translate(-50%,-50%)");var r},M=c.forwardRef((function(e,t){var r,a=e.children,i=e.eps,m=void 0===i?.001:i,x=e.style,y=e.className,M=e.prepend,P=e.center,w=e.fullscreen,W=e.portal,E=e.distanceFactor,O=e.sprite,j=void 0!==O&&O,F=e.transform,T=void 0!==F&&F,C=e.occlude,R=e.onOcclude,z=e.zIndexRange,q=void 0===z?[16777271,0]:z,I=e.calculatePosition,N=void 0===I?h:I,A=e.as,_=void 0===A?"div":A,k=e.pointerEvents,V=void 0===k?"auto":k,D=u.default(e,["children","eps","style","className","prepend","center","fullscreen","portal","distanceFactor","sprite","transform","occlude","onOcclude","zIndexRange","calculatePosition","as","pointerEvents"]),H=o.useThree((function(e){return e.gl})),L=o.useThree((function(e){return e.camera})),S=o.useThree((function(e){return e.scene})),Z=o.useThree((function(e){return e.size})),B=o.useThree((function(e){return e.raycaster})),G=c.useState((function(){return document.createElement(_)}))[0],J=c.useRef(null),K=c.useRef(0),Q=c.useRef([0,0]),U=c.useRef(null),X=c.useRef(null),Y=null!==(r=null==W?void 0:W.current)&&void 0!==r?r:H.domElement.parentNode;c.useEffect((function(){if(J.current){if(S.updateMatrixWorld(),T)G.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{var e=N(J.current,L,Z);G.style.cssText="position:absolute;top:0;left:0;transform:translate3d("+e[0]+"px,"+e[1]+"px,0);transform-origin:0 0;"}return Y&&(M?Y.prepend(G):Y.appendChild(G)),function(){Y&&Y.removeChild(G),p.unmountComponentAtNode(G)}}}),[Y,T]);var $=c.useMemo((function(){return T?{position:"absolute",top:0,left:0,width:Z.width,height:Z.height,transformStyle:"preserve-3d",pointerEvents:"none"}:s.default({position:"absolute",transform:P?"translate3d(-50%,-50%,0)":"none"},w&&{top:-Z.height/2,left:-Z.width/2,width:Z.width,height:Z.height},x)}),[x,P,w,Z,T]),ee=c.useMemo((function(){return{position:"absolute",pointerEvents:V}}),[V]);c.useLayoutEffect((function(){T?p.render(c.createElement("div",{ref:U,style:$},c.createElement("div",{ref:X,style:ee},c.createElement("div",{ref:t,className:y,style:x,children:a}))),G):p.render(c.createElement("div",{ref:t,style:$,className:y,children:a}),G)}));var te=c.useRef(!0);return o.useFrame((function(){if(J.current){L.updateMatrixWorld(),J.current.updateWorldMatrix(!0,!1);var e=T?Q.current:N(J.current,L,Z);if(T||Math.abs(K.current-L.zoom)>m||Math.abs(Q.current[0]-e[0])>m||Math.abs(Q.current[1]-e[1])>m){var t=function(e,t){var r=l.setFromMatrixPosition(e.matrixWorld),n=d.setFromMatrixPosition(t.matrixWorld),o=r.sub(n),a=t.getWorldDirection(f);return o.angleTo(a)>Math.PI/2}(J.current,L),r=!1;"boolean"==typeof C?!0===C&&(r=[S]):Array.isArray(C)&&(r=C.map((function(e){return e.current})));var o=te.current;if(r){var a=function(e,t,r,n){var o=l.setFromMatrixPosition(e.matrixWorld),a=o.clone();a.project(t),r.setFromCamera(a,t);var i=r.intersectObjects(n,!0);if(i.length){var s=i[0].distance;return o.distanceTo(r.ray.origin)<s}return!0}(J.current,L,B,r);te.current=a&&!t}else te.current=!t;if(o!==te.current&&(R?R(!te.current):G.style.display=te.current?"block":"none"),G.style.zIndex=""+function(e,t,r){if(t instanceof n.PerspectiveCamera||t instanceof n.OrthographicCamera){var o=l.setFromMatrixPosition(e.matrixWorld),a=d.setFromMatrixPosition(t.matrixWorld),i=o.distanceTo(a),s=(r[1]-r[0])/(t.far-t.near),u=r[1]-s*t.far;return Math.round(s*i+u)}}(J.current,L,q),T){var i=Z.width/2,s=Z.height/2,u=L.projectionMatrix.elements[5]*s,c=L,p=c.isOrthographicCamera,h=c.top,x=c.left,y=c.bottom,M=c.right,P=b(L.matrixWorldInverse),w=p?"scale("+u+")translate("+v(-(M+x)/2)+"px,"+v((h+y)/2)+"px)":"translateZ("+u+"px)",W=J.current.matrixWorld;j&&((W=L.matrixWorldInverse.clone().transpose().copyPosition(W).scale(J.current.scale)).elements[3]=W.elements[7]=W.elements[11]=0,W.elements[15]=1),G.style.width=Z.width+"px",G.style.height=Z.height+"px",G.style.perspective=p?"":u+"px",U.current&&X.current&&(U.current.style.transform=""+w+P+"translate("+i+"px,"+s+"px)",X.current.style.transform=g(W,1/((E||10)/400)))}else{var O=void 0===E?1:function(e,t){if(t instanceof n.OrthographicCamera)return t.zoom;if(t instanceof n.PerspectiveCamera){var r=l.setFromMatrixPosition(e.matrixWorld),o=d.setFromMatrixPosition(t.matrixWorld),a=t.fov*Math.PI/180,i=r.distanceTo(o);return 1/(2*Math.tan(a/2)*i)}return 1}(J.current,L)*E;G.style.transform="translate3d("+e[0]+"px,"+e[1]+"px,0) scale("+O+")"}Q.current=e,K.current=L.zoom}}})),c.createElement("group",s.default({},D,{ref:J}))}));exports.Html=M;
  