1/*! For license information please see 5943.9ad0f5c9.chunk.js.LICENSE.txt */ 2"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[5943],{91751(e,t,r){r.d(t,{A:()=>o});var s=r(65043),n=r(70579);const a=["rgba(52,168,83,0.35)","rgba(66,133,244,0.35)","rgba(251,188,5,0.40)","rgba(156,39,176,0.35)","rgba(234,67,53,0.35)","rgba(0,188,212,0.35)","rgba(255,152,0,0.40)","rgba(0,150,136,0.35)"];function l(e,t){return`${e}_${t}`}const o=e=>{let{grid:t=[],wordList:r=[],readOnly:o=!1,placements:c=[],onProgress:i,onFoundWordsChange:d}=e;const u=t.length,m=(0,s.useRef)(null),[f,x]=(0,s.useState)([]),[h,p]=(0,s.useState)(null),[g,y]=(0,s.useState)(!1),[w,b]=(0,s.useState)(new Set);(0,s.useEffect)(()=>{if(o&&c.length>0){const e=c.map((e,t)=>{const[r,s]={right:[0,1],left:[0,-1],down:[1,0],up:[-1,0],down_right:[1,1],down_left:[1,-1],up_right:[-1,1],up_left:[-1,-1]}[e.direction]||[0,1],n=e.word.split("").map((t,n)=>({r:e.row+r*n,c:e.col+s*n}));return{word:e.word,cells:n,colour:a[t%a.length]}});x(e),b(new Set(c.map(e=>e.word)))}},[o,c]),(0,s.useEffect)(()=>{if(!o&&i){const e=r.length>0?Math.round(w.size/r.length*100):0;i(e)}!o&&d&&d([...w])},[w,r.length,o,i,d]);const v=new Map;for(const s of f)for(const{r:e,c:t}of s.cells)v.set(l(e,t),s.colour);const N=new Set(h?h.cells.map(e=>{let{r:t,c:r}=e;return l(t,r)}):[]),j=(0,s.useRef)(null);function k(e){const t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return null;const r=parseInt(t.dataset.row,10),s=parseInt(t.dataset.col,10);return isNaN(r)||isNaN(s)?null:{r:r,c:s}}const C=(0,s.useCallback)(e=>{if(o)return;e.currentTarget.setPointerCapture(e.pointerId);const t=k(e);t&&(j.current=t,p({cells:[t]}))},[o]),S=(0,s.useCallback)(e=>{if(!j.current||o)return;const t=k(e);if(!t)return;const r=function(e,t,r,s){if(e===r&&t===s)return[{r:e,c:t}];const n=r-e,a=s-t,l=Math.abs(n),o=Math.abs(a);let c=0,i=0;if(0===l)i=a>0?1:-1;else if(0===o)c=n>0?1:-1;else{if(l!==o){l>=o?c=n>0?1:-1:i=a>0?1:-1;const r=0!==c?l:o,s=[];for(let n=0;n<=r;n++)s.push({r:e+c*n,c:t+i*n});return s}c=n>0?1:-1,i=a>0?1:-1}const d=l>0?l:o,u=[];for(let m=0;m<=d;m++)u.push({r:e+c*m,c:t+i*m});return u}(j.current.r,j.current.c,t.r,t.c);p({cells:r})},[o]),A=(0,s.useCallback)(e=>{if(!j.current||o)return;if(j.current=null,!h||h.cells.length<2)return void p(null);const s=h.cells.map(e=>{var r;let{r:s,c:n}=e;return(null===(r=t[s])||void 0===r?void 0:r[n])||""}).join(""),n=s.split("").reverse().join(""),l=r.find(e=>e===s||e===n);if(l&&!w.has(l)){const e=a[f.length%a.length],t=l===s?h.cells:[...h.cells].reverse();x(r=>[...r,{word:l,cells:t,colour:e}]),b(e=>new Set([...e,l])),p(null)}else y(!0),setTimeout(()=>{y(!1),p(null)},400)},[o,h,t,r,w,f.length]),M=Math.min(32,Math.floor(320/Math.max(u,1)));return u?(0,n.jsx)("div",{className:"select-none",children:(0,n.jsx)("div",{ref:m,className:"inline-block touch-none",style:{display:"grid",gridTemplateColumns:`repeat(${u}, ${M}px)`,gap:"1px",background:"hsl(var(--border))",border:"1px solid hsl(var(--border))",userSelect:"none"},onPointerDown:C,onPointerMove:S,onPointerUp:A,onPointerCancel:()=>{j.current=null,p(null)},children:t.map((e,t)=>e.map((e,r)=>{const s=l(t,r),a=v.get(s),c=N.has(s);return(0,n.jsx)("div",{"data-row":t,"data-col":r,style:{width:M,height:M,display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(10,.5*M),fontWeight:"700",fontFamily:"monospace",background:a||(c?g?"rgba(239,68,68,0.35)":"rgba(var(--primary-rgb, 46,125,50),0.25)":"hsl(var(--background))"),color:"hsl(var(--foreground))",cursor:o?"default":"crosshair",transition:"background 0.1s"},children:e},s)}))})}):null}},91140(e,t,r){r.d(t,{BT:()=>i,Wu:()=>d,ZB:()=>c,Zp:()=>l,aR:()=>o,wL:()=>u});var s=r(65043),n=r(99766),a=r(70579);const l=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("rounded-xl border bg-card text-card-foreground shadow",r),...s})});l.displayName="Card";const o=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("flex flex-col space-y-1.5 p-6",r),...s})});
2o.displayName="CardHeader";const c=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("font-semibold leading-none tracking-tight",r),...s})});c.displayName="CardTitle";const i=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("text-sm text-muted-foreground",r),...s})});i.displayName="CardDescription";const d=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("p-6 pt-0",r),...s})});d.displayName="CardContent";const u=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)("div",{ref:t,className:(0,n.cn)("flex items-center p-6 pt-0",r),...s})});u.displayName="CardFooter"},92264(e,t,r){r.d(t,{p:()=>l});var s=r(65043),n=r(99766),a=r(70579);const l=s.forwardRef((e,t)=>{let{className:r,type:s,...l}=e;return(0,a.jsx)("input",{type:s,className:(0,n.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:t,...l})});l.displayName="Input"},59938(e,t,r){r.d(t,{J:()=>i});var s=r(65043),n=r(65131),a=r(10917),l=r(99766),o=r(70579);const c=(0,a.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),i=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,o.jsx)(n.b,{ref:t,className:(0,l.cn)(c(),r),...s})});i.displayName=n.b.displayName},5943(e,t,r){r.r(t),r.d(t,{default:()=>p});var s=r(65043),n=r(45621),a=r(86213),l=r(13390),o=r(91140),c=r(92264),i=r(59938),d=r(91751),u=r(82054),m=r(22024),f=r(95919),x=r(70579);const h="mcm_fw_play_token",p=()=>{const{shareToken:e}=(0,n.g)(),[t,p]=(0,s.useState)("name"),[g,y]=(0,s.useState)(""),[w,b]=(0,s.useState)(null),[v,N]=(0,s.useState)(!1),[j,k]=(0,s.useState)(null),[C,S]=(0,s.useState)(0),[A,M]=(0,s.use
2State)([]),R=(0,s.useRef)(null),_=(0,s.useRef)(localStorage.getItem(h)||(()=>{const e=crypto.randomUUID();return localStorage.setItem(h,e),e})());(0,s.useEffect)(()=>{(async()=>{N(!0);try{const t=await a.A.get(`/api/findaword/play/${e}`);b(t.data)}catch(r){var t;404===(null===(t=r.response)||void 0===t?void 0:t.status)?k("This puzzle link is no longer active."):k("Could not load puzzle. Please check the link.")}finally{N(!1)}})()},[e]);const $=()=>{g.trim()&&(R.current=Date.now(),p("play"))},P=(0,s.useCallback)(e=>{S(e)},[]),W=(0,s.useCallback)(e=>{M(e)},[]),z=(0,s.useCallback)(async e=>{var t;const s=R.current?Math.round((Date.now()-R.current)/1e3):null,n=(null===w||void 0===w||null===(t=w.content)||void 0===t?void 0:t.words)||[],l=e.length===n.length;try{await a.A.post(`/api/findaword/${w.activity_id}/attempt`,{student_name:g,play_token:_.current,found_words:e,words_total:n.length,completed:l,time_taken_seconds:s})}catch{}p("complete"),l&&(async()=>{try{(0,(await r.e(8838).then(r.bind(r,78838))).default)({particleCount:150,spread:70,origin:{y:.6},useWorker:!0})}catch{}})()},[w,g]);if((0,s.useEffect)(()=>{var e;if("play"!==t)return;const r=(null===w||void 0===w||null===(e=w.content)||void 0===e?void 0:e.words)||[];r.length>0&&A.length===r.length&&z(A)},[A,w,t,z]),v)return(0,x.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,x.jsx)(m.A,{className:"w-8 h-8 animate-spin text-primary"})});if(j)return(0,x.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:(0,x.jsx)(o.Zp,{className:"max-w-md w-full",children:(0,x.jsxs)(o.Wu,{className:"py-12 text-center",children:[(0,x.jsx)(f.A,{className:"w-10 h-10 text-muted-foreground/40 mx-auto mb-4"}),(0,x.jsx)("p",{className:"text-foreground font-medium",children:j})]})})});if(!w)return null;const T=w.content||{},D=T.words||[],F=T.grid||[];var I;return"name"===t?(0,x.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:(0,x.jsxs)(o.Zp,{className:"max-w-md w-full",children:[(0,x.jsxs)(o.aR,{className:"text-center",children:[(0,x.jsx)("div",{className:"mx-auto mb-3 p-3 rounded-full bg-primary/10 w-fit",children:(0,x.jsx)(f.A,{className:"w-8 h-8 text-primary"})}),(0,x.jsx)(o.ZB,{className:"text-xl",children:w.title}),(0,x.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:[w.subject," \xb7 Year ",null===(I=w.year_levels)||void 0===I?void 0:I.join(", ")]})]}),(0,x.jsxs)(o.Wu,{className:"space-y-4",children:[(0,x.jsxs)("div",{className:"space-y-1",children:[(0,x.jsx)(i.J,{htmlFor:"name",children:"Your name"}),(0,x.jsx)(c.p,{id:"name",placeholder:"Enter your name",value:g,onChange:e=>y(e.target.value),onKeyDown:e=>"Enter"===e.key&&$(),autoFocus:!0})]}),(0,x.jsx)(l.$,{className:"w-full bg-primary hover:bg-primary/90 text-primary-foreground",onClick:$,disabled:!g.trim(),children:"Start Word Search"}),(0,x.jsx)("p",{className:"text-xs text-center text-muted-foreground",children:"Created with My Curriculum Mate \xb7 mycurriculummate.com.au"})]})]})}):"complete"===t?(0,x.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:(0,x.jsx)(o.Zp,{className:"max-w-md w-full",children:(0,x.jsxs)(o.Wu,{className:"py-12 text-center",children:[(0,x.jsx)(u.A,{className:"w-16 h-16 text-primary mx-auto mb-4"}),(0,x.jsxs)("h2",{className:"text-2xl font-bold text-foreground",children:["Well done, ",g,"!"]}),(0,x.jsx)("p",{className:"text-muted-foreground mt-2",children:A.length===D.length?"You found all the words!":`You found ${A.length} of ${D.length} words.`}),(0,x.jsxs)("div",{className:"mt-6 p-4 rounded-lg bg-primary/10",children:[(0,x.jsx)("p",{className:"text-sm text-muted-foreground",children:"Words found"}),(0,x.jsxs)("p",{className:"text-3xl font-bold text-primary",children:[C,"%"]})]}),(0,x.jsx)(l.$,{className:"mt-6 w-full bg-primary hover:bg-primary/90 text-primary-foreground",onClick:()=>p("play"),children:"Keep searching"})]})})}):(0,x.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,x.jsxs)("div",{className:"bg-primary text-primary-foreground px-4 py-3 flex items-center gap-3",children:[(0,x.jsx)(f.A,{className:"w-5 h-5 flex-shrink-0"}),(0,x.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,x.jsx)("p",{className:"font-semibold text-sm truncate",children:w.title}),(0,x.jsx)("p",{className:"text-xs opacity-80",children:g})]}),(0,x.jsx)("div",{className:"w-24 h-1.5 rounded-full bg-primary-foreground
2/30 overflow-hidden flex-shrink-0",children:(0,x.jsx)("div",{className:"h-full bg-primary-foreground rounded-full transition-all",style:{width:`${C}%`}})}),(0,x.jsxs)("span",{className:"text-xs font-mono opacity-80 w-10 text-right flex-shrink-0",children:[C,"%"]}),C>0&&C<100&&(0,x.jsx)(l.$,{size:"sm",variant:"secondary",className:"text-xs flex-shrink-0",onClick:()=>z(A),children:"Submit"})]}),(0,x.jsxs)("div",{className:"flex flex-col lg:flex-row gap-4 p-4 max-w-6xl mx-auto",children:[(0,x.jsx)("div",{className:"flex-shrink-0 overflow-auto",children:(0,x.jsx)(d.A,{grid:F,wordList:D,readOnly:!1,onProgress:P,onFoundWordsChange:W})}),(0,x.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,x.jsx)("p",{className:"text-xs font-semibold text-primary uppercase tracking-wide mb-3",children:"Find these words"}),(0,x.jsx)("div",{className:"columns-2 gap-3 text-sm",children:[...D].sort().map(e=>{const t=A.includes(e);return(0,x.jsxs)("div",{className:"mb-2 font-mono font-semibold transition-colors "+(t?"line-through text-muted-foreground":"text-foreground"),children:[t&&(0,x.jsx)("span",{className:"mr-1 text-primary",children:"\u2713"}),e]},e)})}),(0,x.jsx)("p",{className:"text-xs text-muted-foreground mt-4",children:"Click and drag to select a word in any direction \u2014 horizontal, vertical, or diagonal."})]})]})]})}},82054(e,t,r){r.d(t,{A:()=>s});const s=(0,r(77784).A)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},95919(e,t,r){r.d(t,{A:()=>s});const s=(0,r(77784).A)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]])},22024(e,t,r){r.d(t,{A:()=>s});const s=(0,r(77784).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},65131(e,t,r){r.d(t,{b:()=>c});var s=r(65043),n=(r(97950),r(16851)),a=r(70579),l=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const r=(0,n.TL)(`Primitive.${t}`),l=s.forwardRef((e,s)=>{const{asChild:n,...l}=e,o=n?r:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,a.jsx)(o,{...l,ref:s})});return l.displayName=`Primitive.${t}`,{...e,[t]:l}},{});var o=s.forwardRef((e,t)=>(0,a.jsx)(l.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));o.displayName="Label";var c=o}}]); 3//# sourceMappingURL=5943.9ad0f5c9.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.