import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,wt as n,zt as r}from"./mui-B6lh3XSP.js";import{l as i,u as a}from"./IconButton-BEBOUWhl.js";import{t as o}from"./Container-CHg71Wor.js";import{i as s,n as c,r as l,t as u}from"./ExpandMore-BvigPYWL.js";import{t as d}from"./TextField-DOdnjCrL.js";import{t as f}from"./Typography-DfQXhGTT.js";import{n as p}from"./MenuItem-HQNtf0LG.js";import{t as m}from"./dayjs.min-C4hTNXA3.js";import{en as h,ht as g,w as _,yt as v}from"./index-KVuxnkWj.js";import{n as y,t as b}from"./useSettingsStyles-X3caKosH.js";var x=e(t(),1),S=e(m(),1),C=n(),w=()=>{let e=i(),{classes:t}=b(),n=v(),{type:m,id:w}=a(),T=r(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 _(`/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)(p,{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)(f,{variant:`subtitle1`,children:n(`sharedRequired`)})}),(0,C.jsxs)(l,{className:t.details,children:[(0,C.jsx)(d,{value:T.name,label:n(m===`group`?`groupDialog`:`sharedDevice`),disabled:!0}),(0,C.jsx)(d,{label:n(`userExpirationTime`),type:`datetime-local`,value:E,onChange:e=>D(e.target.value)}),(0,C.jsx)(h,{variant:`outlined`,color:`primary`,onClick:A,children:n(`reportShow`)}),(0,C.jsx)(d,{value:O||``,onChange:e=>k(e.target.value),label:n(`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:n(`sharedCancel`)}),(0,C.jsx)(h,{type:`button`,color:`primary`,variant:`contained`,onClick:()=>navigator.clipboard?.writeText(O),disabled:!O,children:n(`sharedCopy`)})]})]})})};export{w as default};