diff --git a/docs/_astro/App.CPgSZwf1.js b/docs/_astro/App.DuCfkfRl.js similarity index 99% rename from docs/_astro/App.CPgSZwf1.js rename to docs/_astro/App.DuCfkfRl.js index 02a1b29..f8c16d5 100644 --- a/docs/_astro/App.CPgSZwf1.js +++ b/docs/_astro/App.DuCfkfRl.js @@ -10210,7 +10210,7 @@ No matching component was found for: */(function(g){function t(z,X){var j=z.length;z.push(X);t:for(;0>>1,tt=z[Q];if(0>>1;QT(U,j))HT(J,U)?(z[Q]=J,z[H]=j,Q=H):(z[Q]=U,z[Z]=j,Q=Z);else if(HT(J,j))z[Q]=J,z[H]=j,Q=H;else break t}}return X}function T(z,X){var j=z.sortIndex-X.sortIndex;return j!==0?j:z.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var E=performance;g.unstable_now=function(){return E.now()}}else{var s=Date,y=s.now();g.unstable_now=function(){return s.now()-y}}var e=[],r=[],p=1,h=null,a=3,l=!1,n=!1,u=!1,f=typeof setTimeout=="function"?setTimeout:null,o=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(z){for(var X=i(r);X!==null;){if(X.callback===null)x(r);else if(X.startTime<=z)x(r),X.sortIndex=X.expirationTime,t(e,X);else break;X=i(r)}}function v(z){if(u=!1,d(z),!n)if(i(e)!==null)n=!0,B(m);else{var X=i(r);X!==null&&G(v,X.startTime-z)}}function m(z,X){n=!1,u&&(u=!1,o(w),w=-1),l=!0;var j=a;try{for(d(X),h=i(e);h!==null&&(!(h.expirationTime>X)||z&&!P());){var Q=h.callback;if(typeof Q=="function"){h.callback=null,a=h.priorityLevel;var tt=Q(h.expirationTime<=X);X=g.unstable_now(),typeof tt=="function"?h.callback=tt:h===i(e)&&x(e),d(X)}else x(e);h=i(e)}if(h!==null)var Y=!0;else{var Z=i(r);Z!==null&&G(v,Z.startTime-X),Y=!1}return Y}finally{h=null,a=j,l=!1}}var S=!1,M=null,w=-1,C=5,A=-1;function P(){return!(g.unstable_now()-Az||125Q?(z.sortIndex=j,t(r,z),i(e)===null&&z===i(r)&&(u?(o(w),w=-1):u=!0,G(v,j-Q))):(z.sortIndex=tt,t(e,z),n||l||(n=!0,B(m))),z},g.unstable_shouldYield=P,g.unstable_wrapCallback=function(z){var X=a;return function(){var j=a;a=X;try{return z.apply(this,arguments)}finally{a=j}}}})(LA);bA.exports=LA;var hM=bA.exports;const Z1={},n7=g=>void Object.assign(Z1,g);function r7(g,t){function i(p,{args:h=[],attach:a,...l},n){let u=`${p[0].toUpperCase()}${p.slice(1)}`,f;if(p==="primitive"){if(l.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const o=l.object;f=If(o,{type:p,root:n,attach:a,primitive:!0})}else{const o=Z1[u];if(!o)throw new Error(`R3F: ${u} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(h))throw new Error("R3F: The args prop must be an array!");f=If(new o(...h),{type:p,root:n,attach:a,memoizedProps:{args:h}})}return f.__r3f.attach===void 0&&(f instanceof Fi?f.__r3f.attach="geometry":f instanceof Wr&&(f.__r3f.attach="material")),u!=="inject"&&fy(f,l),f}function x(p,h){let a=!1;if(h){var l,n;(l=h.__r3f)!=null&&l.attach?uy(p,h,h.__r3f.attach):h.isObject3D&&p.isObject3D&&(p.add(h),a=!0),a||(n=p.__r3f)==null||n.objects.push(h),h.__r3f||If(h,{}),h.__r3f.parent=p,Lx(h),Nf(h)}}function T(p,h,a){let l=!1;if(h){var n,u;if((n=h.__r3f)!=null&&n.attach)uy(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){h.parent=p,h.dispatchEvent({type:"added"}),p.dispatchEvent({type:"childadded",child:h});const f=p.children.filter(c=>c!==h),o=f.indexOf(a);p.children=[...f.slice(0,o),h,...f.slice(o)],l=!0}l||(u=p.__r3f)==null||u.objects.push(h),h.__r3f||If(h,{}),h.__r3f.parent=p,Lx(h),Nf(h)}}function E(p,h,a=!1){p&&[...p].forEach(l=>s(h,l,a))}function s(p,h,a){if(h){var l,n,u;if(h.__r3f&&(h.__r3f.parent=null),(l=p.__r3f)!=null&&l.objects&&(p.__r3f.objects=p.__r3f.objects.filter(v=>v!==h)),(n=h.__r3f)!=null&&n.attach)pM(p,h,h.__r3f.attach);else if(h.isObject3D&&p.isObject3D){var f;p.remove(h),(f=h.__r3f)!=null&&f.root&&c7(dm(h),h)}const c=(u=h.__r3f)==null?void 0:u.primitive,d=!c&&(a===void 0?h.dispose!==null:a);if(!c){var o;E((o=h.__r3f)==null?void 0:o.objects,h,d),E(h.children,h,d)}if(delete h.__r3f,d&&h.dispose&&h.type!=="Scene"){const v=()=>{try{h.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?hM.unstable_scheduleCallback(hM.unstable_IdlePriority,v):v()}Nf(p)}}function y(p,h,a,l){var n;const u=(n=p.__r3f)==null?void 0:n.parent;if(!u)return;const f=i(h,a,p.__r3f.root);if(p.children){for(const o of p.children)o.__r3f&&x(f,o);p.children=p.children.filter(o=>!o.__r3f)}p.__r3f.objects.forEach(o=>x(f,o)),p.__r3f.objects=[],p.__r3f.autoRemovedBeforeAppend||s(u,p),f.parent&&(f.__r3f.autoRemovedBeforeAppend=!0),x(u,f),f.raycast&&f.__r3f.eventCount&&dm(f).getState().internal.interaction.push(f),[l,l.alternate].forEach(o=>{o!==null&&(o.stateNode=f,o.ref&&(typeof o.ref=="function"?o.ref(f):o.ref.current=f))})}const e=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:i7({createInstance:i,removeChild:s,appendChild:x,appendInitialChild:x,insertBefore:T,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(p,h)=>{if(!h)return;const a=p.getState().scene;a.__r3f&&(a.__r3f.root=p,x(a,h))},removeChildFromContainer:(p,h)=>{h&&s(p.getState().scene,h)},insertInContainerBefore:(p,h,a)=>{if(!h||!a)return;const l=p.getState().scene;l.__r3f&&T(l,h,a)},getRootHostContext:()=>null,getChildHostContext:p=>p,finalizeInitialChildren(p){var h;return!!((h=p?.__r3f)!=null?h:{}).handlers},prepareUpdate(p,h,a,l){var n;if(((n=p?.__r3f)!=null?n:{}).primitive&&l.object&&l.object!==p)return[!0];{const{args:f=[],children:o,...c}=l,{args:d=[],children:v,...m}=a;if(!Array.isArray(f))throw new Error("R3F: the args prop must be an array!");if(f.some((M,w)=>M!==d[w]))return[!0];const S=UA(p,c,m,!0);return S.changes.length?[!1,S]:null}},commitUpdate(p,[h,a],l,n,u,f){h?y(p,l,u,f):fy(p,a)},commitMount(p,h,a,l){var n;const u=(n=p.__r3f)!=null?n:{};p.raycast&&u.handlers&&u.eventCount&&dm(p).getState().internal.interaction.push(p)},getPublicInstance:p=>p,prepareForCommit:()=>null,preparePortalMount:p=>If(p.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(p){var h;const{attach:a,parent:l}=(h=p.__r3f)!=null?h:{};a&&l&&pM(l,p,a),p.isObject3D&&(p.visible=!1),Nf(p)},unhideInstance(p,h){var a;const{attach:l,parent:n}=(a=p.__r3f)!=null?a:{};l&&n&&uy(n,p,l),(p.isObject3D&&h.visible==null||h.visible)&&(p.visible=!0),Nf(p)},createTextInstance:e,hideTextInstance:e,unhideTextInstance:e,getCurrentEventPriority:()=>t?t():kf.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&An.fun(performance.now)?performance.now:An.fun(Date.now)?Date.now:()=>0,scheduleTimeout:An.fun(setTimeout)?setTimeout:void 0,cancelTimeout:An.fun(clearTimeout)?clearTimeout:void 0}),applyProps:fy}}var uM,fM;const hy=g=>"colorSpace"in g||"outputColorSpace"in g,FA=()=>{var g;return(g=Z1.ColorManagement)!=null?g:null},OA=g=>g&&g.isOrthographicCamera,s7=g=>g&&g.hasOwnProperty("current"),lp=typeof window<"u"&&((uM=window.document)!=null&&uM.createElement||((fM=window.navigator)==null?void 0:fM.product)==="ReactNative")?Me.useLayoutEffect:Me.useEffect;function DA(g){const t=Me.useRef(g);return lp(()=>void(t.current=g),[g]),t}function a7({set:g}){return lp(()=>(g(new Promise(()=>null)),()=>g(!1)),[g]),null}class IA extends Me.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}}IA.getDerivedStateFromError=()=>({error:!0});const NA="__default",cM=new Map,o7=g=>g&&!!g.memoized&&!!g.changes;function BA(g){var t;const i=typeof window<"u"?(t=window.devicePixelRatio)!=null?t:2:1;return Array.isArray(g)?Math.min(Math.max(g[0],i),g[1]):g}const rd=g=>{var t;return(t=g.__r3f)==null?void 0:t.root.getState()};function dm(g){let t=g.__r3f.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}const An={obj:g=>g===Object(g)&&!An.arr(g)&&typeof g!="function",fun:g=>typeof g=="function",str:g=>typeof g=="string",num:g=>typeof g=="number",boo:g=>typeof g=="boolean",und:g=>g===void 0,arr:g=>Array.isArray(g),equ(g,t,{arrays:i="shallow",objects:x="reference",strict:T=!0}={}){if(typeof g!=typeof t||!!g!=!!t)return!1;if(An.str(g)||An.num(g))return g===t;const E=An.obj(g);if(E&&x==="reference")return g===t;const s=An.arr(g);if(s&&i==="reference")return g===t;if((s||E)&&g===t)return!0;let y;for(y in g)if(!(y in t))return!1;if(E&&i==="shallow"&&x==="shallow"){for(y in T?t:g)if(!An.equ(g[y],t[y],{strict:T,objects:"reference"}))return!1}else for(y in T?t:g)if(g[y]!==t[y])return!1;if(An.und(y)){if(s&&g.length===0&&t.length===0||E&&Object.keys(g).length===0&&Object.keys(t).length===0)return!0;if(g!==t)return!1}return!0}};function l7(g){g.dispose&&g.type!=="Scene"&&g.dispose();for(const t in g)t.dispose==null||t.dispose(),delete g[t]}function If(g,t){const i=g;return i.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...t},g}function bx(g,t){let i=g;if(t.includes("-")){const x=t.split("-"),T=x.pop();return i=x.reduce((E,s)=>E[s],g),{target:i,key:T}}else return{target:i,key:t}}const dM=/-\d+$/;function uy(g,t,i){if(An.str(i)){if(dM.test(i)){const E=i.replace(dM,""),{target:s,key:y}=bx(g,E);Array.isArray(s[y])||(s[y]=[])}const{target:x,key:T}=bx(g,i);t.__r3f.previousAttach=x[T],x[T]=t}else t.__r3f.previousAttach=i(g,t)}function pM(g,t,i){var x,T;if(An.str(i)){const{target:E,key:s}=bx(g,i),y=t.__r3f.previousAttach;y===void 0?delete E[s]:E[s]=y}else(x=t.__r3f)==null||x.previousAttach==null||x.previousAttach(g,t);(T=t.__r3f)==null||delete T.previousAttach}function UA(g,{children:t,key:i,ref:x,...T},{children:E,key:s,ref:y,...e}={},r=!1){var p;const h=(p=g?.__r3f)!=null?p:{},a=Object.entries(T),l=[];if(r){const u=Object.keys(e);for(let f=0;f{var o;if((o=g.__r3f)!=null&&o.primitive&&u==="object"||An.equ(f,e[u]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(u))return l.push([u,f,!0,[]]);let c=[];u.includes("-")&&(c=u.split("-")),l.push([u,f,!1,c]);for(const d in T){const v=T[d];d.startsWith(`${u}-`)&&l.push([d,v,!1,d.split("-")])}});const n={...T};return h.memoizedProps&&h.memoizedProps.args&&(n.args=h.memoizedProps.args),h.memoizedProps&&h.memoizedProps.attach&&(n.attach=h.memoizedProps.attach),{memoized:n,changes:l}}const h7=typeof process<"u"&&!1;function fy(g,t){var i,x,T;const E=(i=g.__r3f)!=null?i:{},s=E.root,y=(x=s==null||s.getState==null?void 0:s.getState())!=null?x:{},{memoized:e,changes:r}=o7(t)?t:UA(g,t),p=E.eventCount;g.__r3f&&(g.__r3f.memoizedProps=e);for(let a=0;ad[v],g),!(c&&c.set))){const[d,...v]=f.reverse();o=v.reverse().reduce((m,S)=>m[S],g),l=d}if(n===NA+"remove")if(o.constructor){let d=cM.get(o.constructor);d||(d=new o.constructor,cM.set(o.constructor,d)),n=d[l]}else n=0;if(u)n?E.handlers[l]=n:delete E.handlers[l],E.eventCount=Object.keys(E.handlers).length;else if(c&&c.set&&(c.copy||c instanceof Mu)){if(Array.isArray(n))c.fromArray?c.fromArray(n):c.set(...n);else if(c.copy&&n&&n.constructor&&(h7?c.constructor.name===n.constructor.name:c.constructor===n.constructor))c.copy(n);else if(n!==void 0){const d=c instanceof ze;!d&&c.setScalar?c.setScalar(n):c instanceof Mu&&n instanceof Mu?c.mask=n.mask:c.set(n),!FA()&&!y.linear&&d&&c.convertSRGBToLinear()}}else if(o[l]=n,o[l]instanceof zn&&o[l].format===vs&&o[l].type===Go){const d=o[l];hy(d)&&hy(y.gl)?d.colorSpace=y.gl.outputColorSpace:d.encoding=y.gl.outputEncoding}Nf(g)}if(E.parent&&g.raycast&&p!==E.eventCount){const a=dm(g).getState().internal,l=a.interaction.indexOf(g);l>-1&&a.interaction.splice(l,1),E.eventCount&&a.interaction.push(g)}return!(r.length===1&&r[0][0]==="onUpdate")&&r.length&&(T=g.__r3f)!=null&&T.parent&&Lx(g),g}function Nf(g){var t,i;const x=(t=g.__r3f)==null||(i=t.root)==null||i.getState==null?void 0:i.getState();x&&x.internal.frames===0&&x.invalidate()}function Lx(g){g.onUpdate==null||g.onUpdate(g)}function u7(g,t){g.manual||(OA(g)?(g.left=t.width/-2,g.right=t.width/2,g.top=t.height/2,g.bottom=t.height/-2):g.aspect=t.width/t.height,g.updateProjectionMatrix(),g.updateMatrixWorld())}function $v(g){return(g.eventObject||g.object).uuid+"/"+g.index+g.instanceId}function f7(){var g;const t=typeof self<"u"&&self||typeof window<"u"&&window;if(!t)return kf.DefaultEventPriority;switch((g=t.event)==null?void 0:g.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return kf.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return kf.ContinuousEventPriority;default:return kf.DefaultEventPriority}}function zA(g,t,i,x){const T=i.get(t);T&&(i.delete(t),i.size===0&&(g.delete(x),T.target.releasePointerCapture(x)))}function c7(g,t){const{internal:i}=g.getState();i.interaction=i.interaction.filter(x=>x!==t),i.initialHits=i.initialHits.filter(x=>x!==t),i.hovered.forEach((x,T)=>{(x.eventObject===t||x.object===t)&&i.hovered.delete(T)}),i.capturedMap.forEach((x,T)=>{zA(i.capturedMap,t,x,T)})}function d7(g){function t(e){const{internal:r}=g.getState(),p=e.offsetX-r.initialClick[0],h=e.offsetY-r.initialClick[1];return Math.round(Math.sqrt(p*p+h*h))}function i(e){return e.filter(r=>["Move","Over","Enter","Out","Leave"].some(p=>{var h;return(h=r.__r3f)==null?void 0:h.handlers["onPointer"+p]}))}function x(e,r){const p=g.getState(),h=new Set,a=[],l=r?r(p.internal.interaction):p.internal.interaction;for(let o=0;o{const d=rd(o.object),v=rd(c.object);return!d||!v?o.distance-c.distance:v.events.priority-d.events.priority||o.distance-c.distance}).filter(o=>{const c=$v(o);return h.has(c)?!1:(h.add(c),!0)});p.events.filter&&(u=p.events.filter(u,p));for(const o of u){let c=o.object;for(;c;){var f;(f=c.__r3f)!=null&&f.eventCount&&a.push({...o,eventObject:c}),c=c.parent}}if("pointerId"in e&&p.internal.capturedMap.has(e.pointerId))for(let o of p.internal.capturedMap.get(e.pointerId).values())h.has($v(o.intersection))||a.push(o.intersection);return a}function T(e,r,p,h){const a=g.getState();if(e.length){const l={stopped:!1};for(const n of e){const u=rd(n.object)||a,{raycaster:f,pointer:o,camera:c,internal:d}=u,v=new Ct(o.x,o.y,0).unproject(c),m=A=>{var P,b;return(P=(b=d.capturedMap.get(A))==null?void 0:b.has(n.eventObject))!=null?P:!1},S=A=>{const P={intersection:n,target:r.target};d.capturedMap.has(A)?d.capturedMap.get(A).set(n.eventObject,P):d.capturedMap.set(A,new Map([[n.eventObject,P]])),r.target.setPointerCapture(A)},M=A=>{const P=d.capturedMap.get(A);P&&zA(d.capturedMap,n.eventObject,P,A)};let w={};for(let A in r){let P=r[A];typeof P!="function"&&(w[A]=P)}let C={...n,...w,pointer:o,intersections:e,stopped:l.stopped,delta:p,unprojectedPoint:v,ray:f.ray,camera:c,stopPropagation(){const A="pointerId"in r&&d.capturedMap.get(r.pointerId);if((!A||A.has(n.eventObject))&&(C.stopped=l.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(P=>P.eventObject===n.eventObject))){const P=e.slice(0,e.indexOf(n));E([...P,n])}},target:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},currentTarget:{hasPointerCapture:m,setPointerCapture:S,releasePointerCapture:M},nativeEvent:r};if(h(C),l.stopped===!0)break}}return e}function E(e){const{internal:r}=g.getState();for(const p of r.hovered.values())if(!e.length||!e.find(h=>h.object===p.object&&h.index===p.index&&h.instanceId===p.instanceId)){const a=p.eventObject.__r3f,l=a?.handlers;if(r.hovered.delete($v(p)),a!=null&&a.eventCount){const n={...p,intersections:e};l.onPointerOut==null||l.onPointerOut(n),l.onPointerLeave==null||l.onPointerLeave(n)}}}function s(e,r){for(let p=0;pE([]);case"onLostPointerCapture":return r=>{const{internal:p}=g.getState();"pointerId"in r&&p.capturedMap.has(r.pointerId)&&requestAnimationFrame(()=>{p.capturedMap.has(r.pointerId)&&(p.capturedMap.delete(r.pointerId),E([]))})}}return function(p){const{onPointerMissed:h,internal:a}=g.getState();a.lastEvent.current=p;const l=e==="onPointerMove",n=e==="onClick"||e==="onContextMenu"||e==="onDoubleClick",f=x(p,l?i:void 0),o=n?t(p):0;e==="onPointerDown"&&(a.initialClick=[p.offsetX,p.offsetY],a.initialHits=f.map(d=>d.eventObject)),n&&!f.length&&o<=2&&(s(p,a.interaction),h&&h(p)),l&&E(f);function c(d){const v=d.eventObject,m=v.__r3f,S=m?.handlers;if(m!=null&&m.eventCount)if(l){if(S.onPointerOver||S.onPointerEnter||S.onPointerOut||S.onPointerLeave){const M=$v(d),w=a.hovered.get(M);w?w.stopped&&d.stopPropagation():(a.hovered.set(M,d),S.onPointerOver==null||S.onPointerOver(d),S.onPointerEnter==null||S.onPointerEnter(d))}S.onPointerMove==null||S.onPointerMove(d)}else{const M=S[e];M?(!n||a.initialHits.includes(v))&&(s(p,a.interaction.filter(w=>!a.initialHits.includes(w))),M(d)):n&&a.initialHits.includes(v)&&s(p,a.interaction.filter(w=>!a.initialHits.includes(w)))}}T(f,p,o,c)}}return{handlePointer:y}}const GA=g=>!!(g!=null&&g.render),VA=Me.createContext(null),p7=(g,t)=>{const i=Qz((y,e)=>{const r=new Ct,p=new Ct,h=new Ct;function a(o=e().camera,c=p,d=e().size){const{width:v,height:m,top:S,left:M}=d,w=v/m;c instanceof Ct?h.copy(c):h.set(...c);const C=o.getWorldPosition(r).distanceTo(h);if(OA(o))return{width:v/o.zoom,height:m/o.zoom,top:S,left:M,factor:1,distance:C,aspect:w};{const A=o.fov*Math.PI/180,P=2*Math.tan(A/2)*C,b=P*(v/m);return{width:b,height:P,top:S,left:M,factor:v/b,distance:C,aspect:w}}}let l;const n=o=>y(c=>({performance:{...c.performance,current:o}})),u=new ve;return{set:y,get:e,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(o=1)=>g(e(),o),advance:(o,c)=>t(o,c,e()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Y1,pointer:u,mouse:u,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const o=e();l&&clearTimeout(l),o.performance.current!==o.performance.min&&n(o.performance.min),l=setTimeout(()=>n(e().performance.max),o.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:a},setEvents:o=>y(c=>({...c,events:{...c.events,...o}})),setSize:(o,c,d,v,m)=>{const S=e().camera,M={width:o,height:c,top:v||0,left:m||0,updateStyle:d};y(w=>({size:M,viewport:{...w.viewport,...a(S,p,M)}}))},setDpr:o=>y(c=>{const d=BA(o);return{viewport:{...c.viewport,dpr:d,initialDpr:c.viewport.initialDpr||d}}}),setFrameloop:(o="always")=>{const c=e().clock;c.stop(),c.elapsedTime=0,o!=="never"&&(c.start(),c.elapsedTime=0),y(()=>({frameloop:o}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Me.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(o,c,d)=>{const v=e().internal;return v.priority=v.priority+(c>0?1:0),v.subscribers.push({ref:o,priority:c,store:d}),v.subscribers=v.subscribers.sort((m,S)=>m.priority-S.priority),()=>{const m=e().internal;m!=null&&m.subscribers&&(m.priority=m.priority-(c>0?1:0),m.subscribers=m.subscribers.filter(S=>S.ref!==o))}}}}}),x=i.getState();let T=x.size,E=x.viewport.dpr,s=x.camera;return i.subscribe(()=>{const{camera:y,size:e,viewport:r,gl:p,set:h}=i.getState();if(e.width!==T.width||e.height!==T.height||r.dpr!==E){var a;T=e,E=r.dpr,u7(y,e),p.setPixelRatio(r.dpr);const l=(a=e.updateStyle)!=null?a:typeof HTMLCanvasElement<"u"&&p.domElement instanceof HTMLCanvasElement;p.setSize(e.width,e.height,l)}y!==s&&(s=y,h(l=>({viewport:{...l.viewport,...l.viewport.getCurrentViewport(y)}})))}),i.subscribe(y=>g(y)),i};let Qv,v7=new Set,m7=new Set,g7=new Set;function cy(g,t){if(g.size)for(const{callback:i}of g.values())i(t)}function sd(g,t){switch(g){case"before":return cy(v7,t);case"after":return cy(m7,t);case"tail":return cy(g7,t)}}let dy,py;function vy(g,t,i){let x=t.clock.getDelta();for(t.frameloop==="never"&&typeof g=="number"&&(x=g-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=g),dy=t.internal.subscribers,Qv=0;Qv0)&&!((p=E.gl.xr)!=null&&p.isPresenting)&&(x+=vy(r,E))}if(i=!1,sd("after",r),x===0)return sd("tail",r),t=!1,cancelAnimationFrame(T)}function y(r,p=1){var h;if(!r)return g.forEach(a=>y(a.store.getState(),p));(h=r.gl.xr)!=null&&h.isPresenting||!r.internal.active||r.frameloop==="never"||(p>1?r.internal.frames=Math.min(60,r.internal.frames+p):i?r.internal.frames=2:r.internal.frames=1,t||(t=!0,requestAnimationFrame(s)))}function e(r,p=!0,h,a){if(p&&sd("before",r),h)vy(r,h,a);else for(const l of g.values())vy(r,l.store.getState());p&&sd("after",r)}return{loop:s,invalidate:y,advance:e}}function x7(){const g=Me.useContext(VA);if(!g)throw new Error("R3F: Hooks can only be used within the Canvas component!");return g}function S7(g,t=0){const i=x7(),x=i.getState().internal.subscribe,T=DA(g);return lp(()=>x(T,t,i),[t,x,i]),null}const nc=new Map,{invalidate:vM,advance:mM}=y7(nc),{reconciler:bm,applyProps:Of}=r7(nc,f7),Df={objects:"shallow",strict:!1},T7=(g,t)=>{const i=typeof g=="function"?g(t):g;return GA(i)?i:new R1({powerPreference:"high-performance",canvas:t,antialias:!0,alpha:!0,...g})};function E7(g,t){const i=typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement;if(t){const{width:x,height:T,top:E,left:s,updateStyle:y=i}=t;return{width:x,height:T,top:E,left:s,updateStyle:y}}else if(typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement&&g.parentElement){const{width:x,height:T,top:E,left:s}=g.parentElement.getBoundingClientRect();return{width:x,height:T,top:E,left:s,updateStyle:i}}else if(typeof OffscreenCanvas<"u"&&g instanceof OffscreenCanvas)return{width:g.width,height:g.height,top:0,left:0,updateStyle:i};return{width:0,height:0,top:0,left:0}}function M7(g){const t=nc.get(g),i=t?.fiber,x=t?.store;t&&console.warn("R3F.createRoot should only be called once!");const T=typeof reportError=="function"?reportError:console.error,E=x||p7(vM,mM),s=i||bm.createContainer(E,kf.ConcurrentRoot,null,!1,null,"",T,null);t||nc.set(g,{fiber:s,store:E});let y,e=!1,r;return{configure(p={}){let{gl:h,size:a,scene:l,events:n,onCreated:u,shadows:f=!1,linear:o=!1,flat:c=!1,legacy:d=!1,orthographic:v=!1,frameloop:m="always",dpr:S=[1,2],performance:M,raycaster:w,camera:C,onPointerMissed:A}=p,P=E.getState(),b=P.gl;P.gl||P.set({gl:b=T7(h,g)});let O=P.raycaster;O||P.set({raycaster:O=new wA});const{params:I,...D}=w||{};if(An.equ(D,O,Df)||Of(O,{...D}),An.equ(I,O.params,Df)||Of(O,{params:{...O.params,...I}}),!P.camera||P.camera===r&&!An.equ(r,C,Df)){r=C;const j=C instanceof tp,Q=j?C:v?new np(0,0,0,0,.1,1e3):new Dr(75,0,.1,1e3);j||(Q.position.z=5,C&&Of(Q,C),!P.camera&&!(C!=null&&C.rotation)&&Q.lookAt(0,0,0)),P.set({camera:Q}),O.camera=Q}if(!P.scene){let j;l instanceof Pm?j=l:(j=new Pm,l&&Of(j,l)),P.set({scene:If(j)})}if(!P.xr){var B;const j=(Y,Z)=>{const U=E.getState();U.frameloop!=="never"&&mM(Y,!0,U,Z)},Q=()=>{const Y=E.getState();Y.gl.xr.enabled=Y.gl.xr.isPresenting,Y.gl.xr.setAnimationLoop(Y.gl.xr.isPresenting?j:null),Y.gl.xr.isPresenting||vM(Y)},tt={connect(){const Y=E.getState().gl;Y.xr.addEventListener("sessionstart",Q),Y.xr.addEventListener("sessionend",Q)},disconnect(){const Y=E.getState().gl;Y.xr.removeEventListener("sessionstart",Q),Y.xr.removeEventListener("sessionend",Q)}};typeof((B=b.xr)==null?void 0:B.addEventListener)=="function"&&tt.connect(),P.set({xr:tt})}if(b.shadowMap){const j=b.shadowMap.enabled,Q=b.shadowMap.type;if(b.shadowMap.enabled=!!f,An.boo(f))b.shadowMap.type=cd;else if(An.str(f)){var G;const tt={basic:mw,percentage:lg,soft:cd,variance:qa};b.shadowMap.type=(G=tt[f])!=null?G:cd}else An.obj(f)&&Object.assign(b.shadowMap,f);(j!==b.shadowMap.enabled||Q!==b.shadowMap.type)&&(b.shadowMap.needsUpdate=!0)}const z=FA();z&&("enabled"in z?z.enabled=!d:"legacyMode"in z&&(z.legacyMode=d)),e||Of(b,{outputEncoding:o?3e3:3001,toneMapping:c?zo:l1}),P.legacy!==d&&P.set(()=>({legacy:d})),P.linear!==o&&P.set(()=>({linear:o})),P.flat!==c&&P.set(()=>({flat:c})),h&&!An.fun(h)&&!GA(h)&&!An.equ(h,b,Df)&&Of(b,h),n&&!P.events.handlers&&P.set({events:n(E)});const X=E7(g,a);return An.equ(X,P.size,Df)||P.setSize(X.width,X.height,X.updateStyle,X.top,X.left),S&&P.viewport.dpr!==BA(S)&&P.setDpr(S),P.frameloop!==m&&P.setFrameloop(m),P.onPointerMissed||P.set({onPointerMissed:A}),M&&!An.equ(M,P.performance,Df)&&P.set(j=>({performance:{...j.performance,...M}})),y=u,e=!0,this},render(p){return e||this.configure(),bm.updateContainer(Me.createElement(C7,{store:E,children:p,onCreated:y,rootElement:g}),s,null,()=>{}),E},unmount(){HA(g)}}}function C7({store:g,children:t,onCreated:i,rootElement:x}){return lp(()=>{const T=g.getState();T.set(E=>({internal:{...E.internal,active:!0}})),i&&i(T),g.getState().events.connected||T.events.connect==null||T.events.connect(x)},[]),Me.createElement(VA.Provider,{value:g},t)}function HA(g,t){const i=nc.get(g),x=i?.fiber;if(x){const T=i?.store.getState();T&&(T.internal.active=!1),bm.updateContainer(null,x,null,()=>{T&&setTimeout(()=>{try{var E,s,y,e;T.events.disconnect==null||T.events.disconnect(),(E=T.gl)==null||(s=E.renderLists)==null||s.dispose==null||s.dispose(),(y=T.gl)==null||y.forceContextLoss==null||y.forceContextLoss(),(e=T.gl)!=null&&e.xr&&T.xr.disconnect(),l7(T),nc.delete(g),t&&t(g)}catch{}},500)})}}bm.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Me.version});function Lm(){return Lm=Object.assign?Object.assign.bind():function(g){for(var t=1;t=0?x=setTimeout(e,t-p):(x=null,i||(y=g.apply(E,T),E=T=null))}var r=function(){E=this,T=arguments,s=Date.now();var p=i&&!x;return x||(x=setTimeout(e,t)),p&&(y=g.apply(E,T),E=T=null),y};return r.clear=function(){x&&(clearTimeout(x),x=null)},r.flush=function(){x&&(y=g.apply(E,T),E=T=null,clearTimeout(x),x=null)},r}Fx.debounce=Fx;var w7=Fx;const gM=kd(w7);function A7(g){let{debounce:t,scroll:i,polyfill:x,offsetSize:T}=g===void 0?{debounce:0,scroll:!1,offsetSize:!1}:g;const E=x||(typeof window>"u"?class{}:window.ResizeObserver);if(!E)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,y]=Me.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),e=Me.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s}),r=t?typeof t=="number"?t:t.scroll:null,p=t?typeof t=="number"?t:t.resize:null,h=Me.useRef(!1);Me.useEffect(()=>(h.current=!0,()=>void(h.current=!1)));const[a,l,n]=Me.useMemo(()=>{const c=()=>{if(!e.current.element)return;const{left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A}=e.current.element.getBoundingClientRect(),P={left:d,top:v,width:m,height:S,bottom:M,right:w,x:C,y:A};e.current.element instanceof HTMLElement&&T&&(P.height=e.current.element.offsetHeight,P.width=e.current.element.offsetWidth),Object.freeze(P),h.current&&!L7(e.current.lastBounds,P)&&y(e.current.lastBounds=P)};return[c,p?gM(c,p):c,r?gM(c,r):c]},[y,T,r,p]);function u(){e.current.scrollContainers&&(e.current.scrollContainers.forEach(c=>c.removeEventListener("scroll",n,!0)),e.current.scrollContainers=null),e.current.resizeObserver&&(e.current.resizeObserver.disconnect(),e.current.resizeObserver=null)}function f(){e.current.element&&(e.current.resizeObserver=new E(n),e.current.resizeObserver.observe(e.current.element),i&&e.current.scrollContainers&&e.current.scrollContainers.forEach(c=>c.addEventListener("scroll",n,{capture:!0,passive:!0})))}const o=c=>{!c||c===e.current.element||(u(),e.current.element=c,e.current.scrollContainers=WA(c),f())};return R7(n,!!i),P7(l),Me.useEffect(()=>{u(),f()},[i,n,l]),Me.useEffect(()=>u,[]),[o,s,a]}function P7(g){Me.useEffect(()=>{const t=g;return window.addEventListener("resize",t),()=>void window.removeEventListener("resize",t)},[g])}function R7(g,t){Me.useEffect(()=>{if(t){const i=g;return window.addEventListener("scroll",i,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",i,!0)}},[g,t])}function WA(g){const t=[];if(!g||g===document.body)return t;const{overflow:i,overflowX:x,overflowY:T}=window.getComputedStyle(g);return[i,x,T].some(E=>E==="auto"||E==="scroll")&&t.push(g),[...t,...WA(g.parentElement)]}const b7=["x","y","top","bottom","left","right","width","height"],L7=(g,t)=>b7.every(i=>g[i]===t[i]);var F7=Object.defineProperty,O7=Object.defineProperties,D7=Object.getOwnPropertyDescriptors,yM=Object.getOwnPropertySymbols,I7=Object.prototype.hasOwnProperty,N7=Object.prototype.propertyIsEnumerable,xM=(g,t,i)=>t in g?F7(g,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[t]=i,SM=(g,t)=>{for(var i in t||(t={}))I7.call(t,i)&&xM(g,i,t[i]);if(yM)for(var i of yM(t))N7.call(t,i)&&xM(g,i,t[i]);return g},B7=(g,t)=>O7(g,D7(t)),TM,EM;typeof window<"u"&&((TM=window.document)!=null&&TM.createElement||((EM=window.navigator)==null?void 0:EM.product)==="ReactNative")?Me.useLayoutEffect:Me.useEffect;function XA(g,t,i){if(!g)return;if(i(g)===!0)return g;let x=t?g.return:g.child;for(;x;){const T=XA(x,t,i);if(T)return T;x=t?null:x.sibling}}function YA(g){try{return Object.defineProperties(g,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return g}}const MM=console.error;console.error=function(){const g=[...arguments].join("");if(g?.startsWith("Warning:")&&g.includes("useContext")){console.error=MM;return}return MM.apply(this,arguments)};const J1=YA(Me.createContext(null));class kA extends Me.Component{render(){return Me.createElement(J1.Provider,{value:this._reactInternals},this.props.children)}}function U7(){const g=Me.useContext(J1);if(g===null)throw new Error("its-fine: useFiber must be called within a !");const t=Me.useId();return Me.useMemo(()=>{for(const x of[g,g?.alternate]){if(!x)continue;const T=XA(x,!1,E=>{let s=E.memoizedState;for(;s;){if(s.memoizedState===t)return!0;s=s.next}});if(T)return T}},[g,t])}function z7(){const g=U7(),[t]=Me.useState(()=>new Map);t.clear();let i=g;for(;i;){if(i.type&&typeof i.type=="object"){const T=i.type._context===void 0&&i.type.Provider===i.type?i.type:i.type._context;T&&T!==J1&&!t.has(T)&&t.set(T,Me.useContext(YA(T)))}i=i.return}return t}function G7(){const g=z7();return Me.useMemo(()=>Array.from(g.keys()).reduce((t,i)=>x=>Me.createElement(t,null,Me.createElement(i.Provider,B7(SM({},x),{value:g.get(i)}))),t=>Me.createElement(kA,SM({},t))),[g])}const my={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function V7(g){const{handlePointer:t}=d7(g);return{priority:1,enabled:!0,compute(i,x,T){x.pointer.set(i.offsetX/x.size.width*2-1,-(i.offsetY/x.size.height)*2+1),x.raycaster.setFromCamera(x.pointer,x.camera)},connected:void 0,handlers:Object.keys(my).reduce((i,x)=>({...i,[x]:t(x)}),{}),update:()=>{var i;const{events:x,internal:T}=g.getState();(i=T.lastEvent)!=null&&i.current&&x.handlers&&x.handlers.onPointerMove(T.lastEvent.current)},connect:i=>{var x;const{set:T,events:E}=g.getState();E.disconnect==null||E.disconnect(),T(s=>({events:{...s.events,connected:i}})),Object.entries((x=E.handlers)!=null?x:[]).forEach(([s,y])=>{const[e,r]=my[s];i.addEventListener(e,y,{passive:r})})},disconnect:()=>{const{set:i,events:x}=g.getState();if(x.connected){var T;Object.entries((T=x.handlers)!=null?T:[]).forEach(([E,s])=>{if(x&&x.connected instanceof HTMLElement){const[y]=my[E];x.connected.removeEventListener(y,s)}}),i(E=>({events:{...E.events,connected:void 0}}))}}}}const H7=Me.forwardRef(function({children:t,fallback:i,resize:x,style:T,gl:E,events:s=V7,eventSource:y,eventPrefix:e,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,onPointerMissed:v,onCreated:m,...S},M){Me.useMemo(()=>n7(Zz),[]);const w=G7(),[C,A]=A7({scroll:!0,debounce:{scroll:50,resize:0},...x}),P=Me.useRef(null),b=Me.useRef(null);Me.useImperativeHandle(M,()=>P.current);const O=DA(v),[I,D]=Me.useState(!1),[B,G]=Me.useState(!1);if(I)throw I;if(B)throw B;const z=Me.useRef(null);lp(()=>{const j=P.current;A.width>0&&A.height>0&&j&&(z.current||(z.current=M7(j)),z.current.configure({gl:E,events:s,shadows:r,linear:p,flat:h,legacy:a,orthographic:l,frameloop:n,dpr:u,performance:f,raycaster:o,camera:c,scene:d,size:A,onPointerMissed:(...Q)=>O.current==null?void 0:O.current(...Q),onCreated:Q=>{Q.events.connect==null||Q.events.connect(y?s7(y)?y.current:y:b.current),e&&Q.setEvents({compute:(tt,Y)=>{const Z=tt[e+"X"],U=tt[e+"Y"];Y.pointer.set(Z/Y.size.width*2-1,-(U/Y.size.height)*2+1),Y.raycaster.setFromCamera(Y.pointer,Y.camera)}}),m?.(Q)}}),z.current.render(Me.createElement(w,null,Me.createElement(IA,{set:G},Me.createElement(Me.Suspense,{fallback:Me.createElement(a7,{set:D})},t)))))}),Me.useEffect(()=>{const j=P.current;if(j)return()=>HA(j)},[]);const X=y?"none":"auto";return Me.createElement("div",Lm({ref:b,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:X,...T}},S),Me.createElement("div",{ref:C,style:{width:"100%",height:"100%"}},Me.createElement("canvas",{ref:P,style:{display:"block"}},i)))}),W7=Me.forwardRef(function(t,i){return Me.createElement(kA,null,Me.createElement(H7,Lm({},t,{ref:i})))});function io(g,t={}){let i=Me.useCallback(T=>t.keys?QO(g,t.keys,T):g.listen(T),[t.keys,g]),x=g.get.bind(g);return Me.useSyncExternalStore(i,x,x)}const X7=[new to(-Math.PI/2,-Math.PI/2,-Math.PI/2),new to(0,Math.PI/2,0),new to(0,-Math.PI/2,-Math.PI/2),new to(Math.PI/2,Math.PI,Math.PI),new to(0,0,-Math.PI/2),new to(Math.PI,0,0)],Y7=({diceValues:g,isRolling:t,textures:i})=>{const x=Me.useRef([]),T=Me.useRef([]);return Me.useEffect(()=>{const E=new fA,s=new ze(16766720);T.current=[new yl({map:E.load(i.side1),color:s}),new yl({map:E.load(i.side2),color:s}),new yl({map:E.load(i.side3),color:s}),new yl({map:E.load(i.side4),color:s}),new yl({map:E.load(i.side5),color:s}),new yl({map:E.load(i.side6),color:s})],x.current.forEach(y=>{y&&(y.material=T.current)})},[i]),S7(()=>{x.current.forEach((E,s)=>{if(E)if(t)E.rotation.x+=.2,E.rotation.y+=.2;else{const y=X7[g[s]-1];E.rotation.x=fm.lerp(E.rotation.x,y.x,.1),E.rotation.y=fm.lerp(E.rotation.y,y.y,.1),E.rotation.z=fm.lerp(E.rotation.z,y.z,.1)}})}),Yt.jsx(Yt.Fragment,{children:g.map((E,s)=>Yt.jsxs("mesh",{ref:y=>x.current[s]=y,position:[s*2-(g.length-1),0,0],children:[Yt.jsx("boxGeometry",{args:[1,1,1]}),T.current.length===6&&T.current.map((y,e)=>Yt.jsx("meshStandardMaterial",{attach:`material-${e}`,...y},e))]},s))})},k7=({styleClass:g,textures:t,diceCount:i})=>{const x=io(Ed);Me.useEffect(()=>{XI("Dice"),kI(t),YI({type:"ROLL_DICE",diceValues:Array(i).fill(1),isRolling:!1})},[t,i]);const T=()=>{RT(!0),setTimeout(()=>{const E=Array.from({length:i},()=>Math.floor(Math.random()*6)+1);dw(E),RT(!1);const s={diceValues:E};Si.emit("diceRollResult",s)},2e3)};return Yt.jsxs("div",{className:`flex flex-col items-center justify-center p-4 ${g}`,children:[Yt.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Dice Roller"}),Yt.jsxs(W7,{className:"w-full h-full",camera:{position:[0,0,5]},children:[Yt.jsx("ambientLight",{intensity:2.5}),Yt.jsx("pointLight",{position:[10,10,10]}),vT(x.action)&&Yt.jsx(Y7,{diceValues:x.action.diceValues,isRolling:x.action.isRolling,textures:x.textures})]}),vT(x.action)&&Yt.jsx("button",{onClick:T,className:`mt-4 p-2 border border-yellow-300 rounded text-yellow-400 hover:scale-110 ${x.action.isRolling?"opacity-50":""}`,disabled:x.action.isRolling,children:"Roll Dice"})]})},j7=({text:g,speed:t=80,onComplete:i})=>{const[x,T]=Me.useState([]),E=Me.useRef([]);return Me.useEffect(()=>{let s,y=0;const e=g.split(/(<\/?span[^>]*>)/g).filter(Boolean),r=[];e.forEach((h,a)=>{if(h.startsWith("/);if(l){const n=l[1];r.push(Yt.jsx("span",{className:n},`span-${a}`))}else r.push(Yt.jsx("span",{},`span-${a}`))}else h.split("").forEach((l,n)=>{r.push(Yt.jsx("span",{children:l},`char-${a}-${n}`))})}),y=0;const p=()=>{y{window.clearTimeout(s)}},[g,t,i]),Yt.jsx("div",{children:x})},jA=Ou.memo(j7);class KA{constructor(t,i,x){this.scene=t,this.gridEngine=i,this.quadtree=x,this.cursor=this.scene.input.keyboard?.createCursorKeys(),this.initializeWASDKeys(),this.registerEventHandlers(),this.tooltip=this.scene.add.text(0,0,"Press [F]",{font:"16px Arial",backgroundColor:"#000000"}).setDepth(4).setPadding(3,2,2,3).setVisible(!1)}initializeWASDKeys(){const t=this.scene.input.keyboard;t&&(this.wasdKeys={W:t.addKey(Phaser.Input.Keyboard.KeyCodes.W),A:t.addKey(Phaser.Input.Keyboard.KeyCodes.A),S:t.addKey(Phaser.Input.Keyboard.KeyCodes.S),D:t.addKey(Phaser.Input.Keyboard.KeyCodes.D)})}handleConsume(t){const i=Tl(t);i&&i.consumable?(qe.log(`Consuming item: ${i.name}`),HI(i),PT(i.id)):qe.log(`Item ${t} is not consumable`)}handleEquip(t){const i=Tl(t);i&&(qe.log(`Equipping item: ${i.name}`),OI("weapon",i.id))}handleUnequip(t){const i=Tl(t);i&&(qe.log(`Unequipping item: ${i.name}`),DI("weapon"))}handleDiscard(t){qe.log(`Discarding item: ${t}`),PT(t)}handleView(t){const i=Tl(t);if(i&&(qe.log(`Viewing item: ${i.name} with ${i.slug}`),i.slug)){const x=`https://kbve.com/${i.slug}#${i.name.toLowerCase().replace(/\s+/g,"-").replace(/[^\w-]+/g,"")}`;window.open(x,"_blank")}}registerEventHandlers(){Si.on("itemAction",this.handleItemAction.bind(this));//! Broken Si.on("playerMove",this.handlePlayerMove.bind(this)),Si.on("playerReward",this.handlePlayerReward.bind(this)),Si.on("playerDamage",this.handlePlayerCombatDamage.bind(this))}handleItemAction(t){if(t)switch(qe.log(`Preparing Action: ${t.itemId} with ${t.action}`),t.action){case"consume":this.handleConsume(t.itemId);break;case"equip":this.handleEquip(t.itemId);break;case"unequip":this.handleUnequip(t.itemId);break;case"discard":this.handleDiscard(t.itemId);break;case"view":this.handleView(t.itemId);break;default:qe.log(`Unknown action: ${t.action}`)}}handlePlayerReward(t){qe.log("Rewarding the player"),t&&(Si.emit("notification",{title:"Success",message:t.message,notificationType:Ru.success}),FI(t.item))}handlePlayerCombatDamage(t){t&&(cw(parseInt(t.damage)),Si.emit("notification",{title:"Danger",message:`You taken ${t.damage} points of damage!`,notificationType:Ru.danger}))}handlePlayerMove(t){t&&this.gridEngine.moveTo("player",{x:t.x,y:t.y})}checkForNearbyObjects(){const i=this.gridEngine.getPosition("player"),x=i.x*48,T=i.y*48;this.quadtree.query(i).length>0?this.tooltip.setPosition(x,T-60).setVisible(!0):this.tooltip.setVisible(!1)}handleMovement(){if(!this.cursor)return;const t=this.cursor,i=this.wasdKeys;if(this.scene.input.keyboard?.addKey("F").isDown){const x=this.gridEngine.getPosition("player"),T=this.quadtree.query(x);for(const E of T)E.action()}(t.left.isDown||i.A.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-left"):(t.left.isDown||i.A.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-left"):(t.right.isDown||i.D.isDown)&&(t.up.isDown||i.W.isDown)?this.gridEngine.move("player","up-right"):(t.right.isDown||i.D.isDown)&&(t.down.isDown||i.S.isDown)?this.gridEngine.move("player","down-right"):t.left.isDown||i.A.isDown?this.gridEngine.move("player","left"):t.right.isDown||i.D.isDown?this.gridEngine.move("player","right"):t.up.isDown||i.W.isDown?this.gridEngine.move("player","up"):(t.down.isDown||i.S.isDown)&&this.gridEngine.move("player","down"),this.checkForNearbyObjects()}}class ZA extends Phaser.GameObjects.Container{constructor(t,i,x,T){const E=i.x,s=i.y-i.height+10;super(t,E,s),this.sprite=i;const y=150,e=40+T.length*20;this.background=t.add.rectangle(0,0,y,e,0,.7),this.text=t.add.text(0,-e/2+10,x,{fontSize:"12px",color:"#ffffff"}).setOrigin(.5),this.buttons=T.map((r,p)=>{const h=t.add.text(0,-e/2+30+p*20,r.label,{fontSize:"12px",color:"#00ff00"}).setOrigin(.5);return h.setInteractive({useHandCursor:!0}),h.on("pointerdown",r.callback),h}),this.add(this.background),this.add(this.text),this.buttons.forEach(r=>this.add(r)),this.scene.add.existing(this)}updatePosition(){this.setPosition(this.sprite.x-30,this.sprite.y-this.sprite.height-this.background.height/2+100)}static attachToSprite(t,i,x,T){i.setInteractive(),i.on("pointerover",E=>{const s={npcId:i.name,npcName:x,actions:T.map(e=>e.label),coords:{x:E.x,y:E.y}};if(Si.emit("npcInteraction",s),!i.getData("tooltipMenu")){const e=new ZA(t,i,x,T);i.setData("tooltipMenu",e)}const y=i.getData("tooltipMenu");y.setVisible(!0),y.updatePosition()}),i.on("pointerout",()=>{const E=i.getData("tooltipMenu");E&&E.setVisible(!1)})}static updateAllTooltipPositions(t){t.children.list.forEach(i=>{if(i instanceof Phaser.GameObjects.Sprite){const x=i.getData("tooltipMenu");x&&x.updatePosition()}})}}let FG=class extends Phaser.GameObjects.Sprite{};function K7(g,t,i,x){const y=g.add.graphics();y.fillStyle(16777215,1),y.fillRoundedRect(0,0,200,60,16),y.setDepth(99);const e=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});e.setOrigin(.5),e.setWordWrapWidth(200-10*2),e.setDepth(100);const r=g.add.container(0,0,[y,e]);return r.setDepth(100),t.messageBubble=r,J7(t),g.time.addEvent({delay:x,callback:()=>{r.destroy(),t.messageBubble===r&&(t.messageBubble=void 0)},callbackScope:g}),r}function Z7(g,t,i){const s=g.add.graphics();s.fillStyle(16777215,1),s.fillRoundedRect(0,0,200,60,16),s.setDepth(99);const y=g.add.text(100,30,i,{fontFamily:"Arial",fontSize:16,color:"#000000"});y.setOrigin(.5),y.setWordWrapWidth(200-10*2),y.setDepth(100);const e=g.add.container(0,0,[s,y]);return e.setDepth(100),t.textBubble=e,Ox(t),e}function Ox(g){const t=g.textBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}function J7(g){const t=g.messageBubble;t&&(t.x=g.x,t.y=g.y-g.height-t.height/2)}var JA={exports:{}};(function(g,t){(function(i,x){g.exports=x()})(Ty,function(){var i=function(V,K){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(et,st){et.__proto__=st}||function(et,st){for(var ht in st)Object.prototype.hasOwnProperty.call(st,ht)&&(et[ht]=st[ht])})(V,K)},x=function(){return(x=Object.assign||function(V){for(var K,et=1,st=arguments.length;et"u"||E.Promise||(E.Promise=Promise);var r=Object.getPrototypeOf,p={}.hasOwnProperty;function h(V,K){return p.call(V,K)}function a(V,K){typeof K=="function"&&(K=K(r(V))),(typeof Reflect>"u"?s:Reflect.ownKeys)(K).forEach(function(et){n(V,et,K[et])})}var l=Object.defineProperty;function n(V,K,et,st){l(V,K,e(et&&h(et,"get")&&typeof et.get=="function"?{get:et.get,set:et.set,configurable:!0}:{value:et,configurable:!0,writable:!0},st))}function u(V){return{from:function(K){return V.prototype=Object.create(K.prototype),n(V.prototype,"constructor",V),{extend:a.bind(null,V.prototype)}}}}var f=Object.getOwnPropertyDescriptor,o=[].slice;function c(V,K,et){return o.call(V,K,et)}function d(V,K){return K(V)}function v(V){if(!V)throw new Error("Assertion Failed")}function m(V){E.setImmediate?setImmediate(V):setTimeout(V,0)}function S(V,K){if(typeof K=="string"&&h(V,K))return V[K];if(!K)return V;if(typeof K!="string"){for(var et=[],st=0,ht=K.length;st"u"?[]:function(){var V=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[V,r(V),V];var K=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[K,r(K),V]}(),re=Vs[0],hr=Vs[1],Vs=Vs[2],hr=hr&&hr.then,le=re&&re.constructor,ge=!!Vs,xe=function(V,K){je.push([V,K]),te&&(queueMicrotask(Gi),te=!1)},Pe=!0,te=!0,Ge=[],Oe=[],Be=gt,Le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:rt,pgp:!1,env:{},finalize:rt},ne=Le,je=[],si=0,Mi=[];function he(V){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var K=this._PSD=ne;if(typeof V!="function"){if(V!==Ht)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Ce(this,this._value))}this._state=null,this._value=null,++K.ref,function et(st,ht){try{ht(function(pt){if(st._state===null){if(pt===st)throw new TypeError("A promise cannot be resolved with itself.");var Mt=st._lib&&Ii();pt&&typeof pt.then=="function"?et(st,function(Nt,zt){pt instanceof he?pt._then(Nt,zt):pt.then(Nt,zt)}):(st._state=!0,st._value=pt,we(st)),Mt&&nn()}},Ce.bind(null,st))}catch(pt){Ce(st,pt)}}(this,V)}var Ti={get:function(){var V=ne,K=_r;function et(st,ht){var pt=this,Mt=!V.global&&(V!==ne||K!==_r),Nt=Mt&&!Ss(),zt=new he(function(ct,St){Ve(pt,new bt(ie(st,V,Mt,Nt),ie(ht,V,Mt,Nt),ct,St,V))});return this._consoleTask&&(zt._consoleTask=this._consoleTask),zt}return et.prototype=Ht,et},set:function(V){n(this,"then",V&&V.prototype===Ht?Ti:{get:function(){return V},set:Ti.set})}};function bt(V,K,et,st,ht){this.onFulfilled=typeof V=="function"?V:null,this.onRejected=typeof K=="function"?K:null,this.resolve=et,this.reject=st,this.psd=ht}function Ce(V,K){var et,st;Oe.push(K),V._state===null&&(et=V._lib&&Ii(),K=Be(K),V._state=!1,V._value=K,st=V,Ge.some(function(ht){return ht._value===st._value})||Ge.push(st),we(V),et&&nn())}function we(V){var K=V._listeners;V._listeners=[];for(var et=0,st=K.length;et.",$e="String expected.",ti=[],ni="__dbnames",oi="readonly",$i="readwrite";function un(V,K){return V?K?function(){return V.apply(this,arguments)&&K.apply(this,arguments)}:V:K}var ji={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function yn(V){return typeof V!="string"||/\./.test(V)?function(K){return K}:function(K){return K[V]===void 0&&V in K&&delete(K=O(K))[V],K}}function ei(){throw q.Type()}function Se(V,K){try{var et=Br(V),st=Br(K);if(et!==st)return et==="Array"?1:st==="Array"?-1:et==="binary"?1:st==="binary"?-1:et==="string"?1:st==="string"?-1:et==="Date"?1:st!=="Date"?NaN:-1;switch(et){case"number":case"Date":case"string":return KQt+ae&&Kt(Qt+Ft)})})}var Jt=Ki(et)&&et.limit===1/0&&(typeof V!="function"||V===Fa)&&{index:et.index,range:et.range};return Kt(0).then(function(){if(0=Ft})).length!==0?(St.forEach(function(Kt){Wt.push(function(){var Jt=It,Qt=Kt._cfg.dbschema;Na(vt,Jt,Ut),Na(vt,Qt,Ut),It=vt._dbSchema=Qt;var ae=bn(Jt,Qt);ae.add.forEach(function(me){Oa(Ut,me[0],me[1].primKey,me[1].indexes)}),ae.change.forEach(function(me){if(me.recreate)throw new q.Upgrade("Not yet support for changing primary key");var be=Ut.objectStore(me.name);me.add.forEach(function(_e){return Mn(be,_e)}),me.change.forEach(function(_e){be.deleteIndex(_e.name),Mn(be,_e)}),me.del.forEach(function(_e){return be.deleteIndex(_e)})});var ue=Kt._cfg.contentUpgrade;if(ue&&Kt._cfg.version>Ft){Ko(vt,Ut),Lt._memoizedTables={};var Re=w(Qt);ae.del.forEach(function(me){Re[me]=Jt[me]}),Gr(vt,[vt.Transaction.prototype]),Dl(vt,[vt.Transaction.prototype],s(Re),Re),Lt.schema=Re;var pe,Ae=Q(ue);return Ae&&zs(),ae=he.follow(function(){var me;(pe=ue(Lt))&&Ae&&(me=Ss.bind(null,null),pe.then(me,me))}),pe&&typeof pe.then=="function"?he.resolve(pe):ae.then(function(){return pe})}}),Wt.push(function(Jt){var Qt,ae,ue=Kt._cfg.dbschema;Qt=ue,ae=Jt,[].slice.call(ae.db.objectStoreNames).forEach(function(Re){return Qt[Re]==null&&ae.db.deleteObjectStore(Re)}),Gr(vt,[vt.Transaction.prototype]),Dl(vt,[vt.Transaction.prototype],vt._storeNames,vt._dbSchema),Lt.schema=vt._dbSchema}),Wt.push(function(Jt){vt.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(vt.idbdb.version/10)===Kt._cfg.version?(vt.idbdb.deleteObjectStore("$meta"),delete vt._dbSchema.$meta,vt._storeNames=vt._storeNames.filter(function(Qt){return Qt!=="$meta"})):Jt.objectStore("$meta").put(Kt._cfg.version,"version"))})}),function Kt(){return Wt.length?he.resolve(Wt.shift()(Lt.idbtrans)).then(Kt):he.resolve()}().then(function(){Da(It,Ut)})):he.resolve();var vt,Ft,Lt,Ut,Wt,It}).catch(Mt)):(s(ht).forEach(function(St){Oa(et,St,ht[St].primKey,ht[St].indexes)}),Ko(V,et),void he.follow(function(){return V.on.populate.fire(pt)}).catch(Mt));var zt,ct})}function Ph(V,K){Da(V._dbSchema,K),K.db.version%10!=0||K.objectStoreNames.contains("$meta")||K.db.createObjectStore("$meta").add(Math.ceil(K.db.version/10-1),"version");var et=Ia(0,V.idbdb,K);Na(V,V._dbSchema,K);for(var st=0,ht=bn(et,V._dbSchema).change;stMath.pow(2,62)?0:It.oldVersion,vt=It<1,V.idbdb=Wt.result,pt&&Ph(V,St),xn(V,It/10,St,Lt))},Lt),Wt.onsuccess=pi(function(){St=null;var It,Kt,Jt,Qt,ae,ue=V.idbdb=Wt.result,Re=c(ue.objectStoreNames);if(0"u"?he.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(Ft){function Lt(){return indexedDB.databases().finally(Ft)}zt=setInterval(Lt,100),Lt()}).finally(function(){return clearInterval(zt)}):Promise.resolve()).then(Nt)]).then(function(){return Mt(),K.onReadyBeingFired=[],he.resolve(Xr(function(){return V.on.ready.fire(V.vip)})).then(function Ft(){if(0K.limit?Ft.length=K.limit:V.length===K.limit&&Ft.length=Kt.limit&&(!Kt.values||ue.req.values)&&mo(ue.req.query.range,Kt.query.range)}),!1,Jt,Qt];case"count":return ae=Qt.find(function(ue){return qi(ue.req.query.range,Kt.query.range)}),[ae,!!ae,Jt,Qt]}}(K,et,"query",pt),St=ct[0],vt=ct[1],Ft=ct[2],Lt=ct[3];return St&&vt?St.obsSet=pt.obsSet:(vt=st.query(pt).then(function(Ut){var Wt=Ut.result;if(St&&(St.res=Wt),Mt){for(var It=0,Kt=Wt.length;It{qe.log(`Texture ${s} loaded successfully.`),this.addNPCToScene(t,E,x,T)}),t.load.start()}else throw new Error(`Sprite with ID ${E.spriteImageId} not found`)}}catch(E){E instanceof Error?qe.error(`Failed to load NPC: ${E.message}`):qe.error("Failed to load NPC:",E)}}addNPCToScene(t,i,x,T){try{qe.log(`Adding NPC to scene: ${JSON.stringify(i)}`),qe.log(`Using sprite key: ${i.spriteKey}`);const E=t.add.sprite(0,0,i.spriteKey);E.scale=i.scale||1.5,E.name=i.id||"Error Missing Name",qe.log(`NPC Sprite created with texture key ${i.spriteKey} at position (${i.startPosition.x}, ${i.startPosition.y})`);const s={id:i.id,sprite:E,walkingAnimationMapping:i.walkingAnimationMapping,startPosition:{x:x??i.startPosition.x,y:T??i.startPosition.y},speed:i.speed};if(qe.log(`Grid engine config: ${JSON.stringify(s)}`),!t.textures.exists(i.spriteKey))throw new Error(`Texture with key ${i.spriteKey} does not exist in the scene`);t.gridEngine.addCharacter(s),qe.log(`NPC added to grid engine with ID ${i.id}`),((e,r,p)=>{const h=t.gridEngine.getPosition(e.name);qe.log(`Attaching NPC events to ${r} at position: ${JSON.stringify(h)}`),$A.attachNPCEvent(e,r,p,{coords:h})})(E,i.name,i.actions.map(e=>({label:e}))),qe.log(`NPC ${i.name} added to scene successfully`)}catch(E){E instanceof Error?qe.error(`Error adding NPC to scene from addNPCToScene: ${E.message}`):qe.error("Error adding NPC to scene:",E)}}async addDialogue(t){await this.dialogues.put(t)}async getDialogue(t){return await this.dialogues.get(t)}async getAllDialogues(){return await this.dialogues.toArray()}async getDialoguesForNPC(t){const i=await this.getNPC(t);if(!i)throw new Error(`NPC with ID ${t} not found`);return(await Promise.all((i.dialogues||[]).map(T=>this.getDialogue(T.dialogueId)))).filter(T=>T!==void 0)}async markDialogueAsRead(t,i){const x=await this.getNPC(t);if(!x)throw new Error(`NPC with ID ${t} not found`);const T=x.dialogues?.find(E=>E.dialogueId===i);T&&(T.read=!0,await this.addNPC(x))}async fetchDialogues(t){try{const x=(await gn.get(t)).data.key,T=Object.values(x).map(E=>({...E}));await this.dialogues.bulkPut(T)}catch(i){qe.error(`Failed to fetch dialogues from ${t}:`,i)}}async getPrioritizedDialoguesForNPC(t){try{const i=await this.getNPC(t);if(!i)throw new Error(`NPC with ID ${t} not found`);const T=(await Promise.all((i.dialogues||[]).map(async E=>{const s=await this.getDialogue(E.dialogueId);return s?{...s,priority:E.priority,read:E.read}:null}))).filter(E=>E!==null);return T.sort((E,s)=>s.priority-E.priority),T}catch(i){return qe.error(`Failed to get prioritized dialogues for NPC with ID ${t}:`,i),[]}}async getNPCNameById(t){return(await this.getNPC(t))?.name}async getNPCAvatarById(t){const i=await this.getNPC(t);if(i?.avatarImageId)return(await this.getAvatar(i.avatarImageId))?.avatarData}async getNPCSlugById(t){return(await this.getNPC(t))?.slug}async getNPCHealthById(t){try{return(await this.getNPC(t))?.stats?.health}catch(i){qe.error(`Failed to get health for NPC with ID ${t}:`,i);return}}async getNPCManaById(t){try{return(await this.getNPC(t))?.stats?.mana}catch(i){qe.error(`Failed to get mana for NPC with ID ${t}:`,i);return}}async createNPCSession(t,i){try{const x=this.getNPCNameById(i),T=this.getNPCSlugById(i),E=this.getNPCAvatarById(i),s=this.getNPCHealthById(i),y=this.getNPCManaById(i),[e,r,p,h,a]=await Promise.all([x,T,E,s,y]),l={...t.get(),[`${i}_name`]:e||"Unknown",[`${i}_slug`]:r||"Unknown",[`${i}_avatar`]:p?URL.createObjectURL(p):"Unknown",[`${i}_health`]:h||"100",[`${i}_mana`]:a||"100"};t.set(l)}catch{const T={...t.get(),[`${i}_name`]:"Unknown",[`${i}_slug`]:"Unknown",[`${i}_avatar`]:"Unknown",[`${i}_hp`]:"100",[`${i}_mana`]:"100"};t.set(T)}}}const Zf=new Q7;class _7{constructor(){this.actionHandlers={talk:this.talkToNPC.bind(this),quest:this.questWithNPC.bind(this),trade:this.tradeWithNPC.bind(this),combat:this.startCombat.bind(this),heal:this.healNPC.bind(this),steal:this.stealFromNPC.bind(this),lore:this.loreFromNPC.bind(this)}}getActionHandler(t){return this.actionHandlers[t]}loreFromNPC(t){qe.log(`Pulling up the lore of the NPC with ID: ${t.npcId}`)}questWithNPC(t){qe.log(`Starting quest with NPC with ID: ${t.npcId}`)}healNPC(t){qe.log(`Healing NPC with ID: ${t.npcId}`)}async talkToNPC(t){try{qe.log(`Talking to NPC with ID: ${t.npcId}`);const i=await Zf.getPrioritizedDialoguesForNPC(t.npcId);if(qe.log(i),i.length>0){const x=i[0];Si.emit("npcDialogue",{npcId:t.npcId,dialogue:x},1e3)}else qe.log("No dialogues available for this NPC.")}catch(i){qe.error(`Failed to fetch dialogues for NPC with ID ${t.npcId}:`,i)}}tradeWithNPC(t){qe.log(`Trading with NPC with ID: ${t.npcId}`)}moveToNPC(t){const x=t.data?.coords||{x:10,y:15};Si.emit("playerMove",x)}stealFromNPC(t){qe.log(`Attempting to steal from NPC with ID: ${t.npcId}`);const i={npcId:t.npcId,npcName:t.npcName,data:t.data};Si.emit("playerSteal",i)}startCombat(t){qe.log(`Starting combat with NPC with ID: ${t.npcId}`)}checkFish(t){qe.log(`Checking fish for NPC with ID: ${t.npcId}`)}attachNPCEvent(t,i,x,T){t.setInteractive(),t.on("pointerover",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};Si.emit("npcInteraction",s)}),t.on("pointerout",()=>{}),t.on("pointerdown",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};qe.log(`Click Registered at X: ${s.coords.x} Y: ${s.coords.y}`),Si.emit("npcInteractionClick",s,1e3)})}}const $A=new _7;function QA(g){return+g[g.length-1]}function _A(g){return g.startsWith("monster_bird_")&&!g.startsWith("monster_bird_shadow")}function qA(g,t,i,x,T){const E=[];for(let s=0;s<10;s++){const y=g.add.sprite(0,0,"monster_bird");y.setCrop(t,i,x,T),y.scale=3,E.push(y)}return E}function tP(g){return qA(g,0,0,61,47)}function eP(g){return qA(g,22,47,16,10)}function iP(g){g.anims.create({key:"bird",frames:g.anims.generateFrameNumbers("monster_bird",{start:0,end:2}),frameRate:10,repeat:-1,yoyo:!0})}class q7 extends Qm.Scene{mainMenuButtonImage;mainMenuButtonText;constructor(){super("Preloader")}preload(){this.load.image("mainBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.image("scroll","https://kbve.com/assets/img/fishchip/scroll.webp"),this.load.audio("music","https://kbve.com/assets/img/fishchip/bg.ogg"),this.load.image("creditsBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.audio("type","https://kbve.com/assets/img/fishchip/type.mp3"),this.load.spritesheet("fishing","https://kbve.com/assets/img/fishchip/animate.png",{frameWidth:800,frameHeight:600}),this.load.image("fish","https://kbve.com/assets/img/letter_logo.png"),this.load.image("background","https://kbve.com/assets/img/fishchip/scaled_fish_menu_minigame.webp"),this.load.image("tiles","https://kbve.com/assets/img/fishchip/desert_tileset_1.png"),this.load.image("cloud-city-tiles","/assets/map/cloud_tileset.png"),this.load.tilemapTiledJSON("cloud-city-map-large","/assets/map/cloud_city_large.json"),this.load.tilemapTiledJSON("cloud-city-map","https://kbve.com/assets/img/fishchip/cloud_city.json"),this.load.spritesheet("player","https://kbve.com/assets/img/fishchip/chip_charactersheet_warmer.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("knights","/assets/entity/knights.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("jacko","/assets/entity/jacko.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("monks","/assets/entity/monks.png",{frameWidth:52,frameHeight:72}),RI()}async create(){await Zf.initializeDatabase(),this.sound.get("music")?.isPlaying||this.sound.add("music",{loop:!0,volume:.1}).play(),this.add.image(480,480,"mainBg").setScale(.1),this.mainMenuButtonImage=this.add.image(480,480,"scroll").setAlpha(.9).setScale(.7,.2).setInteractive({useHandCursor:!0}),this.mainMenuButtonText=this.add.text(480,480,"Start Game",{fontFamily:"Arial Black",fontSize:50,color:"#ffffff",stroke:"#000000",strokeThickness:6}).setOrigin(.5).setInteractive({useHandCursor:!0}),this.mainMenuButtonText.on("pointerdown",()=>{this.scene.start("SandCity")},this)}}let DG=class extends Uf.GameObjects.Sprite{textBubble;tooltip};class tG extends Qm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"SandCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new vu(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57}),Si.emit("notification",{title:"Success",message:`You arrived safely to SandCity Passport: ${o1()}`,notificationType:Ru.success})}async create(){const t=this.make.tilemap({key:"cloud-city-map"});t.addTilesetImage("Cloud City","tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new KA(this,this.gridEngine,this.quadtree),K7(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!",3e3),await Zf.loadCharacter(this,"01J2DT4G871KJ0VNSHCNC5REDM",6,6),await Zf.loadCharacter(this,"01J2HCTMQ58JBMJGW9YA3FBQCG",8,8),await Zf.loadCharacter(this,"01J2HQJBMBGEEMWDBDWATRCY3T",8,15),this.gridEngine.moveRandomly("npc",1500,3),this.gridEngine.moveRandomly("fishNpc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,10);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{_A(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+QA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Si.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:()=>{const i={message:"Sign does not have much to say.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",i)}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Si.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Si.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement()}}class NG extends Uf.GameObjects.Sprite{textBubble}class eG extends Qm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"CloudCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new vu(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57})}create(){const t=this.make.tilemap({key:"cloud-city-map-large"});t.addTilesetImage("cloud_tileset","cloud-city-tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new KA(this,this.gridEngine,this.quadtree),Z7(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!"),this.gridEngine.moveRandomly("npc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,20);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{_A(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+QA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Si.emit("charEvent",i,1e3)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:async()=>{try{const T={message:`The Database Response time: ${(await(await fetch("https://api.cryptothrone.com/api/v1/speed")).json()).message.time_ms} ms`,character_name:"Planets Be Scalin",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",T,1e3)}catch(i){console.error("Error fetching data:",i);const x={message:"Sign does not have much to say. Failed to fetch response time.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",x,1e3)}}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Si.emit("charEvent",i,1e3)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Si.emit("charEvent",i,1e3)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement(),this.npcSprite&&this.npcSprite.textBubble&&Ox(this.npcSprite),this.fishNpcSprite&&this.fishNpcSprite.textBubble&&Ox(this.fishNpcSprite)}}const iG=mm.div` + `+pt:""),this.inner=pt||null):typeof ht=="object"&&(this.message="".concat(ht.name," ").concat(ht.message),this.inner=ht):(this.message=tt[K]||et,this.inner=null)}return u(st).from(_),V[K]=st,V},{});q.Syntax=SyntaxError,q.Type=TypeError,q.Range=RangeError;var at=re.reduce(function(V,K){return V[K+"Error"]=q[K],V},{}),ot=hr.reduce(function(V,K){return["Syntax","Type","Range"].indexOf(K)===-1&&(V[K+"Error"]=q[K]),V},{});function rt(){}function gt(V){return V}function yt(V,K){return V==null||V===gt?K:function(et){return K(V(et))}}function Et(V,K){return function(){V.apply(this,arguments),K.apply(this,arguments)}}function At(V,K){return V===rt?K:function(){var et=V.apply(this,arguments);et!==void 0&&(arguments[0]=et);var st=this.onsuccess,ht=this.onerror;this.onsuccess=null,this.onerror=null;var pt=K.apply(this,arguments);return st&&(this.onsuccess=this.onsuccess?Et(st,this.onsuccess):st),ht&&(this.onerror=this.onerror?Et(ht,this.onerror):ht),pt!==void 0?pt:et}}function Pt(V,K){return V===rt?K:function(){V.apply(this,arguments);var et=this.onsuccess,st=this.onerror;this.onsuccess=this.onerror=null,K.apply(this,arguments),et&&(this.onsuccess=this.onsuccess?Et(et,this.onsuccess):et),st&&(this.onerror=this.onerror?Et(st,this.onerror):st)}}function Vt(V,K){return V===rt?K:function(et){var st=V.apply(this,arguments);e(et,st);var ht=this.onsuccess,pt=this.onerror;return this.onsuccess=null,this.onerror=null,et=K.apply(this,arguments),ht&&(this.onsuccess=this.onsuccess?Et(ht,this.onsuccess):ht),pt&&(this.onerror=this.onerror?Et(pt,this.onerror):pt),st===void 0?et===void 0?void 0:et:e(st,et)}}function dt(V,K){return V===rt?K:function(){return K.apply(this,arguments)!==!1&&V.apply(this,arguments)}}function ut(V,K){return V===rt?K:function(){var et=V.apply(this,arguments);if(et&&typeof et.then=="function"){for(var st=this,ht=arguments.length,pt=new Array(ht);ht--;)pt[ht]=arguments[ht];return et.then(function(){return K.apply(st,pt)})}return K.apply(this,arguments)}}ot.ModifyError=U,ot.DexieError=Y,ot.BulkError=H;var Rt=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Dt(V){Rt=V}var Ht={},Bt=100,Vs=typeof Promise>"u"?[]:function(){var V=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[V,r(V),V];var K=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[K,r(K),V]}(),re=Vs[0],hr=Vs[1],Vs=Vs[2],hr=hr&&hr.then,le=re&&re.constructor,ge=!!Vs,xe=function(V,K){je.push([V,K]),te&&(queueMicrotask(Gi),te=!1)},Pe=!0,te=!0,Ge=[],Oe=[],Be=gt,Le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:rt,pgp:!1,env:{},finalize:rt},ne=Le,je=[],si=0,Mi=[];function he(V){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var K=this._PSD=ne;if(typeof V!="function"){if(V!==Ht)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Ce(this,this._value))}this._state=null,this._value=null,++K.ref,function et(st,ht){try{ht(function(pt){if(st._state===null){if(pt===st)throw new TypeError("A promise cannot be resolved with itself.");var Mt=st._lib&&Ii();pt&&typeof pt.then=="function"?et(st,function(Nt,zt){pt instanceof he?pt._then(Nt,zt):pt.then(Nt,zt)}):(st._state=!0,st._value=pt,we(st)),Mt&&nn()}},Ce.bind(null,st))}catch(pt){Ce(st,pt)}}(this,V)}var Ti={get:function(){var V=ne,K=_r;function et(st,ht){var pt=this,Mt=!V.global&&(V!==ne||K!==_r),Nt=Mt&&!Ss(),zt=new he(function(ct,St){Ve(pt,new bt(ie(st,V,Mt,Nt),ie(ht,V,Mt,Nt),ct,St,V))});return this._consoleTask&&(zt._consoleTask=this._consoleTask),zt}return et.prototype=Ht,et},set:function(V){n(this,"then",V&&V.prototype===Ht?Ti:{get:function(){return V},set:Ti.set})}};function bt(V,K,et,st,ht){this.onFulfilled=typeof V=="function"?V:null,this.onRejected=typeof K=="function"?K:null,this.resolve=et,this.reject=st,this.psd=ht}function Ce(V,K){var et,st;Oe.push(K),V._state===null&&(et=V._lib&&Ii(),K=Be(K),V._state=!1,V._value=K,st=V,Ge.some(function(ht){return ht._value===st._value})||Ge.push(st),we(V),et&&nn())}function we(V){var K=V._listeners;V._listeners=[];for(var et=0,st=K.length;et.",$e="String expected.",ti=[],ni="__dbnames",oi="readonly",$i="readwrite";function un(V,K){return V?K?function(){return V.apply(this,arguments)&&K.apply(this,arguments)}:V:K}var ji={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function yn(V){return typeof V!="string"||/\./.test(V)?function(K){return K}:function(K){return K[V]===void 0&&V in K&&delete(K=O(K))[V],K}}function ei(){throw q.Type()}function Se(V,K){try{var et=Br(V),st=Br(K);if(et!==st)return et==="Array"?1:st==="Array"?-1:et==="binary"?1:st==="binary"?-1:et==="string"?1:st==="string"?-1:et==="Date"?1:st!=="Date"?NaN:-1;switch(et){case"number":case"Date":case"string":return KQt+ae&&Kt(Qt+Ft)})})}var Jt=Ki(et)&&et.limit===1/0&&(typeof V!="function"||V===Fa)&&{index:et.index,range:et.range};return Kt(0).then(function(){if(0=Ft})).length!==0?(St.forEach(function(Kt){Wt.push(function(){var Jt=It,Qt=Kt._cfg.dbschema;Na(vt,Jt,Ut),Na(vt,Qt,Ut),It=vt._dbSchema=Qt;var ae=bn(Jt,Qt);ae.add.forEach(function(me){Oa(Ut,me[0],me[1].primKey,me[1].indexes)}),ae.change.forEach(function(me){if(me.recreate)throw new q.Upgrade("Not yet support for changing primary key");var be=Ut.objectStore(me.name);me.add.forEach(function(_e){return Mn(be,_e)}),me.change.forEach(function(_e){be.deleteIndex(_e.name),Mn(be,_e)}),me.del.forEach(function(_e){return be.deleteIndex(_e)})});var ue=Kt._cfg.contentUpgrade;if(ue&&Kt._cfg.version>Ft){Ko(vt,Ut),Lt._memoizedTables={};var Re=w(Qt);ae.del.forEach(function(me){Re[me]=Jt[me]}),Gr(vt,[vt.Transaction.prototype]),Dl(vt,[vt.Transaction.prototype],s(Re),Re),Lt.schema=Re;var pe,Ae=Q(ue);return Ae&&zs(),ae=he.follow(function(){var me;(pe=ue(Lt))&&Ae&&(me=Ss.bind(null,null),pe.then(me,me))}),pe&&typeof pe.then=="function"?he.resolve(pe):ae.then(function(){return pe})}}),Wt.push(function(Jt){var Qt,ae,ue=Kt._cfg.dbschema;Qt=ue,ae=Jt,[].slice.call(ae.db.objectStoreNames).forEach(function(Re){return Qt[Re]==null&&ae.db.deleteObjectStore(Re)}),Gr(vt,[vt.Transaction.prototype]),Dl(vt,[vt.Transaction.prototype],vt._storeNames,vt._dbSchema),Lt.schema=vt._dbSchema}),Wt.push(function(Jt){vt.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(vt.idbdb.version/10)===Kt._cfg.version?(vt.idbdb.deleteObjectStore("$meta"),delete vt._dbSchema.$meta,vt._storeNames=vt._storeNames.filter(function(Qt){return Qt!=="$meta"})):Jt.objectStore("$meta").put(Kt._cfg.version,"version"))})}),function Kt(){return Wt.length?he.resolve(Wt.shift()(Lt.idbtrans)).then(Kt):he.resolve()}().then(function(){Da(It,Ut)})):he.resolve();var vt,Ft,Lt,Ut,Wt,It}).catch(Mt)):(s(ht).forEach(function(St){Oa(et,St,ht[St].primKey,ht[St].indexes)}),Ko(V,et),void he.follow(function(){return V.on.populate.fire(pt)}).catch(Mt));var zt,ct})}function Ph(V,K){Da(V._dbSchema,K),K.db.version%10!=0||K.objectStoreNames.contains("$meta")||K.db.createObjectStore("$meta").add(Math.ceil(K.db.version/10-1),"version");var et=Ia(0,V.idbdb,K);Na(V,V._dbSchema,K);for(var st=0,ht=bn(et,V._dbSchema).change;stMath.pow(2,62)?0:It.oldVersion,vt=It<1,V.idbdb=Wt.result,pt&&Ph(V,St),xn(V,It/10,St,Lt))},Lt),Wt.onsuccess=pi(function(){St=null;var It,Kt,Jt,Qt,ae,ue=V.idbdb=Wt.result,Re=c(ue.objectStoreNames);if(0"u"?he.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(Ft){function Lt(){return indexedDB.databases().finally(Ft)}zt=setInterval(Lt,100),Lt()}).finally(function(){return clearInterval(zt)}):Promise.resolve()).then(Nt)]).then(function(){return Mt(),K.onReadyBeingFired=[],he.resolve(Xr(function(){return V.on.ready.fire(V.vip)})).then(function Ft(){if(0K.limit?Ft.length=K.limit:V.length===K.limit&&Ft.length=Kt.limit&&(!Kt.values||ue.req.values)&&mo(ue.req.query.range,Kt.query.range)}),!1,Jt,Qt];case"count":return ae=Qt.find(function(ue){return qi(ue.req.query.range,Kt.query.range)}),[ae,!!ae,Jt,Qt]}}(K,et,"query",pt),St=ct[0],vt=ct[1],Ft=ct[2],Lt=ct[3];return St&&vt?St.obsSet=pt.obsSet:(vt=st.query(pt).then(function(Ut){var Wt=Ut.result;if(St&&(St.res=Wt),Mt){for(var It=0,Kt=Wt.length;It{qe.log(`Texture ${s} loaded successfully.`),this.addNPCToScene(t,E,x,T)}),t.load.start()}else throw new Error(`Sprite with ID ${E.spriteImageId} not found`)}}catch(E){E instanceof Error?qe.error(`Failed to load NPC: ${E.message}`):qe.error("Failed to load NPC:",E)}}addNPCToScene(t,i,x,T){try{qe.log(`Adding NPC to scene: ${JSON.stringify(i)}`),qe.log(`Using sprite key: ${i.spriteKey}`);const E=t.add.sprite(0,0,i.spriteKey);E.scale=i.scale||1.5,E.name=i.id||"Error Missing Name",qe.log(`NPC Sprite created with texture key ${i.spriteKey} at position (${i.startPosition.x}, ${i.startPosition.y})`);const s={id:i.id,sprite:E,walkingAnimationMapping:i.walkingAnimationMapping,startPosition:{x:x??i.startPosition.x,y:T??i.startPosition.y},speed:i.speed};if(qe.log(`Grid engine config: ${JSON.stringify(s)}`),!t.textures.exists(i.spriteKey))throw new Error(`Texture with key ${i.spriteKey} does not exist in the scene`);t.gridEngine.addCharacter(s),qe.log(`NPC added to grid engine with ID ${i.id}`),((e,r,p)=>{const h=t.gridEngine.getPosition(e.name);qe.log(`Attaching NPC events to ${r} at position: ${JSON.stringify(h)}`),$A.attachNPCEvent(e,r,p,{coords:h})})(E,i.name,i.actions.map(e=>({label:e}))),qe.log(`NPC ${i.name} added to scene successfully`)}catch(E){E instanceof Error?qe.error(`Error adding NPC to scene from addNPCToScene: ${E.message}`):qe.error("Error adding NPC to scene:",E)}}async addDialogue(t){await this.dialogues.put(t)}async getDialogue(t){return await this.dialogues.get(t)}async getAllDialogues(){return await this.dialogues.toArray()}async getDialoguesForNPC(t){const i=await this.getNPC(t);if(!i)throw new Error(`NPC with ID ${t} not found`);return(await Promise.all((i.dialogues||[]).map(T=>this.getDialogue(T.dialogueId)))).filter(T=>T!==void 0)}async markDialogueAsRead(t,i){const x=await this.getNPC(t);if(!x)throw new Error(`NPC with ID ${t} not found`);const T=x.dialogues?.find(E=>E.dialogueId===i);T&&(T.read=!0,await this.addNPC(x))}async fetchDialogues(t){try{const x=(await gn.get(t)).data.key,T=Object.values(x).map(E=>({...E}));await this.dialogues.bulkPut(T)}catch(i){qe.error(`Failed to fetch dialogues from ${t}:`,i)}}async getPrioritizedDialoguesForNPC(t){try{const i=await this.getNPC(t);if(!i)throw new Error(`NPC with ID ${t} not found`);const T=(await Promise.all((i.dialogues||[]).map(async E=>{const s=await this.getDialogue(E.dialogueId);return s?{...s,priority:E.priority,read:E.read}:null}))).filter(E=>E!==null);return T.sort((E,s)=>s.priority-E.priority),T}catch(i){return qe.error(`Failed to get prioritized dialogues for NPC with ID ${t}:`,i),[]}}async getNPCNameById(t){return(await this.getNPC(t))?.name}async getNPCAvatarById(t){const i=await this.getNPC(t);if(i?.avatarImageId)return(await this.getAvatar(i.avatarImageId))?.avatarData}async getNPCSlugById(t){return(await this.getNPC(t))?.slug}async getNPCHealthById(t){try{return(await this.getNPC(t))?.stats?.health}catch(i){qe.error(`Failed to get health for NPC with ID ${t}:`,i);return}}async getNPCManaById(t){try{return(await this.getNPC(t))?.stats?.mana}catch(i){qe.error(`Failed to get mana for NPC with ID ${t}:`,i);return}}async createNPCSession(t,i){try{const x=this.getNPCNameById(i),T=this.getNPCSlugById(i),E=this.getNPCAvatarById(i),s=this.getNPCHealthById(i),y=this.getNPCManaById(i),[e,r,p,h,a]=await Promise.all([x,T,E,s,y]),l={...t.get(),[`${i}_name`]:e||"Unknown",[`${i}_slug`]:r||"Unknown",[`${i}_avatar`]:p?URL.createObjectURL(p):"Unknown",[`${i}_health`]:h||"100",[`${i}_mana`]:a||"100"};t.set(l)}catch{const T={...t.get(),[`${i}_name`]:"Unknown",[`${i}_slug`]:"Unknown",[`${i}_avatar`]:"Unknown",[`${i}_hp`]:"100",[`${i}_mana`]:"100"};t.set(T)}}}const Zf=new Q7;class _7{constructor(){this.actionHandlers={talk:this.talkToNPC.bind(this),quest:this.questWithNPC.bind(this),trade:this.tradeWithNPC.bind(this),combat:this.startCombat.bind(this),heal:this.healNPC.bind(this),steal:this.stealFromNPC.bind(this),lore:this.loreFromNPC.bind(this)}}getActionHandler(t){return this.actionHandlers[t]}loreFromNPC(t){qe.log(`Pulling up the lore of the NPC with ID: ${t.npcId}`)}questWithNPC(t){qe.log(`Starting quest with NPC with ID: ${t.npcId}`)}healNPC(t){qe.log(`Healing NPC with ID: ${t.npcId}`)}async talkToNPC(t){try{qe.log(`Talking to NPC with ID: ${t.npcId}`);const i=await Zf.getPrioritizedDialoguesForNPC(t.npcId);if(qe.log(i),i.length>0){const x=i[0];Si.emit("npcDialogue",{npcId:t.npcId,dialogue:x},1e3)}else qe.log("No dialogues available for this NPC.")}catch(i){qe.error(`Failed to fetch dialogues for NPC with ID ${t.npcId}:`,i)}}tradeWithNPC(t){qe.log(`Trading with NPC with ID: ${t.npcId}`)}moveToNPC(t){const x=t.data?.coords||{x:10,y:15};Si.emit("playerMove",x)}stealFromNPC(t){qe.log(`Attempting to steal from NPC with ID: ${t.npcId}`);const i={npcId:t.npcId,npcName:t.npcName,data:t.data};Si.emit("playerSteal",i)}startCombat(t){qe.log(`Starting combat with NPC with ID: ${t.npcId}`)}checkFish(t){qe.log(`Checking fish for NPC with ID: ${t.npcId}`)}attachNPCEvent(t,i,x,T){t.setInteractive(),t.on("pointerover",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};Si.emit("npcInteraction",s),t.setTint(65280)}),t.on("pointerout",()=>{t.clearTint()}),t.on("pointerdown",E=>{const s={npcId:t.name||"",npcName:i,actions:x.map(y=>y.label),data:T||{},coords:{x:E.x,y:E.y}};qe.log(`Click Registered at X: ${s.coords.x} Y: ${s.coords.y}`),Si.emit("npcInteractionClick",s,1e3)})}}const $A=new _7;function QA(g){return+g[g.length-1]}function _A(g){return g.startsWith("monster_bird_")&&!g.startsWith("monster_bird_shadow")}function qA(g,t,i,x,T){const E=[];for(let s=0;s<10;s++){const y=g.add.sprite(0,0,"monster_bird");y.setCrop(t,i,x,T),y.scale=3,E.push(y)}return E}function tP(g){return qA(g,0,0,61,47)}function eP(g){return qA(g,22,47,16,10)}function iP(g){g.anims.create({key:"bird",frames:g.anims.generateFrameNumbers("monster_bird",{start:0,end:2}),frameRate:10,repeat:-1,yoyo:!0})}class q7 extends Qm.Scene{mainMenuButtonImage;mainMenuButtonText;constructor(){super("Preloader")}preload(){this.load.image("mainBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.image("scroll","https://kbve.com/assets/img/fishchip/scroll.webp"),this.load.image("creditsBg","https://utfs.io/f/2c17f660-7f39-4edf-b83e-122a71014d99-6gflls.webp"),this.load.spritesheet("fishing","https://kbve.com/assets/img/fishchip/animate.png",{frameWidth:800,frameHeight:600}),this.load.image("fish","https://kbve.com/assets/img/letter_logo.png"),this.load.image("background","https://kbve.com/assets/img/fishchip/scaled_fish_menu_minigame.webp"),this.load.image("tiles","https://kbve.com/assets/img/fishchip/desert_tileset_1.png"),this.load.image("cloud-city-tiles","/assets/map/cloud_tileset.png"),this.load.tilemapTiledJSON("cloud-city-map-large","/assets/map/cloud_city_large.json"),this.load.tilemapTiledJSON("cloud-city-map","https://kbve.com/assets/img/fishchip/cloud_city.json"),this.load.spritesheet("player","https://kbve.com/assets/img/fishchip/chip_charactersheet_warmer.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("knights","/assets/entity/knights.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("jacko","/assets/entity/jacko.png",{frameWidth:52,frameHeight:72}),this.load.spritesheet("monks","/assets/entity/monks.png",{frameWidth:52,frameHeight:72}),RI()}async create(){await Zf.initializeDatabase(),this.add.image(480,480,"mainBg").setScale(.1),this.mainMenuButtonImage=this.add.image(480,480,"scroll").setAlpha(.9).setScale(.7,.2).setInteractive({useHandCursor:!0}),this.mainMenuButtonText=this.add.text(480,480,"Start Game",{fontFamily:"Arial Black",fontSize:50,color:"#ffffff",stroke:"#000000",strokeThickness:6}).setOrigin(.5).setInteractive({useHandCursor:!0}),this.mainMenuButtonText.on("pointerdown",()=>{this.scene.start("SandCity")},this)}}let DG=class extends Uf.GameObjects.Sprite{textBubble;tooltip};class tG extends Qm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"SandCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new vu(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57}),Si.emit("notification",{title:"Success",message:`You arrived safely to SandCity Passport: ${o1()}`,notificationType:Ru.success})}async create(){const t=this.make.tilemap({key:"cloud-city-map"});t.addTilesetImage("Cloud City","tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new KA(this,this.gridEngine,this.quadtree),K7(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!",3e3),await Zf.loadCharacter(this,"01J2DT4G871KJ0VNSHCNC5REDM",6,6),await Zf.loadCharacter(this,"01J2HCTMQ58JBMJGW9YA3FBQCG",8,8),await Zf.loadCharacter(this,"01J2HQJBMBGEEMWDBDWATRCY3T",8,15),this.gridEngine.moveRandomly("npc",1500,3),this.gridEngine.moveRandomly("fishNpc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,10);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{_A(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+QA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Si.emit("charEvent",i)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:()=>{const i={message:"Sign does not have much to say.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",i)}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Si.emit("charEvent",i)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Si.emit("charEvent",i)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement()}}class NG extends Uf.GameObjects.Sprite{textBubble}class eG extends Qm.Scene{npcSprite;fishNpcSprite;monsterBirdSprites=[];monsterBirdShadows=[];cursor;gridEngine;quadtree;playerController;constructor(){super({key:"CloudCity"});const t={xMin:0,xMax:20,yMin:0,yMax:20};this.quadtree=new vu(t)}preload(){this.load.spritesheet("monster_bird","/assets/monster/bird_original.png",{frameWidth:61,frameHeight:57})}create(){const t=this.make.tilemap({key:"cloud-city-map-large"});t.addTilesetImage("cloud_tileset","cloud-city-tiles");for(let T=0;T({id:"monster_bird_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1})),...this.monsterBirdShadows.map((T,E)=>({id:"monster_bird_shadow_"+E,sprite:T,startPosition:{x:7,y:7+E},speed:5,collides:!1}))],numberOfDirections:8};this.gridEngine.create(t,x),this.loadRanges(),this.playerController=new KA(this,this.gridEngine,this.quadtree),Z7(this,this.npcSprite,"Enter the sand pit to start fishing! Go near it and press F!"),this.gridEngine.moveRandomly("npc",1500,3);for(let T=0;T<10;T++)this.gridEngine.moveRandomly("monster_bird_"+T,1e3,20);this.gridEngine.positionChangeStarted().subscribe(({charId:T,exitTile:E,enterTile:s})=>{_A(T)&&this.gridEngine.moveTo("monster_bird_shadow_"+QA(T),{x:s.x,y:s.y})}),window.__GRID_ENGINE__=this.gridEngine}loadRanges(){const t=[{name:"well",bounds:{xMin:2,xMax:5,yMin:10,yMax:14},action:()=>{const i={message:"Seems like there are no fish in the sand pits. You know null, this area could be fixed up a bit too."};Si.emit("charEvent",i,1e3)}},{name:"sign",bounds:{xMin:2,xMax:5,yMin:2,yMax:5},action:async()=>{try{const T={message:`The Database Response time: ${(await(await fetch("https://api.cryptothrone.com/api/v1/speed")).json()).message.time_ms} ms`,character_name:"Planets Be Scalin",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",T,1e3)}catch(i){console.error("Error fetching data:",i);const x={message:"Sign does not have much to say. Failed to fetch response time.",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/woodensign.webp"};Si.emit("charEvent",x,1e3)}}},{name:"building",bounds:{xMin:13,xMax:13,yMin:6,yMax:7},action:()=>{const i={message:"Sorry, we are closed!",character_name:"Evee The BarKeep",character_image:"/assets/npc/barkeep.webp",background_image:"/assets/background/animebar.webp"};Si.emit("charEvent",i,1e3)}},{name:"tombstone",bounds:{xMin:7,xMax:10,yMin:9,yMax:10},action:()=>{const i={message:"Samson the Great was an amazing sailer, died drinking dat drank.",character_name:"Samson Statue",character_image:"/assets/npc/samson.png",background_image:"/assets/background/animetombstone.webp"};Si.emit("charEvent",i,1e3)}}];for(const i of t)this.quadtree.insert(i)}update(){this.playerController?.handleMovement(),this.npcSprite&&this.npcSprite.textBubble&&Ox(this.npcSprite),this.fishNpcSprite&&this.fishNpcSprite.textBubble&&Ox(this.fishNpcSprite)}}const iG=mm.div` width: 100vw; height: 100vh; `;function nG(){const g=Me.useRef(null);return Me.useEffect(()=>{let t=null;if(g.current){const i=g.current,x={title:"CryptoThrone",render:{antialias:!1},scale:{mode:Uf.Scale.FIT,autoCenter:Uf.Scale.CENTER_BOTH,zoom:1},type:Uf.AUTO,transparent:!0,width:window.innerWidth,height:window.innerHeight,physics:{default:"arcade",arcade:{gravity:{x:0,y:0},debug:!1}},plugins:{scene:[{key:"gridEngine",plugin:$O,mapping:"gridEngine"}]},scene:[q7,tG,eG],input:{mouse:{preventDefaultWheel:!1},touch:{capture:!0}},parent:i};t=new Uf.Game(x);const T=()=>{t&&t.scale.resize(window.innerWidth,window.innerHeight)};return window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T),t&&t.destroy(!0)}}},[]),Yt.jsx(iG,{children:Yt.jsx("div",{className:"w-full h-full scrollbar-hide",ref:g})})}const wM=jd({message:""}),rG=()=>{const g=io(wM);Me.useEffect(()=>{const i=x=>{if(x){wM.set(x);const T=document.querySelector("#hs-stacked-overlays");T&&(T.classList.remove("hidden"),T.classList.add("open"))}};return Si.on("charEvent",i),()=>{Si.off("charEvent",i)}},[]);const t=()=>{const i=document.querySelector("#hs-stacked-overlays");i&&(i.classList.add("hidden"),i.classList.remove("open"))};return Yt.jsx(Yt.Fragment,{children:Yt.jsx("div",{id:"hs-stacked-overlays",className:"hs-overlay hs-overlay-backdrop-open:bg-gray-900/50 hidden size-full fixed top-0 start-0 z-[60] overflow-x-hidden overflow-y-auto pointer-events-none [--overlay-backdrop:static]","data-hs-overlay-keyboard":"false",children:Yt.jsx("div",{className:"hs-overlay-open:mt-7 hs-overlay-open:opacity-100 hs-overlay-open:duration-500 mt-0 opacity-0 ease-out transition-all sm:max-w-lg sm:w-full m-3 sm:mx-auto",children:Yt.jsxs("div",{className:"flex flex-col lg:flex-row bg-zinc-950 border border-yellow-500 shadow-sm rounded-xl pointer-events-auto bg-cover",style:{backgroundImage:`url(${g.background_image||"https://kbve.com/assets/img/curved-images/wave.jpg"})`},children:[Yt.jsxs("div",{className:"w-full lg:w-1/3 p-4 rounded-l-xl flex flex-col items-center justify-center",children:[Yt.jsx("h3",{className:"font-bold text-yellow-400 bg-zinc-950/80 rounded-2xl text-center mb-4",children:`${g.character_name||"NPC"}`}),Yt.jsx("img",{src:g.character_image||"/assets/npc/barkeep.webp",alt:"Character",className:"w-full h-auto rounded-md"})]}),Yt.jsxs("div",{className:"w-full lg:w-2/3 p-4 bg-cover bg-center rounded-r-xl",children:[Yt.jsxs("div",{className:"flex justify-between items-center pb-3 border-b",children:[Yt.jsx("h3",{className:"font-bold text-yellow-400",children:""}),Yt.jsxs("button",{type:"button",className:"flex justify-center items-center size-7 text-sm font-semibold rounded-full border border-transparent text-yellow-400 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[Yt.jsx("span",{className:"sr-only",children:"Close"}),Yt.jsxs("svg",{className:"flex-shrink-0 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yt.jsx("path",{d:"M18 6 6 18"}),Yt.jsx("path",{d:"m6 6 12 12"})]})]})]}),Yt.jsx("div",{className:"p-4 overflow-y-auto",children:Yt.jsx("p",{className:"mt-1 mb-2 text-yellow-400 bg-zinc-950/80 rounded-xl p-4",children:g.message||"No Message"})}),Yt.jsx("div",{className:"flex justify-end items-center gap-x-2 py-3 px-4 border-t",children:Yt.jsxs("button",{className:"relative rounded px-5 py-2.5 overflow-hidden group bg-yellow-500 relative hover:bg-gradient-to-r hover:from-yellow-500 hover:to-yellow-400 text-white hover:ring-2 hover:ring-offset-2 hover:ring-yellow-400 transition-all ease-out duration-300 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays",onClick:t,children:[Yt.jsx("span",{className:"absolute right-0 w-8 h-32 -mt-12 transition-all duration-1000 transform translate-x-12 bg-white opacity-10 rotate-12 group-hover:-translate-x-40 ease"}),Yt.jsx("span",{className:"relative",children:"Okay."})]})})]})]})})})})},AM=({settingKey:g,label:t,collapseIcon:i=_I,expandIcon:x=qI})=>{const T=gl(g),E=()=>uh(g,!T);return Yt.jsxs("button",{onClick:E,className:"bg-yellow-500 text-white text-sm p-2 rounded ml-2 flex items-center w-20 h-10",children:[T?Yt.jsx(x,{className:"w-2"}):Yt.jsx(i,{className:"w-4"}),Yt.jsx("span",{className:"ml-2 text-xs",children:t})]})},sG=({stats:g})=>{const t=(i,x)=>{const T=typeof i=="string"?parseInt(i,10):i,E=typeof x=="string"?parseInt(x,10):x;return Math.min(T/E*100,100)};return Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Stats"}),Yt.jsxs("div",{className:"mb-2",children:[Yt.jsx("p",{className:"text-sm text-green-400",children:`HP: ${g.health||"0"} / ${g.maxHealth}`}),Yt.jsx("div",{className:"w-full bg-gray-300 h-4 rounded",children:Yt.jsx("div",{className:"bg-green-400 h-full rounded",style:{width:`${t(g.health,g.maxHealth)}%`}})})]}),Yt.jsxs("div",{className:"mb-2",children:[Yt.jsx("p",{className:"text-sm text-blue-400",children:`MP: ${g.mana||"0"} / ${g.maxMana}`}),Yt.jsx("div",{className:"w-full bg-gray-300 h-4 rounded",children:Yt.jsx("div",{className:"bg-blue-400 h-full rounded",style:{width:`${t(g.mana,g.maxMana)}%`}})})]}),Yt.jsxs("div",{className:"mb-2",children:[Yt.jsx("p",{className:"text-sm text-yellow-400",children:`EP: ${g.energy||"0"} / ${g.maxEnergy}`}),Yt.jsx("div",{className:"w-full bg-gray-300 h-4 rounded",children:Yt.jsx("div",{className:"bg-yellow-400 h-full rounded",style:{width:`${t(g.energy,g.maxEnergy)}%`}})})]})]})},aG=({settingKey:g,label:t})=>{const i=gl(g),x=()=>{uh(g,!i)};return Yt.jsxs("label",{className:"flex items-center cursor-pointer",children:[Yt.jsx("span",{className:"mr-2 text-sm",children:t}),Yt.jsxs("div",{className:"relative",children:[Yt.jsx("input",{type:"checkbox",className:"sr-only",checked:i,onChange:x}),Yt.jsx("div",{className:"w-10 h-4 bg-gray-400 rounded-full shadow-inner"}),Yt.jsx("div",{className:`absolute w-6 h-6 bg-white opacity-75 rounded-full shadow -left-1 -top-1 transition-transform ${i?"transform translate-x-full bg-yellow-500 !opacity-100":""}`})]})]})},oG=(g,t)=>{const i=Tl(g);return i?Yt.jsxs("div",{style:{top:t.y,left:t.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[Yt.jsx("p",{className:"text-sm font-semibold",children:i.name}),Yt.jsxs("p",{className:"text-xs",children:["Type: ",i.type]}),Yt.jsxs("p",{className:"text-xs",children:["Bonuses: ",JSON.stringify(i.bonuses)]}),Yt.jsxs("p",{className:"text-xs",children:["Durability: ",i.durability]}),Yt.jsxs("p",{className:"text-xs",children:["Weight: ",i.weight]})]}):null},lG=(g,t,i,x)=>Yt.jsx("ul",{className:"grid grid-cols-8 gap-2",children:Object.keys(g).map(T=>{const E=g[T];return hG(E,t,i,x)})}),hG=(g,t,i,x)=>{if(!g)return Yt.jsx("li",{className:"text-sm relative flex items-center justify-center border border-gray-500 bg-gray-200",style:{width:"32px",height:"32px"}},`empty-${Math.random()}`);const T=Tl(g);return T?Yt.jsxs("li",{className:"text-sm relative",onMouseEnter:E=>t(T.id,E),onMouseLeave:i,onClick:E=>x(T.id,E),children:[T.name," (",T.type,") - Bonuses: ",JSON.stringify(T.bonuses)," - Durability: ",T.durability," - Weight: ",T.weight]},T.id):null},uG=(g,t,i,x)=>Yt.jsx("ul",{className:"grid grid-cols-8 gap-1",children:g.map((T,E)=>{const s=Tl(T);return s?Yt.jsx("li",{className:"text-sm relative hover:scale-[1.3] transition ease-in-out duration-100",onMouseEnter:y=>t(s.id,y),onMouseLeave:i,onClick:y=>x(s.id,y),children:Yt.jsx("img",{src:s.img,alt:s.name,style:{width:"32px",height:"32px"},className:"inline-block border border-yellow-400/50"})},E):null})}),fG=()=>Yt.jsx("div",{className:"transition transform duration-1000 ease-in-out",children:Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Settings"}),Yt.jsx("p",{className:"text-sm",children:"Additional settings can go here."}),Yt.jsx(aG,{settingKey:"debugMode",label:"Debug Mode"})]})}),cG=()=>{const g=io(Tn);io(Sm),io(PI),io(Jr),Me.useEffect(()=>{const r=p=>{};return Si.on("playerEvent",r),()=>{Si.off("playerEvent",r)}},[]);const t=(r,p)=>{uh("tooltipItem",{id:r,position:{x:p.clientX+10,y:p.clientY-150}})},i=()=>{uh("tooltipItem",{...gl("tooltipItem"),id:null})},x=(r,p)=>{uh("submenuItem",{id:r,position:{x:p.clientX,y:p.clientY-150}})},T=()=>{uh("submenuItem",{...gl("submenuItem"),id:null})},E=(r,p)=>{const h=Tl(r);if(h){const a={itemId:h.id,action:p};Si.emit("itemAction",a),T()}};if(!g||!g.stats)return null;const s=gl("submenuItem"),y=s.id?WI(s.id):[],e=gl("tooltipItem");return Yt.jsxs("div",{className:"fixed top-24 left-3 w-[350px] p-4 bg-zinc-800 text-yellow-400 border border-yellow-300 rounded-lg z-20 transition transform ease-in-out duration-500 opacity-50 hover:opacity-100",children:[Yt.jsxs("div",{className:"flex flex-row space-y-2 align-top",children:[Yt.jsx(AM,{settingKey:"isStatsMenuCollapsed",label:"Stats"}),Yt.jsx(AM,{settingKey:"isSettingsMenuCollapsed",label:"Settings"})]}),Yt.jsx("div",{className:`transition transform duration-1000 ease-in-out ${gl("isSettingsMenuCollapsed")?"max-h-0 overflow-hidden":"max-h-screen"}`,children:Yt.jsx(fG,{})}),Yt.jsxs("div",{className:`transition transform duration-1000 ease-in-out ${gl("isStatsMenuCollapsed")?"max-h-0 overflow-hidden":"max-h-screen"}`,children:[Yt.jsx(sG,{stats:g.stats}),Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"User Information"}),Yt.jsx("p",{className:"text-sm",children:g.stats.username||"Guest"})]}),Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"General Information"}),Yt.jsx("p",{className:"text-sm",children:""})]}),Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Inventory"}),uG(g.inventory.backpack,t,i,x)]}),Yt.jsxs("div",{className:"mb-4",children:[Yt.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Equipment"}),lG(g.inventory.equipment,t,i,x)]}),e.id&&oG(e.id,e.position),s.id&&Yt.jsxs("div",{style:{top:s.position.y,left:s.position.x},className:"absolute bg-gray-700 text-white p-2 rounded shadow-lg z-50",children:[Yt.jsx("button",{onClick:T,className:"absolute top-1 right-1 translate-x-6 bg-yellow-400 p-1 text-white hover:text-gray-400",children:"X"}),Yt.jsx("p",{className:"text-sm strong",children:"Actions:"}),Yt.jsxs("ul",{className:"text-xs",children:[y.map(r=>Yt.jsx("li",{onClick:()=>s.id&&E(s.id,r),className:"cursor-pointer hover:bg-gray-600",children:r.charAt(0).toUpperCase()+r.slice(1)},r)),Yt.jsx("li",{onClick:T,className:"cursor-pointer hover:bg-gray-600",children:"Close"})]})]})]})]})},gy=jd(null),yy=jd(null),dG=()=>{const g=io(gy),[t,i]=Me.useState({x:0,y:0}),x=Me.useRef(null);Me.useEffect(()=>{const e=r=>{r&&(gy.set(r),setTimeout(()=>{i(T(r.coords.x,r.coords.y))},0))};return Si.on("npcInteractionClick",e),()=>{Si.off("npcInteractionClick",e)}},[]);const T=(e,r)=>{const h=x.current;if(!h)return{x:e,y:r};const a=h.getBoundingClientRect();let l=e,n=r;return l+a.width>window.innerWidth-10&&(l=window.innerWidth-a.width-10),n+a.height>window.innerHeight-10&&(n=window.innerHeight-a.height-10),l<10&&(l=10),n<10&&(n=10),{x:l,y:n}},E=e=>{if(g){const r=$A.getActionHandler(e);r&&(r(g),s())}},s=()=>{gy.set(null)},y=()=>{if(!g)return null;const{npcName:e,actions:r,npcId:p}=g,{x:h,y:a}=t;return Yt.jsxs("div",{ref:x,className:"absolute bg-zinc-900 border border-yellow-300 rounded-md p-2 z-[100]",style:{left:`${h}px`,top:`${a}px`},children:[Yt.jsxs("div",{className:"flex justify-between items-center mb-2",children:[Yt.jsx("h3",{className:"font-bold text-sm text-white",children:e}),Yt.jsx("button",{onClick:s,className:"text-xs font-bold m-1 text-yellow-300 border rounded-full pl-1 pr-1 hover:text-yellow-500 hover:scale-110",children:"X"})]}),r.map((l,n)=>Yt.jsx("button",{onClick:()=>E(l),className:"block w-full text-sm py-1 px-2 mb-1 bg-yellow-500 hover:bg-yellow-400 rounded capitalize",children:l},n)),Yt.jsx("button",{onClick:s,className:"block w-full text-xs py-1 px-2 mt-2 bg-red-500 hover:bg-red-600 rounded text-white",children:"Close"})]},p)};return Yt.jsx("div",{children:y()})},xy=jd(null),Sy=jd({}),pG=Ou.memo(({text:g,onComplete:t})=>Yt.jsx(jA,{text:g,onComplete:t})),vG=Ou.memo(({text:g,onComplete:t})=>Yt.jsx(jA,{text:g,onComplete:t})),mG=()=>{const g=io(xy),t=io(Sy),[i,x]=Me.useState(!1),[T,E]=Me.useState(!1);Me.useEffect(()=>{const y=e=>{if(e){xy.set(e);const r=document.querySelector("#hs-stacked-overlays-dialogue");r&&(r.classList.remove("hidden"),r.classList.add("open")),e.npcId&&(Zf.createNPCSession(Sy,e.npcId),x(!1),E(!1))}};return Si.on("npcDialogue",y),()=>{Si.off("npcDialogue",y)}},[]);const s=()=>{const y=document.querySelector("#hs-stacked-overlays-dialogue");y&&(y.classList.add("hidden"),y.classList.remove("open")),xy.set(null),Sy.set({}),x(!1),E(!1)};return Yt.jsx(Yt.Fragment,{children:Yt.jsx("div",{id:"hs-stacked-overlays-dialogue",className:"hs-overlay hs-overlay-backdrop-open:bg-gray-900/50 w-full h-full fixed top-0 start-0 z-[60] overflow-x-hidden overflow-y-auto pointer-events-none [--overlay-backdrop:static]","data-hs-overlay-keyboard":"false",children:Yt.jsx("div",{className:"hs-overlay-open:mt-7 hs-overlay-open:opacity-100 hs-overlay-open:duration-500 mt-0 opacity-0 ease-out transition-all w-full h-full sm:max-w-lg sm:w-full m-3 sm:mx-auto md:min-w-fit",children:Yt.jsx("div",{className:"flex flex-col lg:flex-row bg-zinc-950 border border-yellow-500 shadow-sm rounded-xl pointer-events-auto bg-cover min-w-[800px] min-h-[500px]",style:{backgroundImage:`url(${g?.dialogue.backgroundImage||"https://kbve.com/assets/img/curved-images/wave.jpg"})`},children:g?Yt.jsxs(Yt.Fragment,{children:[Yt.jsxs("div",{className:"w-full lg:w-1/3 p-4 rounded-l-xl flex flex-col items-center justify-center relative",children:[Yt.jsx("h3",{className:"font-bold text-yellow-400 bg-zinc-950/80 rounded-2xl text-center mb-4 p-4 absolute top-2 left-2",children:g.npcId&&t[`${g.npcId}_name`]?t[`${g.npcId}_name`]:"Unknown"}),Yt.jsx("img",{src:g.npcId&&t[`${g.npcId}_avatar`]?t[`${g.npcId}_avatar`]:"/assets/npc/barkeep.webp",alt:"Character",className:"w-full h-auto rounded-md absolute bottom-0 left-0"})]}),Yt.jsxs("div",{className:"w-full md:w-2/3 p-4 bg-cover bg-center rounded-r-xl",children:[Yt.jsxs("div",{className:"flex justify-between items-center pb-3 border-b",children:[Yt.jsx("h3",{className:"font-bold text-yellow-400 text-shadow-outline-white",children:g.dialogue.title||"Dialogue"}),Yt.jsxs("button",{type:"button",className:"flex justify-center items-center size-7 text-sm font-semibold rounded-full border border-transparent text-yellow-400 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays-dialogue",onClick:s,children:[Yt.jsx("span",{className:"sr-only",children:"Close"}),Yt.jsxs("svg",{className:"flex-shrink-0 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yt.jsx("path",{d:"M18 6 6 18"}),Yt.jsx("path",{d:"m6 6 12 12"})]})]})]}),Yt.jsx("div",{className:"p-4 overflow-y-auto",children:Yt.jsxs("div",{className:"flex flex-col",children:[Yt.jsx("div",{className:"flex justify-end",children:Yt.jsxs("div",{className:"w-3/4 mt-1 mb-2 text-yellow-400 text-shadow-outline-whites bg-zinc-950/40 rounded-xl p-4 text-right",children:[g.dialogue.playerResponse&&!T&&Yt.jsx(vG,{text:`${g.dialogue.playerResponse}`,onComplete:()=>E(!0)}),T&&Yt.jsx("div",{children:g.dialogue.playerResponse})]})}),Yt.jsx("div",{className:"mt-1 mb-2 text-white bg-zinc-950/40 text-shadow-outline-white rounded-xl p-4 flex w-3/4",children:Yt.jsxs("div",{className:"w-full",children:[g.dialogue.message&&T&&!i&&Yt.jsx(pG,{text:g.dialogue.message,onComplete:()=>x(!0)}),i&&Yt.jsx("div",{children:g.dialogue.message})]})})]})}),Yt.jsx("div",{className:"flex justify-end items-center gap-x-2 py-3 px-4 border-t",children:Yt.jsxs("button",{className:"relative rounded px-5 py-2.5 overflow-hidden group bg-yellow-500 relative hover:bg-gradient-to-r hover:from-yellow-500 hover:to-yellow-400 text-white hover:ring-2 hover:ring-offset-2 hover:ring-yellow-400 transition-all ease-out duration-300 disabled:pointer-events-none","data-hs-overlay":"#hs-stacked-overlays-dialogue",onClick:s,disabled:!T,children:[Yt.jsx("span",{className:"absolute right-0 w-8 h-32 -mt-12 transition-all duration-1000 transform translate-x-12 bg-white opacity-10 rotate-12 group-hover:-translate-x-40 ease"}),Yt.jsx("span",{className:`relative ${T?"":"text-gray-500"}`,children:"Okay."})]})})]})]}):Yt.jsx("div",{className:"w-full p-4 rounded-xl flex flex-col items-center justify-center",children:Yt.jsx("h3",{className:"font-bold text-yellow-400 bg-zinc-950/80 rounded-2xl text-center mb-4 p-4",children:"Loading..."})})})})})})},gG=()=>{const g=io(Qh);Me.useEffect(()=>{const i=x=>{if(x){const T=Date.now()+Math.random(),E={id:T,...x};Qh.set([...Qh.get(),E]),setTimeout(()=>{Qh.set(Qh.get().filter(s=>s.id!==T))},5e3)}};return Si.on("notification",i),()=>{Si.off("notification",i)}},[]);const t=i=>{Qh.set(Qh.get().filter(x=>x.id!==i))};return Yt.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 m-4 space-y-2",children:Array.isArray(g)&&g.map(i=>Yt.jsx("div",{className:`hs-removing:translate-x-5 hs-removing:opacity-0 transition duration-300 max-w-xs border rounded-xl shadow-lg ${i.notificationType.color}`,role:"alert",children:Yt.jsxs("div",{className:"flex p-4",children:[Yt.jsx("img",{src:i.notificationType.imgUrl,alt:i.notificationType.type,className:"flex-shrink-0 size-4"}),Yt.jsxs("div",{className:"ms-2",children:[Yt.jsx("h3",{className:"text-sm font-bold",children:i.title}),Yt.jsx("p",{className:"text-sm",children:i.message})]}),Yt.jsx("div",{className:"ms-auto",children:Yt.jsxs("button",{type:"button",className:"inline-flex flex-shrink-0 justify-center items-center size-5 rounded-lg text-gray-800 opacity-50 hover:opacity-100 focus:outline-none focus:opacity-100 dark:text-white",onClick:()=>t(i.id),children:[Yt.jsx("span",{className:"sr-only",children:"Close"}),Yt.jsxs("svg",{className:"flex-shrink-0 size-4 bg-zinc-900",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yt.jsx("path",{d:"M18 6 6 18"}),Yt.jsx("path",{d:"m6 6 12 12"})]})]})})]})},i.id))})},yG=()=>{const g=io(yy),[t,i]=Me.useState([]),[x,T]=Me.useState(null);Me.useEffect(()=>{const y=r=>{r&&yy.set(r)},e=r=>{r&&i(r.diceValues)};return Si.on("playerSteal",y),Si.on("diceRollResult",e),()=>{Si.off("playerSteal",y),Si.off("diceRollResult",e)}},[]),Me.useEffect(()=>{t.length>0&&E(t)},[t]);const E=y=>{const e=y.reduce((a,l)=>a+l,0);if(T(e),!g)return;let r="",p="";switch(!0){case e>=24:r="01J27QABD2GPFNRVK69S51HSGB",p=`You successfully stole a ${r}!`;break;case e>=20:r="01J27QN2KZG1RDZW4CE9Q9Z3YQ",p=`You successfully stole a ${r}!`;break;case e>=18:r="01J269PK47V1DWX2S1251DEASD",p=`You successfully stole a ${r}!`;break;case e>=15:r="Blue Shark",p=`You successfully stole a ${r}!`;break;case e>=12:r="Salmon",p=`You successfully stole a ${r}!`;break;case e<=4:Si.emit("notification",{title:"Danger",message:`You crit failed to steal from ${g.npcName}!`,notificationType:Ru.danger}),Si.emit("playerDamage",{damage:"5"});break;default:Si.emit("notification",{title:"Danger",message:`You failed to steal from ${g.npcName}!`,notificationType:Ru.danger}),Si.emit("playerDamage",{damage:"1"});return}const h=bI(r);h?Si.emit("playerReward",{message:p,item:h}):console.warn("Item not found in ItemDB")},s=()=>{dw([]),i([]),T(null),yy.set(null)};return g?Yt.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50 bg-zinc-800 bg-opacity-50",children:Yt.jsxs("div",{className:"bg-zinc-800 p-4 rounded-lg shadow-lg w-3/4",children:[Yt.jsx(xG,{npcName:g.npcName,roll:x}),Yt.jsx(TG,{}),Yt.jsx(EG,{handleClose:s})]})}):null},xG=({npcName:g,roll:t})=>Yt.jsxs("div",{children:[Yt.jsx("h2",{className:"text-lg text-yellow-400 font-bold mb-4",children:"Steal Attempt"}),Yt.jsxs("p",{className:"mb-4",children:["Roll the dice to steal from ",g,". You need a total of 12 or higher to succeed."]}),t!==null&&Yt.jsxs("p",{className:"mb-4",children:["Your roll: ",t]})]}),SG=()=>Yt.jsx(k7,{textures:{side1:"/assets/items/set/dice/dice1.png",side2:"/assets/items/set/dice/dice2.png",side3:"/assets/items/set/dice/dice3.png",side4:"/assets/items/set/dice/dice4.png",side5:"/assets/items/set/dice/dice5.png",side6:"/assets/items/set/dice/dice6.png"},styleClass:"h-96",diceCount:4}),TG=Me.memo(SG),EG=({handleClose:g})=>Yt.jsx("button",{onClick:g,className:"block w-full py-2 bg-red-500 text-white rounded hover:bg-red-700 mt-2",children:"Close"}),MG=mm.div` diff --git a/docs/index.html b/docs/index.html index 9a0c12c..ed18248 100644 --- a/docs/index.html +++ b/docs/index.html @@ -27,4 +27,4 @@ Log in \ No newline at end of file + \ No newline at end of file