import{C as e,_ as t,b as n,c as r,d as i,f as a,g as o,l as s,p as c,s as l,u,y as d}from"./index-CEuF-Tb3.js";var f=e(n(),1);function p({width:e,minHeight:n,maxHeight:r,chromeHeight:i=40,contentSelector:o=`[data-adaptive-content]`,enabled:s=!0}){(0,f.useEffect)(()=>{if(!s||typeof window>`u`)return;let c=0,l=0,u=null,d=null,f=()=>{let s=u??document.querySelector(o);if(!s)return;s!==u&&(u=s,d?.observe(s));let c=i+s.scrollHeight,f=Math.min(r,Math.max(n,Math.ceil(c)));Math.abs(f-l)<2||(l=f,t.invoke(a.ResizeWindow,{width:e,height:f}))},p=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(f)};d=new ResizeObserver(p),d.observe(document.body);let m=new MutationObserver(p);return m.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`,`aria-expanded`,`hidden`]}),p(),()=>{d?.disconnect(),m.disconnect(),cancelAnimationFrame(c)}},[e,n,r,i,o,s])}var m=o();function h(){let{t:e}=d();p({width:640,minHeight:360,maxHeight:760,enabled:!0});let t=(0,f.useMemo)(()=>{if(typeof window>`u`)return;let e=Object.fromEntries(new URLSearchParams(window.location.search)),t=u.safeParse(e);if(t.success)return i(t.data)},[]);return(0,m.jsxs)(`div`,{className:`flex h-screen flex-col`,children:[(0,m.jsx)(r,{variant:`titled`,compact:!0,maximizable:!1,title:e(`task.add.title`)}),(0,m.jsx)(c,{services:l,children:(0,m.jsx)(s,{defaultValues:t,onSubmitSuccess:()=>void l.closeHost({showMain:!0,navigateMainTo:`/downloads`}),onCancel:()=>void l.closeHost({showMain:!0}),subscribeEvents:!0})})]})}export{h as AddTaskWindow};