1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3738],{2537:function(e,n,i){(window.__NEXT_P=window.__NEXT_P||[]).push(["/desktop/authorize",function(){return i(99140)}])},99140:function(e,n,i){"use strict";i.r(n),i.d(n,{__N_SSP:function(){return g}});var t=i(85893),o=i(11163),s=i(25675),a=i.n(s),r=i(67294),c=i(64719),l=i(62228),d=i(86920),u=i(18502),h=i(7269),p=i.n(h);const _={title:d.jY?"Continue to WeShop Desktop":"ç»§ç»ä½¿ç¨ WeShop æ¡é¢ç",signedInAs:d.jY?"Signed in as":"å½åç»å½è´¦å·",permission:d.jY?"WeShop Desktop will be able to read your account profile and use WeShop generation and AI model services on your behalf.":"WeShop æ¡é¢çå°å¯ä»¥è¯»åä½ çè´¦å·ä¿¡æ¯ï¼å¹¶ä»¥ä½ çèº«ä»½ä½¿ç¨ WeShop çæä¸ AI 模åæå¡ã",continue:d.jY?"Continue":"ç»§ç»",returning:d.jY?"Returning to WeShop Desktopâ¦":"æ£å¨è¿å WeShop æ¡é¢çâ¦",cancel:d.jY?"Cancel":"åæ¶",loading:d.jY?"Preparing secure authorizationâ¦":"æ£å¨åå¤å®å
¨ææâ¦",retry:d.jY?"Try again":"éè¯",invalid:d.jY?"This authorization request is invalid or has expired.":"è¿ä¸ªææè¯·æ±æ ææå·²ç»è¿æã"};function m(e){return Array.isArray(e)?e[0]:e}var g=!0;n.default=()=>{const e=(0,o.useRouter)(),{userInfos:[n,i],powerBalanceAmount:[,s]}=(0,l.b)(),[h,g]=(0,r.useState)("initializing"),[v,j]=(0,r.useState)(null),[f,w]=(0,r.useState)(""),[S,x]=(0,r.useState)(!1),y=(0,r.useRef)(""),k=(0,r.useRef)(!1),z=async()=>{if(!e.isReady)return;const n=new URLSearchParams;for(const i of["client_id","redirect_uri","state","code_challenge","code_challenge_method","scope"]){const t=m(e.query[i]);t&&n.set(i,t)}const t=n.toString();if(t&&y.current!==t){y.current=t,g("initializing"),w("");try{var o;const e=await fetch("".concat(d._n,"/v1/desktop/oauth/authorize/context?").concat(t),{credentials:"include",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(_.invalid);const n=await e.json();j(n),window.sessionStorage.setItem("weshop.desktop.interaction",n.interaction_id);const a=await(0,u.PR)({noLogin:!0,noShowToast:!0});a.success&&(null===(o=a.data)||void 0===o?void 0:o.uid)&&!1===a.data.freeTry?(i(a.data),s(a.data.powerBalanceAmount),g("confirm")):g("login")}catch(e){w(e instanceof Error?e.message:_.invalid),g("error")}}};(0,r.useEffect)(()=>{z()},[e.isReady]);const N=async()=>{var e;const n=await(0,u.PR)({noLogin:!0,noShowToast:!0});if(!n.success||!(null===(e=n.data)||void 0===e?void 0:e.uid)||!1!==n.data.freeTry)return w(_.invalid),void g("error");i(n.data),s(n.data.powerBalanceAmount),g("confirm")};return"login"===h?(0,t.jsx)("main",{className:p().loginShell,children:(0,t.jsx)(c.Z,{isModal:!1,shouldSkip:!0,source:"desktopAuthorize",onSignIn:()=>{N()},onWorkspace:()=>{N()}})}):(0,t.jsx)("main",{className:p().shell,children:(0,t.jsxs)("section",{className:p().card,"aria-live":"polite",children:[(0,t.jsx)(a(),{src:"/weshop_logo_login.svg",width:56,height:56,alt:d.cg,unoptimized:!0}),"initializing"===h?(0,t.jsxs)("div",{className:p().status,children:[(0,t.jsx)("span",{className:p().spinner,"aria-hidden":!0}),(0,t.jsx)("h1",{children:_.loading})]}):null,"error"===h?(0,t.jsxs)("div",{className:p().status,children:[(0,t.jsx)("h1",{children:_.invalid}),(0,t.jsx)("p",{children:f}),(0,t.jsx)("button",{type:"button",className:p().primary,onClick:()=>{y.current="",z()},children:_.retry})]}):null,"confirm"===h&&v?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:p().heading,children:[(0,t.jsx)("h1",{children:_.title}),(0,t.jsx)("p",{children:_.permission})]}),(0,t.jsxs)("div",{className:p().account,children:[(0,t.jsx)("span",{children:_.signedInAs}),(0,t.jsx)("strong",{children:(null==n?void 0:n.email)||(null==n?void 0:n.phoneNumber)||(null==n?void 0:n.uid)})]}),(0,t.jsxs)("form",{method:"post",action:"".concat(d._n,"/v1/desktop/oauth/authorize/complete"),onSubmit:e=>{k.current?e.preventDefault():(k.current=!0,x(!0),window.sessionStorage.removeItem("weshop.desktop.interaction"))},children:[(0,t.jsx)("input",{type:"hidden",name:"interaction_id",value:v.interaction_id}),(0,t.jsx)("input",{type:"hidden",name:"csrf_token",value:v.csrf_token}),(0,t.jsxs)("div",{className:p().actions,children:[(0,t.jsx)("button",{type:"button",className:p().secondary,onClick:()=>
1{if(!(null==v?void 0:v.redirect_uri))return w(_.invalid),void g("error");const e=new URL(v.redirect_uri);e.searchParams.set("error","access_denied"),v.state&&e.searchParams.set("state",v.state),window.sessionStorage.removeItem("weshop.desktop.interaction"),window.location.assign(e.toString())},children:_.cancel}),(0,t.jsx)("button",{type:"submit",className:p().primary,disabled:S,children:S?_.returning:_.continue})]})]})]}):null]})})}},7269:function(e){e.exports={shell:"authorize_shell__5LDJI",loginShell:"authorize_loginShell__TStH9",card:"authorize_card__JnxWt",heading:"authorize_heading__YrIG1",status:"authorize_status__QiL5y",account:"authorize_account__d_jW2",actions:"authorize_actions__sg5PH",primary:"authorize_primary__bBDP_",secondary:"authorize_secondary__7uwWe",spinner:"authorize_spinner__D6s66",spin:"authorize_spin__Cp325"}}},function(e){e.O(0,[9774,2888,179],function(){return n=2537,e(e.s=n);var n});var n=e.O();_N_E=n}]);
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.