import{a as e,n as t,r as n}from"./createLucideIcon-x_DqbPgA.js";import{t as r}from"./use-items-CGLT3yWe.js";import{c as i,u as a}from"./chunk-UVKPFVEO-CKgCEGmW.js";import{t as o}from"./arrow-left-7SrPmO8V.js";import{t as s}from"./circle-check-big-BGRXsaKU.js";import{t as c}from"./BookmarkForm-BxR8wa-V.js";import{t as l}from"./loader-circle-BS74HvID.js";var u=e(n(),1),d=t();function f(){let e=i(),[t]=a(),n=r(),[f,p]=(0,u.useState)(`idle`);return(0,u.useEffect)(()=>{let r=t.get(`url`),i=t.get(`text`),a=t.get(`title`),o=r||i?.match(/https?:\/\/\S+/)?.[0];o&&(p(`saving`),n.mutate({url:o,title:a||void 0},{onSuccess:()=>{p(`success`),setTimeout(()=>e(`/`),1500)},onError:()=>{p(`error`)}}))},[]),f===`saving`?(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-screen gap-4 p-6`,children:[(0,d.jsx)(l,{className:`h-10 w-10 animate-spin text-[#0096C7]`}),(0,d.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-sm`,children:`Saving...`})]}):f===`success`?(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-screen gap-4 p-6`,children:[(0,d.jsx)(`div`,{className:`animate-pocket-drop`,children:(0,d.jsx)(s,{className:`h-10 w-10 text-[#0096C7]`})}),(0,d.jsx)(`p`,{className:`text-gray-900 dark:text-gray-100 font-medium`,children:`Saved.`}),(0,d.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 text-sm`,children:`Redirecting...`})]}):f===`error`?(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-screen gap-4 p-6`,children:[(0,d.jsx)(`p`,{className:`text-red-500 font-medium`,children:`Failed to save. Please try again.`}),(0,d.jsx)(`button`,{onClick:()=>e(-1),className:`text-sm text-[#0096C7] hover:underline cursor-pointer`,children:`Go back`})]}):(0,d.jsxs)(`div`,{className:`animate-fade-in p-6 max-w-2xl mx-auto`,children:[(0,d.jsxs)(`button`,{onClick:()=>e(-1),className:`inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 mb-6 p-2 -ml-2 rounded-xl hover:bg-sky-50 dark:hover:bg-gray-800 transition-all duration-200 cursor-pointer`,children:[(0,d.jsx)(o,{className:`h-4 w-4`}),`Back`]}),(0,d.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100 mb-1`,children:`Save an item`}),(0,d.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`Paste a URL or enter content to save.`})]}),(0,d.jsx)(`div`,{className:`flex items-center justify-center min-h-[50vh]`,children:(0,d.jsx)(c,{onClose:()=>e(-1)})})]})}export{f as default};