(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6973],{56564:function(e,r,t){"use strict";t.d(r,{Z:function(){return I}});var n=t(71383),a=t(63366),i=t(87462),o=t(67294),s=t(86010),c=t(94780),l=t(70917),u=t(79566),d=t(27048),h=t(80179),f=t(1588),m=t(34867);function v(e){return(0,m.Z)("MuiCircularProgress",e)}(0,f.Z)("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);var p,k,b,x,g,_,Z,S,w=t(85893),y=["className","color","disableShrink","size","style","thickness","value","variant"],j=function(e){return e},C=(0,l.F4)(g||(g=j(p||(p=(0,n.Z)(["\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n"]))))),P=(0,l.F4)(_||(_=j(k||(k=(0,n.Z)(["\n 0% {\n stroke-dasharray: 1px, 200px;\n stroke-dashoffset: 0;\n }\n\n 50% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -15px;\n }\n\n 100% {\n stroke-dasharray: 100px, 200px;\n stroke-dashoffset: -125px;\n }\n"]))))),N=function(e){var r=e.classes,t=e.variant,n=e.color,a=e.disableShrink,i={root:["root",t,"color".concat((0,u.Z)(n))],svg:["svg"],circle:["circle","circle".concat((0,u.Z)(t)),a&&"circleDisableShrink"]};return(0,c.Z)(i,v,r)},E=(0,h.ZP)("span",{name:"MuiCircularProgress",slot:"Root",overridesResolver:function(e,r){var t=e.ownerState;return[r.root,r[t.variant],r["color".concat((0,u.Z)(t.color))]]}})(function(e){var r=e.ownerState,t=e.theme;return(0,i.Z)({display:"inline-block"},"determinate"===r.variant&&{transition:t.transitions.create("transform")},"inherit"!==r.color&&{color:(t.vars||t).palette[r.color].main})},function(e){return"indeterminate"===e.ownerState.variant&&(0,l.iv)(Z||(Z=j(b||(b=(0,n.Z)(["\n animation: "," 1.4s linear infinite;\n "])),0)),C)}),z=(0,h.ZP)("svg",{name:"MuiCircularProgress",slot:"Svg",overridesResolver:function(e,r){return r.svg}})({display:"block"}),D=(0,h.ZP)("circle",{name:"MuiCircularProgress",slot:"Circle",overridesResolver:function(e,r){var t=e.ownerState;return[r.circle,r["circle".concat((0,u.Z)(t.variant))],t.disableShrink&&r.circleDisableShrink]}})(function(e){var r=e.ownerState,t=e.theme;return(0,i.Z)({stroke:"currentColor"},"determinate"===r.variant&&{transition:t.transitions.create("stroke-dashoffset")},"indeterminate"===r.variant&&{strokeDasharray:"80px, 200px",strokeDashoffset:0})},function(e){var r=e.ownerState;return"indeterminate"===r.variant&&!r.disableShrink&&(0,l.iv)(S||(S=j(x||(x=(0,n.Z)(["\n animation: "," 1.4s ease-in-out infinite;\n "])),0)),P)}),I=o.forwardRef(function(e,r){var t=(0,d.Z)({props:e,name:"MuiCircularProgress"}),n=t.className,o=t.color,c=t.disableShrink,l=t.size,u=void 0===l?40:l,h=t.style,f=t.thickness,m=void 0===f?3.6:f,v=t.value,p=void 0===v?0:v,k=t.variant,b=void 0===k?"indeterminate":k,x=(0,a.Z)(t,y),g=(0,i.Z)({},t,{color:void 0===o?"primary":o,disableShrink:void 0!==c&&c,size:u,thickness:m,value:p,variant:b}),_=N(g),Z={},S={},j={};if("determinate"===b){var C=2*Math.PI*((44-m)/2);Z.strokeDasharray=C.toFixed(3),j["aria-valuenow"]=Math.round(p),Z.strokeDashoffset="".concat(((100-p)/100*C).toFixed(3),"px"),S.transform="rotate(-90deg)"}return(0,w.jsx)(E,(0,i.Z)({className:(0,s.Z)(_.root,n),style:(0,i.Z)({width:u,height:u},S,h),ownerState:g,ref:r,role:"progressbar"},j,x,{children:(0,w.jsx)(z,{className:_.svg,ownerState:g,viewBox:"".concat(22," ").concat(22," ").concat(44," ").concat(44),children:(0,w.jsx)(D,{className:_.circle,style:Z,ownerState:g,cx:44,cy:44,r:(44-m)/2,fill:"none",strokeWidth:m})})}))})},96271:function(e,r,t){"use strict";t.r(r),t.d(r,{__N_SSG:function(){return g}});var n=t(50029),a=t(64687),i=t.n(a),o=t(67294),s=t(60337),c=t(35647),l=t(62378),u=t(55245),d=t(69186),h=t(9460),f=t(56564),m=t(12552),v=t(39696),p=t(81496),k=t(61202),b=t(11163),x=t(85893),g=!0;r.default=function(){(0,v.XK)().classes;var e,r=(0,m.$G)("common").t,t=(0,b.useRouter)(),a=(0,o.useState)(""),g=a[0],_=a[1],Z=(0,o.useState)(""),S=Z[0],w=Z[1],y=(0,o.useState)(!1),j=y[0],C=y[1],P=(0,o.useState)(""),N=P[0],E=P[1],z=(0,o.useState)(""),D=z[0],I=z[1],T=(0,o.useState)(""),M=T[0],R=T[1],$=(0,o.useState)(!1),W=$[0],O=$[1],A=(e=(0,n.Z)(i().mark(function e(n){var a,o,s,c;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n.preventDefault(),C(!0),E(""),I(""),R(""),S){e.next=9;break}return I(r("ticket_number_required")),C(!1),e.abrupt("return");case 9:if(W){e.next=13;break}return I(r("ticket_number_format_hint")),C(!1),e.abrupt("return");case 13:if(e.prev=13,a=localStorage.getItem("token")){e.next=17;break}throw Error("请先登录");case 17:return e.prev=17,o=(0,k.o)(a).user_id,e.next=22,fetch("".concat("/api","/ticket/sync"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(a)},body:JSON.stringify({secret_key:g,user_id:o})});case 22:if((s=e.sent).ok){e.next=28;break}return e.next=26,s.json();case 26:throw Error(e.sent.message||r("error_redeem_failed"));case 28:return e.next=30,s.json();case 30:c=e.sent,R("".concat(r("redeem_success")," - ").concat(c.event_name," ").concat(c.name)),_(""),w(""),setTimeout(function(){t.push("/profile")},3e3),e.next=41;break;case 37:throw e.prev=37,e.t0=e.catch(17),console.error("Token decode error:",e.t0),Error("Token 解析失败");case 41:e.next=46;break;case 43:e.prev=43,e.t1=e.catch(13),E(e.t1.message||r("error_redeem_process"));case 46:return e.prev=46,C(!1),e.finish(46);case 49:case"end":return e.stop()}},e,null,[[13,43,46,49],[17,37]])})),function(r){return e.apply(this,arguments)});return(0,x.jsx)(p.Z,{title:r("redeem_title"),subtitle:r("redeem_subtitle"),children:(0,x.jsx)(s.Z,{maxWidth:"sm",children:(0,x.jsx)(l.Z,{py:8,children:(0,x.jsxs)(c.ZP,{container:!0,spacing:3,children:[(0,x.jsxs)(c.ZP,{item:!0,xs:12,children:[(0,x.jsx)(u.Z,{variant:"h4",align:"center",gutterBottom:!0,children:r("redeem_title")}),(0,x.jsx)(u.Z,{variant:"body1",align:"center",paragraph:!0,children:r("redeem_desc")})]}),(0,x.jsx)(c.ZP,{item:!0,xs:12,children:(0,x.jsxs)("form",{onSubmit:A,children:[(0,x.jsx)(d.Z,{fullWidth:!0,variant:"outlined",label:r("ticket_number_label"),value:S,onChange:function(e){var t=e.target.value;(w(t),t)?/^[a-zA-Z]+\d+[a-zA-Z]+\d+$/.test(t)?(I(""),O(!0)):(I(r("ticket_number_format_hint")),O(!1)):(I(r("ticket_number_required")),O(!1))},error:!!D,disabled:j,required:!0,sx:{mb:3}}),(0,x.jsx)(d.Z,{fullWidth:!0,variant:"outlined",label:r("redeem_code_label"),value:g,onChange:function(e){return _(e.target.value)},error:!!N,helperText:N,disabled:j,sx:{mb:3}}),M&&(0,x.jsx)(u.Z,{color:"primary",align:"center",sx:{mb:2},children:M}),(0,x.jsx)(h.Z,{fullWidth:!0,size:"large",variant:"contained",color:"primary",type:"submit",disabled:!g||!S||!W||j,sx:{mb:2},children:j?(0,x.jsx)(f.Z,{size:24}):r("redeem_submit")}),(0,x.jsx)(h.Z,{fullWidth:!0,size:"large",variant:"outlined",onClick:function(){return t.back()},children:r("btn_back")})]})})]})})})})}},3345:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/[locale]/redeem-ticket",function(){return t(96271)}])},61202:function(e,r,t){"use strict";t.d(r,{o:function(){return a}});class n extends Error{}function a(e,r){let t;if("string"!=typeof e)throw new n("Invalid token specified: must be a string");r||(r={});let a=!0===r.header?0:1,i=e.split(".")[a];if("string"!=typeof i)throw new n(`Invalid token specified: missing part #${a+1}`);try{t=function(e){let r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw Error("base64 string is not of the correct length")}try{var t;return t=r,decodeURIComponent(atob(t).replace(/(.)/g,(e,r)=>{let t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t}))}catch(e){return atob(r)}}(i)}catch(e){throw new n(`Invalid token specified: invalid base64 for part #${a+1} (${e.message})`)}try{return JSON.parse(t)}catch(e){throw new n(`Invalid token specified: invalid json for part #${a+1} (${e.message})`)}}n.prototype.name="InvalidTokenError"}},function(e){e.O(0,[7369,2703,5185,9186,1496,2888,9774,179],function(){return e(e.s=3345)}),_N_E=e.O()}]);