"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[788],{3745:(e,t,o)=>{o.d(t,{FH:()=>h,UJ:()=>a,iD:()=>r,ki:()=>i});let n="https://api.aitrading.coach";class a extends Error{constructor(e,t){super((Array.isArray(t.message)?t.message.join("; "):t.message)||"HTTP ".concat(e)),this.status=e,this.body=t,this.name="ApiException"}}let s=null,c=null;function i(e){s=e}function r(){return s}async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{method:o="GET",body:a,signal:c,noRefresh:i,authenticated:r=!0}=t,l={};void 0!==a&&(l["Content-Type"]="application/json"),r&&s&&(l.Authorization="Bearer ".concat(s));let h=await fetch("".concat(n).concat(e),{method:o,headers:l,body:void 0===a?void 0:JSON.stringify(a),credentials:"include",signal:c});if(401===h.status&&r&&!i){let t=await d();if(t)return l.Authorization="Bearer ".concat(t),u(await fetch("".concat(n).concat(e),{method:o,headers:l,body:void 0===a?void 0:JSON.stringify(a),credentials:"include",signal:c}))}return u(h)}async function u(e){let t=await e.text(),o=t?JSON.parse(t):null;if(!e.ok){var n;let s=null!==(n=null==o?void 0:o.error)&&void 0!==n?n:{code:"unknown",message:t||e.statusText,statusCode:e.status};throw new a(e.status,s)}return o}async function d(){return c||(c=(async()=>{try{let e=await l("/v1/auth/refresh",{method:"POST",noRefresh:!0,authenticated:!1});return s=e.accessToken,e.accessToken}catch(e){return s=null,null}finally{c=null}})())}let h={signup:e=>l("/v1/auth/signup",{method:"POST",body:e,authenticated:!1}),verifyEmail:e=>l("/v1/auth/verify-email",{method:"POST",body:e,authenticated:!1}),login:e=>l("/v1/auth/login",{method:"POST",body:e,authenticated:!1}),refresh:()=>l("/v1/auth/refresh",{method:"POST",noRefresh:!0,authenticated:!1}),logout:()=>l("/v1/auth/logout",{method:"POST",noRefresh:!0,authenticated:!1}),forgot:e=>l("/v1/auth/forgot",{method:"POST",body:e,authenticated:!1}),reset:e=>l("/v1/auth/reset",{method:"POST",body:e,authenticated:!1}),enroll2fa:()=>l("/v1/auth/2fa/enroll",{method:"POST"}),verify2fa:e=>l("/v1/auth/2fa/verify",{method:"POST",body:e}),me:()=>l("/v1/auth/me"),redeemHandover:e=>l("/v1/auth/handover/".concat(encodeURIComponent(e)),{method:"POST",authenticated:!1,noRefresh:!0}),googleSigninUrl:()=>"".concat(n,"/v1/auth/google"),health:()=>l("/v1/health",{authenticated:!1,noRefresh:!0})}},1069:(e,t,o)=>{o.d(t,{A:()=>r,AuthProvider:()=>i});var n=o(5155),a=o(2115),s=o(3745);let c=(0,a.createContext)(null);function i(e){let{children:t}=e,[o,i]=(0,a.useState)({status:"loading",user:null}),r=(0,a.useCallback)(async()=>{try{let{accessToken:e}=await s.FH.refresh();(0,s.ki)(e);let t=await s.FH.me();i({status:"authenticated",user:t})}catch(e){(0,s.ki)(null),i({status:"anonymous",user:null})}},[]);(0,a.useEffect)(()=>{r()},[r]);let l=(0,a.useCallback)(async e=>{let t=await s.FH.login(e);if("requiresTwoFactor"in t&&t.requiresTwoFactor)return{requiresTwoFactor:!0};if(!("accessToken"in t))throw new s.UJ(500,{code:"unexpected",message:"Login response missing access token",statusCode:500});return(0,s.ki)(t.accessToken),i({status:"authenticated",user:await s.FH.me()}),{}},[]),u=(0,a.useCallback)(async e=>{await s.FH.signup(e),i({status:"anonymous",user:null})},[]),d=(0,a.useCallback)(async()=>{try{await s.FH.logout()}finally{(0,s.ki)(null),i({status:"anonymous",user:null})}},[]),h=(0,a.useMemo)(()=>({...o,login:l,signup:u,logout:d,refresh:r}),[o,l,u,d,r]);return(0,n.jsx)(c.Provider,{value:h,children:t})}function r(){let e=(0,a.useContext)(c);if(!e)throw Error("useAuth must be used inside ");return e}},6288:(e,t,o)=>{o.d(t,{ES:()=>p,Jm:()=>v,Od:()=>s,Y2:()=>y,Yq:()=>m,a6:()=>f,e8:()=>d,hR:()=>h,nR:()=>T,z3:()=>g});var n=o(3745);let a="https://api.aitrading.coach";class s extends n.UJ{constructor(e,t,o){super(e,t),this.retryAfterSeconds=o,this.name="ToolApiException"}}async function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{method:o="GET",body:s,signal:c}=t,i=async t=>{let n={};return void 0!==s&&(n["Content-Type"]="application/json"),t&&(n.Authorization="Bearer ".concat(t)),fetch("".concat(a).concat(e),{method:o,headers:n,body:void 0===s?void 0:JSON.stringify(s),credentials:"include",signal:c})},r=await i((0,n.iD)());if(401===r.status){let e=await l();e&&(r=await i(e))}return u(r)}async function i(e,t,o){let s=async n=>{let s={};n&&(s.Authorization="Bearer ".concat(n));let c=new FormData;return c.append("file",t,t.name),fetch("".concat(a).concat(e),{method:"POST",headers:s,body:c,credentials:"include",signal:o})},c=await s((0,n.iD)());if(401===c.status){let e=await l();e&&(c=await s(e))}return u(c)}async function r(e,t,o,s){let c=async n=>{let c={};n&&(c.Authorization="Bearer ".concat(n));let i=new FormData;for(let[e,n]of(i.append("file",t,t.name),Object.entries(o)))i.append(e,n);return fetch("".concat(a).concat(e),{method:"POST",headers:c,body:i,credentials:"include",signal:s})},i=await c((0,n.iD)());if(401===i.status){let e=await l();e&&(i=await c(e))}return u(i)}async function l(){try{let e=await fetch("".concat(a,"/v1/auth/refresh"),{method:"POST",credentials:"include"});if(!e.ok)return(0,n.ki)(null),null;let t=await e.json();return(0,n.ki)(t.accessToken),t.accessToken}catch(e){return(0,n.ki)(null),null}}async function u(e){let t=await e.text(),o=t?JSON.parse(t):null;if(!e.ok){var n;let a=null!==(n=null==o?void 0:o.error)&&void 0!==n?n:{code:"unknown",message:t||e.statusText,statusCode:e.status},c=e.headers.get("Retry-After"),i=c&&/^\d+$/.test(c)?parseInt(c,10):null;throw new s(e.status,a,i)}return o}let d={create:e=>c("/v1/tools",{method:"POST",body:e}),listMine:e=>c("/v1/tools/mine",{signal:e}),listSubscribed:e=>c("/v1/tools/subscribed",{signal:e}),getOne:(e,t)=>c("/v1/tools/".concat(encodeURIComponent(e)),{signal:t}),update:(e,t)=>c("/v1/tools/".concat(encodeURIComponent(e)),{method:"PATCH",body:t}),archive:e=>c("/v1/tools/".concat(encodeURIComponent(e)),{method:"DELETE"}),createSession:()=>c("/v1/tools/skill-creation/sessions",{method:"POST"}),getSession:(e,t)=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e)),{signal:t}),abandonSession:e=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e)),{method:"DELETE"}),removeAttachment:(e,t)=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/attachments/").concat(encodeURIComponent(t)),{method:"DELETE"}),uploadAttachment:(e,t,o)=>i("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/upload"),t,o),nextQuestion:e=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/question"),{method:"POST"}),submitAnswer:(e,t)=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/answer"),{method:"POST",body:t}),recomputeConfidence:e=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/recompute-confidence"),{method:"POST"}),generateSkill:e=>c("/v1/tools/skill-creation/sessions/".concat(encodeURIComponent(e),"/generate"),{method:"POST"}),uploadToolCover:(e,t,o)=>i("/v1/tools/".concat(encodeURIComponent(e),"/cover-image"),t,o),deleteToolCover:e=>c("/v1/tools/".concat(encodeURIComponent(e),"/cover-image"),{method:"DELETE"}),addToolGalleryImage(e,t,o,n){let a={};return void 0!==o&&(a.caption=o),r("/v1/tools/".concat(encodeURIComponent(e),"/gallery"),t,a,n)},patchToolGalleryImage:(e,t,o)=>c("/v1/tools/".concat(encodeURIComponent(e),"/gallery/").concat(encodeURIComponent(t)),{method:"PATCH",body:o}),deleteToolGalleryImage:(e,t)=>c("/v1/tools/".concat(encodeURIComponent(e),"/gallery/").concat(encodeURIComponent(t)),{method:"DELETE"})},h=0x1900000,m=["application/pdf","text/markdown","text/plain","image/png","image/jpeg","image/webp","audio/mpeg","video/mp4"],f=["rect","hline","vline","trendline","fibo","channel","triangle","ellipse","andrews_pitchfork","gann_grid","text","arrow"],p=["red","green","blue","yellow","cyan","magenta","white"],v="atc:tool-builder:session-id";function y(e){return!Number.isFinite(e)||e<0?"$0.00":"$".concat((e/100).toFixed(2))}function g(e){return e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")}function T(e){return e>=.95?"high":e>=.5?"mid":"low"}}}]);