
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0d923ea2-e946-59e2-816f-4b7a605e72d4")}catch(e){}}();
import{r as d,a as N,u as k}from"./index-D6da9p6-.js";import{j as e}from"./jsx-runtime-BjG_zV1W.js";import{_ as F}from"./index-CqJN8iQq.js";import{u as $}from"./useIsLoggedIn-BA0Ud5Qu.js";import{u as S}from"./useToast-DK42uF07.js";import{c as T,L as w,u as j}from"./components-1fH5YjVo.js";import{u as b}from"./useTranslation-CfKJAmGY.js";import{L}from"./LoginWithPasswordAction-CTGTbo_j.js";import{T as u}from"./index-BdpAPpdN.js";import{I as M}from"./Image-ycA_AFLr.js";import{_ as g}from"./dialog-Bw_il7y1.js";import{F as y}from"./XMarkIcon-DGYkrnTx.js";import{q as x}from"./transition-jWlQb9Jg.js";const P=s=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s),z=({allowSignup:s=!0,onSuccess:r})=>{const[a,t]=d.useState(""),o=$(),n=T(),m=n.data,i=n.state==="submitting",{t:l}=b();if(d.useEffect(()=>{localStorage.removeItem("signup_redirects")},[]),S(m?.toast,r),o)return null;const h=()=>{const c=new FormData;if(!P(a))return F.error("Please enter a valid email address");c.set("email",a),c.set("login_error_message",`${l("errors.default")} ${l("errors.try_later")}`),c.set("login_success_message",`${l("toast.login_link.message")}`),c.set("redirect_to",window?.location?.href),c.set("request_magic_link","true"),n.submit(c,{method:"post",action:"/login"})};return e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"flex flex-col items-center rounded-lg bg-[#F9FAFB] p-1 sm:flex-row",children:[e.jsx("input",{type:"text",name:"login_email",autoComplete:"email",autoFocus:!0,value:a,onChange:c=>t(c.target.value),placeholder:l("subscribe.email_placeholder")||"",className:"block w-full flex-[2] border-none bg-transparent text-lg font-normal text-black placeholder:text-lg focus:text-lg focus:outline-none",required:!0}),e.jsx("button",{type:"button",onClick:h,className:"wt-button-font block h-full w-full flex-[1] cursor-pointer rounded-lg border border-transparent bg-wt-primary px-5 py-3 text-lg font-semibold text-wt-text-on-primary transition duration-200",disabled:i,children:l(i?"login.magic_link_sending":"login.send_magic_link")})]}),s&&e.jsxs("div",{className:"text-md mt-2",children:[e.jsxs("span",{className:"opacity-75",children:[l("login.sign_up_label")," "]}),e.jsx(w,{to:"/subscribe",className:"inline-flex justify-center underline",children:l("shared.cta.sign_up")})]})]})};function C({title:s,titleId:r,...a},t){return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":r},a),s?d.createElement("title",{id:r},s):null,d.createElement("path",{fillRule:"evenodd",d:"M12.516 2.17a.75.75 0 0 0-1.032 0 11.209 11.209 0 0 1-7.877 3.08.75.75 0 0 0-.722.515A12.74 12.74 0 0 0 2.25 9.75c0 5.942 4.064 10.933 9.563 12.348a.749.749 0 0 0 .374 0c5.499-1.415 9.563-6.406 9.563-12.348 0-1.39-.223-2.73-.635-3.985a.75.75 0 0 0-.722-.516l-.143.001c-2.996 0-5.717-1.17-7.734-3.08Zm3.094 8.016a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const H=d.forwardRef(C),E=({isOpen:s,onClose:r,children:a,title:t,description:o,publication:n,alternativeAction:m})=>{const i=!!n?.has_subscription_password;return e.jsx(x,{appear:!0,show:s,as:d.Fragment,children:e.jsxs(g,{as:"div",onClose:r,children:[e.jsx(x.Child,{as:d.Fragment,enter:"ease-out duration-50",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-50",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:e.jsx("div",{className:"fixed inset-0 bottom-0 left-0 z-20 bg-black/60"})}),e.jsx(x.Child,{as:d.Fragment,enter:"ease-out duration-100",enterFrom:"transform sm:translate-y-0 translate-y-1/2 opacity-0",enterTo:"transform translate-y-0 opacity-100",leave:"ease-in duration-100",leaveFrom:"transform translate-y-0 opacity-100",leaveTo:"transform sm:translate-y-0 translate-y-1/2 opacity-0",children:e.jsx("div",{className:"fixed inset-0 bottom-0 left-0 z-40 flex items-end overflow-y-auto sm:items-center",children:e.jsx(g.Panel,{className:"relative mx-auto flex w-full max-w-none transform justify-center overflow-auto rounded-t-wt bg-wt-background text-left align-middle transition-all sm:max-w-xl sm:rounded-wt",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"relative p-6",children:[e.jsx("div",{className:"absolute right-6",children:e.jsx("button",{"aria-label":"Close",className:"flex h-6 w-6 items-center justify-center rounded-wt transition-all hover:bg-black/5",onClick:r,children:e.jsx(y,{className:"h-5 w-5 stroke-1 text-gray-400 transition-all hover:text-gray-700"})})}),e.jsx("div",{className:"",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"mx-auto h-12 w-12 overflow-hidden rounded-wt",children:e.jsx(M,{className:"h-full w-full rounded-wt object-contain",src:n?.logo?.thumb?.url||"",alt:`${t} logo`,aspectRatio:"square",maxWidth:200})}),i?e.jsx(u,{as:"h2",size:"xl",type:"title",weight:"medium",theme:"default",className:"mt-6 break-words text-center",children:t}):e.jsxs(e.Fragment,{children:[e.jsx(u,{as:"h4",size:"2xl",theme:"content",className:"mt-6 text-center",children:t}),e.jsx(u,{as:"p",size:"lg",theme:"content",weight:"regular",className:"font-regular mt-4 text-center",children:o})]})]})}),e.jsx("div",{className:"mt-6",children:a})]}),m&&e.jsx("div",{className:"border-t p-6 text-center",children:m})]})})})})]})})},K=({isOpen:s,handleCloseModal:r,publication:a})=>{const{t}=b(),o=!!a?.has_subscription_password;return e.jsx(E,{title:t("shared.cta.login_to_pub",{name:a.name}),description:`${t("nav.description")}`,isOpen:s,onClose:r,publication:a,alternativeAction:a.private?"":e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between",children:[e.jsxs(u,{as:"p",size:"xs",type:"body",theme:"default",children:[t("login.sign_up_label")," ",e.jsx(w,{to:"/subscribe",className:"underline",children:e.jsx(u,{as:"span",size:"xs",type:"body",weight:"bold",theme:"default",children:t("shared.cta.sign_up")})})]}),o&&e.jsxs(u,{as:"p",size:"xs",type:"body",theme:"default",className:"",children:[t("login.first_time_message")," ",e.jsx("a",{href:"/create_password",className:"underline",children:e.jsx(u,{as:"span",size:"xs",type:"body",weight:"bold",theme:"default",children:t("login.create_password")})})]})]}),children:o?e.jsx(L,{onSuccess:r,bypassSparkLoopMode:!0}):e.jsx(z,{allowSignup:!1,onSuccess:r})})},Q=()=>{const[s,r]=j(),a=s.get("modal");return{isLoginModalOpen:a==="login",isSignupModalOpen:a==="signup",handleCloseModal:()=>{s.delete("modal"),r(s,{replace:!0})},handleOpenModal:n=>{s.set("modal",n),r(s,{replace:!0})}}},f=s=>s===1?"":"s",X=s=>{const r=new Date,a=new Date(s),t=r.getTime()-a.getTime(),o=Math.floor(t/1e3),n=Math.floor(o/60),m=Math.floor(n/60),i=Math.floor(m/24),l=Math.floor(i/7),h=Math.floor(l/4),c=Math.floor(h/12);return o<60?`${o} second${f(o)} ago`:n<60?`${n} minute${f(n)} ago`:m<24?`${m} hour${f(m)} ago`:i<7?`${i} day${f(i)} ago`:l<4?`${l} week${f(l)} ago`:h<12?`${h} month${f(h)} ago`:`${c} year${f(c)} ago`},Y=({isOpen:s,onClose:r,children:a,title:t,description:o})=>e.jsx(x,{appear:!0,show:s,as:d.Fragment,children:e.jsxs(g,{as:"div",onClose:r,children:[e.jsx(x.Child,{as:d.Fragment,enter:"ease-out duration-50",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-50",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:e.jsx("div",{className:"fixed inset-0 bottom-0 left-0 z-20 bg-black/60"})}),e.jsx(x.Child,{as:d.Fragment,enter:"ease-out duration-100",enterFrom:"transform sm:translate-y-0 translate-y-1/2 opacity-0",enterTo:"transform translate-y-0 opacity-100",leave:"ease-in duration-100",leaveFrom:"transform translate-y-0 opacity-100",leaveTo:"transform sm:translate-y-0 translate-y-1/2 opacity-0",children:e.jsx("div",{className:"fixed inset-0 bottom-0 left-0 z-40 flex items-end overflow-y-auto sm:items-center",children:e.jsx(g.Panel,{className:"relative mx-auto flex w-full max-w-none transform justify-center overflow-auto rounded-t-wt bg-wt-background p-8 text-left align-middle transition-all sm:max-w-xl sm:rounded-wt",children:e.jsxs("div",{className:"relative w-full space-y-4",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(u,{as:"h4",size:"2xl",theme:"content",children:t}),e.jsx(u,{as:"p",size:"md",theme:"content",weight:"regular",className:"font-regular",children:o})]}),e.jsx("div",{className:"h-6 w-6",children:e.jsx("button",{"aria-label":"Close",className:"flex h-6 w-6 items-center justify-center rounded-wt transition-all hover:bg-black/5",onClick:r,children:e.jsx(y,{className:"h-5 w-5 stroke-1 text-gray-400 transition-all hover:text-gray-700"})})})]}),a]})})})})]})}),ee=({guid:s,setCookie:r,cookiesSet:a})=>{const[t,o]=j(),n=N(),m=k(),i=t.get("last_resource_guid")||s,l=t.get("admin_token"),h=t.get("jwt_token"),c=n.hash!=="",p=t.toString();d.useEffect(()=>{if(a&&i)if(r({name:"last_resource_guid",value:i,days:1}),t.delete("last_resource_guid"),l&&t.delete("admin_token"),h&&t.delete("jwt_token"),c){const v=new URLSearchParams(t),_=`${n.pathname}?${v.toString()}${n.hash}`;m(_,{replace:!0,state:{}})}else p!==t.toString()&&o(t,{replace:!0})},[a,i,p])};export{H as F,K as L,Y as S,ee as a,E as b,X as r,Q as u};
//# sourceMappingURL=useSetLastViewedResource-Dc3QAjps.js.map

//# debugId=0d923ea2-e946-59e2-816f-4b7a605e72d4
