1import{aS as v,aR as w,a8 as C,P as E,af as e,ac as z}from"./index-B3RcUG2d.js";import{l as o}from"./vendor-charts-CCORyT6D.js";import"./vendor-supabase-CD_YAFfX.js";import"./vendor-katex-Cwc2KRvW.js";const i="3px solid #000",p="4px 4px 0 #000",R="#FFD93D",W="#FF6B6B",D="#C4B5FD",L={invalid_code:"æ¾ä¸å°éçµéé碼",already_used:"éçµééç¢¼å·²è¢«ä½¿ç¨æå·²éæ",need_login:"è«å
ç»å
¥"};function P(){const[,u]=v(),{login:a}=w(),[n,m]=o.useState(""),[x,g]=o.useState(!1),[r,s]=o.useState(null),[S,b]=o.useState(!1),[y,k]=o.useState(3),f=o.useCallback(async()=>{const t=n.trim().toUpperCase();if(t.length<6){s({text:"ééç¢¼æ ¼å¼ä¸æ£ç¢º",ok:!1});return}g(!0),s(null);try{const{data:l,error:h}=await C().rpc("redeem_activation",{p_code:t});if(h)throw h;const d=String(l);if(d==="ok"){b(!0),sessionStorage.setItem(E,"/teacher");let c=3;const j=window.setInterval(()=>{c-=1,k(c),c<=0&&(window.clearInterval(j),a())},1e3)}else s({text:L[d]??d,ok:!1})}catch(l){console.warn("[RedeemPage]",l),s({text:"å
æå¤±æï¼è«ç¨å¾å試",ok:!1})}finally{g(!1)}},[n,a]);return e.jsxs("div",{style:{maxWidth:480,margin:"0 auto",padding:"20px 20px calc(128px + env(safe-area-inset-bottom))"},children:[e.jsx("button",{onClick:()=>u("/"),style:{border:"none",background:"none",fontSize:"14px",fontWeight:700,color:"#555",padding:"0 0 16px",cursor:"pointer"},children:"â åé¦é "}),e.jsx("p",{style:{fontSize:"24px",fontWeight:900,margin:"0 0 8px"},children:"è師éé"}),e.jsx("p",{style:{fontSize:"14px",color:"#555",margin:"0 0 24px",lineHeight:1.6},children:"輸å
¥ç³è«éé徿¶å°çéé碼ï¼å³å¯åç¨è師åè½ã"}),S?e.jsxs("div",{style:{border:i,boxShadow:p,background:D,padding:24,textAlign:"center"},children:[e.jsx("p",{style:{fontSize:"20px",fontWeight:900,margin:0},children:"ééæå ð"}),e.jsxs("p",{style:{fontSize:"14px",margin:"10px 0 0",lineHeight:1.6},children:[y," ç§å¾å°èªåéæ°ç»å
¥ï¼",e.jsx("br",{}),"å®æå¾æç´æ¥é²å
¥è師端ã"]}),e.jsx("button",{onClick:a,style:{marginTop:16,border:i,boxShadow:"3px 3px 0 #000",background:"#fff",fontSize:"14px",fontWeight:900,padding:"10px 18px",cursor:"pointer"},children:"é²å
¥è師端 â"})]}):z()?e.jsxs("div",{style:{border:i,boxShadow:p,background:"#fff",padding:20},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsx("input",{value:n,onChange:t=>m(t.target.value.toUpperCase().slice(0,20)),onKeyDown:t=>{t.key==="Enter"&&!t.nativeEvent.isComposing&&f()},placeholder:"TRIAL-XXXXXX",autoCapitalize:"characters",autoCorrect:"off",spellCheck:!1,style:{flex:1,minWidth:0,border:i,padding:"12px 14px",fontSize:"16px",fontWeight:900,letterSpacing:"2px",textAlign:"center",outline:"none"}}),e.jsx("button",{onClick:()=>{f()},disabled:x||n.trim().length<6,style:{flexShrink:0,border:i,boxShadow:"3px 3px 0 #000",background:n.trim().length>=6?R:"#eee",fontSize:"15px",fontWeight:900,padding:"12px 18px",cursor:x||n.trim().length<6?"not-allowed":"pointer"},children:"éé"})]}),r&&e.jsx("p",{style:{fontSize:"14px",fontWeight:700,marginTop:14,marginBottom:0,color:r.ok?"#000":W},children:r.text})]}):e.jsxs("div",{style:{border:i,boxShadow:p,background:"#fff",padding:20},children:[e.jsx("p",{style:{fontSize:"15px",fontWeight:900,margin:0},children:"è«å
ç¨ LINE ç»å
¥"}),e.jsx("p",{style:{fontSize:"13px",color:"#666",margin:"8px 0 0"},children:"ç»å
¥å¾åå°éåé é¢å³å¯è¼¸å
¥éé碼ã"})]})]})}export{P as default};
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.