UNPKG

trillion-widget

Version:

Trillion AR Widget

22 lines 948 kB
var sE=Object.defineProperty,lE=(e,t,n)=>t in e?sE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,re=(e,t,n)=>lE(e,typeof t!="symbol"?t+"":t,n);import P0,{createContext as Vv,useContext as Wv,createRef as Co,useState as De,useEffect as fe,useCallback as fn,useRef as ir,Suspense as I0,forwardRef as cE,useMemo as Dt,memo as Kv,lazy as pn}from"react";import{create as uE}from"zustand";import{produce as dE}from"immer";import*as Ie from"three";import{DataTextureLoader as Xv,HalfFloatType as Ma,FloatType as qr,DataUtils as Ss,LinearSRGBColorSpace as Rn,LinearFilter as Zr,Ray as hE,Plane as N0,MathUtils as ar,Vector3 as z,Controls as fE,MOUSE as Ms,TOUCH as ks,Quaternion as qi,Spherical as Yv,Vector2 as J,TrianglesDrawMode as pE,TriangleFanDrawMode as D0,TriangleStripDrawMode as $v,Box3 as Pn,InstancedBufferGeometry as mE,Float32BufferAttribute as $u,InstancedInterleavedBuffer as L0,InterleavedBufferAttribute as To,WireframeGeometry as gE,Sphere as Qu,UniformsLib as qu,ShaderLib as Jl,UniformsUtils as Qv,ShaderMaterial as or,Vector4 as Ro,Matrix4 as In,Line3 as ki,Mesh as Cs,RGBAFormat as ec,RedFormat as qv,NoColorSpace as O0,Loader as Zv,FileLoader as Zu,SRGBColorSpace as Je,BufferGeometry as tc,BufferAttribute as Jr,Color as kr,ColorManagement as B0,LoaderUtils as nc,SpotLight as vE,PointLight as _E,DirectionalLight as F0,MeshBasicMaterial as ka,MeshPhysicalMaterial as ei,InstancedMesh as yE,InstancedBufferAttribute as wE,Object3D as Ca,TextureLoader as bE,ImageBitmapLoader as xE,InterleavedBuffer as AE,LinearMipmapLinearFilter as z0,RepeatWrapping as U0,NearestFilter as Cr,PointsMaterial as EE,Material as rc,LineBasicMaterial as Jv,MeshStandardMaterial as e3,DoubleSide as Po,PropertyBinding as SE,SkinnedMesh as ME,LineSegments as t3,Line as kE,LineLoop as CE,Points as n3,Group as Ju,PerspectiveCamera as ed,OrthographicCamera as r3,Skeleton as TE,AnimationClip as RE,Bone as PE,InterpolateLinear as i3,NearestMipmapNearestFilter as IE,LinearMipmapNearestFilter as NE,NearestMipmapLinearFilter as DE,ClampToEdgeWrapping as LE,MirroredRepeatWrapping as OE,InterpolateDiscrete as BE,FrontSide as td,Texture as nd,VectorKeyframeTrack as a3,NumberKeyframeTrack as o3,QuaternionKeyframeTrack as s3,Interpolant as FE,PMREMGenerator as zE,LoadingManager as UE,WebGLRenderer as l3,ACESFilmicToneMapping as jE,UnsignedByteType as Ci,DepthTexture as HE,DepthStencilFormat as GE,UnsignedInt248Type as VE,UnsignedIntType as Ts,WebGLRenderTarget as Tr,REVISION as ic,Scene as rd,Camera as WE,BasicDepthPacking as Io,Uniform as Me,RGBADepthPacking as c3,EqualDepth as j0,NotEqualDepth as u3,NoBlending as Ta,BackSide as ac,EventDispatcher as H0,LessDepth as d3,MeshDepthMaterial as KE,GreaterDepth as XE,GreaterEqualDepth as YE,LessEqualDepth as $E,AlwaysDepth as QE,NeverDepth as qE,Triangle as Rs,DataTexture as G0,IntType as V0,UnsignedShortType as ZE,ByteType as h3,ShortType as JE,RGBAIntegerFormat as W0,RGFormat as eS,RGIntegerFormat as f3,RedIntegerFormat as tS,CylinderGeometry as nS,Box2 as K0,Shape as rS,ShapeGeometry as iS,GridHelper as X0,AxesHelper as aS}from"three";import{KalmanFilter as oS}from"kalman-filter";import*as Te from"@tensorflow/tfjs";import{dispose as sS}from"@tensorflow/tfjs";import{AnimatePresence as Zi,motion as qt,useAnimation as id}from"framer-motion";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d7d7a1ce-d83d-4932-afd0-e360f5d18826",e._sentryDebugIdIdentifier="sentry-dbid-d7d7a1ce-d83d-4932-afd0-e360f5d18826")}catch{}})();var lS=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};lS.SENTRY_RELEASE={id:"trillion-widget-react@0.40.5"};var Y0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cS(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p3={exports:{}},ad={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var uS=P0,dS=Symbol.for("react.element"),hS=Symbol.for("react.fragment"),fS=Object.prototype.hasOwnProperty,pS=uS.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,mS={key:!0,ref:!0,__self:!0,__source:!0};function m3(e,t,n){var r,i={},a=null,o=null;n!==void 0&&(a=""+n),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)fS.call(t,r)&&!mS.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:dS,type:e,key:a,ref:o,props:i,_owner:pS.current}}ad.Fragment=hS,ad.jsx=m3,ad.jsxs=m3,p3.exports=ad;var k=p3.exports;class Ps extends Error{constructor(t="default_error",n){super(t,{cause:n}),re(this,"userMessage","default_error"),this.userMessage=t}}const gS=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i=="function"?dE(i):i;return t(s,a,...o)},e(r.setState,n,r)),vS=gS,g3={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1,VITE_GTM_DATA_LAYER_NAME:"dataLayer_trillion_widget",VITE_GTM_ID:"GTM-KZMLZRD",VITE_GTM_SERVER_CONTAINER_PATH:"https://tag.trillion.jewelry",VITE_IS_LIBRARY_MODE:"true",VITE_SENTRY_DSN:"https://379109574f68e5de37dbbade12618a37@o4506462464638976.ingest.sentry.io/4506478511652864",VITE_USER_NODE_ENV:"production"},$0=new Map,od=e=>{const t=$0.get(e);return t?Object.fromEntries(Object.entries(t.stores).map(([n,r])=>[n,r.getState()])):{}},_S=(e,t,n)=>{if(e===void 0)return{type:"untracked",connection:t.connect(n)};const r=$0.get(n.name);if(r)return{type:"tracked",store:e,...r};const i={connection:t.connect(n),stores:{}};return $0.set(n.name,i),{type:"tracked",store:e,...i}},yS=(e,t={})=>(n,r,i)=>{const{enabled:a,anonymousActionType:o,store:s,...l}=t;let c;try{c=(a??(g3?"library":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return e(n,r,i);const{connection:d,...u}=_S(s,c,l);let h=!0;i.setState=(v,_,p)=>{const m=n(v,_);if(!h)return m;const y=p===void 0?{type:o||"anonymous"}:typeof p=="string"?{type:p}:p;return s===void 0?(d?.send(y,r()),m):(d?.send({...y,type:`${s}/${y.type}`},{...od(l.name),[s]:i.getState()}),m)};const f=(...v)=>{const _=h;h=!1,n(...v),h=_},g=e(i.setState,r,i);if(u.type==="untracked"?d?.init(g):(u.stores[u.store]=i,d?.init(Object.fromEntries(Object.entries(u.stores).map(([v,_])=>[v,v===u.store?g:_.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let v=!1;const _=i.dispatch;i.dispatch=(...p)=>{(g3?"library":void 0)!=="production"&&p[0].type==="__setState"&&!v&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),v=!0),_(...p)}}return d.subscribe(v=>{var _;switch(v.type){case"ACTION":if(typeof v.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Q0(v.payload,p=>{if(p.type==="__setState"){if(s===void 0){f(p.state);return}Object.keys(p.state).length!==1&&console.error(` [zustand devtools middleware] Unsupported __setState action format. When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(), and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } } `);const m=p.state[s];if(m==null)return;JSON.stringify(i.getState())!==JSON.stringify(m)&&f(m);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(p)});case"DISPATCH":switch(v.payload.type){case"RESET":return f(g),s===void 0?d?.init(i.getState()):d?.init(od(l.name));case"COMMIT":if(s===void 0){d?.init(i.getState());return}return d?.init(od(l.name));case"ROLLBACK":return Q0(v.state,p=>{if(s===void 0){f(p),d?.init(i.getState());return}f(p[s]),d?.init(od(l.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Q0(v.state,p=>{if(s===void 0){f(p);return}JSON.stringify(i.getState())!==JSON.stringify(p[s])&&f(p[s])});case"IMPORT_STATE":{const{nextLiftedState:p}=v.payload,m=(_=p.computedStates.slice(-1)[0])==null?void 0:_.state;if(!m)return;f(s===void 0?m:m[s]),d?.send(null,p);return}case"PAUSE_RECORDING":return h=!h}return}}),g},wS=yS,Q0=(e,t)=>{let n;try{n=JSON.parse(e)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}n!==void 0&&t(n)},bS=e=>(t,n,r)=>{const i=r.subscribe;return r.subscribe=(a,o,s)=>{let l=a;if(o){const c=s?.equalityFn||Object.is;let d=a(r.getState());l=u=>{const h=a(u);if(!c(d,h)){const f=d;o(d=h,f)}},s!=null&&s.fireImmediately&&o(d,d)}return i(l)},e(t,n,r)},xS=bS,AS={point_camera_at_hand:"Align your hand with the camera",point_camera_at_yourself:"Point the camera at yourself",point_camera_at_ear:"Tips: Make sure your ears are visible and uncovered",tap_on_finger_to_select_it:"Choose a finger to try on by clicking (tap) it on the screen",tap_on_finger_to_add_ring:"Tap on the finger for adding ring",buy_it_now:"Buy it now",first_hand:"1st hand",second_hand:"2nd hand",your_ring:"Your ring",first_ring:"1st ring",second_ring:"2nd",third_ring:"3rd",favorites:"Favorites",lets_go:"Let's go",next:"Next",reload:"Reload",no_camera_error:"Camera is necessary. Please connect your camera and try again.",default_error:"Something went wrong. Please reload the App and try again.",rotate_device:"Rotate your phone to try on",license_error:"Problem with the license, please contact the administration",activation_key_error:"Problem with the activation key, please contact the administration",is_published_error:"Product is not published, please contact the administration",sku_not_supported:"This product doesn't support Virtual try-on"},ES={point_camera_at_hand:"\uC190\uC744 \uCE74\uBA54\uB77C\uC5D0 \uB9DE\uCD94\uC138\uC694",point_camera_at_yourself:"\uCE74\uBA54\uB77C\uB97C \uC790\uC2E0\uC5D0\uAC8C \uD5A5\uD558\uC138\uC694",point_camera_at_ear:"\uD301: \uADC0\uAC00 \uBCF4\uC774\uACE0 \uAC00\uB824\uC9C0\uC9C0 \uC54A\uB3C4\uB85D \uD558\uC138\uC694",tap_on_finger_to_select_it:"\uD301: \uD654\uBA74\uC5D0\uC11C \uBC18\uC9C0\uB97C \uBCC0\uACBD\uD558\uB824\uBA74 \uC190\uAC00\uB77D\uC744 \uD074\uB9AD\uD558\uAC70\uB098 \uD0ED\uD558\uC138\uC694",tap_on_finger_to_add_ring:"\uBC18\uC9C0\uB97C \uCD94\uAC00\uD558\uB824\uBA74 \uD130\uCE58\uD558\uC138\uC694",buy_it_now:"\uC9C0\uAE08 \uAD6C\uB9E4\uD558\uC138\uC694",first_hand:"1\uBC88\uC9F8 \uC190",second_hand:"2\uBC88\uC9F8 \uC190",your_ring:"\uB0B4 \uBC18\uC9C0",first_ring:"1\uBC88\uC9F8 \uBC18\uC9C0",second_ring:"2\uC704",third_ring:"3\uC704",favorites:"\uC990\uACA8\uCC3E\uAE30",lets_go:"\uC2DC\uC791\uD558\uAE30",next:"\uB2E4\uC74C",reload:"\uB2E4\uC2DC \uB85C\uB4DC",no_camera_error:"\uCE74\uBA54\uB77C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uCE74\uBA54\uB77C\uB97C \uC5F0\uACB0\uD558\uACE0 \uB2E4\uC2DC \uC2DC\uB3C4\uD558\uC138\uC694",default_error:"\uBB38\uC81C\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4. \uC571\uC744 \uB2E4\uC2DC \uB85C\uB4DC\uD558\uACE0 \uB2E4\uC2DC \uC2DC\uB3C4\uD558\uC138\uC694",rotate_device:"\uD734\uB300\uD3F0\uC744 \uB3CC\uB824\uC11C \uC2DC\uB3C4\uD574 \uBCF4\uC138\uC694",license_error:"\uB77C\uC774\uC120\uC2A4\uC5D0 \uBB38\uC81C\uAC00 \uC788\uC2B5\uB2C8\uB2E4. \uAD00\uB9AC\uC790\uC5D0\uAC8C \uBB38\uC758\uD558\uC138\uC694",activation_key_error:"\uD65C\uC131\uD654 \uD0A4\uC5D0 \uBB38\uC81C\uAC00 \uC788\uC2B5\uB2C8\uB2E4. \uAD00\uB9AC\uC790\uC5D0\uAC8C \uBB38\uC758\uD558\uC138\uC694",is_published_error:"\uC81C\uD488\uC774 \uAC8C\uC2DC\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \uAD00\uB9AC\uC790\uC5D0\uAC8C \uBB38\uC758\uD558\uC138\uC694",sku_not_supported:"\uC774 \uC81C\uD488\uC740 \uAC00\uC0C1 \uCC29\uC6A9\uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4"},SS={point_camera_at_hand:"\u0421\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u0442\u0435 \u0441\u0432\u043E\u044E \u0440\u0443\u043A\u0443 \u0441 \u043A\u0430\u043C\u0435\u0440\u043E\u0439",point_camera_at_yourself:"\u041D\u0430\u0432\u0435\u0434\u0438\u0442\u0435 \u043A\u0430\u043C\u0435\u0440\u0443 \u043D\u0430 \u0441\u0435\u0431\u044F",point_camera_at_ear:"\u0421\u043E\u0432\u0435\u0442: \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044C, \u0447\u0442\u043E \u0432\u0430\u0448\u0438 \u0443\u0448\u0438 \u0432\u0438\u0434\u043D\u044B \u0438 \u043D\u0435 \u0437\u0430\u043A\u0440\u044B\u0442\u044B",tap_on_finger_to_select_it:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0430\u043B\u0435\u0446 \u0434\u043B\u044F \u043F\u0440\u0438\u043C\u0435\u0440\u043A\u0438, \u043A\u043B\u0438\u043A\u043D\u0443\u0432 \u043F\u043E \u043D\u0435\u043C\u0443 \u043D\u0430 \u044D\u043A\u0440\u0430\u043D\u0435",tap_on_finger_to_add_ring:"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u043D\u0430 \u043F\u0430\u043B\u0435\u0446, \u0447\u0442\u043E\u0431\u044B \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043B\u044C\u0446\u043E",buy_it_now:"\u041A\u0443\u043F\u0438\u0442\u044C \u0441\u0435\u0439\u0447\u0430\u0441",first_hand:"1-\u044F \u0440\u0443\u043A\u0430",second_hand:"2-\u044F \u0440\u0443\u043A\u0430",your_ring:"\u0412\u0430\u0448\u0435 \u043A\u043E\u043B\u044C\u0446\u043E",first_ring:"1-\u0435 \u043A\u043E\u043B\u044C\u0446\u043E",second_ring:"2-\u0435 \u043A\u043E\u043B\u044C\u0446\u043E",third_ring:"3-\u0435 \u043A\u043E\u043B\u044C\u0446\u043E",favorites:"\u0418\u0437\u0431\u0440\u0430\u043D\u043D\u043E\u0435",lets_go:"\u041F\u0440\u0438\u0441\u0442\u0443\u043F\u0438\u0442\u044C",next:"\u0414\u0430\u043B\u0435\u0435",reload:"\u041F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C",no_camera_error:"\u041D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u0430 \u043A\u0430\u043C\u0435\u0440\u0430. \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u043A\u0430\u043C\u0435\u0440\u0443 \u0438 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0441\u043D\u043E\u0432\u0430.",default_error:"\u0427\u0442\u043E-\u0442\u043E \u043F\u043E\u0448\u043B\u043E \u043D\u0435 \u0442\u0430\u043A. \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0438 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0441\u043D\u043E\u0432\u0430.",rotate_device:"\u041F\u043E\u0432\u0435\u0440\u043D\u0438\u0442\u0435 \u0442\u0435\u043B\u0435\u0444\u043E\u043D, \u0447\u0442\u043E\u0431\u044B \u043F\u0440\u0438\u043C\u0435\u0440\u0438\u0442\u044C",license_error:"\u041F\u0440\u043E\u0431\u043B\u0435\u043C\u0430 \u0441 \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0435\u0439, \u043F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0441\u0432\u044F\u0436\u0438\u0442\u0435\u0441\u044C \u0441 trillion",activation_key_error:"\u041F\u0440\u043E\u0431\u043B\u0435\u043C\u0430 \u0441 \u043A\u043B\u044E\u0447\u043E\u043C \u0430\u043A\u0442\u0438\u0432\u0430\u0446\u0438\u0438, \u043F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0441\u0432\u044F\u0436\u0438\u0442\u0435\u0441\u044C \u0441 trillion",is_published_error:"\u0422\u043E\u0432\u0430\u0440 \u043D\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D, \u043F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0441\u0432\u044F\u0436\u0438\u0442\u0435\u0441\u044C \u0441 trillion",sku_not_supported:"\u042D\u0442\u043E\u0442 \u043F\u0440\u043E\u0434\u0443\u043A\u0442 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 Virtual try-on"},MS={en:AS,kr:ES,ru:SS};function kS(){return{language:"en",localizationData:MS}}const CS=kS(),TS=e=>({...CS,setLanguage:t=>e({language:t}),setLocalizationData:t=>e({localizationData:t})});function sd(e){throw new Error(`Unreachable code, param is ${e}`)}function Ra(){const e=[];return{subscribe:t=>{if(e.includes(t))return console.trace("Observer already subscribed");e.push(t)},unsubscribe:t=>{const n=e.indexOf(t);if(n===-1)return console.trace("Observer not registered");e.splice(n,1)},notify:t=>{for(const n of[...e])n(t)}}}const v3=Vv({}),ld=()=>Wv(v3),RS={changeJewelry:Ra(),removeJewelry:Ra()},PS=({children:e})=>k.jsx(v3.Provider,{value:RS,children:e}),_3=Vv({hostAppElement:document}),Ji=()=>Wv(_3),IS=e=>({videoElementRef:Co(),cameraFeedCanvasRef:Co(),rendererCanvasRef:Co(),canvasGroupRef:Co(),landmarksCanvasRef:Co(),renderStatsBlockRef:Co(),totalStatsBlockRef:Co(),hostAppElement:e}),NS=({children:e,hostAppElement:t})=>k.jsx(_3.Provider,{value:IS(t),children:e});function Is(e){const t=e.map(i=>({value:0,weight:i})),n=Ra();let r;return{progressChangedEvent:n,update(i,a){if(t[i].value>a)return;t[i].value=a;const o=t.reduce((l,c)=>l+c.weight,0),s=t.reduce((l,c)=>l+c.value*c.weight,0)/o;n.notify(s)},setAutoIncrement(i,a=.01,o=1e3){r=setInterval(()=>{const s=t[i].value;s<.95?this.update(i,s+a):clearInterval(r)},o)},forceComplete(i=!0){clearInterval(r),t.forEach(a=>a.value=1),i&&n.notify(1)}}}const oc="ring_demo_store",q0="ring";let Z0;Z0="https://storage.googleapis.com/trillionprod.appspot.com";function y3(){return`${Z0}/Resources/Web`}function DS(e){Z0=e}function cd(e){return`${y3()}/${e}.gltf`}function sc(e){return`${y3()}/${e}`}class LS{constructor(t,n){this.email=t,this.url=n}}class ea extends Error{constructor(t){super(`Product owner has no related billing package for service: ${t}`),this.name="NoBillingPackageError"}}class lc extends Error{constructor(t){super(`Error while fetching product config for ${t}`),this.name="FetchingConfigError"}}class ta extends Error{constructor(){super("The integration has an incorrect ActivationKey or this hostname is not connected with the owner account, please check the settings in the Trillion Dashboard"),this.name="IncorrectActivationKeyError"}}class OS extends Error{constructor(){super("Error while fetching reflection maps "),this.name="FetchingReflectionMapsError"}}class cc extends Error{constructor(){super("Product not published or doesn't exist"),this.name="ProductNotExistOrNotPublishedError"}}const J0=class JA{constructor(){this._staticConfigsUrl=void 0,this._serviceActivationKey=null,this._baseUrl=this.getDefaultBaseUrl()}getDefaultBaseUrl(){return JA.prodUrl}changeBaseURL(t){this._baseUrl=t??this.getDefaultBaseUrl()}setServiceActivationKey(t){this._serviceActivationKey=t}async get(t,n,r){let i,a,o=n?`?${new URLSearchParams(n)}`:"";try{a=await fetch(`${this._baseUrl}/${t}${o}`,{headers:{"Content-Type":"application/json;charset=utf-8"},signal:r}),i=await a.json()}catch(s){throw s instanceof SyntaxError?console.log("There was a SyntaxError",s):s.name==="AbortError"||console.log("There was an error",s),new Error("Fetch error",{cause:s})}return{response:a,json:i}}async post(t,n){let r,i;try{i=await fetch(`${this._baseUrl}/${t}`,{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify(n)}),r=await i.json()}catch(a){throw a instanceof SyntaxError?console.log("There was a SyntaxError",a):console.log("There was an error",a),new Error("Fetch error",{cause:a})}return{response:i,json:r}}async getAllReflectionMaps(){const{response:t,json:n}=await this.get("trillionwebapp/reflection-maps/all");if(t!=null&&t.ok)return n;throw new OS}async getProductConfigForViewer(t,n){let r;this._serviceActivationKey&&(r={key:this._serviceActivationKey});const{response:i,json:a}=await this.get(`trillionwebapp/config/viewer/${t}`,r,n);if(i!=null&&i.ok)return a;throw i.status===403?new ea("viewer"):i.status===401?new ta:i.status===406?new cc:new lc("viewer")}async getProductConfigsForViewer(t){const n={ids:t.join(",")};this._serviceActivationKey&&(n.key=this._serviceActivationKey);const{response:r,json:i}=await this.get("trillionwebapp/config/viewer",n);if(r!=null&&r.ok)return i;throw r.status===403?new ea("viewer"):r.status===401?new ta:r.status===406?new cc:new lc("viewer")}async getProductConfigForWidget(t){let n;this._serviceActivationKey&&(n={key:this._serviceActivationKey});const{response:r,json:i}=await this.get(`trillionwebapp/config/widget/${t}`,n);if(r!=null&&r.ok)return i;throw r.status===403?new ea("widget"):r.status===401?new ta:r.status===406?new cc:new lc("widget")}async getProductConfigsForWidget(t){if(this._staticConfigsUrl)return this.getProductConfigsFromStaticConfig(t);const n={ids:t.join(",")};this._serviceActivationKey&&(n.key=this._serviceActivationKey);const{response:r,json:i}=await this.get("trillionwebapp/config/widget",n);if(r!=null&&r.ok)return i;throw r.status===403?new ea("widget"):r.status===401?new ta:r.status===406?new cc:new lc("widget")}async saveUserData(t,n){const r=new LS(t,n),{response:i}=await this.post("/trillionwebapp/userData",r);i!=null&&i.ok||console.error("Error while saving user data",i.statusText)}setStaticConfigsUrl(t){this._staticConfigsUrl=t,this._baseUrl=""}async getProductConfigsFromStaticConfig(t){if(!this._staticConfigsUrl)throw new Error("Static configs url is not set");const{response:n,json:r}=await this.get(this._staticConfigsUrl);if(n!=null&&n.ok)return r.filter(i=>t.includes(i.sku));throw new lc("widget")}};J0.prodUrl="https://dashboard.trillion.jewelry/api/",J0.devUrl="https://dev.dashboard.trillion.jewelry/api/";let BS=J0;const No=new BS;class FS{constructor(t){this.sku=t.sku,this.previewImageUrl=t.previewImageUrl,this.modelPath=t.modelPath,this.category=t.category,this.buyItNowEnabledViewer=t.buyItNowEnabledViewer,this.buyItNowEnabledWidget=t.buyItNowEnabledWidget,this.linkToProduct=t.linkToProduct,this.reflectionMap=t.reflectionMap,this.envMapRotation=t.envMapRotation,this.backgroundColor=t.backgroundColor,this.rotateEnvMapWithCamera=t.rotateEnvMapWithCamera,this.applyEnvMapOnBackground=t.applyEnvMapOnBackground,this.environmentIntensity=t.environmentIntensity,this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundRotation=t.backgroundRotation,this.materialColors=t.materialColors,this.diamondCuts=t.diamondCuts,this.diamondBands=t.diamondBands,this.stoneSizes=t.stoneSizes,this.stoneHalos=t.stoneHalos,this.posteffectsConfig=t.posteffectsConfig,this.materials=t.materials,this.loaderImage=t.loaderImage,this.createdAt=t.createdAt,this.updatedAt=t.updatedAt}}class uc extends FS{constructor(t){super(t),this.widgetReflectionMap=t.widgetReflectionMap,this.carat=t.carat,this.ringPositionHeight=t.ringPositionHeight,this.revertDirection=t.revertDirection,this.ringInnerDiameter=t.ringInnerDiameter}}async function w3(e,t){try{const n=await No.getProductConfigForWidget(e),r=new uc(n);return r.modelPath||(r.modelPath=cd(e)),r}catch(n){if(console.error(n),n instanceof ea||n instanceof ta)throw n;return new uc({sku:e,category:t??q0,modelPath:cd(e),buyItNowEnabled:!1,linkToProduct:""})}}async function zS(e,t){try{return(await No.getProductConfigsForWidget(e)).map(n=>{const r=new uc(n);return r.modelPath||(r.modelPath=cd(n.sku)),r})}catch(n){if(console.error(n),n instanceof ea||n instanceof ta)throw n;return e.map(r=>new uc({sku:r,category:t??q0,modelPath:cd(r),buyItNowEnabled:!1,linkToProduct:""}))}}class b3 extends Xv{constructor(t){super(t),this.type=Ma}parse(t){const n=function(p,m){switch(p){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(m||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(m||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(m||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(m||""))}},r=` `,i=function(p,m,y){m=m||1024;let b=p.pos,x=-1,A=0,E="",M=String.fromCharCode.apply(null,new Uint16Array(p.subarray(b,b+128)));for(;0>(x=M.indexOf(r))&&A<m&&b<p.byteLength;)E+=M,A+=M.length,b+=128,M+=String.fromCharCode.apply(null,new Uint16Array(p.subarray(b,b+128)));return-1<x?(p.pos+=A+x+1,E+M.slice(0,x)):!1},a=function(p){const m=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,x=/^\s*FORMAT=(\S+)\s*$/,A=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,E={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let M,T;for((p.pos>=p.byteLength||!(M=i(p)))&&n(1,"no header found"),(T=M.match(m))||n(3,"bad initial token"),E.valid|=1,E.programtype=T[1],E.string+=M+` `;M=i(p),M!==!1;){if(E.string+=M+` `,M.charAt(0)==="#"){E.comments+=M+` `;continue}if((T=M.match(y))&&(E.gamma=parseFloat(T[1])),(T=M.match(b))&&(E.exposure=parseFloat(T[1])),(T=M.match(x))&&(E.valid|=2,E.format=T[1]),(T=M.match(A))&&(E.valid|=4,E.height=parseInt(T[1],10),E.width=parseInt(T[2],10)),E.valid&2&&E.valid&4)break}return E.valid&2||n(3,"missing format specifier"),E.valid&4||n(3,"missing image size specifier"),E},o=function(p,m,y){const b=m;if(b<8||b>32767||p[0]!==2||p[1]!==2||p[2]&128)return new Uint8Array(p);b!==(p[2]<<8|p[3])&&n(3,"wrong scanline width");const x=new Uint8Array(4*m*y);x.length||n(4,"unable to allocate buffer space");let A=0,E=0;const M=4*b,T=new Uint8Array(4),R=new Uint8Array(M);let I=y;for(;I>0&&E<p.byteLength;){E+4>p.byteLength&&n(1),T[0]=p[E++],T[1]=p[E++],T[2]=p[E++],T[3]=p[E++],(T[0]!=2||T[1]!=2||(T[2]<<8|T[3])!=b)&&n(3,"bad rgbe scanline format");let N=0,O;for(;N<M&&E<p.byteLength;){O=p[E++];const Q=O>128;if(Q&&(O-=128),(O===0||N+O>M)&&n(3,"bad scanline data"),Q){const oe=p[E++];for(let ae=0;ae<O;ae++)R[N++]=oe}else R.set(p.subarray(E,E+O),N),N+=O,E+=O}const Y=b;for(let Q=0;Q<Y;Q++){let oe=0;x[A]=R[Q+oe],oe+=b,x[A+1]=R[Q+oe],oe+=b,x[A+2]=R[Q+oe],oe+=b,x[A+3]=R[Q+oe],A+=4}I--}return x},s=function(p,m,y,b){const x=p[m+3],A=Math.pow(2,x-128)/255;y[b+0]=p[m+0]*A,y[b+1]=p[m+1]*A,y[b+2]=p[m+2]*A,y[b+3]=1},l=function(p,m,y,b){const x=p[m+3],A=Math.pow(2,x-128)/255;y[b+0]=Ss.toHalfFloat(Math.min(p[m+0]*A,65504)),y[b+1]=Ss.toHalfFloat(Math.min(p[m+1]*A,65504)),y[b+2]=Ss.toHalfFloat(Math.min(p[m+2]*A,65504)),y[b+3]=Ss.toHalfFloat(1)},c=new Uint8Array(t);c.pos=0;const d=a(c),u=d.width,h=d.height,f=o(c.subarray(c.pos),u,h);let g,v,_;switch(this.type){case qr:_=f.length/4;const p=new Float32Array(_*4);for(let y=0;y<_;y++)s(f,y*4,p,y*4);g=p,v=qr;break;case Ma:_=f.length/4;const m=new Uint16Array(_*4);for(let y=0;y<_;y++)l(f,y*4,m,y*4);g=m,v=Ma;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:u,height:h,data:g,header:d.string,gamma:d.gamma,exposure:d.exposure,type:v}}setDataType(t){return this.type=t,this}load(t,n,r,i){function a(o,s){switch(o.type){case qr:case Ma:o.colorSpace=Rn,o.minFilter=Zr,o.magFilter=Zr,o.generateMipmaps=!1,o.flipY=!0;break}n&&n(o,s)}return super.load(t,a,r,i)}}const x3={type:"change"},ep={type:"start"},A3={type:"end"},ud=new hE,E3=new N0,US=Math.cos(70*ar.DEG2RAD),Zt=new z,jn=2*Math.PI,et={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},tp=1e-6;class jS extends fE{constructor(t,n=null){super(t,n),this.state=et.NONE,this.enabled=!0,this.target=new z,this.cursor=new z,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ms.ROTATE,MIDDLE:Ms.DOLLY,RIGHT:Ms.PAN},this.touches={ONE:ks.ROTATE,TWO:ks.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new z,this._lastQuaternion=new qi,this._lastTargetPosition=new z,this._quat=new qi().setFromUnitVectors(t.up,new z(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Yv,this._sphericalDelta=new Yv,this._scale=1,this._panOffset=new z,this._rotateStart=new J,this._rotateEnd=new J,this._rotateDelta=new J,this._panStart=new J,this._panEnd=new J,this._panDelta=new J,this._dollyStart=new J,this._dollyEnd=new J,this._dollyDelta=new J,this._dollyDirection=new z,this._mouse=new J,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=GS.bind(this),this._onPointerDown=HS.bind(this),this._onPointerUp=VS.bind(this),this._onContextMenu=qS.bind(this),this._onMouseWheel=XS.bind(this),this._onKeyDown=YS.bind(this),this._onTouchStart=$S.bind(this),this._onTouchMove=QS.bind(this),this._onMouseDown=WS.bind(this),this._onMouseMove=KS.bind(this),this._interceptControlDown=ZS.bind(this),this._interceptControlUp=JS.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(x3),this.update(),this.state=et.NONE}update(t=null){const n=this.object.position;Zt.copy(n).sub(this.target),Zt.applyQuaternion(this._quat),this._spherical.setFromVector3(Zt),this.autoRotate&&this.state===et.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=jn:r>Math.PI&&(r-=jn),i<-Math.PI?i+=jn:i>Math.PI&&(i-=jn),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Zt.setFromSpherical(this._spherical),Zt.applyQuaternion(this._quatInverse),n.copy(this.target).add(Zt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const s=Zt.length();o=this._clampDistance(s*this._scale);const l=s-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const s=new z(this._mouse.x,this._mouse.y,0);s.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new z(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(s),this.object.updateMatrixWorld(),o=Zt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(ud.origin.copy(this.object.position),ud.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ud.direction))<US?this.object.lookAt(this.target):(E3.setFromNormalAndCoplanarPoint(this.object.up,this.target),ud.intersectPlane(E3,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>tp||8*(1-this._lastQuaternion.dot(this.object.quaternion))>tp||this._lastTargetPosition.distanceToSquared(this.target)>tp?(this.dispatchEvent(x3),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?jn/60*this.autoRotateSpeed*t:jn/60/60*this.autoRotateSpeed}_getZoomScale(t){const n=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,n){Zt.setFromMatrixColumn(n,0),Zt.multiplyScalar(-t),this._panOffset.add(Zt)}_panUp(t,n){this.screenSpacePanning===!0?Zt.setFromMatrixColumn(n,1):(Zt.setFromMatrixColumn(n,0),Zt.crossVectors(this.object.up,Zt)),Zt.multiplyScalar(t),this._panOffset.add(Zt)}_pan(t,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Zt.copy(i).sub(this.target);let a=Zt.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=t-r.left,a=n-r.top,o=r.width,s=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/s)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(jn*this._rotateDelta.x/n.clientHeight),this._rotateUp(jn*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let n=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(jn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-jn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(jn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-jn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),r=.5*(t.pageX+n.x),i=.5*(t.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),r=.5*(t.pageX+n.x),i=.5*(t.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(t){const n=this._getSecondPointerPosition(t),r=t.pageX-n.x,i=t.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const r=this._getSecondPointerPosition(t),i=.5*(t.pageX+r.x),a=.5*(t.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(jn*this._rotateDelta.x/n.clientHeight),this._rotateUp(jn*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),r=.5*(t.pageX+n.x),i=.5*(t.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const n=this._getSecondPointerPosition(t),r=t.pageX-n.x,i=t.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(t.pageX+n.x)*.5,s=(t.pageY+n.y)*.5;this._updateZoomParameters(o,s)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==t.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(t){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==t.pointerId)return!0;return!1}_trackPointer(t){let n=this._pointerPositions[t.pointerId];n===void 0&&(n=new J,this._pointerPositions[t.pointerId]=n),n.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const n=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(t){const n=t.deltaMode,r={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function HS(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType==="touch"?this._onTouchStart(e):this._onMouseDown(e)))}function GS(e){this.enabled!==!1&&(e.pointerType==="touch"?this._onTouchMove(e):this._onMouseMove(e))}function VS(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(A3),this.state=et.NONE;break;case 1:const t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function WS(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Ms.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=et.DOLLY;break;case Ms.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=et.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=et.ROTATE}break;case Ms.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=et.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=et.PAN}break;default:this.state=et.NONE}this.state!==et.NONE&&this.dispatchEvent(ep)}function KS(e){switch(this.state){case et.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case et.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case et.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function XS(e){this.enabled===!1||this.enableZoom===!1||this.state!==et.NONE||(e.preventDefault(),this.dispatchEvent(ep),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(A3))}function YS(e){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(e)}function $S(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case ks.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=et.TOUCH_ROTATE;break;case ks.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=et.TOUCH_PAN;break;default:this.state=et.NONE}break;case 2:switch(this.touches.TWO){case ks.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=et.TOUCH_DOLLY_PAN;break;case ks.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=et.TOUCH_DOLLY_ROTATE;break;default:this.state=et.NONE}break;default:this.state=et.NONE}this.state!==et.NONE&&this.dispatchEvent(ep)}function QS(e){switch(this._trackPointer(e),this.state){case et.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case et.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case et.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case et.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=et.NONE}}function qS(e){this.enabled!==!1&&e.preventDefault()}function ZS(e){e.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function JS(e){e.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}/*! fflate - fast JavaScript compression/decompression <https://101arrowz.github.io/fflate> Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE version 0.8.2 */var Rr=Uint8Array,Ns=Uint16Array,e8=Int32Array,S3=new Rr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),M3=new Rr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),t8=new Rr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),k3=function(e,t){for(var n=new Ns(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new e8(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},C3=k3(S3,2),T3=C3.b,n8=C3.r;T3[28]=258,n8[258]=28;for(var r8=k3(M3,0),i8=r8.b,np=new Ns(32768),bt=0;bt<32768;++bt){var Pa=(bt&43690)>>1|(bt&21845)<<1;Pa=(Pa&52428)>>2|(Pa&13107)<<2,Pa=(Pa&61680)>>4|(Pa&3855)<<4,np[bt]=((Pa&65280)>>8|(Pa&255)<<8)>>1}for(var dc=function(e,t,n){for(var r=e.length,i=0,a=new Ns(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new Ns(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new Ns(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],d=t-e[i],u=o[e[i]-1]++<<d,h=u|(1<<d)-1;u<=h;++u)s[np[u]>>l]=c}else for(s=new Ns(r),i=0;i<r;++i)e[i]&&(s[i]=np[o[e[i]-1]++]>>15-e[i]);return s},hc=new Rr(288),bt=0;bt<144;++bt)hc[bt]=8;for(var bt=144;bt<256;++bt)hc[bt]=9;for(var bt=256;bt<280;++bt)hc[bt]=7;for(var bt=280;bt<288;++bt)hc[bt]=8;for(var R3=new Rr(32),bt=0;bt<32;++bt)R3[bt]=5;var a8=dc(hc,9,1),o8=dc(R3,5,1),rp=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ti=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ip=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},s8=function(e){return(e+7)/8|0},l8=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new Rr(e.subarray(t,n))},c8=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ni=function(e,t,n){var r=new Error(t||c8[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ni),!n)throw r;return r},u8=function(e,t,n,r){var i=e.length,a=0;if(!i||t.f&&!t.l)return n||new Rr(0);var o=!n,s=o||t.i!=2,l=t.i;o&&(n=new Rr(i*3));var c=function(Fe){var Vt=n.length;if(Fe>Vt){var it=new Rr(Math.max(Vt*2,Fe));it.set(n),n=it}},d=t.f||0,u=t.p||0,h=t.b||0,f=t.l,g=t.d,v=t.m,_=t.n,p=i*8;do{if(!f){d=ti(e,u,1);var m=ti(e,u+1,3);if(u+=3,m)if(m==1)f=a8,g=o8,v=9,_=5;else if(m==2){var y=ti(e,u,31)+257,b=ti(e,u+10,15)+4,x=y+ti(e,u+5,31)+1;u+=14;for(var A=new Rr(x),E=new Rr(19),M=0;M<b;++M)E[t8[M]]=ti(e,u+M*3,7);u+=b*3;for(var T=rp(E),R=(1<<T)-1,I=dc(E,T,1),M=0;M<x;){var N=I[ti(e,u,R)];u+=N&15;var O=N>>4;if(O<16)A[M++]=O;else{var Y=0,Q=0;for(O==16?(Q=3+ti(e,u,3),u+=2,Y=A[M-1]):O==17?(Q=3+ti(e,u,7),u+=3):O==18&&(Q=11+ti(e,u,127),u+=7);Q--;)A[M++]=Y}}var oe=A.subarray(0,y),ae=A.subarray(y);v=rp(oe),_=rp(ae),f=dc(oe,v,1),g=dc(ae,_,1)}else ni(1);else{var O=s8(u)+4,G=e[O-4]|e[O-3]<<8,Z=O+G;if(Z>i){l&&ni(0);break}s&&c(h+G),n.set(e.subarray(O,Z),h),t.b=h+=G,t.p=u=Z*8,t.f=d;continue}if(u>p){l&&ni(0);break}}s&&c(h+131072);for(var B=(1<<v)-1,ie=(1<<_)-1,H=u;;H=u){var Y=f[ip(e,u)&B],V=Y>>4;if(u+=Y&15,u>p){l&&ni(0);break}if(Y||ni(2),V<256)n[h++]=V;else if(V==256){H=u,f=null;break}else{var ce=V-254;if(V>264){var M=V-257,j=S3[M];ce=ti(e,u,(1<<j)-1)+T3[M],u+=j}var te=g[ip(e,u)&ie],ue=te>>4;te||ni(3),u+=te&15;var ae=i8[ue];if(ue>3){var j=M3[ue];ae+=ip(e,u)&(1<<j)-1,u+=j}if(u>p){l&&ni(0);break}s&&c(h+131072);var we=h+ce;if(h<ae){var xe=a-ae,Ae=Math.min(ae,we);for(xe+h<0&&ni(3);h<Ae;++h)n[h]=r[xe+h]}for(;h<we;++h)n[h]=n[h-ae]}}t.l=f,t.p=H,t.b=h,t.f=d,f&&(d=1,t.m=v,t.d=g,t.n=_)}while(!d);return h!=n.length&&o?l8(n,0,h):n.subarray(0,h)},d8=new Rr(0),h8=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&ni(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&ni(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function dd(e,t){return u8(e.subarray(h8(e,t),-4),{i:2},t,t)}var f8=typeof TextDecoder<"u"&&new TextDecoder,p8=0;try{f8.decode(d8,{stream:!0}),p8=1}catch{}function P3(e,t){if(t===pE)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===D0||t===$v){let n=e.getIndex();if(n===null){const o=[],s=e.g