import{e as k,a as v,f as N,j as e,__tla as E}from"./FontSizeProvider-Cy0K7gvl.js";import{S as F,__tla as I}from"./SettingsOptionLayout-DCeJo04x.js";import{O as q,__tla as T}from"./Layout-DSO4xVx8.js";import{a as K,u as P,d as h,F as n,I as C,e as O,T as D,j as Q}from"./trash-2-Dx96Ty-c.js";import{D as u,S as z,a as M,E as U,F as x}from"./SaveButton-DAQL8oi6.js";import{aa as $,ab as J,ac as L,__tla as R}from"./index-KoiODSx1.js";import{T as V}from"./Trans-CLnc82mi.js";import{T as A}from"./Table-C5URQSxp.js";import{m as i}from"./index-CNNXFhHX.js";import"./ProviderIcon-D3tRBvxU.js";import"./LinkComponent-BNBw6Z6W.js";import"./brain-circuit-E5LTXM_M.js";import"./info-DfLcFogF.js";import"./loader-2-eRkEtMXl.js";import"./chevron-right-CxApm3L5.js";import"./webui-C025Pd1b.js";import"./index-CWrRY1Fi.js";import"./index-BwBXqow1.js";import"./index-Dy9fbQqh.js";let g,B=Promise.all([(()=>{try{return E}catch{}})(),(()=>{try{return I}catch{}})(),(()=>{try{return T}catch{}})(),(()=>{try{return R}catch{}})()]).then(async()=>{let l,o;l=async s=>{const a=await u(`${K(s)}/api/v1/ping`);if(!a.ok)throw new Error("Unable to verify page share");return await a.text()==="pong"},o=()=>{const s=k(),{t:a}=v(["settings"]),[d,p]=N("shareMode",!1),{status:m,data:c}=P({queryKey:["fetchShareInfo"],queryFn:async()=>{const[r,t]=await Promise.all([U(),$()]);return{url:r,shares:t}}}),b=async r=>{d?await l(r.url)&&await x(r.url):await x(r.url)},f=async({api_url:r,share_id:t,id:w})=>{const S=await J();if(!(await u(`${r}/api/v1/share/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({share_id:t,owner_id:S})})).ok)throw new Error("Failed to delete share link");return await L(w),"ok"},{mutate:y,isPending:j}=h({mutationFn:b,onSuccess:()=>{s.invalidateQueries({queryKey:["fetchShareInfo"]}),i.success(a("manageShare.notification.pageShareSuccess"))},onError:r=>{i.error((r==null?void 0:r.message)||a("manageShare.notification.someError"))}}),{mutate:_}=h({mutationFn:f,onSuccess:()=>{s.invalidateQueries({queryKey:["fetchShareInfo"]}),i.success(a("manageShare.notification.webShareDeleteSuccess"))},onError:r=>{i.error((r==null?void 0:r.message)||a("manageShare.notification.someError"))}});return e.jsxs("div",{className:"flex flex-col space-y-3",children:[m==="pending"&&e.jsx(z,{paragraph:{rows:4},active:!0}),m==="success"&&e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-7 text-gray-900 dark:text-white",children:a("manageShare.heading")}),e.jsx("div",{className:"border border-b border-gray-200 dark:border-gray-600 mt-3 mb-6"})]}),e.jsxs(n,{layout:"vertical",onFinish:y,initialValues:{url:c.url},children:[e.jsx(n.Item,{name:"url",help:e.jsx(V,{i18nKey:"settings:manageShare.form.url.help",components:{anchor:e.jsx("a",{href:"https://github.com/n4ze3m/page-assist/blob/main/page-share.md",target:"__blank",className:"text-blue-600 dark:text-blue-400"})}}),rules:[{required:!0,message:a("manageShare.form.url.required")}],label:a("manageShare.form.url.label"),children:e.jsx(C,{placeholder:a("manageShare.form.url.placeholder"),size:"large"})}),e.jsx(n.Item,{children:e.jsx("div",{className:"flex justify-end",children:e.jsx(M,{disabled:j,btnType:"submit"})})})]}),e.jsxs("div",{className:"space-y-2 flex mb-4 flex-row items-center justify-between rounded-lg  dark:border-gray-600 ",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("label",{className:"text-sm font-semibold leading-5 text-gray-900 dark:text-white",children:a("manageShare.webshare.label")}),e.jsx("p",{className:"text-sm font-normal leading-5 text-gray-700 dark:text-gray-400",children:a("manageShare.webshare.description")})]}),e.jsx(O,{checked:d,onChange:p})]})]}),e.jsxs("div",{children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-7 text-gray-900 dark:text-white",children:a("manageShare.webshare.heading")}),e.jsx("div",{className:"border border-b border-gray-200 dark:border-gray-600 mt-3 mb-6"})]}),e.jsx("div",{children:e.jsx(A,{dataSource:c.shares,columns:[{title:a("manageShare.webshare.columns.title"),dataIndex:"title",key:"title"},{title:a("manageShare.webshare.columns.url"),dataIndex:"url",key:"url",render:r=>e.jsx("a",{href:r,target:"__blank",className:"text-blue-600 dark:text-blue-400",children:r})},{title:a("manageShare.webshare.columns.actions"),render:(r,t)=>e.jsx(D,{title:a("manageShare.webshare.tooltip.delete"),children:e.jsx("button",{onClick:()=>{window.confirm(a("manageShare.webshare.confirm.delete"))&&_({id:t.id,share_id:t.share_id,api_url:t.api_url})},className:"text-red-500 dark:text-red-400",children:e.jsx(Q,{className:"w-5 h-5"})})})}]})})]})]})]})},g=()=>e.jsx(q,{children:e.jsx(F,{children:e.jsx(o,{})})})});export{B as __tla,g as default};
