import{d as k,a as S,n as e,R as y,r as c,C as o,P as d,f as L,j as p,c as w,u as v,k as x}from"./assets/storage-kVIrj-Ow.js";/**
 * @license lucide-react v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const b=k("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);function C(){const[a,r]=c.useState(null),[s,m]=c.useState(!1),[n,f]=c.useState(!1);c.useEffect(()=>{(async()=>{var j;const h=await chrome.storage.local.get("pendingSavedLink");if((j=h.pendingSavedLink)!=null&&j.url){const t=h.pendingSavedLink;r({id:"pending",title:t.title||p(t.url),url:t.url,domain:p(t.url),favicon:L(t.url),source:"saved"});return}r(await w.activeTabSite())})()},[]);const l=async()=>{if(!a)return;const i={id:v("link"),title:a.title,url:a.url,domain:a.domain,favicon:a.favicon,tags:[],category:"عمومی",archived:!1,createdAt:Date.now()};await x.put("links",i),await chrome.storage.local.remove("pendingSavedLink"),m(!0)},u=async()=>{if(!a)return;const i={id:v("shortcut"),title:a.title||a.domain,url:a.url,domain:a.domain,favicon:a.favicon,createdAt:Date.now()};await x.put("shortcuts",i),await chrome.storage.local.remove("pendingSavedLink"),f(!0)},g=async()=>{await l(),await u()};return e.jsxs("main",{className:"popup",children:[e.jsxs("header",{children:[e.jsx(b,{}),e.jsxs("div",{children:[e.jsx("strong",{children:"ذخیره در آزادراه"}),e.jsx("span",{children:"انتخاب کن این صفحه کجا ذخیره شود"})]})]}),a?e.jsxs("section",{className:"link-card",children:[e.jsx("img",{src:a.favicon,alt:""}),e.jsx("strong",{children:a.title}),e.jsx("span",{children:a.domain})]}):e.jsx("p",{children:"برای این صفحه لینکی قابل ذخیره پیدا نشد."}),e.jsxs("div",{className:"popup-actions",children:[e.jsxs("button",{disabled:!a||s,onClick:l,children:[s?e.jsx(o,{}):e.jsx(d,{}),"اتاق مطالعه"]}),e.jsxs("button",{disabled:!a||n,onClick:u,children:[n?e.jsx(o,{}):e.jsx(d,{}),"لانچ‌پد"]}),e.jsxs("button",{disabled:!a||s&&n,onClick:g,children:[s&&n?e.jsx(o,{}):e.jsx(d,{}),"هر دو"]})]})]})}S.createRoot(document.getElementById("root")).render(e.jsx(y.StrictMode,{children:e.jsx(C,{})}));
