@obb871001/api-integration-sdk 1.0.52 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +53 -48
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11,4 +11,4 @@ Check the top-level render call using <`+g+">.")}return l}}function ur(e,l){{if(
|
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,De,ne,Zr,ne),cr[ne+De]=!0}}return e===E?Yr(L):Kr(L),L}}function Qr(e,l,g){return ir(e,l,g,!0)}function xr(e,l,g){return ir(e,l,g,!1)}var zr=xr,Xr=Qr;ye.Fragment=E,ye.jsx=zr,ye.jsxs=Xr})()),ye}var fr;function ot(){return fr||(fr=1,process.env.NODE_ENV==="production"?Ae.exports=at():Ae.exports=ut()),Ae.exports}var dr=ot();const Ge=N.createContext(null),be=()=>{const r=N.useContext(Ge);if(!r)throw new Error("useApiContext must be used within ApiProvider");return r};function ct({baseURL:r,getToken:S,timeoutMs:O=15e3,lng:E="tw",store:f,onError:_}={}){const y=rt.create({baseURL:r,timeout:O,headers:{"Content-Type":"application/json"}});return y.interceptors.request.use(async d=>{if(d.headers=d.headers||{},S){const s=await S();s&&(d.headers.Authorization=`Bearer ${s}`)}const c=f?.getState()?.isWalletCurrency;return d.headers.Currency=c,d.headers["currency-code"]=c,d.headers.lang=E,d}),y.interceptors.response.use(d=>d.data,d=>_?_(d,{instance:y}):Promise.reject(d)),y}function it({children:r,...S}){const O=N.useMemo(()=>ct(S),[S]),f=N.useMemo(()=>new $.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return dr.jsx($.QueryClientProvider,{client:f,children:dr.jsx(Ge.Provider,{value:{client:O,...S},children:r})})}const st=()=>{const r=(E,f)=>!E&&!f,S=E=>E.startsWith("pc.");return{executeLogout:({isCallBackInvalid:E=!1,hostname:f="",shouldRedirect:_,onShowError:y,onCleanup:d,onRemoveToken:c,onRedirect:s,onGoogleLogout:u})=>{const a=S(f);r(E,a)&&y?.(),d?.(),c?.(),_&&s?.("/"),u?.()},shouldShowErrorNotice:r,isMachineDomain:S}},Je=()=>{const{client:r}=be(),S=N.useCallback(async y=>{const{mac_address:d="",app_version:c="",anydesk_id:s=""}=y,{data:u}=await r.post("/cash-register/login",{mac_address:d,app_version:c,anydesk_id:s});return u},[r]),O=N.useCallback(async()=>r.get("/member/getMemberInfo"),[r]),E=N.useCallback(async()=>await r.get("member/getGameList"),[r]),f=N.useCallback(async()=>await r.get("/member/getNowCurrencyExchange"),[r]),_=N.useCallback(async()=>await r.get("member/getFavoriteGame"),[r]);return{machineLoginApi:S,userInfoApi:O,userGameListApi:E,userFavoriteGameApi:_,userCurrencyExchangeApi:f}},lt=({otherQueryKey:r=[],options:S={}}={})=>{const{userCurrencyExchangeApi:O}=Je(),{getToken:E}=be(),{enabled:f,..._}=S,y=!!E&&(f?f.every(d=>d):!0);return $.useQueries({queries:[{queryKey:["userCurrencyExchange",...r],queryFn:()=>O(),enabled:y,..._}]})};var je={},q={},Ue={},vr;function B(){return vr||(vr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.isEventSourceSupported=r.isReactNative=r.ReadyState=r.DEFAULT_HEARTBEAT=r.UNPARSABLE_JSON_OBJECT=r.DEFAULT_RECONNECT_INTERVAL_MS=r.DEFAULT_RECONNECT_LIMIT=r.SOCKET_IO_PING_CODE=r.SOCKET_IO_PATH=r.SOCKET_IO_PING_INTERVAL=r.DEFAULT_EVENT_SOURCE_OPTIONS=r.EMPTY_EVENT_HANDLERS=r.DEFAULT_OPTIONS=void 0;var S=1,O=1e3*S;r.DEFAULT_OPTIONS={},r.EMPTY_EVENT_HANDLERS={},r.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:r.EMPTY_EVENT_HANDLERS},r.SOCKET_IO_PING_INTERVAL=25*O,r.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",r.SOCKET_IO_PING_CODE="2",r.DEFAULT_RECONNECT_LIMIT=20,r.DEFAULT_RECONNECT_INTERVAL_MS=5e3,r.UNPARSABLE_JSON_OBJECT={},r.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var E;(function(_){_[_.UNINSTANTIATED=-1]="UNINSTANTIATED",_[_.CONNECTING=0]="CONNECTING",_[_.OPEN=1]="OPEN",_[_.CLOSING=2]="CLOSING",_[_.CLOSED=3]="CLOSED"})(E||(r.ReadyState=E={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};r.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",r.isEventSourceSupported=!r.isReactNative&&f()})(Ue)),Ue}var Se={},We={},Er;function He(){return Er||(Er=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetWebSockets=r.sharedWebSockets=void 0,r.sharedWebSockets={};var S=function(O){if(O&&r.sharedWebSockets.hasOwnProperty(O))delete r.sharedWebSockets[O];else for(var E in r.sharedWebSockets)r.sharedWebSockets.hasOwnProperty(E)&&delete r.sharedWebSockets[E]};r.resetWebSockets=S})(We)),We}var ae={},x={},_r;function Ve(){if(_r)return x;_r=1,Object.defineProperty(x,"__esModule",{value:!0}),x.setUpSocketIOPing=x.appendQueryParams=x.parseSocketIOUrl=void 0;var r=B(),S=function(f){if(f){var _=/^https|wss/.test(f),y=f.replace(/^(https?|wss?)(:\/\/)?/,""),d=y.replace(/\/$/,""),c=_?"wss":"ws";return"".concat(c,"://").concat(d).concat(r.SOCKET_IO_PATH)}else if(f===""){var _=/^https/.test(window.location.protocol),c=_?"wss":"ws",s=window.location.port?":".concat(window.location.port):"";return"".concat(c,"://").concat(window.location.hostname).concat(s).concat(r.SOCKET_IO_PATH)}return f};x.parseSocketIOUrl=S;var O=function(f,_){_===void 0&&(_={});var y=/\?([\w]+=[\w]+)/,d=y.test(f),c="".concat(Object.entries(_).reduce(function(s,u){var a=u[0],i=u[1];return s+"".concat(a,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(d?"&":"?").concat(c)};x.appendQueryParams=O;var E=function(f,_){_===void 0&&(_=r.SOCKET_IO_PING_INTERVAL);var y=function(){return f(r.SOCKET_IO_PING_CODE)};return window.setInterval(y,_)};return x.setUpSocketIOPing=E,x}var ke={},yr;function Ar(){if(yr)return ke;yr=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.heartbeat=O;var r=B();function S(E){return Array.isArray(E)?E.reduce(function(f,_){return f.current>_.current?f:_}).current:E.current}function O(E,f,_){var y=_||{},d=y.interval,c=d===void 0?r.DEFAULT_HEARTBEAT.interval:d,s=y.timeout,u=s===void 0?r.DEFAULT_HEARTBEAT.timeout:s,a=y.message,i=a===void 0?r.DEFAULT_HEARTBEAT.message:a,t=Math.max(100,c/10),n=Date.now(),v=setInterval(function(){var h=Date.now(),o=S(f);if(o+u<=h)console.warn("Heartbeat timed out, closing connection, last message received ".concat(h-o,"ms ago, last ping sent ").concat(h-n,"ms ago")),E.close();else if(o+c<=h&&n+c<=h)try{typeof i=="function"?E.send(i()):E.send(i),n=h}catch(b){console.error("Heartbeat failed, closing connection",b instanceof Error?b.message:b),E.close()}},t);return E.addEventListener("close",function(){clearInterval(v)}),function(){}}return ke}var he={},Fe={},Sr;function $e(){return Sr||(Sr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetSubscribers=r.removeSubscriber=r.addSubscriber=r.hasSubscribers=r.getSubscribers=void 0;var S={},O=[],E=function(c){return(0,r.hasSubscribers)(c)?Array.from(S[c]):O};r.getSubscribers=E;var f=function(c){var s;return((s=S[c])===null||s===void 0?void 0:s.size)>0};r.hasSubscribers=f;var _=function(c,s){S[c]=S[c]||new Set,S[c].add(s)};r.addSubscriber=_;var y=function(c,s){S[c].delete(s)};r.removeSubscriber=y;var d=function(c){if(c&&S.hasOwnProperty(c))delete S[c];else for(var s in S)S.hasOwnProperty(s)&&delete S[s]};r.resetSubscribers=d})(Fe)),Fe}var hr;function Be(){if(hr)return he;hr=1,Object.defineProperty(he,"__esModule",{value:!0}),he.assertIsWebSocket=O,he.resetGlobalState=E;var r=He(),S=$e();function O(f,_){if(!_&&!(f instanceof WebSocket))throw new Error("")}function E(f){(0,S.resetSubscribers)(f),(0,r.resetWebSockets)(f)}return he}var br;function ft(){if(br)return ae;br=1;var r=ae&&ae.__assign||function(){return r=Object.assign||function(u){for(var a,i=1,t=arguments.length;i<t;i++){a=arguments[i];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(u[n]=a[n])}return u},r.apply(this,arguments)};Object.defineProperty(ae,"__esModule",{value:!0}),ae.attachListeners=void 0;var S=Ve(),O=Ar(),E=B(),f=Be(),_=function(u,a,i,t){u.onmessage=function(n){var v;a.current.onMessage&&a.current.onMessage(n),typeof t?.current=="number"&&(t.current=Date.now()),!(typeof a.current.filter=="function"&&a.current.filter(n)!==!0)&&(a.current.heartbeat&&typeof a.current.heartbeat!="boolean"&&((v=a.current.heartbeat)===null||v===void 0?void 0:v.returnMessage)===n.data||i(n))}},y=function(u,a,i,t,n){u.onopen=function(v){if(a.current.onOpen&&a.current.onOpen(v),t.current=0,i(E.ReadyState.OPEN),a.current.heartbeat&&u instanceof WebSocket){var h=typeof a.current.heartbeat=="boolean"?void 0:a.current.heartbeat;n.current=Date.now(),(0,O.heartbeat)(u,n,h)}}},d=function(u,a,i,t,n){if(E.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,a.current.skipAssert);var v;return u.onclose=function(h){var o;if(a.current.onClose&&a.current.onClose(h),i(E.ReadyState.CLOSED),a.current.shouldReconnect&&a.current.shouldReconnect(h)){var b=(o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT;if(n.current<b){var R=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},R??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(b),console.warn("Max reconnect attempts of ".concat(b," exceeded"))}},function(){return v&&window.clearTimeout(v)}},c=function(u,a,i,t,n){var v;return u.onerror=function(h){var o;if(a.current.onError&&a.current.onError(h),E.isEventSourceSupported&&u instanceof EventSource&&(a.current.onClose&&a.current.onClose(r(r({},h),{code:1006,reason:"An error occurred with the EventSource: ".concat(h),wasClean:!1})),i(E.ReadyState.CLOSED),u.close()),a.current.retryOnError)if(n.current<((o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT)){var b=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},b??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(a.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts," exceeded"))},function(){return v&&window.clearTimeout(v)}},s=function(u,a,i,t,n,v,h){var o=a.setLastMessage,b=a.setReadyState,R,k,m;return i.current.fromSocketIO&&(R=(0,S.setUpSocketIOPing)(h)),_(u,i,o,v),y(u,i,b,n,v),k=d(u,i,b,t,n),m=c(u,i,b,t,n),function(){b(E.ReadyState.CLOSING),k(),m(),u.close(),R&&clearInterval(R)}};return ae.attachListeners=s,ae}var ue={},gr;function dt(){if(gr)return ue;gr=1;var r=ue&&ue.__assign||function(){return r=Object.assign||function(a){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var v in i)Object.prototype.hasOwnProperty.call(i,v)&&(a[v]=i[v])}return a},r.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.attachSharedListeners=void 0;var S=He(),O=B(),E=$e(),f=Ve(),_=Ar(),y=function(a,i,t){a.onmessage=function(n){(0,E.getSubscribers)(i).forEach(function(v){var h;v.optionsRef.current.onMessage&&v.optionsRef.current.onMessage(n),typeof((h=v?.lastMessageTime)===null||h===void 0?void 0:h.current)=="number"&&(v.lastMessageTime.current=Date.now()),!(typeof v.optionsRef.current.filter=="function"&&v.optionsRef.current.filter(n)!==!0)&&(t&&typeof t!="boolean"&&t?.returnMessage===n.data||v.setLastMessage(n))})}},d=function(a,i,t){a.onopen=function(n){var v=(0,E.getSubscribers)(i);v.forEach(function(h){h.reconnectCount.current=0,h.optionsRef.current.onOpen&&h.optionsRef.current.onOpen(n),h.setReadyState(O.ReadyState.OPEN),t&&a instanceof WebSocket&&(h.lastMessageTime.current=Date.now())}),t&&a instanceof WebSocket&&(0,_.heartbeat)(a,v.map(function(h){return h.lastMessageTime}),typeof t=="boolean"?void 0:t)}},c=function(a,i){a instanceof WebSocket&&(a.onclose=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onClose&&n.optionsRef.current.onClose(t),n.setReadyState(O.ReadyState.CLOSED)}),delete S.sharedWebSockets[i],(0,E.getSubscribers)(i).forEach(function(n){var v;if(n.optionsRef.current.shouldReconnect&&n.optionsRef.current.shouldReconnect(t)){var h=(v=n.optionsRef.current.reconnectAttempts)!==null&&v!==void 0?v:O.DEFAULT_RECONNECT_LIMIT;if(n.reconnectCount.current<h){var o=typeof n.optionsRef.current.reconnectInterval=="function"?n.optionsRef.current.reconnectInterval(n.reconnectCount.current):n.optionsRef.current.reconnectInterval;setTimeout(function(){n.reconnectCount.current++,n.reconnect.current()},o??O.DEFAULT_RECONNECT_INTERVAL_MS)}else n.optionsRef.current.onReconnectStop&&n.optionsRef.current.onReconnectStop(n.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(h," exceeded"))}})})},s=function(a,i){a.onerror=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onError&&n.optionsRef.current.onError(t),O.isEventSourceSupported&&a instanceof EventSource&&(n.optionsRef.current.onClose&&n.optionsRef.current.onClose(r(r({},t),{code:1006,reason:"An error occurred with the EventSource: ".concat(t),wasClean:!1})),n.setReadyState(O.ReadyState.CLOSED))}),O.isEventSourceSupported&&a instanceof EventSource&&a.close()}},u=function(a,i,t,n){var v;return t.current.fromSocketIO&&(v=(0,f.setUpSocketIOPing)(n)),y(a,i,t.current.heartbeat),c(a,i),d(a,i,t.current.heartbeat),s(a,i),function(){v&&clearInterval(v)}};return ue.attachSharedListeners=u,ue}var Or;function vt(){if(Or)return Se;Or=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.createOrJoinSocket=void 0;var r=He(),S=B(),O=ft(),E=dt(),f=$e(),_=function(d,c,s,u,a){return function(){if((0,f.removeSubscriber)(d,c),!(0,f.hasSubscribers)(d)){try{var i=r.sharedWebSockets[d];i instanceof WebSocket&&(i.onclose=function(t){s.current.onClose&&s.current.onClose(t),u(S.ReadyState.CLOSED)}),i.close()}catch{}a&&a(),delete r.sharedWebSockets[d]}}},y=function(d,c,s,u,a,i,t,n,v){if(!S.isEventSourceSupported&&u.current.eventSourceOptions)throw S.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var h=null;r.sharedWebSockets[c]===void 0?(r.sharedWebSockets[c]=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),d.current=r.sharedWebSockets[c],s(S.ReadyState.CONNECTING),h=(0,E.attachSharedListeners)(r.sharedWebSockets[c],c,u,v)):(d.current=r.sharedWebSockets[c],s(r.sharedWebSockets[c].readyState));var o={setLastMessage:a,setReadyState:s,optionsRef:u,reconnectCount:t,lastMessageTime:n,reconnect:i};return(0,f.addSubscriber)(c,o),_(c,o,u,s,h)}else{if(d.current=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),s(S.ReadyState.CONNECTING),!d.current)throw new Error("WebSocket failed to be created");return(0,O.attachListeners)(d.current,{setLastMessage:a,setReadyState:s},u,i.current,t,n,v)}};return Se.createOrJoinSocket=y,Se}var z={},pr;function Et(){return pr||(pr=1,(function(r){var S=z&&z.__awaiter||function(c,s,u,a){function i(t){return t instanceof u?t:new u(function(n){n(t)})}return new(u||(u=Promise))(function(t,n){function v(b){try{o(a.next(b))}catch(R){n(R)}}function h(b){try{o(a.throw(b))}catch(R){n(R)}}function o(b){b.done?t(b.value):i(b.value).then(v,h)}o((a=a.apply(c,s||[])).next())})},O=z&&z.__generator||function(c,s){var u={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=v(0),n.throw=v(1),n.return=v(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function v(o){return function(b){return h([o,b])}}function h(o){if(a)throw new TypeError("Generator is already executing.");for(;n&&(n=0,o[0]&&(u=0)),u;)try{if(a=1,i&&(t=o[0]&2?i.return:o[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,o[1])).done)return t;switch(i=0,t&&(o=[o[0]&2,t.value]),o[0]){case 0:case 1:t=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,i=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(t=u.trys,!(t=t.length>0&&t[t.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!t||o[1]>t[0]&&o[1]<t[3])){u.label=o[1];break}if(o[0]===6&&u.label<t[1]){u.label=t[1],t=o;break}if(t&&u.label<t[2]){u.label=t[2],u.ops.push(o);break}t[2]&&u.ops.pop(),u.trys.pop();continue}o=s.call(c,u)}catch(b){o=[6,b],i=0}finally{a=t=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},E=z&&z.__spreadArray||function(c,s,u){if(u||arguments.length===2)for(var a=0,i=s.length,t;a<i;a++)(t||!(a in s))&&(t||(t=Array.prototype.slice.call(s,0,a)),t[a]=s[a]);return c.concat(t||Array.prototype.slice.call(s))};Object.defineProperty(r,"__esModule",{value:!0}),r.getUrl=void 0;var f=Ve(),_=B(),y=function(c){return new Promise(function(s){return window.setTimeout(s,c)})},d=function(c,s){for(var u=[],a=2;a<arguments.length;a++)u[a-2]=arguments[a];return S(void 0,E([c,s],u,!0),void 0,function(i,t,n){var v,h,o,b,R,k,m,A;return n===void 0&&(n=0),O(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return v=I.sent(),[3,9];case 3:return I.sent(),t.current.retryOnError?(h=(k=t.current.reconnectAttempts)!==null&&k!==void 0?k:_.DEFAULT_RECONNECT_LIMIT,n<h?(o=typeof t.current.reconnectInterval=="function"?t.current.reconnectInterval(n):t.current.reconnectInterval,[4,y(o??_.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,r.getUrl)(i,t,n+1)];case 5:return(A=(m=t.current).onReconnectStop)===null||A===void 0||A.call(m,n),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:v=i,I.label=11;case 11:return b=t.current.fromSocketIO?(0,f.parseSocketIOUrl)(v):v,R=t.current.queryParams?(0,f.appendQueryParams)(b,t.current.queryParams):b,[2,R]}})})};r.getUrl=d})(z)),z}var qe={},mr;function _t(){return mr||(mr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.websocketWrapper=void 0;var S=function(O,E){return new Proxy(O,{get:function(f,_){var y=f[_];return _==="reconnect"?E:typeof y=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):y},set:function(f,_,y){return/^on/.test(_)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[_]=y,!0)}})};r.websocketWrapper=S,r.default=r.websocketWrapper})(qe)),qe}var Tr;function Ke(){if(Tr)return q;Tr=1;var r=q&&q.__assign||function(){return r=Object.assign||function(i){for(var t,n=1,v=arguments.length;n<v;n++){t=arguments[n];for(var h in t)Object.prototype.hasOwnProperty.call(t,h)&&(i[h]=t[h])}return i},r.apply(this,arguments)},S=q&&q.__awaiter||function(i,t,n,v){function h(o){return o instanceof n?o:new n(function(b){b(o)})}return new(n||(n=Promise))(function(o,b){function R(A){try{m(v.next(A))}catch(I){b(I)}}function k(A){try{m(v.throw(A))}catch(I){b(I)}}function m(A){A.done?o(A.value):h(A.value).then(R,k)}m((v=v.apply(i,t||[])).next())})},O=q&&q.__generator||function(i,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},v,h,o,b=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return b.next=R(0),b.throw=R(1),b.return=R(2),typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function R(m){return function(A){return k([m,A])}}function k(m){if(v)throw new TypeError("Generator is already executing.");for(;b&&(b=0,m[0]&&(n=0)),n;)try{if(v=1,h&&(o=m[0]&2?h.return:m[0]?h.throw||((o=h.return)&&o.call(h),0):h.next)&&!(o=o.call(h,m[1])).done)return o;switch(h=0,o&&(m=[m[0]&2,o.value]),m[0]){case 0:case 1:o=m;break;case 4:return n.label++,{value:m[1],done:!1};case 5:n.label++,h=m[1],m=[0];continue;case 7:m=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(m[0]===6||m[0]===2)){n=0;continue}if(m[0]===3&&(!o||m[1]>o[0]&&m[1]<o[3])){n.label=m[1];break}if(m[0]===6&&n.label<o[1]){n.label=o[1],o=m;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(m);break}o[2]&&n.ops.pop(),n.trys.pop();continue}m=t.call(i,n)}catch(A){m=[6,A],h=0}finally{v=o=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},E=q&&q.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(q,"__esModule",{value:!0}),q.useWebSocket=void 0;var f=N,_=tt,y=B(),d=vt(),c=Et(),s=E(_t()),u=Be(),a=function(i,t,n){t===void 0&&(t=y.DEFAULT_OPTIONS),n===void 0&&(n=!0);var v=(0,f.useState)(null),h=v[0],o=v[1],b=(0,f.useState)({}),R=b[0],k=b[1],m=(0,f.useMemo)(function(){if(!t.disableJson&&h)try{return JSON.parse(h.data)}catch{return y.UNPARSABLE_JSON_OBJECT}return null},[h,t.disableJson]),A=(0,f.useRef)(null),I=(0,f.useRef)(null),fe=(0,f.useRef)(function(){}),de=(0,f.useRef)(0),Pe=(0,f.useRef)(Date.now()),ge=(0,f.useRef)([]),H=(0,f.useRef)(null),j=(0,f.useRef)(t);j.current=t;var J=A.current&&R[A.current]!==void 0?R[A.current]:i!==null&&n===!0?y.ReadyState.CONNECTING:y.ReadyState.UNINSTANTIATED,ee=t.queryParams?JSON.stringify(t.queryParams):null,K=(0,f.useCallback)(function(D,U){var Y;if(U===void 0&&(U=!0),y.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===y.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),I.current.send(D)):U&&ge.current.push(D)},[]),Oe=(0,f.useCallback)(function(D,U){U===void 0&&(U=!0),K(JSON.stringify(D),U)},[K]),pe=(0,f.useCallback)(function(){return j.current.share!==!0||y.isEventSourceSupported&&I.current instanceof EventSource?I.current:(H.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),H.current=(0,s.default)(I.current,fe)),H.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&n===!0){var D,U=!1,Y=!0,ve=function(){return S(void 0,void 0,void 0,function(){var re,Z,me;return O(this,function(ce){switch(ce.label){case 0:return re=A,[4,(0,c.getUrl)(i,j)];case 1:return re.current=ce.sent(),A.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),A.current="ABORTED",(0,_.flushSync)(function(){return k(function(Q){return r(r({},Q),{ABORTED:y.ReadyState.CLOSED})})}),[2]):(Z=function(Q){U||(0,_.flushSync)(function(){return o(Q)})},me=function(Q){U||(0,_.flushSync)(function(){return k(function(ie){var te;return r(r({},ie),A.current&&(te={},te[A.current]=Q,te))})})},Y&&(D=(0,d.createOrJoinSocket)(I,A.current,me,j,Z,fe,de,Pe,K)),[2])}})})};return fe.current=function(){U||(H.current&&(H.current=null),D?.(),ve())},ve(),function(){U=!0,Y=!1,H.current&&(H.current=null),D?.(),o(null)}}else(i===null||n===!1)&&(de.current=0,k(function(re){var Z;return r(r({},re),A.current&&(Z={},Z[A.current]=y.ReadyState.CLOSED,Z))}))},[i,n,ee,K]),(0,f.useEffect)(function(){J===y.ReadyState.OPEN&&ge.current.splice(0).forEach(function(D){K(D)})},[J]),{sendMessage:K,sendJsonMessage:Oe,lastMessage:h,lastJsonMessage:m,readyState:J,getWebSocket:pe}};return q.useWebSocket=a,q}var oe={},Cr;function yt(){if(Cr)return oe;Cr=1;var r=oe&&oe.__assign||function(){return r=Object.assign||function(d){for(var c,s=1,u=arguments.length;s<u;s++){c=arguments[s];for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&(d[a]=c[a])}return d},r.apply(this,arguments)};Object.defineProperty(oe,"__esModule",{value:!0}),oe.useSocketIO=void 0;var S=N,O=Ke(),E=B(),f={type:"empty",payload:null},_=function(d){if(!d||!d.data)return f;var c=d.data.match(/\[.*]/);if(!c)return f;var s=JSON.parse(c);return!Array.isArray(s)||!s[1]?f:{type:s[0],payload:s[1]}},y=function(d,c,s){c===void 0&&(c=E.DEFAULT_OPTIONS),s===void 0&&(s=!0);var u=(0,S.useMemo)(function(){return r(r({},c),{fromSocketIO:!0})},[]),a=(0,O.useWebSocket)(d,u,s),i=a.sendMessage,t=a.sendJsonMessage,n=a.lastMessage,v=a.readyState,h=a.getWebSocket,o=(0,S.useMemo)(function(){return _(n)},[n]);return{sendMessage:i,sendJsonMessage:t,lastMessage:o,lastJsonMessage:o,readyState:v,getWebSocket:h}};return oe.useSocketIO=y,oe}var X={},Rr;function St(){if(Rr)return X;Rr=1;var r=X&&X.__assign||function(){return r=Object.assign||function(y){for(var d,c=1,s=arguments.length;c<s;c++){d=arguments[c];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(y[u]=d[u])}return y},r.apply(this,arguments)},S=X&&X.__rest||function(y,d){var c={};for(var s in y)Object.prototype.hasOwnProperty.call(y,s)&&d.indexOf(s)<0&&(c[s]=y[s]);if(y!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,s=Object.getOwnPropertySymbols(y);u<s.length;u++)d.indexOf(s[u])<0&&Object.prototype.propertyIsEnumerable.call(y,s[u])&&(c[s[u]]=y[s[u]]);return c};Object.defineProperty(X,"__esModule",{value:!0}),X.useEventSource=void 0;var O=N,E=Ke(),f=B(),_=function(y,d,c){d===void 0&&(d=f.DEFAULT_EVENT_SOURCE_OPTIONS);var s=d.withCredentials,u=d.events,a=S(d,["withCredentials","events"]);c===void 0&&(c=!0);var i=r(r({},a),{eventSourceOptions:{withCredentials:s}}),t=(0,O.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(t.current=u);var n=(0,E.useWebSocket)(y,i,c),v=n.lastMessage,h=n.readyState,o=n.getWebSocket;return(0,O.useEffect)(function(){v?.type&&Object.entries(t.current).forEach(function(b){var R=b[0],k=b[1];R===v.type&&k(v)})},[v]),{lastEvent:v,readyState:h,getEventSource:o}};return X.useEventSource=_,X}var wr;function ht(){return wr||(wr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetGlobalState=r.useEventSource=r.ReadyState=r.useSocketIO=r.default=void 0;var S=Ke();Object.defineProperty(r,"default",{enumerable:!0,get:function(){return S.useWebSocket}});var O=yt();Object.defineProperty(r,"useSocketIO",{enumerable:!0,get:function(){return O.useSocketIO}});var E=B();Object.defineProperty(r,"ReadyState",{enumerable:!0,get:function(){return E.ReadyState}});var f=St();Object.defineProperty(r,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var _=Be();Object.defineProperty(r,"resetGlobalState",{enumerable:!0,get:function(){return _.resetGlobalState}})})(je)),je}var bt=ht();const gt=nt(bt),V={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},Ot=3e4,pt=({socketUrl:r,socketHandlers:S={},options:O={}})=>{const E=N.useRef(!1),f=N.useRef(S),{sendMessage:_,sendJsonMessage:y,lastMessage:d,readyState:c}=gt(r,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>E.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...O}),s=N.useMemo(()=>{try{return JSON.parse(d?.data)}catch{return null}},[d?.data]);return N.useEffect(()=>{const u=setInterval(()=>_("ping"),Ot);return()=>clearInterval(u)},[_]),N.useEffect(()=>{f.current=S},[S]),N.useEffect(()=>{if(!s)return;const{onDeposit:u,onTransCode:a,onError:i,onUpdateMember:t,onMaintainNotice:n,onMaintainNoticeMember:v,onReload:h,onTransferInGame:o,onCashRegisterLimit:b}=f.current,R=we.get(s,"type",""),k={memberInfoUid:we.get(s,"member_info_uid",null),data:we.get(s,"data",null),memo:we.get(s,"memo",null)};switch(R){case V.DEPOSIT:u?.(k);break;case V.TRANS_CODE:a?.(k);break;case V.ERROR:i?.(k);break;case V.UPDATE_MEMBER:t?.(k);break;case V.MAINTAIN_NOTICE:n?.(k);break;case V.MAINTAIN_NOTICE_MEMBER:v?.(k);break;case V.RELOAD:h?.(k);break;case V.TRANSFER_IN_GAME:case V.CHECK_REQUEST:o?.(k);break;case V.CASH_REGISTER_LIMIT:b?.(k);break;default:console.warn("Unknown socket type:",R);break}},[s]),N.useEffect(()=>()=>E.current=!0,[]),{sendMessage:_,sendJsonMessage:y,readyState:c}},kr=()=>{const{client:r}=be(),S=N.useCallback(async()=>{const{data:E}=await r.get("/carousels");return E},[r]),O=N.useCallback(async()=>await r.get("/marquees"),[r]);return{commonCarouselApi:S,commonMarqueeApi:O}},mt=()=>{const{commonCarouselApi:r}=kr();return $.useQuery({queryKey:["getCarouselList"],queryFn:async()=>await r()})},Tt=()=>{const{commonMarqueeApi:r}=kr();return $.useQuery({queryKey:["getMarqueeList"],queryFn:async()=>r(),select:S=>S.Marquees})},Ct=({refetchInterval:r=5e4,trigger:S=[],enabled:O=!0}={})=>{const{getToken:E}=be(),{userInfoApi:f}=Je(),_=$.useQueries({queries:[{queryKey:["getMemberInfo",...S],queryFn:async()=>await f(),refetchInterval:r,enabled:!!E&&O}]}),{data:y,isFetching:d,error:c}=_[0]||{};return{data:y,isFetching:d,error:c}},Rt=({enabled:r=!0}={})=>{const{userInfoApi:S,userFavoriteGameApi:O,userGameListApi:E,userCurrencyExchangeApi:f}=Je(),_=$.useQuery({queryKey:["getMemInfo"],queryFn:async()=>S(),enabled:r}),y=$.useQuery({queryKey:["getFavoriteGame"],queryFn:async()=>O(),enabled:r&&_.isSuccess}),d=$.useQuery({queryKey:["getUserGameList"],queryFn:async()=>E(),enabled:r&&_.isSuccess&&y.isSuccess}),c=$.useQuery({queryKey:["getUserCurrencyExchange"],queryFn:async()=>f(),enabled:r&&_.isSuccess&&y.isSuccess&&d.isSuccess});return[_,y,d,c]};exports.ApiCtx=Ge;exports.ApiProvider=it;exports.createLogoutHandler=st;exports.useApiContext=be;exports.useBalanceGetter=lt;exports.useClientWebSocket=pt;exports.useGetCarouseList=mt;exports.useGetMarquee=Tt;exports.useGetMemberInfo=Ct;exports.useInitializeWithToken=Rt;
|
|
14
|
+
<%s key={someKey} {...props} />`,De,ne,Zr,ne),cr[ne+De]=!0}}return e===E?Yr(L):Kr(L),L}}function Qr(e,l,g){return ir(e,l,g,!0)}function xr(e,l,g){return ir(e,l,g,!1)}var zr=xr,Xr=Qr;ye.Fragment=E,ye.jsx=zr,ye.jsxs=Xr})()),ye}var fr;function ot(){return fr||(fr=1,process.env.NODE_ENV==="production"?Ae.exports=at():Ae.exports=ut()),Ae.exports}var dr=ot();const Ge=N.createContext(null),be=()=>{const r=N.useContext(Ge);if(!r)throw new Error("useApiContext must be used within ApiProvider");return r};function ct({baseURL:r,getToken:S,timeoutMs:O=15e3,lng:E="tw",store:f,onError:_}={}){const y=rt.create({baseURL:r,timeout:O,headers:{"Content-Type":"application/json"}});return y.interceptors.request.use(async d=>{if(d.headers=d.headers||{},S){const s=await S();s&&(d.headers.Authorization=`Bearer ${s}`)}const c=f?.getState()?.isWalletCurrency;return d.headers.Currency=c,d.headers["currency-code"]=c,d.headers.lang=E,d}),y.interceptors.response.use(d=>d.data,d=>_?_(d,{instance:y}):Promise.reject(d)),y}function it({children:r,...S}){const O=N.useMemo(()=>ct(S),[S]),f=N.useMemo(()=>new $.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return dr.jsx($.QueryClientProvider,{client:f,children:dr.jsx(Ge.Provider,{value:{client:O,...S},children:r})})}const st=()=>{const r=(E,f)=>!E&&!f,S=E=>E.startsWith("pc.");return{executeLogout:({isCallBackInvalid:E=!1,hostname:f="",shouldRedirect:_,onShowError:y,onCleanup:d,onRemoveToken:c,onRedirect:s,onGoogleLogout:u})=>{const a=S(f);r(E,a)&&y?.(),d?.(),c?.(),_&&s?.("/"),u?.()},shouldShowErrorNotice:r,isMachineDomain:S}},Je=()=>{const{client:r}=be(),S=N.useCallback(async y=>{const{mac_address:d="",app_version:c="",anydesk_id:s=""}=y,{data:u}=await r.post("/cash-register/login",{mac_address:d,app_version:c,anydesk_id:s});return u},[r]),O=N.useCallback(async()=>r.get("/member/getMemberInfo"),[r]),E=N.useCallback(async()=>await r.get("member/getGameList"),[r]),f=N.useCallback(async()=>await r.get("/member/getNowCurrencyExchange"),[r]),_=N.useCallback(async()=>await r.get("member/getFavoriteGame"),[r]);return{machineLoginApi:S,userInfoApi:O,userGameListApi:E,userFavoriteGameApi:_,userCurrencyExchangeApi:f}},lt=({otherQueryKey:r=[],options:S={}}={})=>{const{userCurrencyExchangeApi:O}=Je(),{getToken:E}=be(),{enabled:f,..._}=S,y=!!E&&(f?f.every(d=>d):!0);return $.useQueries({queries:[{queryKey:["userCurrencyExchange",...r],queryFn:()=>O(),enabled:y,..._}]})},ft=({refetchInterval:r=5e4,trigger:S=[],enabled:O=!0}={})=>{const{getToken:E}=be(),{userInfoApi:f}=Je(),_=$.useQueries({queries:[{queryKey:["getMemberInfo",...S],queryFn:async()=>await f(),refetchInterval:r,enabled:!!E&&O}]}),{data:y,isFetching:d,error:c}=_[0]||{};return{data:y,isFetching:d,error:c}},dt=({enabled:r=!0}={})=>{const{userInfoApi:S,userFavoriteGameApi:O,userGameListApi:E,userCurrencyExchangeApi:f}=Je(),_=$.useQuery({queryKey:["getMemInfo"],queryFn:async()=>S(),enabled:r}),y=$.useQuery({queryKey:["getFavoriteGame"],queryFn:async()=>O(),enabled:r&&_.isSuccess}),d=$.useQuery({queryKey:["getUserGameList"],queryFn:async()=>E(),enabled:r&&_.isSuccess&&y.isSuccess}),c=$.useQuery({queryKey:["getUserCurrencyExchange"],queryFn:async()=>f(),enabled:r&&_.isSuccess&&y.isSuccess&&d.isSuccess});return[_,y,d,c]};var je={},q={},Ue={},vr;function B(){return vr||(vr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.isEventSourceSupported=r.isReactNative=r.ReadyState=r.DEFAULT_HEARTBEAT=r.UNPARSABLE_JSON_OBJECT=r.DEFAULT_RECONNECT_INTERVAL_MS=r.DEFAULT_RECONNECT_LIMIT=r.SOCKET_IO_PING_CODE=r.SOCKET_IO_PATH=r.SOCKET_IO_PING_INTERVAL=r.DEFAULT_EVENT_SOURCE_OPTIONS=r.EMPTY_EVENT_HANDLERS=r.DEFAULT_OPTIONS=void 0;var S=1,O=1e3*S;r.DEFAULT_OPTIONS={},r.EMPTY_EVENT_HANDLERS={},r.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:r.EMPTY_EVENT_HANDLERS},r.SOCKET_IO_PING_INTERVAL=25*O,r.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",r.SOCKET_IO_PING_CODE="2",r.DEFAULT_RECONNECT_LIMIT=20,r.DEFAULT_RECONNECT_INTERVAL_MS=5e3,r.UNPARSABLE_JSON_OBJECT={},r.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var E;(function(_){_[_.UNINSTANTIATED=-1]="UNINSTANTIATED",_[_.CONNECTING=0]="CONNECTING",_[_.OPEN=1]="OPEN",_[_.CLOSING=2]="CLOSING",_[_.CLOSED=3]="CLOSED"})(E||(r.ReadyState=E={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};r.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",r.isEventSourceSupported=!r.isReactNative&&f()})(Ue)),Ue}var Se={},We={},Er;function He(){return Er||(Er=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetWebSockets=r.sharedWebSockets=void 0,r.sharedWebSockets={};var S=function(O){if(O&&r.sharedWebSockets.hasOwnProperty(O))delete r.sharedWebSockets[O];else for(var E in r.sharedWebSockets)r.sharedWebSockets.hasOwnProperty(E)&&delete r.sharedWebSockets[E]};r.resetWebSockets=S})(We)),We}var ae={},x={},_r;function Ve(){if(_r)return x;_r=1,Object.defineProperty(x,"__esModule",{value:!0}),x.setUpSocketIOPing=x.appendQueryParams=x.parseSocketIOUrl=void 0;var r=B(),S=function(f){if(f){var _=/^https|wss/.test(f),y=f.replace(/^(https?|wss?)(:\/\/)?/,""),d=y.replace(/\/$/,""),c=_?"wss":"ws";return"".concat(c,"://").concat(d).concat(r.SOCKET_IO_PATH)}else if(f===""){var _=/^https/.test(window.location.protocol),c=_?"wss":"ws",s=window.location.port?":".concat(window.location.port):"";return"".concat(c,"://").concat(window.location.hostname).concat(s).concat(r.SOCKET_IO_PATH)}return f};x.parseSocketIOUrl=S;var O=function(f,_){_===void 0&&(_={});var y=/\?([\w]+=[\w]+)/,d=y.test(f),c="".concat(Object.entries(_).reduce(function(s,u){var a=u[0],i=u[1];return s+"".concat(a,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(d?"&":"?").concat(c)};x.appendQueryParams=O;var E=function(f,_){_===void 0&&(_=r.SOCKET_IO_PING_INTERVAL);var y=function(){return f(r.SOCKET_IO_PING_CODE)};return window.setInterval(y,_)};return x.setUpSocketIOPing=E,x}var ke={},yr;function Ar(){if(yr)return ke;yr=1,Object.defineProperty(ke,"__esModule",{value:!0}),ke.heartbeat=O;var r=B();function S(E){return Array.isArray(E)?E.reduce(function(f,_){return f.current>_.current?f:_}).current:E.current}function O(E,f,_){var y=_||{},d=y.interval,c=d===void 0?r.DEFAULT_HEARTBEAT.interval:d,s=y.timeout,u=s===void 0?r.DEFAULT_HEARTBEAT.timeout:s,a=y.message,i=a===void 0?r.DEFAULT_HEARTBEAT.message:a,t=Math.max(100,c/10),n=Date.now(),v=setInterval(function(){var h=Date.now(),o=S(f);if(o+u<=h)console.warn("Heartbeat timed out, closing connection, last message received ".concat(h-o,"ms ago, last ping sent ").concat(h-n,"ms ago")),E.close();else if(o+c<=h&&n+c<=h)try{typeof i=="function"?E.send(i()):E.send(i),n=h}catch(b){console.error("Heartbeat failed, closing connection",b instanceof Error?b.message:b),E.close()}},t);return E.addEventListener("close",function(){clearInterval(v)}),function(){}}return ke}var he={},Fe={},Sr;function $e(){return Sr||(Sr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetSubscribers=r.removeSubscriber=r.addSubscriber=r.hasSubscribers=r.getSubscribers=void 0;var S={},O=[],E=function(c){return(0,r.hasSubscribers)(c)?Array.from(S[c]):O};r.getSubscribers=E;var f=function(c){var s;return((s=S[c])===null||s===void 0?void 0:s.size)>0};r.hasSubscribers=f;var _=function(c,s){S[c]=S[c]||new Set,S[c].add(s)};r.addSubscriber=_;var y=function(c,s){S[c].delete(s)};r.removeSubscriber=y;var d=function(c){if(c&&S.hasOwnProperty(c))delete S[c];else for(var s in S)S.hasOwnProperty(s)&&delete S[s]};r.resetSubscribers=d})(Fe)),Fe}var hr;function Be(){if(hr)return he;hr=1,Object.defineProperty(he,"__esModule",{value:!0}),he.assertIsWebSocket=O,he.resetGlobalState=E;var r=He(),S=$e();function O(f,_){if(!_&&!(f instanceof WebSocket))throw new Error("")}function E(f){(0,S.resetSubscribers)(f),(0,r.resetWebSockets)(f)}return he}var br;function vt(){if(br)return ae;br=1;var r=ae&&ae.__assign||function(){return r=Object.assign||function(u){for(var a,i=1,t=arguments.length;i<t;i++){a=arguments[i];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(u[n]=a[n])}return u},r.apply(this,arguments)};Object.defineProperty(ae,"__esModule",{value:!0}),ae.attachListeners=void 0;var S=Ve(),O=Ar(),E=B(),f=Be(),_=function(u,a,i,t){u.onmessage=function(n){var v;a.current.onMessage&&a.current.onMessage(n),typeof t?.current=="number"&&(t.current=Date.now()),!(typeof a.current.filter=="function"&&a.current.filter(n)!==!0)&&(a.current.heartbeat&&typeof a.current.heartbeat!="boolean"&&((v=a.current.heartbeat)===null||v===void 0?void 0:v.returnMessage)===n.data||i(n))}},y=function(u,a,i,t,n){u.onopen=function(v){if(a.current.onOpen&&a.current.onOpen(v),t.current=0,i(E.ReadyState.OPEN),a.current.heartbeat&&u instanceof WebSocket){var h=typeof a.current.heartbeat=="boolean"?void 0:a.current.heartbeat;n.current=Date.now(),(0,O.heartbeat)(u,n,h)}}},d=function(u,a,i,t,n){if(E.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,a.current.skipAssert);var v;return u.onclose=function(h){var o;if(a.current.onClose&&a.current.onClose(h),i(E.ReadyState.CLOSED),a.current.shouldReconnect&&a.current.shouldReconnect(h)){var b=(o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT;if(n.current<b){var R=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},R??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(b),console.warn("Max reconnect attempts of ".concat(b," exceeded"))}},function(){return v&&window.clearTimeout(v)}},c=function(u,a,i,t,n){var v;return u.onerror=function(h){var o;if(a.current.onError&&a.current.onError(h),E.isEventSourceSupported&&u instanceof EventSource&&(a.current.onClose&&a.current.onClose(r(r({},h),{code:1006,reason:"An error occurred with the EventSource: ".concat(h),wasClean:!1})),i(E.ReadyState.CLOSED),u.close()),a.current.retryOnError)if(n.current<((o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT)){var b=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},b??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(a.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts," exceeded"))},function(){return v&&window.clearTimeout(v)}},s=function(u,a,i,t,n,v,h){var o=a.setLastMessage,b=a.setReadyState,R,k,m;return i.current.fromSocketIO&&(R=(0,S.setUpSocketIOPing)(h)),_(u,i,o,v),y(u,i,b,n,v),k=d(u,i,b,t,n),m=c(u,i,b,t,n),function(){b(E.ReadyState.CLOSING),k(),m(),u.close(),R&&clearInterval(R)}};return ae.attachListeners=s,ae}var ue={},gr;function Et(){if(gr)return ue;gr=1;var r=ue&&ue.__assign||function(){return r=Object.assign||function(a){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var v in i)Object.prototype.hasOwnProperty.call(i,v)&&(a[v]=i[v])}return a},r.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.attachSharedListeners=void 0;var S=He(),O=B(),E=$e(),f=Ve(),_=Ar(),y=function(a,i,t){a.onmessage=function(n){(0,E.getSubscribers)(i).forEach(function(v){var h;v.optionsRef.current.onMessage&&v.optionsRef.current.onMessage(n),typeof((h=v?.lastMessageTime)===null||h===void 0?void 0:h.current)=="number"&&(v.lastMessageTime.current=Date.now()),!(typeof v.optionsRef.current.filter=="function"&&v.optionsRef.current.filter(n)!==!0)&&(t&&typeof t!="boolean"&&t?.returnMessage===n.data||v.setLastMessage(n))})}},d=function(a,i,t){a.onopen=function(n){var v=(0,E.getSubscribers)(i);v.forEach(function(h){h.reconnectCount.current=0,h.optionsRef.current.onOpen&&h.optionsRef.current.onOpen(n),h.setReadyState(O.ReadyState.OPEN),t&&a instanceof WebSocket&&(h.lastMessageTime.current=Date.now())}),t&&a instanceof WebSocket&&(0,_.heartbeat)(a,v.map(function(h){return h.lastMessageTime}),typeof t=="boolean"?void 0:t)}},c=function(a,i){a instanceof WebSocket&&(a.onclose=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onClose&&n.optionsRef.current.onClose(t),n.setReadyState(O.ReadyState.CLOSED)}),delete S.sharedWebSockets[i],(0,E.getSubscribers)(i).forEach(function(n){var v;if(n.optionsRef.current.shouldReconnect&&n.optionsRef.current.shouldReconnect(t)){var h=(v=n.optionsRef.current.reconnectAttempts)!==null&&v!==void 0?v:O.DEFAULT_RECONNECT_LIMIT;if(n.reconnectCount.current<h){var o=typeof n.optionsRef.current.reconnectInterval=="function"?n.optionsRef.current.reconnectInterval(n.reconnectCount.current):n.optionsRef.current.reconnectInterval;setTimeout(function(){n.reconnectCount.current++,n.reconnect.current()},o??O.DEFAULT_RECONNECT_INTERVAL_MS)}else n.optionsRef.current.onReconnectStop&&n.optionsRef.current.onReconnectStop(n.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(h," exceeded"))}})})},s=function(a,i){a.onerror=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onError&&n.optionsRef.current.onError(t),O.isEventSourceSupported&&a instanceof EventSource&&(n.optionsRef.current.onClose&&n.optionsRef.current.onClose(r(r({},t),{code:1006,reason:"An error occurred with the EventSource: ".concat(t),wasClean:!1})),n.setReadyState(O.ReadyState.CLOSED))}),O.isEventSourceSupported&&a instanceof EventSource&&a.close()}},u=function(a,i,t,n){var v;return t.current.fromSocketIO&&(v=(0,f.setUpSocketIOPing)(n)),y(a,i,t.current.heartbeat),c(a,i),d(a,i,t.current.heartbeat),s(a,i),function(){v&&clearInterval(v)}};return ue.attachSharedListeners=u,ue}var Or;function _t(){if(Or)return Se;Or=1,Object.defineProperty(Se,"__esModule",{value:!0}),Se.createOrJoinSocket=void 0;var r=He(),S=B(),O=vt(),E=Et(),f=$e(),_=function(d,c,s,u,a){return function(){if((0,f.removeSubscriber)(d,c),!(0,f.hasSubscribers)(d)){try{var i=r.sharedWebSockets[d];i instanceof WebSocket&&(i.onclose=function(t){s.current.onClose&&s.current.onClose(t),u(S.ReadyState.CLOSED)}),i.close()}catch{}a&&a(),delete r.sharedWebSockets[d]}}},y=function(d,c,s,u,a,i,t,n,v){if(!S.isEventSourceSupported&&u.current.eventSourceOptions)throw S.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var h=null;r.sharedWebSockets[c]===void 0?(r.sharedWebSockets[c]=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),d.current=r.sharedWebSockets[c],s(S.ReadyState.CONNECTING),h=(0,E.attachSharedListeners)(r.sharedWebSockets[c],c,u,v)):(d.current=r.sharedWebSockets[c],s(r.sharedWebSockets[c].readyState));var o={setLastMessage:a,setReadyState:s,optionsRef:u,reconnectCount:t,lastMessageTime:n,reconnect:i};return(0,f.addSubscriber)(c,o),_(c,o,u,s,h)}else{if(d.current=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),s(S.ReadyState.CONNECTING),!d.current)throw new Error("WebSocket failed to be created");return(0,O.attachListeners)(d.current,{setLastMessage:a,setReadyState:s},u,i.current,t,n,v)}};return Se.createOrJoinSocket=y,Se}var z={},pr;function yt(){return pr||(pr=1,(function(r){var S=z&&z.__awaiter||function(c,s,u,a){function i(t){return t instanceof u?t:new u(function(n){n(t)})}return new(u||(u=Promise))(function(t,n){function v(b){try{o(a.next(b))}catch(R){n(R)}}function h(b){try{o(a.throw(b))}catch(R){n(R)}}function o(b){b.done?t(b.value):i(b.value).then(v,h)}o((a=a.apply(c,s||[])).next())})},O=z&&z.__generator||function(c,s){var u={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=v(0),n.throw=v(1),n.return=v(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function v(o){return function(b){return h([o,b])}}function h(o){if(a)throw new TypeError("Generator is already executing.");for(;n&&(n=0,o[0]&&(u=0)),u;)try{if(a=1,i&&(t=o[0]&2?i.return:o[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,o[1])).done)return t;switch(i=0,t&&(o=[o[0]&2,t.value]),o[0]){case 0:case 1:t=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,i=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(t=u.trys,!(t=t.length>0&&t[t.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!t||o[1]>t[0]&&o[1]<t[3])){u.label=o[1];break}if(o[0]===6&&u.label<t[1]){u.label=t[1],t=o;break}if(t&&u.label<t[2]){u.label=t[2],u.ops.push(o);break}t[2]&&u.ops.pop(),u.trys.pop();continue}o=s.call(c,u)}catch(b){o=[6,b],i=0}finally{a=t=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},E=z&&z.__spreadArray||function(c,s,u){if(u||arguments.length===2)for(var a=0,i=s.length,t;a<i;a++)(t||!(a in s))&&(t||(t=Array.prototype.slice.call(s,0,a)),t[a]=s[a]);return c.concat(t||Array.prototype.slice.call(s))};Object.defineProperty(r,"__esModule",{value:!0}),r.getUrl=void 0;var f=Ve(),_=B(),y=function(c){return new Promise(function(s){return window.setTimeout(s,c)})},d=function(c,s){for(var u=[],a=2;a<arguments.length;a++)u[a-2]=arguments[a];return S(void 0,E([c,s],u,!0),void 0,function(i,t,n){var v,h,o,b,R,k,m,A;return n===void 0&&(n=0),O(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return v=I.sent(),[3,9];case 3:return I.sent(),t.current.retryOnError?(h=(k=t.current.reconnectAttempts)!==null&&k!==void 0?k:_.DEFAULT_RECONNECT_LIMIT,n<h?(o=typeof t.current.reconnectInterval=="function"?t.current.reconnectInterval(n):t.current.reconnectInterval,[4,y(o??_.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,r.getUrl)(i,t,n+1)];case 5:return(A=(m=t.current).onReconnectStop)===null||A===void 0||A.call(m,n),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:v=i,I.label=11;case 11:return b=t.current.fromSocketIO?(0,f.parseSocketIOUrl)(v):v,R=t.current.queryParams?(0,f.appendQueryParams)(b,t.current.queryParams):b,[2,R]}})})};r.getUrl=d})(z)),z}var qe={},mr;function St(){return mr||(mr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.websocketWrapper=void 0;var S=function(O,E){return new Proxy(O,{get:function(f,_){var y=f[_];return _==="reconnect"?E:typeof y=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):y},set:function(f,_,y){return/^on/.test(_)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[_]=y,!0)}})};r.websocketWrapper=S,r.default=r.websocketWrapper})(qe)),qe}var Tr;function Ke(){if(Tr)return q;Tr=1;var r=q&&q.__assign||function(){return r=Object.assign||function(i){for(var t,n=1,v=arguments.length;n<v;n++){t=arguments[n];for(var h in t)Object.prototype.hasOwnProperty.call(t,h)&&(i[h]=t[h])}return i},r.apply(this,arguments)},S=q&&q.__awaiter||function(i,t,n,v){function h(o){return o instanceof n?o:new n(function(b){b(o)})}return new(n||(n=Promise))(function(o,b){function R(A){try{m(v.next(A))}catch(I){b(I)}}function k(A){try{m(v.throw(A))}catch(I){b(I)}}function m(A){A.done?o(A.value):h(A.value).then(R,k)}m((v=v.apply(i,t||[])).next())})},O=q&&q.__generator||function(i,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},v,h,o,b=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return b.next=R(0),b.throw=R(1),b.return=R(2),typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function R(m){return function(A){return k([m,A])}}function k(m){if(v)throw new TypeError("Generator is already executing.");for(;b&&(b=0,m[0]&&(n=0)),n;)try{if(v=1,h&&(o=m[0]&2?h.return:m[0]?h.throw||((o=h.return)&&o.call(h),0):h.next)&&!(o=o.call(h,m[1])).done)return o;switch(h=0,o&&(m=[m[0]&2,o.value]),m[0]){case 0:case 1:o=m;break;case 4:return n.label++,{value:m[1],done:!1};case 5:n.label++,h=m[1],m=[0];continue;case 7:m=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(m[0]===6||m[0]===2)){n=0;continue}if(m[0]===3&&(!o||m[1]>o[0]&&m[1]<o[3])){n.label=m[1];break}if(m[0]===6&&n.label<o[1]){n.label=o[1],o=m;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(m);break}o[2]&&n.ops.pop(),n.trys.pop();continue}m=t.call(i,n)}catch(A){m=[6,A],h=0}finally{v=o=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},E=q&&q.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(q,"__esModule",{value:!0}),q.useWebSocket=void 0;var f=N,_=tt,y=B(),d=_t(),c=yt(),s=E(St()),u=Be(),a=function(i,t,n){t===void 0&&(t=y.DEFAULT_OPTIONS),n===void 0&&(n=!0);var v=(0,f.useState)(null),h=v[0],o=v[1],b=(0,f.useState)({}),R=b[0],k=b[1],m=(0,f.useMemo)(function(){if(!t.disableJson&&h)try{return JSON.parse(h.data)}catch{return y.UNPARSABLE_JSON_OBJECT}return null},[h,t.disableJson]),A=(0,f.useRef)(null),I=(0,f.useRef)(null),fe=(0,f.useRef)(function(){}),de=(0,f.useRef)(0),Pe=(0,f.useRef)(Date.now()),ge=(0,f.useRef)([]),H=(0,f.useRef)(null),j=(0,f.useRef)(t);j.current=t;var J=A.current&&R[A.current]!==void 0?R[A.current]:i!==null&&n===!0?y.ReadyState.CONNECTING:y.ReadyState.UNINSTANTIATED,ee=t.queryParams?JSON.stringify(t.queryParams):null,K=(0,f.useCallback)(function(D,U){var Y;if(U===void 0&&(U=!0),y.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===y.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),I.current.send(D)):U&&ge.current.push(D)},[]),Oe=(0,f.useCallback)(function(D,U){U===void 0&&(U=!0),K(JSON.stringify(D),U)},[K]),pe=(0,f.useCallback)(function(){return j.current.share!==!0||y.isEventSourceSupported&&I.current instanceof EventSource?I.current:(H.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),H.current=(0,s.default)(I.current,fe)),H.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&n===!0){var D,U=!1,Y=!0,ve=function(){return S(void 0,void 0,void 0,function(){var re,Z,me;return O(this,function(ce){switch(ce.label){case 0:return re=A,[4,(0,c.getUrl)(i,j)];case 1:return re.current=ce.sent(),A.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),A.current="ABORTED",(0,_.flushSync)(function(){return k(function(Q){return r(r({},Q),{ABORTED:y.ReadyState.CLOSED})})}),[2]):(Z=function(Q){U||(0,_.flushSync)(function(){return o(Q)})},me=function(Q){U||(0,_.flushSync)(function(){return k(function(ie){var te;return r(r({},ie),A.current&&(te={},te[A.current]=Q,te))})})},Y&&(D=(0,d.createOrJoinSocket)(I,A.current,me,j,Z,fe,de,Pe,K)),[2])}})})};return fe.current=function(){U||(H.current&&(H.current=null),D?.(),ve())},ve(),function(){U=!0,Y=!1,H.current&&(H.current=null),D?.(),o(null)}}else(i===null||n===!1)&&(de.current=0,k(function(re){var Z;return r(r({},re),A.current&&(Z={},Z[A.current]=y.ReadyState.CLOSED,Z))}))},[i,n,ee,K]),(0,f.useEffect)(function(){J===y.ReadyState.OPEN&&ge.current.splice(0).forEach(function(D){K(D)})},[J]),{sendMessage:K,sendJsonMessage:Oe,lastMessage:h,lastJsonMessage:m,readyState:J,getWebSocket:pe}};return q.useWebSocket=a,q}var oe={},Cr;function ht(){if(Cr)return oe;Cr=1;var r=oe&&oe.__assign||function(){return r=Object.assign||function(d){for(var c,s=1,u=arguments.length;s<u;s++){c=arguments[s];for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&(d[a]=c[a])}return d},r.apply(this,arguments)};Object.defineProperty(oe,"__esModule",{value:!0}),oe.useSocketIO=void 0;var S=N,O=Ke(),E=B(),f={type:"empty",payload:null},_=function(d){if(!d||!d.data)return f;var c=d.data.match(/\[.*]/);if(!c)return f;var s=JSON.parse(c);return!Array.isArray(s)||!s[1]?f:{type:s[0],payload:s[1]}},y=function(d,c,s){c===void 0&&(c=E.DEFAULT_OPTIONS),s===void 0&&(s=!0);var u=(0,S.useMemo)(function(){return r(r({},c),{fromSocketIO:!0})},[]),a=(0,O.useWebSocket)(d,u,s),i=a.sendMessage,t=a.sendJsonMessage,n=a.lastMessage,v=a.readyState,h=a.getWebSocket,o=(0,S.useMemo)(function(){return _(n)},[n]);return{sendMessage:i,sendJsonMessage:t,lastMessage:o,lastJsonMessage:o,readyState:v,getWebSocket:h}};return oe.useSocketIO=y,oe}var X={},Rr;function bt(){if(Rr)return X;Rr=1;var r=X&&X.__assign||function(){return r=Object.assign||function(y){for(var d,c=1,s=arguments.length;c<s;c++){d=arguments[c];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(y[u]=d[u])}return y},r.apply(this,arguments)},S=X&&X.__rest||function(y,d){var c={};for(var s in y)Object.prototype.hasOwnProperty.call(y,s)&&d.indexOf(s)<0&&(c[s]=y[s]);if(y!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,s=Object.getOwnPropertySymbols(y);u<s.length;u++)d.indexOf(s[u])<0&&Object.prototype.propertyIsEnumerable.call(y,s[u])&&(c[s[u]]=y[s[u]]);return c};Object.defineProperty(X,"__esModule",{value:!0}),X.useEventSource=void 0;var O=N,E=Ke(),f=B(),_=function(y,d,c){d===void 0&&(d=f.DEFAULT_EVENT_SOURCE_OPTIONS);var s=d.withCredentials,u=d.events,a=S(d,["withCredentials","events"]);c===void 0&&(c=!0);var i=r(r({},a),{eventSourceOptions:{withCredentials:s}}),t=(0,O.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(t.current=u);var n=(0,E.useWebSocket)(y,i,c),v=n.lastMessage,h=n.readyState,o=n.getWebSocket;return(0,O.useEffect)(function(){v?.type&&Object.entries(t.current).forEach(function(b){var R=b[0],k=b[1];R===v.type&&k(v)})},[v]),{lastEvent:v,readyState:h,getEventSource:o}};return X.useEventSource=_,X}var wr;function gt(){return wr||(wr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetGlobalState=r.useEventSource=r.ReadyState=r.useSocketIO=r.default=void 0;var S=Ke();Object.defineProperty(r,"default",{enumerable:!0,get:function(){return S.useWebSocket}});var O=ht();Object.defineProperty(r,"useSocketIO",{enumerable:!0,get:function(){return O.useSocketIO}});var E=B();Object.defineProperty(r,"ReadyState",{enumerable:!0,get:function(){return E.ReadyState}});var f=bt();Object.defineProperty(r,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var _=Be();Object.defineProperty(r,"resetGlobalState",{enumerable:!0,get:function(){return _.resetGlobalState}})})(je)),je}var Ot=gt();const pt=nt(Ot),V={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},mt=3e4,Tt=({socketUrl:r,socketHandlers:S={},options:O={}})=>{const E=N.useRef(!1),f=N.useRef(S),{sendMessage:_,sendJsonMessage:y,lastMessage:d,readyState:c}=pt(r,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>E.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...O}),s=N.useMemo(()=>{try{return JSON.parse(d?.data)}catch{return null}},[d?.data]);return N.useEffect(()=>{const u=setInterval(()=>_("ping"),mt);return()=>clearInterval(u)},[_]),N.useEffect(()=>{f.current=S},[S]),N.useEffect(()=>{if(!s)return;const{onDeposit:u,onTransCode:a,onError:i,onUpdateMember:t,onMaintainNotice:n,onMaintainNoticeMember:v,onReload:h,onTransferInGame:o,onCashRegisterLimit:b}=f.current,R=we.get(s,"type",""),k={memberInfoUid:we.get(s,"member_info_uid",null),data:we.get(s,"data",null),memo:we.get(s,"memo",null)};switch(R){case V.DEPOSIT:u?.(k);break;case V.TRANS_CODE:a?.(k);break;case V.ERROR:i?.(k);break;case V.UPDATE_MEMBER:t?.(k);break;case V.MAINTAIN_NOTICE:n?.(k);break;case V.MAINTAIN_NOTICE_MEMBER:v?.(k);break;case V.RELOAD:h?.(k);break;case V.TRANSFER_IN_GAME:case V.CHECK_REQUEST:o?.(k);break;case V.CASH_REGISTER_LIMIT:b?.(k);break;default:console.warn("Unknown socket type:",R);break}},[s]),N.useEffect(()=>()=>E.current=!0,[]),{sendMessage:_,sendJsonMessage:y,readyState:c}},kr=()=>{const{client:r}=be(),S=N.useCallback(async()=>{const{data:E}=await r.get("/carousels");return E},[r]),O=N.useCallback(async()=>await r.get("/marquees"),[r]);return{commonCarouselApi:S,commonMarqueeApi:O}},Ct=()=>{const{commonCarouselApi:r}=kr();return $.useQuery({queryKey:["getCarouselList"],queryFn:async()=>await r()})},Rt=()=>{const{commonMarqueeApi:r}=kr();return $.useQuery({queryKey:["getMarqueeList"],queryFn:async()=>r(),select:S=>S.Marquees})};exports.ApiCtx=Ge;exports.ApiProvider=it;exports.createLogoutHandler=st;exports.useApiContext=be;exports.useBalanceGetter=lt;exports.useClientWebSocket=Tt;exports.useGetCarouseList=Ct;exports.useGetMarquee=Rt;exports.useGetMemberInfo=ft;exports.useInitializeWithToken=dt;
|
package/dist/index.js
CHANGED
|
@@ -714,6 +714,51 @@ const Lt = () => {
|
|
|
714
714
|
}
|
|
715
715
|
]
|
|
716
716
|
});
|
|
717
|
+
}, jt = ({
|
|
718
|
+
refetchInterval: r = 5e4,
|
|
719
|
+
trigger: S = [],
|
|
720
|
+
enabled: O = !0
|
|
721
|
+
} = {}) => {
|
|
722
|
+
const { getToken: E } = ke(), { userInfoApi: f } = Ve(), _ = kr({
|
|
723
|
+
queries: [
|
|
724
|
+
{
|
|
725
|
+
queryKey: ["getMemberInfo", ...S],
|
|
726
|
+
queryFn: async () => await f(),
|
|
727
|
+
refetchInterval: r,
|
|
728
|
+
enabled: !!E && O
|
|
729
|
+
}
|
|
730
|
+
]
|
|
731
|
+
}), { data: y, isFetching: v, error: c } = _[0] || {};
|
|
732
|
+
return { data: y, isFetching: v, error: c };
|
|
733
|
+
}, Ut = ({ enabled: r = !0 } = {}) => {
|
|
734
|
+
const {
|
|
735
|
+
userInfoApi: S,
|
|
736
|
+
userFavoriteGameApi: O,
|
|
737
|
+
userGameListApi: E,
|
|
738
|
+
userCurrencyExchangeApi: f
|
|
739
|
+
} = Ve(), _ = le({
|
|
740
|
+
queryKey: ["getMemInfo"],
|
|
741
|
+
queryFn: async () => S(),
|
|
742
|
+
enabled: r
|
|
743
|
+
}), y = le({
|
|
744
|
+
queryKey: ["getFavoriteGame"],
|
|
745
|
+
queryFn: async () => O(),
|
|
746
|
+
enabled: r && _.isSuccess
|
|
747
|
+
}), v = le({
|
|
748
|
+
queryKey: ["getUserGameList"],
|
|
749
|
+
queryFn: async () => E(),
|
|
750
|
+
enabled: r && _.isSuccess && y.isSuccess
|
|
751
|
+
}), c = le({
|
|
752
|
+
queryKey: ["getUserCurrencyExchange"],
|
|
753
|
+
queryFn: async () => f(),
|
|
754
|
+
enabled: r && _.isSuccess && y.isSuccess && v.isSuccess
|
|
755
|
+
});
|
|
756
|
+
return [
|
|
757
|
+
_,
|
|
758
|
+
y,
|
|
759
|
+
v,
|
|
760
|
+
c
|
|
761
|
+
];
|
|
717
762
|
};
|
|
718
763
|
var We = {}, F = {}, Fe = {}, yr;
|
|
719
764
|
function V() {
|
|
@@ -1507,7 +1552,7 @@ const Rt = /* @__PURE__ */ vt(Ct), H = {
|
|
|
1507
1552
|
TRANSFER_IN_GAME: "transfer_in_game",
|
|
1508
1553
|
CHECK_REQUEST: "CHECK_RREQUEST",
|
|
1509
1554
|
CASH_REGISTER_LIMIT: "cash_register_limit"
|
|
1510
|
-
}, wt = 3e4,
|
|
1555
|
+
}, wt = 3e4, Wt = ({
|
|
1511
1556
|
socketUrl: r,
|
|
1512
1557
|
socketHandlers: S = {},
|
|
1513
1558
|
options: O = {}
|
|
@@ -1607,59 +1652,19 @@ const Rt = /* @__PURE__ */ vt(Ct), H = {
|
|
|
1607
1652
|
return E;
|
|
1608
1653
|
}, [r]), O = ue(async () => await r.get("/marquees"), [r]);
|
|
1609
1654
|
return { commonCarouselApi: S, commonMarqueeApi: O };
|
|
1610
|
-
},
|
|
1655
|
+
}, Ft = () => {
|
|
1611
1656
|
const { commonCarouselApi: r } = Lr();
|
|
1612
1657
|
return le({
|
|
1613
1658
|
queryKey: ["getCarouselList"],
|
|
1614
1659
|
queryFn: async () => await r()
|
|
1615
1660
|
});
|
|
1616
|
-
},
|
|
1661
|
+
}, qt = () => {
|
|
1617
1662
|
const { commonMarqueeApi: r } = Lr();
|
|
1618
1663
|
return le({
|
|
1619
1664
|
queryKey: ["getMarqueeList"],
|
|
1620
1665
|
queryFn: async () => r(),
|
|
1621
1666
|
select: (S) => S.Marquees
|
|
1622
1667
|
});
|
|
1623
|
-
}, Ft = ({
|
|
1624
|
-
refetchInterval: r = 5e4,
|
|
1625
|
-
trigger: S = [],
|
|
1626
|
-
enabled: O = !0
|
|
1627
|
-
} = {}) => {
|
|
1628
|
-
const { getToken: E } = ke(), { userInfoApi: f } = Ve(), _ = kr({
|
|
1629
|
-
queries: [
|
|
1630
|
-
{
|
|
1631
|
-
queryKey: ["getMemberInfo", ...S],
|
|
1632
|
-
queryFn: async () => await f(),
|
|
1633
|
-
refetchInterval: r,
|
|
1634
|
-
enabled: !!E && O
|
|
1635
|
-
}
|
|
1636
|
-
]
|
|
1637
|
-
}), { data: y, isFetching: v, error: c } = _[0] || {};
|
|
1638
|
-
return { data: y, isFetching: v, error: c };
|
|
1639
|
-
}, qt = ({ enabled: r = !0 } = {}) => {
|
|
1640
|
-
const {
|
|
1641
|
-
userInfoApi: S,
|
|
1642
|
-
userFavoriteGameApi: O,
|
|
1643
|
-
userGameListApi: E,
|
|
1644
|
-
userCurrencyExchangeApi: f
|
|
1645
|
-
} = Ve(), _ = le({
|
|
1646
|
-
queryKey: ["getMemInfo"],
|
|
1647
|
-
queryFn: async () => S(),
|
|
1648
|
-
enabled: r
|
|
1649
|
-
}), y = le({
|
|
1650
|
-
queryKey: ["getFavoriteGame"],
|
|
1651
|
-
queryFn: async () => O(),
|
|
1652
|
-
enabled: r && _.isSuccess
|
|
1653
|
-
}), v = le({
|
|
1654
|
-
queryKey: ["getUserGameList"],
|
|
1655
|
-
queryFn: async () => E(),
|
|
1656
|
-
enabled: r && _.isSuccess && y.isSuccess
|
|
1657
|
-
}), c = le({
|
|
1658
|
-
queryKey: ["getUserCurrencyExchange"],
|
|
1659
|
-
queryFn: async () => f(),
|
|
1660
|
-
enabled: r && _.isSuccess && y.isSuccess && v.isSuccess
|
|
1661
|
-
});
|
|
1662
|
-
return [_, y, v, c];
|
|
1663
1668
|
};
|
|
1664
1669
|
export {
|
|
1665
1670
|
Nr as ApiCtx,
|
|
@@ -1667,9 +1672,9 @@ export {
|
|
|
1667
1672
|
Lt as createLogoutHandler,
|
|
1668
1673
|
ke as useApiContext,
|
|
1669
1674
|
Dt as useBalanceGetter,
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
+
Wt as useClientWebSocket,
|
|
1676
|
+
Ft as useGetCarouseList,
|
|
1677
|
+
qt as useGetMarquee,
|
|
1678
|
+
jt as useGetMemberInfo,
|
|
1679
|
+
Ut as useInitializeWithToken
|
|
1675
1680
|
};
|