import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,Nt as n,vt as r}from"./mui-BgU4WrXF.js";import{l as i,u as a}from"./IconButton-oialqkv3.js";import{t as o}from"./Container-fY8-hTkD.js";import{i as s,n as c,r as l,t as u}from"./ExpandMore-D0ycvrdR.js";import{t as d}from"./Typography-7EcQ2i3p.js";import{n as f}from"./MenuItem-BNgF7Xqv.js";import{t as p}from"./TextField-DctlzLY-.js";import{t as m}from"./dayjs.min-C4hTNXA3.js";import{Ut as h,lt as g,pt as _,w as v}from"./index-bel1r0Sr.js";import{n as y,t as b}from"./useSettingsStyles-Bugi6oTj.js";var x=e(t(),1),S=e(m(),1),C=r(),w=()=>{let e=i(),{classes:t}=b(),r=_(),{type:m,id:w}=a(),T=n(e=>m===`group`?e.groups.items[w]:e.devices.items[w]),[E,D]=(0,x.useState)(()=>(0,S.default)().add(1,`week`).locale(`en`).format(`YYYY-MM-DDTHH:mm`)),[O,k]=(0,x.useState)(),A=g(async()=>{let e=(0,S.default)(E).toISOString(),t=await(await v(`/api/share/${m}`,{method:`POST`,body:new URLSearchParams(`${m}Id=${w}&expiration=${e}`)})).text();k(`${window.location.origin}?token=${t}`)},[w,E,m,k]);return(0,C.jsx)(f,{menu:(0,C.jsx)(y,{}),breadcrumbs:[`sharedShare`],children:(0,C.jsxs)(o,{maxWidth:`xs`,className:t.container,children:[(0,C.jsxs)(s,{defaultExpanded:!0,children:[(0,C.jsx)(c,{expandIcon:(0,C.jsx)(u,{}),children:(0,C.jsx)(d,{variant:`subtitle1`,children:r(`sharedRequired`)})}),(0,C.jsxs)(l,{className:t.details,children:[(0,C.jsx)(p,{value:T.name,label:r(m===`group`?`groupDialog`:`sharedDevice`),disabled:!0}),(0,C.jsx)(p,{label:r(`userExpirationTime`),type:`datetime-local`,value:E,onChange:e=>D(e.target.value)}),(0,C.jsx)(h,{variant:`outlined`,color:`primary`,onClick:A,children:r(`reportShow`)}),(0,C.jsx)(p,{value:O||``,onChange:e=>k(e.target.value),label:r(`sharedLink`),slotProps:{input:{readOnly:!0}}})]})]}),(0,C.jsxs)(`div`,{className:t.buttons,children:[(0,C.jsx)(h,{type:`button`,color:`primary`,variant:`outlined`,onClick:()=>e(-1),children:r(`sharedCancel`)}),(0,C.jsx)(h,{type:`button`,color:`primary`,variant:`contained`,onClick:()=>navigator.clipboard?.writeText(O),disabled:!O,children:r(`sharedCopy`)})]})]})})};export{w as default};