Files
gnommoeditor/dist/glitch/glitch_gallery/assets/index-CwQ-ysLn.js
T

2 lines
11 KiB
JavaScript
Raw Normal View History

2026-04-11 09:24:21 +02:00
import{r as n,j as t}from"./index-CEeZxcxj.js";const ke="_wrapper_h2w9g_1",je="_frame_h2w9g_12",Pe="_frameSucceeded_h2w9g_25",ve="_header_h2w9g_33",$e="_title_h2w9g_37",Te="_statsLine_h2w9g_50",Oe="_boardPanel_h2w9g_58",Ee="_board_h2w9g_58",Re="_trailOverlay_h2w9g_76",Ae="_trailPath_h2w9g_85",Le="_trailHead_h2w9g_94",Me="_cell_h2w9g_99",Ie="_lightCell_h2w9g_105",De="_darkCell_h2w9g_109",He="_knight_h2w9g_113",Ge="_target_h2w9g_130",Be="_readout_h2w9g_138",Ue="_readoutLine_h2w9g_145",Fe="_programPanel_h2w9g_154",Ye="_programTrack_h2w9g_160",Ve="_placeholder_h2w9g_171",Xe="_step_h2w9g_176",Ke="_stepExecuted_h2w9g_187",Ze="_programButtons_h2w9g_192",ze="_controlRow_h2w9g_193",We="_button_h2w9g_199",qe="_buttonPrimary_h2w9g_200",Je="_legend_h2w9g_233",Qe="_promptOverlay_h2w9g_239",et="_promptTitle_h2w9g_250",tt="_promptText_h2w9g_258",rt="_promptOptions_h2w9g_264",st="_promptOption_h2w9g_264",nt="_promptSelected_h2w9g_282",at="_promptHint_h2w9g_287",e={wrapper:ke,frame:je,frameSucceeded:Pe,header:ve,title:$e,statsLine:Te,boardPanel:Oe,board:Ee,trailOverlay:Re,trailPath:Ae,trailHead:Le,cell:Me,lightCell:Ie,darkCell:De,knight:He,target:Ge,readout:Be,readoutLine:Ue,programPanel:Fe,programTrack:Ye,placeholder:Ve,step:Xe,stepExecuted:Ke,programButtons:Ze,controlRow:ze,button:We,buttonPrimary:qe,legend:Je,promptOverlay:Qe,promptTitle:et,promptText:tt,promptOptions:rt,promptOption:st,promptSelected:nt,promptHint:at},b=8,h={x:0,y:b-1},ot=220,ct=64,lt=3,I=100,it=5,dt={up:{dx:0,dy:-1},down:{dx:0,dy:1},left:{dx:-1,dy:0},right:{dx:1,dy:0}},pt={up:"↑",down:"↓",left:"←",right:"→"},de=[{dx:0,dy:1},{dx:1,dy:1},{dx:1,dy:2},{dx:1,dy:3},{dx:2,dy:3},{dx:1,dy:5},{dx:1,dy:6}],X=(s,o,u)=>Math.min(u,Math.max(o,s)),pe=s=>s.x>=0&&s.x<b&&s.y>=0&&s.y<b,ut=(s,o)=>s.x===o.x&&s.y===o.y,se=(s,o)=>o===0?s:se(o,s%o),mt=(s,o)=>{const u=Math.abs(o.x-s.x),d=Math.abs(o.y-s.y);if(u===0&&d===0)return 0;if(u===0||d===0)return u+d;const g=se(u,d);return u/g+d/g},ht=s=>new Promise(o=>{window.setTimeout(o,s)}),ie=s=>s==="Enter"||s==="NumpadEnter"||s===" "||s==="Space"||s==="Spacebar",gt=s=>`${(s.x+.5)*I},${(s.y+.5)*I}`,K=s=>X(s,0,de.length-1),ue=s=>de[K(s)],te=s=>{const o=ue(s);return o.dx+o.dy},re=s=>{const o=ue(s),u=[];for(let g=1;g<b;g+=1){const p={x:h.x+o.dx*g,y:h.y-o.dy*g};if(!pe(p))break;Math.abs(p.x-h.x)+Math.abs(p.y-h.y)>it&&u.push(p)}if(u.length===0)return{x:h.x+o.dx,y:h.y-o.dy};const d=Math.floor(Math.random()*u.length);return u[d]};function _t({config:s,onComplete:o,onProgress:u,theme:d,className:g}){const p=n.useMemo(()=>{const a=s.params.goalCaptures;return typeof a!="number"?lt:X(Math.round(a),1,10)},[s.params.goalCaptures]),[N,ne]=n.useState(0),[w,Z]=n.useState(h),[k,ae]=n.useState(()=>re(0)),[x,z]=n.useState([]),[D,H]=n.useState([h]),[_,j]=n.useState("idle"),[me,v]=n.useState(-1),[y,oe]=n.useState(0),[ce,O]=n.useState(""),[E,G]=n.useState("yes"),[R,B]=n.useState("continue"),[f,he]=n.useState(!1),C=n.useRef(0),U=n.useRef(!1),i=_==="running",m=_==="gameOverPrompt"||_==="successPrompt"||_==="finished",W=te(N),ge=n.useMemo(()=>d?{"--gc-primary":d.primary,"--gc-accent":d.accent,"--gc-bg":d.bg,"--gc-bg-secondary":d.bgSecondary,"--gc-text":d.text,"--gc-text-muted":d.textMuted,"--gc-border":d.border}:{},[d]);n.useEffect(()=>{const a=y/p;u?.(Math.round(X(a*100,0,100)))},[y,p,u]);const F=n.useCallback((a,r,c="")=>{C.current+=1,j("idle"),ne(K(a)),Z(h),ae(re(a)),H([h]),v(-1),oe(r),G("yes"),B("continue"),O(c)},[]),q=n.useCallback(()=>{F(N,0,`Looking for a ${W}-step move set.`)},[N,W,F]),Y=n.useCallback((a=0)=>{const r=K(N+1),c=te(r);F(r,a,`Looking for a ${c}-step move set.`)},[N,F]),J=n.useCallback(()=>{U.current||(U.current=!0,C.current+=1,j("finished"),o({success:!1,error:"Player chose no after game over.",data:{captures:y,goalCaptures:p,configId:s.id,completedAt:new Date().toISOString(),hasEverSucceeded:f}}))},[y,s.id,p,f,o]),L=n.useCallback(()=>{U.current||(U.current=!0,C.current+=1,j("finished"),o({success:!0,score:100,data:{captures:y,goalCaptures:p,configId:s.id,completedAt:new Date().toISOString(),hasEverSucceeded:f}}))},[y,s.id,p,f,o]),A=n.useCall