playsout-web-sdk 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -54,7 +54,7 @@ Required parameters:
54
54
  | --- | --- |
55
55
  | `platform` | Platform identifier. Use `'grab'` or `'eros'`. |
56
56
  | `platformUserId` | Unique user ID from the host platform. |
57
- | `platformToken` | Login credential issued by the host platform for the current user. |
57
+ | `platformToken` | Random string. |
58
58
  | `username` | User display name. |
59
59
 
60
60
  Example:
@@ -63,12 +63,12 @@ Example:
63
63
  await Playsout.Login({
64
64
  platform: 'eros',
65
65
  platformUserId: '10',
66
- platformToken: 'platform_token',
66
+ platformToken: 'random-string',
67
67
  username: 'TestUser',
68
68
  });
69
69
  ```
70
70
 
71
- `platformToken` is a required, non-empty string. Playsout Web SDK does not impose any specific format or content requirements; it only validates the type and forwards the value to the backend unchanged.
71
+ `platformToken` is a required, non-empty random string.
72
72
 
73
73
  ## HTML Integration
74
74
 
@@ -96,7 +96,7 @@ Place the following code in `index.html`:
96
96
  loginPromise = window.Playsout.Login({
97
97
  platform: 'eros',
98
98
  platformUserId: '10',
99
- platformToken: 'platform_token',
99
+ platformToken: 'random-string',
100
100
  username: 'TestUser'
101
101
  }).finally(function () {
102
102
  loginPromise = null;
@@ -227,7 +227,7 @@ function login() {
227
227
  loginPromise = Login({
228
228
  platform: 'eros',
229
229
  platformUserId: '10',
230
- platformToken: 'platform_token',
230
+ platformToken: 'random-string',
231
231
  username: 'TestUser',
232
232
  }).finally(() => {
233
233
  loginPromise = null;
@@ -309,7 +309,7 @@ export default function App() {
309
309
  Login({
310
310
  platform: 'eros',
311
311
  platformUserId: '10',
312
- platformToken: 'platform_token',
312
+ platformToken: 'random-string',
313
313
  username: 'TestUser',
314
314
  })
315
315
  .catch((error) => {
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');var k=(p=>(p.NOT_INITIALIZED="NOT_INITIALIZED",p.ALREADY_INITIALIZED="ALREADY_INITIALIZED",p.NOT_LOGGED_IN="NOT_LOGGED_IN",p.TOKEN_EXPIRED="TOKEN_EXPIRED",p.INVALID_TOKEN="INVALID_TOKEN",p.NETWORK_ERROR="NETWORK_ERROR",p.TIMEOUT="TIMEOUT",p.SERVER_ERROR="SERVER_ERROR",p.API_ERROR="API_ERROR",p.INVALID_PARAMS="INVALID_PARAMS",p.MISSING_PARAMS="MISSING_PARAMS",p.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",p.UNKNOWN="UNKNOWN",p.PAYMENT_FAILED="PAYMENT_FAILED",p.SHARE_FAILED="SHARE_FAILED",p))(k||{}),y=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},W={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function l(o,e){return new y(o,W[o],e)}var w="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(w+e)}catch{return null}}set(e,t){try{this.storage.setItem(w+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(w+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(w)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},N=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function v(o="localStorage"){return typeof window>"u"||o==="memory"?new N:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var I=v(),g={get:o=>I.get(o),set:(o,e)=>{I.set(o,e);},remove:o=>{I.remove(o);},clear:()=>{I.clear();},getJSON:o=>{let e=I.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{I.set(o,JSON.stringify(e));},configure(o){I=v(o);}},c={TOKEN_DATA:"token_data",USER:"user",LOCALE:"locale",CONFIG:"config"};var $=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},J=o=>o.map(e=>{if(!e.externalUrl)return e;let t=$(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Z=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:chunkZ2CIDSTP_cjs.c("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],x=J(Z),E=()=>x.filter(o=>o.enable);({Adventure:E().filter(o=>o.category==="Adventure"),Moba:E().filter(o=>o.category==="Moba")});var G=o=>x.find(e=>e.id===o);var K=()=>Array.from(new Set(E().map(o=>o.category)));var U="https://api.playsout.com",C=3e4;function V(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw l("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw l("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw l("MISSING_PARAMS","platformToken is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:typeof t.username=="string"?t.username:void 0,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw l("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var A=null,O=null,L=null;function j(o){O=o;}function F(o){L=o;}function M(){if(L)try{L();}catch{}}async function z(o,e={},t,r=false){let i=t?.apiBaseUrl||U,d=o.startsWith("http")?o:`${i}${o}`,u=new AbortController,s=setTimeout(()=>u.abort(),C);try{let m=g.getJSON(c.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};m?.accessToken&&!f.token&&(f.token=m.accessToken);let h=await fetch(d,{...e,signal:u.signal,headers:f});if(clearTimeout(s),!h.ok){if(h.status===401&&r)return await H(o,e,t);throw l(h.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${h.status}: ${h.statusText}`)}let D=await h.json();if(D.code!==1e4){if(r)return await H(o,e,t);throw l("API_ERROR",D.msg||"API request failed")}return D.data}catch(m){throw clearTimeout(s),m instanceof y?m:m instanceof Error?m.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",m.message):l("UNKNOWN")}}async function H(o,e,t){await B(t);let r=t?.apiBaseUrl||U,i=o.startsWith("http")?o:`${r}${o}`,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=g.getJSON(c.TOKEN_DATA),m={"Content-Type":"application/json",...e.headers};s?.accessToken&&(m.token=s.accessToken);let f=await fetch(i,{...e,signal:d.signal,headers:m});if(clearTimeout(u),!f.ok)throw l(f.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${f.status}: ${f.statusText}`);let h=await f.json();if(h.code!==1e4)throw l("API_ERROR",h.msg||"API request failed");return h.data}catch(s){throw clearTimeout(u),s instanceof y?s:s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Request failed")}}async function B(o){if(A)return A;let e=(async()=>{let t=g.getJSON(c.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw M(),l("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||U,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(u),!s.ok)throw s.status>=500?l("SERVER_ERROR",`HTTP ${s.status}: ${s.statusText}`):l("TOKEN_EXPIRED",`HTTP ${s.status}: ${s.statusText}`);let m=await s.json();if(m.code!==1e4||!m.data)throw l("TOKEN_EXPIRED",m.msg||"Failed to refresh token");let f=m.data;if(g.setJSON(c.TOKEN_DATA,f),O)try{O(f);}catch{}return f}catch(s){throw clearTimeout(u),s instanceof y?((s.code==="TOKEN_EXPIRED"||s.code==="NOT_LOGGED_IN")&&M(),s):s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Refresh token failed")}})();A=e;try{return await e}finally{A===e&&(A=null);}}var b=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await B(this.config||void 0)}async getGames(e){let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return G(e)}async getCategoryNames(){return K()}async loginOnly(e){let t=V(e);return await z("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e),r;try{r=await this.getUserInfo();}catch{}return {tokenData:t,user:r}}async getUserInfo(){return await z("/platform/user",{method:"GET"},this.config??void 0,true)}async getUser(){return g.getJSON(c.USER)}async validateToken(e){return !!e}},_=null;function P(){return _||(_=new b),_}var X="https://api.playsout.com",q="zh",S=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=q;this._widget=null;}clearAuthState(){let e=!!(this._token||g.get(c.TOKEN_DATA)||g.get(c.USER));return this._user=null,this._token=null,g.remove(c.TOKEN_DATA),g.remove(c.USER),e}handleAuthExpired(){this.clearAuthState()&&chunkZ2CIDSTP_cjs.b.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw l("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||X,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||q,appId:e.appId||""},g.configure(this.config.storage),j(i=>{this._token=i.accessToken;}),F(()=>{this.handleAuthExpired();});let t=g.getJSON(c.TOKEN_DATA);this._user=g.getJSON(c.USER),this._locale=g.get(c.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t)if(!t.refreshToken||t.refreshExpiresAt<=r)this.handleAuthExpired();else if(t.accessToken&&t.expiresAt>r)this._token=t.accessToken;else try{let i=P();i.configure(this.config),await i.refreshToken();}catch(i){if(!(i instanceof y&&(i.code==="TOKEN_EXPIRED"||i.code==="NOT_LOGGED_IN")))throw i}this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),chunkZ2CIDSTP_cjs.b.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,g.clear(),chunkZ2CIDSTP_cjs.b.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!this._token}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);let t=P();t.configure(this.config);let r=await t.loginOnly(e);g.setJSON(c.TOKEN_DATA,r),this.config?.debug&&console.log("[PlaysoutSDK] Token saved, expires at:",new Date(r.expiresAt*1e3).toISOString());let i;try{i=await t.getUserInfo();}catch(u){if(u instanceof y&&(u.code==="TOKEN_EXPIRED"||u.code==="NOT_LOGGED_IN"||u.code==="INVALID_TOKEN"))throw u;this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo failed, login still success:",u);}let d=g.getJSON(c.TOKEN_DATA);return this._token=d?.accessToken||r.accessToken,i&&(this._user={userId:String(i.id),username:i.username},g.setJSON(c.USER,this._user)),this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",i),chunkZ2CIDSTP_cjs.b.emit("login",{user:this._user,token:this._token}),{tokenData:r,user:i}}async getUserInfo(){if(this.ensureInitialized(),!this._token)throw l("NOT_LOGGED_IN","Please login first");let e=P();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&(this._user={userId:String(t.id),username:t.username},g.setJSON(c.USER,this._user)),t}logout(){this.clearAuthState(),chunkZ2CIDSTP_cjs.b.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw l("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,g.set(c.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),chunkZ2CIDSTP_cjs.b.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),E().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw l("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw l("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",d=>{let u=d;t.onGameClick(u.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",d=>{let u=d;t.onLocaleChange(u.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.on(e,t)}off(e,t){this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw l("NOT_INITIALIZED")}},a=S.getInstance(),fe=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var Ee=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:S});
1
+ 'use strict';var chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');var k=(p=>(p.NOT_INITIALIZED="NOT_INITIALIZED",p.ALREADY_INITIALIZED="ALREADY_INITIALIZED",p.NOT_LOGGED_IN="NOT_LOGGED_IN",p.TOKEN_EXPIRED="TOKEN_EXPIRED",p.INVALID_TOKEN="INVALID_TOKEN",p.NETWORK_ERROR="NETWORK_ERROR",p.TIMEOUT="TIMEOUT",p.SERVER_ERROR="SERVER_ERROR",p.API_ERROR="API_ERROR",p.INVALID_PARAMS="INVALID_PARAMS",p.MISSING_PARAMS="MISSING_PARAMS",p.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",p.UNKNOWN="UNKNOWN",p.PAYMENT_FAILED="PAYMENT_FAILED",p.SHARE_FAILED="SHARE_FAILED",p))(k||{}),y=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},W={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function l(o,e){return new y(o,W[o],e)}var w="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(w+e)}catch{return null}}set(e,t){try{this.storage.setItem(w+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(w+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(w)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},N=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function v(o="localStorage"){return typeof window>"u"||o==="memory"?new N:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var I=v(),g={get:o=>I.get(o),set:(o,e)=>{I.set(o,e);},remove:o=>{I.remove(o);},clear:()=>{I.clear();},getJSON:o=>{let e=I.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{I.set(o,JSON.stringify(e));},configure(o){I=v(o);}},c={TOKEN_DATA:"token_data",USER:"user",LOCALE:"locale",CONFIG:"config"};var $=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},J=o=>o.map(e=>{if(!e.externalUrl)return e;let t=$(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Z=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:chunkZ2CIDSTP_cjs.c("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:chunkZ2CIDSTP_cjs.c("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:chunkZ2CIDSTP_cjs.c("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:chunkZ2CIDSTP_cjs.c("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:chunkZ2CIDSTP_cjs.c("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:chunkZ2CIDSTP_cjs.c("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:chunkZ2CIDSTP_cjs.c("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],x=J(Z),E=()=>x.filter(o=>o.enable);({Adventure:E().filter(o=>o.category==="Adventure"),Moba:E().filter(o=>o.category==="Moba")});var G=o=>x.find(e=>e.id===o);var K=()=>Array.from(new Set(E().map(o=>o.category)));var U="https://api.playsout.com",C=3e4;function V(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw l("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw l("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw l("MISSING_PARAMS","platformToken is required for Grab/Eros login");if(typeof t.username!="string"||!t.username.trim())throw l("MISSING_PARAMS","username is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:t.username,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw l("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var A=null,O=null,L=null;function j(o){O=o;}function F(o){L=o;}function M(){if(L)try{L();}catch{}}async function z(o,e={},t,r=false){let i=t?.apiBaseUrl||U,d=o.startsWith("http")?o:`${i}${o}`,u=new AbortController,s=setTimeout(()=>u.abort(),C);try{let m=g.getJSON(c.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};m?.accessToken&&!f.token&&(f.token=m.accessToken);let h=await fetch(d,{...e,signal:u.signal,headers:f});if(clearTimeout(s),!h.ok){if(h.status===401&&r)return await H(o,e,t);throw l(h.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${h.status}: ${h.statusText}`)}let D=await h.json();if(D.code!==1e4){if(r)return await H(o,e,t);throw l("API_ERROR",D.msg||"API request failed")}return D.data}catch(m){throw clearTimeout(s),m instanceof y?m:m instanceof Error?m.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",m.message):l("UNKNOWN")}}async function H(o,e,t){await B(t);let r=t?.apiBaseUrl||U,i=o.startsWith("http")?o:`${r}${o}`,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=g.getJSON(c.TOKEN_DATA),m={"Content-Type":"application/json",...e.headers};s?.accessToken&&(m.token=s.accessToken);let f=await fetch(i,{...e,signal:d.signal,headers:m});if(clearTimeout(u),!f.ok)throw l(f.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${f.status}: ${f.statusText}`);let h=await f.json();if(h.code!==1e4)throw l("API_ERROR",h.msg||"API request failed");return h.data}catch(s){throw clearTimeout(u),s instanceof y?s:s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Request failed")}}async function B(o){if(A)return A;let e=(async()=>{let t=g.getJSON(c.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw M(),l("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||U,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(u),!s.ok)throw s.status>=500?l("SERVER_ERROR",`HTTP ${s.status}: ${s.statusText}`):l("TOKEN_EXPIRED",`HTTP ${s.status}: ${s.statusText}`);let m=await s.json();if(m.code!==1e4||!m.data)throw l("TOKEN_EXPIRED",m.msg||"Failed to refresh token");let f=m.data;if(g.setJSON(c.TOKEN_DATA,f),O)try{O(f);}catch{}return f}catch(s){throw clearTimeout(u),s instanceof y?((s.code==="TOKEN_EXPIRED"||s.code==="NOT_LOGGED_IN")&&M(),s):s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Refresh token failed")}})();A=e;try{return await e}finally{A===e&&(A=null);}}var b=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await B(this.config||void 0)}async getGames(e){let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return G(e)}async getCategoryNames(){return K()}async loginOnly(e){let t=V(e);return await z("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e),r;try{r=await this.getUserInfo();}catch{}return {tokenData:t,user:r}}async getUserInfo(){return await z("/platform/user",{method:"GET"},this.config??void 0,true)}async getUser(){return g.getJSON(c.USER)}async validateToken(e){return !!e}},_=null;function P(){return _||(_=new b),_}var X="https://api.playsout.com",q="zh",S=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=q;this._widget=null;}clearAuthState(){let e=!!(this._token||g.get(c.TOKEN_DATA)||g.get(c.USER));return this._user=null,this._token=null,g.remove(c.TOKEN_DATA),g.remove(c.USER),e}handleAuthExpired(){this.clearAuthState()&&chunkZ2CIDSTP_cjs.b.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw l("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||X,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||q,appId:e.appId||""},g.configure(this.config.storage),j(i=>{this._token=i.accessToken;}),F(()=>{this.handleAuthExpired();});let t=g.getJSON(c.TOKEN_DATA);this._user=g.getJSON(c.USER),this._locale=g.get(c.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t)if(!t.refreshToken||t.refreshExpiresAt<=r)this.handleAuthExpired();else if(t.accessToken&&t.expiresAt>r)this._token=t.accessToken;else try{let i=P();i.configure(this.config),await i.refreshToken();}catch(i){if(!(i instanceof y&&(i.code==="TOKEN_EXPIRED"||i.code==="NOT_LOGGED_IN")))throw i}this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),chunkZ2CIDSTP_cjs.b.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,g.clear(),chunkZ2CIDSTP_cjs.b.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!this._token}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);let t=P();t.configure(this.config);let r=await t.loginOnly(e);g.setJSON(c.TOKEN_DATA,r),this.config?.debug&&console.log("[PlaysoutSDK] Token saved, expires at:",new Date(r.expiresAt*1e3).toISOString());let i;try{i=await t.getUserInfo();}catch(u){if(u instanceof y&&(u.code==="TOKEN_EXPIRED"||u.code==="NOT_LOGGED_IN"||u.code==="INVALID_TOKEN"))throw u;this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo failed, login still success:",u);}let d=g.getJSON(c.TOKEN_DATA);return this._token=d?.accessToken||r.accessToken,i&&(this._user={userId:String(i.id),username:i.username},g.setJSON(c.USER,this._user)),this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",i),chunkZ2CIDSTP_cjs.b.emit("login",{user:this._user,token:this._token}),{tokenData:r,user:i}}async getUserInfo(){if(this.ensureInitialized(),!this._token)throw l("NOT_LOGGED_IN","Please login first");let e=P();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&(this._user={userId:String(t.id),username:t.username},g.setJSON(c.USER,this._user)),t}logout(){this.clearAuthState(),chunkZ2CIDSTP_cjs.b.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw l("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,g.set(c.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),chunkZ2CIDSTP_cjs.b.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),E().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw l("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw l("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",d=>{let u=d;t.onGameClick(u.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",d=>{let u=d;t.onLocaleChange(u.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.on(e,t)}off(e,t){this.ensureInitialized(),chunkZ2CIDSTP_cjs.b.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw l("NOT_INITIALIZED")}},a=S.getInstance(),fe=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var Ee=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:S});
2
2
  exports.a=k;exports.b=y;exports.c=g;exports.d=c;exports.e=S;exports.f=a;exports.g=fe;exports.h=Ee;
@@ -1,2 +1,2 @@
1
- import {c as c$1,b as b$1}from'./chunk-EZLO3WY6.js';var k=(p=>(p.NOT_INITIALIZED="NOT_INITIALIZED",p.ALREADY_INITIALIZED="ALREADY_INITIALIZED",p.NOT_LOGGED_IN="NOT_LOGGED_IN",p.TOKEN_EXPIRED="TOKEN_EXPIRED",p.INVALID_TOKEN="INVALID_TOKEN",p.NETWORK_ERROR="NETWORK_ERROR",p.TIMEOUT="TIMEOUT",p.SERVER_ERROR="SERVER_ERROR",p.API_ERROR="API_ERROR",p.INVALID_PARAMS="INVALID_PARAMS",p.MISSING_PARAMS="MISSING_PARAMS",p.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",p.UNKNOWN="UNKNOWN",p.PAYMENT_FAILED="PAYMENT_FAILED",p.SHARE_FAILED="SHARE_FAILED",p))(k||{}),y=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},W={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function l(o,e){return new y(o,W[o],e)}var w="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(w+e)}catch{return null}}set(e,t){try{this.storage.setItem(w+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(w+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(w)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},N=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function v(o="localStorage"){return typeof window>"u"||o==="memory"?new N:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var I=v(),g={get:o=>I.get(o),set:(o,e)=>{I.set(o,e);},remove:o=>{I.remove(o);},clear:()=>{I.clear();},getJSON:o=>{let e=I.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{I.set(o,JSON.stringify(e));},configure(o){I=v(o);}},c={TOKEN_DATA:"token_data",USER:"user",LOCALE:"locale",CONFIG:"config"};var $=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},J=o=>o.map(e=>{if(!e.externalUrl)return e;let t=$(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Z=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:c$1("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:c$1("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:c$1("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:c$1("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:c$1("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:c$1("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:c$1("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:c$1("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:c$1("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:c$1("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:c$1("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:c$1("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:c$1("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:c$1("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:c$1("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:c$1("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:c$1("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:c$1("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:c$1("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:c$1("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:c$1("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:c$1("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:c$1("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:c$1("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:c$1("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:c$1("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:c$1("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:c$1("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:c$1("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:c$1("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:c$1("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:c$1("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],x=J(Z),E=()=>x.filter(o=>o.enable);({Adventure:E().filter(o=>o.category==="Adventure"),Moba:E().filter(o=>o.category==="Moba")});var G=o=>x.find(e=>e.id===o);var K=()=>Array.from(new Set(E().map(o=>o.category)));var U="https://api.playsout.com",C=3e4;function V(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw l("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw l("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw l("MISSING_PARAMS","platformToken is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:typeof t.username=="string"?t.username:void 0,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw l("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var A=null,O=null,L=null;function j(o){O=o;}function F(o){L=o;}function M(){if(L)try{L();}catch{}}async function z(o,e={},t,r=false){let i=t?.apiBaseUrl||U,d=o.startsWith("http")?o:`${i}${o}`,u=new AbortController,s=setTimeout(()=>u.abort(),C);try{let m=g.getJSON(c.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};m?.accessToken&&!f.token&&(f.token=m.accessToken);let h=await fetch(d,{...e,signal:u.signal,headers:f});if(clearTimeout(s),!h.ok){if(h.status===401&&r)return await H(o,e,t);throw l(h.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${h.status}: ${h.statusText}`)}let D=await h.json();if(D.code!==1e4){if(r)return await H(o,e,t);throw l("API_ERROR",D.msg||"API request failed")}return D.data}catch(m){throw clearTimeout(s),m instanceof y?m:m instanceof Error?m.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",m.message):l("UNKNOWN")}}async function H(o,e,t){await B(t);let r=t?.apiBaseUrl||U,i=o.startsWith("http")?o:`${r}${o}`,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=g.getJSON(c.TOKEN_DATA),m={"Content-Type":"application/json",...e.headers};s?.accessToken&&(m.token=s.accessToken);let f=await fetch(i,{...e,signal:d.signal,headers:m});if(clearTimeout(u),!f.ok)throw l(f.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${f.status}: ${f.statusText}`);let h=await f.json();if(h.code!==1e4)throw l("API_ERROR",h.msg||"API request failed");return h.data}catch(s){throw clearTimeout(u),s instanceof y?s:s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Request failed")}}async function B(o){if(A)return A;let e=(async()=>{let t=g.getJSON(c.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw M(),l("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||U,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(u),!s.ok)throw s.status>=500?l("SERVER_ERROR",`HTTP ${s.status}: ${s.statusText}`):l("TOKEN_EXPIRED",`HTTP ${s.status}: ${s.statusText}`);let m=await s.json();if(m.code!==1e4||!m.data)throw l("TOKEN_EXPIRED",m.msg||"Failed to refresh token");let f=m.data;if(g.setJSON(c.TOKEN_DATA,f),O)try{O(f);}catch{}return f}catch(s){throw clearTimeout(u),s instanceof y?((s.code==="TOKEN_EXPIRED"||s.code==="NOT_LOGGED_IN")&&M(),s):s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Refresh token failed")}})();A=e;try{return await e}finally{A===e&&(A=null);}}var b=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await B(this.config||void 0)}async getGames(e){let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return G(e)}async getCategoryNames(){return K()}async loginOnly(e){let t=V(e);return await z("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e),r;try{r=await this.getUserInfo();}catch{}return {tokenData:t,user:r}}async getUserInfo(){return await z("/platform/user",{method:"GET"},this.config??void 0,true)}async getUser(){return g.getJSON(c.USER)}async validateToken(e){return !!e}},_=null;function P(){return _||(_=new b),_}var X="https://api.playsout.com",q="zh",S=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=q;this._widget=null;}clearAuthState(){let e=!!(this._token||g.get(c.TOKEN_DATA)||g.get(c.USER));return this._user=null,this._token=null,g.remove(c.TOKEN_DATA),g.remove(c.USER),e}handleAuthExpired(){this.clearAuthState()&&b$1.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw l("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||X,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||q,appId:e.appId||""},g.configure(this.config.storage),j(i=>{this._token=i.accessToken;}),F(()=>{this.handleAuthExpired();});let t=g.getJSON(c.TOKEN_DATA);this._user=g.getJSON(c.USER),this._locale=g.get(c.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t)if(!t.refreshToken||t.refreshExpiresAt<=r)this.handleAuthExpired();else if(t.accessToken&&t.expiresAt>r)this._token=t.accessToken;else try{let i=P();i.configure(this.config),await i.refreshToken();}catch(i){if(!(i instanceof y&&(i.code==="TOKEN_EXPIRED"||i.code==="NOT_LOGGED_IN")))throw i}this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),b$1.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,g.clear(),b$1.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!this._token}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);let t=P();t.configure(this.config);let r=await t.loginOnly(e);g.setJSON(c.TOKEN_DATA,r),this.config?.debug&&console.log("[PlaysoutSDK] Token saved, expires at:",new Date(r.expiresAt*1e3).toISOString());let i;try{i=await t.getUserInfo();}catch(u){if(u instanceof y&&(u.code==="TOKEN_EXPIRED"||u.code==="NOT_LOGGED_IN"||u.code==="INVALID_TOKEN"))throw u;this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo failed, login still success:",u);}let d=g.getJSON(c.TOKEN_DATA);return this._token=d?.accessToken||r.accessToken,i&&(this._user={userId:String(i.id),username:i.username},g.setJSON(c.USER,this._user)),this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",i),b$1.emit("login",{user:this._user,token:this._token}),{tokenData:r,user:i}}async getUserInfo(){if(this.ensureInitialized(),!this._token)throw l("NOT_LOGGED_IN","Please login first");let e=P();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&(this._user={userId:String(t.id),username:t.username},g.setJSON(c.USER,this._user)),t}logout(){this.clearAuthState(),b$1.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw l("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,g.set(c.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),b$1.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),E().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw l("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw l("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",d=>{let u=d;t.onGameClick(u.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",d=>{let u=d;t.onLocaleChange(u.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),b$1.on(e,t)}off(e,t){this.ensureInitialized(),b$1.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw l("NOT_INITIALIZED")}},a=S.getInstance(),fe=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var Ee=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:S});
1
+ import {c as c$1,b as b$1}from'./chunk-EZLO3WY6.js';var k=(p=>(p.NOT_INITIALIZED="NOT_INITIALIZED",p.ALREADY_INITIALIZED="ALREADY_INITIALIZED",p.NOT_LOGGED_IN="NOT_LOGGED_IN",p.TOKEN_EXPIRED="TOKEN_EXPIRED",p.INVALID_TOKEN="INVALID_TOKEN",p.NETWORK_ERROR="NETWORK_ERROR",p.TIMEOUT="TIMEOUT",p.SERVER_ERROR="SERVER_ERROR",p.API_ERROR="API_ERROR",p.INVALID_PARAMS="INVALID_PARAMS",p.MISSING_PARAMS="MISSING_PARAMS",p.FEATURE_NOT_SUPPORTED="FEATURE_NOT_SUPPORTED",p.UNKNOWN="UNKNOWN",p.PAYMENT_FAILED="PAYMENT_FAILED",p.SHARE_FAILED="SHARE_FAILED",p))(k||{}),y=class extends Error{constructor(t,r,i){super(r);this.code=t;this.details=i;this.name="SDKError";}toJSON(){return {name:this.name,code:this.code,message:this.message,details:this.details}}},W={NOT_INITIALIZED:"SDK not initialized. Please call PlaysoutSDK.init() first.",ALREADY_INITIALIZED:"SDK already initialized. Please do not call init() more than once.",NOT_LOGGED_IN:"User not logged in. Please log in first.",TOKEN_EXPIRED:"Login token has expired. Please log in again.",INVALID_TOKEN:"Invalid login token. Please log in again.",NETWORK_ERROR:"Network connection failed. Please check your network.",TIMEOUT:"Request timed out. Please try again later.",SERVER_ERROR:"Server is busy. Please try again later.",API_ERROR:"API request failed.",INVALID_PARAMS:"Invalid parameter(s).",MISSING_PARAMS:"Missing required parameter(s).",FEATURE_NOT_SUPPORTED:"This feature is not supported in the current environment.",UNKNOWN:"An unknown error occurred.",PAYMENT_FAILED:"Payment failed.",SHARE_FAILED:"Share failed."};function l(o,e){return new y(o,W[o],e)}var w="playsout_",R=class{constructor(e){this.storage=e;}get(e){try{return this.storage.getItem(w+e)}catch{return null}}set(e,t){try{this.storage.setItem(w+e,t);}catch(r){console.warn("[PlaysoutSDK] Storage set failed:",r);}}remove(e){try{this.storage.removeItem(w+e);}catch{}}clear(){try{let e=[];for(let t=0;t<this.storage.length;t++){let r=this.storage.key(t);r&&r.startsWith(w)&&e.push(r);}e.forEach(t=>this.storage.removeItem(t));}catch{}}},N=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function v(o="localStorage"){return typeof window>"u"||o==="memory"?new N:o==="sessionStorage"?new R(sessionStorage):new R(localStorage)}var I=v(),g={get:o=>I.get(o),set:(o,e)=>{I.set(o,e);},remove:o=>{I.remove(o);},clear:()=>{I.clear();},getJSON:o=>{let e=I.get(o);if(!e)return null;try{return JSON.parse(e)}catch{return null}},setJSON:(o,e)=>{I.set(o,JSON.stringify(e));},configure(o){I=v(o);}},c={TOKEN_DATA:"token_data",USER:"user",LOCALE:"locale",CONFIG:"config"};var $=o=>{if(!o)return o;try{let e=new URL(o);if(e.hostname==="games.playsout.com"){let t=e.pathname,r=t.endsWith("/"),i=/\.[a-z0-9]+$/i.test(t);!r&&!i&&(e.pathname=`${t}/`);}return e.toString()}catch{return o}},J=o=>o.map(e=>{if(!e.externalUrl)return e;let t=$(e.externalUrl);return t===e.externalUrl?e:{...e,externalUrl:t}}),Z=[{id:"BlockCrushFun",title:"Block Crush Fun",category:"Puzzle",image:c$1("./games/BlockCrushFun.png"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BlockCrushFun"},{id:"DogeSurvivors",title:"Doge Survivors",category:"Doge OS",image:c$1("./games/DogeSurvivors.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeSurvivors/"},{id:"DogeMaze",title:"Doge Maze",category:"Doge OS",image:c$1("./games/DogeMaze.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMaze/"},{id:"DogeMart",title:"Doge Mart",category:"Doge OS",image:c$1("./games/DogeMart.jpg"),isNew:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Doge/DogeMart/"},{id:"KittyEscape",title:"Kitty Escape",category:"Puzzle",image:c$1("./games/KittyEscape.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/KittyEscape/"},{id:"ProjectGarden",title:"Project: Garden",category:"Adventure",image:c$1("./games/SimulatedAdventures.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/simulated/"},{id:"ProjectIDLE",title:"Project: IDLE",category:"Simulation",image:c$1("./games/ProjectIDLE.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/idle/"},{id:"CulinaryStarWeb",title:"Culinary Star",category:"Casual",image:c$1("./games/CulinaryStar.webp"),description:"Cooking game",isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CulinaryStar/"},{id:"PickaxeQuest",title:"Pickaxe Quest",category:"Adventure",image:c$1("./games/PickaxeQuest.jpg"),description:"Mining and adventure game",isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/PickaxeQuest/",apiGameId:73},{id:"MonsterSurvivors",title:"Monster Survivors",category:"Adventure",image:c$1("./games/MonsterSurvivors.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MonsterSurvivors/"},{id:"IdleTowerDefense",title:"Idle Tower Defense",category:"RPG",image:c$1("./games/IdleTowerDefense.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/IdleTowerDefense/"},{id:"MushroomWarriors",title:"Mushroom Warriors",category:"RPG",image:c$1("./games/MushroomWarriors.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/MushroomWarriors/"},{id:"FollowThePath",title:"Follow The Path",category:"Arcade",image:c$1("./games/FollowThePath.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FollowThePath/"},{id:"ColorRun",title:"Color Run",category:"Arcade",image:c$1("./games/ColorRun.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorRun/"},{id:"StupidArrow",title:"Stupid Arrow",category:"Arcade",image:c$1("./games/StupidArrow.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/StupidArrow/"},{id:"ZigZag",title:"Zig Zag",category:"Arcade",image:c$1("./games/ZigZag.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ZigZag/"},{id:"SpikesEverywhere",title:"Spikes Everywhere",category:"Arcade",image:c$1("./games/SpikesEverywhere.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpikesEverywhere/"},{id:"ArrowRacer",title:"Arrow Racer",category:"Arcade",image:c$1("./games/ArrowRacer.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ArrowRacer/"},{id:"CircleLeap",title:"Circle Leap",category:"Arcade",image:c$1("./games/CircleLeap.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircleLeap/"},{id:"ColorMatcher",title:"Color Matcher",category:"Arcade",image:c$1("./games/ColorMatcher.jpg"),isNew:false,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ColorMatcher/"},{id:"EndlessMaze",title:"Endless Maze",category:"Arcade",image:c$1("./games/EndlessMaze.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/EndlessMaze/"},{id:"SpinningAround",title:"Spinning Around",category:"Arcade",image:c$1("./games/SpinningAround.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/SpinningAround/"},{id:"BoomBallz",title:"Boom Ballz",category:"Arcade",image:c$1("./games/BoomBallz.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/BoomBallz/"},{id:"CubeHead",title:"Cube Head",category:"Arcade",image:c$1("./games/CubeHead.jpg"),isNew:false,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CubeHead/"},{id:"CapybaraLink",title:"Capybara Link",category:"Puzzle",image:c$1("./games/CapybaraLink.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CapybaraLink/"},{id:"Snake2048",title:"Snake 2048",category:"Puzzle",image:c$1("./games/Snake2048.jpg"),isNew:true,isHot:true,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Snake2048/"},{id:"FishTankFury",title:"Fish Tank Fury",category:"Puzzle",image:c$1("./games/FishTankFury.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/FishTankFury/"},{id:"ConnectBalls",title:"Connect Balls",category:"Arcade",image:c$1("./games/ConnectBalls.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/ConnectBalls/"},{id:"CircularBreaker",title:"Circular Breaker",category:"Arcade",image:c$1("./games/CircularBreaker.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CircularBreaker/"},{id:"OneDoor",title:"One Door",category:"Arcade",image:c$1("./games/OneDoor.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/OneDoor/"},{id:"CatchtheFruits",title:"Catch the Fruits",category:"Casual",image:c$1("./games/CatchtheFruits.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/CatchtheFruits/"},{id:"Falling2048",title:"Falling 2048",category:"Casual",image:c$1("./games/Falling2048.jpg"),isNew:true,isHot:false,enable:true,orientation:"portrait",externalUrl:"https://games.playsout.com/Falling2048/"}],x=J(Z),E=()=>x.filter(o=>o.enable);({Adventure:E().filter(o=>o.category==="Adventure"),Moba:E().filter(o=>o.category==="Moba")});var G=o=>x.find(e=>e.id===o);var K=()=>Array.from(new Set(E().map(o=>o.category)));var U="https://api.playsout.com",C=3e4;function V(o){let e=String(o?.platform||"").toLowerCase();if(e==="tiktok"){let t=o.authorizationCode;if(typeof t!="string"||!t.trim())throw l("MISSING_PARAMS","authorizationCode is required for TikTok login");return {platform:e,authorizationCode:t}}if(e==="grab"||e==="eros"){let t=o;if(typeof t.platformUserId!="string"||!t.platformUserId.trim())throw l("MISSING_PARAMS","platformUserId is required for Grab/Eros login");if(typeof t.platformToken!="string"||!t.platformToken.trim())throw l("MISSING_PARAMS","platformToken is required for Grab/Eros login");if(typeof t.username!="string"||!t.username.trim())throw l("MISSING_PARAMS","username is required for Grab/Eros login");return {platform:e,platformUserId:t.platformUserId,platformToken:t.platformToken,username:t.username,inviteCode:typeof t.inviteCode=="string"?t.inviteCode:void 0}}throw l("INVALID_PARAMS","Unsupported platform. Expected grab, eros, or tiktok")}var A=null,O=null,L=null;function j(o){O=o;}function F(o){L=o;}function M(){if(L)try{L();}catch{}}async function z(o,e={},t,r=false){let i=t?.apiBaseUrl||U,d=o.startsWith("http")?o:`${i}${o}`,u=new AbortController,s=setTimeout(()=>u.abort(),C);try{let m=g.getJSON(c.TOKEN_DATA),f={"Content-Type":"application/json",...e.headers};m?.accessToken&&!f.token&&(f.token=m.accessToken);let h=await fetch(d,{...e,signal:u.signal,headers:f});if(clearTimeout(s),!h.ok){if(h.status===401&&r)return await H(o,e,t);throw l(h.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${h.status}: ${h.statusText}`)}let D=await h.json();if(D.code!==1e4){if(r)return await H(o,e,t);throw l("API_ERROR",D.msg||"API request failed")}return D.data}catch(m){throw clearTimeout(s),m instanceof y?m:m instanceof Error?m.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",m.message):l("UNKNOWN")}}async function H(o,e,t){await B(t);let r=t?.apiBaseUrl||U,i=o.startsWith("http")?o:`${r}${o}`,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=g.getJSON(c.TOKEN_DATA),m={"Content-Type":"application/json",...e.headers};s?.accessToken&&(m.token=s.accessToken);let f=await fetch(i,{...e,signal:d.signal,headers:m});if(clearTimeout(u),!f.ok)throw l(f.status>=500?"SERVER_ERROR":"API_ERROR",`HTTP ${f.status}: ${f.statusText}`);let h=await f.json();if(h.code!==1e4)throw l("API_ERROR",h.msg||"API request failed");return h.data}catch(s){throw clearTimeout(u),s instanceof y?s:s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Request failed")}}async function B(o){if(A)return A;let e=(async()=>{let t=g.getJSON(c.TOKEN_DATA),r=Math.floor(Date.now()/1e3);if(!t?.refreshToken||t.refreshExpiresAt<=r)throw M(),l("TOKEN_EXPIRED","Refresh token has expired");let i=o?.apiBaseUrl||U,d=new AbortController,u=setTimeout(()=>d.abort(),C);try{let s=await fetch(`${i}/platform/refreshToken`,{method:"POST",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t.refreshToken})});if(clearTimeout(u),!s.ok)throw s.status>=500?l("SERVER_ERROR",`HTTP ${s.status}: ${s.statusText}`):l("TOKEN_EXPIRED",`HTTP ${s.status}: ${s.statusText}`);let m=await s.json();if(m.code!==1e4||!m.data)throw l("TOKEN_EXPIRED",m.msg||"Failed to refresh token");let f=m.data;if(g.setJSON(c.TOKEN_DATA,f),O)try{O(f);}catch{}return f}catch(s){throw clearTimeout(u),s instanceof y?((s.code==="TOKEN_EXPIRED"||s.code==="NOT_LOGGED_IN")&&M(),s):s instanceof Error&&s.name==="AbortError"?l("TIMEOUT"):l("NETWORK_ERROR",s?.message||"Refresh token failed")}})();A=e;try{return await e}finally{A===e&&(A=null);}}var b=class{constructor(){this.config=null;}configure(e){this.config=e;}async refreshToken(){return await B(this.config||void 0)}async getGames(e){let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return G(e)}async getCategoryNames(){return K()}async loginOnly(e){let t=V(e);return await z("/platform/login",{method:"POST",body:JSON.stringify(t)},this.config??void 0)}async Login(e){let t=await this.loginOnly(e),r;try{r=await this.getUserInfo();}catch{}return {tokenData:t,user:r}}async getUserInfo(){return await z("/platform/user",{method:"GET"},this.config??void 0,true)}async getUser(){return g.getJSON(c.USER)}async validateToken(e){return !!e}},_=null;function P(){return _||(_=new b),_}var X="https://api.playsout.com",q="zh",S=class o{constructor(){this.config=null;this._isInitialized=false;this._user=null;this._token=null;this._locale=q;this._widget=null;}clearAuthState(){let e=!!(this._token||g.get(c.TOKEN_DATA)||g.get(c.USER));return this._user=null,this._token=null,g.remove(c.TOKEN_DATA),g.remove(c.USER),e}handleAuthExpired(){this.clearAuthState()&&b$1.emit("authExpired"),this.config?.debug&&console.warn("[PlaysoutSDK] Auth expired, logged out");}static getInstance(){return o.instance||(o.instance=new o),o.instance}async init(e={}){if(this._isInitialized)throw l("ALREADY_INITIALIZED");this.config={apiBaseUrl:e.apiBaseUrl||X,debug:e.debug||false,storage:e.storage||"localStorage",locale:e.locale||q,appId:e.appId||""},g.configure(this.config.storage),j(i=>{this._token=i.accessToken;}),F(()=>{this.handleAuthExpired();});let t=g.getJSON(c.TOKEN_DATA);this._user=g.getJSON(c.USER),this._locale=g.get(c.LOCALE)||this.config.locale;let r=Math.floor(Date.now()/1e3);if(t)if(!t.refreshToken||t.refreshExpiresAt<=r)this.handleAuthExpired();else if(t.accessToken&&t.expiresAt>r)this._token=t.accessToken;else try{let i=P();i.configure(this.config),await i.refreshToken();}catch(i){if(!(i instanceof y&&(i.code==="TOKEN_EXPIRED"||i.code==="NOT_LOGGED_IN")))throw i}this._isInitialized=true,this.config.debug&&(console.log("[PlaysoutSDK] Initialized with config:",this.config),console.log("[PlaysoutSDK] Restored token:",this._token?this._token.substring(0,20)+"...":"(none)")),b$1.emit("initialized");}destroy(){this.config=null,this._isInitialized=false,this._user=null,this._token=null,g.clear(),b$1.clear();}get isInitialized(){return this._isInitialized}get isLoggedIn(){return !!this._token}get user(){return this._user}get token(){return this._token}get locale(){return this._locale}get sdkConfig(){return this.config}async Login(e){this.ensureInitialized(),this.config?.debug&&console.log("[PlaysoutSDK] Login with params:",e);let t=P();t.configure(this.config);let r=await t.loginOnly(e);g.setJSON(c.TOKEN_DATA,r),this.config?.debug&&console.log("[PlaysoutSDK] Token saved, expires at:",new Date(r.expiresAt*1e3).toISOString());let i;try{i=await t.getUserInfo();}catch(u){if(u instanceof y&&(u.code==="TOKEN_EXPIRED"||u.code==="NOT_LOGGED_IN"||u.code==="INVALID_TOKEN"))throw u;this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo failed, login still success:",u);}let d=g.getJSON(c.TOKEN_DATA);return this._token=d?.accessToken||r.accessToken,i&&(this._user={userId:String(i.id),username:i.username},g.setJSON(c.USER,this._user)),this.config?.debug&&console.log("[PlaysoutSDK] Login success, user:",i),b$1.emit("login",{user:this._user,token:this._token}),{tokenData:r,user:i}}async getUserInfo(){if(this.ensureInitialized(),!this._token)throw l("NOT_LOGGED_IN","Please login first");let e=P();e.configure(this.config);let t=await e.getUserInfo();return this.config?.debug&&console.log("[PlaysoutSDK] getUserInfo result:",t),t&&(this._user={userId:String(t.id),username:t.username},g.setJSON(c.USER,this._user)),t}logout(){this.clearAuthState(),b$1.emit("logout");}getToken(){return this.ensureInitialized(),this._token}getUser(){return this.ensureInitialized(),this._user}setLocale(e){if(this.ensureInitialized(),!["zh","en","ja","ko","vi","th","id","ms"].includes(e))throw l("INVALID_PARAMS",`Unsupported locale: ${e}`);this._locale=e,g.set(c.LOCALE,e),this.config?.debug&&console.log("[PlaysoutSDK] Locale changed to:",e);let t=this._widget||document.querySelector("playsout-widget");t&&t.getAttribute("locale")!==e&&t.setAttribute("locale",e),b$1.emit("localeChange",e);}getLocale(){return this.ensureInitialized(),this._locale}async getGames(e){this.ensureInitialized();let t=E();if(e?.category&&(t=t.filter(r=>r.category===e.category)),e?.search){let r=e.search.toLowerCase();t=t.filter(i=>i.title.toLowerCase().includes(r)||i.category.toLowerCase().includes(r)||i.description&&i.description.toLowerCase().includes(r));}if(e?.sortBy)switch(e.sortBy){case "newest":t=t.filter(r=>r.isNew).concat(t.filter(r=>!r.isNew));break;case "rating":t=t.filter(r=>r.isHot).concat(t.filter(r=>!r.isHot));break}if(e?.page&&e?.pageSize){let r=(e.page-1)*e.pageSize;t=t.slice(r,r+e.pageSize);}return t}async getCategories(){this.ensureInitialized();let e=E(),t=new Map;return e.forEach(r=>{let i=t.get(r.category)||0;t.set(r.category,i+1);}),Array.from(t.entries()).map(([r,i],d)=>({id:`category_${d}`,name:r,count:i}))}async getGameById(e){return this.ensureInitialized(),E().find(t=>t.id===e)}mount(e,t){if(this.ensureInitialized(),typeof document>"u")throw l("FEATURE_NOT_SUPPORTED","mount requires DOM environment");let r=document.querySelector(e);if(!r)throw l("INVALID_PARAMS",`Container not found: ${e}`);let i=document.createElement("playsout-widget");this.config?.appId&&i.setAttribute("app-id",this.config.appId),i.setAttribute("locale",t?.locale||this._locale),t?.detailMode&&i.setAttribute("detail-mode",t.detailMode),this._widget=i,t?.onGameClick&&i.addEventListener("game-click",d=>{let u=d;t.onGameClick(u.detail);}),t?.onLoginRequired&&i.addEventListener("login-required",t.onLoginRequired),t?.onLocaleChange&&i.addEventListener("locale-change",d=>{let u=d;t.onLocaleChange(u.detail);}),r.appendChild(i),this.config?.debug&&console.log("[PlaysoutSDK] Widget mounted to:",e);}unmount(){let e=document.querySelector("playsout-widget");e&&e.remove(),this._widget=null;}on(e,t){return this.ensureInitialized(),b$1.on(e,t)}off(e,t){this.ensureInitialized(),b$1.off(e,t);}ensureInitialized(){if(!this._isInitialized)throw l("NOT_INITIALIZED")}},a=S.getInstance(),fe=a;typeof window<"u"&&(window.__playsout_sdk_instance=a);var Ee=Object.freeze({init:a.init.bind(a),mount:a.mount.bind(a),unmount:a.unmount.bind(a),destroy:a.destroy.bind(a),Login:a.Login.bind(a),logout:a.logout.bind(a),getToken:a.getToken.bind(a),getUserInfo:a.getUserInfo.bind(a),getUser:a.getUser.bind(a),setLocale:a.setLocale.bind(a),getLocale:a.getLocale.bind(a),getGames:a.getGames.bind(a),getCategories:a.getCategories.bind(a),on:a.on.bind(a),off:a.off.bind(a),get isInitialized(){return a.isInitialized},get isLoggedIn(){return a.isLoggedIn},instance:a,PlaysoutSDKClass:S});
2
2
  export{k as a,y as b,g as c,c as d,S as e,a as f,fe as g,Ee as h};
package/core/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/core/api.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,SAAS,EAET,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACV,MAAM,SAAS,CAAC;AAoFjB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,IAAI,CAEtF;AAMD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjE;AAsOD,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAA0B;IAKxC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAS5B,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IAQlC,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAuClD,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAmBpC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;IAOlD,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAOrC,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IAY1D,KAAK,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAuBhE,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAUxC,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAO/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAA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
package/core/types.d.ts CHANGED
@@ -19,7 +19,7 @@ export interface GrabErosLoginParams {
19
19
  platform: 'grab' | 'eros';
20
20
  platformUserId: string;
21
21
  platformToken: string;
22
- username?: string | null;
22
+ username: string;
23
23
  inviteCode?: string;
24
24
  }
25
25
  export interface TikTokLoginParams {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAG3C,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAGpF,MAAM,WAAW,SAAS;IAExB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAGvE,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAElC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B,cAAc,EAAE,MAAM,CAAC;IAEvB,aAAa,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,QAAQ,C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AAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEnC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAE7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CACpD;AAMD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,QAAQ;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;CAC1B"}
package/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkR6BPBCQR_cjs=require('./chunk-R6BPBCQR.cjs'),chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');Object.defineProperty(exports,"ErrorCode",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.a}});Object.defineProperty(exports,"Playsout",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.h}});Object.defineProperty(exports,"PlaysoutSDK",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.e}});Object.defineProperty(exports,"SDKError",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.b}});Object.defineProperty(exports,"STORAGE_KEYS",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.d}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.g}});Object.defineProperty(exports,"sdk",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.f}});Object.defineProperty(exports,"storage",{enumerable:true,get:function(){return chunkR6BPBCQR_cjs.c}});Object.defineProperty(exports,"SDKEvent",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.a}});Object.defineProperty(exports,"eventEmitter",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.b}});
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunk5IONEDIP_cjs=require('./chunk-5IONEDIP.cjs'),chunkZ2CIDSTP_cjs=require('./chunk-Z2CIDSTP.cjs');Object.defineProperty(exports,"ErrorCode",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.a}});Object.defineProperty(exports,"Playsout",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.h}});Object.defineProperty(exports,"PlaysoutSDK",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.e}});Object.defineProperty(exports,"SDKError",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.b}});Object.defineProperty(exports,"STORAGE_KEYS",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.d}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.g}});Object.defineProperty(exports,"sdk",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.f}});Object.defineProperty(exports,"storage",{enumerable:true,get:function(){return chunk5IONEDIP_cjs.c}});Object.defineProperty(exports,"SDKEvent",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.a}});Object.defineProperty(exports,"eventEmitter",{enumerable:true,get:function(){return chunkZ2CIDSTP_cjs.b}});