diff --git a/assets/index-44a6e1a5.js b/assets/index-98f9ffb1.js similarity index 75% rename from assets/index-44a6e1a5.js rename to assets/index-98f9ffb1.js index 6714010..c2e1d71 100644 --- a/assets/index-44a6e1a5.js +++ b/assets/index-98f9ffb1.js @@ -95,7 +95,7 @@ void main(void) { vec4 color = texture(u_texture, v_tex); o_color = color; -}`;let St;const ga=new Vt([ne.make(0,O.Float2,!1),ne.make(1,O.Float2,!1)]),ui="u_texture",xi="u_matrix";let Y=x.make(0,0,1,1);const wi=Y.x,ki=Y.y,vi=Y.x+Y.w,bi=Y.y,Ei=Y.x+Y.w,Ti=Y.x+Y.h,Ai=Y.x,Mi=Y.x+Y.h,[Si,zi,Fi,Ri,Ci,Ui,Oi,Di]=[0,0,1,0,1,1,0,1];class Ni{constructor(){o(this,"texture");o(this,"mesh");o(this,"material");o(this,"indices",[0,1,2,0,2,3]);o(this,"vertices",[]);o(this,"matrix");o(this,"sampler",ye.get_default)}set_matrix(a){this.matrix=a,this.vertices=[],this.PUSH_VERTEX(wi,ki,Si,zi),this.PUSH_VERTEX(vi,bi,Fi,Ri),this.PUSH_VERTEX(Ei,Ti,Ci,Ui),this.PUSH_VERTEX(Ai,Mi,Oi,Di)}PUSH_VERTEX(a,e,s,i){let h=this.matrix;this.vertices.push(new Pi(n.make(a*h.m11+e*h.m21+h.m31,a*h.m12+e*h.m22+h.m32),n.make(s,1-i)))}render(a=c.backbuffer){this.render_with_m(a,ie.create_ortho_offcenter(0,a.width,a.height,0,.01,1e3))}render_with_m(a,e){St||(St=qe.create([mi,yi])),this.mesh||(this.mesh=Ve.create()),this.material||(this.material=gt.create(St));let s=ga.stride,i=new ArrayBuffer(s*this.vertices.length),h=new DataView(i);this.vertices.reduce((l,p)=>p.push_to(h,l),0),this.mesh.index_data(this.indices),this.mesh.vertex_data(ga,i);let r=new Kt;r.target=a,r.mesh=this.mesh,r.has_viewport=!1,r.viewport=x.make(0,0,0,0),r.instance_count=0,r.material=this.material,r.material.set_texture(ui,this.texture),r.material.set_sampler_at_location(0,this.sampler),r.material.set_matrix(xi,e),r.index_start=0,r.index_count=this.indices.length,r.perform()}}class Pi{constructor(a,e){this.pos=a,this.tex=e}push_to(a,e){let{pos:s,tex:i}=this;return a.setFloat32(e+0,s.x,!0),a.setFloat32(e+4,s.y,!0),a.setFloat32(e+8,i.x,!0),a.setFloat32(e+12,i.y,!0),e+16}}const zt=new Ni;function Li(t,a,e){return a+(e-a)*t}function he(t,a,e){return t+(a-t)*e}function $t(t,a,e){return t=e.length-1&&(this.loop===1?(this._i=0,this._values.reverse(),this._durations.reverse()):this._completed=!0))}init(){return this._i=0,this._t=0,this._completed=!1,this._value=this._values[0],this}};o(lt,"make",(a,e,s=!1)=>new lt(a.slice(0),[e],s?1:0).init());let Bt=lt;y.hex(2106417);const Bi=y.hex(4895437),_t=class _t{constructor(){o(this,"_render_order",0);o(this,"visible",!0);o(this,"g_position");o(this,"position");o(this,"rotation");o(this,"origin",n.zero);o(this,"scale",n.one);o(this,"coroutines",[]);o(this,"_data");o(this,"_disposes");o(this,"objects");o(this,"parent");o(this,"g_scissor");o(this,"_tweens",[]);o(this,"_tween")}routine(a){this.coroutines.push(a)}*wait_for(a){let e=0;for(;ee[0]!==a)}tween_single(a,e,s,i,h=0,r){return a&&this.cancel(a),this.tween(e,s,i,h,r)}make(a,e,s){let i=this._make(a,e,s);return this._add_object(i),i}init(){return this._disposes=[],this.objects=[],this._init(),this}update(){this.coroutines=this.coroutines.filter(a=>!a.next().done),this.objects.forEach(a=>a.update()),this._tweens=this._tweens.filter(([a,e,s])=>(a.update(b.delta),e(a.value),a.completed&&s&&s(),!a.completed)),this._update()}draw(a){this.visible&&(this._render_order=_t.next_render_order++,this._draw(a))}_draw_children(a){this.objects.forEach(e=>e.draw(a))}dispose(){this.objects.slice(0).forEach(a=>a.dispose()),this._dispose(),this._disposes.forEach(a=>a()),this.parent&&this.parent.objects.splice(this.parent.objects.indexOf(this),1)}_init(){}_update(){}_draw(a){a.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,a.m_matrix),this._draw_children(a),a.pop_matrix()}_dispose(){}};o(_t,"next_render_order",0);let w=_t;class Ke extends w{get data(){return this._data}get nine(){return Se.find_nine(this.data.name)}_draw(a){let{frames:e}=this.nine,s=400/3,i=(this.data.h-s*2)/s,h=(this.data.w-s*2)/s;a.push_matrix(v.create_transform(this.position,n.zero,n.one,0)),this.g_position=n.transform(n.zero,a.m_matrix),a.stex(e[0].image,n.make(0,0),y.white),a.stex_o(e[1].image,n.make(0,s),n.zero,n.make(1,i),0,y.white),a.stex(e[2].image,n.make(0,s+i*s),y.white),a.stex_o(e[3].image,n.make(s,0),n.zero,n.make(h,1),0,y.white),a.stex_o(e[4].image,n.make(s,s),n.zero,n.make(h,i),0,y.white),a.stex_o(e[5].image,n.make(s,s+i*s),n.zero,n.make(h,1),0,y.white),a.stex(e[6].image,n.make(s+h*s,0),y.white),a.stex_o(e[7].image,n.make(s+h*s,s),n.zero,n.make(1,i),0,y.white),a.stex(e[8].image,n.make(s+h*s,s+i*s),y.white),a.pop_matrix()}}class R extends w{constructor(){super(...arguments);o(this,"alpha",255);o(this,"_animation","idle");o(this,"_frame_counter",0);o(this,"_frame",0);o(this,"_loop",!1);o(this,"_reverse",!1);o(this,"_on_complete");o(this,"will_play")}get data(){return this._data}get sprite(){return Se.find_sprite(this.data.name)}get alpha_color(){return new y(this.alpha,this.alpha,this.alpha,this.alpha)}get animation(){return this.sprite.get(this._animation)}get frame(){var e;return(e=this.animation)==null?void 0:e.frames[this._frame]}get subtexture(){var e;return(e=this.frame)==null?void 0:e.image}get duration(){var e;return(e=this.frame)==null?void 0:e.duration}play_now(e,s,i=!1){var h;if(this._on_complete=s,this._animation=e,this._frame=0,i){let r=((h=this.animation)==null?void 0:h.frames.length)||0;this._frame=r-1}this._reverse=i}play(e,s,i=!1){this.will_play=()=>this.play_now(e,s,i)}play_o(e,s){this._loop=s.loop??!1,this.play_now(e)}_update(){var i,h;const e=(i=this.animation)==null?void 0:i.frames.length,s=(h=this.frame)==null?void 0:h.duration;e&&s&&(this._frame_counter+=b.delta,this._frame_counter>=s&&(this._frame_counter-=s,this._reverse?(this._frame--,this._frame<0&&(this._loop?this._frame=e-1:this._frame=0,this._on_complete&&this._on_complete(),this.will_play&&(this.will_play(),this.will_play=void 0))):(this._frame++,this._frame>=e&&(this._loop?this._frame=0:this._frame=e-1,this._on_complete&&this._on_complete(),this.will_play&&(this.will_play(),this.will_play=void 0)))))}_draw(e){this.subtexture&&(e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),e.stex(this.subtexture,n.zero,this.alpha_color),e.pop_matrix())}}const ji=t=>t!==void 0,Hi=t=>{const a={get:e=>t.getItem(e),set:(e,s)=>t.setItem(e,s),remove:e=>t.removeItem(e),make:e=>({get:()=>a.get(e),set:s=>a.set(e,s),remove:()=>a.remove(e)}),makeBoolean:e=>({get:()=>a.get(e)=="1",set:s=>a.set(e,s?"1":"0"),toggle:()=>a.set(e,a.get(e)=="1"?"0":"1")})};return a},ma=Hi(window.localStorage),be=(t,a)=>e=>{if(ji(e))return ma.set(t,JSON.stringify(e)),e;const s=JSON.parse(ma.get(t));return s!==null?s:a()},ya={threecards:1,onecard:1.5,nolimit:1,threepass:1.5,onepass:2.2},le=class le{constructor(a,e,s,i){this.win=a,this.score=e,this.turning_cards=s,this.turning_limit=i}get turning_cards_multiplier(){return ya[this.turning_cards]}get turning_limit_multiplier(){return ya[this.turning_limit]}get multiplied_score(){return this.score*(this.turning_cards_multiplier+this.turning_limit_multiplier)}get fen(){return[this.win,this.score,this.turning_cards,this.turning_limit].join("/")}};o(le,"from_fen",a=>{let[e,s,i,h]=a.split("/");return new le(e==="true",parseInt(s),i,h)}),o(le,"from_win",(a,e)=>new le(!0,e,a.cards,a.limit)),o(le,"from_loss",(a,e)=>new le(!1,e,a.cards,a.limit));let He=le;const dt=class dt{constructor(a){this.list=a}get fen(){return this.list.map(a=>a.fen).join("$")}push(a){this.list.push(a)}clear(){this.list.length=0}get total_wins(){return this.list.filter(a=>a.win).length}get total_played(){return this.list.length}get top_5_highscores(){return this.list.sort((a,e)=>e.multiplied_score-a.multiplied_score).slice(0,5)}};o(dt,"from_fen",(a,e)=>new dt(a===""?[]:a.split("$").map(s=>e(s))));let ze=dt;class Xi{constructor(a,e,s){this.solitaire=a,this.freecell=e,this.spider=s}get total_wins(){return this.freecell_total_wins+this.spider_total_wins+this.solitaire_total_wins}get total_played(){return this.freecell_total_played+this.spider_total_played+this.solitaire_total_played}get top_5_highscores(){return[...this.freecell_top_5_highscores,...this.spider_top_5_highscores,...this.solitaire_top_5_highscores].sort((a,e)=>e.multiplied_score-a.multiplied_score).slice(0,5)}get freecell_total_wins(){return this.freecell.total_wins}get freecell_total_played(){return this.freecell.total_played}get freecell_top_5_highscores(){return this.freecell.top_5_highscores}get spider_total_wins(){return this.spider.total_wins}get spider_total_played(){return this.spider.total_played}get spider_top_5_highscores(){return this.spider.top_5_highscores}get solitaire_total_wins(){return this.solitaire.total_wins}get solitaire_total_played(){return this.solitaire.total_played}get solitaire_top_5_highscores(){return this.solitaire.top_5_highscores}}let ua=["nolimit","threepass","onepass"],xa=["threecards","onecard"];class Vi{constructor(){o(this,"_cards");o(this,"_limit");let a="threecards";this._cards=be("cards",()=>a);let e="nolimit";this._limit=be("limit",()=>e)}get cards(){return this._cards()}set cards(a){this._cards(a)}get limit(){return this._limit()}set limit(a){this._limit(a)}get general_settings(){let{limit:a,cards:e}=this;return{limit:a,cards:e}}}class qi{constructor(){o(this,"_music");o(this,"_sound");o(this,"_language");let a="en";this._language=be("language",()=>a),this._sound=be("sound",()=>!0),this._music=be("music",()=>!0)}get music(){return this._music()}set music(a){this._music(a)}get sound(){return this._sound()}set sound(a){this._sound(a)}get language(){return this._language()}set language(a){this._language(a)}}let De=new Vi,ee=new qi;class Ki{constructor(){o(this,"_results");this._results=be("solitaire_results",()=>new ze([]).fen)}set results(a){this._results(a.fen)}get results(){return ze.from_fen(this._results(),He.from_fen)}add_result(a){let e=this.results;e.push(a),this.results=e}clear_results(){let a=this.results;a.clear(),this.results=a}}let mt=new Ki;function wa(t){return new Audio(t)}let Gi=["Win","auto_flip","drag1","drag2","drag3","cancel","drop","hit","recycle","undo2"];class Wi{constructor(){o(this,"audios");o(this,"musics");o(this,"load",async()=>{this.audios={},Gi.forEach(a=>this.audios[a]=[...Array(4).keys()].map(()=>wa(`./audio/${a}.wav`))),this.musics={},this.musics.main=wa("./music/SoundBox-music.wav")})}play(a){if(!ee.sound)return;let e=this.audios[a],s=e.pop();e.unshift(s),s.play()}stop_music(){this.musics.main.pause()}music(a){if(!ee.music)return;let e=this.musics[a];e.loop=!0,e.play()}}const X=new Wi,oe=1/60,E={seconds:60*oe,half:30*oe,thirds:20*oe,lengths:15*oe,sixth:10*oe,five:5*oe,three:3*oe,one:1*oe},L=n.make(1920,1080),Yi=(t=1)=>()=>{var a=Math.sin(t++)*1e4;return a-Math.floor(a)},ue=Yi();function qa(t,a=ue){return Math.floor(a()*t)}function ka(t=ue){return t()*2-1}function Qi(t,a=ue){return t[qa(t.length,a)]}const N=(t=ue)=>n.make(t(),t()),va=(t=ue)=>n.make(ka(t),ka(t));class Ji extends w{get data(){return this._data}_init(){let a=this.make(R,n.make(0,0),{name:"button_bg"});a.origin=n.make(366,200).scale(1/2),this.make(T,n.make(0,-30),{width:360,height:100,key:this.data.text,center:!0});let e=this;this.make(D,n.make(-366+80,-200+80).scale(1/2),{rect:x.make(0,0,366-80,200-80),on_hover(){a.play_o("hover",{loop:!1})},on_hover_end(){a.play("hover",()=>{a.play("idle")},!0)},on_click_begin(){a.play_o("click",{loop:!1})},on_click(){e.data.on_click()}})}}var Zi=Object.defineProperty,eh=(t,a,e)=>a in t?Zi(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,M=(t,a,e)=>(eh(t,typeof a!="symbol"?a+"":a,e),e),Yt=["d","c","h","s"],Ka=["A","K","Q","J","T","9","8","7","6","5","4","3","2"],jt=["A","2","3","4","5","6","7","8","9","T","J","Q","K"],th=Yt.flatMap(t=>Ka.map(a=>`${t}${a}`)),ah=t=>{let a=Yt.indexOf(t[0]),e=Ka.indexOf(t[1]);return a*100+e};function ba(t){switch(t[0]){case"d":case"h":return"red";default:return"black"}}function sh(t,a){return jt[jt.indexOf(a[1])-1]===t[1]}function ih(t,a){return ba(t)!=ba(a)}function hh(t){return t[1]==="K"}function rh(t){return t[1]==="A"}var Ga=class{static get deck(){return th.slice(0)}};function nh(t){let a=[];for(let e=0;e=0;a--)this.cards.unshift(t[a])}remove_cards(t){return this.cards.splice(-t)}remove_all(){return this.remove_cards(this.cards.length)}},K=Xe;M(K,"take_n",(t,a)=>new Xe(t.splice(0,a)));M(K,"from_fen",t=>new Xe(nh(t)));var Qt="??",yt=class{constructor(t){this.cards=t}get fen(){return this.cards.join(" ")}get clone(){return new yt(this.cards.slice(0))}get length(){return this.cards.length}get top_card(){return this.cards[this.cards.length-1]}unshift_cards(t){for(let a=t.length-1;a>=0;a--)this.cards.push(t[a])}shift_cards(t){return this.cards.splice(0,t)}add_cards(t){this.cards.push(...t)}remove_cards(t){return this.cards.splice(-t)}remove_all(){return this.remove_cards(this.cards.length)}},rt=yt;M(rt,"from_fen",t=>new yt(t===""?[]:t.split(" ")));M(rt,"backs",t=>new yt([...Array(t).keys()].map(a=>Qt)));var xe=class{constructor(t){o(this,"_data");this.game=t}_set_data(t){return this._data=t,this}},Wa=class{constructor(t,a,e){this.game=t,this.stats=a,this.history=e}get nb_moves(){return this.stats.nb_moves}set nb_moves(t){this.stats.nb_moves=t}get score(){return this.stats.score}set score(t){this.stats.score=t}get pov(){return new Qa(this.game.pov,this.stats,this.history.length)}apply(t,a){let e=new t(this.game)._set_data(a);if(!t.can(this.game.pov,a))return;let s=e.apply();return this.score+=s,this.nb_moves++,this.history.push(e),e}get can_undo(){return this.history.length>0}undo(){if(!this.can_undo)return;let t=this.history.pop(),a=t.undo();return this.score+=a,this.nb_moves++,t}},Ya=Wa;M(Ya,"make",t=>new Wa(t,{score:0,nb_moves:0},[]));var Qa=class{constructor(t,a,e){o(this,"history");this.game=t,this.stats=a,this.history=e}finalize_apply_pov(t){this.game.finalize_apply_pov(t)}get clone(){let t=this.game.clone;return new Qa(t,{...this.stats},this.history)}get nb_moves(){return this.stats.nb_moves}set nb_moves(t){this.stats.nb_moves=t}get score(){return this.stats.score}set score(t){this.stats.score=t}get can_undo(){return this.history>0}apply(t,a){t.apply(this.game,a),this.nb_moves++,this.history++}undo_pov(){this.nb_moves++,this.history--}undo(t){t.undo_pov(this.game)}},$={Recycle:-10,HitStock:0,WasteToTableu:10,WasteToFoundation:30,TableuToFoundation:20,FoundationToTableu:-30,Undo:-80,TableuToTableuFlip:10,TableuToTableuNoFlip:0};function oh(t){let[a,e]=t.split("$");return{cards:a,limit:e}}function lh(t){return[t.cards,t.limit].join("$")}var Jt=class{constructor(t,a,e){this.stock=t,this.waste=a,this.hidden=e}get fen(){return[this.stock.fen,this.waste.fen,this.hidden.fen].join("$")}get pov(){return new es(this.stock.hidden_pov,this.waste,this.hidden.hidden_pov)}get can_hit(){return this.stock.length>0}get can_recycle(){return this.stock.length===0&&this.waste.length+this.hidden.length>0}from_waste(){return{cards:this.waste.remove_cards(1)}}undo_from_waste(t){this.waste.add_cards(t)}hit(t){let a=this.stock.remove_cards(t),e=this.waste.remove_all();return this.hidden.unshift_cards(e),this.waste.add_cards(a),{waste:e,cards:a}}undo_hit(t){let{cards:a,waste:e}=t,s=this.waste.remove_cards(a.length),i=this.hidden.shift_cards(e.length);this.waste.add_cards(i),this.stock.add_cards(s)}recycle(){let t=this.waste.remove_all();return this.hidden.unshift_cards(t),this.stock.add_cards(this.hidden.remove_all()),{waste:t}}undo_recycle(t){let{waste:a}=t;this.hidden.add_cards(this.stock.remove_all());let e=this.hidden.shift_cards(a.length);this.waste.add_cards(e)}},ut=Jt;M(ut,"from_fen",t=>{let[a,e,s]=t.split("$"),i=K.from_fen(a),h=K.from_fen(e),r=K.from_fen(s);return new Jt(i,h,r)});M(ut,"make",t=>new Jt(K.take_n(t,t.length),K.empty,K.empty));var Zt=class{constructor(t,a){this.back=t,this.front=a}get fen(){return[this.back.fen,this.front.fen].join("$")}get pov(){return new ts(this.back.hidden_pov,this.front)}from_tableu(t){let a=this.front.remove_cards(t);if(this.front.length===0){let[e]=this.back.remove_cards(1);return e?(this.front.add_cards([e]),{flip:e,cards:a}):{cards:a}}return{cards:a}}undo_from_tableu(t){if(t.flip){let a=this.front.remove_cards(1);this.back.add_cards(a)}this.front.add_cards(t.cards)}to_tableu(t){this.front.add_cards(t)}undo_to_tableu(t){this.front.remove_cards(t.length)}},xt=Zt;M(xt,"from_fen",t=>{let[a,e]=t.split("$");return new Zt(K.from_fen(a),K.from_fen(e))});M(xt,"make",(t,a)=>new Zt(K.take_n(t,a),K.take_n(t,1)));var wt=class{constructor(t){this.foundation=t}get fen(){return this.foundation.fen}get clone(){return new wt(this.foundation.clone)}get suit(){var t;return(t=this.foundation.top_card)==null?void 0:t[0]}get is_finished(){return this.foundation.length===13}get next_top(){if(!this.suit)return;let t=this.suit,a=jt[this.foundation.length];return`${t}${a}`}get can_from(){let{top_card:t}=this.foundation;if(t)return{cards:[t]}}can_to(t){let[a]=t;return t.length===1&&(this.next_top?a===this.next_top:rh(a))}to_foundation(t){this.foundation.add_cards(t)}undo_to_foundation(t){this.foundation.remove_cards(t.length)}from_foundation(){return{cards:this.foundation.remove_cards(1)}}undo_from_foundation(t){this.foundation.add_cards(t)}},kt=wt;M(kt,"from_fen",t=>{let a=t;return new wt(K.from_fen(a))});M(kt,"make",()=>new wt(K.empty));var st=[...Array(7).keys()],Ea=[...Array(4).keys()],ea=class{constructor(t,a,e,s,i){this.settings=t,this.nb_recycles=a,this.stock=e,this.tableus=s,this.foundations=i}get fen(){let t=lh(this.settings),a=this.stock.fen,e=this.tableus.map(h=>h.fen).join("/"),s=this.foundations.map(h=>h.fen).join("/"),i=this.nb_recycles;return[t,i,a,e,s].join(" ")}get hit_n(){return this.settings.cards==="threecards"?3:1}get pov(){return new as(this.settings,this.nb_recycles,this.stock.pov,this.tableus.map(t=>t.pov),this.foundations)}get recycle_n(){return this.settings.limit==="nolimit"?9999:this.settings.limit==="threepass"?3:1}get can_hit(){return this.stock.can_hit}get can_recycle(){return this.has_recycle_limit&&this.stock.can_recycle}get has_recycle_limit(){return this.recycle_n-this.nb_recycles>0}hit_stock(){return this.stock.hit(this.hit_n)}undo_hit_stock(t){this.stock.undo_hit(t)}recycle(){return this.nb_recycles++,this.stock.recycle()}undo_recycle(t){this.nb_recycles--,this.stock.undo_recycle(t)}tableu_to_tableu(t){let{from:a,to:e,i:s}=t,i=this.tableus[a].from_tableu(s);return this.tableus[e].to_tableu(i.cards),i}undo_tableu_to_tableu(t,a){let{from:e,to:s,i}=t;this.tableus[s].undo_to_tableu(a.cards),this.tableus[e].undo_from_tableu(a)}waste_to_tableu(t){let{to:a}=t,e=this.stock.from_waste();return this.tableus[a].to_tableu(e.cards),e}undo_waste_to_tableu(t,a){let{to:e}=t;this.tableus[e].undo_to_tableu(a.cards),this.stock.undo_from_waste(a.cards)}waste_to_foundation(t){let{to:a}=t,e=this.stock.from_waste();return this.foundations[a].to_foundation(e.cards),e}undo_waste_to_foundation(t,a){let{to:e}=t;this.foundations[e].undo_to_foundation(a.cards),this.stock.undo_from_waste(a.cards)}tableu_to_foundation(t){let{from:a,to:e}=t,s=this.tableus[a].from_tableu(1);return this.foundations[e].to_foundation(s.cards),s}undo_tableu_to_foundation(t,a){let{from:e,to:s}=t;this.foundations[s].undo_to_foundation(a.cards),this.tableus[e].undo_from_tableu(a)}foundation_to_tableu(t){let{from:a,to:e}=t,s=this.foundations[a].from_foundation();return this.tableus[e].to_tableu(s.cards),s}undo_foundation_to_tableu(t,a){let{from:e,to:s}=t;this.tableus[s].undo_to_tableu(a.cards),this.foundations[e].undo_from_foundation(a.cards)}},ta=ea;M(ta,"from_fen",t=>{let[a,e,s,i,h]=t.split(" "),r=oh(a),l=parseInt(e),p=ut.from_fen(s),d=i.split("/").map(f=>xt.from_fen(f)),g=h.split("/").map(f=>kt.from_fen(f));return new ea(r,l,p,d,g)});M(ta,"make",(t,a)=>{let e=st.map(h=>xt.make(a,h)),s=ut.make(a),i=0;return new ea(t,i,s,e,Yt.map(h=>kt.make()))});var Ee=class extends xe{constructor(){super(...arguments);o(this,"data")}get solitaire(){return this.game}apply(){return this.data=this.solitaire.hit_stock(),$.HitStock}undo(){return this.solitaire.undo_hit_stock(this.data),$.Undo}undo_pov(a){a.undo_hit_stock(this.data)}};M(Ee,"can",t=>t.can_hit);M(Ee,"apply",t=>{t.hit_stock()});var Ie=class extends xe{constructor(){super(...arguments);o(this,"data")}get solitaire(){return this.game}apply(){return this.data=this.solitaire.recycle(),$.Recycle}undo(){return this.solitaire.undo_recycle(this.data),$.Undo}undo_pov(a){a.undo_recycle(this.data)}};M(Ie,"can",t=>t.can_recycle);M(Ie,"apply",t=>{t.recycle()});var ce=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.tableu_to_tableu(this.data),this.res.flip?$.TableuToTableuFlip:$.TableuToTableuNoFlip}undo(){return this.solitaire.undo_tableu_to_tableu(this.data,this.res),$.Undo}undo_pov(a){a.undo_tableu_to_tableu(this.data,this.res)}};M(ce,"can",(t,a)=>{let e=a,s=t.can_drag_tableu(e);return s?t.can_drop_tableu({...a,...s}):!1});M(ce,"apply",(t,a)=>{t.tableu_to_tableu(a)});var pe=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.waste_to_tableu(this.data),$.WasteToTableu}undo(){return this.solitaire.undo_waste_to_tableu(this.data,this.res),$.Undo}undo_pov(a){a.undo_waste_to_tableu(this.data,this.res)}};M(pe,"can",(t,a)=>{const e=t.can_drag_waste;return e?t.can_drop_tableu({...a,...e}):!1});M(pe,"apply",(t,a)=>{t.waste_to_tableu(a)});var Ja=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.waste_to_foundation(this.data),$.WasteToFoundation}undo(){return this.solitaire.undo_waste_to_foundation(this.data,this.res),$.Undo}undo_pov(a){a.undo_waste_to_foundation(this.data,this.res)}},j=Ja;M(j,"auto_can",t=>{for(let a=0;a<4;a++)if(Ja.can(t,{to:a}))return{to:a}});M(j,"can",(t,a)=>{const e=t.can_drag_waste;return e?t.can_drop_foundation({...a,...e}):!1});M(j,"apply",(t,a)=>{t.waste_to_foundation(a)});var Za=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.tableu_to_foundation(this.data),$.TableuToFoundation}undo(){return this.solitaire.undo_tableu_to_foundation(this.data,this.res),$.Undo}undo_pov(a){a.undo_tableu_to_foundation(this.data,this.res)}},H=Za;M(H,"auto_can",(t,a)=>{let{tableu:e}=a;for(let s=0;s<4;s++)if(Za.can(t,{from:e,to:s}))return{from:e,to:s}});M(H,"can",(t,a)=>{const e=t.can_drag_tableu({...a,i:1});return e?t.can_drop_foundation({...a,...e}):!1});M(H,"apply",(t,a)=>{t.tableu_to_foundation(a)});var ke=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.foundation_to_tableu(this.data),$.FoundationToTableu}undo(){return this.solitaire.undo_foundation_to_tableu(this.data,this.res),$.Undo}undo_pov(a){a.undo_foundation_to_tableu(this.data,this.res)}};M(ke,"can",(t,a)=>{const e=t.can_drag_foundation(a);return e?t.can_drop_tableu({...a,...e}):!1});M(ke,"apply",(t,a)=>{t.foundation_to_tableu(a)});var es=class{constructor(t,a,e){this.stock=t,this.waste=a,this.hidden=e}pov_hit_stock(t){this.waste.remove_cards(t.length),this.waste.add_cards(t)}get can_hit(){return this.stock.length>0}get can_recycle(){return this.stock.length===0&&this.waste.length+this.hidden.length>0}get can_from_waste(){let{top_card:t}=this.waste;if(t)return{cards:[t]}}get clone(){return new es(this.stock.clone,this.waste.clone,this.hidden.clone)}from_waste(){return{cards:this.waste.remove_cards(1)}}undo_from_waste(t){this.waste.add_cards(t)}hit(t){let a=this.stock.remove_cards(t),e=this.waste.remove_all();this.hidden.unshift_cards(e),this.waste.add_cards(a)}undo_hit(t){let{cards:a,waste:e}=t;this.waste.remove_cards(a.length),this.hidden.shift_cards(e.length),this.waste.add_cards(e),this.stock.add_cards(a)}recycle(){let t=this.waste.remove_all();return this.hidden.unshift_cards(t),this.stock.add_cards(this.hidden.remove_all()),{waste:t}}undo_recycle(t){let{waste:a}=t;this.hidden.add_cards(this.stock.remove_all());let e=this.hidden.shift_cards(a.length);this.waste.add_cards(e)}},ts=class{constructor(t,a){this.back=t,this.front=a}pov_flip(t){this.front.remove_cards(1),this.front.add_cards([t])}get clone(){return new ts(this.back.clone,this.front.clone)}can_from(t){let a=this.front.clone;this.back.clone;let e=a.remove_cards(t);if(e.length===t)return{cards:e}}can_to(t){let a=t[0];return a?this.front.length>0?ih(a,this.front.top_card)&&sh(a,this.front.top_card):hh(a):!1}from_tableu(t){let a=this.front.remove_cards(t);if(this.front.length===0){let[e]=this.back.remove_cards(1);return e?(this.front.add_cards([e]),{flip:e,cards:a}):{cards:a}}return{cards:a}}undo_from_tableu(t){if(t.flip){let a=this.front.remove_cards(1);this.back.add_cards(a)}this.front.add_cards(t.cards)}to_tableu(t){this.front.add_cards(t)}undo_to_tableu(t){this.front.remove_cards(t.length)}},as=class{constructor(t,a,e,s,i){this.settings=t,this.nb_recycles=a,this.stock=e,this.tableus=s,this.foundations=i}get clone(){return new as(this.settings,this.nb_recycles,this.stock.clone,this.tableus.map(t=>t.clone),this.foundations.map(t=>t.clone))}get recycle_n(){return this.settings.limit==="nolimit"?9999:this.settings.limit==="threepass"?3:1}get hit_n(){return this.settings.cards==="threecards"?3:1}get has_recycle_limit(){return this.recycle_n-this.nb_recycles>0}get can_hit(){return this.stock.can_hit}get can_recycle(){return this.has_recycle_limit&&this.stock.can_recycle}get is_finished(){return this.foundations.every(t=>t.is_finished)}can_drag_tableu(t){let{from:a,i:e}=t;return this.tableus[a].can_from(e)}can_drop_tableu(t){let{to:a,cards:e}=t;return this.tableus[a].can_to(e)}can_drop_foundation(t){let{to:a,cards:e}=t;return this.foundations[a].can_to(e)}get can_drag_waste(){return this.stock.can_from_waste}can_drag_foundation(t){let{from:a}=t;return this.foundations[a].can_from}hit_stock(){return this.stock.hit(this.hit_n)}undo_hit_stock(t){this.stock.undo_hit(t)}recycle(){return this.nb_recycles++,this.stock.recycle()}undo_recycle(t){this.nb_recycles--,this.stock.undo_recycle(t)}finalize_apply_pov(t){if(t instanceof ce&&t.res.flip){let{from:a}=t.data;this.tableus[a].pov_flip(t.res.flip)}if(t instanceof H&&t.res.flip){let{from:a}=t.data;this.tableus[a].pov_flip(t.res.flip)}t instanceof Ee&&this.stock.pov_hit_stock(t.data.cards)}tableu_to_tableu(t){let{from:a,to:e,i:s}=t,i=this.tableus[a].from_tableu(s);return this.tableus[e].to_tableu(i.cards),i}undo_tableu_to_tableu(t,a){let{from:e,to:s,i}=t;this.tableus[s].undo_to_tableu(a.cards),this.tableus[e].undo_from_tableu(a)}waste_to_tableu(t){let{to:a}=t,e=this.stock.from_waste();return this.tableus[a].to_tableu(e.cards),e}undo_waste_to_tableu(t,a){let{to:e}=t;this.tableus[e].undo_to_tableu(a.cards),this.stock.undo_from_waste(a.cards)}waste_to_foundation(t){let{to:a}=t,e=this.stock.from_waste();return this.foundations[a].to_foundation(e.cards),e}undo_waste_to_foundation(t,a){let{to:e}=t;this.foundations[e].undo_to_foundation(a.cards),this.stock.undo_from_waste(a.cards)}tableu_to_foundation(t){let{from:a,to:e}=t,s=this.tableus[a].from_tableu(1);return this.foundations[e].to_foundation(s.cards),s}undo_tableu_to_foundation(t,a){let{from:e,to:s}=t;this.foundations[s].undo_to_foundation(a.cards),this.tableus[e].undo_from_tableu(a)}foundation_to_tableu(t){let{from:a,to:e}=t,s=this.foundations[a].from_foundation();return this.tableus[e].to_tableu(s.cards),s}undo_foundation_to_tableu(t,a){let{from:e,to:s}=t;this.tableus[s].undo_to_tableu(a.cards),this.foundations[e].undo_from_foundation(a.cards)}};const Ft={s:"spades",d:"diamonds",h:"hearts",c:"clubs"},_h={A:"a",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",T:"t",J:"j",Q:"q",K:"k"};class dh extends w{constructor(){super(...arguments);o(this,"_card");o(this,"rank");o(this,"rsuit");o(this,"suit");o(this,"decsuit")}get waiting(){return this._card===Qt}get card(){return this._card}set card(e){this._card=e,this.rank.play_now(_h[e[1]]),this.suit.play_now(Ft[e[0]]),this.rsuit.play_now(Ft[e[0]]),this.decsuit.forEach(s=>s.play_now(Ft[e[0]]))}_init(){let e=n.make(40,50);this.decsuit=[...Array(3).keys()].map(()=>e=e.add(N().mul(n.make(4,30)).add(n.make(0,30)))).map(i=>{let h=this.make(R,i,{name:"suit"});return h.origin=n.make(32,32),h.play_now("spades"),h.scale=n.one.scale(N().x*.2).add(n.make(.2,.2)),h});let s=[...Array(2).keys()].map(()=>e=e.sub(N().mul(n.make(24,20)).add(n.make(0,30)))).map(i=>{i.x+=120;let h=this.make(R,i,{name:"suit"});return h.origin=n.make(32,32),h.play_now("spades"),h.scale=n.one.scale(N().x*.2).add(n.make(.2,.2)),h});this.decsuit.push(...s),this.rank=this.make(R,n.make(140,32),{name:"rank_2"}),this.rank.origin=n.make(32,32),this.rank.play_now("a"),this.rank.scale=n.make(.6,.6),this.suit=this.make(R,n.make(30,32),{name:"suit"}),this.suit.origin=n.make(32,32),this.suit.play_now("spades"),this.suit.scale=n.make(.6,.6),this.rsuit=this.make(R,n.make(150,210),{name:"suit"}),this.rsuit.origin=n.make(32,32),this.rsuit.rotation=Math.PI,this.rsuit.play_now("spades"),this.rsuit.scale=n.make(.6,.6)}}class ch extends w{constructor(){super(...arguments);o(this,"decoration");o(this,"_will_lerp_t");o(this,"_will_lerp_position");o(this,"_dragging");o(this,"_drag_decay",n.zero);o(this,"_on_drag");o(this,"_on_drop");o(this,"_on_hover");o(this,"_on_click");o(this,"facing");o(this,"anim");o(this,"shadow");o(this,"highlight");o(this,"_will_hover");o(this,"_will_hover_end");o(this,"_will_flip_back");o(this,"_will_flip_front");o(this,"lerp_hover_y");o(this,"_lerp_drag_shadow");o(this,"_tr");o(this,"_tx");o(this,"_ty");o(this,"_target_speed");o(this,"_speed");o(this,"_hover_time");o(this,"_after_ease")}release(){this.lerp_position(),this.unset_dragging(),this.set_highlight(!1),this.bind_click(void 0),this.bind_drag(void 0),this.bind_drop(void 0),this.bind_hover(void 0),this._after_ease=void 0}lerp_release(){this.lerp_position(),this.unset_dragging()}get waiting(){return this.decoration.waiting}get card(){return this.decoration.card}set card(e){this.decoration.card=e,this.waiting?this.anim._animation==="idle"&&(this.anim.play_now("wait"),this.decoration.visible=!1):this.anim._animation==="wait"&&(this.anim.play_now("idle"),this.decoration.visible=!0)}get flipping(){return this.anim._animation==="flip"||this.anim._animation==="back_flip"}get easing(){return!!this._tx||!!this._ty||!!this._tr}lerp_position(e,s){this._tx&&(this.cancel(this._tx),this._tx=void 0),this._ty&&(this.cancel(this._ty),this._ty=void 0),this._will_lerp_position=e,this._will_lerp_t=s,e?this._target_speed=(1-(s||.5))*.2:this._target_speed=0}get drag_decay(){return this._drag_decay}bind_drag(e){this._on_drag=e}bind_drop(e){this._on_drop=e}bind_hover(e){this._on_hover=e}bind_click(e){this._on_click=e}get hover_time(){return this._hover_time??0}ease_rotation(e,s=E.half){this._tr=this.tween_single(this._tr,[this.rotation,e],i=>{this.rotation=i},s,0,()=>{this._tr=void 0})}ease_position(e,s=E.half){e.equals(this.position)||(this._target_speed=s/E.half*.2,this._tx=this.tween_single(this._tx,[this.position.x,e.x],i=>{this.position.x=i},s,0,()=>{this._tx=void 0,this._target_speed=0}),this._ty=this.tween_single(this._ty,[this.position.y,e.y],i=>{this.position.y=i},s,0,()=>{this._ty=void 0}))}set_highlight(e){this.highlight.visible=e}set_dragging(){this._lerp_drag_shadow=0,this._dragging=!0}unset_dragging(){this._dragging=!1}after_ease(e){this._after_ease=e}_init(){this.shadow=this._make(R,n.make(0,0),{name:"card"}),this.shadow.origin=n.make(88,120),this.shadow.play_now("shadow"),this.anim=this.make(R,n.make(0,0),{name:"card"}),this.anim.origin=n.make(88,120),this.facing=-1,this.anim.play_now("back_idle"),this.highlight=this.make(R,n.make(0,0),{name:"card"}),this.highlight.origin=n.make(88,120),this.highlight.play_now("highlight"),this.highlight.visible=!1,this.decoration=this.make(dh,n.make(-80,-120),{}),this.decoration.visible=!1,this.decoration.card=Qt,this._will_hover=!1,this._will_hover_end=!1,this._will_flip_back=!1,this._will_flip_front=!1,this.lerp_hover_y=0,this._dragging=!1,this._speed=0,this._target_speed=0;let e=this;this.make(D,n.make(16,16).sub(this.anim.origin),{rect:x.make(0,0,170,210),on_click(){if(e._on_click)return e._on_click()},on_hover(){return e._on_hover&&e._on_hover[0](),e._on_drag?(e._will_hover=!0,!0):!1},on_hover_end(){e._on_hover&&e._on_hover[1](),e._will_hover_end=!0},on_drag_begin(s){return e._on_drag?(e._lerp_drag_shadow=0,e._dragging=!0,e._drag_decay=s.sub(e.position),!0):!1},on_drag_end(){e._dragging=!1},on_drag(s){return e._on_drag?(e._on_drag(s),!0):!1},on_drop(){e._on_drop&&e._on_drop()}})}_update(){this._speed=he(this._speed,this._target_speed,.2);let e=$i(Math.abs(Math.sin(b.seconds*3)))*this._speed;if(this.scale=n.make(1-e,1+e),this._will_lerp_position&&(this.position=n.lerp(this.position,this._will_lerp_position,this._will_lerp_t??.5)),this._lerp_drag_shadow!==void 0&&(this._dragging?this._lerp_drag_shadow=he(this._lerp_drag_shadow,1,.2):(this._lerp_drag_shadow=he(this._lerp_drag_shadow,0,.2),this._lerp_drag_shadow<.001&&(this._lerp_drag_shadow=void 0))),this._lerp_drag_shadow!==void 0){let s=this._lerp_drag_shadow*.05;this.shadow.scale=n.one.add(n.one.scale(s)),this.shadow.alpha=(1-this._lerp_drag_shadow)*100+155}if(this._after_ease&&!this.easing&&(this._after_ease(),this._after_ease=void 0),this.easing||(this.anim.position.y=he(this.anim.position.y,this.lerp_hover_y,.2),this.decoration.position.y=he(this.decoration.position.y,this.lerp_hover_y-120,.16),this.highlight.position.y=he(this.highlight.position.y,this.lerp_hover_y,.16)),this._will_hover&&(this._will_hover=!1,!this.easing&&!this.flipping&&this._will_flip_back&&this._will_flip_front&&this.anim.play(this.facing===1?"hover":"back_hover"),this.lerp_hover_y=-6,this._hover_time=0),this._will_hover_end){this._will_hover_end=!1;let s=this.waiting?"wait":"idle";!this.easing&&!this.flipping&&this._will_flip_back&&this._will_flip_front&&this.anim.play(this.facing===1?s:"back_idle"),this.lerp_hover_y=0,this._hover_time=void 0}this._hover_time!==void 0&&this._hover_time>=0&&(this.easing&&(this._hover_time=0),this._hover_time+=b.delta),this._will_flip_back&&(this.easing||(this._will_flip_back=!1,this.shadow.visible=!1,this.decoration.visible=!1,this.anim.play_now("flip",()=>{this.facing=-1,this.anim.play("back_idle"),this.shadow.visible=!0}))),this._will_flip_front&&(this.easing||(this._will_flip_front=!1,this.shadow.visible=!1,this.decoration.visible=!1,this.anim.play_now("back_flip",()=>{this.facing=1,this.anim.play(this.waiting?"wait":"idle"),this.shadow.visible=!0,this.waiting||(this.decoration.visible=!0)})))}flip_back(){this._will_flip_front=!1,this._will_flip_back=this.facing!==-1||this.anim._animation==="back_flip"}flip_front(){this._will_flip_back=!1,this._will_flip_front=this.facing!==1||this.anim._animation==="flip"}_draw_shadow(e){e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),this.shadow.draw(e),e.pop_matrix()}}class ss extends w{constructor(){super(...arguments);o(this,"_on_click");o(this,"_on_drop");o(this,"_will_hover");o(this,"_will_hover_end");o(this,"anim")}bind_click(e){this._on_click=e}bind_drop(e){this._on_drop=e}_init(){this.anim=this._make(R,n.make(0,0),{name:"card"}),this.anim.origin=n.make(88,120);let e=this;this.make(D,n.make(16,16).sub(this.anim.origin),{rect:x.make(0,0,170,210),on_hover(){return e._on_drop?(e._will_hover=!0,!0):!1},on_hover_end(){e._will_hover_end=!0},on_drop(){e._on_drop&&e._on_drop()},on_click(){return e._on_click?(e._on_click(),!0):!1}})}_update(){this._will_hover&&(this._will_hover=!1),this._will_hover_end&&(this._will_hover_end=!1)}}class ph extends w{constructor(){super(...arguments);o(this,"frees");o(this,"used");o(this,"_shadow_group")}borrow(){let e=this.frees.shift();return this.used.push(e),e.visible=!0,e}release(e){e.visible=!1,this.used.splice(this.used.indexOf(e),1),e.release(),this.frees.push(e)}set shadow_group(e){this._shadow_group=e}_init(){this.frees=Ga.deck.map(e=>{let s=this.make(ch,n.zero,{});return s.visible=!1,s}),this.used=[]}_draw(e){var s,i;e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),this._draw_children(e),(s=this._shadow_group)==null||s.forEach(h=>{h._draw_shadow(e)}),(i=this._shadow_group)==null||i.forEach(h=>{h.draw(e)}),e.pop_matrix()}}class Te extends w{constructor(){super(...arguments);o(this,"_i_gap");o(this,"cards")}get data(){return this._data}get length(){return this.cards.length}get top_card(){return this.cards[this.cards.length-1]}get h(){let e=55*(1-this.cards.length/50);return this.data.h??e}get top_position(){return this.position.add(n.make(0,this.cards.length*this.h))}set_highlight(e,s){this.cards.slice(this.cards.length-e,this.cards.length).forEach(h=>h.set_highlight(s))}add_cards(e){e.forEach(s=>s.send_front()),this.cards.push(...e),this._reposition()}remove_cards(e){let s=this.cards.splice(this.cards.length-e,this.cards.length);return this._reposition(),s}set i_gap(e){this._i_gap!==e&&(this._i_gap=e,this._reposition())}_reposition(){this.cards.forEach((e,s)=>{let i=this._i_gap!==void 0&&s>this._i_gap?s+.5:s;e.ease_position(this.p_position.add(n.make(0,i*this.h)))})}ease_position(e){this.position=e,this._reposition()}_init(){this.cards=[]}}function fh(t){return 1/(1+Math.exp(-t))}class Rt extends w{constructor(){super(...arguments);o(this,"_waiting",!1);o(this,"_cards")}get waiting(){return this._waiting}wait_drop(){this._waiting=!0}set cards(e){this._cards=e.slice(0),this._cards.forEach(s=>s.send_front()),this._cards.forEach(s=>s.set_dragging())}get drag_decay(){return this._cards[0].drag_decay}get h(){return 50}drag(e){this._cards.forEach((s,i)=>{let h=e.add(n.make(0,this.h*i).sub(this.drag_decay)),r=1-fh(i/this._cards.length*2);s.lerp_position(h,r)})}lerp_release(){let e=this._cards.splice(0);return e.forEach(s=>s.lerp_release()),e}_init(){this._cards=[]}}class gh extends w{constructor(){super(...arguments);o(this,"backs");o(this,"fronts");o(this,"drop_target")}get data(){return this._data}get top_front_position(){return this.fronts.top_position}get top_back_position(){return this.backs.top_position}release_all(){return this.free()}free(){return[...this.backs.remove_cards(this.backs.length),...this.fronts.remove_cards(this.fronts.length)]}add_backs(e){e.forEach(s=>s.flip_back()),this.backs.add_cards(e),this.fronts.ease_position(this.top_back_position)}add_fronts(e){var h;this.fronts.add_cards(e),e.forEach(r=>r.flip_front());let s=this,i=this.fronts.cards.length;this.fronts.cards.forEach((r,l)=>{r.bind_drop(void 0),r.bind_drag(p=>{s.data.on_front_drag(i-l,p)}),r.bind_click(()=>(s.data.on_front_click(i-l),!0))}),(h=this.fronts.top_card)==null||h.bind_drop(()=>{s.data.on_front_drop()}),this.open_drop_target()}remove_fronts(e){var r;let s=this.fronts.remove_cards(e);s.forEach(l=>{l.bind_drop(void 0)});let i=this,h=this.fronts.cards.length;return this.fronts.cards.forEach((l,p)=>{l.bind_drop(void 0),l.bind_drag(d=>{i.data.on_front_drag(h-p,d)}),l.bind_click(()=>(i.data.on_front_click(h-p),!0))}),(r=this.fronts.top_card)==null||r.bind_drop(()=>{i.data.on_front_drop()}),this.open_drop_target(),s}flip_front(e){var h;let[s]=this.backs.remove_cards(1);s.card=e,s.flip_front(),this.fronts.ease_position(this.top_back_position),(h=this.fronts.top_card)==null||h.bind_drop(void 0),this.fronts.add_cards([s]);let i=this;this.fronts.top_card.bind_drag(r=>{i.data.on_front_drag(1,r)}),this.fronts.top_card.bind_drop(()=>{i.data.on_front_drop()}),this.fronts.top_card.bind_click(()=>(i.data.on_front_click(1),!0))}get empty(){return this.fronts.length===0&&this.backs.length===0}open_drop_target(){this.drop_target.visible=this.empty}flip_back(){let[e]=this.fronts.remove_cards(1);e.flip_back(),this.backs.add_cards([e]),this.fronts.ease_position(this.top_back_position),e.bind_drop(void 0)}_init(){this.drop_target=this.make(ss,n.make(0,0),{}),this.drop_target.bind_drop(()=>{this.data.on_front_drop()}),this.drop_target.bind_click(()=>(this.data.on_front_click(1),!0)),this.backs=this.make(Te,n.make(0,0),{h:33}),this.fronts=this.make(Te,n.make(0,0),{}),this.open_drop_target()}_update(){let e=this.fronts.cards.findIndex(s=>s.hover_time>E.thirds);e!==-1?this.fronts.i_gap=e:this.fronts.i_gap=void 0}}const Ct=t=>typeof t=="object"&&t.foundation!==void 0,mh=t=>typeof t=="object"&&typeof t.tableu=="number";class yh extends w{constructor(){super(...arguments);o(this,"anim")}get data(){return this._data}disable(){this.anim.play("disabled")}enable(){this.anim.play("idle")}_init(){let e=this.make(R,n.make(0,0),{name:"recycle"});this.anim=e;let s=this;this.make(D,n.make(20,20),{rect:x.make(0,0,140,160),on_hover(){e._animation!=="disabled"&&e.play("hover")},on_hover_end(){e._animation!=="disabled"&&e.play("idle")},on_click(){s.data.on_recycle()}})}}const uh=(t,a)=>{for(let e=t.length-1;e>=0;e--)a(t[e])};class xh extends w{constructor(){super(...arguments);o(this,"stock");o(this,"waste");o(this,"waste_hidden")}get data(){return this._data}get can_recycle(){return this.stock.length===0}release_all(){return this.free()}free(){return[...this.stock.remove_cards(this.stock.length),...this.waste.remove_cards(this.waste.length),...this.waste_hidden.remove_cards(this.waste_hidden.length)]}add_waste_hidden(e){e.forEach(s=>s.flip_back()),this.waste_hidden.add_cards(e)}add_waste(e){e.forEach(s=>{s.bind_drop(void 0),s.bind_drag(void 0),s.bind_click(void 0)}),this.waste.add_cards(e),e.forEach((s,i)=>s.flip_front()),this.bind_new_front()}add_stocks(e){e.forEach(s=>s.flip_back()),this.stock.add_cards(e)}remove_waste(e){return this.waste.remove_cards(e)}bind_new_front(){var e,s;this.waste.cards.forEach(i=>{i.bind_drag(void 0),i.bind_click(void 0)}),(e=this.waste.top_card)==null||e.bind_drag(i=>{this.data.on_front_drag(i)}),(s=this.waste.top_card)==null||s.bind_click(()=>(this.data.on_waste_click(),!0))}undo_hit(e,s){let i=this.waste.remove_cards(e.length),h=this.waste_hidden.remove_cards(s.length);this.waste.add_cards(h),h.forEach((r,l)=>{r.card=s[l],r.flip_front()}),i.forEach(r=>{r.flip_back(),r.bind_click(void 0),r.bind_drag(void 0)}),this.stock.add_cards(i),this.bind_new_front()}hit(e){let s=this.stock.remove_cards(e.length);s.forEach((h,r)=>h.card=e[r]),s.forEach((h,r)=>h.flip_front());let i=this.waste.remove_cards(this.waste.cards.length);i.forEach(h=>{h.flip_back(),h.bind_drag(void 0),h.bind_click(void 0)}),this.waste_hidden.add_cards(i),this.waste.add_cards(s),uh(this.waste_hidden.cards,h=>h.send_back()),this.bind_new_front(),X.play("hit")}recycle(){let e=this.waste.remove_cards(this.waste.length);this.waste_hidden.add_cards(e);let s=this.waste_hidden.remove_cards(this.waste_hidden.length);s.forEach(i=>{i.bind_drag(void 0),i.bind_click(void 0)}),s.forEach(i=>i.flip_back()),s.forEach(i=>i.send_front()),this.stock.add_cards(s),X.play("recycle")}undo_recycle(e){let s=this.stock.remove_cards(this.stock.length);this.waste_hidden.add_cards(s);let i=this.waste_hidden.remove_cards(e);s.forEach(h=>h.flip_front()),i.forEach(h=>h.flip_front()),this.waste.add_cards(i)}_init(){this.stock=this.make(Te,n.make(0,0),{h:1}),this.waste=this.make(Te,n.make(0,260),{}),this.waste_hidden=this.make(Te,n.make(0,300),{h:0});let e=this;this.make(D,n.make(-64,-80),{rect:x.make(0,0,160,210),on_click(){e.stock.length>0&&e.data.on_hit()}})}}class wh extends w{constructor(){super(...arguments);o(this,"foundation");o(this,"drop_target")}get data(){return this._data}release_all(){return this.free()}free(){return this.remove_cards(this.foundation.length)}add_cards(e){var s,i;this.foundation.add_cards(e),(s=this.foundation.top_card)==null||s.bind_drag(h=>this.data.on_front_drag(h)),(i=this.foundation.top_card)==null||i.bind_click(()=>this.data.on_front_click())}remove_cards(e){return this.foundation.remove_cards(e)}_init(){this.drop_target=this.make(ss,n.make(0,0),{}),this.drop_target.bind_drop(()=>{this.data.on_front_drop()}),this.drop_target.bind_click(()=>(this.data.on_front_click(),!0)),this.foundation=this.make(Te,n.make(0,0),{h:0})}}class kh extends w{constructor(){super(...arguments);o(this,"recycle_view");o(this,"cards");o(this,"dealer");o(this,"stock");o(this,"tableus");o(this,"foundations");o(this,"dragging");o(this,"drag_source");o(this,"click_source");o(this,"back_res");o(this,"trigger_auto",-2)}get game_pov(){return this.back_res.game_pov}get pov(){return this.game_pov.game}get cmd(){return this.back_res.cmd}_init(){let e=this;this.make(D,n.zero,{rect:x.make(0,0,1920,1080),on_up(){e.dragging&&!e.dragging.waiting&&e._release_cancel_drag()},on_click(){e.click_source&&e._release_cancel_highlight()}}),this.recycle_view=this.make(yh,n.make(40,200),{on_recycle(){e.stock.can_recycle&&e.cmd(Ie)}}),this.cards=this.make(ph,n.zero,{});let s=120,i=320;this.stock=this.make(xh,n.make(s,i),{on_waste_click(){if(e.click_source==="waste"){e._release_cancel_highlight();let f=j.auto_can(e.pov);f&&(e.trigger_auto=-1,e.cmd(j,f));return}e._release_cancel_highlight(),e.stock.waste.top_card.set_highlight(!0),e.click_source="waste"},on_hit(){e.cmd(Ee)},on_front_drag(f){if(e._release_cancel_highlight(),e.dragging)e.dragging.drag(f);else{if(e.trigger_auto!==-2)return;if(e.pov.can_drag_waste){let m=e.stock.remove_waste(1);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=m,e.cards.shadow_group=m,e.drag_source="waste",X.play("drag1")}}}});let h=350,r=180,l=200;this.tableus=st.map(f=>this.make(gh,n.make(h+l*f,r),{on_front_click(m){if(!e.click_source)e._release_cancel_highlight(),e.tableus[f].fronts.set_highlight(m,!0),e.click_source={tableu:f,i:m};else if(e.click_source==="waste")e.cmd(pe,{to:f});else{let{tableu:u,i:k}=e.click_source;if(u===f){if(m===1){e._release_cancel_highlight();let z=H.auto_can(e.pov,{tableu:u});z&&(e.trigger_auto=-1,e.cmd(H,z));return}e._release_cancel_highlight(),e.tableus[f].fronts.set_highlight(m,!0),e.click_source={tableu:f,i:m};return}e.cmd(ce,{from:u,to:f,i:k})}},on_front_drag(m,u){if(e.dragging)e.dragging.drag(u);else{if(e._release_cancel_highlight(),e.trigger_auto!==-2)return;if(e.pov.can_drag_tableu({from:f,i:m})){let k=e.tableus[f].remove_fronts(m);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=k,e.cards.shadow_group=k,e.drag_source={tableu:f,i:m};let z=Math.min(3,Math.floor(m/3)+1);X.play(`drag${z}`)}}},on_front_drop(){if(e.drag_source==="waste")e.dragging.wait_drop(),e.cmd(pe,{to:f});else if(Ct(e.drag_source)){let{foundation:m}=e.drag_source;e.dragging.wait_drop(),e.cmd(ke,{from:m,to:f})}else if(e.drag_source){let{tableu:m,i:u}=e.drag_source;e.dragging.wait_drop(),e.cmd(ce,{from:m,to:f,i:u})}}}));let p=1790,d=166,g=240;this.foundations=Ea.map(f=>this.make(wh,n.make(p,d+g*f),{on_front_click(){if(e.click_source==="waste")e.cmd(j,{to:f});else if(e.click_source){let{tableu:m,i:u}=e.click_source;u===1&&e.cmd(H,{from:m,to:f,i:1})}},on_front_drag(m){if(e._release_cancel_highlight(),e.dragging)e.dragging.drag(m);else{if(e.trigger_auto!==-2)return;if(e.pov.can_drag_foundation({from:f})){let u=e.foundations[f].remove_cards(1);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=u,e.cards.shadow_group=u,e.drag_source={foundation:f},X.play("drag1")}}},on_front_drop(){if(e.drag_source==="waste")e.dragging.wait_drop(),e.cmd(j,{to:f});else if(!Ct(e.drag_source)){if(e.drag_source){let{tableu:m,i:u}=e.drag_source;u===1&&(e.dragging.wait_drop(),e.cmd(H,{from:m,to:f,i:1}))}}}})),this.dealer=this.make(zh,n.zero,{on_shuffle(){e.dealer.cards.forEach(f=>e.cards.release(f))}})}_release_cancel_highlight(){if(this.click_source)if(this.click_source==="waste")this.stock.waste.top_card.set_highlight(!1),this.click_source=void 0;else{let{tableu:e,i:s}=this.click_source;this.tableus[e].fronts.set_highlight(s,!1),this.click_source=void 0}else return}_release_cancel_drag(){if(!this.dragging){this._release_cancel_highlight();return}let e=this.dragging.lerp_release();if(this.drag_source==="waste")this.stock.add_waste(e);else if(Ct(this.drag_source)){let{foundation:s}=this.drag_source;this.foundations[s].add_cards(e)}else{let{tableu:s,i}=this.drag_source;this.tableus[s].add_fronts(e)}this.dragging.dispose(),this.dragging=void 0,this.drag_source=void 0,X.play("cancel"),e[0].after_ease(()=>{this.cards.shadow_group=void 0})}_collect_pov(){this._init_pov()}_init_pov(){let{pov:e,stock:s,tableus:i,foundations:h}=this;st.map(r=>{i[r].release_all().forEach(p=>this.cards.release(p))}),s.release_all().forEach(r=>this.cards.release(r)),Ea.map(r=>{h[r].release_all().forEach(p=>this.cards.release(p))}),this.drag_source=void 0,this.click_source=void 0,this._refresh_recycle(),s.add_waste_hidden(e.stock.hidden.cards.map(r=>this.cards.borrow())),s.add_stocks(e.stock.stock.cards.map(r=>this.cards.borrow())),s.add_waste(e.stock.waste.cards.map(r=>{let l=this.cards.borrow();return l.card=r,l})),st.map(r=>{let l=i[r],p=e.tableus[r];l.add_backs(p.back.cards.map(d=>this.cards.borrow())),l.add_fronts(p.front.cards.map(d=>{let g=this.cards.borrow();return g.card=d,g}))})}_refresh_recycle(){this.pov.can_hit?this.recycle_view.visible=!1:this.recycle_view.visible=!0,this.pov.can_recycle?this.recycle_view.enable():this.recycle_view.disable()}new_game(){this._collect_pov()}undo(e){if(X.play("undo2"),e instanceof Ee)this.stock.undo_hit(e.data.cards,e.data.waste),this._refresh_recycle();else if(e instanceof Ie)this.stock.undo_recycle(e.data.waste.length),this._refresh_recycle();else if(e instanceof ce){let{flip:s}=e.res,{from:i,to:h,i:r}=e.data;s&&this.tableus[i].flip_back();let l=this.tableus[h].remove_fronts(r);this.tableus[i].add_fronts(l)}else if(e instanceof pe){let{to:s}=e.data,i=this.tableus[s].remove_fronts(1);this.stock.add_waste(i)}else if(e instanceof H){let{flip:s}=e.res,{from:i,to:h}=e.data;s&&this.tableus[i].flip_back();let r=this.foundations[h].remove_cards(1);this.tableus[i].add_fronts(r)}else if(e instanceof j){let{to:s}=e.data,i=this.foundations[s].remove_cards(1);this.stock.add_waste(i)}else if(e instanceof ke){let{from:s,to:i}=e.data,h=this.tableus[i].remove_fronts(1);this.foundations[s].add_cards(h)}}apply(e){let s;if(e instanceof Ee)this._release_cancel_highlight(),this.stock.hit(e.data.cards),this._refresh_recycle();else if(e instanceof Ie)this.stock.recycle(),this._refresh_recycle();else if(e instanceof ce){let{flip:i}=e.res,{from:h,to:r,i:l}=e.data,p;if(this.dragging){let d=this.dragging.lerp_release();this.tableus[r].add_fronts(d),s=d}else if(this.click_source&&mh(this.click_source)){let{tableu:d,i:g}=this.click_source;this._release_cancel_highlight();let f=this.tableus[d].remove_fronts(g);this.tableus[r].add_fronts(f),p=f}i&&(this.tableus[h].flip_front(i),p&&p.forEach(d=>d.send_front()))}else if(e instanceof pe){let{to:i}=e.data;if(this.dragging){let h=this.dragging.lerp_release();this.tableus[i].add_fronts(h),this.stock.bind_new_front(),s=h}else{this._release_cancel_highlight();let h=this.stock.remove_waste(1);this.tableus[i].add_fronts(h),this.stock.bind_new_front()}}else if(e instanceof H){let{flip:i}=e.res,{from:h,to:r}=e.data;if(this.dragging){let l=this.dragging.lerp_release();this.foundations[r].add_cards(l),s=l}else{this._release_cancel_highlight();let l=this.tableus[h].remove_fronts(1);this.foundations[r].add_cards(l)}i&&this.tableus[h].flip_front(i)}else if(e instanceof j){let{to:i}=e.data;if(this.dragging){let h=this.dragging.lerp_release();this.foundations[i].add_cards(h),s=h}else{this._release_cancel_highlight();let h=this.stock.remove_waste(1);this.foundations[i].add_cards(h)}this.stock.bind_new_front()}else if(e instanceof ke){let{from:i,to:h}=e.data,r=this.dragging.lerp_release();this.tableus[h].add_fronts(r),this.stock.bind_new_front(),s=r}s&&(this.dragging.dispose(),this.dragging=void 0,this.drag_source=void 0,s[0].after_ease(()=>{this.cards.shadow_group=void 0})),(e instanceof H||e instanceof j)&&(this.trigger_auto===-1&&X.play("auto_flip"),this.trigger_auto===-3&&(X.play("auto_flip"),this.trigger_auto=-1))}apply_pov(e,s){}cant(e,s){e===ke?this._release_cancel_drag():e===pe?this._release_cancel_drag():e===j?this._release_cancel_drag():e===ce?this._release_cancel_drag():e===H?this._release_cancel_drag():e===j?this._release_cancel_drag():console.log("cant",e)}cant_undo(){}request_undo(){this.back_res.undo()}request_new_game(){this.back_res.new_game()}_update(){if(this.trigger_auto===-1)this.trigger_auto=E.thirds;else if(this.trigger_auto>0)this.trigger_auto=$t(this.trigger_auto,0,b.delta);else if(this.trigger_auto===0){this.trigger_auto=-2;let e=j.auto_can(this.pov);if(e)this.cmd(j,e),this.trigger_auto=-3;else for(let s=0;s<7;s++){let i=H.auto_can(this.pov,{tableu:s});if(i){this.cmd(H,i),this.trigger_auto=-3;break}}}}}const vh=async(t,a,e,s)=>{let i=Je,h=await i.get_pov();return{get game_pov(){return h},cmd(r,l){r.can(h.game,l)?(h.apply(r,l),t.apply_pov(r,l),i.apply(r,l).then(p=>{p?(t.apply(p),h.finalize_apply_pov(p),i.get_pov().then(d=>a(d.score)),i.get_pov().then(d=>{d.game.is_finished&&s(d.game.settings,d.score)})):t.cant(r,l)})):t.cant(r,l)},undo(){h.can_undo?(h.undo_pov(),i.undo().then(r=>{r?(h.undo(r),t.undo(r),i.get_pov().then(l=>a(l.score))):t.cant_undo()})):t.cant_undo()},async new_game(){i.get_pov().then(r=>{let l=r.score;l>0&&(r.game.is_finished||mt.add_result(He.from_loss(r.game.settings,l)))}),Je=new nt,i=Je,h=await Je.get_pov(),t.new_game(),i.get_pov().then(r=>a(r.score)),i.get_pov().then(r=>e(r.game.settings))}}},ct=class ct{constructor(){o(this,"game");let a=ta.make(De.general_settings,bh(Ga.deck));this.game=Ya.make(a)}async get_pov(){return this.game.pov.clone}async apply(a,e){return await this.game.apply(a,e)}async undo(){return await this.game.undo()}};o(ct,"resume",()=>new ct);let nt=ct,Je=new nt;function bh(t){for(var a=t.length-1;a>0;a--){var e=Math.floor(Math.random()*(a+1)),s=t[a];t[a]=t[e],t[e]=s}return t}let Eh=[...Array(50).keys()].map(()=>N().mul(L.scale(.8)));class Th extends w{constructor(){super(...arguments);o(this,"_timer");o(this,"_cards",[]);o(this,"end_on_final_ease")}get data(){return this._data}set cards(e){this._cards=e,e.length>0&&(this._timer=E.seconds*.5)}_update(){if(this.end_on_final_ease&&this._cards.every(e=>!e.easing)&&(this.end_on_final_ease=void 0,this.data.on_end()),b.on_interval(E.three)&&this._timer)if(this._timer-=b.delta,this._timer<0)this._timer=void 0,this.end_on_final_ease=!0,this._cards.forEach((e,s)=>{e.ease_position(n.make(L.x/2,L.y*.8),E.half+E.half*(s/this._cards.length))});else{let e=Qi(Eh),s=va(),i=n.max(n.min(e.add(s.scale(100)),L),n.zero);for(let h=0;h<3;h++)this._cards.filter(r=>!r.easing).sort((r,l)=>r.position.distance(e)-l.position.distance(e)).slice(0,2+qa(2)).forEach((r,l)=>{r.ease_position(i.add(va().scale(l*5)),E.half+ue()*3*E.sixth)})}this._cards.forEach(e=>e.update())}_draw(e){this._cards.forEach(s=>s.draw(e))}}function Ta(t,a=ue){let e,s,i;for(s=t.length;s;)e=a()*s--|0,i=t[s],t[s]=t[e],t[e]=i;return t}function*Ah(t){let a=t.length,e=1;for(;e0;){e=Math.floor(e/3);for(let s=1;s<=e;s++)yield*Mh(t,s,e)}}function*Mh(t,a,e){let s=t.length;for(let i=a+e;i=e&&t[h]{let e=t/(a-1)*Math.PI;e=Li(e/Math.PI,-Math.PI*.2,Math.PI*.2)-Math.PI*.5;let s=L.scale(1/2).sub(n.up.scale(1200)),i=s.add(n.from_angle(e,1400)),h=i.sub(s).normal.angle+Math.PI/2;return[i,h]};class Sh extends w{constructor(){super(...arguments);o(this,"_cards",[]);o(this,"layer");o(this,"_sort_shot");o(this,"flip_i");o(this,"final");o(this,"end_on_final_ease")}get data(){return this._data}set cards(e){this._cards=e,e.length>0&&this._begin_lay()}_begin_lay(){Ta(this._cards),this.layer=[0,Ta(this._cards.map((e,s)=>s))]}_begin_sort(){let e=this._cards.map(l=>l.card?ah(l.card):-1);this._sort_shot=[];let s=Ah(e),i=Math.floor(e.length/3),h=0,r=this._cards.slice(0);for(let l of s){let[p,d]=l,g=r[p];r[p]=r[d],r[d]=g,h++>3&&h%i===0&&this._sort_shot.unshift(r.slice(0))}this._sort_shot.unshift(r)}_begin_flip(){this.flip_i=0}_update(){if(this.layer){let[e,s]=this.layer;for(let i=0;i<1;i++){if(e>=s.length){this._cards.every(h=>!h.easing)&&(this.layer=void 0,this._begin_sort());break}if(b.on_interval(E.three)){let[h,r]=Ut(e,this._cards.length);this._cards[e].ease_position(h),this._cards[e].ease_rotation(r),e++}}this.layer&&(this.layer[0]=e)}if(this._sort_shot){if(this._sort_shot.length===0)this._sort_shot=void 0,this._begin_flip();else if(b.on_interval(E.sixth)){let e=this._sort_shot.pop();this._cards.forEach((s,i)=>{let h=e.findIndex(r=>r===s);if(i!==h){let[r,l]=Ut(h,this._cards.length);this._cards[i].ease_position(r),this._cards[i].ease_rotation(l)}}),this._cards=e}}this.flip_i!==void 0&&b.on_interval(E.three)&&(this._cards[this.flip_i].flip_back(),this.flip_i++,this.flip_i>=this._cards.length&&(this.flip_i=void 0,this.final=!0)),this.final&&(this.final=void 0,this.end_on_final_ease=!0,this._cards.forEach(e=>{let[s,i]=Ut(2,5);e.ease_position(s),e.ease_rotation(i)})),this.end_on_final_ease&&this._cards.every(e=>!e.easing)&&(this.end_on_final_ease=void 0,this.data.on_layout()),this._cards.forEach(e=>e.update())}_draw(e){this._cards.forEach(s=>s.draw(e))}}class zh extends w{constructor(){super(...arguments);o(this,"_cards");o(this,"shuffler");o(this,"laydeck")}get data(){return this._data}get cards(){return this._cards}set cards(e){this._cards=e}_init(){let e=this;this.laydeck=this.make(Sh,n.make(0,0),{on_layout(){e.laydeck.cards=[],e.begin_shuffle()}}),this.shuffler=this.make(Th,n.make(0,0),{on_end(){e.shuffler.cards=[],e.data.on_shuffle()}})}begin_laydeck(){this.laydeck.cards=this._cards}begin_shuffle(){this.shuffler.cards=this._cards}}class Fh extends w{constructor(){super(...arguments);o(this,"_score");o(this,"score_text");o(this,"score_text_shadow")}set score(e){this._score=e,this.score_text.text=`${e}`,this.score_text_shadow.text=`${e}`}get score(){return this._score}_init(){this._score=0,this.make(T,n.make(0,25),{key:"score",width:80,height:100}),this.score_text_shadow=this.make(T,n.make(100,6),{no_trans:!0,key:`${this.score}`,width:180,height:100,color:y.black}),this.score_text=this.make(T,n.make(100,0),{no_trans:!0,key:`${this.score}`,width:180,height:100})}}class Rh extends w{get data(){return this._data}_init(){[N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L)].forEach(e=>{let s=this.make(R,e,{name:"swiggle"});s.origin=n.make(600,400),s.scale=n.one.scale(.5+N().x),N().y<.5&&s.play("small"),s.rotation=N().y*Math.PI});let a=this;this.make(D,n.zero,{rect:x.make(0,0,1920,1080),on_hover(){return!0},on_drag(){return!0},on_click(){return a.data.on_close(),!0}})}}class Ch extends w{constructor(){super(...arguments);o(this,"cards");o(this,"limit")}set settings(e){this.cards.text=e.cards,this.limit.text=e.limit}_init(){this.make(T,n.make(0,0),{no_trans:!0,key:"Solitaire",width:350,height:64,color:y.white}),this.cards=this.make(T,n.make(350,5),{key:"one_pass",width:350,height:40,color:y.white}),this.limit=this.make(T,n.make(550,5),{key:"no_limit",width:350,height:40,color:y.white})}}class Uh extends w{constructor(){super(...arguments);o(this,"ax",0);o(this,"ay",0);o(this,"vx",0);o(this,"vy",0)}get data(){return this._data}_init(){let e=Math.random()<.3?"2":"",s=this.make(R,n.make(0,0),{name:"confetti"+e});s.play_o("idle",{loop:!0});let i=.5+Math.random()*.8;s.scale=n.make(i,i),s.rotation=Math.PI*Math.random(),this.vx=100+Math.random()*100,this.vy=-100+Math.random()*100,this.vx*=this.data.sign,this.ax=this.vx*10,this.ay=this.vy*10}_update(){this.position.x+=this.vx*b.delta,this.position.y+=this.vy*b.delta,this.position.x+=this.ax*b.delta,this.position.y+=this.ay*b.delta,this.ax=$t(this.ax,0,b.delta*1e3),this.ay=$t(this.ay,0,b.delta*1e3),this.position.x>2e3&&this.dispose()}}class Aa extends w{constructor(){super(...arguments);o(this,"life",0)}get data(){return this._data}_init(){if(this.pop_confetti(),this.data.sign<0){let e=this.make(R,n.make(0,700),{name:"confbar"});this.tween([Math.PI,0,Math.PI*.3,Math.PI*.16,0],s=>e.rotation=s,[E.half,E.lengths,E.thirds,E.thirds])}else{let e=this.make(R,n.make(1920,700),{name:"confbar"});e.scale=n.make(-1,1),this.tween([-Math.PI,0,-Math.PI*.3,-Math.PI*.16,0],s=>e.rotation=s,[E.half,E.lengths,E.thirds,E.thirds])}}_update(){this.life<6&&b.on_interval(E.seconds*2)&&(this.pop_confetti(),this.life++)}pop_confetti(){for(let e=0;e<6;e++)this.make(Uh,n.make(this.data.sign>0?-500+e*100:1920-e*100,1080-e*300*Math.random()),{sign:this.data.sign})}}class Ma extends w{pop(){X.play("Win"),this.make(Aa,n.make(0,0),{sign:1}),this.make(Aa,n.make(0,0),{sign:-1})}}class Oh extends w{get data(){return this._data}_init(){let a=1200,e=300;this.make(Ke,n.make(1920/2-a/2,520),{name:"panel_bg_nine_slice",w:a,h:e}),this.make(T,n.make(1920/2,590),{key:"congratz",width:450,height:100,color:y.white,center:!0}),this.make(T,n.make(1920/2,700),{key:`you_finished_with_score%${this.data.score}%`,width:650,height:60,color:y.white,center:!0})}}class it extends w{constructor(){super(...arguments);o(this,"hamburger");o(this,"sidebar");o(this,"overlay");o(this,"over_confetties",[])}set sidebar_open(e){this.sidebar.open=e,this.overlay.visible=e,this.hamburger.open=e}_init(){let e;this.make(Vh,n.zero,void 0),this.over_confetties.push(this.make(Ma,n.make(0,0),{}));let s=this.make(kh,n.make(0,0),{});this.over_confetties.push(this.make(Ma,n.make(0,0),{})),this.make(Ji,n.make(160,1e3),{text:"undo",on_click(){s.request_undo()}});let i=this.make(Ch,n.make(640,16),{}),h=this.make(Fh,n.make(16,860),{});const r=u=>{h.score=u};let l;vh(s,r,u=>{i.settings=u,l&&(l.dispose(),l=void 0)},(u,k)=>{this.game_over_confetti_pop(),l=this.make(Oh,n.make(0,0),{score:k}),mt.add_result(He.from_win(u,k))}).then(u=>{s.back_res=u,s._collect_pov(),X.music("main"),i.settings=u.game_pov.game.settings});let g=this,f=this.make(Rh,n.zero,{on_close(){g.sidebar_open=!1,g.hamburger.open=!1}}),m=this.make(Nh,n.make(2,2),{on_open:u=>{g.sidebar_open=u}});e=this.make(Dh,n.make(-600,180),{on_new_game(){s.request_new_game(),g.sidebar_open=!1}}),this.sidebar=e,this.overlay=f,this.hamburger=m,this.sidebar_open=!1}game_over_confetti_pop(){this.over_confetties.forEach(e=>e.pop())}}class Dh extends w{constructor(){super(...arguments);o(this,"_t_x");o(this,"_open")}get data(){return this._data}set open(e){this._open=e,this._t_x&&this.cancel(this._t_x),e?this._t_x=this.tween([this.position.x,0],s=>{this.position.x=s},E.sixth,0,()=>{this._t_x=void 0}):this._t_x=this.tween([this.position.x,-600],s=>{this.position.x=s},E.sixth,0,()=>{this._t_x=void 0})}_init(){this._open=!1;let e=this,s=this.make(R,n.make(0,-100),{name:"side_menu_bg"});s.scale=n.make(1.4,1.4);let i=20,h=60,r=160;this.make(Ce,n.make(i,h),{text:"main_menu",on_click(){q.next(Fe)}}),this.make(Ce,n.make(i,h+r),{text:"new_game",on_click(){e.data.on_new_game()}}),this.make(Ce,n.make(i,h+r*2),{text:"settings",on_click(){q.next(ls,n.zero,{selected_index:1,on_back:it})}}),this.make(Ce,n.make(i,h+r*3),{text:"how_to_play",on_click(){q.next(ns,n.zero,{selected_index:0,on_back:it})}}),this.make(Ce,n.make(i,h+r*4),{text:"about",on_click(){q.next(rs,n.zero,{on_back:it})}})}}class Ce extends w{constructor(){super(...arguments);o(this,"_t_color");o(this,"_i_color");o(this,"bg");o(this,"fg")}get data(){return this._data}get i_color(){return this._i_color}set i_color(e){this._i_color=e,this.bg.color=y.lerp(y.white,y.hex(2106417),this._i_color),this.fg.color=y.lerp(y.white,y.hex(2106417),1-this._i_color)}set hover(e){this._t_color&&this.cancel(this._t_color),e?this._t_color=this.tween([this.i_color,0],s=>{this.i_color=s},E.sixth,0,()=>{this._t_color=void 0}):this._t_color=this.tween([this.i_color,1],s=>{this.i_color=s},E.sixth,0,()=>{this._t_color=void 0})}_init(){this._i_color=0,this.bg=this.make(B,n.make(-20,-40),{w:412,h:120,color:y.hex(2106417)}),this.fg=this.make(T,n.make(0,0),{key:this.data.text,width:350,height:100,color:y.white});let e=360,s=120,i=this;this.make(D,n.make(-20,-40),{rect:x.make(0,0,e,s),on_hover(){i.hover=!0},on_hover_end(){i.hover=!1},on_click(){return i.data.on_click(),!0}})}}class Nh extends w{constructor(){super(...arguments);o(this,"_open");o(this,"anim")}get data(){return this._data}set open(e){this._open=e,this._open?this.anim.play("open"):this.anim.play("idle")}_init(){this._open=!1;let e=this.make(R,n.make(0,0),{name:"hmg_bg"});this.anim=e;let s=200,i=100,h=this;this.make(D,n.make(20,20),{rect:x.make(0,0,s,i),on_hover(){e.play(h._open?"open_hover":"hover")},on_hover_end(){e.play(h._open?"open":"idle")},on_click(){return h.open=!h._open,h.data.on_open(h._open),!0}})}}const Ph=`en=english +}`;let St;const ga=new Vt([ne.make(0,O.Float2,!1),ne.make(1,O.Float2,!1)]),ui="u_texture",xi="u_matrix";let Y=x.make(0,0,1,1);const wi=Y.x,ki=Y.y,vi=Y.x+Y.w,bi=Y.y,Ei=Y.x+Y.w,Ti=Y.x+Y.h,Ai=Y.x,Mi=Y.x+Y.h,[Si,zi,Fi,Ri,Ci,Ui,Oi,Di]=[0,0,1,0,1,1,0,1];class Ni{constructor(){o(this,"texture");o(this,"mesh");o(this,"material");o(this,"indices",[0,1,2,0,2,3]);o(this,"vertices",[]);o(this,"matrix");o(this,"sampler",ye.get_default)}set_matrix(a){this.matrix=a,this.vertices=[],this.PUSH_VERTEX(wi,ki,Si,zi),this.PUSH_VERTEX(vi,bi,Fi,Ri),this.PUSH_VERTEX(Ei,Ti,Ci,Ui),this.PUSH_VERTEX(Ai,Mi,Oi,Di)}PUSH_VERTEX(a,e,s,i){let h=this.matrix;this.vertices.push(new Pi(n.make(a*h.m11+e*h.m21+h.m31,a*h.m12+e*h.m22+h.m32),n.make(s,1-i)))}render(a=c.backbuffer){this.render_with_m(a,ie.create_ortho_offcenter(0,a.width,a.height,0,.01,1e3))}render_with_m(a,e){St||(St=qe.create([mi,yi])),this.mesh||(this.mesh=Ve.create()),this.material||(this.material=gt.create(St));let s=ga.stride,i=new ArrayBuffer(s*this.vertices.length),h=new DataView(i);this.vertices.reduce((l,p)=>p.push_to(h,l),0),this.mesh.index_data(this.indices),this.mesh.vertex_data(ga,i);let r=new Kt;r.target=a,r.mesh=this.mesh,r.has_viewport=!1,r.viewport=x.make(0,0,0,0),r.instance_count=0,r.material=this.material,r.material.set_texture(ui,this.texture),r.material.set_sampler_at_location(0,this.sampler),r.material.set_matrix(xi,e),r.index_start=0,r.index_count=this.indices.length,r.perform()}}class Pi{constructor(a,e){this.pos=a,this.tex=e}push_to(a,e){let{pos:s,tex:i}=this;return a.setFloat32(e+0,s.x,!0),a.setFloat32(e+4,s.y,!0),a.setFloat32(e+8,i.x,!0),a.setFloat32(e+12,i.y,!0),e+16}}const zt=new Ni;function Li(t,a,e){return a+(e-a)*t}function he(t,a,e){return t+(a-t)*e}function $t(t,a,e){return t=e.length-1&&(this.loop===1?(this._i=0,this._values.reverse(),this._durations.reverse()):this._completed=!0))}init(){return this._i=0,this._t=0,this._completed=!1,this._value=this._values[0],this}};o(lt,"make",(a,e,s=!1)=>new lt(a.slice(0),[e],s?1:0).init());let Bt=lt;y.hex(2106417);const Bi=y.hex(4895437),_t=class _t{constructor(){o(this,"_render_order",0);o(this,"visible",!0);o(this,"g_position");o(this,"position");o(this,"rotation");o(this,"origin",n.zero);o(this,"scale",n.one);o(this,"coroutines",[]);o(this,"_data");o(this,"_disposes");o(this,"objects");o(this,"parent");o(this,"g_scissor");o(this,"_tweens",[]);o(this,"_tween")}routine(a){this.coroutines.push(a)}*wait_for(a){let e=0;for(;ee[0]!==a)}tween_single(a,e,s,i,h=0,r){return a&&this.cancel(a),this.tween(e,s,i,h,r)}make(a,e,s){let i=this._make(a,e,s);return this._add_object(i),i}init(){return this._disposes=[],this.objects=[],this._init(),this}update(){this.coroutines=this.coroutines.filter(a=>!a.next().done),this.objects.forEach(a=>a.update()),this._tweens=this._tweens.filter(([a,e,s])=>(a.update(b.delta),e(a.value),a.completed&&s&&s(),!a.completed)),this._update()}draw(a){this.visible&&(this._render_order=_t.next_render_order++,this._draw(a))}_draw_children(a){this.objects.forEach(e=>e.draw(a))}dispose(){this.objects.slice(0).forEach(a=>a.dispose()),this._dispose(),this._disposes.forEach(a=>a()),this.parent&&this.parent.objects.splice(this.parent.objects.indexOf(this),1)}_init(){}_update(){}_draw(a){a.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,a.m_matrix),this._draw_children(a),a.pop_matrix()}_dispose(){}};o(_t,"next_render_order",0);let w=_t;class Ke extends w{get data(){return this._data}get nine(){return Se.find_nine(this.data.name)}_draw(a){let{frames:e}=this.nine,s=400/3,i=(this.data.h-s*2)/s,h=(this.data.w-s*2)/s;a.push_matrix(v.create_transform(this.position,n.zero,n.one,0)),this.g_position=n.transform(n.zero,a.m_matrix),a.stex(e[0].image,n.make(0,0),y.white),a.stex_o(e[1].image,n.make(0,s),n.zero,n.make(1,i),0,y.white),a.stex(e[2].image,n.make(0,s+i*s),y.white),a.stex_o(e[3].image,n.make(s,0),n.zero,n.make(h,1),0,y.white),a.stex_o(e[4].image,n.make(s,s),n.zero,n.make(h,i),0,y.white),a.stex_o(e[5].image,n.make(s,s+i*s),n.zero,n.make(h,1),0,y.white),a.stex(e[6].image,n.make(s+h*s,0),y.white),a.stex_o(e[7].image,n.make(s+h*s,s),n.zero,n.make(1,i),0,y.white),a.stex(e[8].image,n.make(s+h*s,s+i*s),y.white),a.pop_matrix()}}class R extends w{constructor(){super(...arguments);o(this,"alpha",255);o(this,"_animation","idle");o(this,"_frame_counter",0);o(this,"_frame",0);o(this,"_loop",!1);o(this,"_reverse",!1);o(this,"_on_complete");o(this,"will_play")}get data(){return this._data}get sprite(){return Se.find_sprite(this.data.name)}get alpha_color(){return new y(this.alpha,this.alpha,this.alpha,this.alpha)}get animation(){return this.sprite.get(this._animation)}get frame(){var e;return(e=this.animation)==null?void 0:e.frames[this._frame]}get subtexture(){var e;return(e=this.frame)==null?void 0:e.image}get duration(){var e;return(e=this.frame)==null?void 0:e.duration}play_now(e,s,i=!1){var h;if(this._on_complete=s,this._animation=e,this._frame=0,i){let r=((h=this.animation)==null?void 0:h.frames.length)||0;this._frame=r-1}this._reverse=i}play(e,s,i=!1){this.will_play=()=>this.play_now(e,s,i)}play_o(e,s){this._loop=s.loop??!1,this.play_now(e)}_update(){var i,h;const e=(i=this.animation)==null?void 0:i.frames.length,s=(h=this.frame)==null?void 0:h.duration;e&&s&&(this._frame_counter+=b.delta,this._frame_counter>=s&&(this._frame_counter-=s,this._reverse?(this._frame--,this._frame<0&&(this._loop?this._frame=e-1:this._frame=0,this._on_complete&&this._on_complete(),this.will_play&&(this.will_play(),this.will_play=void 0))):(this._frame++,this._frame>=e&&(this._loop?this._frame=0:this._frame=e-1,this._on_complete&&this._on_complete(),this.will_play&&(this.will_play(),this.will_play=void 0)))))}_draw(e){this.subtexture&&(e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),e.stex(this.subtexture,n.zero,this.alpha_color),e.pop_matrix())}}const ji=t=>t!==void 0,Hi=t=>{const a={get:e=>t.getItem(e),set:(e,s)=>t.setItem(e,s),remove:e=>t.removeItem(e),make:e=>({get:()=>a.get(e),set:s=>a.set(e,s),remove:()=>a.remove(e)}),makeBoolean:e=>({get:()=>a.get(e)=="1",set:s=>a.set(e,s?"1":"0"),toggle:()=>a.set(e,a.get(e)=="1"?"0":"1")})};return a},ma=Hi(window.localStorage),be=(t,a)=>e=>{if(ji(e))return ma.set(t,JSON.stringify(e)),e;const s=JSON.parse(ma.get(t));return s!==null?s:a()},ya={threecards:1,onecard:1.5,nolimit:1,threepass:1.5,onepass:2.2},le=class le{constructor(a,e,s,i){this.win=a,this.score=e,this.turning_cards=s,this.turning_limit=i}get turning_cards_multiplier(){return ya[this.turning_cards]}get turning_limit_multiplier(){return ya[this.turning_limit]}get multiplied_score(){return this.score*(this.turning_cards_multiplier+this.turning_limit_multiplier)}get fen(){return[this.win,this.score,this.turning_cards,this.turning_limit].join("/")}};o(le,"from_fen",a=>{let[e,s,i,h]=a.split("/");return new le(e==="true",parseInt(s),i,h)}),o(le,"from_win",(a,e)=>new le(!0,e,a.cards,a.limit)),o(le,"from_loss",(a,e)=>new le(!1,e,a.cards,a.limit));let He=le;const dt=class dt{constructor(a){this.list=a}get fen(){return this.list.map(a=>a.fen).join("$")}push(a){this.list.push(a)}clear(){this.list.length=0}get total_wins(){return this.list.filter(a=>a.win).length}get total_played(){return this.list.length}get top_5_highscores(){return this.list.sort((a,e)=>e.multiplied_score-a.multiplied_score).slice(0,5)}};o(dt,"from_fen",(a,e)=>new dt(a===""?[]:a.split("$").map(s=>e(s))));let ze=dt;class Xi{constructor(a,e,s){this.solitaire=a,this.freecell=e,this.spider=s}get total_wins(){return this.freecell_total_wins+this.spider_total_wins+this.solitaire_total_wins}get total_played(){return this.freecell_total_played+this.spider_total_played+this.solitaire_total_played}get top_5_highscores(){return[...this.freecell_top_5_highscores,...this.spider_top_5_highscores,...this.solitaire_top_5_highscores].sort((a,e)=>e.multiplied_score-a.multiplied_score).slice(0,5)}get freecell_total_wins(){return this.freecell.total_wins}get freecell_total_played(){return this.freecell.total_played}get freecell_top_5_highscores(){return this.freecell.top_5_highscores}get spider_total_wins(){return this.spider.total_wins}get spider_total_played(){return this.spider.total_played}get spider_top_5_highscores(){return this.spider.top_5_highscores}get solitaire_total_wins(){return this.solitaire.total_wins}get solitaire_total_played(){return this.solitaire.total_played}get solitaire_top_5_highscores(){return this.solitaire.top_5_highscores}}let ua=["nolimit","threepass","onepass"],xa=["threecards","onecard"];class Vi{constructor(){o(this,"_cards");o(this,"_limit");let a="threecards";this._cards=be("cards",()=>a);let e="nolimit";this._limit=be("limit",()=>e)}get cards(){return this._cards()}set cards(a){this._cards(a)}get limit(){return this._limit()}set limit(a){this._limit(a)}get general_settings(){let{limit:a,cards:e}=this;return{limit:a,cards:e}}}class qi{constructor(){o(this,"_music");o(this,"_sound");o(this,"_language");let a="en";this._language=be("language",()=>a),this._sound=be("sound",()=>!0),this._music=be("music",()=>!0)}get music(){return this._music()}set music(a){this._music(a)}get sound(){return this._sound()}set sound(a){this._sound(a)}get language(){return this._language()}set language(a){this._language(a)}}let De=new Vi,ee=new qi;class Ki{constructor(){o(this,"_results");this._results=be("solitaire_results",()=>new ze([]).fen)}set results(a){this._results(a.fen)}get results(){return ze.from_fen(this._results(),He.from_fen)}add_result(a){let e=this.results;e.push(a),this.results=e}clear_results(){let a=this.results;a.clear(),this.results=a}}let mt=new Ki;function wa(t){return new Audio(t)}let Gi=["Win","new_game","auto_flip","drag1","drag2","drag3","cancel","drop","hit","recycle","undo2"];class Wi{constructor(){o(this,"audios");o(this,"musics");o(this,"load",async()=>{this.audios={},Gi.forEach(a=>this.audios[a]=[...Array(4).keys()].map(()=>wa(`./audio/${a}.wav`))),this.musics={},this.musics.main=wa("./music/SoundBox-music.wav")})}play(a){if(!ee.sound)return;let e=this.audios[a],s=e.pop();e.unshift(s),s.play()}stop_music(){this.musics.main.pause()}music(a){if(!ee.music)return;let e=this.musics[a];e.loop=!0,e.play()}}const $=new Wi,oe=1/60,E={seconds:60*oe,half:30*oe,thirds:20*oe,lengths:15*oe,sixth:10*oe,five:5*oe,three:3*oe,one:1*oe},L=n.make(1920,1080),Yi=(t=1)=>()=>{var a=Math.sin(t++)*1e4;return a-Math.floor(a)},ue=Yi();function qa(t,a=ue){return Math.floor(a()*t)}function ka(t=ue){return t()*2-1}function Qi(t,a=ue){return t[qa(t.length,a)]}const N=(t=ue)=>n.make(t(),t()),va=(t=ue)=>n.make(ka(t),ka(t));class Ji extends w{get data(){return this._data}_init(){let a=this.make(R,n.make(0,0),{name:"button_bg"});a.origin=n.make(366,200).scale(1/2),this.make(T,n.make(0,-30),{width:360,height:100,key:this.data.text,center:!0});let e=this;this.make(D,n.make(-366+80,-200+80).scale(1/2),{rect:x.make(0,0,366-80,200-80),on_hover(){a.play_o("hover",{loop:!1})},on_hover_end(){a.play("hover",()=>{a.play("idle")},!0)},on_click_begin(){a.play_o("click",{loop:!1})},on_click(){e.data.on_click()}})}}var Zi=Object.defineProperty,eh=(t,a,e)=>a in t?Zi(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,M=(t,a,e)=>(eh(t,typeof a!="symbol"?a+"":a,e),e),Yt=["d","c","h","s"],Ka=["A","K","Q","J","T","9","8","7","6","5","4","3","2"],jt=["A","2","3","4","5","6","7","8","9","T","J","Q","K"],th=Yt.flatMap(t=>Ka.map(a=>`${t}${a}`)),ah=t=>{let a=Yt.indexOf(t[0]),e=Ka.indexOf(t[1]);return a*100+e};function ba(t){switch(t[0]){case"d":case"h":return"red";default:return"black"}}function sh(t,a){return jt[jt.indexOf(a[1])-1]===t[1]}function ih(t,a){return ba(t)!=ba(a)}function hh(t){return t[1]==="K"}function rh(t){return t[1]==="A"}var Ga=class{static get deck(){return th.slice(0)}};function nh(t){let a=[];for(let e=0;e=0;a--)this.cards.unshift(t[a])}remove_cards(t){return this.cards.splice(-t)}remove_all(){return this.remove_cards(this.cards.length)}},K=Xe;M(K,"take_n",(t,a)=>new Xe(t.splice(0,a)));M(K,"from_fen",t=>new Xe(nh(t)));var Qt="??",yt=class{constructor(t){this.cards=t}get fen(){return this.cards.join(" ")}get clone(){return new yt(this.cards.slice(0))}get length(){return this.cards.length}get top_card(){return this.cards[this.cards.length-1]}unshift_cards(t){for(let a=t.length-1;a>=0;a--)this.cards.push(t[a])}shift_cards(t){return this.cards.splice(0,t)}add_cards(t){this.cards.push(...t)}remove_cards(t){return this.cards.splice(-t)}remove_all(){return this.remove_cards(this.cards.length)}},rt=yt;M(rt,"from_fen",t=>new yt(t===""?[]:t.split(" ")));M(rt,"backs",t=>new yt([...Array(t).keys()].map(a=>Qt)));var xe=class{constructor(t){o(this,"_data");this.game=t}_set_data(t){return this._data=t,this}},Wa=class{constructor(t,a,e){this.game=t,this.stats=a,this.history=e}get nb_moves(){return this.stats.nb_moves}set nb_moves(t){this.stats.nb_moves=t}get score(){return this.stats.score}set score(t){this.stats.score=t}get pov(){return new Qa(this.game.pov,this.stats,this.history.length)}apply(t,a){let e=new t(this.game)._set_data(a);if(!t.can(this.game.pov,a))return;let s=e.apply();return this.score+=s,this.nb_moves++,this.history.push(e),e}get can_undo(){return this.history.length>0}undo(){if(!this.can_undo)return;let t=this.history.pop(),a=t.undo();return this.score+=a,this.nb_moves++,t}},Ya=Wa;M(Ya,"make",t=>new Wa(t,{score:0,nb_moves:0},[]));var Qa=class{constructor(t,a,e){o(this,"history");this.game=t,this.stats=a,this.history=e}finalize_apply_pov(t){this.game.finalize_apply_pov(t)}get clone(){let t=this.game.clone;return new Qa(t,{...this.stats},this.history)}get nb_moves(){return this.stats.nb_moves}set nb_moves(t){this.stats.nb_moves=t}get score(){return this.stats.score}set score(t){this.stats.score=t}get can_undo(){return this.history>0}apply(t,a){t.apply(this.game,a),this.nb_moves++,this.history++}undo_pov(){this.nb_moves++,this.history--}undo(t){t.undo_pov(this.game)}},B={Recycle:-10,HitStock:0,WasteToTableu:10,WasteToFoundation:30,TableuToFoundation:20,FoundationToTableu:-30,Undo:-80,TableuToTableuFlip:10,TableuToTableuNoFlip:0};function oh(t){let[a,e]=t.split("$");return{cards:a,limit:e}}function lh(t){return[t.cards,t.limit].join("$")}var Jt=class{constructor(t,a,e){this.stock=t,this.waste=a,this.hidden=e}get fen(){return[this.stock.fen,this.waste.fen,this.hidden.fen].join("$")}get pov(){return new es(this.stock.hidden_pov,this.waste,this.hidden.hidden_pov)}get can_hit(){return this.stock.length>0}get can_recycle(){return this.stock.length===0&&this.waste.length+this.hidden.length>0}from_waste(){return{cards:this.waste.remove_cards(1)}}undo_from_waste(t){this.waste.add_cards(t)}hit(t){let a=this.stock.remove_cards(t),e=this.waste.remove_all();return this.hidden.unshift_cards(e),this.waste.add_cards(a),{waste:e,cards:a}}undo_hit(t){let{cards:a,waste:e}=t,s=this.waste.remove_cards(a.length),i=this.hidden.shift_cards(e.length);this.waste.add_cards(i),this.stock.add_cards(s)}recycle(){let t=this.waste.remove_all();return this.hidden.unshift_cards(t),this.stock.add_cards(this.hidden.remove_all()),{waste:t}}undo_recycle(t){let{waste:a}=t;this.hidden.add_cards(this.stock.remove_all());let e=this.hidden.shift_cards(a.length);this.waste.add_cards(e)}},ut=Jt;M(ut,"from_fen",t=>{let[a,e,s]=t.split("$"),i=K.from_fen(a),h=K.from_fen(e),r=K.from_fen(s);return new Jt(i,h,r)});M(ut,"make",t=>new Jt(K.take_n(t,t.length),K.empty,K.empty));var Zt=class{constructor(t,a){this.back=t,this.front=a}get fen(){return[this.back.fen,this.front.fen].join("$")}get pov(){return new ts(this.back.hidden_pov,this.front)}from_tableu(t){let a=this.front.remove_cards(t);if(this.front.length===0){let[e]=this.back.remove_cards(1);return e?(this.front.add_cards([e]),{flip:e,cards:a}):{cards:a}}return{cards:a}}undo_from_tableu(t){if(t.flip){let a=this.front.remove_cards(1);this.back.add_cards(a)}this.front.add_cards(t.cards)}to_tableu(t){this.front.add_cards(t)}undo_to_tableu(t){this.front.remove_cards(t.length)}},xt=Zt;M(xt,"from_fen",t=>{let[a,e]=t.split("$");return new Zt(K.from_fen(a),K.from_fen(e))});M(xt,"make",(t,a)=>new Zt(K.take_n(t,a),K.take_n(t,1)));var wt=class{constructor(t){this.foundation=t}get fen(){return this.foundation.fen}get clone(){return new wt(this.foundation.clone)}get suit(){var t;return(t=this.foundation.top_card)==null?void 0:t[0]}get is_finished(){return this.foundation.length===13}get next_top(){if(!this.suit)return;let t=this.suit,a=jt[this.foundation.length];return`${t}${a}`}get can_from(){let{top_card:t}=this.foundation;if(t)return{cards:[t]}}can_to(t){let[a]=t;return t.length===1&&(this.next_top?a===this.next_top:rh(a))}to_foundation(t){this.foundation.add_cards(t)}undo_to_foundation(t){this.foundation.remove_cards(t.length)}from_foundation(){return{cards:this.foundation.remove_cards(1)}}undo_from_foundation(t){this.foundation.add_cards(t)}},kt=wt;M(kt,"from_fen",t=>{let a=t;return new wt(K.from_fen(a))});M(kt,"make",()=>new wt(K.empty));var st=[...Array(7).keys()],Ea=[...Array(4).keys()],ea=class{constructor(t,a,e,s,i){this.settings=t,this.nb_recycles=a,this.stock=e,this.tableus=s,this.foundations=i}get fen(){let t=lh(this.settings),a=this.stock.fen,e=this.tableus.map(h=>h.fen).join("/"),s=this.foundations.map(h=>h.fen).join("/"),i=this.nb_recycles;return[t,i,a,e,s].join(" ")}get hit_n(){return this.settings.cards==="threecards"?3:1}get pov(){return new as(this.settings,this.nb_recycles,this.stock.pov,this.tableus.map(t=>t.pov),this.foundations)}get recycle_n(){return this.settings.limit==="nolimit"?9999:this.settings.limit==="threepass"?3:1}get can_hit(){return this.stock.can_hit}get can_recycle(){return this.has_recycle_limit&&this.stock.can_recycle}get has_recycle_limit(){return this.recycle_n-this.nb_recycles>0}hit_stock(){return this.stock.hit(this.hit_n)}undo_hit_stock(t){this.stock.undo_hit(t)}recycle(){return this.nb_recycles++,this.stock.recycle()}undo_recycle(t){this.nb_recycles--,this.stock.undo_recycle(t)}tableu_to_tableu(t){let{from:a,to:e,i:s}=t,i=this.tableus[a].from_tableu(s);return this.tableus[e].to_tableu(i.cards),i}undo_tableu_to_tableu(t,a){let{from:e,to:s,i}=t;this.tableus[s].undo_to_tableu(a.cards),this.tableus[e].undo_from_tableu(a)}waste_to_tableu(t){let{to:a}=t,e=this.stock.from_waste();return this.tableus[a].to_tableu(e.cards),e}undo_waste_to_tableu(t,a){let{to:e}=t;this.tableus[e].undo_to_tableu(a.cards),this.stock.undo_from_waste(a.cards)}waste_to_foundation(t){let{to:a}=t,e=this.stock.from_waste();return this.foundations[a].to_foundation(e.cards),e}undo_waste_to_foundation(t,a){let{to:e}=t;this.foundations[e].undo_to_foundation(a.cards),this.stock.undo_from_waste(a.cards)}tableu_to_foundation(t){let{from:a,to:e}=t,s=this.tableus[a].from_tableu(1);return this.foundations[e].to_foundation(s.cards),s}undo_tableu_to_foundation(t,a){let{from:e,to:s}=t;this.foundations[s].undo_to_foundation(a.cards),this.tableus[e].undo_from_tableu(a)}foundation_to_tableu(t){let{from:a,to:e}=t,s=this.foundations[a].from_foundation();return this.tableus[e].to_tableu(s.cards),s}undo_foundation_to_tableu(t,a){let{from:e,to:s}=t;this.tableus[s].undo_to_tableu(a.cards),this.foundations[e].undo_from_foundation(a.cards)}},ta=ea;M(ta,"from_fen",t=>{let[a,e,s,i,h]=t.split(" "),r=oh(a),l=parseInt(e),p=ut.from_fen(s),d=i.split("/").map(f=>xt.from_fen(f)),g=h.split("/").map(f=>kt.from_fen(f));return new ea(r,l,p,d,g)});M(ta,"make",(t,a)=>{let e=st.map(h=>xt.make(a,h)),s=ut.make(a),i=0;return new ea(t,i,s,e,Yt.map(h=>kt.make()))});var Ee=class extends xe{constructor(){super(...arguments);o(this,"data")}get solitaire(){return this.game}apply(){return this.data=this.solitaire.hit_stock(),B.HitStock}undo(){return this.solitaire.undo_hit_stock(this.data),B.Undo}undo_pov(a){a.undo_hit_stock(this.data)}};M(Ee,"can",t=>t.can_hit);M(Ee,"apply",t=>{t.hit_stock()});var Ie=class extends xe{constructor(){super(...arguments);o(this,"data")}get solitaire(){return this.game}apply(){return this.data=this.solitaire.recycle(),B.Recycle}undo(){return this.solitaire.undo_recycle(this.data),B.Undo}undo_pov(a){a.undo_recycle(this.data)}};M(Ie,"can",t=>t.can_recycle);M(Ie,"apply",t=>{t.recycle()});var ce=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.tableu_to_tableu(this.data),this.res.flip?B.TableuToTableuFlip:B.TableuToTableuNoFlip}undo(){return this.solitaire.undo_tableu_to_tableu(this.data,this.res),B.Undo}undo_pov(a){a.undo_tableu_to_tableu(this.data,this.res)}};M(ce,"can",(t,a)=>{let e=a,s=t.can_drag_tableu(e);return s?t.can_drop_tableu({...a,...s}):!1});M(ce,"apply",(t,a)=>{t.tableu_to_tableu(a)});var pe=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.waste_to_tableu(this.data),B.WasteToTableu}undo(){return this.solitaire.undo_waste_to_tableu(this.data,this.res),B.Undo}undo_pov(a){a.undo_waste_to_tableu(this.data,this.res)}};M(pe,"can",(t,a)=>{const e=t.can_drag_waste;return e?t.can_drop_tableu({...a,...e}):!1});M(pe,"apply",(t,a)=>{t.waste_to_tableu(a)});var Ja=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.waste_to_foundation(this.data),B.WasteToFoundation}undo(){return this.solitaire.undo_waste_to_foundation(this.data,this.res),B.Undo}undo_pov(a){a.undo_waste_to_foundation(this.data,this.res)}},H=Ja;M(H,"auto_can",t=>{for(let a=0;a<4;a++)if(Ja.can(t,{to:a}))return{to:a}});M(H,"can",(t,a)=>{const e=t.can_drag_waste;return e?t.can_drop_foundation({...a,...e}):!1});M(H,"apply",(t,a)=>{t.waste_to_foundation(a)});var Za=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.tableu_to_foundation(this.data),B.TableuToFoundation}undo(){return this.solitaire.undo_tableu_to_foundation(this.data,this.res),B.Undo}undo_pov(a){a.undo_tableu_to_foundation(this.data,this.res)}},X=Za;M(X,"auto_can",(t,a)=>{let{tableu:e}=a;for(let s=0;s<4;s++)if(Za.can(t,{from:e,to:s}))return{from:e,to:s}});M(X,"can",(t,a)=>{const e=t.can_drag_tableu({...a,i:1});return e?t.can_drop_foundation({...a,...e}):!1});M(X,"apply",(t,a)=>{t.tableu_to_foundation(a)});var ke=class extends xe{constructor(){super(...arguments);o(this,"res")}get solitaire(){return this.game}get data(){return this._data}apply(){return this.res=this.solitaire.foundation_to_tableu(this.data),B.FoundationToTableu}undo(){return this.solitaire.undo_foundation_to_tableu(this.data,this.res),B.Undo}undo_pov(a){a.undo_foundation_to_tableu(this.data,this.res)}};M(ke,"can",(t,a)=>{const e=t.can_drag_foundation(a);return e?t.can_drop_tableu({...a,...e}):!1});M(ke,"apply",(t,a)=>{t.foundation_to_tableu(a)});var es=class{constructor(t,a,e){this.stock=t,this.waste=a,this.hidden=e}pov_hit_stock(t){this.waste.remove_cards(t.length),this.waste.add_cards(t)}get can_hit(){return this.stock.length>0}get can_recycle(){return this.stock.length===0&&this.waste.length+this.hidden.length>0}get can_from_waste(){let{top_card:t}=this.waste;if(t)return{cards:[t]}}get clone(){return new es(this.stock.clone,this.waste.clone,this.hidden.clone)}from_waste(){return{cards:this.waste.remove_cards(1)}}undo_from_waste(t){this.waste.add_cards(t)}hit(t){let a=this.stock.remove_cards(t),e=this.waste.remove_all();this.hidden.unshift_cards(e),this.waste.add_cards(a)}undo_hit(t){let{cards:a,waste:e}=t;this.waste.remove_cards(a.length),this.hidden.shift_cards(e.length),this.waste.add_cards(e),this.stock.add_cards(a)}recycle(){let t=this.waste.remove_all();return this.hidden.unshift_cards(t),this.stock.add_cards(this.hidden.remove_all()),{waste:t}}undo_recycle(t){let{waste:a}=t;this.hidden.add_cards(this.stock.remove_all());let e=this.hidden.shift_cards(a.length);this.waste.add_cards(e)}},ts=class{constructor(t,a){this.back=t,this.front=a}pov_flip(t){this.front.remove_cards(1),this.front.add_cards([t])}get clone(){return new ts(this.back.clone,this.front.clone)}can_from(t){let a=this.front.clone;this.back.clone;let e=a.remove_cards(t);if(e.length===t)return{cards:e}}can_to(t){let a=t[0];return a?this.front.length>0?ih(a,this.front.top_card)&&sh(a,this.front.top_card):hh(a):!1}from_tableu(t){let a=this.front.remove_cards(t);if(this.front.length===0){let[e]=this.back.remove_cards(1);return e?(this.front.add_cards([e]),{flip:e,cards:a}):{cards:a}}return{cards:a}}undo_from_tableu(t){if(t.flip){let a=this.front.remove_cards(1);this.back.add_cards(a)}this.front.add_cards(t.cards)}to_tableu(t){this.front.add_cards(t)}undo_to_tableu(t){this.front.remove_cards(t.length)}},as=class{constructor(t,a,e,s,i){this.settings=t,this.nb_recycles=a,this.stock=e,this.tableus=s,this.foundations=i}get clone(){return new as(this.settings,this.nb_recycles,this.stock.clone,this.tableus.map(t=>t.clone),this.foundations.map(t=>t.clone))}get recycle_n(){return this.settings.limit==="nolimit"?9999:this.settings.limit==="threepass"?3:1}get hit_n(){return this.settings.cards==="threecards"?3:1}get has_recycle_limit(){return this.recycle_n-this.nb_recycles>0}get can_hit(){return this.stock.can_hit}get can_recycle(){return this.has_recycle_limit&&this.stock.can_recycle}get is_finished(){return this.foundations.every(t=>t.is_finished)}can_drag_tableu(t){let{from:a,i:e}=t;return this.tableus[a].can_from(e)}can_drop_tableu(t){let{to:a,cards:e}=t;return this.tableus[a].can_to(e)}can_drop_foundation(t){let{to:a,cards:e}=t;return this.foundations[a].can_to(e)}get can_drag_waste(){return this.stock.can_from_waste}can_drag_foundation(t){let{from:a}=t;return this.foundations[a].can_from}hit_stock(){return this.stock.hit(this.hit_n)}undo_hit_stock(t){this.stock.undo_hit(t)}recycle(){return this.nb_recycles++,this.stock.recycle()}undo_recycle(t){this.nb_recycles--,this.stock.undo_recycle(t)}finalize_apply_pov(t){if(t instanceof ce&&t.res.flip){let{from:a}=t.data;this.tableus[a].pov_flip(t.res.flip)}if(t instanceof X&&t.res.flip){let{from:a}=t.data;this.tableus[a].pov_flip(t.res.flip)}t instanceof Ee&&this.stock.pov_hit_stock(t.data.cards)}tableu_to_tableu(t){let{from:a,to:e,i:s}=t,i=this.tableus[a].from_tableu(s);return this.tableus[e].to_tableu(i.cards),i}undo_tableu_to_tableu(t,a){let{from:e,to:s,i}=t;this.tableus[s].undo_to_tableu(a.cards),this.tableus[e].undo_from_tableu(a)}waste_to_tableu(t){let{to:a}=t,e=this.stock.from_waste();return this.tableus[a].to_tableu(e.cards),e}undo_waste_to_tableu(t,a){let{to:e}=t;this.tableus[e].undo_to_tableu(a.cards),this.stock.undo_from_waste(a.cards)}waste_to_foundation(t){let{to:a}=t,e=this.stock.from_waste();return this.foundations[a].to_foundation(e.cards),e}undo_waste_to_foundation(t,a){let{to:e}=t;this.foundations[e].undo_to_foundation(a.cards),this.stock.undo_from_waste(a.cards)}tableu_to_foundation(t){let{from:a,to:e}=t,s=this.tableus[a].from_tableu(1);return this.foundations[e].to_foundation(s.cards),s}undo_tableu_to_foundation(t,a){let{from:e,to:s}=t;this.foundations[s].undo_to_foundation(a.cards),this.tableus[e].undo_from_tableu(a)}foundation_to_tableu(t){let{from:a,to:e}=t,s=this.foundations[a].from_foundation();return this.tableus[e].to_tableu(s.cards),s}undo_foundation_to_tableu(t,a){let{from:e,to:s}=t;this.tableus[s].undo_to_tableu(a.cards),this.foundations[e].undo_from_foundation(a.cards)}};const Ft={s:"spades",d:"diamonds",h:"hearts",c:"clubs"},_h={A:"a",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9",T:"t",J:"j",Q:"q",K:"k"};class dh extends w{constructor(){super(...arguments);o(this,"_card");o(this,"rank");o(this,"rsuit");o(this,"suit");o(this,"decsuit")}get waiting(){return this._card===Qt}get card(){return this._card}set card(e){this._card=e,this.rank.play_now(_h[e[1]]),this.suit.play_now(Ft[e[0]]),this.rsuit.play_now(Ft[e[0]]),this.decsuit.forEach(s=>s.play_now(Ft[e[0]]))}_init(){let e=n.make(40,50);this.decsuit=[...Array(3).keys()].map(()=>e=e.add(N().mul(n.make(4,30)).add(n.make(0,30)))).map(i=>{let h=this.make(R,i,{name:"suit"});return h.origin=n.make(32,32),h.play_now("spades"),h.scale=n.one.scale(N().x*.2).add(n.make(.2,.2)),h});let s=[...Array(2).keys()].map(()=>e=e.sub(N().mul(n.make(24,20)).add(n.make(0,30)))).map(i=>{i.x+=120;let h=this.make(R,i,{name:"suit"});return h.origin=n.make(32,32),h.play_now("spades"),h.scale=n.one.scale(N().x*.2).add(n.make(.2,.2)),h});this.decsuit.push(...s),this.rank=this.make(R,n.make(140,32),{name:"rank_2"}),this.rank.origin=n.make(32,32),this.rank.play_now("a"),this.rank.scale=n.make(.6,.6),this.suit=this.make(R,n.make(30,32),{name:"suit"}),this.suit.origin=n.make(32,32),this.suit.play_now("spades"),this.suit.scale=n.make(.6,.6),this.rsuit=this.make(R,n.make(150,210),{name:"suit"}),this.rsuit.origin=n.make(32,32),this.rsuit.rotation=Math.PI,this.rsuit.play_now("spades"),this.rsuit.scale=n.make(.6,.6)}}class ch extends w{constructor(){super(...arguments);o(this,"decoration");o(this,"_will_lerp_t");o(this,"_will_lerp_position");o(this,"_dragging");o(this,"_drag_decay",n.zero);o(this,"_on_drag");o(this,"_on_drop");o(this,"_on_hover");o(this,"_on_click");o(this,"facing");o(this,"anim");o(this,"shadow");o(this,"highlight");o(this,"_will_hover");o(this,"_will_hover_end");o(this,"_will_flip_back");o(this,"_will_flip_front");o(this,"lerp_hover_y");o(this,"_lerp_drag_shadow");o(this,"_tr");o(this,"_tx");o(this,"_ty");o(this,"_target_speed");o(this,"_speed");o(this,"_hover_time");o(this,"_after_ease")}release(){this.lerp_position(),this.unset_dragging(),this.set_highlight(!1),this.bind_click(void 0),this.bind_drag(void 0),this.bind_drop(void 0),this.bind_hover(void 0),this._after_ease=void 0}lerp_release(){this.lerp_position(),this.unset_dragging()}get waiting(){return this.decoration.waiting}get card(){return this.decoration.card}set card(e){this.decoration.card=e,this.waiting?this.anim._animation==="idle"&&(this.anim.play_now("wait"),this.decoration.visible=!1):this.anim._animation==="wait"&&(this.anim.play_now("idle"),this.decoration.visible=!0)}get flipping(){return this.anim._animation==="flip"||this.anim._animation==="back_flip"}get easing(){return!!this._tx||!!this._ty||!!this._tr}lerp_position(e,s){this._tx&&(this.cancel(this._tx),this._tx=void 0),this._ty&&(this.cancel(this._ty),this._ty=void 0),this._will_lerp_position=e,this._will_lerp_t=s,e?this._target_speed=(1-(s||.5))*.2:this._target_speed=0}get drag_decay(){return this._drag_decay}bind_drag(e){this._on_drag=e}bind_drop(e){this._on_drop=e}bind_hover(e){this._on_hover=e}bind_click(e){this._on_click=e}get hover_time(){return this._hover_time??0}ease_rotation(e,s=E.half){this._tr=this.tween_single(this._tr,[this.rotation,e],i=>{this.rotation=i},s,0,()=>{this._tr=void 0})}ease_position(e,s=E.half){e.equals(this.position)||(this._target_speed=s/E.half*.2,this._tx=this.tween_single(this._tx,[this.position.x,e.x],i=>{this.position.x=i},s,0,()=>{this._tx=void 0,this._target_speed=0}),this._ty=this.tween_single(this._ty,[this.position.y,e.y],i=>{this.position.y=i},s,0,()=>{this._ty=void 0}))}set_highlight(e){this.highlight.visible=e}set_dragging(){this._lerp_drag_shadow=0,this._dragging=!0}unset_dragging(){this._dragging=!1}after_ease(e){this._after_ease=e}_init(){this.shadow=this._make(R,n.make(0,0),{name:"card"}),this.shadow.origin=n.make(88,120),this.shadow.play_now("shadow"),this.anim=this.make(R,n.make(0,0),{name:"card"}),this.anim.origin=n.make(88,120),this.facing=-1,this.anim.play_now("back_idle"),this.highlight=this.make(R,n.make(0,0),{name:"card"}),this.highlight.origin=n.make(88,120),this.highlight.play_now("highlight"),this.highlight.visible=!1,this.decoration=this.make(dh,n.make(-80,-120),{}),this.decoration.visible=!1,this.decoration.card=Qt,this._will_hover=!1,this._will_hover_end=!1,this._will_flip_back=!1,this._will_flip_front=!1,this.lerp_hover_y=0,this._dragging=!1,this._speed=0,this._target_speed=0;let e=this;this.make(D,n.make(16,16).sub(this.anim.origin),{rect:x.make(0,0,170,210),on_click(){if(e._on_click)return e._on_click()},on_hover(){return e._on_hover&&e._on_hover[0](),e._on_drag?(e._will_hover=!0,!0):!1},on_hover_end(){e._on_hover&&e._on_hover[1](),e._will_hover_end=!0},on_drag_begin(s){return e._on_drag?(e._lerp_drag_shadow=0,e._dragging=!0,e._drag_decay=s.sub(e.position),!0):!1},on_drag_end(){e._dragging=!1},on_drag(s){return e._on_drag?(e._on_drag(s),!0):!1},on_drop(){e._on_drop&&e._on_drop()}})}_update(){this._speed=he(this._speed,this._target_speed,.2);let e=$i(Math.abs(Math.sin(b.seconds*3)))*this._speed;if(this.scale=n.make(1-e,1+e),this._will_lerp_position&&(this.position=n.lerp(this.position,this._will_lerp_position,this._will_lerp_t??.5)),this._lerp_drag_shadow!==void 0&&(this._dragging?this._lerp_drag_shadow=he(this._lerp_drag_shadow,1,.2):(this._lerp_drag_shadow=he(this._lerp_drag_shadow,0,.2),this._lerp_drag_shadow<.001&&(this._lerp_drag_shadow=void 0))),this._lerp_drag_shadow!==void 0){let s=this._lerp_drag_shadow*.05;this.shadow.scale=n.one.add(n.one.scale(s)),this.shadow.alpha=(1-this._lerp_drag_shadow)*100+155}if(this._after_ease&&!this.easing&&(this._after_ease(),this._after_ease=void 0),this.easing||(this.anim.position.y=he(this.anim.position.y,this.lerp_hover_y,.2),this.decoration.position.y=he(this.decoration.position.y,this.lerp_hover_y-120,.16),this.highlight.position.y=he(this.highlight.position.y,this.lerp_hover_y,.16)),this._will_hover&&(this._will_hover=!1,!this.easing&&!this.flipping&&this._will_flip_back&&this._will_flip_front&&this.anim.play(this.facing===1?"hover":"back_hover"),this.lerp_hover_y=-6,this._hover_time=0),this._will_hover_end){this._will_hover_end=!1;let s=this.waiting?"wait":"idle";!this.easing&&!this.flipping&&this._will_flip_back&&this._will_flip_front&&this.anim.play(this.facing===1?s:"back_idle"),this.lerp_hover_y=0,this._hover_time=void 0}this._hover_time!==void 0&&this._hover_time>=0&&(this.easing&&(this._hover_time=0),this._hover_time+=b.delta),this._will_flip_back&&(this.easing||(this._will_flip_back=!1,this.shadow.visible=!1,this.decoration.visible=!1,this.anim.play_now("flip",()=>{this.facing=-1,this.anim.play("back_idle"),this.shadow.visible=!0}))),this._will_flip_front&&(this.easing||(this._will_flip_front=!1,this.shadow.visible=!1,this.decoration.visible=!1,this.anim.play_now("back_flip",()=>{this.facing=1,this.anim.play(this.waiting?"wait":"idle"),this.shadow.visible=!0,this.waiting||(this.decoration.visible=!0)})))}flip_back(){this._will_flip_front=!1,this._will_flip_back=this.facing!==-1||this.anim._animation==="back_flip"}flip_front(){this._will_flip_back=!1,this._will_flip_front=this.facing!==1||this.anim._animation==="flip"}_draw_shadow(e){e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),this.shadow.draw(e),e.pop_matrix()}}class ss extends w{constructor(){super(...arguments);o(this,"_on_click");o(this,"_on_drop");o(this,"_will_hover");o(this,"_will_hover_end");o(this,"anim")}bind_click(e){this._on_click=e}bind_drop(e){this._on_drop=e}_init(){this.anim=this._make(R,n.make(0,0),{name:"card"}),this.anim.origin=n.make(88,120);let e=this;this.make(D,n.make(16,16).sub(this.anim.origin),{rect:x.make(0,0,170,210),on_hover(){return e._on_drop?(e._will_hover=!0,!0):!1},on_hover_end(){e._will_hover_end=!0},on_drop(){e._on_drop&&e._on_drop()},on_click(){return e._on_click?(e._on_click(),!0):!1}})}_update(){this._will_hover&&(this._will_hover=!1),this._will_hover_end&&(this._will_hover_end=!1)}}class ph extends w{constructor(){super(...arguments);o(this,"frees");o(this,"used");o(this,"_shadow_group")}borrow(){let e=this.frees.shift();return this.used.push(e),e.visible=!0,e}release(e){e.visible=!1,this.used.splice(this.used.indexOf(e),1),e.release(),this.frees.push(e)}set shadow_group(e){this._shadow_group=e}_init(){this.frees=Ga.deck.map(e=>{let s=this.make(ch,n.zero,{});return s.visible=!1,s}),this.used=[]}_draw(e){var s,i;e.push_matrix(v.create_transform(this.position,this.origin,this.scale,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),this._draw_children(e),(s=this._shadow_group)==null||s.forEach(h=>{h._draw_shadow(e)}),(i=this._shadow_group)==null||i.forEach(h=>{h.draw(e)}),e.pop_matrix()}}class Te extends w{constructor(){super(...arguments);o(this,"_i_gap");o(this,"cards")}get data(){return this._data}get length(){return this.cards.length}get top_card(){return this.cards[this.cards.length-1]}get h(){let e=55*(1-this.cards.length/50);return this.data.h??e}get top_position(){return this.position.add(n.make(0,this.cards.length*this.h))}set_highlight(e,s){this.cards.slice(this.cards.length-e,this.cards.length).forEach(h=>h.set_highlight(s))}add_cards(e){e.forEach(s=>s.send_front()),this.cards.push(...e),this._reposition()}remove_cards(e){let s=this.cards.splice(this.cards.length-e,this.cards.length);return this._reposition(),s}set i_gap(e){this._i_gap!==e&&(this._i_gap=e,this._reposition())}_reposition(){this.cards.forEach((e,s)=>{let i=this._i_gap!==void 0&&s>this._i_gap?s+.5:s;e.ease_position(this.p_position.add(n.make(0,i*this.h)))})}ease_position(e){this.position=e,this._reposition()}_init(){this.cards=[]}}function fh(t){return 1/(1+Math.exp(-t))}class Rt extends w{constructor(){super(...arguments);o(this,"_waiting",!1);o(this,"_cards")}get waiting(){return this._waiting}wait_drop(){this._waiting=!0}set cards(e){this._cards=e.slice(0),this._cards.forEach(s=>s.send_front()),this._cards.forEach(s=>s.set_dragging())}get drag_decay(){return this._cards[0].drag_decay}get h(){return 50}drag(e){this._cards.forEach((s,i)=>{let h=e.add(n.make(0,this.h*i).sub(this.drag_decay)),r=1-fh(i/this._cards.length*2);s.lerp_position(h,r)})}lerp_release(){let e=this._cards.splice(0);return e.forEach(s=>s.lerp_release()),e}_init(){this._cards=[]}}class gh extends w{constructor(){super(...arguments);o(this,"backs");o(this,"fronts");o(this,"drop_target")}get data(){return this._data}get top_front_position(){return this.fronts.top_position}get top_back_position(){return this.backs.top_position}release_all(){return this.free()}free(){return[...this.backs.remove_cards(this.backs.length),...this.fronts.remove_cards(this.fronts.length)]}add_backs(e){e.forEach(s=>s.flip_back()),this.backs.add_cards(e),this.fronts.ease_position(this.top_back_position)}add_fronts(e){var h;this.fronts.add_cards(e),e.forEach(r=>r.flip_front());let s=this,i=this.fronts.cards.length;this.fronts.cards.forEach((r,l)=>{r.bind_drop(void 0),r.bind_drag(p=>{s.data.on_front_drag(i-l,p)}),r.bind_click(()=>(s.data.on_front_click(i-l),!0))}),(h=this.fronts.top_card)==null||h.bind_drop(()=>{s.data.on_front_drop()}),this.open_drop_target()}remove_fronts(e){var r;let s=this.fronts.remove_cards(e);s.forEach(l=>{l.bind_drop(void 0)});let i=this,h=this.fronts.cards.length;return this.fronts.cards.forEach((l,p)=>{l.bind_drop(void 0),l.bind_drag(d=>{i.data.on_front_drag(h-p,d)}),l.bind_click(()=>(i.data.on_front_click(h-p),!0))}),(r=this.fronts.top_card)==null||r.bind_drop(()=>{i.data.on_front_drop()}),this.open_drop_target(),s}flip_front(e){var h;let[s]=this.backs.remove_cards(1);s.card=e,s.flip_front(),this.fronts.ease_position(this.top_back_position),(h=this.fronts.top_card)==null||h.bind_drop(void 0),this.fronts.add_cards([s]);let i=this;this.fronts.top_card.bind_drag(r=>{i.data.on_front_drag(1,r)}),this.fronts.top_card.bind_drop(()=>{i.data.on_front_drop()}),this.fronts.top_card.bind_click(()=>(i.data.on_front_click(1),!0))}get empty(){return this.fronts.length===0&&this.backs.length===0}open_drop_target(){this.drop_target.visible=this.empty}flip_back(){let[e]=this.fronts.remove_cards(1);e.flip_back(),this.backs.add_cards([e]),this.fronts.ease_position(this.top_back_position),e.bind_drop(void 0)}_init(){this.drop_target=this.make(ss,n.make(0,0),{}),this.drop_target.bind_drop(()=>{this.data.on_front_drop()}),this.drop_target.bind_click(()=>(this.data.on_front_click(1),!0)),this.backs=this.make(Te,n.make(0,0),{h:33}),this.fronts=this.make(Te,n.make(0,0),{}),this.open_drop_target()}_update(){let e=this.fronts.cards.findIndex(s=>s.hover_time>E.thirds);e!==-1?this.fronts.i_gap=e:this.fronts.i_gap=void 0}}const Ct=t=>typeof t=="object"&&t.foundation!==void 0,mh=t=>typeof t=="object"&&typeof t.tableu=="number";class yh extends w{constructor(){super(...arguments);o(this,"anim")}get data(){return this._data}disable(){this.anim.play("disabled")}enable(){this.anim.play("idle")}_init(){let e=this.make(R,n.make(0,0),{name:"recycle"});this.anim=e;let s=this;this.make(D,n.make(20,20),{rect:x.make(0,0,140,160),on_hover(){e._animation!=="disabled"&&e.play("hover")},on_hover_end(){e._animation!=="disabled"&&e.play("idle")},on_click(){s.data.on_recycle()}})}}const uh=(t,a)=>{for(let e=t.length-1;e>=0;e--)a(t[e])};class xh extends w{constructor(){super(...arguments);o(this,"stock");o(this,"waste");o(this,"waste_hidden")}get data(){return this._data}get can_recycle(){return this.stock.length===0}release_all(){return this.free()}free(){return[...this.stock.remove_cards(this.stock.length),...this.waste.remove_cards(this.waste.length),...this.waste_hidden.remove_cards(this.waste_hidden.length)]}add_waste_hidden(e){e.forEach(s=>s.flip_back()),this.waste_hidden.add_cards(e)}add_waste(e){e.forEach(s=>{s.bind_drop(void 0),s.bind_drag(void 0),s.bind_click(void 0)}),this.waste.add_cards(e),e.forEach((s,i)=>s.flip_front()),this.bind_new_front()}add_stocks(e){e.forEach(s=>s.flip_back()),this.stock.add_cards(e)}remove_waste(e){return this.waste.remove_cards(e)}bind_new_front(){var e,s;this.waste.cards.forEach(i=>{i.bind_drag(void 0),i.bind_click(void 0)}),(e=this.waste.top_card)==null||e.bind_drag(i=>{this.data.on_front_drag(i)}),(s=this.waste.top_card)==null||s.bind_click(()=>(this.data.on_waste_click(),!0))}undo_hit(e,s){let i=this.waste.remove_cards(e.length),h=this.waste_hidden.remove_cards(s.length);this.waste.add_cards(h),h.forEach((r,l)=>{r.card=s[l],r.flip_front()}),i.forEach(r=>{r.flip_back(),r.bind_click(void 0),r.bind_drag(void 0)}),this.stock.add_cards(i),this.bind_new_front()}hit(e){let s=this.stock.remove_cards(e.length);s.forEach((h,r)=>h.card=e[r]),s.forEach((h,r)=>h.flip_front());let i=this.waste.remove_cards(this.waste.cards.length);i.forEach(h=>{h.flip_back(),h.bind_drag(void 0),h.bind_click(void 0)}),this.waste_hidden.add_cards(i),this.waste.add_cards(s),uh(this.waste_hidden.cards,h=>h.send_back()),this.bind_new_front(),$.play("hit")}recycle(){let e=this.waste.remove_cards(this.waste.length);this.waste_hidden.add_cards(e);let s=this.waste_hidden.remove_cards(this.waste_hidden.length);s.forEach(i=>{i.bind_drag(void 0),i.bind_click(void 0)}),s.forEach(i=>i.flip_back()),s.forEach(i=>i.send_front()),this.stock.add_cards(s),$.play("recycle")}undo_recycle(e){let s=this.stock.remove_cards(this.stock.length);this.waste_hidden.add_cards(s);let i=this.waste_hidden.remove_cards(e);s.forEach(h=>h.flip_front()),i.forEach(h=>h.flip_front()),this.waste.add_cards(i)}_init(){this.stock=this.make(Te,n.make(0,0),{h:1}),this.waste=this.make(Te,n.make(0,260),{}),this.waste_hidden=this.make(Te,n.make(0,300),{h:0});let e=this;this.make(D,n.make(-64,-80),{rect:x.make(0,0,160,210),on_click(){e.stock.length>0&&e.data.on_hit()}})}}class wh extends w{constructor(){super(...arguments);o(this,"foundation");o(this,"drop_target")}get data(){return this._data}release_all(){return this.free()}free(){return this.remove_cards(this.foundation.length)}add_cards(e){var s,i;this.foundation.add_cards(e),(s=this.foundation.top_card)==null||s.bind_drag(h=>this.data.on_front_drag(h)),(i=this.foundation.top_card)==null||i.bind_click(()=>this.data.on_front_click())}remove_cards(e){return this.foundation.remove_cards(e)}_init(){this.drop_target=this.make(ss,n.make(0,0),{}),this.drop_target.bind_drop(()=>{this.data.on_front_drop()}),this.drop_target.bind_click(()=>(this.data.on_front_click(),!0)),this.foundation=this.make(Te,n.make(0,0),{h:0})}}class kh extends w{constructor(){super(...arguments);o(this,"recycle_view");o(this,"cards");o(this,"dealer");o(this,"stock");o(this,"tableus");o(this,"foundations");o(this,"dragging");o(this,"drag_source");o(this,"click_source");o(this,"back_res");o(this,"trigger_auto",-2)}get game_pov(){return this.back_res.game_pov}get pov(){return this.game_pov.game}get cmd(){return this.back_res.cmd}_init(){let e=this;this.make(D,n.zero,{rect:x.make(0,0,1920,1080),on_up(){e.dragging&&!e.dragging.waiting&&e._release_cancel_drag()},on_click(){e.click_source&&e._release_cancel_highlight()}}),this.recycle_view=this.make(yh,n.make(40,200),{on_recycle(){e.stock.can_recycle&&e.cmd(Ie)}}),this.cards=this.make(ph,n.zero,{});let s=120,i=320;this.stock=this.make(xh,n.make(s,i),{on_waste_click(){if(e.click_source==="waste"){e._release_cancel_highlight();let f=H.auto_can(e.pov);f&&(e.trigger_auto=-1,e.cmd(H,f));return}e._release_cancel_highlight(),e.stock.waste.top_card.set_highlight(!0),e.click_source="waste"},on_hit(){e.cmd(Ee)},on_front_drag(f){if(e._release_cancel_highlight(),e.dragging)e.dragging.drag(f);else{if(e.trigger_auto!==-2)return;if(e.pov.can_drag_waste){let m=e.stock.remove_waste(1);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=m,e.cards.shadow_group=m,e.drag_source="waste",$.play("drag1")}}}});let h=350,r=180,l=200;this.tableus=st.map(f=>this.make(gh,n.make(h+l*f,r),{on_front_click(m){if(!e.click_source)e._release_cancel_highlight(),e.tableus[f].fronts.set_highlight(m,!0),e.click_source={tableu:f,i:m};else if(e.click_source==="waste")e.cmd(pe,{to:f});else{let{tableu:u,i:k}=e.click_source;if(u===f){if(m===1){e._release_cancel_highlight();let z=X.auto_can(e.pov,{tableu:u});z&&(e.trigger_auto=-1,e.cmd(X,z));return}e._release_cancel_highlight(),e.tableus[f].fronts.set_highlight(m,!0),e.click_source={tableu:f,i:m};return}e.cmd(ce,{from:u,to:f,i:k})}},on_front_drag(m,u){if(e.dragging)e.dragging.drag(u);else{if(e._release_cancel_highlight(),e.trigger_auto!==-2)return;if(e.pov.can_drag_tableu({from:f,i:m})){let k=e.tableus[f].remove_fronts(m);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=k,e.cards.shadow_group=k,e.drag_source={tableu:f,i:m};let z=Math.min(3,Math.floor(m/3)+1);$.play(`drag${z}`)}}},on_front_drop(){if(e.drag_source==="waste")e.dragging.wait_drop(),e.cmd(pe,{to:f});else if(Ct(e.drag_source)){let{foundation:m}=e.drag_source;e.dragging.wait_drop(),e.cmd(ke,{from:m,to:f})}else if(e.drag_source){let{tableu:m,i:u}=e.drag_source;e.dragging.wait_drop(),e.cmd(ce,{from:m,to:f,i:u})}}}));let p=1790,d=166,g=240;this.foundations=Ea.map(f=>this.make(wh,n.make(p,d+g*f),{on_front_click(){if(e.click_source==="waste")e.cmd(H,{to:f});else if(e.click_source){let{tableu:m,i:u}=e.click_source;u===1&&e.cmd(X,{from:m,to:f,i:1})}},on_front_drag(m){if(e._release_cancel_highlight(),e.dragging)e.dragging.drag(m);else{if(e.trigger_auto!==-2)return;if(e.pov.can_drag_foundation({from:f})){let u=e.foundations[f].remove_cards(1);e.dragging=e.make(Rt,n.zero,{}),e.dragging.cards=u,e.cards.shadow_group=u,e.drag_source={foundation:f},$.play("drag1")}}},on_front_drop(){if(e.drag_source==="waste")e.dragging.wait_drop(),e.cmd(H,{to:f});else if(!Ct(e.drag_source)){if(e.drag_source){let{tableu:m,i:u}=e.drag_source;u===1&&(e.dragging.wait_drop(),e.cmd(X,{from:m,to:f,i:1}))}}}})),this.dealer=this.make(zh,n.zero,{on_shuffle(){e.dealer.cards.forEach(f=>e.cards.release(f))}})}_release_cancel_highlight(){if(this.click_source)if(this.click_source==="waste")this.stock.waste.top_card.set_highlight(!1),this.click_source=void 0;else{let{tableu:e,i:s}=this.click_source;this.tableus[e].fronts.set_highlight(s,!1),this.click_source=void 0}else return}_release_cancel_drag(){if(!this.dragging){this._release_cancel_highlight();return}let e=this.dragging.lerp_release();if(this.drag_source==="waste")this.stock.add_waste(e);else if(Ct(this.drag_source)){let{foundation:s}=this.drag_source;this.foundations[s].add_cards(e)}else{let{tableu:s,i}=this.drag_source;this.tableus[s].add_fronts(e)}this.dragging.dispose(),this.dragging=void 0,this.drag_source=void 0,$.play("cancel"),e[0].after_ease(()=>{this.cards.shadow_group=void 0})}_collect_pov(){this._init_pov()}_init_pov(){let{pov:e,stock:s,tableus:i,foundations:h}=this;st.map(r=>{i[r].release_all().forEach(p=>this.cards.release(p))}),s.release_all().forEach(r=>this.cards.release(r)),Ea.map(r=>{h[r].release_all().forEach(p=>this.cards.release(p))}),this.drag_source=void 0,this.click_source=void 0,this._refresh_recycle(),s.add_waste_hidden(e.stock.hidden.cards.map(r=>this.cards.borrow())),s.add_stocks(e.stock.stock.cards.map(r=>this.cards.borrow())),s.add_waste(e.stock.waste.cards.map(r=>{let l=this.cards.borrow();return l.card=r,l})),st.map(r=>{let l=i[r],p=e.tableus[r];l.add_backs(p.back.cards.map(d=>this.cards.borrow())),l.add_fronts(p.front.cards.map(d=>{let g=this.cards.borrow();return g.card=d,g}))})}_refresh_recycle(){this.pov.can_hit?this.recycle_view.visible=!1:this.recycle_view.visible=!0,this.pov.can_recycle?this.recycle_view.enable():this.recycle_view.disable()}new_game(){this._collect_pov()}undo(e){if($.play("undo2"),e instanceof Ee)this.stock.undo_hit(e.data.cards,e.data.waste),this._refresh_recycle();else if(e instanceof Ie)this.stock.undo_recycle(e.data.waste.length),this._refresh_recycle();else if(e instanceof ce){let{flip:s}=e.res,{from:i,to:h,i:r}=e.data;s&&this.tableus[i].flip_back();let l=this.tableus[h].remove_fronts(r);this.tableus[i].add_fronts(l)}else if(e instanceof pe){let{to:s}=e.data,i=this.tableus[s].remove_fronts(1);this.stock.add_waste(i)}else if(e instanceof X){let{flip:s}=e.res,{from:i,to:h}=e.data;s&&this.tableus[i].flip_back();let r=this.foundations[h].remove_cards(1);this.tableus[i].add_fronts(r)}else if(e instanceof H){let{to:s}=e.data,i=this.foundations[s].remove_cards(1);this.stock.add_waste(i)}else if(e instanceof ke){let{from:s,to:i}=e.data,h=this.tableus[i].remove_fronts(1);this.foundations[s].add_cards(h)}}apply(e){let s;if(e instanceof Ee)this._release_cancel_highlight(),this.stock.hit(e.data.cards),this._refresh_recycle();else if(e instanceof Ie)this.stock.recycle(),this._refresh_recycle();else if(e instanceof ce){let{flip:i}=e.res,{from:h,to:r,i:l}=e.data,p;if(this.dragging){let d=this.dragging.lerp_release();this.tableus[r].add_fronts(d),s=d}else if(this.click_source&&mh(this.click_source)){let{tableu:d,i:g}=this.click_source;this._release_cancel_highlight();let f=this.tableus[d].remove_fronts(g);this.tableus[r].add_fronts(f),p=f}i&&(this.tableus[h].flip_front(i),p&&p.forEach(d=>d.send_front()))}else if(e instanceof pe){let{to:i}=e.data;if(this.dragging){let h=this.dragging.lerp_release();this.tableus[i].add_fronts(h),this.stock.bind_new_front(),s=h}else{this._release_cancel_highlight();let h=this.stock.remove_waste(1);this.tableus[i].add_fronts(h),this.stock.bind_new_front()}}else if(e instanceof X){let{flip:i}=e.res,{from:h,to:r}=e.data;if(this.dragging){let l=this.dragging.lerp_release();this.foundations[r].add_cards(l),s=l}else{this._release_cancel_highlight();let l=this.tableus[h].remove_fronts(1);this.foundations[r].add_cards(l)}i&&this.tableus[h].flip_front(i)}else if(e instanceof H){let{to:i}=e.data;if(this.dragging){let h=this.dragging.lerp_release();this.foundations[i].add_cards(h),s=h}else{this._release_cancel_highlight();let h=this.stock.remove_waste(1);this.foundations[i].add_cards(h)}this.stock.bind_new_front()}else if(e instanceof ke){let{from:i,to:h}=e.data,r=this.dragging.lerp_release();this.tableus[h].add_fronts(r),this.stock.bind_new_front(),s=r}s&&(this.dragging.dispose(),this.dragging=void 0,this.drag_source=void 0,s[0].after_ease(()=>{this.cards.shadow_group=void 0})),(e instanceof X||e instanceof H)&&(this.trigger_auto===-1&&$.play("auto_flip"),this.trigger_auto===-3&&($.play("auto_flip"),this.trigger_auto=-1))}apply_pov(e,s){}cant(e,s){e===ke?this._release_cancel_drag():e===pe?this._release_cancel_drag():e===H?this._release_cancel_drag():e===ce?this._release_cancel_drag():e===X?this._release_cancel_drag():e===H?this._release_cancel_drag():console.log("cant",e)}cant_undo(){}request_undo(){this.back_res.undo()}request_new_game(){this.back_res.new_game()}_update(){if(this.trigger_auto===-1)this.trigger_auto=E.thirds;else if(this.trigger_auto>0)this.trigger_auto=$t(this.trigger_auto,0,b.delta);else if(this.trigger_auto===0){this.trigger_auto=-2;let e=H.auto_can(this.pov);if(e)this.cmd(H,e),this.trigger_auto=-3;else for(let s=0;s<7;s++){let i=X.auto_can(this.pov,{tableu:s});if(i){this.cmd(X,i),this.trigger_auto=-3;break}}}}}const vh=async(t,a,e,s)=>{let i=Je,h=await i.get_pov();return{get game_pov(){return h},cmd(r,l){r.can(h.game,l)?(h.apply(r,l),t.apply_pov(r,l),i.apply(r,l).then(p=>{p?(t.apply(p),h.finalize_apply_pov(p),i.get_pov().then(d=>a(d.score)),i.get_pov().then(d=>{d.game.is_finished&&s(d.game.settings,d.score)})):t.cant(r,l)})):t.cant(r,l)},undo(){h.can_undo?(h.undo_pov(),i.undo().then(r=>{r?(h.undo(r),t.undo(r),i.get_pov().then(l=>a(l.score))):t.cant_undo()})):t.cant_undo()},async new_game(){i.get_pov().then(r=>{let l=r.score;l>0&&(r.game.is_finished||mt.add_result(He.from_loss(r.game.settings,l)))}),Je=new nt,i=Je,h=await Je.get_pov(),t.new_game(),i.get_pov().then(r=>a(r.score)),i.get_pov().then(r=>e(r.game.settings))}}},ct=class ct{constructor(){o(this,"game");let a=ta.make(De.general_settings,bh(Ga.deck));this.game=Ya.make(a)}async get_pov(){return this.game.pov.clone}async apply(a,e){return await this.game.apply(a,e)}async undo(){return await this.game.undo()}};o(ct,"resume",()=>new ct);let nt=ct,Je=new nt;function bh(t){for(var a=t.length-1;a>0;a--){var e=Math.floor(Math.random()*(a+1)),s=t[a];t[a]=t[e],t[e]=s}return t}let Eh=[...Array(50).keys()].map(()=>N().mul(L.scale(.8)));class Th extends w{constructor(){super(...arguments);o(this,"_timer");o(this,"_cards",[]);o(this,"end_on_final_ease")}get data(){return this._data}set cards(e){this._cards=e,e.length>0&&(this._timer=E.seconds*.5)}_update(){if(this.end_on_final_ease&&this._cards.every(e=>!e.easing)&&(this.end_on_final_ease=void 0,this.data.on_end()),b.on_interval(E.three)&&this._timer)if(this._timer-=b.delta,this._timer<0)this._timer=void 0,this.end_on_final_ease=!0,this._cards.forEach((e,s)=>{e.ease_position(n.make(L.x/2,L.y*.8),E.half+E.half*(s/this._cards.length))});else{let e=Qi(Eh),s=va(),i=n.max(n.min(e.add(s.scale(100)),L),n.zero);for(let h=0;h<3;h++)this._cards.filter(r=>!r.easing).sort((r,l)=>r.position.distance(e)-l.position.distance(e)).slice(0,2+qa(2)).forEach((r,l)=>{r.ease_position(i.add(va().scale(l*5)),E.half+ue()*3*E.sixth)})}this._cards.forEach(e=>e.update())}_draw(e){this._cards.forEach(s=>s.draw(e))}}function Ta(t,a=ue){let e,s,i;for(s=t.length;s;)e=a()*s--|0,i=t[s],t[s]=t[e],t[e]=i;return t}function*Ah(t){let a=t.length,e=1;for(;e0;){e=Math.floor(e/3);for(let s=1;s<=e;s++)yield*Mh(t,s,e)}}function*Mh(t,a,e){let s=t.length;for(let i=a+e;i=e&&t[h]{let e=t/(a-1)*Math.PI;e=Li(e/Math.PI,-Math.PI*.2,Math.PI*.2)-Math.PI*.5;let s=L.scale(1/2).sub(n.up.scale(1200)),i=s.add(n.from_angle(e,1400)),h=i.sub(s).normal.angle+Math.PI/2;return[i,h]};class Sh extends w{constructor(){super(...arguments);o(this,"_cards",[]);o(this,"layer");o(this,"_sort_shot");o(this,"flip_i");o(this,"final");o(this,"end_on_final_ease")}get data(){return this._data}set cards(e){this._cards=e,e.length>0&&this._begin_lay()}_begin_lay(){Ta(this._cards),this.layer=[0,Ta(this._cards.map((e,s)=>s))]}_begin_sort(){let e=this._cards.map(l=>l.card?ah(l.card):-1);this._sort_shot=[];let s=Ah(e),i=Math.floor(e.length/3),h=0,r=this._cards.slice(0);for(let l of s){let[p,d]=l,g=r[p];r[p]=r[d],r[d]=g,h++>3&&h%i===0&&this._sort_shot.unshift(r.slice(0))}this._sort_shot.unshift(r)}_begin_flip(){this.flip_i=0}_update(){if(this.layer){let[e,s]=this.layer;for(let i=0;i<1;i++){if(e>=s.length){this._cards.every(h=>!h.easing)&&(this.layer=void 0,this._begin_sort());break}if(b.on_interval(E.three)){let[h,r]=Ut(e,this._cards.length);this._cards[e].ease_position(h),this._cards[e].ease_rotation(r),e++}}this.layer&&(this.layer[0]=e)}if(this._sort_shot){if(this._sort_shot.length===0)this._sort_shot=void 0,this._begin_flip();else if(b.on_interval(E.sixth)){let e=this._sort_shot.pop();this._cards.forEach((s,i)=>{let h=e.findIndex(r=>r===s);if(i!==h){let[r,l]=Ut(h,this._cards.length);this._cards[i].ease_position(r),this._cards[i].ease_rotation(l)}}),this._cards=e}}this.flip_i!==void 0&&b.on_interval(E.three)&&(this._cards[this.flip_i].flip_back(),this.flip_i++,this.flip_i>=this._cards.length&&(this.flip_i=void 0,this.final=!0)),this.final&&(this.final=void 0,this.end_on_final_ease=!0,this._cards.forEach(e=>{let[s,i]=Ut(2,5);e.ease_position(s),e.ease_rotation(i)})),this.end_on_final_ease&&this._cards.every(e=>!e.easing)&&(this.end_on_final_ease=void 0,this.data.on_layout()),this._cards.forEach(e=>e.update())}_draw(e){this._cards.forEach(s=>s.draw(e))}}class zh extends w{constructor(){super(...arguments);o(this,"_cards");o(this,"shuffler");o(this,"laydeck")}get data(){return this._data}get cards(){return this._cards}set cards(e){this._cards=e}_init(){let e=this;this.laydeck=this.make(Sh,n.make(0,0),{on_layout(){e.laydeck.cards=[],e.begin_shuffle()}}),this.shuffler=this.make(Th,n.make(0,0),{on_end(){e.shuffler.cards=[],e.data.on_shuffle()}})}begin_laydeck(){this.laydeck.cards=this._cards}begin_shuffle(){this.shuffler.cards=this._cards}}class Fh extends w{constructor(){super(...arguments);o(this,"_score");o(this,"score_text");o(this,"score_text_shadow")}set score(e){this._score=e,this.score_text.text=`${e}`,this.score_text_shadow.text=`${e}`}get score(){return this._score}_init(){this._score=0,this.make(T,n.make(0,25),{key:"score",width:80,height:100}),this.score_text_shadow=this.make(T,n.make(100,6),{no_trans:!0,key:`${this.score}`,width:180,height:100,color:y.black}),this.score_text=this.make(T,n.make(100,0),{no_trans:!0,key:`${this.score}`,width:180,height:100})}}class Rh extends w{get data(){return this._data}_init(){[N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L),N().mul(L)].forEach(e=>{let s=this.make(R,e,{name:"swiggle"});s.origin=n.make(600,400),s.scale=n.one.scale(.5+N().x),N().y<.5&&s.play("small"),s.rotation=N().y*Math.PI});let a=this;this.make(D,n.zero,{rect:x.make(0,0,1920,1080),on_hover(){return!0},on_drag(){return!0},on_click(){return a.data.on_close(),!0}})}}class Ch extends w{constructor(){super(...arguments);o(this,"cards");o(this,"limit")}set settings(e){this.cards.text=e.cards,this.limit.text=e.limit}_init(){this.make(T,n.make(0,0),{no_trans:!0,key:"Solitaire",width:350,height:64,color:y.white}),this.cards=this.make(T,n.make(350,5),{key:"one_pass",width:350,height:40,color:y.white}),this.limit=this.make(T,n.make(550,5),{key:"no_limit",width:350,height:40,color:y.white})}}class Uh extends w{constructor(){super(...arguments);o(this,"ax",0);o(this,"ay",0);o(this,"vx",0);o(this,"vy",0)}get data(){return this._data}_init(){let e=Math.random()<.3?"2":"",s=this.make(R,n.make(0,0),{name:"confetti"+e});s.play_o("idle",{loop:!0});let i=.5+Math.random()*.8;s.scale=n.make(i,i),s.rotation=Math.PI*Math.random(),this.vx=100+Math.random()*100,this.vy=-100+Math.random()*100,this.vx*=this.data.sign,this.ax=this.vx*10,this.ay=this.vy*10}_update(){this.position.x+=this.vx*b.delta,this.position.y+=this.vy*b.delta,this.position.x+=this.ax*b.delta,this.position.y+=this.ay*b.delta,this.ax=$t(this.ax,0,b.delta*1e3),this.ay=$t(this.ay,0,b.delta*1e3),this.position.x>2e3&&this.dispose()}}class Aa extends w{constructor(){super(...arguments);o(this,"life",0)}get data(){return this._data}_init(){if(this.pop_confetti(),this.data.sign<0){let e=this.make(R,n.make(0,700),{name:"confbar"});this.tween([Math.PI,0,Math.PI*.3,Math.PI*.16,0],s=>e.rotation=s,[E.half,E.lengths,E.thirds,E.thirds])}else{let e=this.make(R,n.make(1920,700),{name:"confbar"});e.scale=n.make(-1,1),this.tween([-Math.PI,0,-Math.PI*.3,-Math.PI*.16,0],s=>e.rotation=s,[E.half,E.lengths,E.thirds,E.thirds])}}_update(){this.life<6&&b.on_interval(E.seconds*2)&&(this.pop_confetti(),this.life++)}pop_confetti(){for(let e=0;e<6;e++)this.make(Uh,n.make(this.data.sign>0?-500+e*100:1920-e*100,1080-e*300*Math.random()),{sign:this.data.sign})}}class Ma extends w{pop(){$.play("Win"),this.make(Aa,n.make(0,0),{sign:1}),this.make(Aa,n.make(0,0),{sign:-1})}}class Oh extends w{get data(){return this._data}_init(){let a=1200,e=300;this.make(Ke,n.make(1920/2-a/2,520),{name:"panel_bg_nine_slice",w:a,h:e}),this.make(T,n.make(1920/2,590),{key:"congratz",width:450,height:100,color:y.white,center:!0}),this.make(T,n.make(1920/2,700),{key:`you_finished_with_score%${this.data.score}%`,width:650,height:60,color:y.white,center:!0})}}class it extends w{constructor(){super(...arguments);o(this,"hamburger");o(this,"sidebar");o(this,"overlay");o(this,"over_confetties",[])}set sidebar_open(e){this.sidebar.open=e,this.overlay.visible=e,this.hamburger.open=e}_init(){let e;this.make(Vh,n.zero,void 0),this.over_confetties.push(this.make(Ma,n.make(0,0),{}));let s=this.make(kh,n.make(0,0),{});this.over_confetties.push(this.make(Ma,n.make(0,0),{})),this.make(Ji,n.make(160,1e3),{text:"undo",on_click(){s.request_undo()}});let i=this.make(Ch,n.make(640,16),{}),h=this.make(Fh,n.make(16,860),{});const r=u=>{h.score=u};let l;vh(s,r,u=>{i.settings=u,l&&(l.dispose(),l=void 0),$.play("new_game")},(u,k)=>{this.game_over_confetti_pop(),l=this.make(Oh,n.make(0,0),{score:k}),mt.add_result(He.from_win(u,k))}).then(u=>{s.back_res=u,s._collect_pov(),$.music("main"),i.settings=u.game_pov.game.settings});let g=this,f=this.make(Rh,n.zero,{on_close(){g.sidebar_open=!1,g.hamburger.open=!1}}),m=this.make(Nh,n.make(2,2),{on_open:u=>{g.sidebar_open=u}});e=this.make(Dh,n.make(-600,180),{on_new_game(){s.request_new_game(),g.sidebar_open=!1}}),this.sidebar=e,this.overlay=f,this.hamburger=m,this.sidebar_open=!1}game_over_confetti_pop(){this.over_confetties.forEach(e=>e.pop())}}class Dh extends w{constructor(){super(...arguments);o(this,"_t_x");o(this,"_open")}get data(){return this._data}set open(e){this._open=e,this._t_x&&this.cancel(this._t_x),e?this._t_x=this.tween([this.position.x,0],s=>{this.position.x=s},E.sixth,0,()=>{this._t_x=void 0}):this._t_x=this.tween([this.position.x,-600],s=>{this.position.x=s},E.sixth,0,()=>{this._t_x=void 0})}_init(){this._open=!1;let e=this,s=this.make(R,n.make(0,-100),{name:"side_menu_bg"});s.scale=n.make(1.4,1.4);let i=20,h=60,r=160;this.make(Ce,n.make(i,h),{text:"main_menu",on_click(){q.next(Fe)}}),this.make(Ce,n.make(i,h+r),{text:"new_game",on_click(){e.data.on_new_game()}}),this.make(Ce,n.make(i,h+r*2),{text:"settings",on_click(){q.next(ls,n.zero,{selected_index:1,on_back:it})}}),this.make(Ce,n.make(i,h+r*3),{text:"how_to_play",on_click(){q.next(ns,n.zero,{selected_index:0,on_back:it})}}),this.make(Ce,n.make(i,h+r*4),{text:"about",on_click(){q.next(rs,n.zero,{on_back:it})}})}}class Ce extends w{constructor(){super(...arguments);o(this,"_t_color");o(this,"_i_color");o(this,"bg");o(this,"fg")}get data(){return this._data}get i_color(){return this._i_color}set i_color(e){this._i_color=e,this.bg.color=y.lerp(y.white,y.hex(2106417),this._i_color),this.fg.color=y.lerp(y.white,y.hex(2106417),1-this._i_color)}set hover(e){this._t_color&&this.cancel(this._t_color),e?this._t_color=this.tween([this.i_color,0],s=>{this.i_color=s},E.sixth,0,()=>{this._t_color=void 0}):this._t_color=this.tween([this.i_color,1],s=>{this.i_color=s},E.sixth,0,()=>{this._t_color=void 0})}_init(){this._i_color=0,this.bg=this.make(j,n.make(-20,-40),{w:412,h:120,color:y.hex(2106417)}),this.fg=this.make(T,n.make(0,0),{key:this.data.text,width:350,height:100,color:y.white});let e=360,s=120,i=this;this.make(D,n.make(-20,-40),{rect:x.make(0,0,e,s),on_hover(){i.hover=!0},on_hover_end(){i.hover=!1},on_click(){return i.data.on_click(),!0}})}}class Nh extends w{constructor(){super(...arguments);o(this,"_open");o(this,"anim")}get data(){return this._data}set open(e){this._open=e,this._open?this.anim.play("open"):this.anim.play("idle")}_init(){this._open=!1;let e=this.make(R,n.make(0,0),{name:"hmg_bg"});this.anim=e;let s=200,i=100,h=this;this.make(D,n.make(20,20),{rect:x.make(0,0,s,i),on_hover(){e.play(h._open?"open_hover":"hover")},on_hover_end(){e.play(h._open?"open":"idle")},on_click(){return h.open=!h._open,h.data.on_open(h._open),!0}})}}const Ph=`en=english how_to_play=how to play statistics=statistics settings=settings @@ -401,5 +401,5 @@ Eğlenceli bir şekilde zaman geçirmek için 3 solitaire oyunu. [Solitaire]"htt `;let is={en:$h,tr:Bh},hs={en:Ph,tr:Lh,fr:Ih};const Ne=Object.keys(hs),jh=Object.keys(is);let Pe={},Ht={};Ne.forEach(t=>Pe[t]=Hh(hs[t]));jh.forEach(t=>Ht[t]=Xh(is[t]));function Hh(t){let a={};return t.trim().split(` `).map(e=>{let[s,i]=e.split("=");a[s]=i}),a}function Xh(t){let a={},e,s="";return t.split(` `).forEach(i=>{let h=i.match(/^# (.*)/);h?(e&&(a[e]=s,s=""),e=h[1]):s+=i+` -`}),a[e]=s,a}const fe=class fe{constructor(){o(this,"_language",fe.default_language);o(this,"hooks",[])}get default_language(){return fe.default_language}get language(){return this._language}set language(a){this._language=a,this.hooks.forEach(e=>e())}get default_trans2_map(){return Ht[fe.default_language]}get trans2_map(){return Ht[this.language]}get default_trans_map(){return Pe[fe.default_language]}get trans_map(){return Pe[this.language]}lang_key(a){return Pe[a][a]}key(a,e){let s=a.match(/([^%]*)%([^%]*)%$/);if(s!==null){let[i,h,r]=s;return this.trans_map_with_key(h,e).replace("%d",r)}else return this.trans_map_with_key(a,e)}trans_map_with_key(a,e){return e?Pe[e][a]||this.default_trans_map[a]:this.trans_map[a]||this.default_trans_map[a]}key2(a){var e;return((e=this.trans2_map)==null?void 0:e[a])||this.default_trans2_map[a]}register(a){return this.hooks.push(a),()=>{this.hooks.splice(this.hooks.indexOf(a),1)}}};o(fe,"default_language","en");let Xt=fe;const te=new Xt;class B extends w{constructor(){super(...arguments);o(this,"_color")}get data(){return this._data}set color(e){this._color=e}get color(){return this._color}set height(e){this.data.h=e}_init(){this.color=this.data.color??y.white}_draw(e){e.rect(x.make(this.position.x,this.position.y,this.data.w,this.data.h),this.color)}}class Vh extends w{_init(){this.make(B,n.make(0,0),{w:S.width,h:S.height,color:y.hex(2236962)})}_update(){b.on_interval(E.seconds*3)}}class D extends w{constructor(){super(...arguments);o(this,"_scaled_rect")}get data(){return this._data}get width(){return this._scaled_rect.w}get height(){return this._scaled_rect.h}get _rect(){return this.data.abs?x.make(this.position.x,this.position.y,this.width,this.height):this._scaled_rect}get rect(){let{p_scissor:e}=this;return e?this._rect.overlaps_rect(e):this._rect}_init(){this._scaled_rect=this.data.rect;let e=!1,s=!1,i=this;this.unbindable_input({on_click_begin(h,r){var g,f;if(r||!i.p_visible)return!1;let l=h.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_click_begin)==null?void 0:f.call(g))??!1:!1},on_drag(h,r){var l,p,d,g;if(h._right||!i.p_visible)return!1;if(e){let f=h.m.mul(S.v_screen);return((p=(l=i.data).on_drag)==null?void 0:p.call(l,f))??!1}if(h.m&&(!r||!r.m)){let f=h.e.mul(S.v_screen),m=x.make(f.x-4,f.y-4,8,8);return i.rect.overlaps(m)?(e=!0,((g=(d=i.data).on_drag_begin)==null?void 0:g.call(d,f))??!1):!1}return!1},on_up(h,r,l){var d,g,f,m,u,k;if(r||!i.p_visible)return!1;let p=h.mul(S.v_screen);if(e&&(e=!1,(g=(d=i.data).on_drag_end)==null||g.call(d,p)),(m=(f=i.data).on_up)==null||m.call(f,h,r),l){let z=l.mul(S.v_screen),P=x.make(z.x-4,z.y-4,8,8);i.rect.overlaps(P)&&((k=(u=i.data).on_drop)==null||k.call(u,l))}return!1},on_hover(h){var d,g,f,m;if(!i.data.on_hover||!i.p_visible)return!1;let r=h.mul(S.v_screen),l=x.make(r.x-4,r.y-4,8,8);if(i.rect.overlaps(l)){if(!s)return s=!0,((g=(d=i.data).on_hover)==null?void 0:g.call(d))??!1}else s&&(s=!1,(m=(f=i.data).on_hover_end)==null||m.call(f));return s},on_hover_clear(){var h,r;return i.data.on_hover_end?s?(s=!1,(r=(h=i.data).on_hover_end)==null?void 0:r.call(h)):(i.p_visible,!1):!1},on_click(h,r){var g,f;if(!i.p_visible)return!1;let l=h.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_click)==null?void 0:f.call(g))??!1:!1},on_wheel(h,r){var g,f;if(!i.p_visible)return!1;let l=r.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_wheel)==null?void 0:f.call(g,h))??!1:!1}})}_draw(){de.push_matrix(v.create_translation(this.position)),this.g_position=n.transform(n.zero,de.m_matrix),this._scaled_rect=x.transform(this.data.rect,de.m_matrix),this.data.debug&&de.rect(x.make(0,0,this.width,this.height),y.hex(65280)),de.pop_matrix()}}class rs extends w{get data(){return this._data}_init(){this.make(B,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let a=this;this.make(vt,n.zero,{key:"about",on_back(){q.next(a.data.on_back??Fe)}});let e=1880,s=940;this.make(Ke,n.make(20,120),{name:"panel_bg_nine_slice",w:e,h:s});let i=this._make(Ae,n.make(0,0),{width:1880-100,content:te.key2("about")});this.make(G,n.make(60,160),{w:e-100,h:s-80,content:i})}}const pt=class pt extends w{constructor(){super(...arguments);o(this,"height")}get data(){return this._data}_init(){let e=60,s=this._make(re,n.zero,{size:e,text:" "}),i=s.width,h=s.height,r=0,l=0;this.data.content.trim().split(` -`).forEach(p=>{pt.parse(p).forEach(d=>{let g;d.link?g=this.make(qh,n.zero,{size:e,text:d.text,color:Bi,on_click(){window.open(d.link,"_blank")}}):g=this.make(re,n.zero,{size:e,text:d.text}),r+g.width>this.data.width&&(r=0,l+=g.height),g.position=n.make(r,l),r+=g.width+i}),r=0,l+=h}),this.height=l+h}};o(pt,"parse",e=>{let s=/\[([^\]]*)\]\"([^\"]*)\"/g,i=0,h=[],r;for(;(r=s.exec(e))!==null;){let[l,p,d]=r,g=r.index,f=g+l.length;g>i&&e.slice(i,g).split(" ").filter(m=>!!m).forEach(m=>h.push({text:m})),h.push({text:p,link:d}),i=f}return i!!l).forEach(l=>h.push({text:l})),h});let Ae=pt;class aa extends w{constructor(){super(...arguments);o(this,"_selected_index")}get data(){return this._data}on_click(e){this.selected_index=this.data.tabs.indexOf(e)}get selected_index(){return this._selected_index}set selected_index(e){this._selected_index=e,this.data.tabs.forEach((s,i)=>s.set_active(e===i)),this.data.on_selected_index(e)}_init(){this._selected_index=this.data.selected_index,this.data.tabs.forEach((i,h)=>i.set_active(this._selected_index===h));let e=this.data.tabs.length===4?.63:1,s=this.data.tabs.reduce((i,h)=>i+h.width*e,0);this.make(B,n.make(10,130),{w:s,h:10,color:y.hex(1052737)}),this.data.tabs.forEach(i=>i.parent=this),this.data.tabs.forEach(i=>{this.data.tabs.length===4&&(i.scale=n.one.scale(.6),i.position.y+=50)})}_update(){this.data.tabs.forEach(e=>e.update())}_draw(e){e.push_matrix(v.create_translation(this.position)),this._draw_children(e),this.data.tabs.forEach(s=>s.draw(e)),e.pop_matrix()}_dispose(){this.data.tabs.forEach(e=>e.dispose())}}class T extends w{constructor(){super(...arguments);o(this,"_text");o(this,"_text_view");o(this,"dispose_trans")}get data(){return this._data}set color(e){this._text_view.color=e}get height(){return this._text_view.height}set text(e){this._text=e,this._text_view.text=this.text,this._text_view.size=this.size}get text(){return this.data.no_trans?this._text:te.key(this._text)}get size(){let e=Se.sp_font.width_of(this.text),s=128,i=s*this.data.width/e,h=Se.sp_font.height_of(this.text),r=s*this.data.height/h;return Math.min(i,r)}_init(){let e=this.data.center,s=this.data.color;this._text=this.data.key,this._text_view=this.make(re,n.make(0,0),{size:this.size,text:this.text,center:e,color:s}),this.data.no_trans||(this.dispose_trans=te.register(()=>{this._text_view.text=te.key(this._text),this._text_view.size=this.size}))}_dispose(){var e;(e=this.dispose_trans)==null||e.call(this)}}class re extends w{constructor(){super(...arguments);o(this,"_color");o(this,"_size")}get data(){return this._data}get justify(){return this.data.center?n.make(0,0):n.zero}get color(){return this._color}set color(e){this._color=e}get text(){return this.data.text}set text(e){this.data.text=e}get size(){return this._size}set size(e){this._size=e}get width(){return this.font.width_of(this.text)/this.font.size*this.size}get height(){return this.font.height_of(this.text)/this.font.size*this.size}_init(){this.color=this.data.color??y.white,this._size=this.data.size??128,this.rotation=this.data.rotation??0,this.origin=this.data.center?n.make(this.width/2,0):n.zero}_draw(e){e.push_matrix(v.create_transform(this.position,this.origin,n.one,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),e.str_j(this.font,this.text,n.zero,this.justify,this.size,this.color),e.pop_matrix()}}class qh extends w{constructor(){super(...arguments);o(this,"text_view")}get data(){return this._data}set color(e){this.text_view.color=e}get width(){return this.text_view.width}get height(){return this.text_view.height}_init(){this.text_view=this.make(re,n.zero,this.data);let e=this;this.make(D,n.make(0,-this.text_view.height/3),{rect:x.make(0,0,this.text_view.width,this.text_view.height),on_hover(){e.color=y.red},on_hover_end(){e.color=e.data.color??y.white},on_click(){e.data.on_click()}})}}class Z extends w{constructor(){super(...arguments);o(this,"_active");o(this,"anim")}get data(){return this._data}get width(){return this.data.w}get height(){return 32+64}set_active(e){this._active=e,e?this.anim.play("active"):this.anim.play("idle")}_init(){let e=this.make(R,n.zero,{name:"tab3_bg"});this.anim=e,this.make(T,n.make(this.width/2,this.height/2),{no_trans:this.data.no_trans,width:this.width-80,height:this.height,key:this.data.text,center:!0});let s=this;this.make(D,n.make(32,32),{rect:x.make(0,0,360,90),on_hover(){s._active||e.play("hover")},on_hover_end(){e.play(s._active?"active":"idle")},on_click(){s.parent.on_click(s)}})}}class sa extends w{constructor(){super(...arguments);o(this,"_selected_index")}get data(){return this._data}get selected_index(){return this._selected_index}set selected_index(e){this._selected_index=e,this.data.panels.forEach((s,i)=>s.visible=e===i)}get active_panel(){return this.data.panels[this.selected_index]}_init(){this.selected_index=this.data.selected_index}_update(){this.active_panel.update()}_draw(e){e.push_matrix(v.create_translation(this.position)),this._draw_children(e),this.active_panel.draw(e),e.pop_matrix()}_dispose(){this.data.panels.forEach(e=>e.dispose())}}class G extends w{constructor(){super(...arguments);o(this,"scroll_y");o(this,"scroll_off");o(this,"scroll_edge_off");o(this,"target_scroll_y");o(this,"thumb");o(this,"content_base_position")}get data(){return this._data}get content(){return this.data.content}get width(){return this.data.w}get height(){return this.data.h}_init(){this.data.content.parent=this,this.content_base_position=n.copy(this.data.content.position),this.scroll_y=0,this.scroll_off=0,this.scroll_edge_off=0,this.target_scroll_y=0,this.make(B,n.make(this.data.w-20-8,8),{w:20,h:this.data.h-16,color:y.black});let e=this.height*(this.height/this.content.height);this.thumb=this._make(B,n.make(this.data.w-20-8+4,8+4),{w:20-8,h:e,color:y.white});let s,i=this;this.make(D,n.zero,{rect:x.make(0,0,this.width,this.height),on_drag_begin(h){var r,l;return(l=(r=i.data).on_scroll)==null||l.call(r),s=h,!0},on_drag(h){return i.scroll_off=h.y-s.y,!0},on_up(h,r){if(i.scroll_y+=i.scroll_off,i.scroll_off=0,i.target_scroll_y=i.scroll_y,i.scroll_y>0)i.scroll_edge_off=i.scroll_y,i.scroll_y=0;else{let l=-i.content.height+i.data.h;i.content.height{this.t=e},E.half,0,()=>{this._t=void 0})}get done(){return!this._t}_draw(e){e.push_matrix(v.create_transform(n.make(this.t,S.height/2),n.make(160,90),n.make(13,13),Math.PI*.25)),e.rect(x.make(0,0,320,180),y.hex(65280)),e.pop_matrix(),e.push_matrix(v.create_transform(n.make(this.t-1820,S.height/2),n.make(80,10),n.make(13,13),Math.PI*.25)),e.rect(x.make(0,0,160,10),y.hex(0)),e.pop_matrix()}}class Ze extends w{get data(){return this._data}_init(){let a=this.make(R,n.zero,{name:"main_settings_bg"});this.make(T,n.make(320,86),{key:this.data.text,center:!0,width:400,height:100,color:y.black});let e=this.make(T,n.make(320,86),{key:this.data.text,center:!0,width:400,height:100}),s=e.position.y,i=this;this.make(D,n.make(100,50),{rect:x.make(0,0,440,120),on_hover(){a.play("hover"),i.tween([e.position.y,s-2],h=>{e.position.y=h},E.lengths)},on_hover_end(){a.play("idle"),i.tween([e.position.y,s+2],h=>{e.position.y=h},E.lengths)},on_click(){i.data.on_click()}})}}class Gh extends w{get data(){return this._data}_init(){let a=this.make(R,n.zero,{name:this.data.name}),e=this;this.make(D,n.make(this.data.rect.x,this.data.rect.y),{debug:this.data.debug,rect:x.make(0,0,this.data.rect.w,this.data.rect.h),on_hover(){a.play("hover")},on_hover_end(){a.play("idle")},on_click(){e.data.on_click()}})}}class vt extends w{get data(){return this._data}_init(){let a=this;this.make(Gh,n.zero,{name:"navigation_bg",rect:x.make(30,30,540,100),on_click(){a.data.on_back()}}),this.make(T,n.make(112,54),{key:this.data.key,width:400,height:96})}}class ns extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(B,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"how_to_play",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(20,180),{name:"panel_bg_nine_slice",w:1860,h:860});let s=410,i=[this._make(Z,n.make(2,2),{no_trans:!0,text:"solitaire",w:s}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"fourtimes",w:s}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"octopus",w:s})],h=40,r=780,l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("solitaire")}),p=this._make(G,n.make(20,h),{w:1800,h:r,content:l});l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("fourtimes")});let d=this._make(G,n.make(20,h),{w:1800,h:r,content:l});l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("octopus")});let g=this._make(G,n.make(20,h),{w:1800,h:r,content:l}),f=[p,d,g],m=this.make(sa,n.make(20,180),{w:1860,h:860,panels:f,selected_index:a});this.make(aa,n.make(600,8),{tabs:i,selected_index:a,on_selected_index(u){m.selected_index=u}})}}class Wh extends w{constructor(){super(...arguments);o(this,"box");o(this,"selected_text")}get data(){return this._data}set selected_index(e){this.box.selected_index=e,this.selected_text.text=this.data.items[e]}_init(){let e=this.make(R,n.zero,{name:"dropdown_bg"});this.selected_text=this.make(T,n.make(32,60),{no_trans:this.data.no_trans,key:this.data.items[this.data.selected_index],width:250,height:100});let s=this;this.make(D,n.make(0,0),{abs:!0,rect:x.make(0,0,1920,1080),on_click(){let i=s.box.visible;return s.box.visible=!1,i},on_drag_begin(){return s.box.visible=!1,!1}}),this.make(D,n.make(16,32),{rect:x.make(0,0,480,112),on_hover(){e.play("hover")},on_hover_end(){e.play("idle")},on_click(){return s.box.visible?!1:(s.box.visible=!0,!0)}})}}class os extends w{constructor(){super(...arguments);o(this,"dropdown_list")}get data(){return this._data}set selected_index(e){this.dropdown_list.selected_index=e}_init(){let e=this.make(B,n.make(0,0),{w:500,h:500,color:y.hex(3233172)}),s=this,i=this._make(Yh,n.make(0,0),{no_trans:this.data.no_trans,items:this.data.items,selected_index:this.data.selected_index,on_selected(h){s.data.on_selected(h)}});e.height=Math.min(500,i.height),this.dropdown_list=i,this.make(G,n.make(0,0),{w:500,h:Math.min(500,i.height),content:i})}}class Yh extends w{constructor(){super(...arguments);o(this,"height");o(this,"_selected_index");o(this,"items")}get data(){return this._data}set selected_index(e){this._selected_index=e,this._color_items(),this.data.on_selected(e)}get selected_index(){return this._selected_index}_init(){let e=140,s=0,i=this;this.items=this.data.items.map((h,r)=>{let l=this.make(Qh,n.make(0,s),{no_trans:this.data.no_trans,item:h,on_selected(){i.selected_index=r}});return s+=e,l}),this.height=s+30,this._selected_index=this.data.selected_index}_color_items(){this.items.forEach((e,s)=>{e.selected=this.selected_index===s})}}class Qh extends w{constructor(){super(...arguments);o(this,"bg");o(this,"text")}get data(){return this._data}set selected(e){e?(this.bg.color=y.white,this.text.color=y.hex(3233172)):(this.text.color=y.white,this.bg.color=y.hex(3233172))}_init(){this.bg=this.make(B,n.make(-40,-30),{w:470,h:140,color:y.hex(3233172)}),this.text=this.make(T,n.make(0,0),{no_trans:this.data.no_trans,width:340,height:140,key:this.data.item});let e=this;this.make(D,n.make(-40,-30),{rect:x.make(0,0,470,140),on_click(){return e.data.on_selected(),!0}})}}class Jh extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(280,20),{key:"solitaire_settings",width:820,height:200});let e=220,s=this.make($e,n.make(40,e),{name:"turning_cards",items:["three_cards","one_card"],selected_index:xa.indexOf(De.cards),on_selected(h){De.cards=xa[h]}}),i=this.make($e,n.make(40,e*2),{name:"turning_limit",items:["no_limit","three_passes","one_pass"],selected_index:ua.indexOf(De.limit),on_selected(h){De.limit=ua[h]}});this.make_box(s),this.make_box(i),this.height=e*3+500}make_box(e,s){let i=this.make(os,n.make(e.position.x+e.dropdown.position.x,e.position.y+e.dropdown.position.y+160),{no_trans:s,items:e.data.items,selected_index:e.data.selected_index,on_selected(h){i.visible=!1,e.dropdown.data.on_selected(h),e.dropdown.selected_text.text=e.data.items[h]}});e.dropdown.box=i,i.visible=!1}}class Ot extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(280,20),{key:"general_settings",width:820,height:200});let e=220,s=this.make($e,n.make(40,e*1),{no_trans:!0,name:"language",items:Ne.map(p=>te.lang_key(p)),selected_index:Ne.indexOf(ee.language),on_selected(p){te.language=Ne[p],ee.language=Ne[p]}}),i=["on","off"],h=this.make($e,n.make(40,e*2),{name:"sounds",items:["on","off"],selected_index:ee.sound?0:1,on_selected(p){ee.sound=i[p]==="on"}}),r=["on","off"],l=this.make($e,n.make(40,e*3),{name:"music",items:["on","off"],selected_index:ee.music?0:1,on_selected(p){ee.music=r[p]==="on",ee.music||X.stop_music()}});this.make_box(s,!0),this.make_box(h),this.make_box(l),this.height=e*3+500}make_box(e,s){let i=this.make(os,n.make(e.position.x+e.dropdown.position.x,e.position.y+e.dropdown.position.y+160),{no_trans:s,items:e.data.items,selected_index:e.data.selected_index,on_selected(h){i.visible=!1,e.dropdown.data.on_selected(h),e.dropdown.selected_text.text=e.data.items[h]}});e.dropdown.box=i,i.visible=!1}}class $e extends w{constructor(){super(...arguments);o(this,"dropdown")}get data(){return this._data}_init(){this.make(B,n.make(0,0),{w:1300,h:200,color:y.hex(2106433)}),this.make(T,n.make(50,60),{key:this.data.name,width:420,height:200});let e=this;this.dropdown=this.make(Wh,n.make(720,8),{no_trans:this.data.no_trans,items:this.data.items,selected_index:this.data.selected_index,on_selected(s){e.data.on_selected(s)}})}}class Dt extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(700,0),{key:"overall_statistics",width:820,height:200,center:!0});let e=new Xi(mt.results,new ze([]),new ze([])),s=100;this.make(T,n.make(700,200),{key:`total_games_played%${e.total_played}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*1.2),{key:`games_won%${e.total_wins}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*3),{key:"top5_highscores",width:820,height:200,center:!0}),e.top_5_highscores.forEach((h,r)=>{this.make(T,n.make(200,200+s*4+s*r*1.5+80),{key:`${r+1}.`,width:80,height:100,no_trans:!0}),this.make(T,n.make(700,200+s*4+s*r*1.5+80),{key:`${h.multiplied_score}`,width:80,height:100,no_trans:!0,center:!0}),this.make(B,n.make(200,100+200+s*4+s*r*1.5+80),{w:1e3,h:20,color:y.white})}),this.height=2e3}}class Zh extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(700,0),{key:"solitaire_statistics",width:820,height:200,center:!0});let e=mt.results,s=100;this.make(T,n.make(700,200),{key:`total_games_played%${e.total_played}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*1.2),{key:`games_won%${e.total_wins}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*3),{key:"top5_highscores",width:820,height:200,center:!0}),e.top_5_highscores.forEach((h,r)=>{this.make(T,n.make(200,200+s*4+s*r*1.5+80),{key:`${r+1}.`,width:80,height:100,no_trans:!0}),this.make(T,n.make(700,200+s*4+s*r*1.5+80),{key:`${h.multiplied_score}`,width:80,height:100,no_trans:!0,center:!0}),this.make(B,n.make(200,100+200+s*4+s*r*1.5+80),{w:1e3,h:20,color:y.white})}),this.height=2e3}}class er extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(B,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"statistics",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(220,150),{name:"panel_bg_nine_slice",w:1480,h:910});let s=1e3/4,i=s*1.6,h=[this._make(Z,n.make(2,2),{text:"overall",w:i}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"solitaire",w:i}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"fourtimes",w:i}),this._make(Z,n.make(2+(s+4)*3,2),{no_trans:!0,text:"octopus",w:i})],r;this.make(aa,n.make(600,8),{tabs:h,selected_index:a,on_selected_index(u){r.selected_index=u}});let l=this._make(Dt,n.make(0,0),{}),p=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Zh,n.make(0,0),{});let d=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Dt,n.make(0,0),{});let g=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Dt,n.make(0,0),{});let f=this._make(G,n.make(0,0),{w:1450,h:850,content:l}),m=[p,d,g,f];r=this.make(sa,n.make(220,180),{w:1050,h:850,panels:m,selected_index:a})}}class ls extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(B,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"settings",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(220,150),{name:"panel_bg_nine_slice",w:1480,h:910});let s=1e3/4,i=s*1.6,h=[this._make(Z,n.make(2,2),{text:"general",w:i}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"solitaire",w:i}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"fourtimes",w:i}),this._make(Z,n.make(2+(s+4)*3,2),{no_trans:!0,text:"octopus",w:i})],r;this.make(aa,n.make(600,8),{tabs:h,selected_index:a,on_selected_index(u){r.selected_index=u}});let l=this._make(Ot,n.make(0,0),{}),p=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Jh,n.make(0,0),{});let d=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Ot,n.make(0,0),{});let g=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Ot,n.make(0,0),{});let f=this._make(G,n.make(0,0),{w:1450,h:850,content:l}),m=[p,d,g,f];r=this.make(sa,n.make(220,180),{w:1050,h:850,panels:m,selected_index:a})}}class Fe extends w{_init(){this.make(B,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let a=this.make(R,n.zero,{name:"main_title_bg"});a.scale=n.make(2,2),a=this.make(R,n.make(200,150),{name:"main_bg"});let e=this.make(re,n.make(16,32),{text:"sofo",color:y.hex(2106417)});this.make(re,n.make(16+e.width,32),{text:".demo",color:y.hex(11845300)});let s=200,i=320,h=this.make(R,n.make(s,250),{name:"main_card_bg"});h.play_now("solitaire"),this.make(D,n.make(s+120,350),{rect:x.make(0,0,220,500),on_hover(){h.play("solitaire_hover")},on_hover_end(){h.play("solitaire")},on_click(){q.next(it)}});let r=this.make(re,n.make(s+120+140,350+250),{text:"solitaire",center:!0,size:98});r.rotation=Math.PI/2;let l=this.make(R,n.make(s+i,250),{name:"main_card_bg"});l.play_now("fourtimes"),this.make(D,n.make(s+i+120,350),{rect:x.make(0,0,220,500),on_hover(){l.play("fourtimes_hover")},on_hover_end(){l.play("fourtimes")},on_click(){}});let p=this.make(re,n.make(s+i+120+140,350+250),{text:"fourtimes",center:!0,size:82});p.rotation=Math.PI/2;let d=this.make(R,n.make(s+i*2,250),{name:"main_card_bg"});d.play_now("octopus"),this.make(D,n.make(s+i*2+120,350),{rect:x.make(0,0,220,500),on_hover(){d.play("octopus_hover")},on_hover_end(){d.play("octopus")},on_click(){}});let g=this.make(re,n.make(s+i*2+120+140,350+250),{text:"octopus",center:!0,size:96});g.rotation=Math.PI/2;let f=180,m=200;this.make(Ze,n.make(1300,m),{text:"how_to_play",on_click(){q.next(ns)}}),this.make(Ze,n.make(1300,m+f),{text:"statistics",on_click(){q.next(er)}}),this.make(Ze,n.make(1300,m+f*2),{text:"settings",on_click(){q.next(ls)}}),this.make(Ze,n.make(1300,m+f*3),{text:"about",on_click(){q.next(rs)}})}}class tr extends w{constructor(){super(...arguments);o(this,"theme_target");o(this,"mask_target");o(this,"target");o(this,"target2");o(this,"mask");o(this,"current");o(this,"_next")}next(e,s=n.zero,i={}){this._next||(this._next=this._make(e,s,i),this.mask=this._make(Kh,n.zero,{}))}_init(){this.target2=me.create(S.width,S.height),this.target=me.create(S.width,S.height),this.mask_target=me.create(S.width,S.height),this.theme_target=me.create(S.width,S.height),this.current=this._make(Fe,n.zero,{}),Re.set_matrix(v.create_scale_v(S.v_screen)),zt.set_matrix(v.create_scale_v(S.v_screen))}_update(){var e,s,i;(e=this._next)==null||e.update(),this.current.update(),(s=this.mask)==null||s.update(),(i=this.mask)!=null&&i.done&&(this.current.dispose(),this.mask.dispose(),this.mask=void 0,this.current=this._next,this._next=void 0)}_draw(e){var s;this._next?(this.current.draw(e),e.render(this.target),e.clear(),this._next.draw(e),e.render(this.target2),e.clear(),this.mask_target.clear(y.hex(16711680)),(s=this.mask)==null||s.draw(e),e.render(this.mask_target),e.clear(),Re.texture=this.target.texture(0),Re.texture2=this.target2.texture(0),Re.mask_texture=this.mask_target.texture(0),Re.render(this.theme_target)):(this.current.draw(e),e.render(this.theme_target),e.clear()),zt.texture=this.theme_target.texture(0),zt.render()}}let q;const ge=class ge extends w{_init(){de.default_sampler=ye.make(Le.Linear),this.objects=[],X.load().then(()=>{console.log(X)}),Se.load().then(()=>{te.language=ee.language,q=this.make(tr,n.zero,{})})}_update(){}_draw(){w.next_render_order=0,c.backbuffer.clear(y.black),this._draw_children(de),ht._sort_hooks()}};o(ge,"width",1920),o(ge,"height",1080),o(ge,"v_screen",n.make(ge.width,ge.height));let S=ge;const ar=t=>{let a=new S;c.run({name:"solitaire23",width:1920,height:1080,on_startup(){a.init()},on_update(){ht.update(),a.update()},on_render(){a.draw(de)}}),c.canvas&&t.appendChild(c.canvas),ht.listen(t)};ar(document.getElementById("app")); +`}),a[e]=s,a}const fe=class fe{constructor(){o(this,"_language",fe.default_language);o(this,"hooks",[])}get default_language(){return fe.default_language}get language(){return this._language}set language(a){this._language=a,this.hooks.forEach(e=>e())}get default_trans2_map(){return Ht[fe.default_language]}get trans2_map(){return Ht[this.language]}get default_trans_map(){return Pe[fe.default_language]}get trans_map(){return Pe[this.language]}lang_key(a){return Pe[a][a]}key(a,e){let s=a.match(/([^%]*)%([^%]*)%$/);if(s!==null){let[i,h,r]=s;return this.trans_map_with_key(h,e).replace("%d",r)}else return this.trans_map_with_key(a,e)}trans_map_with_key(a,e){return e?Pe[e][a]||this.default_trans_map[a]:this.trans_map[a]||this.default_trans_map[a]}key2(a){var e;return((e=this.trans2_map)==null?void 0:e[a])||this.default_trans2_map[a]}register(a){return this.hooks.push(a),()=>{this.hooks.splice(this.hooks.indexOf(a),1)}}};o(fe,"default_language","en");let Xt=fe;const te=new Xt;class j extends w{constructor(){super(...arguments);o(this,"_color")}get data(){return this._data}set color(e){this._color=e}get color(){return this._color}set height(e){this.data.h=e}_init(){this.color=this.data.color??y.white}_draw(e){e.rect(x.make(this.position.x,this.position.y,this.data.w,this.data.h),this.color)}}class Vh extends w{_init(){this.make(j,n.make(0,0),{w:S.width,h:S.height,color:y.hex(2236962)})}_update(){b.on_interval(E.seconds*3)}}class D extends w{constructor(){super(...arguments);o(this,"_scaled_rect")}get data(){return this._data}get width(){return this._scaled_rect.w}get height(){return this._scaled_rect.h}get _rect(){return this.data.abs?x.make(this.position.x,this.position.y,this.width,this.height):this._scaled_rect}get rect(){let{p_scissor:e}=this;return e?this._rect.overlaps_rect(e):this._rect}_init(){this._scaled_rect=this.data.rect;let e=!1,s=!1,i=this;this.unbindable_input({on_click_begin(h,r){var g,f;if(r||!i.p_visible)return!1;let l=h.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_click_begin)==null?void 0:f.call(g))??!1:!1},on_drag(h,r){var l,p,d,g;if(h._right||!i.p_visible)return!1;if(e){let f=h.m.mul(S.v_screen);return((p=(l=i.data).on_drag)==null?void 0:p.call(l,f))??!1}if(h.m&&(!r||!r.m)){let f=h.e.mul(S.v_screen),m=x.make(f.x-4,f.y-4,8,8);return i.rect.overlaps(m)?(e=!0,((g=(d=i.data).on_drag_begin)==null?void 0:g.call(d,f))??!1):!1}return!1},on_up(h,r,l){var d,g,f,m,u,k;if(r||!i.p_visible)return!1;let p=h.mul(S.v_screen);if(e&&(e=!1,(g=(d=i.data).on_drag_end)==null||g.call(d,p)),(m=(f=i.data).on_up)==null||m.call(f,h,r),l){let z=l.mul(S.v_screen),P=x.make(z.x-4,z.y-4,8,8);i.rect.overlaps(P)&&((k=(u=i.data).on_drop)==null||k.call(u,l))}return!1},on_hover(h){var d,g,f,m;if(!i.data.on_hover||!i.p_visible)return!1;let r=h.mul(S.v_screen),l=x.make(r.x-4,r.y-4,8,8);if(i.rect.overlaps(l)){if(!s)return s=!0,((g=(d=i.data).on_hover)==null?void 0:g.call(d))??!1}else s&&(s=!1,(m=(f=i.data).on_hover_end)==null||m.call(f));return s},on_hover_clear(){var h,r;return i.data.on_hover_end?s?(s=!1,(r=(h=i.data).on_hover_end)==null?void 0:r.call(h)):(i.p_visible,!1):!1},on_click(h,r){var g,f;if(!i.p_visible)return!1;let l=h.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_click)==null?void 0:f.call(g))??!1:!1},on_wheel(h,r){var g,f;if(!i.p_visible)return!1;let l=r.mul(S.v_screen),p=x.make(l.x-4,l.y-4,8,8);return i.rect.overlaps(p)?((f=(g=i.data).on_wheel)==null?void 0:f.call(g,h))??!1:!1}})}_draw(){de.push_matrix(v.create_translation(this.position)),this.g_position=n.transform(n.zero,de.m_matrix),this._scaled_rect=x.transform(this.data.rect,de.m_matrix),this.data.debug&&de.rect(x.make(0,0,this.width,this.height),y.hex(65280)),de.pop_matrix()}}class rs extends w{get data(){return this._data}_init(){this.make(j,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let a=this;this.make(vt,n.zero,{key:"about",on_back(){q.next(a.data.on_back??Fe)}});let e=1880,s=940;this.make(Ke,n.make(20,120),{name:"panel_bg_nine_slice",w:e,h:s});let i=this._make(Ae,n.make(0,0),{width:1880-100,content:te.key2("about")});this.make(G,n.make(60,160),{w:e-100,h:s-80,content:i})}}const pt=class pt extends w{constructor(){super(...arguments);o(this,"height")}get data(){return this._data}_init(){let e=60,s=this._make(re,n.zero,{size:e,text:" "}),i=s.width,h=s.height,r=0,l=0;this.data.content.trim().split(` +`).forEach(p=>{pt.parse(p).forEach(d=>{let g;d.link?g=this.make(qh,n.zero,{size:e,text:d.text,color:Bi,on_click(){window.open(d.link,"_blank")}}):g=this.make(re,n.zero,{size:e,text:d.text}),r+g.width>this.data.width&&(r=0,l+=g.height),g.position=n.make(r,l),r+=g.width+i}),r=0,l+=h}),this.height=l+h}};o(pt,"parse",e=>{let s=/\[([^\]]*)\]\"([^\"]*)\"/g,i=0,h=[],r;for(;(r=s.exec(e))!==null;){let[l,p,d]=r,g=r.index,f=g+l.length;g>i&&e.slice(i,g).split(" ").filter(m=>!!m).forEach(m=>h.push({text:m})),h.push({text:p,link:d}),i=f}return i!!l).forEach(l=>h.push({text:l})),h});let Ae=pt;class aa extends w{constructor(){super(...arguments);o(this,"_selected_index")}get data(){return this._data}on_click(e){this.selected_index=this.data.tabs.indexOf(e)}get selected_index(){return this._selected_index}set selected_index(e){this._selected_index=e,this.data.tabs.forEach((s,i)=>s.set_active(e===i)),this.data.on_selected_index(e)}_init(){this._selected_index=this.data.selected_index,this.data.tabs.forEach((i,h)=>i.set_active(this._selected_index===h));let e=this.data.tabs.length===4?.63:1,s=this.data.tabs.reduce((i,h)=>i+h.width*e,0);this.make(j,n.make(10,130),{w:s,h:10,color:y.hex(1052737)}),this.data.tabs.forEach(i=>i.parent=this),this.data.tabs.forEach(i=>{this.data.tabs.length===4&&(i.scale=n.one.scale(.6),i.position.y+=50)})}_update(){this.data.tabs.forEach(e=>e.update())}_draw(e){e.push_matrix(v.create_translation(this.position)),this._draw_children(e),this.data.tabs.forEach(s=>s.draw(e)),e.pop_matrix()}_dispose(){this.data.tabs.forEach(e=>e.dispose())}}class T extends w{constructor(){super(...arguments);o(this,"_text");o(this,"_text_view");o(this,"dispose_trans")}get data(){return this._data}set color(e){this._text_view.color=e}get height(){return this._text_view.height}set text(e){this._text=e,this._text_view.text=this.text,this._text_view.size=this.size}get text(){return this.data.no_trans?this._text:te.key(this._text)}get size(){let e=Se.sp_font.width_of(this.text),s=128,i=s*this.data.width/e,h=Se.sp_font.height_of(this.text),r=s*this.data.height/h;return Math.min(i,r)}_init(){let e=this.data.center,s=this.data.color;this._text=this.data.key,this._text_view=this.make(re,n.make(0,0),{size:this.size,text:this.text,center:e,color:s}),this.data.no_trans||(this.dispose_trans=te.register(()=>{this._text_view.text=te.key(this._text),this._text_view.size=this.size}))}_dispose(){var e;(e=this.dispose_trans)==null||e.call(this)}}class re extends w{constructor(){super(...arguments);o(this,"_color");o(this,"_size")}get data(){return this._data}get justify(){return this.data.center?n.make(0,0):n.zero}get color(){return this._color}set color(e){this._color=e}get text(){return this.data.text}set text(e){this.data.text=e}get size(){return this._size}set size(e){this._size=e}get width(){return this.font.width_of(this.text)/this.font.size*this.size}get height(){return this.font.height_of(this.text)/this.font.size*this.size}_init(){this.color=this.data.color??y.white,this._size=this.data.size??128,this.rotation=this.data.rotation??0,this.origin=this.data.center?n.make(this.width/2,0):n.zero}_draw(e){e.push_matrix(v.create_transform(this.position,this.origin,n.one,this.rotation)),this.g_position=n.transform(n.zero,e.m_matrix),e.str_j(this.font,this.text,n.zero,this.justify,this.size,this.color),e.pop_matrix()}}class qh extends w{constructor(){super(...arguments);o(this,"text_view")}get data(){return this._data}set color(e){this.text_view.color=e}get width(){return this.text_view.width}get height(){return this.text_view.height}_init(){this.text_view=this.make(re,n.zero,this.data);let e=this;this.make(D,n.make(0,-this.text_view.height/3),{rect:x.make(0,0,this.text_view.width,this.text_view.height),on_hover(){e.color=y.red},on_hover_end(){e.color=e.data.color??y.white},on_click(){e.data.on_click()}})}}class Z extends w{constructor(){super(...arguments);o(this,"_active");o(this,"anim")}get data(){return this._data}get width(){return this.data.w}get height(){return 32+64}set_active(e){this._active=e,e?this.anim.play("active"):this.anim.play("idle")}_init(){let e=this.make(R,n.zero,{name:"tab3_bg"});this.anim=e,this.make(T,n.make(this.width/2,this.height/2),{no_trans:this.data.no_trans,width:this.width-80,height:this.height,key:this.data.text,center:!0});let s=this;this.make(D,n.make(32,32),{rect:x.make(0,0,360,90),on_hover(){s._active||e.play("hover")},on_hover_end(){e.play(s._active?"active":"idle")},on_click(){s.parent.on_click(s)}})}}class sa extends w{constructor(){super(...arguments);o(this,"_selected_index")}get data(){return this._data}get selected_index(){return this._selected_index}set selected_index(e){this._selected_index=e,this.data.panels.forEach((s,i)=>s.visible=e===i)}get active_panel(){return this.data.panels[this.selected_index]}_init(){this.selected_index=this.data.selected_index}_update(){this.active_panel.update()}_draw(e){e.push_matrix(v.create_translation(this.position)),this._draw_children(e),this.active_panel.draw(e),e.pop_matrix()}_dispose(){this.data.panels.forEach(e=>e.dispose())}}class G extends w{constructor(){super(...arguments);o(this,"scroll_y");o(this,"scroll_off");o(this,"scroll_edge_off");o(this,"target_scroll_y");o(this,"thumb");o(this,"content_base_position")}get data(){return this._data}get content(){return this.data.content}get width(){return this.data.w}get height(){return this.data.h}_init(){this.data.content.parent=this,this.content_base_position=n.copy(this.data.content.position),this.scroll_y=0,this.scroll_off=0,this.scroll_edge_off=0,this.target_scroll_y=0,this.make(j,n.make(this.data.w-20-8,8),{w:20,h:this.data.h-16,color:y.black});let e=this.height*(this.height/this.content.height);this.thumb=this._make(j,n.make(this.data.w-20-8+4,8+4),{w:20-8,h:e,color:y.white});let s,i=this;this.make(D,n.zero,{rect:x.make(0,0,this.width,this.height),on_drag_begin(h){var r,l;return(l=(r=i.data).on_scroll)==null||l.call(r),s=h,!0},on_drag(h){return i.scroll_off=h.y-s.y,!0},on_up(h,r){if(i.scroll_y+=i.scroll_off,i.scroll_off=0,i.target_scroll_y=i.scroll_y,i.scroll_y>0)i.scroll_edge_off=i.scroll_y,i.scroll_y=0;else{let l=-i.content.height+i.data.h;i.content.height{this.t=e},E.half,0,()=>{this._t=void 0})}get done(){return!this._t}_draw(e){e.push_matrix(v.create_transform(n.make(this.t,S.height/2),n.make(160,90),n.make(13,13),Math.PI*.25)),e.rect(x.make(0,0,320,180),y.hex(65280)),e.pop_matrix(),e.push_matrix(v.create_transform(n.make(this.t-1820,S.height/2),n.make(80,10),n.make(13,13),Math.PI*.25)),e.rect(x.make(0,0,160,10),y.hex(0)),e.pop_matrix()}}class Ze extends w{get data(){return this._data}_init(){let a=this.make(R,n.zero,{name:"main_settings_bg"});this.make(T,n.make(320,86),{key:this.data.text,center:!0,width:400,height:100,color:y.black});let e=this.make(T,n.make(320,86),{key:this.data.text,center:!0,width:400,height:100}),s=e.position.y,i=this;this.make(D,n.make(100,50),{rect:x.make(0,0,440,120),on_hover(){a.play("hover"),i.tween([e.position.y,s-2],h=>{e.position.y=h},E.lengths)},on_hover_end(){a.play("idle"),i.tween([e.position.y,s+2],h=>{e.position.y=h},E.lengths)},on_click(){i.data.on_click()}})}}class Gh extends w{get data(){return this._data}_init(){let a=this.make(R,n.zero,{name:this.data.name}),e=this;this.make(D,n.make(this.data.rect.x,this.data.rect.y),{debug:this.data.debug,rect:x.make(0,0,this.data.rect.w,this.data.rect.h),on_hover(){a.play("hover")},on_hover_end(){a.play("idle")},on_click(){e.data.on_click()}})}}class vt extends w{get data(){return this._data}_init(){let a=this;this.make(Gh,n.zero,{name:"navigation_bg",rect:x.make(30,30,540,100),on_click(){a.data.on_back()}}),this.make(T,n.make(112,54),{key:this.data.key,width:400,height:96})}}class ns extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(j,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"how_to_play",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(20,180),{name:"panel_bg_nine_slice",w:1860,h:860});let s=410,i=[this._make(Z,n.make(2,2),{no_trans:!0,text:"solitaire",w:s}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"fourtimes",w:s}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"octopus",w:s})],h=40,r=780,l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("solitaire")}),p=this._make(G,n.make(20,h),{w:1800,h:r,content:l});l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("fourtimes")});let d=this._make(G,n.make(20,h),{w:1800,h:r,content:l});l=this._make(Ae,n.make(0,0),{width:1800-80,content:te.key2("octopus")});let g=this._make(G,n.make(20,h),{w:1800,h:r,content:l}),f=[p,d,g],m=this.make(sa,n.make(20,180),{w:1860,h:860,panels:f,selected_index:a});this.make(aa,n.make(600,8),{tabs:i,selected_index:a,on_selected_index(u){m.selected_index=u}})}}class Wh extends w{constructor(){super(...arguments);o(this,"box");o(this,"selected_text")}get data(){return this._data}set selected_index(e){this.box.selected_index=e,this.selected_text.text=this.data.items[e]}_init(){let e=this.make(R,n.zero,{name:"dropdown_bg"});this.selected_text=this.make(T,n.make(32,60),{no_trans:this.data.no_trans,key:this.data.items[this.data.selected_index],width:250,height:100});let s=this;this.make(D,n.make(0,0),{abs:!0,rect:x.make(0,0,1920,1080),on_click(){let i=s.box.visible;return s.box.visible=!1,i},on_drag_begin(){return s.box.visible=!1,!1}}),this.make(D,n.make(16,32),{rect:x.make(0,0,480,112),on_hover(){e.play("hover")},on_hover_end(){e.play("idle")},on_click(){return s.box.visible?!1:(s.box.visible=!0,!0)}})}}class os extends w{constructor(){super(...arguments);o(this,"dropdown_list")}get data(){return this._data}set selected_index(e){this.dropdown_list.selected_index=e}_init(){let e=this.make(j,n.make(0,0),{w:500,h:500,color:y.hex(3233172)}),s=this,i=this._make(Yh,n.make(0,0),{no_trans:this.data.no_trans,items:this.data.items,selected_index:this.data.selected_index,on_selected(h){s.data.on_selected(h)}});e.height=Math.min(500,i.height),this.dropdown_list=i,this.make(G,n.make(0,0),{w:500,h:Math.min(500,i.height),content:i})}}class Yh extends w{constructor(){super(...arguments);o(this,"height");o(this,"_selected_index");o(this,"items")}get data(){return this._data}set selected_index(e){this._selected_index=e,this._color_items(),this.data.on_selected(e)}get selected_index(){return this._selected_index}_init(){let e=140,s=0,i=this;this.items=this.data.items.map((h,r)=>{let l=this.make(Qh,n.make(0,s),{no_trans:this.data.no_trans,item:h,on_selected(){i.selected_index=r}});return s+=e,l}),this.height=s+30,this._selected_index=this.data.selected_index}_color_items(){this.items.forEach((e,s)=>{e.selected=this.selected_index===s})}}class Qh extends w{constructor(){super(...arguments);o(this,"bg");o(this,"text")}get data(){return this._data}set selected(e){e?(this.bg.color=y.white,this.text.color=y.hex(3233172)):(this.text.color=y.white,this.bg.color=y.hex(3233172))}_init(){this.bg=this.make(j,n.make(-40,-30),{w:470,h:140,color:y.hex(3233172)}),this.text=this.make(T,n.make(0,0),{no_trans:this.data.no_trans,width:340,height:140,key:this.data.item});let e=this;this.make(D,n.make(-40,-30),{rect:x.make(0,0,470,140),on_click(){return e.data.on_selected(),!0}})}}class Jh extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(280,20),{key:"solitaire_settings",width:820,height:200});let e=220,s=this.make($e,n.make(40,e),{name:"turning_cards",items:["three_cards","one_card"],selected_index:xa.indexOf(De.cards),on_selected(h){De.cards=xa[h]}}),i=this.make($e,n.make(40,e*2),{name:"turning_limit",items:["no_limit","three_passes","one_pass"],selected_index:ua.indexOf(De.limit),on_selected(h){De.limit=ua[h]}});this.make_box(s),this.make_box(i),this.height=e*3+500}make_box(e,s){let i=this.make(os,n.make(e.position.x+e.dropdown.position.x,e.position.y+e.dropdown.position.y+160),{no_trans:s,items:e.data.items,selected_index:e.data.selected_index,on_selected(h){i.visible=!1,e.dropdown.data.on_selected(h),e.dropdown.selected_text.text=e.data.items[h]}});e.dropdown.box=i,i.visible=!1}}class Ot extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(280,20),{key:"general_settings",width:820,height:200});let e=220,s=this.make($e,n.make(40,e*1),{no_trans:!0,name:"language",items:Ne.map(p=>te.lang_key(p)),selected_index:Ne.indexOf(ee.language),on_selected(p){te.language=Ne[p],ee.language=Ne[p]}}),i=["on","off"],h=this.make($e,n.make(40,e*2),{name:"sounds",items:["on","off"],selected_index:ee.sound?0:1,on_selected(p){ee.sound=i[p]==="on"}}),r=["on","off"],l=this.make($e,n.make(40,e*3),{name:"music",items:["on","off"],selected_index:ee.music?0:1,on_selected(p){ee.music=r[p]==="on",ee.music||$.stop_music()}});this.make_box(s,!0),this.make_box(h),this.make_box(l),this.height=e*3+500}make_box(e,s){let i=this.make(os,n.make(e.position.x+e.dropdown.position.x,e.position.y+e.dropdown.position.y+160),{no_trans:s,items:e.data.items,selected_index:e.data.selected_index,on_selected(h){i.visible=!1,e.dropdown.data.on_selected(h),e.dropdown.selected_text.text=e.data.items[h]}});e.dropdown.box=i,i.visible=!1}}class $e extends w{constructor(){super(...arguments);o(this,"dropdown")}get data(){return this._data}_init(){this.make(j,n.make(0,0),{w:1300,h:200,color:y.hex(2106433)}),this.make(T,n.make(50,60),{key:this.data.name,width:420,height:200});let e=this;this.dropdown=this.make(Wh,n.make(720,8),{no_trans:this.data.no_trans,items:this.data.items,selected_index:this.data.selected_index,on_selected(s){e.data.on_selected(s)}})}}class Dt extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(700,0),{key:"overall_statistics",width:820,height:200,center:!0});let e=new Xi(mt.results,new ze([]),new ze([])),s=100;this.make(T,n.make(700,200),{key:`total_games_played%${e.total_played}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*1.2),{key:`games_won%${e.total_wins}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*3),{key:"top5_highscores",width:820,height:200,center:!0}),e.top_5_highscores.forEach((h,r)=>{this.make(T,n.make(200,200+s*4+s*r*1.5+80),{key:`${r+1}.`,width:80,height:100,no_trans:!0}),this.make(T,n.make(700,200+s*4+s*r*1.5+80),{key:`${h.multiplied_score}`,width:80,height:100,no_trans:!0,center:!0}),this.make(j,n.make(200,100+200+s*4+s*r*1.5+80),{w:1e3,h:20,color:y.white})}),this.height=2e3}}class Zh extends w{constructor(){super(...arguments);o(this,"height")}_init(){this.make(T,n.make(700,0),{key:"solitaire_statistics",width:820,height:200,center:!0});let e=mt.results,s=100;this.make(T,n.make(700,200),{key:`total_games_played%${e.total_played}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*1.2),{key:`games_won%${e.total_wins}%`,width:820,height:200,center:!0}),this.make(T,n.make(700,200+s*3),{key:"top5_highscores",width:820,height:200,center:!0}),e.top_5_highscores.forEach((h,r)=>{this.make(T,n.make(200,200+s*4+s*r*1.5+80),{key:`${r+1}.`,width:80,height:100,no_trans:!0}),this.make(T,n.make(700,200+s*4+s*r*1.5+80),{key:`${h.multiplied_score}`,width:80,height:100,no_trans:!0,center:!0}),this.make(j,n.make(200,100+200+s*4+s*r*1.5+80),{w:1e3,h:20,color:y.white})}),this.height=2e3}}class er extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(j,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"statistics",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(220,150),{name:"panel_bg_nine_slice",w:1480,h:910});let s=1e3/4,i=s*1.6,h=[this._make(Z,n.make(2,2),{text:"overall",w:i}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"solitaire",w:i}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"fourtimes",w:i}),this._make(Z,n.make(2+(s+4)*3,2),{no_trans:!0,text:"octopus",w:i})],r;this.make(aa,n.make(600,8),{tabs:h,selected_index:a,on_selected_index(u){r.selected_index=u}});let l=this._make(Dt,n.make(0,0),{}),p=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Zh,n.make(0,0),{});let d=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Dt,n.make(0,0),{});let g=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Dt,n.make(0,0),{});let f=this._make(G,n.make(0,0),{w:1450,h:850,content:l}),m=[p,d,g,f];r=this.make(sa,n.make(220,180),{w:1050,h:850,panels:m,selected_index:a})}}class ls extends w{get data(){return this._data}_init(){let a=this.data.selected_index??0;this.make(j,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let e=this;this.make(vt,n.zero,{key:"settings",on_back(){q.next(e.data.on_back??Fe)}}),this.make(Ke,n.make(220,150),{name:"panel_bg_nine_slice",w:1480,h:910});let s=1e3/4,i=s*1.6,h=[this._make(Z,n.make(2,2),{text:"general",w:i}),this._make(Z,n.make(2+s+4,2),{no_trans:!0,text:"solitaire",w:i}),this._make(Z,n.make(2+(s+4)*2,2),{no_trans:!0,text:"fourtimes",w:i}),this._make(Z,n.make(2+(s+4)*3,2),{no_trans:!0,text:"octopus",w:i})],r;this.make(aa,n.make(600,8),{tabs:h,selected_index:a,on_selected_index(u){r.selected_index=u}});let l=this._make(Ot,n.make(0,0),{}),p=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Jh,n.make(0,0),{});let d=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Ot,n.make(0,0),{});let g=this._make(G,n.make(0,0),{w:1450,h:850,content:l});l=this._make(Ot,n.make(0,0),{});let f=this._make(G,n.make(0,0),{w:1450,h:850,content:l}),m=[p,d,g,f];r=this.make(sa,n.make(220,180),{w:1050,h:850,panels:m,selected_index:a})}}class Fe extends w{_init(){this.make(j,n.zero,{w:1920,h:1080,color:y.hex(11845300)});let a=this.make(R,n.zero,{name:"main_title_bg"});a.scale=n.make(2,2),a=this.make(R,n.make(200,150),{name:"main_bg"});let e=this.make(re,n.make(16,32),{text:"sofo",color:y.hex(2106417)});this.make(re,n.make(16+e.width,32),{text:".demo",color:y.hex(11845300)});let s=200,i=320,h=this.make(R,n.make(s,250),{name:"main_card_bg"});h.play_now("solitaire"),this.make(D,n.make(s+120,350),{rect:x.make(0,0,220,500),on_hover(){h.play("solitaire_hover")},on_hover_end(){h.play("solitaire")},on_click(){q.next(it)}});let r=this.make(re,n.make(s+120+140,350+250),{text:"solitaire",center:!0,size:98});r.rotation=Math.PI/2;let l=this.make(R,n.make(s+i,250),{name:"main_card_bg"});l.play_now("fourtimes"),this.make(D,n.make(s+i+120,350),{rect:x.make(0,0,220,500),on_hover(){l.play("fourtimes_hover")},on_hover_end(){l.play("fourtimes")},on_click(){}});let p=this.make(re,n.make(s+i+120+140,350+250),{text:"fourtimes",center:!0,size:82});p.rotation=Math.PI/2;let d=this.make(R,n.make(s+i*2,250),{name:"main_card_bg"});d.play_now("octopus"),this.make(D,n.make(s+i*2+120,350),{rect:x.make(0,0,220,500),on_hover(){d.play("octopus_hover")},on_hover_end(){d.play("octopus")},on_click(){}});let g=this.make(re,n.make(s+i*2+120+140,350+250),{text:"octopus",center:!0,size:96});g.rotation=Math.PI/2;let f=180,m=200;this.make(Ze,n.make(1300,m),{text:"how_to_play",on_click(){q.next(ns)}}),this.make(Ze,n.make(1300,m+f),{text:"statistics",on_click(){q.next(er)}}),this.make(Ze,n.make(1300,m+f*2),{text:"settings",on_click(){q.next(ls)}}),this.make(Ze,n.make(1300,m+f*3),{text:"about",on_click(){q.next(rs)}})}}class tr extends w{constructor(){super(...arguments);o(this,"theme_target");o(this,"mask_target");o(this,"target");o(this,"target2");o(this,"mask");o(this,"current");o(this,"_next")}next(e,s=n.zero,i={}){this._next||(this._next=this._make(e,s,i),this.mask=this._make(Kh,n.zero,{}))}_init(){this.target2=me.create(S.width,S.height),this.target=me.create(S.width,S.height),this.mask_target=me.create(S.width,S.height),this.theme_target=me.create(S.width,S.height),this.current=this._make(Fe,n.zero,{}),Re.set_matrix(v.create_scale_v(S.v_screen)),zt.set_matrix(v.create_scale_v(S.v_screen))}_update(){var e,s,i;(e=this._next)==null||e.update(),this.current.update(),(s=this.mask)==null||s.update(),(i=this.mask)!=null&&i.done&&(this.current.dispose(),this.mask.dispose(),this.mask=void 0,this.current=this._next,this._next=void 0)}_draw(e){var s;this._next?(this.current.draw(e),e.render(this.target),e.clear(),this._next.draw(e),e.render(this.target2),e.clear(),this.mask_target.clear(y.hex(16711680)),(s=this.mask)==null||s.draw(e),e.render(this.mask_target),e.clear(),Re.texture=this.target.texture(0),Re.texture2=this.target2.texture(0),Re.mask_texture=this.mask_target.texture(0),Re.render(this.theme_target)):(this.current.draw(e),e.render(this.theme_target),e.clear()),zt.texture=this.theme_target.texture(0),zt.render()}}let q;const ge=class ge extends w{_init(){de.default_sampler=ye.make(Le.Linear),this.objects=[],$.load().then(()=>{console.log($)}),Se.load().then(()=>{te.language=ee.language,q=this.make(tr,n.zero,{})})}_update(){}_draw(){w.next_render_order=0,c.backbuffer.clear(y.black),this._draw_children(de),ht._sort_hooks()}};o(ge,"width",1920),o(ge,"height",1080),o(ge,"v_screen",n.make(ge.width,ge.height));let S=ge;const ar=t=>{let a=new S;c.run({name:"solitaire23",width:1920,height:1080,on_startup(){a.init()},on_update(){ht.update(),a.update()},on_render(){a.draw(de)}}),c.canvas&&t.appendChild(c.canvas),ht.listen(t)};ar(document.getElementById("app")); diff --git a/audio/new_game.wav b/audio/new_game.wav new file mode 100644 index 0000000..7dc28b6 Binary files /dev/null and b/audio/new_game.wav differ diff --git a/index.html b/index.html index 02cf2cb..cefa69c 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@ } - +