speakid-build-a-sentence 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Game.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export interface GameProps {
2
2
  logoUrl?: string;
3
3
  showLogo?: boolean;
4
- baseURL?: string;
5
4
  }
6
5
  declare function GameComponent(props?: GameProps): import("react/jsx-runtime").JSX.Element;
7
6
  export default GameComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../src/Game.tsx"],"names":[],"mappings":"AA2DA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iBAAS,aAAa,CAAC,KAAK,GAAE,SAAc,2CAm+B3C;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"Game.d.ts","sourceRoot":"","sources":["../src/Game.tsx"],"names":[],"mappings":"AA4DA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,KAAK,GAAE,SAAc,2CA2mC3C;AAED,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Game.styles.d.ts","sourceRoot":"","sources":["../src/Game.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAoEtC,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CA4MhD,CAAC"}
1
+ {"version":3,"file":"Game.styles.d.ts","sourceRoot":"","sources":["../src/Game.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAoEtC,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAmNhD,CAAC"}
@@ -1,37 +1,37 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),s=require("react"),Ye=`
2
- @keyframes magic-sentence-spin {
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),s=require("react"),ot=`
2
+ @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
5
5
  }
6
6
 
7
- @keyframes magic-sentence-pulse {
7
+ @keyframes pulse {
8
8
  0%, 100% { transform: scale(1); }
9
9
  50% { transform: scale(1.05); }
10
10
  }
11
11
 
12
- @keyframes magic-sentence-shake {
12
+ @keyframes shake {
13
13
  0%, 100% { transform: translateX(0); }
14
14
  25% { transform: translateX(-5px); }
15
15
  75% { transform: translateX(5px); }
16
16
  }
17
17
 
18
- @keyframes magic-sentence-slideIn {
18
+ @keyframes slideIn {
19
19
  from { transform: translateY(-20px); opacity: 0; }
20
20
  to { transform: translateY(0); opacity: 1; }
21
21
  }
22
22
 
23
- @keyframes magic-sentence-bounce {
23
+ @keyframes bounce {
24
24
  0%, 20%, 53%, 80%, 100% { transform: translate3d(0,0,0); }
25
25
  40%, 43% { transform: translate3d(0, -8px, 0); }
26
26
  70% { transform: translate3d(0, -4px, 0); }
27
27
  90% { transform: translate3d(0, -2px, 0); }
28
28
  }
29
29
 
30
- @keyframes magic-sentence-glow {
30
+ @keyframes glow {
31
31
  0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }
32
32
  50% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.8), 0 0 30px rgba(76, 175, 80, 0.6); }
33
33
  }
34
- `;if(typeof document<"u"&&!document.getElementById("magic-sentence-keyframes")){const u=document.createElement("style");u.id="magic-sentence-keyframes",u.innerHTML=Ye,document.head.appendChild(u)}const xe={spin:{animation:"magic-sentence-spin 1.4s linear infinite"},pulse:{animation:"magic-sentence-pulse 0.6s ease-in-out"},shake:{animation:"magic-sentence-shake 0.4s ease-in-out"},slideIn:{animation:"magic-sentence-slideIn 0.3s ease-out"},bounce:{animation:"magic-sentence-bounce 0.6s ease-in-out"},glow:{animation:"magic-sentence-glow 1s ease-in-out infinite"}},p={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center",color:"#1f2937",padding:"24px 16px",boxSizing:"border-box",transform:"translateY(20px)"},gmHeadline1:{fontWeight:700,fontSize:"clamp(28px, 4vw, 40px)",lineHeight:"110%"},gmHeadline2:{fontWeight:600,fontSize:"24px",lineHeight:"120%"},gmBodyM:{fontWeight:400,fontSize:"16px",lineHeight:"140%"},gmBodyS:{fontWeight:400,fontSize:"14px",lineHeight:"140%",color:"#6b7280"},gmButton:{fontFamily:'"Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans"',fontWeight:600,fontSize:"16px",padding:"10px 16px",borderRadius:"12px",border:"1px solid #e5e7eb",background:"#ec4c44",color:"#ffffff",cursor:"pointer",boxShadow:"0 6px 18px rgba(236, 76, 68, .18)",transition:"transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease"},gmGameLayout:{position:"relative",width:"100%",maxWidth:"none",minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmLogoFixed:{position:"absolute",top:"16px",left:"16px",width:"120px",zIndex:30,pointerEvents:"none",background:"transparent",transform:"none",willChange:"auto"},gmLogoImg:{height:"clamp(28px, 5vw, 40px)",width:"auto",background:"transparent",backgroundImage:"url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjQwIiB2aWV3Qm94PSIwIDAgMTAwIDQwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8dGV4dCB4PSI1MCIgeT0iMjUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyMCIgZm9udC13ZWlnaHQ9ImJvbGQiIGZpbGw9IiNlYzRjNDQiIHRleHQtYW5jaG9yPSJtaWRkbGUiPlNQRUFLSUQ8L3RleHQ+Cjwvc3ZnPgo=')",backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased",objectFit:"contain",imageRendering:"auto"},gmReadyWrapper:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"60%",gap:"16px"},gmHourglass:{fontSize:"42px",...xe.spin},...xe},ye=()=>{const[u,a]=s.useState([]),x=s.useCallback((S,z,I)=>{const g=[];S.trim()||g.push({type:"empty",message:"Sentence cannot be empty"}),S.length>41&&g.push({type:"length",message:`Sentence is too long (${S.length}/41 characters)`}),S&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(S)&&g.push({type:"characters",message:"Only Latin characters, numbers, spaces and punctuation are allowed"});const m=I.findIndex((v,H)=>H!==z&&v.toLowerCase().trim()===S.toLowerCase().trim());return m!==-1&&g.push({type:"duplicate",message:`Duplicate sentence (same as sentence ${m+1})`}),a(g),{isValid:g.length===0,errors:g}},[]),E=s.useCallback(S=>{const z=[];return S.forEach((I,g)=>{const C=x(I,g,S);z.push(...C.errors.map(m=>({...m,message:`Sentence ${g+1}: ${m.message}`})))}),{isValid:z.length===0,errors:z}},[x]),_=s.useCallback(()=>{a([])},[]);return{errors:u,validateSentence:x,validateAllSentences:E,clearErrors:_}},be=(u,a,x)=>a&&x?`${u} word "${a}" ${x}`:a?`${u} word "${a}"`:u,Se=(u,a,x=["Enter"," "])=>{x.includes(u.key)&&(u.preventDefault(),a())},P=u=>{const a=document.createElement("div");a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),a.style.position="absolute",a.style.left="-10000px",a.style.width="1px",a.style.height="1px",a.style.overflow="hidden",document.body.appendChild(a),a.textContent=u,setTimeout(()=>{document.body.removeChild(a)},1e3)},Ke=()=>{const u=document.createElement("style");u.id="magic-sentence-reset";const a=document.getElementById("magic-sentence-reset");a&&a.remove(),u.textContent=`
34
+ `;if(typeof document<"u"&&!document.getElementById("game-keyframes")){const w=document.createElement("style");w.id="game-keyframes",w.innerHTML=ot,document.head.appendChild(w)}const ve={spin:{animation:"spin 1.4s linear infinite"},pulse:{animation:"pulse 0.6s ease-in-out"},shake:{animation:"shake 0.4s ease-in-out"},slideIn:{animation:"slideIn 0.3s ease-out"},bounce:{animation:"bounce 0.6s ease-in-out"},glow:{animation:"glow 1s ease-in-out infinite"}},p={gmCenterScreen:{position:"relative",zIndex:1,minHeight:"100%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center",color:"#1f2937",padding:"24px 16px",boxSizing:"border-box",transform:"translateY(20px)"},gmHeadline1:{fontWeight:700,fontSize:"clamp(28px, 4vw, 40px)",lineHeight:"110%"},gmHeadline2:{fontWeight:600,fontSize:"24px",lineHeight:"120%"},gmBodyM:{fontWeight:400,fontSize:"16px",lineHeight:"140%"},gmBodyS:{fontWeight:400,fontSize:"14px",lineHeight:"140%",color:"#6b7280"},gmButton:{fontFamily:'"Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans"',fontWeight:600,fontSize:"16px",padding:"10px 16px",borderRadius:"12px",border:"1px solid #e5e7eb",background:"#ec4c44",color:"#ffffff",cursor:"pointer",boxShadow:"0 6px 18px rgba(236, 76, 68, .18)",transition:"transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease"},gmGameLayout:{position:"relative",width:"100%",maxWidth:"none",minHeight:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",color:"#1f2937",padding:"16px 8px",margin:"0 auto"},gmInput:{padding:"6px 10px",borderRadius:"6px",border:"1px solid #ccc",fontSize:"16px",fontFamily:'"Geist", system-ui',width:"160px"},gmLogoFixed:{position:"absolute",top:"16px",left:"16px",width:"auto",zIndex:10,pointerEvents:"none",background:"transparent",transform:"none",willChange:"auto"},gmLogoImg:{height:"28px",width:"auto",background:"transparent",objectFit:"contain",imageRendering:"auto",transform:"translateZ(0)",backfaceVisibility:"hidden",WebkitFontSmoothing:"antialiased",display:"block"},gmReadyWrapper:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"60%",gap:"16px"},gmHourglass:{fontSize:"42px",...ve.spin},...ve},He=()=>{const[w,d]=s.useState([]),k=s.useCallback((T,j,f)=>{const y=[];T.trim()||y.push({type:"empty",message:"Sentence cannot be empty"}),T.length>41&&y.push({type:"length",message:`Sentence is too long (${T.length}/41 characters)`}),T&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(T)&&y.push({type:"characters",message:"Only Latin characters, numbers, spaces and punctuation are allowed"});const W=f.findIndex((D,U)=>U!==j&&D.toLowerCase().trim()===T.toLowerCase().trim());return W!==-1&&y.push({type:"duplicate",message:`Duplicate sentence (same as sentence ${W+1})`}),d(y),{isValid:y.length===0,errors:y}},[]),re=s.useCallback(T=>{const j=[];return T.forEach((f,y)=>{const x=k(f,y,T);j.push(...x.errors.map(W=>({...W,message:`Sentence ${y+1}: ${W.message}`})))}),{isValid:j.length===0,errors:j}},[k]),oe=s.useCallback(()=>{d([])},[]);return{errors:w,validateSentence:k,validateAllSentences:re,clearErrors:oe}},Ce=(w,d,k)=>d&&k?`${w} word "${d}" ${k}`:d?`${w} word "${d}"`:w,Ie=(w,d,k=["Enter"," "])=>{k.includes(w.key)&&(w.preventDefault(),d())},z=w=>{const d=document.createElement("div");d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true"),d.style.position="absolute",d.style.left="-10000px",d.style.width="1px",d.style.height="1px",d.style.overflow="hidden",document.body.appendChild(d),d.textContent=w,setTimeout(()=>{document.body.removeChild(d)},1e3)},st=()=>{const w=document.createElement("style");w.id="magic-sentence-reset",w.textContent=`
35
35
  #magic-sentence-root, #magic-sentence-root * {
36
36
  box-sizing: border-box;
37
37
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
@@ -48,7 +48,7 @@
48
48
  width: 100% !important;
49
49
  height: 100% !important;
50
50
  overflow: hidden !important;
51
- zoom: 1 !important;
51
+ zoom: 1 !important; /* ✅ защита от подзума */
52
52
  }
53
53
  #root {
54
54
  margin: 0 !important;
@@ -57,5 +57,5 @@
57
57
  height: 100% !important;
58
58
  overflow: hidden !important;
59
59
  }
60
- `,document.head.appendChild(u)},_e=u=>[...u].sort(()=>Math.random()-.5);function We(u={}){const{logoUrl:a,showLogo:x=!0,baseURL:E}=u,_=s.useRef(null),{validateAllSentences:S,errors:z}=ye(),I=()=>l||window.innerWidth<768,g=()=>l||window.innerWidth<768||window.innerWidth>=320&&window.innerWidth<=932&&window.innerHeight>=390&&window.innerHeight<=932,C=(e="medium")=>{if(!g())return{padding:"12px 24px",fontSize:"16px",minWidth:"auto"};switch(e){case"small":return{padding:"4px 6px",fontSize:"9px",minWidth:"40px"};case"medium":return{padding:"5px 8px",fontSize:"10px",minWidth:"50px"};case"large":return{padding:"6px 10px",fontSize:"11px",minWidth:"60px"}}};s.useEffect(()=>(Ke(),()=>{document.documentElement.style.overflow="",document.body.style.overflow="";const e=document.getElementById("magic-sentence-reset");e&&e.remove()}),[]);const[m,v]=s.useState("select"),[H,le]=s.useState(null),[ce,ge]=s.useState(null),[k,U]=s.useState([]),[j,pe]=s.useState(0),[ee,ue]=s.useState([]),[W,ne]=s.useState([]),[B,he]=s.useState(20),[X,V]=s.useState(0),[nn,we]=s.useState(null),[M,R]=s.useState(null),[c,q]=s.useState(!1),[te,ve]=s.useState(Number(localStorage.getItem("magicSentenceBest"))||0),J=s.useRef(null),[y,D]=s.useState({list:null,index:null,side:null}),[l,ke]=s.useState(!1),[tn,ie]=s.useState(1),[me,oe]=s.useState(null),[He,Ie]=s.useState(!1),[L,Ce]=s.useState(!1),[A,je]=s.useState(!1),[$,De]=s.useState(!1),[G,Te]=s.useState(!1),[N,Pe]=s.useState(!1),[O,Re]=s.useState(!1),[F,Ee]=s.useState(!1),[Z,ze]=s.useState(!1);s.useEffect(()=>{const e=()=>{const t=window.innerWidth,n=window.innerHeight,i=t<768||t===926&&n===428||t===932&&n===430,r=n<700,w=t===768&&n===1024,f=t===1024&&n===768,d=t===820&&n===1180,h=t===1180&&n===820,Q=t===540&&n===720,b=t===720&&n===540,de=t===1024&&n===1366,Ue=t===1366&&n===1024,Ve=t>=1200&&n>=600&&!i;if(Ie(Ve),Ce(w),je(f),De(d),Te(h),Pe(Q),Re(b),Ee(de),ze(Ue),ke(i),i)oe(null),ie(1);else if(r)oe(null),ie(1);else{const qe=Math.min(1e3,Math.min(t,n)*.9);oe(qe),ie(1)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const Y=(e,t,n,i)=>{if(c)return;let r=[...ee],w=[...W];const f=e==="bank"?r:w,d=t==="bank"?r:w,h=f.findIndex(de=>de.id===n);if(h===-1)return;const[Q]=f.splice(h,1);let b=i;e===t&&b!==null&&b!==void 0&&b>h&&(b=b-1),b==null||b<0||b>d.length?d.push(Q):d.splice(b,0,Q),e==="bank"?r=f:w=f,t==="bank"?r=d:w=d,ue(r),ne(w)},K=(e,t,n)=>{if(e.preventDefault(),c){D({list:null,index:null,side:null});return}const i=e.dataTransfer.getData("application/x-token")||(()=>{const r=e.dataTransfer.getData("text/plain");if(!r)return"";const w=ee.some(h=>h.id===r),f=W.some(h=>h.id===r),d=w?"bank":f?"selected":null;return d?JSON.stringify({from:d,id:r}):""})();if(i){try{const r=JSON.parse(i);if(!r||!r.id||!r.from)return;Y(r.from,t,r.id,n)}catch{}D({list:null,index:null,side:null})}},Be=e=>{le(e),U(Array(e).fill("")),v("time")},Me=e=>{ge(e),v("type")},Le=(e,t)=>{if(t.length>41||t&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(t))return;const i=[...k];i[e]=t,U(i);const r=S(i);r.isValid||console.warn("Validation errors:",r.errors)},Ae=e=>e.trim().replace(/\s+/g," "),fe=e=>e<=3?20:e<=5?18:e<=7?16:e<=9?14:12,$e=()=>{k.some(t=>t.trim().length===0)||(U(t=>t.map(n=>Ae(n))),V(0),pe(0),we(null),v("getready"))};s.useEffect(()=>{if(m==="getready"){const e=setTimeout(()=>re(0),3e3);return()=>clearTimeout(e)}},[m]);const re=e=>{const t=k[e];if(!t)return;const i=_e(t.trim().split(/\s+/).filter(Boolean)).map((r,w)=>({id:`${Date.now()}-${e}-${w}-${Math.random().toString(36).slice(2)}`,text:r}));ue(i),ne([]),pe(e),he(ce||20),R(null),q(!1),v("play")};s.useEffect(()=>{if(m==="play"&&!c)if(J.current!==null&&window.clearTimeout(J.current),B>0)J.current=window.setTimeout(()=>he(e=>e-1),1e3);else{q(!0);const t=k[j].trim().split(/\s+/),n=W.map(d=>d.text),i=t.filter(d=>!n.includes(d)).length,r=n.filter(d=>!t.includes(d)).length,w=t.filter((d,h)=>d!==n[h]).length,f=i+r+w;f===0?(R("correct"),T("correct"),P("Correct! Well done!")):f===1?(R("almost"),T("half"),P("Almost correct! Just one mistake.")):(R("wrong"),T("wrong"),P("Not quite right. Keep trying!"))}return()=>{J.current!==null&&window.clearTimeout(J.current)}},[m,B,c,k,j,W]);const Ge=(e=!0)=>{if(c&&e){j+1<(H||0)?re(j+1):(v("results"),setTimeout(()=>se(),600));return}if(e&&!c){const n=k[j].trim().split(/\s+/),i=W.map(h=>h.text),r=n.filter(h=>!i.includes(h)).length,w=i.filter(h=>!n.includes(h)).length,f=n.filter((h,Q)=>h!==i[Q]).length,d=r+w+f;d===0&&B>0?(V(h=>h+1),R("correct"),T("correct"),P("Correct! Well done!")):d===1?(V(h=>h+.5),R("almost"),T("half"),P("Almost correct! Just one mistake.")):(R("wrong"),T("wrong"),P("Not quite right. Keep trying!")),j+1<(H||0)?setTimeout(()=>re(j+1),800):(v("results"),setTimeout(()=>se(),600))}};s.useEffect(()=>{m==="results"&&X>te&&(ve(X),localStorage.setItem("magicSentenceBest",String(X)))},[m,X,te]);const T=e=>{const t=new(window.AudioContext||window.webkitAudioContext),n=t.createOscillator(),i=t.createGain();switch(n.connect(i),i.connect(t.destination),e){case"start":n.frequency.value=500;break;case"click":n.frequency.value=800;break;case"correct":n.frequency.value=1e3;break;case"half":n.frequency.value=700;break;case"wrong":n.frequency.value=200;break}i.gain.setValueAtTime(.1,t.currentTime),n.start(),n.stop(t.currentTime+.2)},se=()=>{const t=Date.now()+2500,n=["#ec4c44","#f7c948","#6fcf97","#56ccf2","#bb6bd9"],i=document.createElement("canvas"),r=i.getContext("2d");i.width=window.innerWidth,i.height=window.innerHeight,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.pointerEvents="none",document.body.appendChild(i);const w=Array.from({length:100}).map(()=>({x:Math.random()*i.width,y:Math.random()*i.height-i.height,size:6+Math.random()*6,color:n[Math.floor(Math.random()*n.length)],speed:2+Math.random()*4,tilt:Math.random()*2*Math.PI})),f=()=>{r.clearRect(0,0,i.width,i.height),w.forEach(d=>{r.fillStyle=d.color,r.beginPath(),r.ellipse(d.x,d.y,d.size,d.size/2,d.tilt,0,2*Math.PI),r.fill(),d.y+=d.speed,d.x+=Math.sin(d.tilt)}),Date.now()<t?requestAnimationFrame(f):document.body.removeChild(i)};f()},Ne=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select number of rounds"}),o.jsx("div",{style:{display:"flex",gap:g()?"8px":"16px",justifyContent:"center"},children:[3,4,5].map(e=>o.jsxs("button",{onClick:()=>Be(e),style:{...p.gmButton,...C("medium")},children:[e," ROUNDS"]},e))})]}),Oe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select time per round"}),o.jsx("div",{style:{display:"flex",gap:g()?"8px":"16px",justifyContent:"center"},children:[15,20,30].map(e=>o.jsxs("button",{onClick:()=>Me(e),style:{...p.gmButton,...C("medium")},children:[e,"s"]},e))})]}),Fe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsxs("h2",{style:{...p.gmBodyM,marginBottom:"0px"},children:["Type down ",H," sentence",H&&H>1?"s":""," for your student"]}),o.jsx("p",{style:{...p.gmBodyS,marginBottom:"16px",marginTop:"0px",color:"#6b7280"},children:"Maximum 41 characters per sentence"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,width:"auto",minWidth:"fit-content",maxWidth:"600px"},children:k.map((e,t)=>o.jsx("input",{value:e,placeholder:`Sentence ${t+1}`,onChange:n=>Le(t,n.target.value),style:{...p.gmInput,padding:g()?"8px 12px":"12px 16px",fontSize:g()?"14px":"16px",width:"100%",textAlign:"center"}},t))}),o.jsx("button",{onClick:$e,disabled:k.some(e=>e.trim().length===0),style:{...p.gmButton,marginTop:30,background:k.some(e=>e.trim().length===0)?"#ccc":"#ec4c44",cursor:k.some(e=>e.trim().length===0)?"not-allowed":"pointer",...C("large")},children:"PLAY"})]}),Ze=()=>o.jsxs("div",{style:p.gmReadyWrapper,children:[o.jsx("h1",{style:{...p.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),o.jsx("div",{style:p.gmHourglass,children:"⏳"})]}),Qe=()=>o.jsxs("div",{style:p.gmGameLayout,children:[o.jsxs("h2",{style:{marginBottom:g()?"5px":"10px",fontSize:g()?"16px":"20px"},children:["Round ",j+1,"/",H," — ",c?"TIME'S UP!":`Time: ${B}s`]}),o.jsx("div",{style:{width:"60%",height:g()?"8px":"14px",borderRadius:8,background:"#eee",overflow:"hidden",marginBottom:g()?"10px":"20px"},children:o.jsx("div",{style:{height:"100%",width:`${B/(ce||20)*100}%`,background:B<=5?"#ec4c44":"#4caf50",transition:"width 1s linear"}})}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>K(e,"bank",null),style:{display:"flex",flexWrap:I()?"wrap":"nowrap",gap:l||window.innerWidth<768?"6px":"10px",justifyContent:"center",marginBottom:l||window.innerWidth<768?"15px":"30px",padding:l||window.innerWidth<768?"5px":"10px",width:"100%",boxSizing:"border-box"},children:ee.map((e,t)=>o.jsx("div",{draggable:!c,role:"button",tabIndex:c?-1:0,"aria-label":c?`Word: ${e.text} (time expired)`:be("Drag word",e.text,"to build sentence"),onDragStart:n=>{if(c){n.preventDefault();return}n.dataTransfer.setData("application/x-token",JSON.stringify({from:"bank",id:e.id})),n.dataTransfer.setData("text/plain",e.id),P(`Dragging word: ${e.text}`)},onKeyDown:n=>{c||Se(n,()=>Y("bank","selected",e.id,null))},onDragOver:n=>n.preventDefault(),onDrop:n=>{const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,w=n.clientX>r?t+1:t;D({list:null,index:null,side:null}),n.stopPropagation(),K(n,"bank",w)},onDragEnter:n=>{if(c)return;const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;D({list:"bank",index:t,side:n.clientX>r?"right":"left"})},onDragLeave:()=>D({list:null,index:null,side:null}),onClick:()=>{c||Y("bank","selected",e.id,null)},style:{padding:l||window.innerWidth<768?"6px 10px":"10px 16px",borderRadius:l||window.innerWidth<768?"6px":"10px",border:"1px solid #ccc",background:c?"#f0f0f0":"#f9f9f9",cursor:c?"not-allowed":"pointer",fontSize:l||window.innerWidth<768?"12px":"18px",borderLeft:y.list==="bank"&&y.index===t&&y.side==="left"?"3px solid #3b82f6":"1px solid #ccc",borderRight:y.list==="bank"&&y.index===t&&y.side==="right"?"3px solid #3b82f6":"1px solid #ccc",flexShrink:0,flexBasis:"auto",opacity:c?.6:1,transition:"opacity 0.3s ease"},children:e.text},e.id))}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>K(e,"selected",null),style:{minHeight:l||window.innerWidth<768?"50px":"70px",width:"auto",maxWidth:"none",minWidth:"245px",border:M==="correct"?"2px dashed #4caf50":M==="almost"?"2px dashed #ff9800":M==="wrong"?"2px dashed #f44336":"2px dashed #ccc",borderRadius:l||window.innerWidth<768?"8px":"12px",padding:l||window.innerWidth<768?"8px":"12px",display:"flex",flexWrap:I()?"wrap":"nowrap",alignItems:"center",justifyContent:"center",fontSize:`${fe(W.length)}px`,background:M==="correct"?"#e8f5e8":M==="almost"?"#fff3e0":M==="wrong"?"#ffebee":"#fafafa",overflowX:I()?"hidden":"auto",whiteSpace:I()?"normal":"nowrap"},children:W.map((e,t)=>o.jsx("span",{draggable:!c,onDragStart:n=>{if(c){n.preventDefault();return}n.dataTransfer.setData("application/x-token",JSON.stringify({from:"selected",id:e.id})),n.dataTransfer.setData("text/plain",e.id)},onDragOver:n=>n.preventDefault(),onDrop:n=>{const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,w=n.clientX>r?t+1:t;D({list:null,index:null,side:null}),n.stopPropagation(),K(n,"selected",w)},onDragEnter:n=>{if(c)return;const i=n.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;D({list:"selected",index:t,side:n.clientX>r?"right":"left"})},onDragLeave:()=>D({list:null,index:null,side:null}),onClick:()=>{c||Y("selected","bank",e.id,null)},title:c?"Time expired":"Click to remove back to bank",style:{padding:g()?"4px 6px":"6px 10px",margin:g()?"2px":"4px",borderRadius:g()?"4px":"8px",background:c?"#f0f0f0":"#ffe9e7",border:c?"1px solid #ccc":"1px solid #ec4c44",borderLeft:y.list==="selected"&&y.index===t&&y.side==="left"?"3px solid #3b82f6":void 0,borderRight:y.list==="selected"&&y.index===t&&y.side==="right"?"3px solid #3b82f6":void 0,cursor:c?"not-allowed":"pointer",userSelect:"none",fontSize:`${fe(W.length)}px`,fontFamily:'"Roboto", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif',whiteSpace:"nowrap",opacity:c?.6:1,transition:"opacity 0.3s ease"},children:e.text},e.id))}),o.jsx("button",{onClick:()=>Ge(!0),disabled:!c&&W.length===0,style:{marginTop:g()?"15px":"30px",fontSize:g()?"14px":"20px",padding:g()?"6px 12px":"10px 24px",borderRadius:g()?"8px":"12px",background:c||W.length>0?"#ec4c44":"#ccc",color:"white",border:"none",cursor:c||W.length>0?"pointer":"not-allowed"},children:"NEXT"})]}),Xe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:{...p.gmHeadline1,marginTop:(l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z,"0px"),marginBottom:l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z?"2px":"10px",fontSize:l&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"32px":"clamp(28px, 4vw, 40px)"},children:"Game Over 🎯"}),o.jsxs("h2",{style:{...p.gmHeadline2,marginTop:(l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z,"0px"),marginBottom:l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z?"2px":"16px",fontSize:l&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"18px":"24px"},children:["Your score: ",X," out of ",H]}),o.jsxs("p",{style:{...p.gmBodyM,color:"#10b981",marginTop:l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z?"0px":"12px",marginBottom:l&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||L||A||$||G||N||O||F||Z?"2px":"16px",fontSize:l&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"14px":"16px"},children:["Best score: ",te]}),o.jsxs("div",{style:{display:"flex",gap:l&&window.innerWidth>window.innerHeight||l&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"6px":"12px",marginTop:l&&window.innerWidth>window.innerHeight||l&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"2px":window.innerWidth===1366&&window.innerHeight===766||window.innerWidth===1366&&window.innerHeight===768||window.innerWidth===1280&&window.innerHeight===720||window.innerWidth===1440&&window.innerHeight===900||He?"12px":"24px"},children:[o.jsx("button",{onClick:()=>{se(),T("start"),setTimeout(()=>{v("getready"),we(null),q(!1)},800)},style:{...p.gmButton,...C("medium")},children:"🔁 Play again"}),o.jsx("button",{onClick:()=>{T("click"),v("select"),le(null),ge(null),U([]),V(0),ne([]),q(!1)},style:{...p.gmButton,...C("medium")},children:"⬅️ Exit"})]})]}),ae=a||(E?`${E.endsWith("/")?E.slice(0,-1):E}/logo.svg`:typeof window<"u"&&window.origin?`${window.origin}/browser/speakid/games/magic%20sentence/logo.svg`:null),Je=!l&&x&&!(window.innerWidth>window.innerHeight)&&window.innerHeight>=700;return o.jsx("div",{ref:_,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",transition:"background 0.3s ease",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},children:o.jsxs("div",{style:{width:l?"100%":me||1e3,height:l?"100%":me||1e3,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",borderRadius:l?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",boxShadow:l?"none":"0 0 40px rgba(0,0,0,0.1)",margin:l?"0 auto":"unset",position:"relative"},children:[!l&&Je&&o.jsx("div",{style:{...p.gmLogoFixed,position:"absolute",top:16,left:16,zIndex:30},children:ae?o.jsxs("picture",{children:[o.jsx("source",{srcSet:ae,type:"image/svg+xml"}),o.jsx("img",{src:ae.replace(".svg",".png"),alt:"SPEAKID Logo",style:p.gmLogoImg,loading:"lazy"})]}):o.jsx("div",{style:p.gmLogoImg,children:"SPEAKID"})}),o.jsx("div",{style:{transform:"none",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:o.jsxs("div",{id:"magic-sentence-root",children:[m==="select"?Ne():null,m==="time"?Oe():null,m==="type"?Fe():null,m==="getready"?Ze():null,m==="play"?Qe():null,m==="results"?Xe():null]})})]})})}class en extends s.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,x){console.error("Game Error:",a,x),this.setState({error:a,errorInfo:x})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",textAlign:"center",backgroundColor:"#fef2f2",color:"#dc2626",fontFamily:"system-ui, sans-serif"},children:[o.jsx("h1",{style:{fontSize:"24px",marginBottom:"16px"},children:"🚨 Oops! Something went wrong"}),o.jsx("p",{style:{fontSize:"16px",marginBottom:"24px",maxWidth:"500px"},children:"The game encountered an unexpected error. Don't worry, your progress is saved!"}),o.jsx("button",{onClick:this.handleReset,style:{padding:"12px 24px",fontSize:"16px",backgroundColor:"#dc2626",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"},onMouseOver:a=>a.currentTarget.style.backgroundColor="#b91c1c",onMouseOut:a=>a.currentTarget.style.backgroundColor="#dc2626",children:"🔄 Restart Game"}),typeof process<"u"&&process.env.NODE_ENV==="development"&&this.state.error&&o.jsxs("details",{style:{marginTop:"20px",textAlign:"left",maxWidth:"600px"},children:[o.jsx("summary",{style:{cursor:"pointer",fontSize:"14px"},children:"Technical Details (Development Only)"}),o.jsxs("pre",{style:{backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"4px",fontSize:"12px",overflow:"auto",marginTop:"8px"},children:[this.state.error.toString(),this.state.errorInfo?.componentStack]})]})]}):this.props.children}}exports.ErrorBoundary=en;exports.Game=We;exports.announceToScreenReader=P;exports.createAriaLabel=be;exports.default=We;exports.handleKeyDown=Se;exports.useValidation=ye;
60
+ `;const d=document.getElementById("magic-sentence-reset");d&&d.remove(),document.head.appendChild(w)},at=w=>[...w].sort(()=>Math.random()-.5);function Te(w={}){const{logoUrl:d,showLogo:k=!0}=w,re=s.useRef(null),{validateAllSentences:oe,errors:T}=He(),j=()=>u||window.innerWidth<768,f=()=>u||window.innerWidth<768||window.innerWidth>=320&&window.innerWidth<=932&&window.innerHeight>=390&&window.innerHeight<=932,y=(e="medium")=>{if(!f())return{padding:"12px 24px",fontSize:"16px",minWidth:"auto"};switch(e){case"small":return{padding:"4px 6px",fontSize:"9px",minWidth:"40px"};case"medium":return{padding:"5px 8px",fontSize:"10px",minWidth:"50px"};case"large":return{padding:"6px 10px",fontSize:"11px",minWidth:"60px"}}};s.useEffect(()=>(st(),()=>{document.documentElement.style.overflow="",document.body.style.overflow="";const e=document.getElementById("magic-sentence-reset");e&&e.remove()}),[]);const[x,W]=s.useState("select"),[D,U]=s.useState(null),[he,pe]=s.useState(null),[H,Y]=s.useState([]),[R,ge]=s.useState(0),[se,we]=s.useState([]),[b,ae]=s.useState([]),[L,fe]=s.useState(20),[V,B]=s.useState(0),[lt,me]=s.useState(null),[M,C]=s.useState(null),[c,Z]=s.useState(!1),[_,Q]=s.useState(!1),[de,je]=s.useState(Number(localStorage.getItem("magicSentenceBest"))||0),J=s.useRef(null),De=s.useRef(null),xe=s.useRef(0),[m,P]=s.useState({list:null,id:null,side:null}),[u,Re]=s.useState(!1),[Ee,ee]=s.useState(1),[ye,te]=s.useState(null),[ze,Pe]=s.useState(!1),[A,Be]=s.useState(!1),[$,Me]=s.useState(!1),[O,Le]=s.useState(!1),[N,Ae]=s.useState(!1),[G,$e]=s.useState(!1),[X,Oe]=s.useState(!1),[F,Ne]=s.useState(!1),[q,Ge]=s.useState(!1),[ct,Xe]=s.useState(!1),[ut,Fe]=s.useState(!1);s.useEffect(()=>{const e=()=>{const n=window.innerWidth,t=window.innerHeight,i=n<768||n===926&&t===428||n===932&&t===430,r=t<700,h=n/t>1.8,g=n===768&&t===1024,a=n===1024&&t===768,l=n===820&&t===1180,I=n===1180&&t===820,v=n===540&&t===720,ie=n===720&&t===540,Se=n===1024&&t===1366,We=n===1366&&t===1024,ke=n>=1200&&t>=600&&!i;Pe(ke),Be(g),Me(a),Le(l),Ae(I),$e(v),Oe(ie),Ne(Se),Ge(We),Fe(h);const rt=i&&n>t||i||t<700||h||n===1366&&t===766||n===1366&&t===768||n===1280&&t===720||n===1440&&t===900||g||a||l||I||v||ie||Se||We||ke;if(Xe(rt),Re(i),i)te(null),ee(1);else if(r)te(null),ee(1);else if(h){const ue=Math.min(1e3,Math.min(n,t)*.9);te(ue),ee(.85)}else{const ue=Math.min(1e3,Math.min(n,t)*.9);te(ue),ee(1)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const ne=(e,n,t,i)=>{if(c)return;let r=[...se],h=[...b];const g=e==="bank"?r:h,a=n==="bank"?r:h,l=g.findIndex(ie=>ie.id===t);if(l===-1)return;const[I]=g.splice(l,1);let v=i;e===n&&v!==null&&v!==void 0&&v>l&&(v=v-1),v==null||v<0||v>a.length?a.push(I):a.splice(v,0,I),e==="bank"?r=g:h=g,n==="bank"?r=a:h=a,we(r),ae(h)},K=(e,n,t)=>{if(e.preventDefault(),c){P({list:null,id:null,side:null});return}const i=e.dataTransfer.getData("application/x-token")||(()=>{const r=e.dataTransfer.getData("text/plain");if(!r)return"";const h=se.some(l=>l.id===r),g=b.some(l=>l.id===r),a=h?"bank":g?"selected":null;return a?JSON.stringify({from:a,id:r}):""})();if(i){try{const r=JSON.parse(i);if(!r||!r.id||!r.from)return;ne(r.from,n,r.id,t)}catch{}P({list:null,id:null,side:null})}},qe=e=>{U(e),De.current=e,Y(Array(e).fill("")),W("time")},Ve=e=>{pe(e),W("type")},Je=(e,n)=>{if(n.length>41||n&&!/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(n))return;const i=[...H];i[e]=n,Y(i);const r=oe(i);r.isValid||console.warn("Validation errors:",r.errors)},Ke=e=>e.trim().replace(/\s+/g," "),be=e=>e<=3?20:e<=5?18:e<=7?16:e<=9?14:12,Ue=()=>{H.some(n=>n.trim().length===0)||(Y(n=>n.map(t=>Ke(t))),B(0),ge(0),xe.current=0,me(null),W("getready"))};s.useEffect(()=>{if(x==="getready"){const e=setTimeout(()=>le(0),3e3);return()=>clearTimeout(e)}},[x]);const le=e=>{const n=H[e];if(!n)return;const i=at(n.trim().split(/\s+/).filter(Boolean)).map((r,h)=>({id:`${Date.now()}-${e}-${h}-${Math.random().toString(36).slice(2)}`,text:r}));we(i),ae([]),ge(e),xe.current=e,fe(he||20),C(null),Z(!1),Q(!1),W("play")},S=s.useRef(null);s.useEffect(()=>{if(x!=="play"||c){S.current!==null&&(window.clearTimeout(S.current),S.current=null);return}const e=H[R];if(!e){C(null),S.current!==null&&(window.clearTimeout(S.current),S.current=null);return}if(b.length===0){C(null),S.current!==null&&(window.clearTimeout(S.current),S.current=null);return}const n=e.trim().split(/\s+/),t=b.map(r=>r.text);if(t.length===n.length&&t.every((r,h)=>r===n[h]))C("correct"),_||(Q(!0),B(r=>r+1),E("correct"),z("Correct! Well done!"));else{S.current!==null&&(window.clearTimeout(S.current),S.current=null);const r=n.filter(l=>!t.includes(l)).length,h=t.filter(l=>!n.includes(l)).length,g=n.filter((l,I)=>l!==t[I]).length,a=r+h+g;C(a===1?"almost":"wrong"),_&&(Q(!1),B(l=>Math.max(0,l-1)))}return()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[x,b,H,R,c,M,_,D]),s.useEffect(()=>{if(x==="play"&&!c)if(J.current!==null&&window.clearTimeout(J.current),L>0)J.current=window.setTimeout(()=>fe(e=>e-1),1e3);else{Z(!0);const n=H[R].trim().split(/\s+/),t=b.map(a=>a.text),i=n.filter(a=>!t.includes(a)).length,r=t.filter(a=>!n.includes(a)).length,h=n.filter((a,l)=>a!==t[l]).length,g=i+r+h;g===0?(C("correct"),_||(Q(!0),B(a=>a+1)),E("correct"),z("Correct! Well done!")):g===1?(C("almost"),E("half"),z("Almost correct! Just one mistake.")):(C("wrong"),E("wrong"),z("Not quite right. Keep trying!"))}return()=>{J.current!==null&&window.clearTimeout(J.current)}},[x,L,c,H,R,b]);const Ye=(e=!0)=>{if(c&&e){R+1<(D||0)?le(R+1):(W("results"),setTimeout(()=>ce(),600));return}if(e&&!c){const t=H[R].trim().split(/\s+/),i=b.map(l=>l.text),r=t.filter(l=>!i.includes(l)).length,h=i.filter(l=>!t.includes(l)).length,g=t.filter((l,I)=>l!==i[I]).length,a=r+h+g;a===0&&L>0?(B(l=>l+1),C("correct"),E("correct"),z("Correct! Well done!")):a===1?(B(l=>l+.5),C("almost"),E("half"),z("Almost correct! Just one mistake.")):(C("wrong"),E("wrong"),z("Not quite right. Keep trying!")),R+1<(D||0)?setTimeout(()=>le(R+1),800):(W("results"),setTimeout(()=>ce(),600))}};s.useEffect(()=>{x==="results"&&V>de&&(je(V),localStorage.setItem("magicSentenceBest",String(V)))},[x,V,de]);const E=e=>{const n=new(window.AudioContext||window.webkitAudioContext),t=n.createOscillator(),i=n.createGain();switch(t.connect(i),i.connect(n.destination),e){case"start":t.frequency.value=500;break;case"click":t.frequency.value=800;break;case"correct":t.frequency.value=1e3;break;case"half":t.frequency.value=700;break;case"wrong":t.frequency.value=200;break}i.gain.setValueAtTime(.1,n.currentTime),t.start(),t.stop(n.currentTime+.2)},ce=()=>{const n=Date.now()+2500,t=["#ec4c44","#f7c948","#6fcf97","#56ccf2","#bb6bd9"],i=document.createElement("canvas"),r=i.getContext("2d");i.width=window.innerWidth,i.height=window.innerHeight,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.pointerEvents="none",document.body.appendChild(i);const h=Array.from({length:100}).map(()=>({x:Math.random()*i.width,y:Math.random()*i.height-i.height,size:6+Math.random()*6,color:t[Math.floor(Math.random()*t.length)],speed:2+Math.random()*4,tilt:Math.random()*2*Math.PI})),g=()=>{r.clearRect(0,0,i.width,i.height),h.forEach(a=>{r.fillStyle=a.color,r.beginPath(),r.ellipse(a.x,a.y,a.size,a.size/2,a.tilt,0,2*Math.PI),r.fill(),a.y+=a.speed,a.x+=Math.sin(a.tilt)}),Date.now()<n?requestAnimationFrame(g):document.body.removeChild(i)};g()},Ze=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select number of rounds"}),o.jsx("div",{style:{display:"flex",gap:f()?"8px":"16px",justifyContent:"center"},children:[3,4,5].map(e=>o.jsxs("button",{onClick:()=>qe(e),style:{...p.gmButton,...y("medium")},children:[e," ROUNDS"]},e))})]}),_e=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:p.gmHeadline1,children:"MAGIC SENTENCE"}),o.jsx("p",{style:p.gmBodyM,children:"Select time per round"}),o.jsx("div",{style:{display:"flex",gap:f()?"8px":"16px",justifyContent:"center"},children:[15,20,30].map(e=>o.jsxs("button",{onClick:()=>Ve(e),style:{...p.gmButton,...y("medium")},children:[e,"s"]},e))})]}),Qe=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsxs("h2",{style:{...p.gmBodyM,marginBottom:"0px"},children:["Type down ",D," sentence",D&&D>1?"s":""," for your student"]}),o.jsx("p",{style:{...p.gmBodyS,marginBottom:"16px",marginTop:"0px",color:"#6b7280"},children:"Maximum 41 characters per sentence"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,width:"auto",minWidth:"fit-content",maxWidth:"600px"},children:H.map((e,n)=>o.jsx("input",{value:e,placeholder:`Sentence ${n+1}`,onChange:t=>Je(n,t.target.value),style:{...p.gmInput,padding:f()?"8px 12px":"12px 16px",fontSize:f()?"14px":"16px",width:"100%",textAlign:"center"}},n))}),o.jsx("button",{onClick:Ue,disabled:H.some(e=>e.trim().length===0),style:{...p.gmButton,marginTop:30,background:H.some(e=>e.trim().length===0)?"#ccc":"#ec4c44",cursor:H.some(e=>e.trim().length===0)?"not-allowed":"pointer",...y("large")},children:"PLAY"})]}),et=()=>o.jsxs("div",{style:p.gmReadyWrapper,children:[o.jsx("h1",{style:{...p.gmHeadline1,color:"#ec4c44"},children:"GET READY"}),o.jsx("div",{style:p.gmHourglass,children:"⏳"})]}),tt=()=>o.jsxs("div",{style:p.gmGameLayout,children:[o.jsxs("h2",{style:{marginBottom:f()?"5px":"10px",fontSize:f()?"16px":"20px"},children:["Round ",R+1,"/",D," — ",c?"TIME'S UP!":`Time: ${L}s`]}),o.jsx("div",{style:{width:"60%",height:f()?"8px":"14px",borderRadius:8,background:"#eee",overflow:"hidden",marginBottom:f()?"10px":"20px"},children:o.jsx("div",{style:{height:"100%",width:`${L/(he||20)*100}%`,background:L<=5?"#ec4c44":"#4caf50",transition:"width 1s linear"}})}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>K(e,"bank",null),style:{display:"flex",flexWrap:j()?"wrap":"nowrap",gap:u||window.innerWidth<768?"6px":"10px",justifyContent:"center",marginBottom:u||window.innerWidth<768?"15px":"30px",padding:u||window.innerWidth<768?"5px":"10px",width:"100%",boxSizing:"border-box"},children:se.map((e,n)=>o.jsx("div",{draggable:!c,role:"button",tabIndex:c?-1:0,"aria-label":c?`Word: ${e.text} (time expired)`:Ce("Drag word",e.text,"to build sentence"),onDragStart:t=>{if(c){t.preventDefault();return}t.dataTransfer.setData("application/x-token",JSON.stringify({from:"bank",id:e.id})),t.dataTransfer.setData("text/plain",e.id),z(`Dragging word: ${e.text}`)},onKeyDown:t=>{c||Ie(t,()=>ne("bank","selected",e.id,null))},onDragOver:t=>t.preventDefault(),onDrop:t=>{const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,h=t.clientX>r?n+1:n;P({list:null,id:null,side:null}),t.stopPropagation(),K(t,"bank",h)},onDragEnter:t=>{if(c)return;const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;P({list:"bank",id:e.id,side:t.clientX>r?"right":"left"})},onDragLeave:()=>P({list:null,id:null,side:null}),onClick:()=>{c||ne("bank","selected",e.id,null)},style:{padding:u||window.innerWidth<768?"6px 10px":"10px 16px",borderRadius:u||window.innerWidth<768?"6px":"10px",border:"1px solid #ccc",background:c?"#f0f0f0":"#f9f9f9",cursor:c?"not-allowed":m.list==="bank"&&m.id===e.id?"grabbing":"grab",fontSize:u||window.innerWidth<768?"12px":"18px",...m.list==="bank"&&m.id===e.id&&m.side==="left"?{borderLeft:"3px solid #3b82f6"}:{},...m.list==="bank"&&m.id===e.id&&m.side==="right"?{borderRight:"3px solid #3b82f6"}:{},flexShrink:0,flexBasis:"auto",opacity:c?.6:1,transition:"opacity 0.3s ease, transform 0.2s ease",...m.list==="bank"&&m.id===e.id?{transform:"scale(1.05)",boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"}:{}},children:e.text},e.id))}),o.jsx("div",{onDragOver:e=>e.preventDefault(),onDrop:e=>{const n=e.currentTarget.getBoundingClientRect(),t=Array.from(e.currentTarget.children);if(t.length===0){K(e,"selected",0);return}let i=b.length,r=1/0;t.forEach((h,g)=>{const a=h.getBoundingClientRect(),l=a.left+a.width/2,I=Math.abs(e.clientX-l);I<r&&(r=I,i=e.clientX<l?g:g+1)}),e.clientX>n.right-30&&(i=b.length),e.clientX<n.left+30&&(i=0),K(e,"selected",i)},style:{minHeight:u||window.innerWidth<768?"50px":"70px",width:"auto",maxWidth:"none",minWidth:"245px",border:M==="correct"?"2px dashed #4caf50":M==="almost"?"2px dashed #ff9800":M==="wrong"?"2px dashed #f44336":"2px dashed #ccc",borderRadius:u||window.innerWidth<768?"8px":"12px",padding:u||window.innerWidth<768?"8px":"12px",display:"flex",flexWrap:j()?"wrap":"nowrap",alignItems:"center",justifyContent:"center",fontSize:`${be(b.length)}px`,background:M==="correct"?"#e8f5e8":M==="almost"?"#fff3e0":M==="wrong"?"#ffebee":"#fafafa",overflowX:j()?"hidden":"auto",whiteSpace:j()?"normal":"nowrap"},children:b.map((e,n)=>o.jsx("span",{draggable:!c,onDragStart:t=>{if(c){t.preventDefault();return}t.dataTransfer.setData("application/x-token",JSON.stringify({from:"selected",id:e.id})),t.dataTransfer.setData("text/plain",e.id)},onDragOver:t=>t.preventDefault(),onDrop:t=>{const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2,h=i.width*.25,g=t.clientX<r-h?n:t.clientX>r+h||t.clientX>r?n+1:n;P({list:null,id:null,side:null}),t.stopPropagation(),K(t,"selected",g)},onDragEnter:t=>{if(c)return;const i=t.currentTarget.getBoundingClientRect(),r=i.left+i.width/2;P({list:"selected",id:e.id,side:t.clientX>r?"right":"left"})},onDragLeave:()=>P({list:null,id:null,side:null}),onClick:()=>{c||ne("selected","bank",e.id,null)},title:c?"Time expired":"Click to remove back to bank",style:{padding:f()?"4px 6px":"6px 10px",margin:f()?"2px":"4px",borderRadius:f()?"4px":"8px",background:c?"#f0f0f0":"#ffe9e7",border:c?"1px solid #ccc":"1px solid #ec4c44",...m.list==="selected"&&m.id===e.id&&m.side==="left"?{borderLeft:"3px solid #3b82f6"}:{},...m.list==="selected"&&m.id===e.id&&m.side==="right"?{borderRight:"3px solid #3b82f6"}:{},cursor:c?"not-allowed":m.list==="selected"&&m.id===e.id?"grabbing":"grab",userSelect:"none",fontSize:`${be(b.length)}px`,fontFamily:'"Roboto", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif',whiteSpace:"nowrap",opacity:c?.6:1,transition:"opacity 0.3s ease, transform 0.2s ease",...m.list==="selected"&&m.id===e.id?{transform:"scale(1.05)",boxShadow:"0 2px 8px rgba(59, 130, 246, 0.3)"}:{}},children:e.text},e.id))}),o.jsx("button",{onClick:()=>Ye(!0),disabled:!c&&b.length===0,style:{marginTop:f()?"15px":"30px",fontSize:f()?"14px":"20px",padding:f()?"6px 12px":"10px 24px",borderRadius:f()?"8px":"12px",background:c||b.length>0?"#ec4c44":"#ccc",color:"white",border:"none",cursor:c||b.length>0?"pointer":"not-allowed"},children:"NEXT"})]}),nt=()=>o.jsxs("div",{style:p.gmCenterScreen,children:[o.jsx("h1",{style:{...p.gmHeadline1,marginTop:(u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q,"0px"),marginBottom:u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"10px",fontSize:u&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"32px":"clamp(28px, 4vw, 40px)"},children:"Game Over 🎯"}),o.jsxs("h2",{style:{...p.gmHeadline2,marginTop:(u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q,"0px"),marginBottom:u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"16px",fontSize:u&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"18px":"24px"},children:["Your score: ",V," out of ",D]}),o.jsxs("p",{style:{...p.gmBodyM,color:"#10b981",marginTop:u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"0px":"12px",marginBottom:u&&window.innerWidth>window.innerHeight||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430||A||$||O||N||G||X||F||q?"2px":"16px",fontSize:u&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"14px":"16px"},children:["Best score: ",de]}),o.jsxs("div",{style:{display:"flex",gap:u&&window.innerWidth>window.innerHeight||u&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"6px":"12px",marginTop:u&&window.innerWidth>window.innerHeight||u&&window.innerWidth<=375&&window.innerHeight<=667||window.innerWidth===896&&window.innerHeight===414||window.innerWidth===844&&window.innerHeight===390||window.innerWidth===926&&window.innerHeight===428||window.innerWidth===932&&window.innerHeight===430?"2px":window.innerWidth===1366&&window.innerHeight===766||window.innerWidth===1366&&window.innerHeight===768||window.innerWidth===1280&&window.innerHeight===720||window.innerWidth===1440&&window.innerHeight===900||ze?"12px":"24px"},children:[o.jsx("button",{onClick:()=>{ce(),E("start"),setTimeout(()=>{W("getready"),me(null),Z(!1)},800)},style:{...p.gmButton,...y("medium")},children:"🔁 Play again"}),o.jsx("button",{onClick:()=>{E("click"),W("select"),U(null),pe(null),Y([]),B(0),ae([]),Z(!1)},style:{...p.gmButton,...y("medium")},children:"⬅️ Exit"})]})]}),it=!u&&k;return o.jsx("div",{ref:re,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",transition:"background 0.3s ease",overflow:"hidden",position:"absolute",top:0,left:0,right:0,bottom:0},children:o.jsx("div",{style:{width:u?"100%":ye||1e3,height:u?"100%":ye||1e3,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",borderRadius:u?0:"20px",background:"linear-gradient(to bottom, #fff8f8 0%, #f9fafb 100%)",boxShadow:u?"none":"0 0 40px rgba(0,0,0,0.1)",margin:u?"0 auto":"unset",position:"relative",transform:`scale(${Ee})`},children:o.jsx("div",{style:{transform:"translateZ(0)",width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:o.jsxs("div",{id:"magic-sentence-root",children:[it?o.jsx("div",{style:p.gmLogoFixed,children:o.jsx("img",{src:d||(typeof window<"u"&&window.origin?`${window.origin}/cloud/speakid/games/magic%20sentence/logo.png`:"/logo.png"),alt:"SPEAKID Logo",style:p.gmLogoImg,loading:"lazy"})}):null,x==="select"?Ze():null,x==="time"?_e():null,x==="type"?Qe():null,x==="getready"?et():null,x==="play"?tt():null,x==="results"?nt():null]})})})})}class dt extends s.Component{constructor(d){super(d),this.state={hasError:!1}}static getDerivedStateFromError(d){return{hasError:!0,error:d}}componentDidCatch(d,k){console.error("Game Error:",d,k),this.setState({error:d,errorInfo:k})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"20px",textAlign:"center",backgroundColor:"#fef2f2",color:"#dc2626",fontFamily:"system-ui, sans-serif"},children:[o.jsx("h1",{style:{fontSize:"24px",marginBottom:"16px"},children:"🚨 Oops! Something went wrong"}),o.jsx("p",{style:{fontSize:"16px",marginBottom:"24px",maxWidth:"500px"},children:"The game encountered an unexpected error. Don't worry, your progress is saved!"}),o.jsx("button",{onClick:this.handleReset,style:{padding:"12px 24px",fontSize:"16px",backgroundColor:"#dc2626",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"},onMouseOver:d=>d.currentTarget.style.backgroundColor="#b91c1c",onMouseOut:d=>d.currentTarget.style.backgroundColor="#dc2626",children:"🔄 Restart Game"}),typeof process<"u"&&process.env.NODE_ENV==="development"&&this.state.error&&o.jsxs("details",{style:{marginTop:"20px",textAlign:"left",maxWidth:"600px"},children:[o.jsx("summary",{style:{cursor:"pointer",fontSize:"14px"},children:"Technical Details (Development Only)"}),o.jsxs("pre",{style:{backgroundColor:"#f3f4f6",padding:"12px",borderRadius:"4px",fontSize:"12px",overflow:"auto",marginTop:"8px"},children:[this.state.error.toString(),this.state.errorInfo?.componentStack]})]})]}):this.props.children}}exports.ErrorBoundary=dt;exports.Game=Te;exports.announceToScreenReader=z;exports.createAriaLabel=Ce;exports.default=Te;exports.handleKeyDown=Ie;exports.useValidation=He;
61
61
  //# sourceMappingURL=speakid-build-a-sentence.cjs.js.map