@fungi.computer/prints 0.10.10 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/data-list-CHxHx7uj.js +1 -0
- package/dist/assets/{index-DRbI7n1I.js → index-DX6AftUD.js} +3 -3
- package/dist/assets/{print-info-drawer-D_j9bQ2B.js → print-info-drawer-HknyLAui.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/dist/assets/data-list-iuPAlUl0.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./print-download-button-B6tCroD1.js","./rolldown-runtime-hePW80VL.js","./media-DXNW7KSH.js","./log-event-B3qOOBbh.js","./modules-C4mfDnjH.js","./print-info-drawer-
|
|
2
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$t as r,A as i,An as a,Ar as o,At as s,B as c,Br as l,Bt as u,C as d,Cn as f,D as p,Dn as m,Dr as h,Dt as g,E as _,En as v,Er as y,F as b,Fn as x,Fr as S,G as C,Gn as w,Gr as T,Gt as E,H as D,Hr as O,Ht as k,I as A,In as j,Ir as M,J as N,Jn as P,Jr as F,Jt as I,K as L,Kn as R,Kr as z,Kt as B,L as ee,Ln as V,Lr as te,Lt as ne,M as H,Mn as U,Mr as re,Mt as W,N as ie,Nn as ae,Nr as G,O as oe,On as se,Or as ce,P as le,Pn as ue,Pr as K,Q as de,Qt as fe,R as pe,Rn as me,Rr as he,Rt as ge,S as _e,Sn as ve,Sr as q,T as ye,Tn as be,Tr as xe,U as Se,Un as Ce,Ur as we,Ut as Te,V as Ee,Vr as De,Vt as Oe,W as ke,Wn as Ae,Wr as je,Wt as Me,X as Ne,Xr as Pe,Xt as Fe,Y as Ie,Yn as Le,Yr as Re,Yt as ze,Z as Be,Zt as Ve,_ as He,_n as Ue,_r as We,an as Ge,ar as Ke,at as qe,b as Je,bn as Ye,br as Xe,c as Ze,cn as Qe,cr as $e,d as et,dn as tt,dr as nt,en as rt,et as it,f as at,fr as ot,g as st,gn as ct,gr as lt,h as ut,hr as dt,ht as ft,i as pt,it as mt,j as ht,jn as gt,jr as _t,k as vt,kn as yt,kr as bt,l as xt,ln as St,lr as Ct,m as wt,mn as Tt,mr as Et,n as Dt,nn as Ot,nr as kt,nt as At,on as jt,or as Mt,ot as Nt,p as Pt,pn as Ft,pr as It,pt as Lt,q as Rt,qn as zt,qr as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,sr as Jt,tn as Yt,tt as Xt,u as J,ur as Zt,v as Qt,vn as $t,vr as en,w as tn,wn as nn,wr as rn,x as an,xr as on,y as sn,yn as cn,yr as ln,z as un,zn as dn,zr as fn,zt as pn}from"./media-DXNW7KSH.js";import{a as mn,c as hn,i as gn,l as _n,n as vn,o as yn,r as bn,s as xn,t as Sn,u as Cn}from"./log-event-B3qOOBbh.js";import{$ as wn,A as Tn,At as En,B as Dn,Bt as On,C as kn,Ct as An,D as jn,Dt as Mn,E as Nn,Et as Pn,F as Fn,Ft as In,G as Ln,Gt as Rn,H as zn,Ht as Bn,I as Vn,It as Hn,J as Un,K as Wn,L as Gn,Lt as Kn,M as qn,Mt as Jn,N as Yn,Nt as Xn,Ot as Zn,P as Qn,Pt as $n,Q as er,R as tr,Rt as nr,S as rr,St as ir,T as ar,Tt as or,U as sr,Ut as cr,V as lr,Vt as ur,W as dr,Wt as fr,X as pr,Y as mr,Z as hr,_ as gr,_t as _r,a as vr,at as yr,b as br,bt as xr,ct as Sr,d as Cr,dt as wr,et as Tr,f as Er,ft as Dr,g as Or,gt as kr,h as Ar,ht as jr,i as Mr,it as Nr,j as Pr,jt as Fr,kt as Ir,l as Lr,lt as Rr,m as zr,mt as Br,n as Vr,nt as Hr,o as Ur,ot as Wr,p as Gr,pt as Kr,q as qr,rt as Jr,s as Yr,st as Xr,tt as Zr,u as Qr,ut as $r,v as ei,vt as ti,w as ni,wt as ri,x as ii,xt as ai,y as oi,yt as si,z as ci,zt as li}from"./data-list-iuPAlUl0.js";import{r as ui}from"./modules-C4mfDnjH.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=e(Pe(),1),di=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},fi=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function pi(){let e=!1,t=Ki,n=[],r=[],i=!1,a=[],o=new Set,s=()=>{for(let e of o)e()};return Object.freeze({close:()=>{e||(e=!0,n=[],a=[],r=[],t=Ki,s(),o.clear())},contribute:t=>{if(Si(t),e)throw new fi;Ci(t,n),wi(t,n);let r=Symbol(`whistle-contribution`);xi(t)||(n=[...n,{contribution:Ti(t),generation:r}],i=!0,s());let a=!0;return Wi(o=>{if(!a||e)return;let c={...t,commands:o};Si(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);Ci(c,u),wi(c,u);let d=Ti(c);if(xi(c)){if(l<0)return;n=u}else n=l<0?[...n,{contribution:d,generation:r}]:n.map(e=>e.generation===r?{contribution:d,generation:r}:e);i=!0,s()},()=>{a&&(a=!1,n.find(e=>e.generation===r)!==void 0&&(n=n.filter(e=>e.generation!==r),i=!0,s()))})},execute:async(t,r)=>{if(t.namespace.trim().length===0||t.id.trim().length===0)return{status:`invalid`};if(e)return{status:`closed`};let i=bi(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Ji(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&mi.has(r.origin)&&(o=n({commandId:yi(t.namespace,t.id),title:i.title}));let s={...r,signal:r.signal??new AbortController().signal};o!==void 0&&(s.interaction=o.interaction,s.signal=AbortSignal.any([s.signal,o.interaction.signal]));let c=await i.handler(s);return o?.settle({status:`handled`}),c===void 0?{status:`handled`}:{status:`handled`,result:c}}catch(e){let t=Xi(e instanceof Error?e:Error(`Command handler threw a non-Error value`));return o?.settle(o.interaction.signal.aborted?{status:`cancelled`}:{status:`failed`,message:t.message}),{status:`failed`,error:t}}},present:t=>{let n={presenter:t};return e||(a=[...a,n]),()=>{a=a.filter(e=>e!==n)}},snapshot:()=>{if(e)return Ki;let a=n.flatMap(e=>e.contribution.commands.map(Ji));return(i||a.some((e,t)=>!Yi(e,r[t])))&&(t=Zi(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var mi=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),hi=16,gi=32,_i=64,vi=256;function yi(e,t){return Mt.parse(`${e}:${t}`)}function bi(e,t){for(let n of t)if(n.contribution.namespace===e.namespace){for(let t of n.contribution.commands)if(t.id===e.id)return t}}function xi(e){return e.commands.length===0}function Si(e){Hi(e.sourceId,`source ID`),Hi(e.namespace,`namespace`),e.scope!==void 0&&Hi(e.scope,`scope`);for(let t of e.commands)Li(t)}function Ci(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&Gi(`Namespace is already owned by another source`);let n=new Set,r=new Set;for(let i of t){let t=i.contribution.scope===e.scope;for(let e of i.contribution.commands)if(n.add(yi(i.contribution.namespace,e.id)),t)for(let t of e.projections?.slash?.aliases??[])r.add(t)}for(let t of e.commands){let i=yi(e.namespace,t.id);n.has(i)&&Gi(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&Gi(`Slash alias is already registered`),r.add(e)}}function wi(e,t){t.length>=_i&&Gi(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>vi&&Gi(`Live command capacity exceeded`)}function Ti(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(Ei)};return e.scope===void 0?t:{...t,scope:e.scope}}function Ei(e){let t={id:e.id,title:e.title,category:e.category,handler:e.handler};return e.description!==void 0&&(t.description=e.description),e.action!==void 0&&(t.action=Di(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=ji(e.projections)),t}function Di(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=Oi(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=Oi(e.outputSchema)),e.presentation!==void 0&&(t.presentation=Ai(e.presentation)),Object.freeze(t)}function Oi(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ki(t)])))}function ki(e){return Array.isArray(e)?Object.freeze(e.map(ki)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ki(t)]))):e}function Ai(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:Oi(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:ki(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function ji(e){let t={};return e.bindings!==void 0&&(t.bindings=Mi(e.bindings)),e.agent!==void 0&&(t.agent=Ni(e.agent)),e.help!==void 0&&(t.help=Pi(e.help.order)),e.menu!==void 0&&(t.menu=Pi(e.menu.order)),e.palette!==void 0&&(t.palette=Pi(e.palette.order)),e.slash!==void 0&&(t.slash=Fi(e.slash)),t}function Mi(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function Ni(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function Pi(e){let t={};return e!==void 0&&(t.order=e),t}function Fi(e){let t={aliases:[...e.aliases]};return e.order!==void 0&&(t.order=e.order),e.consumesDraft!==void 0&&(t.consumesDraft=e.consumesDraft),e.arguments!==void 0&&(t.arguments=Ii(e.arguments)),t}function Ii(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:Oi(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:Oi(e.text.arguments)})),Object.freeze(t)}function Li(e){Hi(e.id,`command ID`,!0),Hi(e.title,`title`),Hi(e.category,`category`),Ri(e.action),zi(e.projections)}function Ri(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)Hi(t.label,`choice label`),t.description!==void 0&&Hi(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&Hi(e.presentation.submitLabel,`submit label`);return;case`confirmation`:Hi(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&Hi(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&Hi(e.presentation.cancelLabel,`cancellation label`)}}function zi(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&Ui(t.order);if(e.bindings!==void 0&&Vi(e.bindings.values,`binding`),e.slash!==void 0){Vi(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&Gi(`slash alias must not contain whitespace`);Bi(e.slash.arguments)}e.agent?.keybind!==void 0&&Hi(e.agent.keybind,`agent keybind`)}}function Bi(e){if(e===void 0)return;Hi(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&Gi(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])Hi(n.word,`argument word`),/\s/u.test(n.word)&&Gi(`argument word must not contain whitespace`),t.has(n.word)&&Gi(`argument word is repeated`),t.add(n.word),n.description!==void 0&&Hi(n.description,`argument word description`);t.size>gi&&Gi(`argument word count exceeds 32`),e.text!==void 0&&(Hi(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&Hi(e.text.requestIdField,`request id field`))}function Vi(e,t){e.length>hi&&Gi(`${t} count exceeds 16`);for(let n of e)Hi(n,t)}function Hi(e,t,n=!1){e.trim().length===0&&Gi(`${t} must not be blank`),n&&e.includes(`:`)&&Gi(`${t} must not contain a colon`)}function Ui(e){e!==void 0&&!Number.isSafeInteger(e)&&Gi(`order must be a safe integer`)}function Wi(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function Gi(e){throw Error(e)}var Ki=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),qi=Object.freeze({status:`available`});function Ji(e){let t=e.availability?.()??qi;return t.status===`available`?qi:Object.freeze({status:`unavailable`,reason:t.reason})}function Yi(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function Xi(e){if(e instanceof di){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:ki(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function Zi(e,t){let n=[],r=[],i=[],a=[],o=[],s=[],c=0;for(let l of e){let e=l.contribution;for(let l of e.commands){let u=l.projections,d=t[c++]??qi;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...ia(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...ia(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...ia(e,l,u.slash.order,d),alias:t};u.slash.consumesDraft!==void 0&&(n={...n,consumesDraft:u.slash.consumesDraft}),u.slash.arguments!==void 0&&(n={...n,arguments:u.slash.arguments}),i.push(n)}u?.help!==void 0&&a.push({...ia(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...ia(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(oa(e,l,u.agent,d))}}return ta(n),na(i),ea(r),ea(a),ea(o),ea(s),Object.freeze({bindings:ra(n),palette:ra(r),slash:ra(i),help:ra(a),menu:ra(o),agent:ra(s)})}var Qi=new TextEncoder;function $i(e,t){let n=Qi.encode(e),r=Qi.encode(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return n.length<r.length?-1:+(n.length>r.length)}function ea(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId))}function ta(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId)||$i(e.binding,t.binding))}function na(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId)||$i(e.alias,t.alias))}function ra(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function ia(e,t,n,r){let i=aa(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function aa(e,t,n,r){let i={commandId:yi(e.namespace,t.id),command:Object.freeze({namespace:e.namespace,id:t.id}),sourceId:e.sourceId,title:t.title,category:t.category,order:n??0,availability:r},a=t.description===void 0?i:{...i,description:t.description};return t.action===void 0?a:{...a,action:t.action}}function oa(e,t,n,r){let i=ia(e,t,n.order,r),a=i.action===void 0?i:{...i,action:sa(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function sa(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}function ca(e,t){let n=!1,r=[];for(let i of t){let{availability:t,handler:a,...o}=i,s=a,c=t===void 0?o:{...o,availability:t()};e.register(c,async({arguments:e,origin:t,signal:n})=>{let r=await s(e===void 0?{origin:t,signal:n}:{arguments:e,origin:t,signal:n});return r===void 0?void 0:$e(r)}).then(e=>{n?e():r.push(e)},e=>{console.warn(`App command ${i.id} was not registered`,e)})}return()=>{if(!n){n=!0;for(let e of r.splice(0))e()}}}q(`light.dark.latte.mocha.readout.readout-night.field-guide.field-guide-night.embed.embed-dark.phosphor.codec.paper.ember.tide.tape.sunrise.pirate-radio.pirate-radio-night.consulting.consulting-ink.consulting-night.consulting-night-ink.consulting-riso-latte.consulting-riso-latte-ink.consulting-riso-glomzy.consulting-riso-glomzy-ink.vishnu.coin.coin-night.chamfer`.split(`.`));var la=`data-theme`;function ua(e){return e||(globalThis.document?.documentElement??null)}function da(e){let t=e.trim();if(t.length===0)throw TypeError(`Theme must be a non-empty string`);return t}function fa(e,t){let n=da(e),r=ua(t);r&&r.setAttribute(la,n)}function pa(e){return ua(e)?.getAttribute(la)??null}var ma=class extends cr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:fr(t,n.data),hasPreviousPage:Rn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function ha(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var ga=class extends ft{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Lt.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!W(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ha(e,n).forEach(e=>{e.destroy()}),ha(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=s(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new cr(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Lt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}};function _a({queries:e,...t},n){let r=ge(n),i=Bn(),a=ur(),o=t.subscribed!==!1,s=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{In(e);let t=r.getQueryCache().get(e.queryHash);nr(e,a,t)}),On(a);let[c]=Y.useState(()=>new ga(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;Y.useSyncExternalStore(Y.useCallback(e=>f?c.subscribe(Lt.batchCalls(e)):g,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Y.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Kn(s[t],e))?l.flatMap((e,t)=>{let n=s[t];if(n&&Kn(n,e)){let e=new cr(r,n);return Hn(n,e,a)}return[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&li({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function va(e){return e}function ya(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function ba(e={},t){let n=ge(t).getMutationCache(),r=Y.useRef(e),i=Y.useRef(null);return i.current===null&&(i.current=ya(n,e)),Y.useEffect(()=>{r.current=e}),Y.useSyncExternalStore(Y.useCallback(e=>n.subscribe(()=>{let t=s(i.current,ya(n,r.current));i.current!==t&&(i.current=t,Lt.schedule(e))}),[n]),()=>i.current,()=>i.current)}function xa(e,t){return $n(e,ma,t)}var Sa=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function O(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?k():(S=!1,C=null)}}else S=!1}var k;if(typeof v==`function`)k=function(){v(O)};else if(typeof MessageChannel<`u`){var A=new MessageChannel,j=A.port2;A.port1.onmessage=O,k=function(){j.postMessage(null)}}else k=function(){g(O,0)};function M(e){C=e,S||(S=!0,k())}function N(t,n){w=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,M(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Ca=t(((e,t)=>{t.exports=Sa()})),wa=t((e=>{var t=Pe(),n=Ca();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n]);return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(e){return l.call(f,e)?!0:l.call(d,e)?!1:u.test(e)?f[e]=!0:(d[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function h(e,t,n,r){if(t==null||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var _={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){_[e]=new g(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];_[t]=new g(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){_[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){_[e]=new g(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){_[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){_[e]=new g(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){_[e]=new g(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){_[e]=new g(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){_[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),_.xlinkHref=new g(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function b(e,t,n,r){var i=_.hasOwnProperty(t)?_[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(h(t,n,i,r)&&(n=null),r||i===null?p(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type!==3&&``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for(`react.element`),C=Symbol.for(`react.portal`),w=Symbol.for(`react.fragment`),T=Symbol.for(`react.strict_mode`),E=Symbol.for(`react.profiler`),D=Symbol.for(`react.provider`),O=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.suspense`),j=Symbol.for(`react.suspense_list`),M=Symbol.for(`react.memo`),N=Symbol.for(`react.lazy`),P=Symbol.for(`react.offscreen`),F=Symbol.iterator;function I(e){return typeof e!=`object`||!e?null:(e=F&&e[F]||e[`@@iterator`],typeof e==`function`?e:null)}var L=Object.assign,R;function z(e){if(R===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);R=t&&t[1]||``}return`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./print-download-button-B6tCroD1.js","./rolldown-runtime-hePW80VL.js","./media-DXNW7KSH.js","./log-event-B3qOOBbh.js","./modules-C4mfDnjH.js","./print-info-drawer-HknyLAui.js","./data-list-CHxHx7uj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$t as r,A as i,An as a,Ar as o,At as s,B as c,Br as l,Bt as u,C as d,Cn as f,D as p,Dn as m,Dr as h,Dt as g,E as _,En as v,Er as y,F as b,Fn as x,Fr as S,G as C,Gn as w,Gr as T,Gt as E,H as D,Hr as O,Ht as k,I as A,In as j,Ir as M,J as N,Jn as P,Jr as F,Jt as I,K as L,Kn as R,Kr as z,Kt as B,L as ee,Ln as V,Lr as te,Lt as ne,M as H,Mn as U,Mr as re,Mt as W,N as ie,Nn as ae,Nr as G,O as oe,On as se,Or as ce,P as le,Pn as ue,Pr as K,Q as de,Qt as fe,R as pe,Rn as me,Rr as he,Rt as ge,S as _e,Sn as ve,Sr as q,T as ye,Tn as be,Tr as xe,U as Se,Un as Ce,Ur as we,Ut as Te,V as Ee,Vr as De,Vt as Oe,W as ke,Wn as Ae,Wr as je,Wt as Me,X as Ne,Xr as Pe,Xt as Fe,Y as Ie,Yn as Le,Yr as Re,Yt as ze,Z as Be,Zt as Ve,_ as He,_n as Ue,_r as We,an as Ge,ar as Ke,at as qe,b as Je,bn as Ye,br as Xe,c as Ze,cn as Qe,cr as $e,d as et,dn as tt,dr as nt,en as rt,et as it,f as at,fr as ot,g as st,gn as ct,gr as lt,h as ut,hr as dt,ht as ft,i as pt,it as mt,j as ht,jn as gt,jr as _t,k as vt,kn as yt,kr as bt,l as xt,ln as St,lr as Ct,m as wt,mn as Tt,mr as Et,n as Dt,nn as Ot,nr as kt,nt as At,on as jt,or as Mt,ot as Nt,p as Pt,pn as Ft,pr as It,pt as Lt,q as Rt,qn as zt,qr as Bt,qt as Vt,r as Ht,rn as Ut,rr as Wt,rt as Gt,s as Kt,sn as qt,sr as Jt,tn as Yt,tt as Xt,u as J,ur as Zt,v as Qt,vn as $t,vr as en,w as tn,wn as nn,wr as rn,x as an,xr as on,y as sn,yn as cn,yr as ln,z as un,zn as dn,zr as fn,zt as pn}from"./media-DXNW7KSH.js";import{a as mn,c as hn,i as gn,l as _n,n as vn,o as yn,r as bn,s as xn,t as Sn,u as Cn}from"./log-event-B3qOOBbh.js";import{$ as wn,A as Tn,At as En,B as Dn,Bt as On,C as kn,Ct as An,D as jn,Dt as Mn,E as Nn,Et as Pn,F as Fn,Ft as In,G as Ln,Gt as Rn,H as zn,Ht as Bn,I as Vn,It as Hn,J as Un,K as Wn,L as Gn,Lt as Kn,M as qn,Mt as Jn,N as Yn,Nt as Xn,Ot as Zn,P as Qn,Pt as $n,Q as er,R as tr,Rt as nr,S as rr,St as ir,T as ar,Tt as or,U as sr,Ut as cr,V as lr,Vt as ur,W as dr,Wt as fr,X as pr,Y as mr,Z as hr,_ as gr,_t as _r,a as vr,at as yr,b as br,bt as xr,ct as Sr,d as Cr,dt as wr,et as Tr,f as Er,ft as Dr,g as Or,gt as kr,h as Ar,ht as jr,i as Mr,it as Nr,j as Pr,jt as Fr,kt as Ir,l as Lr,lt as Rr,m as zr,mt as Br,n as Vr,nt as Hr,o as Ur,ot as Wr,p as Gr,pt as Kr,q as qr,rt as Jr,s as Yr,st as Xr,tt as Zr,u as Qr,ut as $r,v as ei,vt as ti,w as ni,wt as ri,x as ii,xt as ai,y as oi,yt as si,z as ci,zt as li}from"./data-list-CHxHx7uj.js";import{r as ui}from"./modules-C4mfDnjH.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Y=e(Pe(),1),di=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},fi=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function pi(){let e=!1,t=Ki,n=[],r=[],i=!1,a=[],o=new Set,s=()=>{for(let e of o)e()};return Object.freeze({close:()=>{e||(e=!0,n=[],a=[],r=[],t=Ki,s(),o.clear())},contribute:t=>{if(Si(t),e)throw new fi;Ci(t,n),wi(t,n);let r=Symbol(`whistle-contribution`);xi(t)||(n=[...n,{contribution:Ti(t),generation:r}],i=!0,s());let a=!0;return Wi(o=>{if(!a||e)return;let c={...t,commands:o};Si(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);Ci(c,u),wi(c,u);let d=Ti(c);if(xi(c)){if(l<0)return;n=u}else n=l<0?[...n,{contribution:d,generation:r}]:n.map(e=>e.generation===r?{contribution:d,generation:r}:e);i=!0,s()},()=>{a&&(a=!1,n.find(e=>e.generation===r)!==void 0&&(n=n.filter(e=>e.generation!==r),i=!0,s()))})},execute:async(t,r)=>{if(t.namespace.trim().length===0||t.id.trim().length===0)return{status:`invalid`};if(e)return{status:`closed`};let i=bi(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Ji(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&mi.has(r.origin)&&(o=n({commandId:yi(t.namespace,t.id),title:i.title}));let s={...r,signal:r.signal??new AbortController().signal};o!==void 0&&(s.interaction=o.interaction,s.signal=AbortSignal.any([s.signal,o.interaction.signal]));let c=await i.handler(s);return o?.settle({status:`handled`}),c===void 0?{status:`handled`}:{status:`handled`,result:c}}catch(e){let t=Xi(e instanceof Error?e:Error(`Command handler threw a non-Error value`));return o?.settle(o.interaction.signal.aborted?{status:`cancelled`}:{status:`failed`,message:t.message}),{status:`failed`,error:t}}},present:t=>{let n={presenter:t};return e||(a=[...a,n]),()=>{a=a.filter(e=>e!==n)}},snapshot:()=>{if(e)return Ki;let a=n.flatMap(e=>e.contribution.commands.map(Ji));return(i||a.some((e,t)=>!Yi(e,r[t])))&&(t=Zi(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var mi=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),hi=16,gi=32,_i=64,vi=256;function yi(e,t){return Mt.parse(`${e}:${t}`)}function bi(e,t){for(let n of t)if(n.contribution.namespace===e.namespace){for(let t of n.contribution.commands)if(t.id===e.id)return t}}function xi(e){return e.commands.length===0}function Si(e){Hi(e.sourceId,`source ID`),Hi(e.namespace,`namespace`),e.scope!==void 0&&Hi(e.scope,`scope`);for(let t of e.commands)Li(t)}function Ci(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&Gi(`Namespace is already owned by another source`);let n=new Set,r=new Set;for(let i of t){let t=i.contribution.scope===e.scope;for(let e of i.contribution.commands)if(n.add(yi(i.contribution.namespace,e.id)),t)for(let t of e.projections?.slash?.aliases??[])r.add(t)}for(let t of e.commands){let i=yi(e.namespace,t.id);n.has(i)&&Gi(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&Gi(`Slash alias is already registered`),r.add(e)}}function wi(e,t){t.length>=_i&&Gi(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>vi&&Gi(`Live command capacity exceeded`)}function Ti(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(Ei)};return e.scope===void 0?t:{...t,scope:e.scope}}function Ei(e){let t={id:e.id,title:e.title,category:e.category,handler:e.handler};return e.description!==void 0&&(t.description=e.description),e.action!==void 0&&(t.action=Di(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=ji(e.projections)),t}function Di(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=Oi(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=Oi(e.outputSchema)),e.presentation!==void 0&&(t.presentation=Ai(e.presentation)),Object.freeze(t)}function Oi(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ki(t)])))}function ki(e){return Array.isArray(e)?Object.freeze(e.map(ki)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ki(t)]))):e}function Ai(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:Oi(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:ki(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function ji(e){let t={};return e.bindings!==void 0&&(t.bindings=Mi(e.bindings)),e.agent!==void 0&&(t.agent=Ni(e.agent)),e.help!==void 0&&(t.help=Pi(e.help.order)),e.menu!==void 0&&(t.menu=Pi(e.menu.order)),e.palette!==void 0&&(t.palette=Pi(e.palette.order)),e.slash!==void 0&&(t.slash=Fi(e.slash)),t}function Mi(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function Ni(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function Pi(e){let t={};return e!==void 0&&(t.order=e),t}function Fi(e){let t={aliases:[...e.aliases]};return e.order!==void 0&&(t.order=e.order),e.consumesDraft!==void 0&&(t.consumesDraft=e.consumesDraft),e.arguments!==void 0&&(t.arguments=Ii(e.arguments)),t}function Ii(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:Oi(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:Oi(e.text.arguments)})),Object.freeze(t)}function Li(e){Hi(e.id,`command ID`,!0),Hi(e.title,`title`),Hi(e.category,`category`),Ri(e.action),zi(e.projections)}function Ri(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)Hi(t.label,`choice label`),t.description!==void 0&&Hi(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&Hi(e.presentation.submitLabel,`submit label`);return;case`confirmation`:Hi(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&Hi(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&Hi(e.presentation.cancelLabel,`cancellation label`)}}function zi(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&Ui(t.order);if(e.bindings!==void 0&&Vi(e.bindings.values,`binding`),e.slash!==void 0){Vi(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&Gi(`slash alias must not contain whitespace`);Bi(e.slash.arguments)}e.agent?.keybind!==void 0&&Hi(e.agent.keybind,`agent keybind`)}}function Bi(e){if(e===void 0)return;Hi(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&Gi(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])Hi(n.word,`argument word`),/\s/u.test(n.word)&&Gi(`argument word must not contain whitespace`),t.has(n.word)&&Gi(`argument word is repeated`),t.add(n.word),n.description!==void 0&&Hi(n.description,`argument word description`);t.size>gi&&Gi(`argument word count exceeds 32`),e.text!==void 0&&(Hi(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&Hi(e.text.requestIdField,`request id field`))}function Vi(e,t){e.length>hi&&Gi(`${t} count exceeds 16`);for(let n of e)Hi(n,t)}function Hi(e,t,n=!1){e.trim().length===0&&Gi(`${t} must not be blank`),n&&e.includes(`:`)&&Gi(`${t} must not contain a colon`)}function Ui(e){e!==void 0&&!Number.isSafeInteger(e)&&Gi(`order must be a safe integer`)}function Wi(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function Gi(e){throw Error(e)}var Ki=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),qi=Object.freeze({status:`available`});function Ji(e){let t=e.availability?.()??qi;return t.status===`available`?qi:Object.freeze({status:`unavailable`,reason:t.reason})}function Yi(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function Xi(e){if(e instanceof di){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:ki(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function Zi(e,t){let n=[],r=[],i=[],a=[],o=[],s=[],c=0;for(let l of e){let e=l.contribution;for(let l of e.commands){let u=l.projections,d=t[c++]??qi;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...ia(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...ia(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...ia(e,l,u.slash.order,d),alias:t};u.slash.consumesDraft!==void 0&&(n={...n,consumesDraft:u.slash.consumesDraft}),u.slash.arguments!==void 0&&(n={...n,arguments:u.slash.arguments}),i.push(n)}u?.help!==void 0&&a.push({...ia(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...ia(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(oa(e,l,u.agent,d))}}return ta(n),na(i),ea(r),ea(a),ea(o),ea(s),Object.freeze({bindings:ra(n),palette:ra(r),slash:ra(i),help:ra(a),menu:ra(o),agent:ra(s)})}var Qi=new TextEncoder;function $i(e,t){let n=Qi.encode(e),r=Qi.encode(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return n.length<r.length?-1:+(n.length>r.length)}function ea(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId))}function ta(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId)||$i(e.binding,t.binding))}function na(e){e.sort((e,t)=>e.order-t.order||$i(e.commandId,t.commandId)||$i(e.alias,t.alias))}function ra(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function ia(e,t,n,r){let i=aa(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function aa(e,t,n,r){let i={commandId:yi(e.namespace,t.id),command:Object.freeze({namespace:e.namespace,id:t.id}),sourceId:e.sourceId,title:t.title,category:t.category,order:n??0,availability:r},a=t.description===void 0?i:{...i,description:t.description};return t.action===void 0?a:{...a,action:t.action}}function oa(e,t,n,r){let i=ia(e,t,n.order,r),a=i.action===void 0?i:{...i,action:sa(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function sa(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}function ca(e,t){let n=!1,r=[];for(let i of t){let{availability:t,handler:a,...o}=i,s=a,c=t===void 0?o:{...o,availability:t()};e.register(c,async({arguments:e,origin:t,signal:n})=>{let r=await s(e===void 0?{origin:t,signal:n}:{arguments:e,origin:t,signal:n});return r===void 0?void 0:$e(r)}).then(e=>{n?e():r.push(e)},e=>{console.warn(`App command ${i.id} was not registered`,e)})}return()=>{if(!n){n=!0;for(let e of r.splice(0))e()}}}q(`light.dark.latte.mocha.readout.readout-night.field-guide.field-guide-night.embed.embed-dark.phosphor.codec.paper.ember.tide.tape.sunrise.pirate-radio.pirate-radio-night.consulting.consulting-ink.consulting-night.consulting-night-ink.consulting-riso-latte.consulting-riso-latte-ink.consulting-riso-glomzy.consulting-riso-glomzy-ink.vishnu.coin.coin-night.chamfer`.split(`.`));var la=`data-theme`;function ua(e){return e||(globalThis.document?.documentElement??null)}function da(e){let t=e.trim();if(t.length===0)throw TypeError(`Theme must be a non-empty string`);return t}function fa(e,t){let n=da(e),r=ua(t);r&&r.setAttribute(la,n)}function pa(e){return ua(e)?.getAttribute(la)??null}var ma=class extends cr{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:fr(t,n.data),hasPreviousPage:Rn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function ha(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var ga=class extends ft{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Lt.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!W(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(ha(e,n).forEach(e=>{e.destroy()}),ha(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=s(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new cr(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Lt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}};function _a({queries:e,...t},n){let r=ge(n),i=Bn(),a=ur(),o=t.subscribed!==!1,s=Y.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{In(e);let t=r.getQueryCache().get(e.queryHash);nr(e,a,t)}),On(a);let[c]=Y.useState(()=>new ga(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;Y.useSyncExternalStore(Y.useCallback(e=>f?c.subscribe(Lt.batchCalls(e)):g,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Y.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Kn(s[t],e))?l.flatMap((e,t)=>{let n=s[t];if(n&&Kn(n,e)){let e=new cr(r,n);return Hn(n,e,a)}return[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&li({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}function va(e){return e}function ya(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function ba(e={},t){let n=ge(t).getMutationCache(),r=Y.useRef(e),i=Y.useRef(null);return i.current===null&&(i.current=ya(n,e)),Y.useEffect(()=>{r.current=e}),Y.useSyncExternalStore(Y.useCallback(e=>n.subscribe(()=>{let t=s(i.current,ya(n,r.current));i.current!==t&&(i.current=t,Lt.schedule(e))}),[n]),()=>i.current,()=>i.current)}function xa(e,t){return $n(e,ma,t)}var Sa=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,M(x);else{var t=n(l);t!==null&&N(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&N(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-E<T)}function O(){if(C!==null){var t=e.unstable_now();E=t;var n=!0;try{n=C(!0,t)}finally{n?k():(S=!1,C=null)}}else S=!1}var k;if(typeof v==`function`)k=function(){v(O)};else if(typeof MessageChannel<`u`){var A=new MessageChannel,j=A.port2;A.port1.onmessage=O,k=function(){j.postMessage(null)}}else k=function(){g(O,0)};function M(e){C=e,S||(S=!0,k())}function N(t,n){w=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){m||p||(m=!0,M(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):T=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,N(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,M(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Ca=t(((e,t)=>{t.exports=Sa()})),wa=t((e=>{var t=Pe(),n=Ca();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n]);return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}var i=new Set,a={};function o(e,t){s(e,t),s(e+`Capture`,t)}function s(e,t){for(a[e]=t,e=0;e<t.length;e++)i.add(t[e])}var c=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),l=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},f={};function p(e){return l.call(f,e)?!0:l.call(d,e)?!1:u.test(e)?f[e]=!0:(d[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case`function`:case`symbol`:return!0;case`boolean`:return r?!1:n===null?(e=e.toLowerCase().slice(0,5),e!==`data-`&&e!==`aria-`):!n.acceptsBooleans;default:return!1}}function h(e,t,n,r){if(t==null||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var _={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){_[e]=new g(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];_[t]=new g(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){_[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){_[e]=new g(e,2,!1,e,null,!1,!1)}),`allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope`.split(` `).forEach(function(e){_[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){_[e]=new g(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){_[e]=new g(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){_[e]=new g(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){_[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}`accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(v,y);_[t]=new g(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),_.xlinkHref=new g(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){_[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function b(e,t,n,r){var i=_.hasOwnProperty(t)?_[t]:null;(i===null?r||!(2<t.length)||t[0]!==`o`&&t[0]!==`O`||t[1]!==`n`&&t[1]!==`N`:i.type!==0)&&(h(t,n,i,r)&&(n=null),r||i===null?p(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,``+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type!==3&&``:n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&!0===n?``:``+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for(`react.element`),C=Symbol.for(`react.portal`),w=Symbol.for(`react.fragment`),T=Symbol.for(`react.strict_mode`),E=Symbol.for(`react.profiler`),D=Symbol.for(`react.provider`),O=Symbol.for(`react.context`),k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.suspense`),j=Symbol.for(`react.suspense_list`),M=Symbol.for(`react.memo`),N=Symbol.for(`react.lazy`),P=Symbol.for(`react.offscreen`),F=Symbol.iterator;function I(e){return typeof e!=`object`||!e?null:(e=F&&e[F]||e[`@@iterator`],typeof e==`function`?e:null)}var L=Object.assign,R;function z(e){if(R===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);R=t&&t[1]||``}return`
|
|
3
3
|
`+R+e}var B=!1;function ee(e,t){if(!e||B)return``;B=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t){if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(t,[])}catch(e){var r=e}Reflect.construct(e,[],t)}else{try{t.call()}catch(e){r=e}e.call(t.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&typeof t.stack==`string`){for(var i=t.stack.split(`
|
|
4
4
|
`),a=r.stack.split(`
|
|
5
5
|
`),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=`
|
|
@@ -7,4 +7,4 @@ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$t as r,A as
|
|
|
7
7
|
`).replace(ui,``)}function di(e,t,n){if(t=Y(t),Y(e)!==t&&n)throw Error(r(425))}function fi(){}var pi=null,mi=null;function hi(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gi=typeof setTimeout==`function`?setTimeout:void 0,_i=typeof clearTimeout==`function`?clearTimeout:void 0,vi=typeof Promise==`function`?Promise:void 0,yi=typeof queueMicrotask==`function`?queueMicrotask:vi===void 0?gi:function(e){return vi.resolve(null).then(e).catch(bi)};function bi(e){setTimeout(function(){throw e})}function xi(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`){if(r===0){e.removeChild(i),nn(t);return}r--}else n!==`$`&&n!==`$?`&&n!==`$!`||r++}n=i}while(n);nn(t)}function Si(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`)break;if(t===`/$`)return null}}return e}function Ci(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`){if(t===0)return e;t--}else n===`/$`&&t++}e=e.previousSibling}return null}var wi=Math.random().toString(36).slice(2),Ti=`__reactFiber$`+wi,Ei=`__reactProps$`+wi,Di=`__reactContainer$`+wi,Oi=`__reactEvents$`+wi,ki=`__reactListeners$`+wi,Ai=`__reactHandles$`+wi;function ji(e){var t=e[Ti];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Di]||n[Ti]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ci(e);e!==null;){if(n=e[Ti])return n;e=Ci(e)}return t}e=n,n=e.parentNode}return null}function Mi(e){return e=e[Ti]||e[Di],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ni(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(r(33))}function Pi(e){return e[Ei]||null}var Fi=[],Ii=-1;function Li(e){return{current:e}}function Ri(e){0>Ii||(e.current=Fi[Ii],Fi[Ii]=null,Ii--)}function zi(e,t){Ii++,Fi[Ii]=e.current,e.current=t}var Bi={},Vi=Li(Bi),Hi=Li(!1),Ui=Bi;function Wi(e,t){var n=e.type.contextTypes;if(!n)return Bi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Gi(e){return e=e.childContextTypes,e!=null}function Ki(){Ri(Hi),Ri(Vi)}function qi(e,t,n){if(Vi.current!==Bi)throw Error(r(168));zi(Vi,t),zi(Hi,n)}function Ji(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ne(e)||`Unknown`,a));return L({},n,i)}function Yi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bi,Ui=Vi.current,zi(Vi,e),zi(Hi,Hi.current),!0}function Xi(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=Ji(e,t,Ui),i.__reactInternalMemoizedMergedChildContext=e,Ri(Hi),Ri(Vi),zi(Vi,e)):Ri(Hi),zi(Hi,n)}var Zi=null,Qi=!1,$i=!1;function ea(e){Zi===null?Zi=[e]:Zi.push(e)}function ta(e){Qi=!0,ea(e)}function na(){if(!$i&&Zi!==null){$i=!0;var e=0,t=Nt;try{var n=Zi;for(Nt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Zi=null,Qi=!1}catch(t){throw Zi!==null&&(Zi=Zi.slice(e+1)),rt(lt,na),t}finally{Nt=t,$i=!1}}return null}var ra=[],ia=0,aa=null,oa=0,sa=[],ca=0,la=null,ua=1,da=``;function fa(e,t){ra[ia++]=oa,ra[ia++]=aa,aa=e,oa=t}function pa(e,t,n){sa[ca++]=ua,sa[ca++]=da,sa[ca++]=la,la=e;var r=ua;e=da;var i=32-_t(r)-1;r&=~(1<<i),n+=1;var a=32-_t(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ua=1<<32-_t(t)+i|n<<i|r,da=a+e}else ua=1<<a|n<<i|r,da=e}function ma(e){e.return!==null&&(fa(e,1),pa(e,1,0))}function ha(e){for(;e===aa;)aa=ra[--ia],ra[ia]=null,oa=ra[--ia],ra[ia]=null;for(;e===la;)la=sa[--ca],sa[ca]=null,da=sa[--ca],sa[ca]=null,ua=sa[--ca],sa[ca]=null}var ga=null,_a=null,va=!1,ya=null;function ba(e,t){var n=Yl(5,null,null,0);n.elementType=`DELETED`,n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function xa(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null&&(e.stateNode=t,ga=e,_a=Si(t.firstChild),!0);case 6:return t=e.pendingProps===``||t.nodeType!==3?null:t,t!==null&&(e.stateNode=t,ga=e,_a=null,!0);case 13:return t=t.nodeType===8?t:null,t!==null&&(n=la===null?null:{id:ua,overflow:da},e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Yl(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ga=e,_a=null,!0);default:return!1}}function Sa(e){return!!(e.mode&1)&&!(e.flags&128)}function wa(e){if(va){var t=_a;if(t){var n=t;if(!xa(e,t)){if(Sa(e))throw Error(r(418));t=Si(n.nextSibling);var i=ga;t&&xa(e,t)?ba(i,n):(e.flags=e.flags&-4097|2,va=!1,ga=e)}}else{if(Sa(e))throw Error(r(418));e.flags=e.flags&-4097|2,va=!1,ga=e}}}function Ta(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ga=e}function Ea(e){if(e!==ga)return!1;if(!va)return Ta(e),va=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!==`head`&&t!==`body`&&!hi(e.type,e.memoizedProps)),t&&=_a){if(Sa(e))throw Da(),Error(r(418));for(;t;)ba(e,t),t=Si(t.nextSibling)}if(Ta(e),e.tag===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));a:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`){if(t===0){_a=Si(e.nextSibling);break a}t--}else n!==`$`&&n!==`$!`&&n!==`$?`||t++}e=e.nextSibling}_a=null}}else _a=ga?Si(e.stateNode.nextSibling):null;return!0}function Da(){for(var e=_a;e;)e=Si(e.nextSibling)}function Oa(){_a=ga=null,va=!1}function ka(e){ya===null?ya=[e]:ya.push(e)}var Aa=x.ReactCurrentBatchConfig;function ja(e,t,n){if(e=n.ref,e!==null&&typeof e!=`function`&&typeof e!=`object`){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(r(309));var i=n.stateNode}if(!i)throw Error(r(147,e));var a=i,o=``+e;return t!==null&&t.ref!==null&&typeof t.ref==`function`&&t.ref._stringRef===o?t.ref:(t=function(e){var t=a.refs;e===null?delete t[o]:t[o]=e},t._stringRef=o,t)}if(typeof e!=`string`)throw Error(r(284));if(!n._owner)throw Error(r(290,e))}return e}function Ma(e,t){throw e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e))}function Na(e){var t=e._init;return t(e._payload)}function Pa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function i(e,t){for(e=new Map;t!==null;)t.key===null?e.set(t.index,t):e.set(t.key,t),t=t.sibling;return e}function a(e,t){return e=Ql(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=2,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=2),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=nu(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===w?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===N&&Na(i)===t.type)?(r=a(t,n.props),r.ref=ja(e,t,n),r.return=e,r):(r=$l(n.type,n.key,n.props,null,e.mode,r),r.ref=ja(e,t,n),r.return=e,r)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ru(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=eu(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`)return t=nu(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case S:return n=$l(t.type,t.key,t.props,null,e.mode,n),n.ref=ja(e,null,t),n.return=e,n;case C:return t=ru(t,e.mode,n),t.return=e,t;case N:var r=t._init;return f(e,r(t._payload),n)}if(K(t)||I(t))return t=eu(t,e.mode,n,null),t.return=e,t;Ma(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case S:return n.key===i?l(e,t,n,r):null;case C:return n.key===i?u(e,t,n,r):null;case N:return i=n._init,p(e,t,i(n._payload),r)}if(K(n)||I(n))return i===null?d(e,t,n,r,null):null;Ma(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case S:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case C:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case N:var a=r._init;return m(e,t,n,a(r._payload),i)}if(K(r)||I(r))return e=e.get(n)||null,d(t,e,r,i,null);Ma(t,r)}return null}function h(r,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),va&&fa(r,h),l;if(d===null){for(;h<s.length;h++)d=f(r,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return va&&fa(r,h),l}for(d=i(r,d);h<s.length;h++)g=m(d,r,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(r,e)}),va&&fa(r,h),l}function g(a,s,c,l){var u=I(c);if(typeof u!=`function`)throw Error(r(150));if(c=u.call(c),c==null)throw Error(r(151));for(var d=u=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),va&&fa(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return va&&fa(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),va&&fa(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===w&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case S:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===w){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===N&&Na(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=ja(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===w?(r=eu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=$l(i.type,i.key,i.props,null,e.mode,o),o.ref=ja(e,r,i),o.return=e,e=o)}return s(e);case C:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=ru(i,e.mode,o),r.return=e,e=r}return s(e);case N:return l=i._init,_(e,r,l(i._payload),o)}if(K(i))return h(e,r,i,o);if(I(i))return g(e,r,i,o);Ma(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=nu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Fa=Pa(!0),Ia=Pa(!1),La=Li(null),Ra=null,za=null,Ba=null;function Va(){Ba=za=Ra=null}function Ha(e){var t=La.current;Ri(La),e._currentValue=t}function Ua(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Wa(e,t){Ra=e,Ba=za=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ps=!0),e.firstContext=null)}function Ga(e){var t=e._currentValue;if(Ba!==e){if(e={context:e,memoizedValue:t,next:null},za===null){if(Ra===null)throw Error(r(308));za=e,Ra.dependencies={lanes:0,firstContext:e}}else za=za.next=e}return t}var Ka=null;function qa(e){Ka===null?Ka=[e]:Ka.push(e)}function Ja(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,qa(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ya(e,r)}function Ya(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Xa=!1;function Za(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $a(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function eo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Uc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ya(e,n)}return i=r.interleaved,i===null?(t.next=t,qa(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ya(e,n)}function to(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Mt(e,n)}}function no(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ro(e,t,n,r){var i=e.updateQueue;Xa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=L({},d,f);break a;case 2:Xa=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Zc|=o,e.lanes=o,e.memoizedState=d}}function io(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var i=e[t],a=i.callback;if(a!==null){if(i.callback=null,i=n,typeof a!=`function`)throw Error(r(191,a));a.call(i)}}}var ao={},oo=Li(ao),so=Li(ao),co=Li(ao);function lo(e){if(e===ao)throw Error(r(174));return e}function uo(e,t){switch(zi(co,t),zi(so,e),zi(oo,ao),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:_e(null,``);break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=_e(t,e)}Ri(oo),zi(oo,t)}function fo(){Ri(oo),Ri(so),Ri(co)}function po(e){lo(co.current);var t=lo(oo.current),n=_e(t,e.type);t!==n&&(zi(so,e),zi(oo,n))}function mo(e){so.current===e&&(Ri(oo),Ri(so))}var ho=Li(0);function go(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data===`$?`||n.data===`$!`))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var _o=[];function vo(){for(var e=0;e<_o.length;e++)_o[e]._workInProgressVersionPrimary=null;_o.length=0}var yo=x.ReactCurrentDispatcher,bo=x.ReactCurrentBatchConfig,xo=0,So=null,Co=null,wo=null,To=!1,Eo=!1,Do=0,Oo=0;function ko(){throw Error(r(321))}function Ao(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!xr(e[n],t[n]))return!1;return!0}function jo(e,t,n,i,a,o){if(xo=o,So=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,yo.current=e===null||e.memoizedState===null?ms:hs,e=n(i,a),Eo){o=0;do{if(Eo=!1,Do=0,25<=o)throw Error(r(301));o+=1,wo=Co=null,t.updateQueue=null,yo.current=gs,e=n(i,a)}while(Eo)}if(yo.current=ps,t=Co!==null&&Co.next!==null,xo=0,wo=Co=So=null,To=!1,t)throw Error(r(300));return e}function Mo(){var e=Do!==0;return Do=0,e}function No(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wo===null?So.memoizedState=wo=e:wo=wo.next=e,wo}function Po(){if(Co===null){var e=So.alternate;e=e===null?null:e.memoizedState}else e=Co.next;var t=wo===null?So.memoizedState:wo.next;if(t!==null)wo=t,Co=e;else{if(e===null)throw Error(r(310));Co=e,e={memoizedState:Co.memoizedState,baseState:Co.baseState,baseQueue:Co.baseQueue,queue:Co.queue,next:null},wo===null?So.memoizedState=wo=e:wo=wo.next=e}return wo}function Fo(e,t){return typeof t==`function`?t(e):t}function Io(e){var t=Po(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=Co,a=i.baseQueue,o=n.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}i.baseQueue=a=o,n.pending=null}if(a!==null){o=a.next,i=i.baseState;var c=s=null,l=null,u=o;do{var d=u.lane;if((xo&d)===d)l!==null&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),i=u.hasEagerState?u.eagerState:e(i,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};l===null?(c=l=f,s=i):l=l.next=f,So.lanes|=d,Zc|=d}u=u.next}while(u!==null&&u!==o);l===null?s=i:l.next=c,xr(i,t.memoizedState)||(Ps=!0),t.memoizedState=i,t.baseState=s,t.baseQueue=l,n.lastRenderedState=i}if(e=n.interleaved,e!==null){a=e;do o=a.lane,So.lanes|=o,Zc|=o,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Lo(e){var t=Po(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);xr(o,t.memoizedState)||(Ps=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Ro(){}function zo(e,t){var n=So,i=Po(),a=t(),o=!xr(i.memoizedState,a);if(o&&(i.memoizedState=a,Ps=!0),i=i.queue,Zo(Ho.bind(null,n,i,e),[e]),i.getSnapshot!==t||o||wo!==null&&wo.memoizedState.tag&1){if(n.flags|=2048,Ko(9,Vo.bind(null,n,i,a,t),void 0,null),Wc===null)throw Error(r(349));xo&30||Bo(n,t,a)}return a}function Bo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=So.updateQueue,t===null?(t={lastEffect:null,stores:null},So.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Vo(e,t,n,r){t.value=n,t.getSnapshot=r,Uo(t)&&Wo(e)}function Ho(e,t,n){return n(function(){Uo(t)&&Wo(e)})}function Uo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!xr(e,n)}catch{return!0}}function Wo(e){var t=Ya(e,1);t!==null&&_l(t,e,1,-1)}function Go(e){var t=No();return typeof e==`function`&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:e},t.queue=e,e=e.dispatch=ls.bind(null,So,e),[t.memoizedState,e]}function Ko(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=So.updateQueue,t===null?(t={lastEffect:null,stores:null},So.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function qo(){return Po().memoizedState}function Jo(e,t,n,r){var i=No();So.flags|=e,i.memoizedState=Ko(1|t,n,void 0,r===void 0?null:r)}function Yo(e,t,n,r){var i=Po();r=r===void 0?null:r;var a=void 0;if(Co!==null){var o=Co.memoizedState;if(a=o.destroy,r!==null&&Ao(r,o.deps)){i.memoizedState=Ko(t,n,a,r);return}}So.flags|=e,i.memoizedState=Ko(1|t,n,a,r)}function Xo(e,t){return Jo(8390656,8,e,t)}function Zo(e,t){return Yo(2048,8,e,t)}function Qo(e,t){return Yo(4,2,e,t)}function $o(e,t){return Yo(4,4,e,t)}function es(e,t){if(typeof t==`function`)return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ts(e,t,n){return n=n==null?null:n.concat([e]),Yo(4,4,es.bind(null,t,e),n)}function ns(){}function rs(e,t){var n=Po();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ao(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function is(e,t){var n=Po();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Ao(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function as(e,t,n){return xo&21?(xr(n,t)||(n=Ot(),So.lanes|=n,Zc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ps=!0),e.memoizedState=n)}function os(e,t){var n=Nt;Nt=n!==0&&4>n?n:4,e(!0);var r=bo.transition;bo.transition={};try{e(!1),t()}finally{Nt=n,bo.transition=r}}function ss(){return Po().memoizedState}function cs(e,t,n){var r=gl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},us(e))ds(t,n);else if(n=Ja(e,t,n,r),n!==null){var i=hl();_l(n,e,r,i),fs(n,t,r)}}function ls(e,t,n){var r=gl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(us(e))ds(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,xr(s,o)){var c=t.interleaved;c===null?(i.next=i,qa(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Ja(e,t,i,r),n!==null&&(i=hl(),_l(n,e,r,i),fs(n,t,r))}}function us(e){var t=e.alternate;return e===So||t!==null&&t===So}function ds(e,t){Eo=To=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Mt(e,n)}}var ps={readContext:Ga,useCallback:ko,useContext:ko,useEffect:ko,useImperativeHandle:ko,useInsertionEffect:ko,useLayoutEffect:ko,useMemo:ko,useReducer:ko,useRef:ko,useState:ko,useDebugValue:ko,useDeferredValue:ko,useTransition:ko,useMutableSource:ko,useSyncExternalStore:ko,useId:ko,unstable_isNewReconciler:!1},ms={readContext:Ga,useCallback:function(e,t){return No().memoizedState=[e,t===void 0?null:t],e},useContext:Ga,useEffect:Xo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Jo(4194308,4,es.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Jo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Jo(4,2,e,t)},useMemo:function(e,t){var n=No();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=No();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=cs.bind(null,So,e),[r.memoizedState,e]},useRef:function(e){var t=No();return e={current:e},t.memoizedState=e},useState:Go,useDebugValue:ns,useDeferredValue:function(e){return No().memoizedState=e},useTransition:function(){var e=Go(!1),t=e[0];return e=os.bind(null,e[1]),No().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=So,a=No();if(va){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Wc===null)throw Error(r(349));xo&30||Bo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Xo(Ho.bind(null,i,o,e),[e]),i.flags|=2048,Ko(9,Vo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=No(),t=Wc.identifierPrefix;if(va){var n=da,r=ua;n=(r&~(1<<32-_t(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Do++,0<n&&(t+=`H`+n.toString(32)),t+=`:`}else n=Oo++,t=`:`+t+`r`+n.toString(32)+`:`;return e.memoizedState=t},unstable_isNewReconciler:!1},hs={readContext:Ga,useCallback:rs,useContext:Ga,useEffect:Zo,useImperativeHandle:ts,useInsertionEffect:Qo,useLayoutEffect:$o,useMemo:is,useReducer:Io,useRef:qo,useState:function(){return Io(Fo)},useDebugValue:ns,useDeferredValue:function(e){return as(Po(),Co.memoizedState,e)},useTransition:function(){return[Io(Fo)[0],Po().memoizedState]},useMutableSource:Ro,useSyncExternalStore:zo,useId:ss,unstable_isNewReconciler:!1},gs={readContext:Ga,useCallback:rs,useContext:Ga,useEffect:Zo,useImperativeHandle:ts,useInsertionEffect:Qo,useLayoutEffect:$o,useMemo:is,useReducer:Lo,useRef:qo,useState:function(){return Lo(Fo)},useDebugValue:ns,useDeferredValue:function(e){var t=Po();return Co===null?t.memoizedState=e:as(t,Co.memoizedState,e)},useTransition:function(){return[Lo(Fo)[0],Po().memoizedState]},useMutableSource:Ro,useSyncExternalStore:zo,useId:ss,unstable_isNewReconciler:!1};function _s(e,t){if(e&&e.defaultProps){for(var n in t=L({},t),e=e.defaultProps,e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function vs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:L({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ys={isMounted:function(e){return(e=e._reactInternals)?Ze(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=hl(),i=gl(e),a=$a(r,i);a.payload=t,n!=null&&(a.callback=n),t=eo(e,a,i),t!==null&&(_l(t,e,i,r),to(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=hl(),i=gl(e),a=$a(r,i);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=eo(e,a,i),t!==null&&(_l(t,e,i,r),to(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=hl(),r=gl(e),i=$a(n,r);i.tag=2,t!=null&&(i.callback=t),t=eo(e,i,r),t!==null&&(_l(t,e,r,n),to(t,e,r))}};function bs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Sr(n,r)||!Sr(i,a):!0}function xs(e,t,n){var r=!1,i=Bi,a=t.contextType;return typeof a==`object`&&a?a=Ga(a):(i=Gi(t)?Ui:Vi.current,r=t.contextTypes,a=(r=r!=null)?Wi(e,i):Bi),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ys,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Ss(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&ys.enqueueReplaceState(t,t.state,null)}function Cs(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Za(e);var a=t.contextType;typeof a==`object`&&a?i.context=Ga(a):(a=Gi(t)?Ui:Vi.current,i.context=Wi(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a==`function`&&(vs(e,t,a,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps==`function`||typeof i.getSnapshotBeforeUpdate==`function`||typeof i.UNSAFE_componentWillMount!=`function`&&typeof i.componentWillMount!=`function`||(t=i.state,typeof i.componentWillMount==`function`&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount==`function`&&i.UNSAFE_componentWillMount(),t!==i.state&&ys.enqueueReplaceState(i,i.state,null),ro(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount==`function`&&(e.flags|=4194308)}function ws(e,t){try{var n=``,r=t;do n+=V(r),r=r.return;while(r);var i=n}catch(e){i=`
|
|
8
8
|
Error generating stack: `+e.message+`
|
|
9
9
|
`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ts(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Es(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Ds=typeof WeakMap==`function`?WeakMap:Map;function Os(e,t,n){n=$a(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){al||(al=!0,ol=r),Es(e,t)},n}function ks(e,t,n){n=$a(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Es(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Es(e,t),typeof r!=`function`&&(sl===null?sl=new Set([this]):sl.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function As(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ds;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Hl.bind(null,e,t,n),t.then(e,e))}function js(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Ms(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=$a(-1,1),t.tag=2,eo(n,t,1))),n.lanes|=1),e)}var Ns=x.ReactCurrentOwner,Ps=!1;function Fs(e,t,n,r){t.child=e===null?Ia(t,null,n,r):Fa(t,e.child,n,r)}function Is(e,t,n,r,i){n=n.render;var a=t.ref;return Wa(t,i),r=jo(e,t,n,r,a,i),n=Mo(),e!==null&&!Ps?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,nc(e,t,i)):(va&&n&&ma(t),t.flags|=1,Fs(e,t,r,i),t.child)}function Ls(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Xl(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Rs(e,t,a,r,i)):(e=$l(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Sr:n,n(o,r)&&e.ref===t.ref)return nc(e,t,i)}return t.flags|=1,e=Ql(a,r),e.ref=t.ref,e.return=t,t.child=e}function Rs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Sr(a,r)&&e.ref===t.ref){if(Ps=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ps=!0);else return t.lanes=e.lanes,nc(e,t,i)}}return Vs(e,t,n,r,i)}function zs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`){if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},zi(Jc,qc),qc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,zi(Jc,qc),qc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,zi(Jc,qc),qc|=r}}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),zi(Jc,qc),qc|=r;return Fs(e,t,i,n),t.child}function Bs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Vs(e,t,n,r,i){var a=Gi(n)?Ui:Vi.current;return a=Wi(t,a),Wa(t,i),n=jo(e,t,n,r,a,i),r=Mo(),e!==null&&!Ps?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,nc(e,t,i)):(va&&r&&ma(t),t.flags|=1,Fs(e,t,n,i),t.child)}function Hs(e,t,n,r,i){if(Gi(n)){var a=!0;Yi(t)}else a=!1;if(Wa(t,i),t.stateNode===null)tc(e,t),xs(t,n,r),Cs(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=Ga(l):(l=Gi(n)?Ui:Vi.current,l=Wi(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Ss(t,o,r,l),Xa=!1;var f=t.memoizedState;o.state=f,ro(t,r,o,i),c=t.memoizedState,s!==r||f!==c||Hi.current||Xa?(typeof u==`function`&&(vs(t,n,u,r),c=t.memoizedState),(s=Xa||bs(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,Qa(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:_s(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=Ga(c):(c=Gi(n)?Ui:Vi.current,c=Wi(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Ss(t,o,r,c),Xa=!1,f=t.memoizedState,o.state=f,ro(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||Hi.current||Xa?(typeof p==`function`&&(vs(t,n,p,r),m=t.memoizedState),(l=Xa||bs(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Us(e,t,n,r,a,i)}function Us(e,t,n,r,i,a){Bs(e,t);var o=!!(t.flags&128);if(!r&&!o)return i&&Xi(t,n,!1),nc(e,t,a);r=t.stateNode,Ns.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Fa(t,e.child,null,a),t.child=Fa(t,null,s,a)):Fs(e,t,s,a),t.memoizedState=r.state,i&&Xi(t,n,!0),t.child}function Ws(e){var t=e.stateNode;t.pendingContext?qi(e,t.pendingContext,t.pendingContext!==t.context):t.context&&qi(e,t.context,!1),uo(e,t.containerInfo)}function Gs(e,t,n,r,i){return Oa(),ka(i),t.flags|=256,Fs(e,t,n,r),t.child}var Ks={dehydrated:null,treeContext:null,retryLane:0};function qs(e){return{baseLanes:e,cachePool:null,transitions:null}}function Js(e,t,n){var r=t.pendingProps,i=ho.current,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(i&2)),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),zi(ho,i&1),e===null)return wa(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.lanes=t.mode&1?e.data===`$!`?8:1073741824:1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=tu(o,r,0,null),e=eu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=qs(n),t.memoizedState=Ks,e):Ys(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return Zs(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Ql(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=eu(a,o,n,null),a.flags|=2):a=Ql(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?qs(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=Ks,r}return a=e.child,e=a.sibling,r=Ql(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ys(e,t){return t=tu({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function Xs(e,t,n,r){return r!==null&&ka(r),Fa(t,e.child,null,n),e=Ys(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Zs(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ts(Error(r(422))),Xs(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=tu({mode:`visible`,children:i.children},a,0,null),o=eu(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Fa(t,e.child,null,s),t.child.memoizedState=qs(s),t.memoizedState=Ks,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return Xs(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ts(o,i,void 0),Xs(e,t,s,i)}if(c=(s&e.childLanes)!==0,Ps||c){if(i=Wc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,Ya(e,a),_l(i,e,a,-1))}return jl(),i=Ts(Error(r(421))),Xs(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Wl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,_a=Si(a.nextSibling),ga=t,va=!0,ya=null,e!==null&&(sa[ca++]=ua,sa[ca++]=da,sa[ca++]=la,ua=e.id,da=e.overflow,la=t),t=Ys(t,i.children),t.flags|=4096,t)}function Qs(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ua(e.return,t,n)}function $s(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function ec(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Fs(e,t,r.children,n),r=ho.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Qs(e,n,t);else if(e.tag===19)Qs(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(zi(ho,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&go(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),$s(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&go(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}$s(t,!0,n,null,a);break;case`together`:$s(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function tc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function nc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Zc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Ql(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ql(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rc(e,t,n){switch(t.tag){case 3:Ws(t),Oa();break;case 5:po(t);break;case 1:Gi(t.type)&&Yi(t);break;case 4:uo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;zi(La,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(zi(ho,ho.current&1),e=nc(e,t,n),e===null?null:e.sibling):Js(e,t,n):(zi(ho,ho.current&1),t.flags|=128,null);zi(ho,ho.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return ec(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),zi(ho,ho.current),r)break;return null;case 22:case 23:return t.lanes=0,zs(e,t,n)}return nc(e,t,n)}var ic=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},ac=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,lo(oo.current);var o=null;switch(n){case`input`:i=G(e,i),r=G(e,r),o=[];break;case`select`:i=L({},i,{value:void 0}),r=L({},r,{value:void 0}),o=[];break;case`textarea`:i=fe(e,i),r=fe(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=fi)}Te(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null){if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null))}for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null)){if(u===`style`){if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l}else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&$r(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},oc=function(e,t,n,r){n!==r&&(t.flags|=4)};function sc(e,t){if(!va)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function cc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function lc(e,t,n){var i=t.pendingProps;switch(ha(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cc(t),null;case 1:return Gi(t.type)&&Ki(),cc(t),null;case 3:return i=t.stateNode,fo(),Ri(Hi),Ri(Vi),vo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Ea(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ya!==null&&(xl(ya),ya=null))),cc(t),null;case 5:mo(t);var o=lo(co.current);if(n=t.type,e!==null&&t.stateNode!=null)ac(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return cc(t),null}if(e=lo(oo.current),Ea(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Ti]=t,i[Ei]=s,e=!!(t.mode&1),n){case`dialog`:$r(`cancel`,i),$r(`close`,i);break;case`iframe`:case`object`:case`embed`:$r(`load`,i);break;case`video`:case`audio`:for(o=0;o<Yr.length;o++)$r(Yr[o],i);break;case`source`:$r(`error`,i);break;case`img`:case`image`:case`link`:$r(`error`,i),$r(`load`,i);break;case`details`:$r(`toggle`,i);break;case`input`:oe(i,s),$r(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},$r(`invalid`,i);break;case`textarea`:pe(i,s),$r(`invalid`,i)}for(var c in Te(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&di(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&di(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&$r(`scroll`,i)}switch(n){case`input`:W(i),le(i,s,!0);break;case`textarea`:W(i),he(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=fi)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=ge(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ti]=t,e[Ei]=i,ic(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ee(n,i),n){case`dialog`:$r(`cancel`,e),$r(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:$r(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<Yr.length;o++)$r(Yr[o],e);o=i;break;case`source`:$r(`error`,e),o=i;break;case`img`:case`image`:case`link`:$r(`error`,e),$r(`load`,e),o=i;break;case`details`:$r(`toggle`,e),o=i;break;case`input`:oe(e,i),o=G(e,i),$r(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=L({},i,{value:void 0}),$r(`invalid`,e);break;case`textarea`:pe(e,i),o=fe(e,i),$r(`invalid`,e);break;default:o=i}for(s in Te(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?Ce(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&q(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&ye(e,u):typeof u==`number`&&ye(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&$r(`scroll`,e):u!=null&&b(e,s,u,c))}switch(n){case`input`:W(e),le(e,i,!1);break;case`textarea`:W(e),he(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+H(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&de(e,!!i.multiple,i.defaultValue,!0):de(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=fi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return cc(t),null;case 6:if(e&&t.stateNode!=null)oc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=lo(co.current),lo(oo.current),Ea(t)){if(i=t.stateNode,n=t.memoizedProps,i[Ti]=t,(s=i.nodeValue!==n)&&(e=ga,e!==null))switch(e.tag){case 3:di(i.nodeValue,n,!!(e.mode&1));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&di(i.nodeValue,n,!!(e.mode&1))}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Ti]=t,t.stateNode=i}return cc(t),null;case 13:if(Ri(ho),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(va&&_a!==null&&t.mode&1&&!(t.flags&128))Da(),Oa(),t.flags|=98560,s=!1;else if(s=Ea(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Ti]=t}else Oa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;cc(t),s=!1}else ya!==null&&(xl(ya),ya=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||ho.current&1?Yc===0&&(Yc=3):jl())),t.updateQueue!==null&&(t.flags|=4),cc(t),null);case 4:return fo(),e===null&&ni(t.stateNode.containerInfo),cc(t),null;case 10:return Ha(t.type._context),cc(t),null;case 17:return Gi(t.type)&&Ki(),cc(t),null;case 19:if(Ri(ho),s=t.memoizedState,s===null)return cc(t),null;if(i=!!(t.flags&128),c=s.rendering,c===null){if(i)sc(s,!1);else{if(Yc!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=go(e),c!==null){for(t.flags|=128,sc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return zi(ho,ho.current&1|2),t.child}e=e.sibling}s.tail!==null&&st()>rl&&(t.flags|=128,i=!0,sc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=go(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),sc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!va)return cc(t),null}else 2*st()-s.renderingStartTime>rl&&n!==1073741824&&(t.flags|=128,i=!0,sc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(cc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=st(),t.sibling=null,n=ho.current,zi(ho,i?n&1|2:n&1),t);case 22:case 23:return Dl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?qc&1073741824&&(cc(t),t.subtreeFlags&6&&(t.flags|=8192)):cc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function uc(e,t){switch(ha(t),t.tag){case 1:return Gi(t.type)&&Ki(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return fo(),Ri(Hi),Ri(Vi),vo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return mo(t),null;case 13:if(Ri(ho),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Oa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ri(ho),null;case 4:return fo(),null;case 10:return Ha(t.type._context),null;case 22:case 23:return Dl(),null;case 24:return null;default:return null}}var dc=!1,fc=!1,pc=typeof WeakSet==`function`?WeakSet:Set,X=null;function mc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Vl(e,t,n)}else n.current=null}}function hc(e,t,n){try{n()}catch(n){Vl(e,t,n)}}var gc=!1;function _c(e,t){if(pi=an,e=Er(),Dr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(mi={focusedElem:e,selectionRange:n},an=!1,X=t;X!==null;)if(t=X,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,X=e;else for(;X!==null;){t=X;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:_s(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Vl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,X=e;break}X=t.return}return h=gc,gc=!1,h}function vc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&hc(t,n,a)}i=i.next}while(i!==r)}}function yc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function bc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function xc(e){var t=e.alternate;t!==null&&(e.alternate=null,xc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ti],delete t[Ei],delete t[Oi],delete t[ki],delete t[Ai])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function Cc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=fi));else if(r!==4&&(e=e.child,e!==null))for(wc(e,t,n),e=e.sibling;e!==null;)wc(e,t,n),e=e.sibling}function Tc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Tc(e,t,n),e=e.sibling;e!==null;)Tc(e,t,n),e=e.sibling}var Ec=null,Dc=!1;function Oc(e,t,n){for(n=n.child;n!==null;)kc(e,t,n),n=n.sibling}function kc(e,t,n){if(ht&&typeof ht.onCommitFiberUnmount==`function`)try{ht.onCommitFiberUnmount(mt,n)}catch{}switch(n.tag){case 5:fc||mc(n,t);case 6:var r=Ec,i=Dc;Ec=null,Oc(e,t,n),Ec=r,Dc=i,Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ec.removeChild(n.stateNode));break;case 18:Ec!==null&&(Dc?(e=Ec,n=n.stateNode,e.nodeType===8?xi(e.parentNode,n):e.nodeType===1&&xi(e,n),nn(e)):xi(Ec,n.stateNode));break;case 4:r=Ec,i=Dc,Ec=n.stateNode.containerInfo,Dc=!0,Oc(e,t,n),Ec=r,Dc=i;break;case 0:case 11:case 14:case 15:if(!fc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&hc(n,t,o),i=i.next}while(i!==r)}Oc(e,t,n);break;case 1:if(!fc&&(mc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Vl(n,t,e)}Oc(e,t,n);break;case 21:Oc(e,t,n);break;case 22:n.mode&1?(fc=(r=fc)||n.memoizedState!==null,Oc(e,t,n),fc=r):Oc(e,t,n);break;default:Oc(e,t,n)}}function Ac(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pc),t.forEach(function(t){var r=Gl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function jc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Ec=c.stateNode,Dc=!1;break a;case 3:Ec=c.stateNode.containerInfo,Dc=!0;break a;case 4:Ec=c.stateNode.containerInfo,Dc=!0;break a}c=c.return}if(Ec===null)throw Error(r(160));kc(o,s,a),Ec=null,Dc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){Vl(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Mc(t,e),t=t.sibling}function Mc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(jc(t,e),Nc(e),i&4){try{vc(3,e,e.return),yc(3,e)}catch(t){Vl(e,e.return,t)}try{vc(5,e,e.return)}catch(t){Vl(e,e.return,t)}}break;case 1:jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return);break;case 5:if(jc(t,e),Nc(e),i&512&&n!==null&&mc(n,n.return),e.flags&32){var a=e.stateNode;try{ye(a,``)}catch(t){Vl(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&se(a,o),Ee(c,s);var u=Ee(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?Ce(a,f):d===`dangerouslySetInnerHTML`?q(a,f):d===`children`?ye(a,f):b(a,d,f,u)}switch(c){case`input`:ce(a,o);break;case`textarea`:me(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?de(a,!!o.multiple,o.multiple?[]:``,!1):de(a,!!o.multiple,o.defaultValue,!0)):de(a,!!o.multiple,m,!1)}a[Ei]=o}catch(t){Vl(e,e.return,t)}}break;case 6:if(jc(t,e),Nc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){Vl(e,e.return,t)}}break;case 3:if(jc(t,e),Nc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{nn(t.containerInfo)}catch(t){Vl(e,e.return,t)}break;case 4:jc(t,e),Nc(e);break;case 13:jc(t,e),Nc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(nl=st())),i&4&&Ac(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(fc=(u=fc)||d,jc(t,e),fc=u):jc(t,e),Nc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(X=e,d=e.child;d!==null;){for(f=X=d;X!==null;){switch(p=X,m=p.child,p.tag){case 0:case 11:case 14:case 15:vc(4,p,p.return);break;case 1:mc(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){Vl(i,n,e)}}break;case 5:mc(p,p.return);break;case 22:if(p.memoizedState!==null){Lc(f);continue}}m===null?Lc(f):(m.return=p,X=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Se(`display`,s))}catch(t){Vl(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){Vl(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:jc(t,e),Nc(e),i&4&&Ac(e);break;case 21:break;default:jc(t,e),Nc(e)}}function Nc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Sc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(ye(a,``),i.flags&=-33),Tc(e,Cc(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;wc(e,Cc(e),o);break;default:throw Error(r(161))}}catch(t){Vl(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Pc(e,t,n){X=e,Fc(e,t,n)}function Fc(e,t,n){for(var r=!!(e.mode&1);X!==null;){var i=X,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||dc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||fc;s=dc;var l=fc;if(dc=o,(fc=c)&&!l)for(X=i;X!==null;)o=X,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Rc(i):(c.return=o,X=c);for(;a!==null;)X=a,Fc(a,t,n),a=a.sibling;X=i,dc=s,fc=l}Ic(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,X=a):Ic(e,t,n)}}function Ic(e){for(;X!==null;){var t=X;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:fc||yc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!fc){if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:_s(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}}var o=t.updateQueue;o!==null&&io(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}io(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&nn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}fc||t.flags&512&&bc(t)}catch(e){Vl(t,t.return,e)}}if(t===e){X=null;break}if(n=t.sibling,n!==null){n.return=t.return,X=n;break}X=t.return}}function Lc(e){for(;X!==null;){var t=X;if(t===e){X=null;break}var n=t.sibling;if(n!==null){n.return=t.return,X=n;break}X=t.return}}function Rc(e){for(;X!==null;){var t=X;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{yc(4,t)}catch(e){Vl(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){Vl(t,i,e)}}var a=t.return;try{bc(t)}catch(e){Vl(t,a,e)}break;case 5:var o=t.return;try{bc(t)}catch(e){Vl(t,o,e)}}}catch(e){Vl(t,t.return,e)}if(t===e){X=null;break}var s=t.sibling;if(s!==null){s.return=t.return,X=s;break}X=t.return}}var zc=Math.ceil,Bc=x.ReactCurrentDispatcher,Vc=x.ReactCurrentOwner,Hc=x.ReactCurrentBatchConfig,Uc=0,Wc=null,Gc=null,Kc=0,qc=0,Jc=Li(0),Yc=0,Xc=null,Zc=0,Qc=0,$c=0,el=null,tl=null,nl=0,rl=1/0,il=null,al=!1,ol=null,sl=null,cl=!1,ll=null,ul=0,dl=0,fl=null,pl=-1,ml=0;function hl(){return Uc&6?st():pl===-1?pl=st():pl}function gl(e){return e.mode&1?Uc&2&&Kc!==0?Kc&-Kc:Aa.transition===null?(e=Nt,e===0?(e=window.event,e=e===void 0?16:dn(e.type),e):e):(ml===0&&(ml=Ot()),ml):1}function _l(e,t,n,i){if(50<dl)throw dl=0,fl=null,Error(r(185));At(e,n,i),(!(Uc&2)||e!==Wc)&&(e===Wc&&(!(Uc&2)&&(Qc|=n),Yc===4&&Cl(e,Kc)),vl(e,i),n===1&&Uc===0&&!(t.mode&1)&&(rl=st()+500,Qi&&na()))}function vl(e,t){var n=e.callbackNode;Et(e,t);var r=wt(e,e===Wc?Kc:0);if(r===0)n!==null&&it(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&it(n),t===1)e.tag===0?ta(wl.bind(null,e)):ea(wl.bind(null,e)),yi(function(){!(Uc&6)&&na()}),n=null;else{switch(Pt(r)){case 1:n=lt;break;case 4:n=ut;break;case 16:n=dt;break;case 536870912:n=pt;break;default:n=dt}n=ql(n,yl.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function yl(e,t){if(pl=-1,ml=0,Uc&6)throw Error(r(327));var n=e.callbackNode;if(zl()&&e.callbackNode!==n)return null;var i=wt(e,e===Wc?Kc:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Ml(e,i);else{t=i;var a=Uc;Uc|=2;var o=Al();(Wc!==e||Kc!==t)&&(il=null,rl=st()+500,Ol(e,t));do try{Pl();break}catch(t){kl(e,t)}while(1);Va(),Bc.current=o,Uc=a,Gc===null?(Wc=null,Kc=0,t=Yc):t=0}if(t!==0){if(t===2&&(a=Dt(e),a!==0&&(i=a,t=bl(e,a))),t===1)throw n=Xc,Ol(e,0),Cl(e,i),vl(e,st()),n;if(t===6)Cl(e,i);else{if(a=e.current.alternate,!(i&30)&&!Sl(a)&&(t=Ml(e,i),t===2&&(o=Dt(e),o!==0&&(i=o,t=bl(e,o))),t===1))throw n=Xc,Ol(e,0),Cl(e,i),vl(e,st()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Ll(e,tl,il);break;case 3:if(Cl(e,i),(i&130023424)===i&&(t=nl+500-st(),10<t)){if(wt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){hl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=gi(Ll.bind(null,e,tl,il),t);break}Ll(e,tl,il);break;case 4:if(Cl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-_t(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=st()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*zc(i/1960))-i,10<i){e.timeoutHandle=gi(Ll.bind(null,e,tl,il),i);break}Ll(e,tl,il);break;case 5:Ll(e,tl,il);break;default:throw Error(r(329))}}}return vl(e,st()),e.callbackNode===n?yl.bind(null,e):null}function bl(e,t){var n=el;return e.current.memoizedState.isDehydrated&&(Ol(e,t).flags|=256),e=Ml(e,t),e!==2&&(t=tl,tl=n,t!==null&&xl(t)),e}function xl(e){tl===null?tl=e:tl.push.apply(tl,e)}function Sl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!xr(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Cl(e,t){for(t&=~$c,t&=~Qc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_t(t),r=1<<n;e[n]=-1,t&=~r}}function wl(e){if(Uc&6)throw Error(r(327));zl();var t=wt(e,0);if(!(t&1))return vl(e,st()),null;var n=Ml(e,t);if(e.tag!==0&&n===2){var i=Dt(e);i!==0&&(t=i,n=bl(e,i))}if(n===1)throw n=Xc,Ol(e,0),Cl(e,t),vl(e,st()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ll(e,tl,il),vl(e,st()),null}function Tl(e,t){var n=Uc;Uc|=1;try{return e(t)}finally{Uc=n,Uc===0&&(rl=st()+500,Qi&&na())}}function El(e){ll!==null&&ll.tag===0&&!(Uc&6)&&zl();var t=Uc;Uc|=1;var n=Hc.transition,r=Nt;try{if(Hc.transition=null,Nt=1,e)return e()}finally{Nt=r,Hc.transition=n,Uc=t,!(Uc&6)&&na()}}function Dl(){qc=Jc.current,Ri(Jc)}function Ol(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,_i(n)),Gc!==null)for(n=Gc.return;n!==null;){var r=n;switch(ha(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ki();break;case 3:fo(),Ri(Hi),Ri(Vi),vo();break;case 5:mo(r);break;case 4:fo();break;case 13:Ri(ho);break;case 19:Ri(ho);break;case 10:Ha(r.type._context);break;case 22:case 23:Dl()}n=n.return}if(Wc=e,Gc=e=Ql(e.current,null),Kc=qc=t,Yc=0,Xc=null,$c=Qc=Zc=0,tl=el=null,Ka!==null){for(t=0;t<Ka.length;t++)if(n=Ka[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}Ka=null}return e}function kl(e,t){do{var n=Gc;try{if(Va(),yo.current=ps,To){for(var i=So.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}To=!1}if(xo=0,wo=Co=So=null,Eo=!1,Do=0,Vc.current=null,n===null||n.return===null){Yc=1,Xc=t,Gc=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=Kc,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=js(s);if(m!==null){m.flags&=-257,Ms(m,s,c,o,t),m.mode&1&&As(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}if(!(t&1)){As(o,u,t),jl();break a}l=Error(r(426))}else if(va&&c.mode&1){var _=js(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Ms(_,s,c,o,t),ka(ws(l,c));break a}}o=l=ws(l,c),Yc!==4&&(Yc=2),el===null?el=[o]:el.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Os(o,l,t);no(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(sl===null||!sl.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=ks(o,c,t);no(o,x);break a}}o=o.return}while(o!==null)}Il(n)}catch(e){t=e,Gc===n&&n!==null&&(Gc=n=n.return);continue}break}while(1)}function Al(){var e=Bc.current;return Bc.current=ps,e===null?ps:e}function jl(){(Yc===0||Yc===3||Yc===2)&&(Yc=4),Wc===null||!(Zc&268435455)&&!(Qc&268435455)||Cl(Wc,Kc)}function Ml(e,t){var n=Uc;Uc|=2;var i=Al();(Wc!==e||Kc!==t)&&(il=null,Ol(e,t));do try{Nl();break}catch(t){kl(e,t)}while(1);if(Va(),Uc=n,Bc.current=i,Gc!==null)throw Error(r(261));return Wc=null,Kc=0,Yc}function Nl(){for(;Gc!==null;)Fl(Gc)}function Pl(){for(;Gc!==null&&!at();)Fl(Gc)}function Fl(e){var t=Kl(e.alternate,e,qc);e.memoizedProps=e.pendingProps,t===null?Il(e):Gc=t,Vc.current=null}function Il(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=uc(n,t),n!==null){n.flags&=32767,Gc=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Yc=6,Gc=null;return}}else if(n=lc(n,t,qc),n!==null){Gc=n;return}if(t=t.sibling,t!==null){Gc=t;return}Gc=t=e}while(t!==null);Yc===0&&(Yc=5)}function Ll(e,t,n){var r=Nt,i=Hc.transition;try{Hc.transition=null,Nt=1,Rl(e,t,n,r)}finally{Hc.transition=i,Nt=r}return null}function Rl(e,t,n,i){do zl();while(ll!==null);if(Uc&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(jt(e,o),e===Wc&&(Gc=Wc=null,Kc=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||cl||(cl=!0,ql(dt,function(){return zl(),null})),o=!!(n.flags&15990),n.subtreeFlags&15990||o){o=Hc.transition,Hc.transition=null;var s=Nt;Nt=1;var c=Uc;Uc|=4,Vc.current=null,_c(e,n),Mc(n,e),Or(mi),an=!!pi,mi=pi=null,e.current=n,Pc(n,e,a),ot(),Uc=c,Nt=s,Hc.transition=o}else e.current=n;if(cl&&(cl=!1,ll=e,ul=a),o=e.pendingLanes,o===0&&(sl=null),gt(n.stateNode,i),vl(e,st()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(al)throw al=!1,e=ol,ol=null,e;return ul&1&&e.tag!==0&&zl(),o=e.pendingLanes,o&1?e===fl?dl++:(dl=0,fl=e):dl=0,na(),null}function zl(){if(ll!==null){var e=Pt(ul),t=Hc.transition,n=Nt;try{if(Hc.transition=null,Nt=16>e?16:e,ll===null)var i=!1;else{if(e=ll,ll=null,ul=0,Uc&6)throw Error(r(331));var a=Uc;for(Uc|=4,X=e.current;X!==null;){var o=X,s=o.child;if(X.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(X=u;X!==null;){var d=X;switch(d.tag){case 0:case 11:case 15:vc(8,d,o)}var f=d.child;if(f!==null)f.return=d,X=f;else for(;X!==null;){d=X;var p=d.sibling,m=d.return;if(xc(d),d===u){X=null;break}if(p!==null){p.return=m,X=p;break}X=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}X=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,X=s;else b:for(;X!==null;){if(o=X,o.flags&2048)switch(o.tag){case 0:case 11:case 15:vc(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,X=v;break b}X=o.return}}var y=e.current;for(X=y;X!==null;){s=X;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,X=b;else b:for(s=y;X!==null;){if(c=X,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:yc(9,c)}}catch(e){Vl(c,c.return,e)}if(c===s){X=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,X=x;break b}X=c.return}}if(Uc=a,na(),ht&&typeof ht.onPostCommitFiberRoot==`function`)try{ht.onPostCommitFiberRoot(mt,e)}catch{}i=!0}return i}finally{Nt=n,Hc.transition=t}}return!1}function Bl(e,t,n){t=ws(n,t),t=Os(e,t,1),e=eo(e,t,1),t=hl(),e!==null&&(At(e,1,t),vl(e,t))}function Vl(e,t,n){if(e.tag===3)Bl(e,e,n);else for(;t!==null;){if(t.tag===3){Bl(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(sl===null||!sl.has(r))){e=ws(n,e),e=ks(t,e,1),t=eo(t,e,1),e=hl(),t!==null&&(At(t,1,e),vl(t,e));break}}t=t.return}}function Hl(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=hl(),e.pingedLanes|=e.suspendedLanes&n,Wc===e&&(Kc&n)===n&&(Yc===4||Yc===3&&(Kc&130023424)===Kc&&500>st()-nl?Ol(e,0):$c|=n),vl(e,t)}function Ul(e,t){t===0&&(e.mode&1?(t=St,St<<=1,!(St&130023424)&&(St=4194304)):t=1);var n=hl();e=Ya(e,t),e!==null&&(At(e,t,n),vl(e,n))}function Wl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ul(e,n)}function Gl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Ul(e,n)}var Kl=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Hi.current)Ps=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ps=!1,rc(e,t,n);Ps=!!(e.flags&131072)}}else Ps=!1,va&&t.flags&1048576&&pa(t,oa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;tc(e,t),e=t.pendingProps;var a=Wi(t,Vi.current);Wa(t,n),a=jo(null,t,i,e,a,n);var o=Mo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Gi(i)?(o=!0,Yi(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Za(t),a.updater=ys,t.stateNode=a,a._reactInternals=t,Cs(t,i,e,n),t=Us(null,t,i,!0,o,n)):(t.tag=0,va&&o&&ma(t),Fs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(tc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Zl(i),e=_s(i,e),a){case 0:t=Vs(null,t,i,e,n);break a;case 1:t=Hs(null,t,i,e,n);break a;case 11:t=Is(null,t,i,e,n);break a;case 14:t=Ls(null,t,i,_s(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Vs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Hs(e,t,i,a,n);case 3:a:{if(Ws(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,Qa(e,t),ro(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=ws(Error(r(423)),t),t=Gs(e,t,i,n,a);break a}if(i!==a){a=ws(Error(r(424)),t),t=Gs(e,t,i,n,a);break a}for(_a=Si(t.stateNode.containerInfo.firstChild),ga=t,va=!0,ya=null,n=Ia(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Oa(),i===a){t=nc(e,t,n);break a}Fs(e,t,i,n)}t=t.child}return t;case 5:return po(t),e===null&&wa(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,hi(i,a)?s=null:o!==null&&hi(i,o)&&(t.flags|=32),Bs(e,t),Fs(e,t,s,n),t.child;case 6:return e===null&&wa(t),null;case 13:return Js(e,t,n);case 4:return uo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Fa(t,null,i,n):Fs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),Is(e,t,i,a,n);case 7:return Fs(e,t,t.pendingProps,n),t.child;case 8:return Fs(e,t,t.pendingProps.children,n),t.child;case 12:return Fs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,zi(La,i._currentValue),i._currentValue=s,o!==null){if(xr(o.value,s)){if(o.children===a.children&&!Hi.current){t=nc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=$a(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ua(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ua(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Fs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Wa(t,n),a=Ga(a),i=i(a),t.flags|=1,Fs(e,t,i,n),t.child;case 14:return i=t.type,a=_s(i,t.pendingProps),a=_s(i.type,a),Ls(e,t,i,a,n);case 15:return Rs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:_s(i,a),tc(e,t),t.tag=1,Gi(i)?(e=!0,Yi(t)):e=!1,Wa(t,n),xs(t,i,a),Cs(t,i,a,n),Us(null,t,i,!0,e,n);case 19:return ec(e,t,n);case 22:return zs(e,t,n)}throw Error(r(156,t.tag))};function ql(e,t){return rt(e,t)}function Jl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yl(e,t,n,r){return new Jl(e,t,n,r)}function Xl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zl(e){if(typeof e==`function`)return+!!Xl(e);if(e!=null){if(e=e.$$typeof,e===k)return 11;if(e===M)return 14}return 2}function Ql(e,t){var n=e.alternate;return n===null?(n=Yl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function $l(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Xl(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case w:return eu(n.children,a,o,t);case T:s=8,a|=8;break;case E:return e=Yl(12,n,t,a|2),e.elementType=E,e.lanes=o,e;case A:return e=Yl(13,n,t,a),e.elementType=A,e.lanes=o,e;case j:return e=Yl(19,n,t,a),e.elementType=j,e.lanes=o,e;case P:return tu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case D:s=10;break a;case O:s=9;break a;case k:s=11;break a;case M:s=14;break a;case N:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Yl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function eu(e,t,n,r){return e=Yl(7,e,r,t),e.lanes=n,e}function tu(e,t,n,r){return e=Yl(22,e,r,t),e.elementType=P,e.lanes=n,e.stateNode={isHidden:!1},e}function nu(e,t,n){return e=Yl(6,e,null,t),e.lanes=n,e}function ru(e,t,n){return t=Yl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function iu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=kt(0),this.expirationTimes=kt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=kt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function au(e,t,n,r,i,a,o,s,c){return e=new iu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Yl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Za(a),e}function ou(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:C,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function su(e){if(!e)return Bi;e=e._reactInternals;a:{if(Ze(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(Gi(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(Gi(n))return Ji(e,n,t)}return t}function cu(e,t,n,r,i,a,o,s,c){return e=au(n,r,!0,e,i,a,o,s,c),e.context=su(null),n=e.current,r=hl(),i=gl(n),a=$a(r,i),a.callback=t??null,eo(n,a,i),e.current.lanes=i,At(e,i,r),vl(e,r),e}function lu(e,t,n,r){var i=t.current,a=hl(),o=gl(i);return n=su(n),t.context===null?t.context=n:t.pendingContext=n,t=$a(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=eo(i,t,o),e!==null&&(_l(e,i,o,a),to(e,i,o)),o}function uu(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function du(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function fu(e,t){du(e,t),(e=e.alternate)&&du(e,t)}function pu(){return null}var mu=typeof reportError==`function`?reportError:function(e){console.error(e)};function hu(e){this._internalRoot=e}gu.prototype.render=hu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));lu(e,t,null,null)},gu.prototype.unmount=hu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;El(function(){lu(null,e,null,null)}),t[Di]=null}};function gu(e){this._internalRoot=e}gu.prototype.unstable_scheduleHydration=function(e){if(e){var t=Rt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<qt.length&&t!==0&&t<qt[n].priority;n++);qt.splice(n,0,e),n===0&&Zt(e)}};function _u(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function vu(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function yu(){}function bu(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=uu(o);a.call(e)}}var o=cu(t,r,e,0,null,!1,!1,``,yu);return e._reactRootContainer=o,e[Di]=o.current,ni(e.nodeType===8?e.parentNode:e),El(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=uu(c);s.call(e)}}var c=au(e,0,!1,null,null,!1,!1,``,yu);return e._reactRootContainer=c,e[Di]=c.current,ni(e.nodeType===8?e.parentNode:e),El(function(){lu(t,c,n,r)}),c}function xu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=uu(o);s.call(e)}}lu(t,o,e,i)}else o=bu(n,t,e,i,r);return uu(o)}Ft=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ct(t.pendingLanes);n!==0&&(Mt(t,n|1),vl(t,st()),!(Uc&6)&&(rl=st()+500,na()))}break;case 13:El(function(){var t=Ya(e,1);t!==null&&_l(t,e,1,hl())}),fu(e,1)}},It=function(e){if(e.tag===13){var t=Ya(e,134217728);t!==null&&_l(t,e,134217728,hl()),fu(e,134217728)}},Lt=function(e){if(e.tag===13){var t=gl(e),n=Ya(e,t);n!==null&&_l(n,e,t,hl()),fu(e,t)}},Rt=function(){return Nt},zt=function(e,t){var n=Nt;try{return Nt=e,t()}finally{Nt=n}},ke=function(e,t,n){switch(t){case`input`:if(ce(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Pi(i);if(!a)throw Error(r(90));ie(i),ce(i,a)}}}break;case`textarea`:me(e,n);break;case`select`:t=n.value,t!=null&&de(e,!!n.multiple,t,!1)}},Ie=Tl,Le=El;var Su={usingClientEntryPoint:!1,Events:[Mi,Ni,Pi,Ne,Fe,Tl]},Cu={findFiberByHostInstance:ji,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},wu={bundleType:Cu.bundleType,version:Cu.version,rendererPackageName:Cu.rendererPackageName,rendererConfig:Cu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:x.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=tt(e),e===null?null:e.stateNode},findFiberByHostInstance:Cu.findFiberByHostInstance||pu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Tu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tu.isDisabled&&Tu.supportsFiber)try{mt=Tu.inject(wu),ht=Tu}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Su,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_u(t))throw Error(r(200));return ou(e,t,null,n)},e.createRoot=function(e,t){if(!_u(e))throw Error(r(299));var n=!1,i=``,a=mu;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=au(e,1,!1,null,null,n,!1,i,a),e[Di]=t.current,ni(e.nodeType===8?e.parentNode:e),new hu(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=tt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return El(e)},e.hydrate=function(e,t,n){if(!vu(t))throw Error(r(200));return xu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!_u(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=mu;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=cu(t,null,e,1,n??null,a,!1,o,s),e[Di]=t.current,ni(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new gu(t)},e.render=function(e,t,n){if(!vu(t))throw Error(r(200));return xu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!vu(e))throw Error(r(40));return e._reactRootContainer?(El(function(){xu(null,null,e,!1,function(){e._reactRootContainer=null,e[Di]=null})}),!0):!1},e.unstable_batchedUpdates=Tl,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!vu(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return xu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),Ta=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=wa()})),Ea=t((e=>{var t=Ta();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))();function Da(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Invalid keymap token: token cannot be empty`);return t}function Oa(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Invalid key name: key name cannot be empty`);return t}function ka(e){return{name:Oa(e.name),ctrl:e.ctrl??!1,shift:e.shift??!1,meta:e.meta??!1,super:e.super??!1,hyper:e.hyper||void 0}}function Aa(e){return{name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super,hyper:e.hyper||void 0}}function ja(e,t){let n=Aa(ka(e));return{stroke:n,display:t?.display??za(n),match:t?.match??Fa(n),tokenName:t?.tokenName?Da(t.tokenName):void 0}}function Ma(e){return{stroke:Aa(e.stroke),display:e.display,match:e.match,tokenName:e.tokenName,patternName:e.patternName,payloadKey:e.payloadKey}}function Na(e){return e.map(e=>Ma(e))}function Pa(e){return`match`in e?e.match:`stroke`in e?Fa(e.stroke):Fa(e)}function Fa(e){return`key:${Ba(ka(e))}`}function Ia(e){let t=e.trim();if(!t)throw Error(`Invalid keymap match id: id cannot be empty`);return`text:${t}`}function La(e,t){return`stroke`in e?t?.preferDisplay&&e.display?e.display:za(e.stroke):za(ka(e))}function Ra(e,t){return e.map(e=>La(e,t)).join(t?.separator??``)}function za(e){let t=[];return e.ctrl&&t.push(`ctrl`),e.shift&&t.push(`shift`),e.meta&&t.push(`meta`),e.super&&t.push(`super`),e.hyper&&t.push(`hyper`),t.push(e.name===`return`?`enter`:e.name),t.join(`+`)}function Ba(e){return`${e.name}:${+!!e.ctrl}:${+!!e.shift}:${+!!e.meta}:${+!!e.super}:${+!!e.hyper}`}var Va=Symbol(`keymap-extension-context`);function Ha(e){return e.isDestroyed?null:e.getFocusedTarget()}function Ua(e,t,n){let r=t??e.rootTarget,i=t!==null;for(;r;){if(n(r,i)===!1)return;r=e.getParentTarget(r),i=!1}}function Wa(e,t){let n=new Set;return Ua(e,t,e=>{n.add(e)}),n}function Ga(e,t,n){let r=[],i=Wa(t,n),a=Array.isArray(e)?e:Ka(e);for(let e of a)qa(t,e,n,i)&&r.push(e);return r}function Ka(e){return[...e].sort((e,t)=>t.priority-e.priority||t.order-e.order)}function qa(e,t,n,r=Wa(e,n)){let i=t.target;return i?e.isTargetDestroyed(i)?!1:t.targetMode===`focus`?i===n:r.has(i):!0}function Ja(e){let t=e.binding.sequence[e.index];if(!t?.patternName)return 0;let n=e.patterns?.at(-1);return n?.name===t.patternName?n.values.length:0}function Ya(e,t,n=!0){let r=e.binding.sequence[e.index];if(!r?.patternName)return!0;let i=t.get(r.patternName);return i?Ja(e)>=i.min:n}function Xa(e,t,n=!0){let r=e.binding.sequence[e.index];if(r?.patternName){let n=t.get(r.patternName);if(n&&Ja(e)<n.max)return!0}return Ya(e,t,n)&&e.index+1<e.binding.sequence.length}function Za(e,t){return e.index===e.binding.sequence.length-1&&Ya(e,t,!1)}function Qa(e,t,n,r){return{parent:e,depth:e?e.depth+1:0,stroke:t,match:n,pattern:r,children:new Map,patternChildren:[],bindings:[],reachableBindings:[]}}function $a(e,t){let n=Qa(null,null,null);for(let r of e){if(r.event!==`press`)continue;let e=n;for(let n of r.sequence){let i;if(n.patternName){let r=t.get(n.patternName);i=e.patternChildren.find(e=>e.pattern?.name===n.patternName),i||(i=Qa(e,n.stroke,n.match,r),e.patternChildren.push(i))}else i=e.children.get(n.match),i||(i=Qa(e,n.stroke,n.match),e.children.set(n.match,i));i.reachableBindings.push(r),e=i}e.bindings.push(r)}return n}function eo(e,t){let n=[];for(let r of e){if(!Ya(r,t))continue;let e=r.index+1,i=r.binding.sequence[e];i&&n.push({part:i,binding:r.binding,index:e,exact:e===r.binding.sequence.length-1,continues:e<r.binding.sequence.length-1})}return n}function to(e,t,n,r){let i=n.patternName;if(!i)return{...e,index:t};let a=[...e.patterns??[]],o=a.at(-1);return o?.name===i?a[a.length-1]={...o,values:[...o.values,r],parts:[...o.parts,n]}:a.push({name:i,payloadKey:n.payloadKey??i,values:[r],parts:[n]}),{layer:e.layer,binding:e.binding,index:t,parts:[...e.parts,n],patterns:a}}function no(e,t){let n=e.parts.at(-1);if(!n||n.patternName)return t.length;let r=t.indexOf(n.match);return r===-1?t.length:r}function ro(e,t,n,r,i,a,o,s,c){let l=t.sequence[n];if(l){if(l.patternName){let a=s(l.patternName,o);if(!a)return;let u=c(o,l.patternName,a);return to({layer:e,binding:t,index:n,parts:r,patterns:i},n,u,a.value??o.name)}if(a.includes(l.match))return{layer:e,binding:t,index:n,parts:[...r,l],patterns:i}}}function io(e,t,n,r,i,a){let o=e.binding.sequence[e.index];if(o?.patternName){let s=r.get(o.patternName);if(s&&Ja(e)<s.max){let t=i(s.name,n);if(t){let r=a(n,s.name,t);return to(e,e.index,r,t.value??n.name)}}return Ya(e,r,!1)?ro(e.layer,e.binding,e.index+1,e.parts,e.patterns,t,n,i,a):void 0}return ro(e.layer,e.binding,e.index+1,e.parts,e.patterns,t,n,i,a)}function ao(e,t,n,r,i){let a=[],o=1/0;for(let s of e.bindings){if(s.event!==`press`)continue;let c=ro(e,s,0,[],void 0,t,n,r,i);if(!c)continue;let l=no(c,t);l<o&&(o=l,a.length=0),l===o&&a.push(c)}return a}import.meta.require;function oo(e){let t=Object.create(null),n=(e,n)=>{let r=t[e];if(!r)return;let i=r.filter(e=>e!==n);i.length===0?delete t[e]:i.length!==r.length&&(t[e]=i)};return{hook(e,r){return t[e]=[...t[e]??[],r],()=>n(e,r)},has(e){return(t[e]?.length??0)>0},emit(n,...r){let i=t[n];if(i)for(let t of i)try{r.length===0?t():t(r[0])}catch(t){e(n,t)}}}}function so(){let e=[];return{get:()=>e,set:t=>{e=t},remove(t){e=e.filter(e=>e!==t)},has:()=>e.length>0,clear:()=>{e=[]}}}function co(){let e=so();return{append(t){return e.set([...e.get(),t]),()=>e.remove(t)},prepend(t){return e.set([t,...e.get()]),()=>e.remove(t)},values:e.get,has:e.has,clear:e.clear}}function lo(){let e=so(),t=0;return{register(n,r){let i={...r,listener:n,order:t++};return e.set([...e.get(),i].sort((e,t)=>t.priority-e.priority||e.order-t.order)),()=>e.remove(i)},entries:e.get,has:e.has,clear:e.clear}}function uo(e){return typeof e==`string`||!!e&&typeof e==`object`&&!Array.isArray(e)}function fo(e){if(!Array.isArray(e))return{ok:!1,reason:`Invalid keymap bindings: expected an array of binding objects`};for(let[t,n]of e.entries()){if(!n||typeof n!=`object`||Array.isArray(n))return{ok:!1,reason:`Invalid keymap binding at index ${t}: expected a binding object`};if(!uo(n.key))return{ok:!1,reason:`Invalid keymap binding at index ${t}: expected "key" to be a string or keystroke object`}}return{ok:!0}}function po(e){let t=fo(e);if(!t.ok)throw Error(t.reason);return e.map(e=>({...e,key:typeof e.key==`string`?e.key:{...e.key}}))}function mo(e){return{...e,sequence:Na(e.sequence)}}function ho(e,t){let n=co();return{prependLayerAnalyzer(e){return n.prepend(e)},appendLayerAnalyzer(e){return n.append(e)},clearLayerAnalyzers(){n.clear()},analyzeLayer(r){let i=n.values();if(i.length===0)return;let a=go(r.bindings),o={target:r.target,order:r.order,sourceBindings:r.sourceBindings,bindings:a,hasTokenBindings:r.hasTokenBindings,checkCommandResolution(e){return t.getCommandResolutionStatus(e,r.commands)},warn(t,n,r){e.emitWarning(t,n,r)},warnOnce(t,n,r,i){e.warnOnce(t,n,r,i)},error(t,n,r){e.emitError(t,n,r)}};for(let t of i)try{t(o)}catch(t){e.emitError(`layer-analyzer-error`,t,`[Keymap] Error in layer analyzer:`)}}}}function go(e){return e.map(t=>({sequence:Na(t.sequence),command:t.command,attrs:t.attrs,event:t.event,preventDefault:t.preventDefault,fallthrough:t.fallthrough,parsedBinding:mo(t.parsedBinding),sourceTarget:t.sourceTarget,sourceLayerOrder:t.sourceLayerOrder,bindingIndex:t.bindingIndex,hasCommandAtSequence:e.some(e=>e.event===`press`&&e.command!==void 0&&_o(e,t)),hasContinuations:e.some(e=>e.event===`press`&&vo(t,e))}))}function _o(e,t){return e.sequence.length===t.sequence.length&&e.sequence.every((e,n)=>e.match===t.sequence[n]?.match)}function vo(e,t){return e.sequence.length<t.sequence.length&&e.sequence.every((e,n)=>e.match===t.sequence[n]?.match)}function yo(){return{version:-1,notifyVersion:-1,focused:void 0,value:[],targets:new WeakMap}}function bo(){return{plain:yo(),bindings:yo(),metadata:yo(),bindingsAndMetadata:yo()}}function xo(e,t){if(t===void 0)return e.plain;let n=t.includeBindings===!0,r=t.includeMetadata===!0;return n?r?e.bindingsAndMetadata:e.bindings:r?e.metadata:e.plain}function So(e,t,n){let r=n?e.targets.get(n):e.nullTarget;return r?.version===t?r:void 0}function Co(e,t,n,r){let i={version:t,value:r};n?e.targets.set(n,i):e.nullTarget=i}function wo(e,t){if(e===t)return!0;if(!e||!t||e.captures.length!==t.captures.length)return!1;for(let n=0;n<e.captures.length;n+=1){let r=e.captures[n],i=t.captures[n];if(!r||!i||r.layer!==i.layer||r.binding!==i.binding||r.index!==i.index||r.parts.length!==i.parts.length)return!1;for(let e=0;e<r.parts.length;e+=1)if(r.parts[e]?.match!==i.parts[e]?.match)return!1;let a=r.patterns??[],o=i.patterns??[];if(a.length!==o.length)return!1;for(let e=0;e<a.length;e+=1){let t=a[e],n=o[e];if(!t||!n||t.name!==n.name||t.values.length!==n.values.length)return!1;for(let e=0;e<t.values.length;e+=1)if(!Object.is(t.values[e],n.values[e]))return!1}}return!0}function To(e){let t=e.parts.at(-1);if(!t||e.parts.length<=1)return;let n=e.index-1,r=e.patterns;if(t.patternName){let i=r?.at(-1);i?.name===t.patternName&&(i.values.length>1?(n=e.index,r=[...(r??[]).slice(0,-1),{...i,values:i.values.slice(0,-1),parts:i.parts.slice(0,-1)}]):r=(r??[]).slice(0,-1))}return{layer:e.layer,binding:e.binding,index:n,parts:e.parts.slice(0,-1),patterns:r}}function Eo(e){let t=e.captures[0];if(!t||t.parts.length===0)return[];let n=[];for(let r=0;r<t.parts.length;r+=1){let i=t.parts[r];if(!i)continue;let a,o,s=!1,c=!1;for(let t of e.captures){let e=t.parts[r];if(e){if(a===void 0){a=e.display,o=e.tokenName;continue}!s&&a!==e.display&&(s=!0),!c&&o!==e.tokenName&&(c=!0)}}(a===void 0||s)&&(a=La(i.stroke)),c&&(o=void 0),n.push(ja(i.stroke,{display:a,match:i.match,tokenName:o}))}return n}function Do(e){if(e.isDestroyed)throw Error(`Cannot use a keymap after its host was destroyed`);return e}function Oo(e,t,n,r,i,a,o={}){let s=bo(),c=-1,l=[],u=()=>Do(t).getFocusedTarget(),d=()=>Ha(t),f=t=>{let n=e.pending;wo(n,t)||(e.pending=t,o.onPendingSequenceChanged?.(n,t),H(),r.queueStateChange())},p=()=>{let t=e.pending;if(!t)return;let n=u(),r=a.getActiveCommandView(n),o=t.captures.filter(t=>e.layers.has(t.layer)&&C(t.layer,n)&&i.matchesConditions(t.layer)&&D(t.binding,n,r)&&Xa(t,e.patterns));if(o.length===0){f(null);return}return o.length!==t.captures.length&&f({captures:o}),e.pending??void 0},m=()=>{t.isDestroyed||!e.pending||p()},h=()=>!t.isDestroyed&&e.pending!==null,g=()=>{if(c===e.cacheVersion)return l;let t=p(),n=t?Eo(t):[];return(!t||T())&&(c=e.cacheVersion,l=n),n},_=()=>{let e=p();if(!e)return!1;let t=e.captures[0];if(!t||t.parts.length<=1)return f(null),!0;let n=[];for(let t of e.captures){let e=To(t);e&&n.push(e)}return n.length===0?(f(null),!0):(f({captures:n}),!0)},v=t=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=xo(s,t);return i.notifyVersion===e.derivedVersion?i.value:y(i,n,r)},y=(n,r,i)=>{t.isDestroyed&&Do(t);let o=u(),s=So(n,e.cacheVersion,o);if(s)return n.notifyVersion=e.derivedVersion,n.version=e.cacheVersion,n.focused=o,n.value=s.value,s.value;let c=a.getActiveCommandView(o),l=p(),d=l?[]:S(o),f=l?F(l.captures,r,i,o,c):j(d,r,i,o,c);return(l?T():w(d))&&(n.version=e.cacheVersion,n.notifyVersion=e.derivedVersion,n.focused=o,n.value=f,Co(n,e.cacheVersion,o,f)),f},b=(e,t)=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=u(),o=a.getActiveCommandView(i);return F(e,n,r,i,o)},x=(e,t)=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=e===d()?p():void 0,o=a.getActiveCommandView(e);return i?F(i.captures,n,r,e,o):j(S(e),n,r,e,o)},S=n=>e.activeLayersCacheVersion===e.cacheVersion&&e.activeLayersCacheFocused===n?e.activeLayersCache:(e.activeLayersCacheVersion=e.cacheVersion,e.activeLayersCacheFocused=n,e.activeLayersCache=Ga(e.sortedLayers,t,n),e.activeLayersCache),C=(e,n)=>qa(t,e,n),w=t=>!e.commandResolvers.has()&&e.activeKeyCacheBlockers===0,T=()=>!e.commandResolvers.has()&&e.activeKeyCacheBlockers===0,E=(e,t,n)=>{let r=[];for(let o of e)i.matchesConditions(o)&&a.isBindingVisible(o,t,n)&&r.push(o);return r},D=(e,t,n)=>i.matchesConditions(e)&&a.isBindingVisible(e,t,n),O=(e,t)=>{let n,r,i=!1,a=!1;for(let o of e){let e=o.sequence[t];if(e){if(n===void 0){n=e.display,r=e.tokenName;continue}!i&&n!==e.display&&(i=!0),!a&&r!==e.tokenName&&(a=!0)}}if(n===void 0||i){let r=e[0]?.sequence[t]?.stroke;n=r?La(r):``}return a&&(r=void 0),{display:n,tokenName:r}},k=(e,t,n)=>({sequence:e.sequence,command:e.command,commandAttrs:a.getBindingCommandAttrs(e,t,n),attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough}),A=(e,t,n)=>e.map(e=>k(e,t,n)),j=(e,t,n,r,a)=>{let o=new Map,s=new Set;for(let n of e)n.root.children.size===0&&n.root.patternChildren.length===0||!i.matchesConditions(n)||(M(n.root.children.values(),o,s,t,r,a),M(n.root.patternChildren,o,s,t,r,a));return R(o,t,n,r,a)},M=(e,t,n,r,i,a)=>{for(let o of e){let e=o.match;if(!e||n.has(e)||!o.stroke)continue;let s=N(o,r,i,a);if(!s)continue;let c=t.get(e);c?te(c,s,r):t.set(e,V(o.stroke,s,r)),s.stop&&n.add(e)}},N=(e,t,n,r)=>{if(!(e.children.size>0||e.patternChildren.length>0)){let i=ee(P(e)?E(e.bindings,n,r):e.bindings,n,r);if(!i)return;let a=O(i.bindings,e.depth-1);return{display:a.display,tokenName:a.tokenName,continues:!1,firstBinding:i.bindings[0],commandBinding:i.commandBinding,bindings:t?[...i.bindings]:void 0,stop:i.stop}}let i=E(e.reachableBindings,n,r);if(i.length===0)return;let a=ee(e.bindings,n,r),o=O(i,e.depth-1);return{display:o.display,tokenName:o.tokenName,continues:!0,firstBinding:a?.bindings[0],commandBinding:a?.commandBinding,bindings:t&&a?[...a.bindings]:void 0,stop:!0}},P=t=>{if(e.commandResolvers.has())return!0;for(let e of t.bindings)if(e.matchers.length>0)return!0;return!1},F=(t,n,r,i,a)=>{let o=new Map,s=new Set;return I(eo(t,e.patterns),o,s,n,i,a),R(o,n,r,i,a)},I=(e,t,n,r,i,a)=>{let o=new Set;for(let s of e)o.has(s.part.match)||(o.add(s.part.match),L(s,e,t,n,r,i,a))},L=(e,t,n,r,i,a,o)=>{let s=e.part.match;if(r.has(s))return;let c=z(e,t,i,a,o);if(!c)return;let l=n.get(s);l?te(l,c,i):n.set(s,V(e.part.stroke,c,i)),c.stop&&r.add(s)},R=(e,t,n,r,i)=>{let a=[];for(let o of e.values()){let e=ne(o,t,n,r,i);e&&a.push(e)}return a},z=(e,t,n,r,i)=>{let a=t.filter(t=>t.part.match===e.part.match),o=a.filter(e=>e.exact).map(e=>e.binding),s=ee(o,r,i),c=a.some(e=>e.continues);if(!c&&!s)return;let l=B(a);return{display:l.display,tokenName:l.tokenName,continues:c,firstBinding:s?.bindings[0],commandBinding:s?.commandBinding,bindings:n&&s?[...s.bindings]:void 0,stop:c||s?.stop===!0}},B=e=>{let t,n,r=!1,i=!1;for(let a of e){let e=a.part;if(t===void 0){t=e.display,n=e.tokenName;continue}!r&&t!==e.display&&(r=!0),!i&&n!==e.tokenName&&(i=!0)}let a=e[0]?.part;return(t===void 0||r)&&(t=a?La(a.stroke):``),i&&(n=void 0),{display:t,tokenName:n}},ee=(e,t,n)=>{let r=[],o;for(let s of e)if(!(!i.matchesConditions(s)||!a.isBindingVisible(s,t,n))&&(r.push(s),s.command!==void 0&&(o??=s,!s.fallthrough)))return{bindings:r,commandBinding:o,stop:!0};if(r.length!==0)return{bindings:r,commandBinding:o,stop:!1}},V=(e,t,n)=>({stroke:e,display:t.display,tokenName:t.tokenName,continues:t.continues,firstBinding:t.firstBinding,commandBinding:t.commandBinding,bindings:n&&t.bindings?[...t.bindings]:void 0}),te=(e,t,n)=>{if(!e.firstBinding&&t.firstBinding&&(e.firstBinding=t.firstBinding),!e.commandBinding&&t.commandBinding&&(e.commandBinding=t.commandBinding),t.continues&&(e.continues=!0),!(!n||!t.bindings||t.bindings.length===0)){if(!e.bindings){e.bindings=[...t.bindings];return}e.bindings.push(...t.bindings)}},ne=(e,t,n,r,i)=>{if(!e.commandBinding&&!e.continues)return;let o={stroke:Aa(e.stroke),display:e.display,continues:e.continues};if(e.tokenName&&(o.tokenName=e.tokenName),e.commandBinding&&(o.command=e.commandBinding.command),t&&e.bindings&&e.bindings.length>0&&(o.bindings=e.bindings.length===1?[k(e.bindings[0],r,i)]:A(e.bindings,r,i)),n){e.firstBinding?.attrs&&(o.bindingAttrs=e.firstBinding.attrs);let t=e.commandBinding?a.getBindingCommandAttrs(e.commandBinding,r,i):void 0;t&&(o.commandAttrs=t)}return o},H=()=>{n.has(`pendingSequence`)&&n.emit(`pendingSequence`,e.pending?Eo(e.pending):[])};return{getFocusedTarget:u,getFocusedTargetIfAvailable:d,setPendingSequence:f,ensureValidPendingSequence:p,revalidatePendingSequenceIfNeeded:m,hasPendingSequenceState:h,getPendingSequence:g,popPendingSequence:_,getActiveKeys:v,getActiveKeysForCaptures:b,getActiveKeysForFocused:x,getActiveLayers:S,isLayerActiveForFocused:C,collectSequencePartsFromPending:Eo,collectMatchingBindings:E,collectActiveBindings:A}}var ko=new Set([`name`,`run`,`fields`,`attrs`,`rejectedResult`]),Ao=new Set([`key`,`cmd`,`event`,`preventDefault`,`fallthrough`]),jo=new Set([`target`,`targetMode`,`priority`,`bindings`,`commands`]);function Mo(e){if(e===void 0||typeof e==`function`)return e;let t=e.trim();if(!t)throw Error(`Invalid keymap command: command cannot be empty`);return t}function No(e){let t=e.trim();if(!t)throw Error(`Invalid keymap command name: name cannot be empty`);if(/\s/.test(t))throw Error(`Invalid keymap command name "${e}": command names cannot contain whitespace`);return t}function Po(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Fo(e){let t=[],n=new Map;for(let r of e.layers)for(let e of r.commands){let i={layer:r,commandState:e};t.push(i),Po(n,e.command.name,i)}return{entries:t,chainsByName:n}}function Io(e,t,n){let r=[],i=[],a=new Map,o=new Map;for(let s of e)if(s.commands.length!==0&&!(n&&!t.matchesConditions(s)))for(let e of s.commands){if(!t.matchesConditions(e))continue;let n={layer:s,commandState:e};r.push(n),Po(o,e.command.name,n),a.has(e.command.name)||(a.set(e.command.name,n),i.push(n))}return{layers:e,entries:r,reachable:i,reachableByName:a,chainsByName:o}}function Lo(e,t,n,r){return(e.activeLayersCacheVersion!==e.cacheVersion||e.activeLayersCacheFocused!==r)&&(e.activeLayersCacheVersion=e.cacheVersion,e.activeLayersCacheFocused=r,e.activeLayersCache=Ga(e.sortedLayers,t,r)),Io(e.activeLayersCache,n,!0)}function Ro(e,t,n,r){if(Object.prototype.hasOwnProperty.call(e,t)&&!Object.is(e[t],n))throw Error(`Conflicting keymap requirement for "${t}" from ${r}`);e[t]=n}function zo(e,t,n,r){if(Object.prototype.hasOwnProperty.call(e,t)&&!Object.is(e[t],n))throw Error(`Conflicting keymap attribute for "${t}" from ${r}`);e[t]=n}function Bo(e){let t=`field ${e.fieldName}`;return{require(n,r){Ro(e.requirements,n,r,t)},attr(n,r){if(!e.attrs)throw Error(`Keymap ${t} cannot publish attrs`);zo(e.attrs,n,r,t)},activeWhen(n){e.matchers.push(e.conditions.buildRuntimeMatcher(n,t))}}}function Vo(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ho(e,t){return e instanceof Error&&e.message?e.message:t}function Uo(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:typeof e.then==`function`}function Wo(e,t){let n=t?.deep===!0,r=t?.freeze===!0,i=t?.preserveNonPlainObjects===!0;if(Array.isArray(e)){let i=n?e.map(e=>Wo(e,t)):[...e];return r?Object.freeze(i):i}if(e&&typeof e==`object`){if(i&&!Vo(e))return e;let a={};for(let[r,i]of Object.entries(e))a[r]=n?Wo(i,t):i;return r?Object.freeze(a):a}return e}var Go=[`name`],Ko=Object.freeze({}),qo=new WeakMap;function Jo(e,t,n,r,i){let a=-1,o,s=-1,c,l,u=-1,d,f,p=-1,m,h=-1,g=new Map,_=t=>Xo({commands:t,commandFields:e.commandFields,conditions:r,onError:(e,t,r)=>{n.emitError(e,t,r)}}),v=t=>R(()=>e.commandResolvers.prepend(t),t),y=t=>R(()=>e.commandResolvers.append(t),t),b=()=>{e.commandResolvers.has()&&n.runWithStateChangeBatch(()=>{e.commandResolvers.clear(),i.onCommandResolversChanged(),n.queueStateChange()})},x=e=>re(e).map(e=>Yo(e.commandState)),S=e=>{let t=U(e),n=re(e,t);if(n.length===0)return[];let r=n.map(e=>({entry:e,command:Yo(e.commandState),commandAttrs:e.commandState.attrs,bindings:[]})),i=new Map;for(let[e,t]of r.entries()){let n=i.get(t.command.name);n?n.push(e):i.set(t.command.name,[e])}return i.size>0&&W(r,i,t),r.map(e=>({command:e.command,bindings:e.bindings}))},C=t=>{if(t.visibility===`registered`&&u===e.derivedVersion&&d===t.commands&&f)return f;let n=new Map;for(let e of t.commands)n.has(e)||n.set(e,[]);return n.size===0?n:(ie(n,U(t)),t.visibility===`registered`&&(u=e.derivedVersion,d=t.commands,f=n),n)},w=(e,t,n)=>{let r=M(t);if(n){let i=[],a=r.chainsByName.get(e);if(a)for(let e of a)i.push({target:e.layer.target,command:e.commandState.command,attrs:e.commandState.attrs,payload:n.payload});let o=le(e,t,{mode:`active`,execution:n});return o.resolved&&i.push(o.resolved),{entries:i.length>0?i:void 0,hadError:o.hadError}}let i=[];for(let t of r.chainsByName.get(e)??[])i.push({target:t.layer.target,command:t.commandState.command,attrs:t.commandState.attrs});let a=le(e,t,{mode:`active`});return a.resolved&&i.push(a.resolved),{entries:i.length>0?i:void 0,hadError:a.hadError}},T=t=>{if(h!==e.derivedVersion&&(h=e.derivedVersion,g=new Map),g.has(t))return g.get(t)??void 0;let n=V(ee(t));return g.set(t,n??null),n},E=(e,t)=>V(M(t).chainsByName.get(e)),D=(e,t)=>le(e,null,{mode:`registered`,execution:t}),O=(e,t,n)=>le(e,t,{mode:`active`,execution:n}),k=(e,t)=>z(e,t)?.command,A=e=>B(e)?.commandState.command,j=(e,n,i)=>{let a=N().chainsByName.get(e);if(!a||a.length===0)return;let o,s;for(let e of a){if(!qa(t,e.layer,n)){o??=e;continue}(!r.matchesConditions(e.layer)||!r.matchesConditions(e.commandState))&&(s??=e)}let c=s??o;if(c)return{reason:s?`disabled`:`inactive`,command:i?c.commandState.command:void 0}},M=n=>{if(s===e.derivedVersion&&c===n&&l)return l;let i=Lo(e,t,r,n);return P()&&(s=e.derivedVersion,c=n,l=i),i},N=()=>a===e.derivedVersion&&o?o:(a=e.derivedVersion,o=Fo(e),o),P=()=>e.activeCommandViewCacheBlockers===0,F=(e,t,n)=>e.command===void 0||e.run?!0:typeof e.command==`string`?n.reachableByName.has(e.command)?!0:te(e.command,t,`active`)!==void 0:!1,I=(e,t,n)=>{if(typeof e.command!=`string`)return;let r=n.reachableByName.get(e.command);return r?r.commandState.attrs:te(e.command,t,`active`)?.attrs},L=(e,n)=>{if(n?.some(t=>t.command.name===e)||N().chainsByName.has(e))return`resolved`;let r=le(e,Ha(t));return r.resolved||r.hadError?r.resolved?`resolved`:`error`:`unresolved`},R=(t,r)=>n.runWithStateChangeBatch(()=>{let a=t();return i.onCommandResolversChanged(),n.queueStateChange(),()=>{n.runWithStateChangeBatch(()=>{a(),!e.commandResolvers.values().includes(r)&&(i.onCommandResolversChanged(),n.queueStateChange())})}}),z=(e,t)=>{let n=M(t).reachableByName.get(e);return n?{target:n.layer.target,command:n.commandState.command,attrs:n.commandState.attrs}:te(e,t,`active`)},B=e=>ee(e)?.[0],ee=t=>{let n=[];for(let r of e.sortedLayers)for(let e of r.commands)e.command.name===t&&n.push({layer:r,commandState:e});return n.length>0?n:void 0},V=e=>{if(e?.length)return e.map(e=>({target:e.layer.target,command:e.commandState.command,attrs:e.commandState.attrs}))},te=(e,t,n)=>le(e,t,{mode:n}).resolved,ne=()=>N().entries,H=()=>{if(p===e.derivedVersion&&m)return m;let t=new Map;for(let n of e.layers)for(let e of n.bindings){if(typeof e.command!=`string`)continue;let n=t.get(e.command);n?n.push(e):t.set(e.command,[e])}return p=e.derivedVersion,m=t,t},U=e=>{let n=e?.visibility??`reachable`,r=e&&Object.prototype.hasOwnProperty.call(e,`focused`)?e.focused??null:Ha(t);return n===`registered`?{visibility:n,focused:r}:{visibility:n,focused:r,activeView:M(r)}},re=(e,t=U(e))=>{let r;return r=t.visibility===`registered`?ne():t.visibility===`active`?t.activeView?.entries??[]:t.activeView?.reachable??[],ts({entries:r,query:e,getCommand:e=>Yo(e),onFilterError:e=>{n.emitError(`command-query-filter-error`,e,`[Keymap] Error in command query filter:`)}})},W=(e,t,n)=>{ae(n,n=>{G(e,t,n)})},ie=(e,t)=>{if(t.visibility===`registered`){let t=H();for(let[n,r]of e){let e=N().chainsByName.get(n)?.[0]?.commandState.attrs;for(let i of t.get(n)??[])r.push(se(i,e))}return}ae(t,n=>{oe(e,n,t)})},ae=(t,n)=>{if(t.visibility===`registered`){for(let t of e.layers)for(let e of t.bindings)n(e);return}let i=t.activeView;if(i){for(let e of i.layers)if(!(e.bindings.length===0||!r.matchesConditions(e)))for(let a of e.bindings)r.matchesConditions(a)&&F(a,t.focused,i)&&n(a)}},G=(e,t,n)=>{if(typeof n.command!=`string`)return;let r=t.get(n.command);if(!(!r||r.length===0))for(let t of r){let r=e[t];r&&r.bindings.push(se(n,r.commandAttrs))}},oe=(e,t,n)=>{if(typeof t.command!=`string`)return;let r=e.get(t.command);r&&r.push(se(t,ce(t,n)))},se=(e,t)=>({sequence:e.sequence,command:e.command,commandAttrs:t,attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough}),ce=(e,t)=>{if(typeof e.command!=`string`)return;if(t.visibility===`registered`)return N().chainsByName.get(e.command)?.[0]?.commandState.attrs;let n=t.activeView;if(n)return I(e,t.focused,n)},le=(t,r,i)=>{let a=i?.mode??`active`,o=i?.execution??{input:t},s=Zo(t,e.commandResolvers.values(),()=>de(r,a,o),e=>{n.emitError(`command-resolver-error`,e,`[Keymap] Error in command resolver for "${t}":`)}),c=s.resolved;if(c){let e=K(c.command.name,r,a);e?.commandState.command===c.command&&c.target===void 0&&(c={...c,target:e.layer.target},s.resolved=c)}if(c&&!c.attrs){let e=ue(c.command.name,r,a)??es(c.command);e&&(s.resolved={...c,attrs:e})}return s},ue=(e,t,n)=>n===`registered`?B(e)?.commandState.attrs:M(t).reachableByName.get(e)?.commandState.attrs,K=(e,t,n)=>n===`registered`?B(e):M(t).reachableByName.get(e),de=(e,t,n)=>{let r=n.input,i=n.payload;return{context:{get input(){return r},get payload(){return i},setInput(e){r=e},setPayload(e){i=e},getCommand:n=>t===`registered`?A(n):k(n,e)},getExecutionFields(){return{input:r,payload:i}}}};return{normalizeCommands:_,prependCommandResolver:v,appendCommandResolver:y,clearCommandResolvers:b,getCommands:x,getCommandEntries:S,getCommandBindings:C,getResolvedCommandChain:w,getRegisteredResolvedEntries:T,getActiveRegisteredResolvedEntries:E,resolveRegisteredResolverFallback:D,resolveActiveResolverFallback:O,getTopCommand:k,getDispatchUnavailableCommandState:j,getActiveCommandView:M,isBindingVisible:F,getBindingCommandAttrs:I,getCommandResolutionStatus:L}}function Yo(e){return e.command}function Xo(e){let t=[],n=new Set;for(let r of e.commands)try{let i={},a=[],o=No(r.name),s=Qo(r),c={};if(n.has(o)){e.onError(`duplicate-command`,{command:o},`Duplicate keymap command "${o}" in the same layer`);continue}r.name=o;for(let[t,n]of Object.entries(s)){if(n===void 0)continue;let r=e.commandFields.get(t);r&&r(n,Bo({fieldName:t,conditions:e.conditions,requirements:i,matchers:a,attrs:c}))}let l={command:r,fields:s,attrs:Object.keys(c).length===0?void 0:c,requires:Object.entries(i),matchers:a};n.add(l.command.name),t.push(l)}catch(t){e.onError(`register-command-failed`,t,Ho(t,`Failed to register keymap command "${String(r.name)}"`));continue}return t}function Zo(e,t,n,r){if(t.length===0)return{hadError:!1};let i=!1;for(let a of t){let t,o=n();try{t=a(e,o.context)}catch(e){i=!0,r(e);continue}if(t)return{hadError:i,resolved:$o(t,o.getExecutionFields())}}return{hadError:i}}function Qo(e){let t={};for(let[n,r]of Object.entries(e))!ko.has(n)&&r!==void 0&&(t[n]=r);return Object.keys(t).length===0?Ko:t}function $o(e,t){return{command:e,input:t.input,payload:t.payload}}function es(e){let t=Qo(e);return t===Ko?void 0:t}function ts(e){let t=e.query?.namespace,n=ns(e.query?.limit);if(n===0)return[];let r=e.query?.search?.trim().toLowerCase()??``,i=Go;e.query?.searchIn&&e.query.searchIn.length>0&&(i=e.query.searchIn);let a=e.query?.filter,o,s,c;if(typeof a==`function`)s=a;else if(a){let e=Object.entries(a),t=[];for(let[n,r]of e){if(n===`name`){if(typeof r==`string`){c=new Set([r]);continue}if(Array.isArray(r)){let e=new Set;for(let t of r)typeof t==`string`&&e.add(t);c=e;continue}}t.push([n,r])}o=t.length>0?t:void 0}let l=[];for(let a of e.entries){let u=a.commandState;if(is(u,t)&&rs(u,r,i)&&!(c&&!c.has(u.command.name))&&as(u,o,e)){if(s){let t=!1;try{t=s(e.getCommand(u))}catch(t){e.onFilterError(t);continue}if(!t)continue}if(l.push(a),n!==void 0&&l.length>=n)break}}return l}function ns(e){if(e===void 0)return;let t=Math.floor(Number(e));return!Number.isFinite(t)||t<=0?0:t}function rs(e,t,n){if(!t)return!0;for(let r of n)if(os(e,r,t))return!0;return!1}function is(e,t){if(t===void 0)return!0;let n=e.fields;return Object.prototype.hasOwnProperty.call(n,`namespace`)?ps(n.namespace,t):!1}function as(e,t,n){if(!t)return!0;for(let[r,i]of t)if(!us(e,r,i,n))return!1;return!0}function os(e,t,n){return ss(e,t)?.includes(n)===!0}function ss(e,t){let n=qo.get(e);if(n||(n=new Map,qo.set(e,n)),n.has(t))return n.get(t);let r=e.fields,i=e.attrs,a;t===`name`?a=e.command.name:Object.prototype.hasOwnProperty.call(r,t)?a=r[t]:i&&Object.prototype.hasOwnProperty.call(i,t)&&(a=i[t]);let o=cs(a);return n.set(t,o),o}function cs(e){if(Array.isArray(e)){let t=[];for(let n of e){let e=cs(n);e!==void 0&&t.push(e)}return t.length>0?t.join(`\0`):void 0}if(typeof e==`string`)return e.toLowerCase();if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e).toLowerCase()}function ls(e,t,n,r){try{return e(t,n)}catch(e){return r(e),!1}}function us(e,t,n,r){return typeof n==`function`?ds(e,t,n,r):fs(e,t,n)}function ds(e,t,n,r){let i=e.command,a=e.fields,o=e.attrs,s,c=!1,l=()=>s??=r.getCommand(e);return t===`name`&&(c=!0,ls(n,i.name,l(),r.onFilterError))||Object.prototype.hasOwnProperty.call(a,t)&&(c=!0,ls(n,a[t],l(),r.onFilterError))||o&&Object.prototype.hasOwnProperty.call(o,t)&&(c=!0,ls(n,o[t],l(),r.onFilterError))?!0:!c&&ls(n,void 0,l(),r.onFilterError)}function fs(e,t,n){let r=e.command,i=e.fields,a=e.attrs;return t===`name`&&ps(r.name,n)||Object.prototype.hasOwnProperty.call(i,t)&&ps(i[t],n)?!0:!!a&&Object.prototype.hasOwnProperty.call(a,t)&&ps(a[t],n)}function ps(e,t){return Array.isArray(t)?t.some(t=>ms(e,t)):ms(e,t)}function ms(e,t){return Array.isArray(e)?e.some(e=>ms(e,t)):Object.is(e,t)}function hs(e,t,n,r,i){let a=(e,t,n,r,a,o)=>({keymap:i.keymap,event:e,focused:t,target:n,data:r,input:a,payload:o}),o=(t,n,r,i)=>{let a=typeof n==`function`?void 0:n,o=typeof n==`function`?n:n.run,s=i?a:void 0,c;try{c=o(a?{...r,command:a}:r)}catch(n){return e.emitError(`command-execution-error`,n,`[Keymap] Error running command "${t}":`),{status:`error`,result:s?{ok:!1,reason:`error`,command:s}:{ok:!1,reason:`error`}}}if(Uo(c))return c.catch(n=>{e.emitError(`async-command-error`,n,`[Keymap] Async error in command "${t}":`)}),{status:`handled`,result:s?{ok:!0,command:s}:{ok:!0}};if(gs(c)){let e=c;return(!c.ok&&c.reason!==`not-found`&&i&&a&&!c.command||c.ok&&i&&a&&!c.command)&&(e={...c,command:a}),{status:c.ok?`handled`:`rejected`,result:e}}return c===!1?{status:`rejected`,result:s?{ok:!1,reason:`rejected`,command:s}:{ok:!1,reason:`rejected`}}:{status:`handled`,result:s?{ok:!0,command:s}:{ok:!0}}},s=(e,t,n,r,i,s,c,l)=>{let u;for(let d of t??[]){let t=o(e,d.command,a(n,r,i??d.target??null,s,e,c),l);if(t.status===`handled`||t.status===`error`)return[t.result,u];u=t.result}return[void 0,u]},c=(e,c,l)=>{let u;try{u=Mo(e)}catch{return{ok:!1,reason:`invalid-args`}}if(typeof u!=`string`)return{ok:!1,reason:`not-found`};let d=c?.includeCommand===!0,f=c?.focused??n.getFocusedTargetIfAvailable(),p=c?.event??i.createCommandEvent(),m=t.getReadonlyData(),h=c?.payload,g=l===`registered`?r.getRegisteredResolvedEntries(u):r.getActiveRegisteredResolvedEntries(u,f),[_,v]=s(u,g,p,f,c?.target,m,h,d);if(_)return _;let y=v,b=l===`registered`?r.resolveRegisteredResolverFallback(u,{input:u,payload:h}):r.resolveActiveResolverFallback(u,f,{input:u,payload:h});if(b.resolved){let e=o(u,b.resolved.command,a(p,f,c?.target??b.resolved.target??null,m,b.resolved.input??u,b.resolved.payload),d);if(e.status===`handled`||e.status===`error`)return e.result;y=e.result}if(b.hadError)return{ok:!1,reason:`error`};if(l===`active`){let e=r.getDispatchUnavailableCommandState(u,f,d);if(e)return e.command?{ok:!1,reason:e.reason,command:e.command}:{ok:!1,reason:e.reason}}return y??{ok:!1,reason:`not-found`}};return{runCommand(e,t){return c(e,t,`registered`)},dispatchCommand(e,t){return c(e,t,`active`)},runBinding(e,n,i,s,c){let l=t.getReadonlyData();if(n.run)return o(typeof n.command==`string`?n.command:`<function>`,n.run,a(i,s,e.target??null,l,typeof n.command==`string`?n.command:`<function>`,c),!1).status!==`rejected`&&(_s(n,i),!0);if(typeof n.command!=`string`)return!1;let u=r.getResolvedCommandChain(n.command,s,c===void 0?void 0:{input:n.command,payload:c}).entries;for(let t of u??[])if(o(n.command,t.command,a(i,s,t.target??e.target??null,l,t.input??n.command,t.payload),!1).status!==`rejected`)return _s(n,i),!0;return!1}}}function gs(e){return typeof e==`object`&&!!e&&`ok`in e}function _s(e,t){e.preventDefault&&(t.preventDefault(),t.stopPropagation())}var vs=Object.freeze({}),ys=[],bs=[];function xs(e){if(Object.keys(e).length!==0)return Wo(e,{freeze:!0})}function Ss(e,t,n,r){let i=t=>Os(t,e.bindingParsers.values(),{tokens:e.tokens,patterns:e.patterns,layer:vs,parseObjectKey:(e,t)=>c(e,t)}),a=t=>{if(typeof t!=`string`)return[c(t)];let n=Ds(t,e.bindingParsers.values(),{tokens:e.tokens,patterns:e.patterns,layer:vs,parseObjectKey:(e,t)=>c(e,t)});for(let e of n.unknownTokens)r.warnUnknownToken(e,t);return n.unknownTokens.length>0?[]:n.parts},o=(e,t)=>Ra(a(e),t),s=(i,a,o,s,d)=>{let f=[],p=!1,m=e.bindingExpanders.values(),h=e.bindingParsers.values(),g=e.bindingFields,_=e.disambiguationResolvers.has(),v=r.warnUnknownField,y=r.warnUnknownToken;for(let[r,b]of i.entries()){let i;try{i=Ts(b.key,m,{layer:d})}catch(e){t.emitError(`binding-expand-error`,e,Ho(e,`Failed to expand keymap binding`));continue}for(let m of i){let i=m.key,x;try{x=typeof i==`string`?Ds(i,h,{tokens:a,patterns:e.patterns,layer:d,parseObjectKey:(e,t)=>c(e,t)}):{parts:[c(i)],usedTokens:[],unknownTokens:[],hasTokenBindings:!1},x=Es(x,m)}catch(e){t.emitError(`binding-parse-error`,e,Ho(e,`Failed to parse keymap binding`));continue}let S=x.parts;p||=x.hasTokenBindings;for(let e of x.unknownTokens)y(e,typeof i==`string`?i:String(i.name));if(!(x.unknownTokens.length>0))for(let i of u(b,S,a,h,d))try{let t=l(i.event),a=i.sequence,c={},u={},d=[];for(let e in i){if(e===`sequence`||Ao.has(e))continue;let t=i[e];if(t===void 0)continue;let r=g.get(e);if(!r){v(`binding`,e);continue}r(t,Bo({fieldName:e,conditions:n,requirements:c,matchers:d,attrs:u}))}let p=Object.keys(u).length>0?xs(u):void 0,m=Mo(i.cmd),h={binding:b,sequence:a,command:m,event:t,parsedBinding:mo(i),sourceTarget:o,sourceLayerOrder:s,bindingIndex:r,requires:Object.keys(c).length>0?Object.entries(c):ys,matchers:d.length>0?d:bs,preventDefault:i.preventDefault!==!1,fallthrough:i.fallthrough??!1};if(p&&(h.attrs=p),typeof m==`function`&&(h.run=m),a.length===0)continue;if(t===`release`&&a.length>1)throw Error(`Keymap release bindings only support a single key stroke`);let y=a.at(-1);if(y?.patternName){let t=e.patterns.get(y.patternName);if(t&&t.max!==t.min)throw Error(`Keymap unbounded sequence patterns must be followed by a concrete continuation`)}t===`press`&&!_&&ws(f,h),f.push(h)}catch(e){t.emitError(`binding-compile-error`,e,Ho(e,`Failed to compile keymap binding`))}}}return{bindings:f,hasTokenBindings:p}},c=(e,t)=>ja(e,t),l=e=>{if(e===void 0||e===`press`)return`press`;if(e===`release`)return`release`;throw Error(`Invalid keymap binding event "${String(e)}": expected "press" or "release"`)},u=(n,r,i,a,o)=>{let s=e.bindingTransformers.values();if(s.length===0)return[{...n,sequence:Na(r)}];let l={...n,sequence:Na(r)},u=[],d=!0,f=o??vs;for(let n of s)try{n(l,{layer:f,parseKey:t=>Os(t,a,{tokens:i,patterns:e.patterns,layer:f,parseObjectKey:(e,t)=>c(e,t)}),add:e=>{u.push(mo(e))},skipOriginal:()=>{d=!1}})}catch(e){t.emitError(`binding-transformer-error`,e,`[Keymap] Error in binding transformer:`)}return d?u.length===0?[l]:[l,...u]:u};return{parseTokenKey:i,parseKeySequence:a,formatKey:o,compileBindings:s}}function Cs(e,t){if(e.length>=t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.match!==t[n]?.match)return!1;return!0}function ws(e,t){for(let n of e)if(n.event===`press`&&(n.command!==void 0&&Cs(n.sequence,t.sequence)||t.command!==void 0&&Cs(t.sequence,n.sequence)))throw Error(`Keymap bindings cannot use the same sequence as both an exact match and a prefix in the same layer`)}function Ts(e,t,n){if(typeof e!=`string`||t.length===0)return[{key:e}];let r=n?.layer??vs,i=[{key:e}];for(let e of t){let t=[];for(let n of i){let i=e({input:n.key,displays:n.displays,layer:r});if(!i){t.push(n);continue}if(i.length===0)throw Error(`Keymap binding expander must return at least one key sequence for "${n.key}"`);for(let e of i){if(!e||typeof e!=`object`||Array.isArray(e)||typeof e.key!=`string`)throw Error(`Keymap binding expander must return expansion objects with string keys for "${n.key}"`);if(e.displays!==void 0){if(!Array.isArray(e.displays))throw Error(`Keymap binding expander displays must be an array of strings for "${n.key}"`);for(let t of e.displays)if(typeof t!=`string`)throw Error(`Keymap binding expander displays must be an array of strings for "${n.key}"`)}t.push(e)}}i=t}return i}function Es(e,t){if(!t.displays)return e;if(t.displays.length!==e.parts.length)throw Error(`Keymap binding expansion displays length must match parsed sequence length for "${String(t.key)}"`);return{...e,parts:e.parts.map((e,n)=>({...e,display:t.displays[n]}))}}function Ds(e,t,n){if(e.length===0)throw Error(`Invalid key sequence: sequence cannot be empty`);if(t.length===0)throw Error(`No keymap binding parsers are registered`);let r=n.tokens??new Map,i=n.patterns??new Map,a=n.layer??vs,o=n.parseObjectKey,s=[],c=new Set,l=new Set,u=0;for(;u<e.length;){let n=!1;for(let d of t){let t=d({input:e,index:u,layer:a,tokens:r,patterns:i,normalizeTokenName:Da,createMatch:Ia,parseObjectKey:o});if(t){if(t.nextIndex<=u||t.nextIndex>e.length)throw Error(`Keymap binding parser must advance the input for "${e}" at index ${u}`);s.push(...t.parts);for(let e of t.usedTokens??[])c.add(e);for(let e of t.unknownTokens??[])l.add(e);u=t.nextIndex,n=!0;break}}if(!n)throw Error(`No keymap binding parser handled input at index ${u} in "${e}"`)}return{parts:s,usedTokens:[...c],unknownTokens:[...l],hasTokenBindings:c.size>0||l.size>0}}function Os(e,t,n){if(typeof e!=`string`)return n.parseObjectKey(e);let{parts:r}=Ds(e,t,n),[i]=r;if(!i||r.length!==1)throw Error(`Invalid key "${String(e)}": expected a single key stroke`);return i}function ks(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.get==`function`&&typeof t.subscribe==`function`}function As(e,t){let n=e=>e.requires.length===0&&e.matchers.length===0,r=e=>{try{return e.match()}catch(n){return t.emitError(`runtime-matcher-error`,n,`[Keymap] Error evaluating runtime matcher from ${e.source}:`),!1}},i=e=>{if(e.matchers.length===0)return!0;if(e.matchers.length===1){let[t]=e.matchers;return!t||r(t)}for(let t of e.matchers)if(!r(t))return!1;return!0},a=t=>{if(t.length===0)return!0;for(let[n,r]of t)if(!Object.is(e.data[n],r))return!1;return!0};return{buildRuntimeMatcher(e,t){if(typeof e==`function`)return{source:t,match:e};if(ks(e))return{source:t,match:()=>e.get(),subscribe:t=>e.subscribe(t)};throw Error(`Keymap ${t} expected a function or a reactive matcher`)},matchesConditions:e=>n(e)||a(e.requires)&&i(e)}}var js=Symbol(`keymap-disambiguation-decision`),Ms=Symbol(`keymap-deferred-disambiguation-decision`);function Ns(e,t){return{[js]:!0,action:e,handler:t}}function Ps(e){return{[Ms]:!0,action:e}}function Fs(e){return!!e&&typeof e==`object`&&e[js]===!0}function Is(e){return!!e&&typeof e==`object`&&e[Ms]===!0}function Ls(e,t){return t.aborted?Promise.resolve(!1):new Promise(n=>{let r=setTimeout(()=>{t.removeEventListener(`abort`,i),n(!0)},Math.max(0,e)),i=()=>{clearTimeout(r),t.removeEventListener(`abort`,i),n(!1)};t.addEventListener(`abort`,i,{once:!0})})}function Rs(e,t,n,r){let i=e.get(n);if(i)try{return i.matcher(r)}catch(e){t.emitError(`sequence-pattern-match-error`,e,`[Keymap] Error matching sequence pattern "${i.name}":`);return}}function zs(e,t,n,r){let i=e.get(n)?.payloadKey??n;return{...ja({name:t.name,ctrl:t.ctrl,shift:t.shift,meta:t.meta,super:t.super??!1,hyper:t.hyper||void 0},{display:r.display??String(r.value??t.name)}),patternName:n,payloadKey:i}}function Bs(e,t,n){if(!n?.patterns||n.patterns.length===0)return;let r={},i=!1;for(let a of n.patterns){let n=e.get(a.name),o;try{o=n?.finalize?n.finalize(a.values):a.values.length===1?a.values[0]:[...a.values]}catch(e){t.emitError(`sequence-pattern-finalize-error`,e,`[Keymap] Error finalizing sequence pattern "${a.name}":`);continue}let s=r[a.payloadKey];s===void 0?(r[a.payloadKey]=o,i=!0):Array.isArray(s)?s.push(o):r[a.payloadKey]=[s,o]}return i?r:void 0}function Vs(e,t,n,r,i,a,o,s,c,l){let u={resolveKey:e=>o.parseTokenKey(e).match},d=null,f=0;function p(t,n,r){if(t===`key`){let t=r;return e.keyHooks.register(n,{priority:t?.priority??0,release:t?.release??!1})}if(t===`key:after`){let t=r;return e.keyAfterHooks.register(n,{priority:t?.priority??0,release:t?.release??!1})}let i=r;return e.rawHooks.register(n,{priority:i?.priority??0})}function m(t){return e.eventMatchResolvers.prepend(t)}function h(t){return e.eventMatchResolvers.append(t)}function g(){e.eventMatchResolvers.clear()}function _(t){return L(()=>e.disambiguationResolvers.prepend(t),t)}function v(t){return L(()=>e.disambiguationResolvers.append(t),t)}function y(){e.disambiguationResolvers.has()&&t.runWithStateChangeBatch(()=>{e.disambiguationResolvers.clear(),c.recompileBindings()})}function b(e,t){d&&se()}function x(n){let r=e.rawHooks.entries();if(r.length===0)return!1;let i=!1,a={sequence:n,stop(){i=!0}};for(let e of r){try{e.listener(a)}catch(e){t.emitError(`raw-intercept-error`,e,`[Keymap] Error in raw intercept listener:`)}if(i)return!0}return!1}function S(e,t){return{sequence:Na(e.sequence),command:e.command,commandAttrs:s.getBindingCommandAttrs(e,t,s.getActiveCommandView(t)),attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough,sourceLayerOrder:e.sourceLayerOrder,bindingIndex:e.bindingIndex}}function C(e){l.has(`dispatch`)&&l.emit(`dispatch`,e)}function w(e,t,n,r){l.has(`dispatch`)&&C({phase:e,event:n.event,focused:r,layer:{order:t.order,priority:t.priority,target:t.target,targetMode:t.targetMode},binding:S(n,r),sequence:Na(n.sequence),command:n.command})}function T(e,t,n){if(!l.has(`dispatch`))return;let i=t[0],a=t.length>0?r.collectSequencePartsFromPending({captures:t}):[];C({phase:e,event:`press`,focused:n,layer:i?{order:i.layer.order,priority:i.layer.priority,target:i.layer.target,targetMode:i.layer.targetMode}:void 0,sequence:a})}function E(t){let n=e.keyAfterHooks.entries();for(let e of n)if(e.release===t)return n}function D(e){return e.sequence?Na(e.sequence):e.captures?r.collectSequencePartsFromPending({captures:e.captures}):[]}function O(e,t){return{handled:e!==`sequence-miss`,reason:e,captures:t}}function k(e,t){return{handled:t,reason:t?`binding-handled`:`binding-rejected`,sequence:e.sequence}}function A(e,t){return t.handled||e.reason===`no-match`?t:e}function j(e,i,a,o,s){let c={event:i,eventType:a?`release`:`press`,focused:o,handled:s.handled,reason:s.reason,sequence:D(s),pendingSequence:r.getPendingSequence(),setData:(e,t)=>{n.setData(e,t)},getData:e=>n.getData(e),consume:e=>{let t=e?.preventDefault??!0,n=e?.stopPropagation??!0;t&&i.preventDefault(),n&&i.stopPropagation()}};for(let n of e)if(n.release===a)try{n.listener(c)}catch(e){t.emitError(`key-after-intercept-error`,e,`[Keymap] Error in key:after intercept listener:`)}}function M(){return{handled:!1,reason:`no-match`}}function N(e){e.preventDefault(),e.stopPropagation()}function P(e,t,n,i){r.setPendingSequence({captures:t});let a=O(`sequence-pending`,t);return T(e,t,n),N(i),a}function F(e,t,n,i){let a=O(e,t);return T(`sequence-clear`,t,n),r.setPendingSequence(null),N(i),a}function I(i,a){a||se();let o=E(a),s=o?r.getFocusedTarget():null,c=e.keyHooks.entries(),l={event:i,setData:(e,t)=>{n.setData(e,t)},getData:e=>n.getData(e),consume:e=>{let t=e?.preventDefault??!0,n=e?.stopPropagation??!0;t&&i.preventDefault(),n&&i.stopPropagation()}};for(let e of c)if(e.release===a){try{e.listener(l)}catch(e){t.emitError(`key-intercept-error`,e,`[Keymap] Error in key intercept listener:`)}if(i.propagationStopped){o&&j(o,i,a,s,{handled:!0,reason:`intercept-consumed`,sequence:[]});return}}if(a){let e=R(i);o&&j(o,i,a,s,e);return}let u=z(i);o&&j(o,i,a,s,u)}function L(n,r){return t.runWithStateChangeBatch(()=>{let i=e.disambiguationResolvers.has(),a=n();return!i&&e.disambiguationResolvers.has()&&c.recompileBindings(),()=>{t.runWithStateChangeBatch(()=>{let t=e.disambiguationResolvers.has();a(),!e.disambiguationResolvers.values().includes(r)&&t&&!e.disambiguationResolvers.has()&&c.recompileBindings()})}})}function R(e){let t=r.getFocusedTarget(),n=r.getActiveLayers(t),a=fe(e),o=M();for(let r of a)layerLoop:for(let a of n){if(a.bindings.length===0||!i.matchesConditions(a))continue;let n=pe(a,r,e,t);if(o=A(o,n.outcome),n.handled){if(n.stop)return o;continue layerLoop}}return o}function z(e){let t=r.getFocusedTarget(),n=r.ensureValidPendingSequence(),i=fe(e);if(n)return B(n,i,e,t);let a=r.getActiveLayers(t),o=M();for(let n of i){let r=V(a,[n],e,t);if(o=A(o,r),r.handled)return o}return o}function B(t,n,i,a){let o=s.getActiveCommandView(a),c=[];for(let r of t.captures){let t=io(r,n,i,e.patterns,me,he);t&&c.push(t)}let l=c.reduce((e,t)=>Math.min(e,no(t,n)),1/0),u=c.filter(e=>no(e,n)===l);if(u.length===0||!u.some(e=>q(e,a,o))){let e=O(`sequence-miss`,t.captures);return T(`sequence-clear`,t.captures,a),r.setPendingSequence(null),e}return ee(u,0,!1,i,a)}function ee(t,n,i,a,o){let s=i,c=M(),l=new Set;for(let i=n;i<t.length;i+=1){let n=t[i];if(!n||l.has(n))continue;let u=K(t,i,n);if(u.length>0){if(s)continue;let e=de(t,n);return H(t,i,u,e,a,o,s)||P(`sequence-advance`,u,o,a)}if(!Za(n,e.patterns))continue;let d=de(t,n);for(let e of d)l.add(e);let f=ye(n.layer,d,a,o);if(c=A(c,f.outcome),f.handled&&(s=!0,f.stop))return T(`sequence-clear`,t,o),r.setPendingSequence(null),c}return T(`sequence-clear`,t,o),r.setPendingSequence(null),c}function V(e,t,n,r){return te(e,0,t,n,r)}function te(t,n,r,a,o){let c=s.getActiveCommandView(o),l=M();for(let s=n;s<t.length;s+=1){let n=t[s];if(!n||!i.matchesConditions(n))continue;let u=ge(n,r,a,o,c);if(u.length===0)continue;if(u.filter(t=>Xa(t,e.patterns,!1)).length>0){let n=u.filter(t=>Za(t,e.patterns)),i=ue(t,s,r,a,o);return ne(t,s,r,i,n,a,o)||P(`sequence-start`,i,o,a)}let d=ye(n,u.filter(t=>Za(t,e.patterns)),a,o);if(l=A(l,d.outcome),d.handled&&d.stop)return l}return l}function ne(e,t,n,i,a,o,s){return U({event:o,focused:s,continuationCaptures:i,exactBindingsSource:a.map(e=>e.binding),sequencePhase:`sequence-start`,runExact:()=>{r.setPendingSequence(null);let i=a[0]?.layer;if(!i)return M();let c=ye(i,a,o,s);return c.stop?c.outcome:A(c.outcome,te(e,t+1,n,o,s))}})}function H(e,t,n,i,a,o,s){return U({event:a,focused:o,continuationCaptures:n,exactBindingsSource:i.map(e=>e.binding),sequencePhase:`sequence-advance`,runExact:()=>{r.setPendingSequence(null);let n=i[0]?.layer;if(!n)return M();let c=ye(n,i,a,o);return c.stop?c.outcome:A(c.outcome,ee(e,t+1,s||c.handled,a,o))}})}function U(t){let{event:n,focused:i,continuationCaptures:a,exactBindingsSource:o,sequencePhase:c,runExact:l}=t;if(!e.disambiguationResolvers.has()||a.length===0)return;let u=s.getActiveCommandView(i),d=r.collectMatchingBindings(o,i,u);if(!d.some(e=>e.command!==void 0))return;let f=()=>P(c,a,i,n),p=()=>F(`sequence-cleared`,a,i,n),m,h=()=>(m??=r.collectSequencePartsFromPending({captures:a}),m),g=W({event:n,focused:i,getSequence:h,exactBindings:d,continuationCaptures:a,activeView:u});return g?re(g,a,l,f,p,i,h):(le(h()),f())}function re(e,t,n,r,i,a,o){if(e.action===`run-exact`)return n();if(e.action===`continue-sequence`)return r();if(e.action===`clear`)return i();let s=r();return ie(t,e.handler,a,o(),e=>{if(e){if(e.action===`run-exact`){n();return}if(e.action===`continue-sequence`){r();return}i()}}),s}function W(i){let a,o,s,c,l={event:i.event,focused:i.focused,get sequence(){return a??=Na(i.getSequence()),a},get stroke(){let e=i.getSequence().at(-1);if(!e)throw Error(`Disambiguation context expected a non-empty sequence`);return c??={...e,stroke:Aa(e.stroke)},c},get exact(){return o??=r.collectActiveBindings(i.exactBindings,i.focused,i.activeView).map(e=>({...e,sequence:Na(e.sequence)})),o},get continuations(){return s??=r.getActiveKeysForCaptures(i.continuationCaptures,{includeBindings:!0,includeMetadata:!0}),s},getData:e=>n.getData(e),setData:(e,t)=>{n.setData(e,t)},runExact:()=>Ns(`run-exact`),continueSequence:()=>Ns(`continue-sequence`),clear:()=>Ns(`clear`),defer:e=>Ns(`defer`,e)};for(let n of e.disambiguationResolvers.values()){let e;try{e=n(l)}catch(e){t.emitError(`disambiguation-resolver-error`,e,`[Keymap] Error in disambiguation resolver:`);continue}if(e!==void 0){if(Uo(e)){t.emitError(`invalid-disambiguation-resolver-return`,e,`[Keymap] Disambiguation resolvers must return synchronously; use ctx.defer(...) for async handling`);continue}if(!Fs(e)){t.emitError(`invalid-disambiguation-decision`,e,`[Keymap] Invalid disambiguation decision returned by resolver:`);continue}return e}}}function ie(e,t,n,r,i){se();let a=new AbortController,o={id:f++,controller:a,captures:e,apply:i};d=o,queueMicrotask(()=>{ae(o,t,n,r)})}function ae(e,n,r,i){if(!ce(e))return;let a={signal:e.controller.signal,sequence:Na(i),focused:r,sleep:t=>Ls(t,e.controller.signal),runExact:()=>Ps(`run-exact`),continueSequence:()=>Ps(`continue-sequence`),clear:()=>Ps(`clear`)},o;try{o=n(a)}catch(n){ce(e)&&(t.emitError(`deferred-disambiguation-error`,n,`[Keymap] Error in deferred disambiguation handler:`),oe(e));return}if(Uo(o)){o.then(t=>{G(e,t)}).catch(n=>{ce(e)&&(t.emitError(`deferred-disambiguation-error`,n,`[Keymap] Error in deferred disambiguation handler:`),oe(e))});return}G(e,o)}function G(e,n){if(ce(e)){if(n!==void 0&&!Is(n)){t.emitError(`invalid-deferred-disambiguation-decision`,n,`[Keymap] Invalid deferred disambiguation decision returned by handler:`),oe(e);return}oe(e),e.apply(n)}}function oe(e){ce(e)&&(d=null)}function se(){let e=d;e&&(d=null,e.controller.abort())}function ce(e){return d===e}function le(e){let n=Ra(e,{preferDisplay:!0});t.warnOnce(`unresolved-disambiguation:${n}`,`unresolved-disambiguation`,{sequence:n},`[Keymap] Ambiguous exact/prefix sequence "${n}" fell back to prefix handling because no disambiguation resolver resolved it`)}function ue(t,n,r,a,o){let c=[],l=s.getActiveCommandView(o);for(let s=n;s<t.length;s+=1){let n=t[s];if(n&&i.matchesConditions(n))for(let t of ge(n,r,a,o,l))Xa(t,e.patterns,!1)&&c.push(t)}return c}function K(t,n,r){return t.filter((t,i)=>i>=n&&Xa(t,e.patterns,!1)&&Us(t.parts,r.parts))}function de(t,n){return t.filter(t=>t.layer===n.layer&&Za(t,e.patterns)&&Us(t.parts,n.parts))}function fe(n){let r=e.eventMatchResolvers.values();if(r.length===0)return[];if(r.length===1)return Hs(r[0],n,u,t);let i=[],a=new Set;for(let e of r){let r;try{r=e(n,u)}catch(e){t.emitError(`event-match-resolver-error`,e,`[Keymap] Error in event match resolver:`);continue}if(!(!r||r.length===0))for(let e of r){if(typeof e!=`string`){t.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`);continue}a.has(e)||(a.add(e),i.push(e))}}return i}function pe(e,t,n,r){let o=!1,s=M();for(let c of e.bindings){if(c.event!==`release`)continue;let l=c.sequence[0];if(!l||l.match!==t||!i.matchesConditions(c))continue;let u=a.runBinding(e,c,n,r);if(s=A(s,k(c,u)),!u){w(`binding-reject`,e,c,r);continue}if(w(`binding-execute`,e,c,r),o=!0,!c.fallthrough)return{handled:!0,stop:!0,outcome:s}}return{handled:o,stop:!1,outcome:s}}function me(n,r){return Rs(e.patterns,t,n,r)}function he(t,n,r){return zs(e.patterns,t,n,r)}function ge(e,t,n,r,i){let a=ao(e,t,n,me,he);return a.some(e=>q(e,r,i))?a:[]}function _e(n){return Bs(e.patterns,t,n)}function ve(e,t,n){return i.matchesConditions(e)&&s.isBindingVisible(e,t,n)}function q(e,t,n){return ve(e.binding,t,n)}function ye(e,t,n,r){let o=!1,s=M();for(let c of t){let t=c.binding;if(!i.matchesConditions(t))continue;let l=a.runBinding(e,t,n,r,_e(c));if(s=A(s,k(t,l)),!l){w(`binding-reject`,e,t,r);continue}if(w(`binding-execute`,e,t,r),o=!0,!t.fallthrough)return{handled:!0,stop:!0,outcome:s}}return{handled:o,stop:!1,outcome:s}}return{intercept:p,prependEventMatchResolver:m,appendEventMatchResolver:h,clearEventMatchResolvers:g,prependDisambiguationResolver:_,appendDisambiguationResolver:v,clearDisambiguationResolvers:y,handlePendingSequenceChange:b,handleRawSequence:x,handleKeyEvent:I}}function Hs(e,t,n,r){let i;try{i=e(t,n)}catch(e){return r.emitError(`event-match-resolver-error`,e,`[Keymap] Error in event match resolver:`),[]}if(!i||i.length===0)return[];if(i.length===1){let[e]=i;return typeof e==`string`?[e]:(r.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`),[])}let a=[],o=new Set;for(let e of i){if(typeof e!=`string`){r.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`);continue}o.has(e)||(o.add(e),a.push(e))}return a}function Us(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.match!==t[n]?.match)return!1;return!0}var Ws=()=>{};function Gs(e,t,n,r){if(n===void 0)return r;if(typeof n!=`number`||!Number.isInteger(n)||n<0)throw Error(`Keymap sequence pattern "${e}" ${t} must be a non-negative integer`);return n}function Ks(e,t){let{kind:n,reservedFields:r,registeredFields:i,emitError:a}=t,o=Object.entries(e),s=[];for(let[e,t]of o){if(r.has(e)){a(`reserved-${n}-field`,{field:e,kind:n},`Keymap ${n} field "${e}" is reserved`);continue}if(i.has(e)){a(`duplicate-${n}-field`,{field:e,kind:n},`Keymap ${n} field "${e}" is already registered`);continue}i.set(e,t),s.push([e,t])}return()=>{for(let[e,t]of s)i.get(e)===t&&i.delete(e)}}function qs(e,t,n,r,i){let a;try{a=Da(i.name)}catch(e){return t.emitError(`token-name-normalize-error`,e,Ho(e,`Failed to register keymap token`)),Ws}if(e.tokens.has(a)||e.patterns.has(a))return t.emitError(`duplicate-token`,{token:a},`Keymap token "${a}" is already registered`),Ws;let o;try{if(o=n.parseTokenKey(i.key),o.patternName)throw Error(`Invalid key "${String(i.key)}": expected a concrete key stroke`)}catch(e){return t.emitError(`token-parse-error`,e,Ho(e,`Failed to register keymap token "${a}"`)),Ws}let s={stroke:o.stroke,match:o.match},c=new Map(e.tokens);c.set(a,s);try{r.applyTokenState(c)}catch(e){return t.emitError(`token-register-error`,e,Ho(e,`Failed to register keymap token "${a}"`)),Ws}return()=>{if(e.tokens.get(a)!==s)return;let n=new Map(e.tokens);n.delete(a);try{r.applyTokenState(n)}catch(e){t.emitError(`token-unregister-error`,e,Ho(e,`Failed to unregister keymap token "${a}"`))}}}function Js(e,t,n,r){let i,a;try{i=Da(r.name);let e=Gs(i,`min`,r.min,1),t=Gs(i,`max`,r.max,2**53-1);if(t<e)throw Error(`Keymap sequence pattern "${i}" max must be greater than or equal to min`);a={name:i,display:r.display,payloadKey:r.payloadKey??i,match:Ia(`pattern:${i}`),min:e,max:t,matcher:e=>r.match(e),finalize:r.finalize}}catch(e){return t.emitError(`sequence-pattern-register-error`,e,Ho(e,`Failed to register keymap sequence pattern`)),Ws}return e.tokens.has(i)||e.patterns.has(i)?(t.emitError(`duplicate-sequence-pattern`,{pattern:i},`Keymap sequence pattern "${i}" is already registered`),Ws):(e.patterns.set(i,a),n.recompileBindings(),()=>{e.patterns.get(i)===a&&(e.patterns.delete(i),n.recompileBindings())})}function Ys(e,t,n,r){return Ks(r,{kind:n,reservedFields:n===`layer`?jo:n===`binding`?Ao:ko,registeredFields:n===`layer`?e.layerFields:n===`binding`?e.bindingFields:e.commandFields,emitError:(e,n,r)=>t.emitError(e,n,r)})}var Xs=()=>{};function Zs(e,t){return t.priority-e.priority||t.order-e.order}function Qs(e){if(e.matchers.length>0)return!0;for(let t of e.commands)if(t.matchers.length>0)return!0;for(let t of e.bindings)if(t.matchers.length>0)return!0;return!1}function $s(e){if(e.commands.length===0)return!1;if(e.matchers.length>0)return!0;for(let t of e.commands)if(t.matchers.length>0)return!0;return!1}function ec(e,t,n,r,i){let a=n=>t.runWithStateChangeBatch(()=>{let a=n.target;if(a&&i.host.isTargetDestroyed(a))return t.emitError(`destroyed-layer-target`,{target:a},`Cannot register a keymap layer for a destroyed keymap target`),Xs;let o,s,c,p,m,v,y;try{y=l(n),o=u(po(n.bindings??[]),n);let e=d(n.commands??[],n);v=e.length===0?[]:i.commands.normalizeCommands(e),{requires:s,matchers:c,fields:p,attrs:m}=f(n)}catch(e){return t.emitError(`register-layer-failed`,e,Ho(e,`Failed to register keymap layer`)),Xs}let b=e.order++,x=i.compiler.compileBindings(o,e.tokens,a,b,p);if(x.bindings.length===0&&!x.hasTokenBindings&&v.length===0)return Xs;i.diagnostics?.analyzeLayer({target:a,order:b,commands:v,sourceBindings:o,bindings:x.bindings,hasTokenBindings:x.hasTokenBindings});let S={order:b,target:a,targetMode:y,priority:n.priority??0,requires:s,matchers:c,fields:p,attrs:m,commands:v,sourceBindings:o,bindings:x.bindings,root:$a(x.bindings,e.patterns),hasTokenBindings:x.hasTokenBindings,activeKeyCacheBlocked:!1,activeCommandViewCacheBlocked:!1};_(S),e.layers.add(S),e.sortedLayers=[...e.sortedLayers,S].sort(Zs),g(S);for(let e of S.commands)g(e);for(let e of S.bindings)g(e);return a&&(S.offTargetDestroy=i.host.onTargetDestroy(a,()=>{h(S)})),S.commands.length>0&&r.ensureValidPendingSequence(),t.queueStateChange(),()=>{h(S)}}),o=n=>{t.runWithStateChangeBatch(()=>{let i=new Map;for(let t of e.layers)t.hasTokenBindings&&i.set(t,p(t,n));e.tokens=n;let a=!1;for(let[e,t]of i)m(e,t)&&(a=!0);a&&r.setPendingSequence(null),i.size>0&&t.queueStateChange()})},s=()=>{t.runWithStateChangeBatch(()=>{let n=0,i=!1;for(let t of e.layers){if(t.sourceBindings.length===0)continue;let r=p(t,e.tokens);m(t,r)&&(i=!0),n+=1}i&&r.setPendingSequence(null),n>0&&t.queueStateChange()})},c=()=>{for(let t of e.layers){y(t);for(let e of t.commands)y(e);for(let e of t.bindings)y(e);t.offTargetDestroy?.(),t.offTargetDestroy=void 0}},l=e=>{if(e.targetMode){if(!e.target)throw Error(`Keymap targetMode "${e.targetMode}" requires a target`);return e.targetMode}return e.target?`focus-within`:void 0},u=(t,n)=>{let r=e.layerBindingsTransformers.values();if(r.length===0)return t;let i=t;for(let e of r){let t=e(i,{layer:n,validateBindings:e=>fo(e)});t&&(i=po(t))}return i},d=(n,r)=>{let i=e.commandTransformers.values();if(n.length===0||i.length===0)return n;let a=[];for(let e of n){let n={...e},o=[],s=!0;for(let e of i)try{e(n,{layer:r,add(e){o.push({...e})},skipOriginal(){s=!1}})}catch(e){t.emitError(`command-transformer-error`,e,`[Keymap] Error in command transformer:`)}s&&a.push(n),a.push(...o)}return a},f=t=>{let r={},a=[],o=Object.create(null),s={};for(let[c,l]of Object.entries(t)){if(jo.has(c)||l===void 0)continue;o[c]=Wo(l);let t=e.layerFields.get(c);if(!t){i.warnUnknownField(`layer`,c);continue}t(l,Bo({fieldName:c,conditions:n,requirements:r,matchers:a,attrs:s}))}return{requires:Object.entries(r),matchers:a,fields:Object.keys(o).length>0?Object.freeze(o):void 0,attrs:Object.keys(s).length>0?Wo(s,{freeze:!0}):void 0}},p=(e,t)=>i.compiler.compileBindings(e.sourceBindings,t,e.target,e.order,e.fields),m=(t,n)=>{i.diagnostics?.analyzeLayer({target:t.target,order:t.order,commands:t.commands,sourceBindings:t.sourceBindings,bindings:n.bindings,hasTokenBindings:n.hasTokenBindings}),v(t);for(let e of t.bindings)y(e);t.bindings=n.bindings,t.root=$a(n.bindings,e.patterns),t.hasTokenBindings=n.hasTokenBindings,_(t);for(let e of t.bindings)g(e);return e.pending?.captures.some(e=>e.layer===t)??!1},h=n=>{t.runWithStateChangeBatch(()=>{if(e.layers.delete(n)){e.sortedLayers=e.sortedLayers.filter(e=>e!==n),v(n),y(n);for(let e of n.commands)y(e);for(let e of n.bindings)y(e);n.offTargetDestroy?.(),n.offTargetDestroy=void 0,e.pending?.captures.some(e=>e.layer===n)?r.setPendingSequence(null):n.commands.length>0&&!i.host.isDestroyed&&r.ensureValidPendingSequence(),t.queueStateChange()}})},g=e=>{for(let n of e.matchers)if(n.subscribe)try{n.dispose=n.subscribe(()=>{if(!r.hasPendingSequenceState()){t.queueStateChange();return}t.runWithStateChangeBatch(()=>{r.revalidatePendingSequenceIfNeeded(),t.queueStateChange()})})}catch(e){t.emitError(`reactive-matcher-subscribe-error`,e,Ho(e,`Failed to subscribe to reactive matcher from ${n.source}`))}},_=t=>{let n=Qs(t),r=$s(t);t.activeKeyCacheBlocked=n,t.activeCommandViewCacheBlocked=r,n&&(e.activeKeyCacheBlockers+=1),r&&(e.activeCommandViewCacheBlockers+=1)},v=t=>{t.activeKeyCacheBlocked&&=(--e.activeKeyCacheBlockers,!1),t.activeCommandViewCacheBlocked&&=(--e.activeCommandViewCacheBlockers,!1)},y=e=>{for(let n of e.matchers)if(n.dispose){try{n.dispose()}catch(e){t.emitError(`reactive-matcher-dispose-error`,e,Ho(e,`Failed to dispose reactive matcher from ${n.source}`))}n.dispose=void 0}};return{registerLayer:a,applyTokenState:o,recompileBindings:s,cleanup:c}}var tc=1e3;function nc(e,t,n){let r=(e,n,r)=>{if(!t.has(`warning`)){let t=`[${e}] ${r}`;n instanceof Error?console.warn(t,n):console.warn(t);return}t.emit(`warning`,{code:e,message:r,warning:n})},i=(e,n,r)=>{if(!t.has(`error`)){let t=`[${e}] ${r}`;n instanceof Error?console.error(t,n):console.error(t);return}t.emit(`error`,{code:e,message:r,error:n})},a=()=>{if(!(!e.stateChangePending||e.stateChangeDepth>0||e.flushingStateChange)){e.flushingStateChange=!0;try{let t=0;for(;e.stateChangePending&&e.stateChangeDepth===0;){if(t>=tc){e.stateChangePending=!1,i(`state-change-feedback-loop`,{iterations:tc},`[Keymap] Possible infinite state listener feedback loop detected after ${tc} iterations; pending state notifications were dropped`);break}t+=1,e.stateChangePending=!1,n.emit(`state`)}}finally{e.flushingStateChange=!1}}};return{runWithStateChangeBatch(t){e.stateChangeDepth+=1;try{return t()}finally{--e.stateChangeDepth,e.stateChangeDepth===0&&a()}},queueStateChange(t){e.derivedVersion+=1,t?.invalidateCaches!==!1&&(e.cacheVersion+=1),n.has(`state`)&&(e.stateChangePending=!0,e.stateChangeDepth===0&&!e.flushingStateChange&&a())},emitWarning:r,emitError:i,reportListenerError(e,t){if(e===`state`){i(`state-listener-error`,t,`[Keymap] Error in state listener:`);return}if(e===`pendingSequence`){i(`pending-sequence-listener-error`,t,`[Keymap] Error in pending sequence listener:`);return}e===`dispatch`&&i(`dispatch-listener-error`,t,`[Keymap] Error in dispatch listener:`)},warnOnce(t,n,i,a){e.usedWarningKeys.has(t)||(e.usedWarningKeys.add(t),r(n,i,a))}}}function rc(e,t,n){return{getData(t){return e.data[t]},setData(r,i){t.runWithStateChangeBatch(()=>{if(i===void 0){if(!(r in e.data))return;delete e.data[r],e.dataVersion+=1,n.ensureValidPendingSequence(),t.queueStateChange();return}Object.is(e.data[r],i)||(e.data[r]=i,e.dataVersion+=1,n.ensureValidPendingSequence(),t.queueStateChange())})},getReadonlyData(){return e.readonlyDataVersion===e.dataVersion?e.readonlyData:(e.readonlyData=Object.freeze({...e.data}),e.readonlyDataVersion=e.dataVersion,e.readonlyData)}}}var ic=Object.freeze({});function ac(){return{order:0,tokens:new Map,patterns:new Map,layerFields:new Map,layerBindingsTransformers:co(),bindingExpanders:co(),bindingParsers:co(),bindingTransformers:co(),bindingFields:new Map,commandTransformers:co(),commandFields:new Map,eventMatchResolvers:co(),disambiguationResolvers:co(),keyHooks:lo(),keyAfterHooks:lo(),rawHooks:lo(),layers:new Set,sortedLayers:[],activeLayersCacheVersion:-1,activeLayersCacheFocused:void 0,activeLayersCache:[],activeKeyCacheBlockers:0,activeCommandViewCacheBlockers:0,commandResolvers:co(),pending:null,data:{},dataVersion:0,readonlyDataVersion:-1,readonlyData:ic,cacheVersion:0,derivedVersion:0,stateChangeDepth:0,stateChangePending:!1,flushingStateChange:!1,usedWarningKeys:new Set}}function oc(e){return Pa(e)}var sc=class{#e=ac();#t=!1;#n=new Map;#r=[];#i=oo(()=>{});#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;getPendingSequence;getActiveKeys;constructor(e){if(this.#b=e,e.isDestroyed)throw Error(`Cannot create a keymap for a destroyed host`);this.#a=oo((e,t)=>{this.#o.reportListenerError(e,t)}),this.#o=nc(this.#e,this.#i,this.#a),this.#l=As(this.#e,this.#o),this.#u=Jo(this.#e,this.#b,this.#o,this.#l,{onCommandResolversChanged:()=>{this.#s.ensureValidPendingSequence()}}),this.#s=Oo(this.#e,this.#b,this.#a,this.#o,this.#l,this.#u,{onPendingSequenceChanged:(e,t)=>{this.#p?.handlePendingSequenceChange(e,t)}}),this.#c=rc(this.#e,this.#o,this.#s),this.#d=hs(this.#o,this.#c,this.#s,this.#u,{keymap:this,createCommandEvent:()=>this.#b.createCommandEvent()}),this.#f=Ss(this.#e,this.#o,this.#l,{warnUnknownField:(e,t)=>{this.#C(e,t)},warnUnknownToken:(e,t)=>{this.#w(e,t)}}),this.#h=ho(this.#o,this.#u),this.#m=ec(this.#e,this.#o,this.#l,this.#s,{compiler:this.#f,commands:this.#u,host:this.#b,diagnostics:this.#h,warnUnknownField:(e,t)=>{this.#C(e,t)}}),this.#p=Vs(this.#e,this.#o,this.#c,this.#s,this.#l,this.#d,this.#f,this.#u,this.#m,this.#a),this.getPendingSequence=this.#s.getPendingSequence,this.getActiveKeys=this.#s.getActiveKeys,this.#g=e=>{this.#p.handleKeyEvent(e,!1)},this.#_=e=>{this.#p.handleKeyEvent(e,!0)},this.#v=e=>this.#p.handleRawSequence(e),this.#y=e=>{this.#S(e)},this.#r.push(this.#b.onKeyPress(this.#g)),this.#r.push(this.#b.onKeyRelease(this.#_)),this.#b.onRawInput&&this.#r.push(this.#b.onRawInput(this.#v)),this.#r.push(this.#b.onFocusChange(this.#y)),this.#b.onDestroy&&this.#r.push(this.#b.onDestroy(()=>{this.#x()}))}[Va](){return{state:this.#e,host:this.#b,conditions:this.#l,catalog:this.#u,activation:this.#s}}#x(){if(!this.#t){this.#t=!0,this.#s.setPendingSequence(null);for(let e of this.#n.values())e.dispose();this.#n.clear(),this.#m.cleanup();for(let e of this.#r.splice(0))e()}}setData(e,t){this.#c.setData(e,t)}getData(e){return this.#c.getData(e)}getHostMetadata(){return this.#b.metadata}hasPendingSequence(){return this.#s.ensureValidPendingSequence()!==void 0}createKeyMatcher(e){let t=this.#f.parseTokenKey(e).match;return e=>e?oc(e)===t:!1}parseKeySequence(e){return this.#f.parseKeySequence(e)}formatKey(e,t){return this.#f.formatKey(e,t)}clearPendingSequence(){this.#s.setPendingSequence(null)}popPendingSequence(){return this.#s.popPendingSequence()}getCommands(e){return this.#u.getCommands(e)}getCommandEntries(e){return this.#u.getCommandEntries(e)}getCommandBindings(e){return this.#u.getCommandBindings(e)}acquireResource(e,t){if(this.#t||this.#b.isDestroyed)throw Error(`Cannot use a keymap after its host was destroyed`);let n=this.#n.get(e);if(n)return n.count+=1,()=>{this.#T(e,n)};let r={count:1,dispose:t()};return this.#n.set(e,r),()=>{this.#T(e,r)}}runCommand(e,t){return this.#d.runCommand(e,t)}dispatchCommand(e,t){return this.#d.dispatchCommand(e,t)}on(e,t){return e===`warning`||e===`error`?this.#i.hook(e,t):this.#a.hook(e,t)}intercept(e,t,n){return this.#p.intercept(e,t,n)}registerLayer(e){return this.#m.registerLayer(e)}registerLayerFields(e){return Ys(this.#e,this.#o,`layer`,e)}prependLayerBindingsTransformer(e){return this.#e.layerBindingsTransformers.prepend(e)}appendLayerBindingsTransformer(e){return this.#e.layerBindingsTransformers.append(e)}clearLayerBindingsTransformers(){this.#e.layerBindingsTransformers.clear()}prependBindingTransformer(e){return this.#e.bindingTransformers.prepend(e)}appendBindingTransformer(e){return this.#e.bindingTransformers.append(e)}clearBindingTransformers(){this.#e.bindingTransformers.clear()}prependCommandTransformer(e){return this.#e.commandTransformers.prepend(e)}appendCommandTransformer(e){return this.#e.commandTransformers.append(e)}clearCommandTransformers(){this.#e.commandTransformers.clear()}prependBindingParser(e){return this.#e.bindingParsers.prepend(e)}appendBindingParser(e){return this.#e.bindingParsers.append(e)}clearBindingParsers(){this.#e.bindingParsers.clear()}registerToken(e){return qs(this.#e,this.#o,this.#f,this.#m,e)}registerSequencePattern(e){return Js(this.#e,this.#o,this.#m,e)}prependBindingExpander(e){return this.#e.bindingExpanders.prepend(e)}appendBindingExpander(e){return this.#e.bindingExpanders.append(e)}clearBindingExpanders(){this.#e.bindingExpanders.clear()}registerBindingFields(e){return Ys(this.#e,this.#o,`binding`,e)}registerCommandFields(e){return Ys(this.#e,this.#o,`command`,e)}prependCommandResolver(e){return this.#u.prependCommandResolver(e)}appendCommandResolver(e){return this.#u.appendCommandResolver(e)}clearCommandResolvers(){this.#u.clearCommandResolvers()}prependLayerAnalyzer(e){return this.#h.prependLayerAnalyzer(e)}appendLayerAnalyzer(e){return this.#h.appendLayerAnalyzer(e)}clearLayerAnalyzers(){this.#h.clearLayerAnalyzers()}prependEventMatchResolver(e){return this.#p.prependEventMatchResolver(e)}appendEventMatchResolver(e){return this.#p.appendEventMatchResolver(e)}clearEventMatchResolvers(){this.#p.clearEventMatchResolvers()}prependDisambiguationResolver(e){return this.#p.prependDisambiguationResolver(e)}appendDisambiguationResolver(e){return this.#p.appendDisambiguationResolver(e)}clearDisambiguationResolvers(){this.#p.clearDisambiguationResolvers()}#S(e){this.#o.runWithStateChangeBatch(()=>{this.#s.setPendingSequence(null),this.#o.queueStateChange({invalidateCaches:!1})})}#C(e,t){this.#o.warnOnce(`${e}:${t}`,`unknown-${e}-field`,{field:t,kind:e},`[Keymap] Unknown ${e} field "${t}" was ignored`)}#w(e,t){this.#o.warnOnce(`token:${e}`,`unknown-token`,{token:e,sequence:t},`[Keymap] Unknown token "${e}" in key sequence "${t}"; binding was skipped until the token is registered`)}#T(e,t){this.#n.get(e)===t&&(--t.count,!(t.count>0)&&(t.dispose(),this.#n.delete(e)))}},cc=new Set(`up.down.left.right.clear.escape.return.linefeed.enter.tab.backspace.delete.insert.home.end.pageup.pagedown.space.lt.gt.plus.minus.equal.comma.period.slash.backslash.semicolon.quote.backquote.leftbracket.rightbracket.capslock.numlock.scrolllock.printscreen.pause.menu.apps.kp0.kp1.kp2.kp3.kp4.kp5.kp6.kp7.kp8.kp9.kpdecimal.kpdivide.kpmultiply.kpminus.kpplus.kpenter.kpequal.kpseparator.kpleft.kpright.kpup.kpdown.kppageup.kppagedown.kphome.kpend.kpinsert.kpdelete.mediaplay.mediapause.mediaplaypause.mediareverse.mediastop.mediafastforward.mediarewind.medianext.mediaprev.mediarecord.volumedown.volumeup.mute.leftshift.leftctrl.leftalt.leftsuper.lefthyper.leftmeta.rightshift.rightctrl.rightalt.rightsuper.righthyper.rightmeta.iso_level3_shift.iso_level5_shift.option.alt.meta.super.hyper.control.ctrl.shift`.split(`.`)),lc=new Set([`ctrl`,`control`,`shift`,`meta`,`alt`,`option`,`super`,`hyper`]),uc=fc(cc),dc=fc(lc);function fc(e){let t=new Map;for(let n of e){let e=n.charCodeAt(0);if(Number.isNaN(e))continue;let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(let e of t.values())e.sort((e,t)=>t.length-e.length);return t}function pc(e){return e>=65&&e<=90?e+32:e}function X(e){return e>=48&&e<=57}function mc(e,t,n){if(e.startsWith(t,n))return!0;if(n+t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(pc(e.charCodeAt(n+r))!==t.charCodeAt(r))return!1;return!0}function hc(e,t,n){let r=t.charCodeAt(n);if(Number.isNaN(r))return;let i=e.get(pc(r));if(i){for(let e of i)if(mc(t,e,n))return e}}function gc(e,t,n,r,i){return e.parseObjectKey(t,{display:n,match:r,tokenName:i})}function _c(e,t){if(e===` `)return t.parseObjectKey({name:`space`},{display:`space`});if(e===`+`)return t.parseObjectKey({name:`+`},{display:`+`});let n=e.split(`+`),r=``,i=``,a=!1,o=!1,s=!1,c=!1,l=!1;for(let t of n){let n=t.trim();if(!n)continue;let u=n.toLowerCase();if(u===`ctrl`||u===`control`){a=!0;continue}if(u===`shift`){o=!0;continue}if(u===`meta`||u===`alt`||u===`option`){s=!0;continue}if(u===`super`){c=!0;continue}if(u===`hyper`){l=!0;continue}if(r)throw Error(`Invalid key "${e}": multiple key names are not supported`);r=n,i=u}if(!r)throw Error(`Invalid key "${e}": missing key name`);let u=[];return a&&u.push(`ctrl`),o&&u.push(`shift`),s&&u.push(`meta`),c&&u.push(`super`),l&&u.push(`hyper`),u.push(i),t.parseObjectKey({name:r,ctrl:a,shift:o,meta:s,super:c,hyper:l||void 0},{display:u.join(`+`)})}function vc(e,t){let n=e.trim().toLowerCase();return t.parseObjectKey({name:n},{display:n})}function yc(e,t){let n=hc(uc,e,t);if(n)return n;if(pc(e.charCodeAt(t))!==102||!X(e.charCodeAt(t+1)))return;let r=X(e.charCodeAt(t+2))?t+3:t+2;return e.slice(t,r).toLowerCase()}function bc(e,t){return hc(dc,e,t)}function xc(e,t,n){let r=t,i=!1,a=!1,o=!1,s=!1,c=!1;for(;r<e.length;){let t=bc(e,r);if(!t)break;let n=r+t.length;if(e[n]!==`+`)break;t===`ctrl`||t===`control`?i=!0:t===`shift`?a=!0:t===`meta`||t===`alt`||t===`option`?o=!0:t===`super`?s=!0:t===`hyper`&&(c=!0),r=n+1}if(r===t)return;let l=e[r];if(l===void 0)throw Error(`Invalid key "${e.slice(t)}": missing key name`);let u=yc(e,r)??l,d=u===` `?`space`:u===`+`?`+`:u.toLowerCase(),f=[];return i&&f.push(`ctrl`),a&&f.push(`shift`),o&&f.push(`meta`),s&&f.push(`super`),c&&f.push(`hyper`),f.push(d),{part:n.parseObjectKey({name:u===` `?`space`:u,ctrl:i,shift:a,meta:o,super:s,hyper:c||void 0},{display:f.join(`+`)}),nextIndex:r+u.length}}var Sc=e=>{let{input:t,index:n,tokens:r,normalizeTokenName:i}=e;if(n===0&&t.includes(`+`)&&/\s/.test(t))return{parts:[_c(t,e)],nextIndex:t.length};let a=t[n];if(a===void 0)return;if(a===`<`){let o=t.indexOf(`>`,n);if(o===-1)return{parts:[_c(a,e)],nextIndex:n+1};let s=i(t.slice(n+1,o)),c=r.get(s);return c?{parts:[gc(e,c.stroke,`<${s}>`,c.match,s)],nextIndex:o+1,usedTokens:[s]}:{parts:[],nextIndex:o+1,unknownTokens:[s]}}if(a===`{`){let r=t.indexOf(`}`,n);if(r===-1)return{parts:[_c(a,e)],nextIndex:n+1};let o=i(t.slice(n+1,r)),s=e.patterns.get(o);return s?{parts:[{...e.parseObjectKey({name:o,ctrl:!1,shift:!1,meta:!1,super:!1},{display:s.display??`{${o}}`,match:s.match}),patternName:s.name,payloadKey:s.payloadKey}],nextIndex:r+1,usedTokens:[o]}:{parts:[],nextIndex:r+1,unknownTokens:[o]}}let o=xc(t,n,e);if(o)return{parts:[o.part],nextIndex:o.nextIndex};let s=yc(t,n);return s?{parts:[vc(s,e)],nextIndex:n+s.length}:{parts:[_c(a,e)],nextIndex:n+1}},Cc=(e,t)=>[t.resolveKey({name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super??!1,hyper:e.hyper||void 0})];function wc(e){return e.appendBindingParser(e=>Sc(e))}function Tc(e){return e.appendEventMatchResolver((e,t)=>Cc(e,t))}function Ec(e){let t=wc(e),n=Tc(e);return()=>{n(),t()}}var Dc=Symbol(`keymap:mod-bindings`),Oc=/(^|[+,\s])mod(?=\s*\+)/i,kc=/(^|[+,\s])mod(?=\s*\+)/gi;function Ac(e){let t=e.primaryModifier;return(t===`ctrl`||t===`super`)&&e.modifiers[t]!==`unsupported`?t:e.modifiers.ctrl===`unsupported`?`super`:`ctrl`}function jc(e){if(e.includes(`,`))return[e];let t=e.trim();return t.includes(` `)?t.split(/\s+/):[e]}function Mc(e){return e.acquireResource(Dc,()=>e.appendBindingExpander(({input:t,displays:n})=>{if(!Oc.test(t))return;let r=Ac(e.getHostMetadata());return[{key:t.replace(kc,(e,t)=>`${t}${r}`),displays:n??jc(t)}]}))}var Nc=new Map([[` `,`space`],[`Spacebar`,`space`],[`ArrowUp`,`up`],[`ArrowDown`,`down`],[`ArrowLeft`,`left`],[`ArrowRight`,`right`],[`Escape`,`escape`],[`Esc`,`escape`],[`Enter`,`return`],[`Backspace`,`backspace`],[`Delete`,`delete`],[`Tab`,`tab`],[`Home`,`home`],[`End`,`end`],[`PageUp`,`pageup`],[`PageDown`,`pagedown`],[`Insert`,`insert`],[`CapsLock`,`capslock`],[`NumLock`,`numlock`],[`ScrollLock`,`scrolllock`],[`ContextMenu`,`menu`],[`Meta`,`super`],[`OS`,`super`],[`Alt`,`alt`],[`Control`,`control`],[`Shift`,`shift`]]);function Pc(e){let t=e?.trim().toLowerCase();return t?t.includes(`mac`)||t.includes(`darwin`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)||t.includes(`x11`)?`linux`:`unknown`:`unknown`}function Fc(){let e=globalThis.navigator,t=e?.userAgentData?.platform,n=Pc(t);return n===`unknown`?Pc(e?.platform??e?.userAgent):n}function Ic(){let e=Fc();return{platform:e,primaryModifier:e===`macos`?`super`:e===`unknown`?`unknown`:`ctrl`,modifiers:{ctrl:`supported`,shift:`supported`,meta:`supported`,super:`supported`,hyper:`unsupported`}}}function Lc(e){return e.length===1&&!/^[a-z0-9]$/i.test(e)}function Rc(e){let t={name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super??!1,hyper:e.hyper||void 0};return!t.shift||!Lc(t.name)?[t]:[t,{...t,shift:!1}]}var zc=class{name;ctrl;shift;meta;superKey;originalEvent;propagationStopped=!1;constructor(e,t,n,r,i,a){this.name=e,this.ctrl=t,this.shift=n,this.meta=r,this.superKey=i,this.originalEvent=a}get super(){return this.superKey}preventDefault(){this.originalEvent?.preventDefault()}stopPropagation(){this.propagationStopped=!0,this.originalEvent?.stopPropagation()}};function Bc(){return globalThis.MutationObserver}function Vc(e){return Nc.get(e)||(/^F\d{1,2}$/i.test(e)||e.length===1?e.toLowerCase():e.trim().toLowerCase().replace(/\s+/g,``))}function Hc(e){if(!e)return new zc(`command`,!1,!1,!1,!1);let t=globalThis.KeyboardEvent;return new zc(Vc(e.key),e.ctrlKey,e.shiftKey,e.altKey,e.metaKey,t&&e instanceof t?e:void 0)}var Uc=class{metadata=Ic();rootTarget;isDestroyed=!1;observer;targetDestroyListeners=new Map;constructor(e){this.rootTarget=e}getFocusedTarget(){let e=this.rootTarget.ownerDocument.activeElement;return!e||typeof e!=`object`?null:e===this.rootTarget||this.rootTarget.contains(e)?e:null}getParentTarget(e){return e.parentElement}isTargetDestroyed(e){return e===this.rootTarget?!1:!e.isConnected||!this.rootTarget.contains(e)}onKeyPress(e){let t=t=>{e(Hc(t))};return this.rootTarget.addEventListener(`keydown`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`keydown`,t,{capture:!0})}}onKeyRelease(e){let t=t=>{e(Hc(t))};return this.rootTarget.addEventListener(`keyup`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`keyup`,t,{capture:!0})}}onFocusChange(e){let t=()=>{queueMicrotask(()=>{e(this.getFocusedTarget())})};return this.rootTarget.addEventListener(`focusin`,t,{capture:!0}),this.rootTarget.addEventListener(`focusout`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`focusin`,t,{capture:!0}),this.rootTarget.removeEventListener(`focusout`,t,{capture:!0})}}onTargetDestroy(e,t){let n=this.targetDestroyListeners.get(e);return n||(n=new Set,this.targetDestroyListeners.set(e,n)),n.add(t),this.ensureObserver(),this.flushDisconnectedTargets(),()=>{let n=this.targetDestroyListeners.get(e);n&&(n.delete(t),n.size===0&&this.targetDestroyListeners.delete(e),this.targetDestroyListeners.size===0&&this.disconnectObserver())}}createCommandEvent(){return Hc()}ensureObserver(){if(this.observer||this.targetDestroyListeners.size===0)return;let e=Bc();e&&(this.observer=new e(()=>{this.flushDisconnectedTargets()}),this.observer.observe(this.rootTarget,{childList:!0,subtree:!0}))}disconnectObserver(){this.observer&&=(this.observer.disconnect(),void 0)}flushDisconnectedTargets(){for(let[e,t]of this.targetDestroyListeners)if(this.isTargetDestroyed(e)){this.targetDestroyListeners.delete(e);for(let e of[...t])e()}this.targetDestroyListeners.size===0&&this.disconnectObserver()}};function Wc(e){return new Uc(e)}var Gc=(e,t)=>Rc(e).map(e=>t.resolveKey(e));function Kc(e){return e instanceof u?{code:e.code,message:Jc(e.message),retryable:e.retryable,...e.need!==void 0&&{need:e.need}}:{code:`HOST_FAILURE`,message:`Host operation failed`,retryable:!1}}function qc(e){try{let t=ht(e);return new u(t.message,{code:t.code,retryable:t.retryable,...t.need!==void 0&&{need:t.need}})}catch(e){return new u(`The host returned a malformed error`,{cause:e,code:`PROTOCOL`,retryable:!1})}}function Jc(e){return e.trim().slice(0,512)||`Host operation failed`}var Yc=e=>({ok:!0,value:e}),Xc=e=>({error:Kc(e),ok:!1});async function Zc(e,t){let n,r=new Set;try{return n=await e,Qc(t(n))}catch(e){throw $c(e)&&el(e,r),e instanceof u?e:new u(`The remote operation failed`,{cause:e,code:`HOST_FAILURE`,retryable:!0})}finally{n!==e&&$c(n)&&el(n,r)}}function Qc(e){if(e.ok)return e.value;throw qc(e.error)}function $c(e){return Wt(e)&&Symbol.dispose in e&&kt(e[Symbol.dispose])}function el(e,t){if(!t.has(e)){t.add(e);try{e[Symbol.dispose]()}catch(e){console.warn(`RPC result disposal failed`,e)}}}function tl(){let e=[],t=new Set;return{get:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),update:n=>{e=n;for(let e of Array.from(t))try{e()}catch(e){console.warn(`App binding subscriber failed`,e)}}}}function nl(e){let t=ke(e),n=new Set;return{get:()=>t,subscribe:e=>(n.add(e),()=>n.delete(e)),update:e=>{t=ke(e);for(let e of Array.from(n))try{e()}catch(e){console.warn(`Reserved chord subscriber failed`,e)}}}}function rl(e){let t=!0,n,r=e.window.document.querySelector(`html`);if(!r)return()=>{t=!1};let i=Wc(r),a=new sc(i);Ec(a),Mc(a),a.prependEventMatchResolver(Gc);let o=al(e.onBroken),s=ll(a,e.chords,e.remote,o),c=il(e,o,()=>t,e=>{n=e},()=>n),l=i.onFocusChange(()=>{queueMicrotask(c)}),u=()=>{queueMicrotask(c)};e.window.addEventListener(`focus`,u),e.window.addEventListener(`blur`,u);let d=e.bindings,f=()=>ol(e.window.document,e.identity.surfaceId).editing,p=d===void 0?()=>void 0:sl(a,d,f),m=d===void 0?()=>void 0:d.subscribe(()=>{p(),p=sl(a,d,f)}),h=e.chords.subscribe(()=>{s(),s=ll(a,e.chords,e.remote,o)});return queueMicrotask(c),()=>{t&&(t=!1,l(),e.window.removeEventListener(`focus`,u),e.window.removeEventListener(`blur`,u),h(),s(),m(),p())}}function il(e,t,n,r,i){return()=>{if(!n())return;let a=ol(e.window.document,e.identity.surfaceId),o=i();(a.editing!==o?.editing||a.surface!==o.surface)&&(r(a),t(()=>e.remote.reportFocus(a)))}}function al(e){return t=>{try{Zc(t(),Be).catch(t=>{Cn(`browser-bridge.host-call`,t),e(t)})}catch(t){Cn(`browser-bridge.host-call`,t),e(t)}}}function ol(e,t){let n=e.activeElement;return ie({editing:!!(n?.matches(`input, textarea, select, [contenteditable='true']`)===!0||n?.closest(`[contenteditable='true']`)),surface:e.hasFocus()?t:null})}function sl(e,t,n){let r=t.get();return e.registerLayer({bindings:r.map((e,t)=>({cmd:`app/${String(t)}`,key:e.key})),commands:r.map((e,t)=>({name:`app/${String(t)}`,run:t=>{let r=t.event.originalEvent;if(r?.defaultPrevented||r?.isComposing||cl(e.key)&&n())return!1;e.run()}})),priority:500})}function cl(e){return!/(?:^|\+)(?:ctrl|control|super|meta|cmd|alt|option|mod)\+/iu.test(e)}function ll(e,t,n,r){let i=t.get();return e.registerLayer({bindings:i.map(e=>({cmd:`reserved/${e.id}`,key:{ctrl:e.ctrlKey,meta:e.altKey,name:Vc(e.key),shift:e.shiftKey,super:e.metaKey}})),commands:i.map(e=>({name:`reserved/${e.id}`,run:t=>{let i=t.event.originalEvent;if(i?.defaultPrevented||i?.isComposing)return!1;r(()=>n.invokeReservedChord(e.id,i?.repeat??!1))}})),priority:1e3})}function ul(e){let t=t=>{if(t.defaultPrevented||t.isComposing)return;let n=pl(t,e.mac);n!==null&&(t.preventDefault(),n===`back`&&!t.repeat&&e.canGoBack()&&e.back())},n=t=>{let n=fl(t.button);if(n===null)return;let r=t.defaultPrevented;t.preventDefault(),t.type===`mouseup`&&n===`back`&&!r&&e.canGoBack()&&e.back()};e.window.addEventListener(`keydown`,t);for(let t of dl)e.window.addEventListener(t,n);return()=>{e.window.removeEventListener(`keydown`,t);for(let t of dl)e.window.removeEventListener(t,n)}}var dl=[`mousedown`,`mouseup`,`auxclick`];function fl(e){return e===3?`back`:e===4?`forward`:null}function pl(e,t){return e.shiftKey||e.ctrlKey?null:t?!e.metaKey||e.altKey?null:e.key===`[`?`back`:e.key===`]`?`forward`:ml(e.target)?null:e.key===`ArrowLeft`?`back`:e.key===`ArrowRight`?`forward`:null:!e.altKey||e.metaKey?null:e.key===`ArrowLeft`?`back`:e.key===`ArrowRight`?`forward`:null}function ml(e){return e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement:!1}function hl(){return!Ke(globalThis.navigator)&&/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)}var gl=e=>crypto.getRandomValues(new Uint8Array(e)),_l=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(409.6*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},vl=(e,t=21)=>_l(e,t|0,gl),yl=`abcdefghijklmnopqrstuvwxyz0123456789`;function bl(e=21){if(e===1/0||e===-1/0)throw RangeError(`nanoid length must be finite`);return vl(yl,e)()}var xl=[];for(let e=0;e<256;++e)xl.push((e+256).toString(16).slice(1));function Sl(e,t=0){return(xl[e[t+0]]+xl[e[t+1]]+xl[e[t+2]]+xl[e[t+3]]+`-`+xl[e[t+4]]+xl[e[t+5]]+`-`+xl[e[t+6]]+xl[e[t+7]]+`-`+xl[e[t+8]]+xl[e[t+9]]+`-`+xl[e[t+10]]+xl[e[t+11]]+xl[e[t+12]]+xl[e[t+13]]+xl[e[t+14]]+xl[e[t+15]]).toLowerCase()}var Cl,wl=new Uint8Array(16);function Tl(){if(!Cl){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);Cl=crypto.getRandomValues.bind(crypto)}return Cl(wl)}var El={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Dl(e,t,n){if(El.randomUUID&&!t&&!e)return El.randomUUID();e||={};let r=e.random??e.rng?.()??Tl();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Sl(r)}var Ol=te({version:`v7`}),kl=K().regex(/^replay_[a-f0-9]{64}$/);y(e=>kl.safeParse(e).success);var Al=te({version:`v4`});y(e=>Ol.safeParse(e).success);var jl=y(e=>Al.safeParse(e).success);function Ml(){return jl.parse(Dl())}var Nl=class extends mt{#e=!0;#t;#n=new Map;constructor(e){super(),this.#t=e}cancel(e){try{return this.#n.get(_(e))?.abort(),Promise.resolve(Yc(void 0))}catch(e){return Promise.resolve(Xc(e))}}dispose(){if(this.#e){this.#e=!1;for(let e of this.#n.values())e.abort();this.#n.clear()}}async invoke(e){try{if(!this.#e)throw new u(`The command is disposed`,{code:`DISCONNECTED`,retryable:!0});let t=p(e);if(this.#n.has(t.requestId))throw new u(`Duplicate command request`,{code:`PROTOCOL`,retryable:!1});if(this.#n.size>=64)throw new u(`Too many command requests`,{code:`HOST_FAILURE`,retryable:!0});let n=new AbortController;this.#n.set(t.requestId,n);try{let e=await this.#t(Je(t,n.signal)),r=oe(e);return Yc(r===void 0?{status:`handled`}:{status:`handled`,result:r})}finally{this.#n.delete(t.requestId)}}catch(e){if(e instanceof di)try{let t={code:e.code,message:e.message,details:e.details};return Yc({status:`failed`,error:Jt(t)})}catch(e){return Xc(e)}return Xc(e)}}[Symbol.dispose](){this.dispose()}};function Pl(e){let t=[];for(let n of e.values()){let{commandId:e,definition:r,target:i}=n;if(e===void 0)continue;let a=r.availability?.status!==`unavailable`;for(let n of r.projections?.bindings?.values??[])n.trim().includes(` `)||n.startsWith(`<`)||t.push({key:n,run:()=>{a&&Promise.resolve().then(async()=>{let t=Qc(await i.invoke({commandId:e,origin:`keyboard`,requestId:Ml()}));if(t.status===`failed`)throw new di(t.error.code,t.error.message,t.error.details)}).catch(e=>{console.warn(`App key command failed`,e)})}})}return t}function Fl(e,t,n,r){let i=new Map,a=!1,o=()=>{r?.update(a?[]:Pl(i))},s=e=>{try{n()}catch(t){console.warn(`App command failure callback failed`,t,e)}},c=e=>{try{Zc(e(),Be).catch(e=>{s(e)})}catch(e){console.warn(`App command RPC supervision failed`,e),s(e)}};return{commands:Ll(e,t,i,()=>a,t=>{let n=i.get(t);if(!n)return;i.delete(t),n.target.dispose(),o();let r=n.commandId;!a&&r!==void 0&&c(()=>e.unregisterCommand(r))},o),dispose(){if(!a){a=!0;for(let e of i.values())e.target[Symbol.dispose]();i.clear(),o()}}}}function Il(e,t,n){let r=t.id;if(e.size>=128||e.has(r))throw n.dispose(),new u(`Command registration is unavailable`,{code:`INVALID_ARGUMENT`,retryable:!1});let i={commandId:void 0,definition:t,target:n};e.set(r,i);let a=!1;return{commit(e){a||(i.commandId=e)},release(){a||(a=!0,e.get(r)===i&&e.delete(r),n.dispose())},target:n}}function Ll(e,t,n,r,i,a){return Object.freeze({async register(o,s){if(t(),!kt(s))throw new u(`Command handler must be a function`,{code:`INVALID_ARGUMENT`,retryable:!1});let c=ye(o),l=new Nl(s),d=Il(n,c,l);try{let t=await Rl(e,c,d.target);r()&&await zl(e,t.commandId,l),d.commit(t.commandId),a()}catch(e){throw d.release(),e}let f=!0;return()=>{f&&(f=!1,i(c.id))}}})}async function Rl(e,t,n){return Zc(e.registerCommand(t,n),Se)}async function zl(e,t,n){throw n.dispose(),await Zc(e.unregisterCommand(t),Be),new u(`The command controller is disposed`,{code:`DISCONNECTED`,retryable:!0})}var Bl=Qe(e=>e instanceof Gt),Vl=class extends mt{#e=!1;#t;constructor(e){super(),this.#t=e}disconnect(e){try{if(this.#e)throw Ql();let t=e===void 0?void 0:ht(e);return setTimeout(()=>this.#t.disconnect?.(t??nu()),0),Promise.resolve(Yc(void 0))}catch(e){return Promise.resolve(Xc(e))}}async requestClose(){try{if(this.#e)throw Ql();return Yc(await(this.#t.beforeClose?.()??!0))}catch(e){return Xc(e)}}async requestBack(){try{if(this.#e)throw Ql();return Yc(await(this.#t.back?.()??!1))}catch(e){return Xc(e)}}async activateNavigation(e){try{if(this.#e)throw Ql();let t=pe(e);return it(this.#t.navigation,t)?Yc(await(this.#t.activate?.(t)??!1)):Yc(!1)}catch(e){return Xc(e)}}async activateStatus(e){try{if(this.#e)throw Ql();let t=Rt(e);return Xt(this.#t.statusItems,t)?Yc(await(this.#t.statusAction?.(t)??!1)):Yc(!1)}catch(e){return Xc(e)}}[Symbol.dispose](){this.#e=!0}async updateContext(e){return this.#e?Xc(Ql()):this.#n(e,`context`,i,e=>{this.#t.context.update(e)})}reconfigure(e){let t=[];try{if(this.#e)throw Ql();let n=le(e);if(n.context.version<=this.#t.versions.context)return Promise.resolve(Yc(void 0));for(let e of n.capabilities)t.push({...e,handle:tt(Bl)(e.handle).dup()});if(!this.#t.capabilities)throw Ql();return this.#t.capabilities.replace(t),t=[],this.#t.versions.context=n.context.version,this.#t.context.update(n.context.value),Promise.resolve(Yc(void 0))}catch(e){for(let e of t)Qt(e.handle);return Promise.resolve(Xc(e))}}updateLifecycle(e){try{if(this.#e)throw Ql();let t=H(A)(e);if(t.version<=this.#t.versions.lifecycle)return Promise.resolve(Yc(void 0));if(!ru(this.#t.lifecycle.get(),t.value))throw new u(`The host sent an invalid lifecycle transition`,{code:`PROTOCOL`,retryable:!1});return this.#t.versions.lifecycle=t.version,this.#t.lifecycle.update(t.value),Promise.resolve(Yc(void 0))}catch(e){return Promise.resolve(Xc(e))}}async updateReservedChords(e){return this.#e?Xc(Ql()):this.#n(e,`chords`,ke,e=>{this.#t.chords.update(e)})}async updateTheme(e){return this.#e?Xc(Ql()):this.#n(e,`theme`,Ie,e=>{this.#t.theme.update(e)})}#n(e,t,n,r){try{let i=H(n)(e);return i.version>this.#t.versions[t]&&(this.#t.versions[t]=i.version,r(i.value)),Promise.resolve(Yc(void 0))}catch(e){return Promise.resolve(Xc(e))}}};async function Hl(e){let t=Kl(),n=new Vl(t),r=qe(e.port,n),i,a=Gl(r);try{performance.mark(`fungi.app-open.agar-rpc-connect-start`);let o=await Promise.race([r.connect({epoch:e.epoch,protocolVersion:2}),a]);performance.mark(`fungi.app-open.agar-rpc-connect-ready`),i=o;let s=Qc(_e(o));if(!e.isActive())throw Wl();let c=ql({bootstrap:s,bootstrapOwner:i,options:e,remote:r,state:t,target:n});return performance.mark(`fungi.app-open.agar-root-created`),i=void 0,c}catch(t){return au(t,e,n,r,i)}}function Ul(e,t){e.context.update(t.context.value),e.theme.update(t.theme.value),e.lifecycle.update(t.lifecycle.value),e.chords.update(t.chords.value),e.versions.context=t.context.version,e.versions.theme=t.theme.version,e.versions.lifecycle=t.lifecycle.version,e.versions.chords=t.chords.version}function Wl(){return new u(`App connection was cancelled`,{code:`CANCELLED`,retryable:!1})}function Gl(e){let t,n=new Promise((e,n)=>{t=n});return n.catch(e=>{Cn(`app-session.rpc-disconnect`,e)}),e.onRpcBroken(()=>t?.(new u(`The app host disconnected`,{code:`DISCONNECTED`,retryable:!0}))),n}function Kl(){return{statusItems:[],navigation:{canGoBack:!1},bindings:tl(),chords:nl([]),context:sn({computerId:null,focus:{editing:!1,surface:null},openRequest:null,visibility:`hidden`}),lifecycle:sn(`connecting`),theme:sn(`default`),canGoBack:!1,versions:{chords:-1,context:-1,lifecycle:-1,theme:-1}}}function ql(e){let t=b(e.bootstrap.identity),n=iu(e.bootstrap);Ul(e.state,n);let r=He(e.bootstrap.capabilities);return e.state.capabilities=r,Yl(e,t,r)}function Jl(e,t,n){return rl({bindings:e.state.bindings,chords:e.state.chords,identity:t,onBroken:e=>{n({code:`DISCONNECTED`,message:e instanceof u?e.message:`The app host rejected a browser bridge operation`,retryable:!0})},remote:e.remote,window:e.options.window})}function Yl(e,t,n){let r=!1,i=t=>{r||(r=!0,eu([()=>{t&&e.state.lifecycle.update(`disconnected`)},()=>{e.state.lifecycle.update(`disposing`)},l,d,()=>{o.dispose()},()=>{e.state.beforeClose=void 0,e.state.back=void 0,e.state.activate=void 0,e.state.statusAction=void 0},()=>{n.disconnect()},()=>{e.target[Symbol.dispose]()},()=>{Qt(e.bootstrapOwner)},()=>{Qt(e.remote)},()=>{e.options.port.close()},()=>{e.state.lifecycle.update(`disposed`)},e.options.onDisposed],`app connection disposal`))},a=()=>{if(r)throw new u(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0})},o=Fl(e.remote,a,()=>{i({code:`DISCONNECTED`,message:`The app host rejected a terminal command operation`,retryable:!0})},e.state.bindings),s=Zl(e.remote,a,e.state),c=Xl(e.state,e.remote,a),l=Jl(e,t,i),d=ul({window:e.options.window,mac:hl(),canGoBack:()=>e.state.canGoBack&&e.state.back!==void 0,back:()=>{let t=e.state.back;t&&Promise.resolve().then(t).catch(e=>{Cn(`app-window.back-input`,e)})}});return e.state.disconnect=i,e.remote.onRpcBroken(()=>{$l(i)}),tu({capabilities:n.directory,commands:o.commands,context:e.state.context,dispose:i,identity:t,lifecycle:e.state.lifecycle,theme:e.state.theme,ui:s,window:c})}function Xl(e,t,n){let r=Object.freeze({async publish(r){n();let i=c(r);e.canGoBack=i.canGoBack,e.navigation=un(i),await Zc(t.reportNavigation(i),Be)},onActivate(t){if(n(),e.activate!==void 0)throw new u(`The App already owns navigation activations`,{code:`INVALID_ARGUMENT`,retryable:!1});e.activate=t;let r=!1;return()=>{r||(r=!0,e.activate===t&&(e.activate=void 0))}},onBack(t){if(n(),e.back!==void 0)throw new u(`The App already owns Back requests`,{code:`INVALID_ARGUMENT`,retryable:!1});e.back=t;let r=!1;return()=>{r||(r=!0,e.back===t&&(e.back=void 0))}}});return Object.freeze({navigation:r,onBeforeClose(t){if(n(),e.beforeClose!==void 0)throw new u(`The App already owns a close consultation`,{code:`INVALID_ARGUMENT`,retryable:!1});e.beforeClose=t;let r=!1;return()=>{r||(r=!0,e.beforeClose===t&&(e.beforeClose=void 0))}}})}function Zl(e,t,n){return Object.freeze({async requestComputerChoice(){t(),await Zc(e.requestComputerChoice(),Be)},async requestBrowserAction(n){t();let r=d(n);return r.kind===`refused`?r:await Zc(e.requestBrowserAction(r),tn)},onStatusAction(e){if(t(),n.statusAction!==void 0)throw new u(`The App already owns its status actions`,{code:`INVALID_ARGUMENT`,retryable:!1});n.statusAction=e;let r=!1;return()=>{r||(r=!0,n.statusAction===e&&(n.statusAction=void 0))}},async requestAppPermissions(n){return t(),await Zc(e.requestAppPermissions(D(n)),Ee)},async openDesktopSettings(){t(),await Zc(e.openDesktopSettings(),Be)},async openSetup(n){return t(),await Zc(e.openSetup(C(n)),L)},async openTeamBilling(){t(),await Zc(e.openTeamBilling(),Be)},async openNavigation(n){t(),await Zc(e.openNavigation(ee(n)),Be)},async reportStatus(r){t();let i=N(r);n.statusItems=i,await Zc(e.reportStatus(i),Be)},async reportAgentSessionSelection(n){t(),await Zc(e.reportAgentSessionSelection(an(n)),Be)},async showToast(n){t(),await Zc(e.showToast(Ne(n)),Be)}})}function Ql(){return new u(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0})}function $l(e){e({code:`DISCONNECTED`,message:`The app host disconnected`,retryable:!0})}function eu(e,t){for(let n of e)try{n()}catch(e){console.warn(`${t} cleanup failed`,e)}}function tu(e){return Object.freeze(e)}function nu(){return{code:`DISCONNECTED`,message:`The app host disconnected`,retryable:!1}}function ru(e,t){return e===t||e===`connected`&&t===`suspended`||e===`suspended`&&t===`connected`}function iu(e){let t=H(i)(e.context),n=H(Ie)(e.theme),r=H(A)(e.lifecycle),a=H(ke)(e.reservedChords);if(r.value!==`connected`&&r.value!==`suspended`)throw new u(`The bootstrap lifecycle is invalid`,{code:`PROTOCOL`,retryable:!1});return{chords:a,context:t,lifecycle:r,theme:n}}function au(e,t,n,r,i){throw eu([()=>{n[Symbol.dispose]()},()=>{i&&Qt(i)},()=>{Qt(r)},()=>{t.port.close()},t.onDisposed],`app connection rejection`),e instanceof u?e:new u(`Unable to establish the app RPC session`,{cause:e,code:`PROTOCOL`,retryable:!1})}var ou=!1,su=class{options;#e;#t;#n=!1;#r;#i;constructor(e){this.options=e,this.#e=globalThis.window}start(){performance.mark(`fungi.app-open.agar-connect-start`);let e=this.#l();return e?Promise.reject(e):(ou=!0,this.#a())}#a(){return new Promise((e,t)=>{let r=(n,r)=>{this.#o(n,r,a,i,e,t)},i=()=>{r(lu())},a=e=>{this.#s(e,r,a)};this.#e.addEventListener(`message`,a),this.options.signal?.addEventListener(`abort`,i,{once:!0});let o=()=>{try{performance.mark(`fungi.app-open.agar-ready-sent`),this.#e.parent.postMessage({protocolVersion:2,type:n},`*`)}catch(e){Cn(`connect.notify-host`,e),r(hu(e))}};this.#r=setInterval(o,200),this.#i=setTimeout(()=>{r(du())},1e4),o()})}#o(e,t,n,r,i,a){if(!this.#n){if(this.#n=!0,this.#c(),this.#e.removeEventListener(`message`,n),this.options.signal?.removeEventListener(`abort`,r),e||!t){this.#t?.close(),ou=!1,a(e??du());return}i(t)}}#s(e,t,n){if(!mu(e.data))return;if(performance.mark(`fungi.app-open.agar-connect-received`),e.source!==this.#e.parent||fu(e.origin)===void 0){t(pu());return}let r=gu(e,t);if(!r)return;let i=e.ports.length===1?e.ports[0]:void 0;if(!i){t(_u(`The app host did not transfer exactly one port`));return}this.#t=i,this.#c(),this.#e.removeEventListener(`message`,n),Hl({epoch:r.epoch,isActive:()=>!this.#n,onDisposed:()=>{ou=!1},port:i,window:this.#e}).then(e=>{performance.mark(`fungi.app-open.agar-root-ready`),t(void 0,e)},e=>{t(uu(e))})}#c(){clearInterval(this.#r),clearTimeout(this.#i),this.#r=void 0,this.#i=void 0}#l(){if(this.options.signal?.aborted)return lu();if(ou)return new u(`An app connection is already live`,{code:`IDENTITY`,retryable:!1});if(Ke(globalThis.window)||this.#e.parent===this.#e)return new u(`The app host is unavailable`,{code:`DISCONNECTED`,retryable:!0})}};function cu(e){return new su(e).start()}function lu(){return new u(`App connection was cancelled`,{code:`CANCELLED`,retryable:!1})}function uu(e){return e instanceof u?e:new u(`Unable to connect to the app host`,{cause:e,code:`PROTOCOL`,retryable:!1})}function du(){return new u(`The app host disconnected`,{code:`DISCONNECTED`,retryable:!0})}function fu(e){if(!URL.canParse(e))return;let t=new URL(e).origin;return t===e?t:void 0}function pu(){return new u(`The app connection identity is invalid`,{code:`IDENTITY`,retryable:!1})}var mu=Tt(Yt({type:Vt(de)}));function hu(e){return new u(`Unable to notify the app host`,{cause:e,code:`DISCONNECTED`,retryable:!0})}function gu(e,t){try{return vt(e.data)}catch(e){Cn(`connect.decode-message`,e),t(e instanceof u?e:new u(`Malformed app connection`,{cause:e,code:`PROTOCOL`,retryable:!1}));return}}function _u(e){return new u(e,{code:`PROTOCOL`,retryable:!1})}function vu(e,t,n){e.style.isolation=`isolate`;let r=(0,Ea.createRoot)(e),i=new AbortController,a=e.ownerDocument.documentElement,o=pa(a),s,c,l,d=!1,f=e=>{let i=(0,Y.createElement)(yu,{state:e,render:n});r.render(t.queryClient?(0,Y.createElement)(ne,{client:t.queryClient},i):i)},p=()=>{l?.(),l=void 0,c?.(),c=void 0;let e=s;s=void 0,e?.dispose(),d&&=(o===null?a.removeAttribute(`data-theme`):fa(o,a),!1)},{defaultView:m}=e.ownerDocument;return performance.mark(`fungi.app-open.react-root-render-start`),m?m.parent===m?f({app:null,status:`standalone`}):(f({app:null,status:`connecting`}),cu({host:`parent`,signal:i.signal}).then(e=>{if(i.signal.aborted){e.dispose();return}s=e;let t=()=>{let t=e.lifecycle.get();return t===`disposing`||t===`disconnected`||t===`disposed`?(p(),f({app:null,status:`ended`}),!0):!1};l=e.lifecycle.subscribe(t),!t()&&(d=!0,fa(e.theme.get(),a),c=e.theme.subscribe(e=>{fa(e,a)}),f({app:e,status:`live`}))}).catch(e=>{i.signal.aborted&&e instanceof u&&e.code===`CANCELLED`||(console.error(`${t.name} host connection failed`,e),p(),i.signal.aborted||f({app:null,status:`not-hosted`,error:e instanceof u?e:new u(`The App host is unavailable`,{cause:e,code:`HOST_FAILURE`,retryable:!0})}))})):f({app:null,status:`not-hosted`,error:new u(`The App document has no window`,{code:`DISCONNECTED`,retryable:!1})}),()=>{i.signal.aborted||(i.abort(),r.unmount(),p())}}function yu({state:e,render:t}){return(0,Y.useLayoutEffect)(()=>{performance.mark(`fungi.app-open.react-initial-commit`)},[]),(0,Y.useLayoutEffect)(()=>{e.app&&performance.mark(`fungi.app-open.react-connected-commit`)},[e.app]),(0,Y.createElement)(Y.Fragment,null,e.status===`not-hosted`?(0,Y.createElement)(`p`,{role:`alert`},`App host connection unavailable. Open this App through its host to try again.`):null,t(e))}function bu(e){let t=(0,Y.useCallback)(t=>e?.subscribe(t)??(()=>void 0),[e]),n=(0,Y.useCallback)(()=>e?.get(),[e]);return(0,Y.useSyncExternalStore)(t,n,n)}function xu(e){return bu(e?.context)??null}function Su(e){return xu(e)?.computerId??null}function Cu(e,t,n,r){let i=(0,Y.useRef)(t);i.current=t;let a=(0,Y.useRef)(n);a.current=n;let o=(0,Y.useRef)(r);o.current=r;let s=JSON.stringify(t),c=n!==void 0;(0,Y.useEffect)(()=>{e&&e.ui.reportStatus(i.current).catch(e=>{o.current?o.current(e):console.error(`Window status report failed`,e)})},[e,s]),(0,Y.useEffect)(()=>{if(!(!e||!c))return e.ui.onStatusAction(e=>a.current?.(e)??!1)},[e,c]),(0,Y.useEffect)(()=>()=>{e?.ui.reportStatus([]).catch(e=>{console.error(`Window status report failed`,e)})},[e])}function wu(e,{sourceId:t,namespace:n},r){let i=(0,Y.useMemo)(()=>pi(),[]),a=(0,Y.useMemo)(r,[r]);return(0,Y.useEffect)(()=>{let e=i.contribute({sourceId:t,namespace:n,commands:a});return()=>{e.dispose()}},[i,t,n,a]),(0,Y.useEffect)(()=>e?ca(e.commands,a):void 0,[e,a]),i}var Tu=Re(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);De.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>O(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>je(e,t,n),e.parseAsync=async(t,n)=>we(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>T(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>z(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Eu=Re(`ZodMiniObject`,(e,t)=>{l.init(e,t),Tu.init(e,t),Bt(e,`shape`,()=>t.shape)});function Du(e,t){return new Eu({type:`object`,shape:e??{},...F(t)})}var Ou=Re(`ZodMiniLiteral`,(e,t)=>{fn.init(e,t),Tu.init(e,t)});function ku(e,t){return new Ou({type:`literal`,values:Array.isArray(e)?e:[e],...F(t)})}var Au=q({png:`png`,jpeg:`jpeg`,webp:`webp`}),ju=q({draft:`draft`,balanced:`balanced`,premium:`premium`,max:`max`}),Mu=ce(()=>G({transport:q({json:`json`,multipart:`multipart`}),dimensions:q({none:`none`,own:`own`}),maxDimension:o().int().positive().nullable(),maxDimensionDocumented:xe(),defaultWidth:o().int().positive(),defaultHeight:o().int().positive(),steps:q({steps:`steps`,num_steps:`num_steps`,fixed:`fixed`}),maxSteps:o().int().positive().nullable(),defaultSteps:o().int().nonnegative().nullable(),referenceField:K().min(1).max(256).nullable(),maxReferences:o().int().nonnegative()}).readonly()),Nu=q({seedance:`bytedance/seedance-2.0`,seedanceFast:`bytedance/seedance-2.0-fast`,seedanceMini:`bytedance/seedance-2.0-mini`,veo:`google/veo-3.1`,veoFast:`google/veo-3.1-fast`,minimaxH3Max:`minimax/h3-max`}),Pu=q({p480:`480p`,p720:`720p`,p768:`768p`,p1080:`1080p`,p4k:`4k`}),Fu=q({wide:`16:9`,landscape:`4:3`,square:`1:1`,portrait:`3:4`,tall:`9:16`,ultrawide:`21:9`,ultratall:`9:21`}),Iu=q({first:`first-frame`,last:`last-frame`,reference:`reference`}),Lu=ce(()=>G({resolution:Pu,aspectRatio:Fu,width:o().int().positive(),height:o().int().positive()}).readonly()),Ru=ce(()=>G({minSeconds:o().int().positive(),maxSeconds:o().int().positive(),defaultSeconds:o().int().positive(),durations:rn(o().int().positive()).readonly(),provider:q({seedance:`seedance`,veo:`veo`,minimax:`minimax`}),formats:rn(Lu).readonly(),defaultResolution:Pu,defaultAspectRatio:Fu,supportsAudio:xe(),defaultGenerateAudio:xe().nullable(),referenceRoles:rn(Iu).readonly(),maxReferenceImages:o().int().nonnegative(),referenceResolutions:rn(Pu).readonly(),prices:rn(G({resolution:Pu,silentMilliunitsPerSecond:o().int().positive(),audioMilliunitsPerSecond:o().int().positive()}).readonly()).readonly()}).readonly()),zu=32e3,Bu=2048;G({id:K().min(1).max(256),label:K().min(1).max(512),kind:q({image:`image`,video:`video`}),tier:ju,outputFormats:rn(Au).max(3).readonly(),maxPromptLength:o().int().positive().max(zu),input:Mu,sizes:rn(K().regex(/^\d+x\d+$/u)).readonly().nullable(),video:Ru.nullable()}).readonly();var Vu=e=>Object.freeze({kind:`image`,sizes:null,video:null,outputFormats:Object.freeze([]),...e,input:Object.freeze(e.input)}),Hu={"480p":480,"720p":720,"768p":768,"1080p":1080,"4k":2160},Uu={"16:9":[16,9],"4:3":[4,3],"1:1":[1,1],"3:4":[3,4],"9:16":[9,16],"21:9":[21,9],"9:21":[9,21]};function Wu(e,t,n,r,i){let a=r===`seedance`,o=a?Fu.options:[Fu.enum.wide,Fu.enum.tall,Fu.enum.square],s=Object.freeze(i.flatMap(([e])=>o.map(t=>{let[n,r]=Uu[t],i=Hu[e],a=Math.min(n,r);return Object.freeze({resolution:e,aspectRatio:t,width:Math.ceil(i*n/a/2)*2,height:Math.ceil(i*r/a/2)*2})}))),c=Object.freeze(a?[4,5,6,7,8,9,10,11,12]:[4,6,8]),l=Object.freeze({minSeconds:4,maxSeconds:a?12:8,defaultSeconds:a?5:6,durations:c,provider:r,formats:s,defaultResolution:`720p`,defaultAspectRatio:`16:9`,supportsAudio:!0,defaultGenerateAudio:!a||null,referenceRoles:Object.freeze(a?Iu.options:[Iu.enum.first]),maxReferenceImages:a?4:0,referenceResolutions:Object.freeze(a?i.map(([e])=>e).filter(e=>e!==`1080p`):[]),prices:Object.freeze(i.map(([e,t,n])=>Object.freeze({resolution:e,silentMilliunitsPerSecond:t,audioMilliunitsPerSecond:n})))});return Vu({id:e,label:t,tier:n,maxPromptLength:a?2e3:Bu,kind:`video`,video:l,sizes:Object.freeze(s.map(({width:e,height:t})=>`${String(e)}x${String(t)}`)),input:{transport:`json`,dimensions:`own`,maxDimension:Math.max(...s.map(({width:e,height:t})=>Math.max(e,t))),maxDimensionDocumented:!1,defaultWidth:1280,defaultHeight:720,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:a?`image`:`image_input`,maxReferences:a?4:1}})}function Gu(){let e=[`480p`,`768p`],t=[Fu.enum.wide,Fu.enum.landscape,Fu.enum.square,Fu.enum.portrait,Fu.enum.tall,Fu.enum.ultrawide],n=Object.freeze(e.flatMap(e=>t.map(t=>{let[n,r]=Uu[t],i=Hu[e],a=Math.min(n,r);return Object.freeze({resolution:e,aspectRatio:t,width:Math.ceil(i*n/a/2)*2,height:Math.ceil(i*r/a/2)*2})}))),r=Pu.enum.p768,i=Fu.enum.wide,a=n.find(e=>e.resolution===r&&e.aspectRatio===i);if(a===void 0)throw Error(`minimax/h3-max is missing its default format`);let o=Object.freeze(Array.from({length:11},(e,t)=>t+5)),s=Object.freeze({minSeconds:5,maxSeconds:15,defaultSeconds:5,durations:o,provider:`minimax`,formats:n,defaultResolution:r,defaultAspectRatio:i,defaultGenerateAudio:null,supportsAudio:!1,referenceRoles:Object.freeze([Iu.enum.first,Iu.enum.reference]),maxReferenceImages:4,referenceResolutions:Object.freeze(e),prices:Object.freeze([{resolution:Pu.enum.p480,silentMilliunitsPerSecond:5e3,audioMilliunitsPerSecond:5e3},{resolution:Pu.enum.p768,silentMilliunitsPerSecond:8e3,audioMilliunitsPerSecond:8e3}])});return Vu({id:Nu.enum.minimaxH3Max,label:`MiniMax H3 Max`,tier:`balanced`,maxPromptLength:7e3,kind:`video`,video:s,sizes:Object.freeze(n.map(({width:e,height:t})=>`${String(e)}x${String(t)}`)),input:{transport:`json`,dimensions:`own`,maxDimension:Math.max(...n.map(({width:e,height:t})=>Math.max(e,t))),maxDimensionDocumented:!1,defaultWidth:a.width,defaultHeight:a.height,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:`image_url`,maxReferences:4}})}Object.freeze([Vu({id:`@cf/black-forest-labs/flux-1-schnell`,maxPromptLength:2048,outputFormats:Object.freeze([`jpeg`]),tier:`draft`,label:`Flux 1 Schnell — cheap/fast sketches`,input:{transport:`json`,dimensions:`none`,maxDimension:null,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`steps`,maxSteps:8,defaultSteps:4,referenceField:null,maxReferences:0}}),Vu({id:`@cf/black-forest-labs/flux-2-klein-4b`,maxPromptLength:Bu,tier:`balanced`,label:`Flux 2 Klein 4b — balanced default`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`fixed`,maxSteps:null,defaultSteps:4,referenceField:`input_image_`,maxReferences:4}}),Vu({id:`@cf/black-forest-labs/flux-2-klein-9b`,maxPromptLength:Bu,tier:`premium`,label:`Flux 2 Klein 9b — higher quality flux-2`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`fixed`,maxSteps:null,defaultSteps:4,referenceField:`input_image_`,maxReferences:4}}),Vu({id:`@cf/black-forest-labs/flux-2-dev`,maxPromptLength:Bu,tier:`max`,label:`Flux 2 Dev — best detailed quality, expensive`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`steps`,maxSteps:null,defaultSteps:20,referenceField:`input_image_`,maxReferences:4}}),Vu({id:`@cf/leonardo/lucid-origin`,maxPromptLength:Bu,tier:`premium`,label:`Leonardo Lucid Origin — premium prompt adherence`,input:{transport:`json`,dimensions:`own`,maxDimension:2500,maxDimensionDocumented:!0,defaultWidth:1120,defaultHeight:1120,steps:`num_steps`,maxSteps:40,defaultSteps:null,referenceField:null,maxReferences:0}}),Vu({id:`@cf/leonardo/phoenix-1.0`,maxPromptLength:Bu,tier:`balanced`,label:`Leonardo Phoenix 1.0 — best prompt adherence`,input:{transport:`json`,dimensions:`own`,maxDimension:2048,maxDimensionDocumented:!0,defaultWidth:1024,defaultHeight:1024,steps:`num_steps`,maxSteps:50,defaultSteps:25,referenceField:null,maxReferences:0}}),Vu({id:`openai/gpt-image-2`,maxPromptLength:32e3,outputFormats:Object.freeze([`png`,`jpeg`,`webp`]),tier:`premium`,label:`GPT Image 2 — strong text and layout, premium`,sizes:Object.freeze([`1024x1024`,`1024x1536`,`1536x1024`]),input:{transport:`json`,dimensions:`own`,maxDimension:1536,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:1024,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:`images`,maxReferences:16}}),Wu(Nu.enum.seedance,`Seedance 2.0`,`balanced`,`seedance`,[[`480p`,7e3,7e3],[`720p`,15e3,15e3],[`1080p`,37e3,37e3],[`4k`,78e3,78e3]]),Wu(Nu.enum.seedanceFast,`Seedance 2.0 Fast`,`draft`,`seedance`,[[`480p`,6e3,6e3],[`720p`,12e3,12e3]]),Wu(Nu.enum.seedanceMini,`Seedance 2.0 Mini`,`draft`,`seedance`,[[`480p`,4e3,4e3],[`720p`,9e3,9e3]]),Wu(Nu.enum.veo,`Veo 3.1`,`premium`,`veo`,[[`720p`,2e4,4e4],[`1080p`,2e4,4e4]]),Wu(Nu.enum.veoFast,`Veo 3.1 Fast`,`balanced`,`veo`,[[`720p`,8e3,1e4],[`1080p`,1e4,12e3]]),Gu()]);var Ku=e=>K().min(1).max(e),qu=o().int().min(-(2**53-1)).max(2**53-1),Ju=qu.positive(),Yu=qu.nonnegative(),Xu=G({printId:Ku(256),computerId:Ku(256),kind:q([`image`,`video`]),prompt:Ku(zu),model:Ku(256),width:Ju.nullable(),height:Ju.nullable(),steps:Yu.nullable(),durationSeconds:Yu.nullable(),format:Ku(32),bytes:Ju,costMilliunits:Yu,actorKind:q([`member`,`agent`]),actorId:Ku(256),derivedFrom:Ku(256).nullable(),createdAt:Yu,source:q([`recorded`,`file`]),schemaVersion:Ju}),Zu=_t({printId:Xu.shape.printId,path:K().startsWith(`/`).min(2).max(4096)});function Qu(e,t){let n=e?.app??null,r=xu(n),i=r?.openRequest,a=r?.computerId,o=i?.kind===`navigate`?i.params.find(e=>e.key===`print`):void 0,s=Xu.shape.printId.safeParse(o?.value),c=s.success?s.data:null,l=i?.kind===`navigate`?i.requestId:null,u=(0,Y.useRef)({app:n,requestId:l,computerId:a});(u.current.app!==n||u.current.requestId!==l)&&(u.current={app:n,requestId:l,computerId:a});let d=u.current.computerId===a,f=Xn({...Ir(n,Zn,Jn.of(n,`prints`,`navigate`,a,l,c),async(e,t)=>{if(!n||!a||!c||!l)throw Error(`No print selected`);let r=await e.call(`openOutput`,JSON.stringify({printId:c,byteLength:1}));if(t.throwIfAborted(),n.context.get().computerId!==a)throw Error(`Computer selection changed`);let i=Zu.parse(r);if(i.printId!==c)throw Error(`Print selection changed`);return{path:i.path,requestId:l,computerId:a}}),enabled:!!(n&&d&&a&&l&&c&&n.capabilities.has(Zn)),retry:!1,staleTime:1/0}),p=(0,Y.useRef)(t);p.current=t;let m=(0,Y.useRef)(void 0);return(0,Y.useEffect)(()=>{let t=f.data;!e||!t||m.current===t||e.app.context.get().computerId!==t.computerId||(m.current=t,p.current(t.path,e,t.computerId))},[e,f.data]),{target:f.data??null,error:f.error}}function $u(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var ed=$u(`https://base-ui.com/production-error`,`Base UI`),td=Y.createContext(void 0);function nd(e){let t=Y.useContext(td);if(!e&&t===void 0)throw Error(ed(27));return t}var rd={};function id(e,t){let n=Y.useRef(rd);return n.current===rd&&(n.current=e(t)),n}function ad(e,t,n,r){let i=id(sd).current;return cd(i,e,t,n,r)&&ud(i,[e,t,n,r]),i.callback}function od(e){let t=id(sd).current;return ld(t,e)&&ud(t,e),t.callback}function sd(){return{callback:null,cleanup:null,refs:[]}}function cd(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function ld(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function ud(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}var dd=18;function fd(e){return dd>=e}function pd(e){if(!Y.isValidElement(e))return null;let t=e,n=t.props;return(fd(19)?n?.ref:t.ref)??null}function md(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function hd(){}var gd=Object.freeze([]),_d=Object.freeze({});function vd(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function yd(e,t){return typeof e==`function`?e(t):e}function bd(e,t){return typeof e==`function`?e(t):e}var xd={};function Sd(e,t,n,r,i){if(!n&&!r&&!i&&!e)return wd(t);let a=wd(e);return t&&(a=Td(a,t)),n&&(a=Td(a,n)),r&&(a=Td(a,r)),i&&(a=Td(a,i)),a}function Cd(e){if(e.length===0)return xd;if(e.length===1)return wd(e[0]);let t=wd(e[0]);for(let n=1;n<e.length;n+=1)t=Td(t,e[n]);return t}function wd(e){return kd(e)?{...e(xd)}:Ed(e)}function Td(e,t){return kd(t)?t(e):Dd(e,t)}function Ed(e){let t={...e};for(let e in t){let n=t[e];Od(e,n)&&(t[e]=jd(n))}return t}function Dd(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=md(e.style,r);break;case`className`:e[n]=Nd(e.className,r);break;default:e[n]=Od(n,r)?Ad(e[n],r):r}}return e}function Od(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function kd(e){return typeof e==`function`}function Ad(e,t){return t?e?(...n)=>{let r=n[0];if(Pd(r)){let i=r;Md(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:jd(t):e}function jd(e){return e&&((...t)=>{let n=t[0];return Pd(n)&&Md(n),e(...t)})}function Md(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Nd(e,t){return t?e?t+` `+e:t:e}function Pd(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Fd(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=zd(r));let i=Id(t,n,r);if(n.enabled===!1)return null;let a=n.state??_d;return Bd(e,r,i,a)}function Id(e,t,n){let{className:r,style:i}=e,{state:a=_d,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?yd(r,a):void 0,d=l?bd(i,a):void 0,f=l?vd(a,c):_d,p=l&&s?Ld(s):void 0,m=l?md(f,p)??{}:_d;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?od([m.ref,pd(n),...o]):ad(m.ref,pd(n),o):ad(null,null)),l?(u!==void 0&&(m.className=Nd(m.className,u)),d!==void 0&&(m.style=md(m.style,d)),m):_d}function Ld(e){return Array.isArray(e)?Cd(e):Sd(void 0,e)}var Rd=Symbol.for(`react.lazy`);function zd(e){if(e?.$$typeof!==Rd)return e;let t=Y.Children.toArray(e)[0];return Y.isValidElement(t)?t:e}function Bd(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Sd(n,t.props);return e.ref=n.ref,Y.cloneElement(t,e)}return Vd(e,n)}function Vd(e,t){return e===`button`?(0,Y.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,Y.createElement)(`img`,{alt:``,...t,key:t.key}):Y.createElement(e,t)}var Hd=`data-starting-style`,Ud=`data-ending-style`,Wd={[Hd]:``},Gd={[Ud]:``},Kd={transitionStatus(e){return e===`starting`?Wd:e===`ending`?Gd:null}},qd=`data-open`,Jd=`data-closed`,Yd=`data-anchor-hidden`,Xd=`data-popup-open`,Zd=`data-pressed`,Qd={[Xd]:``},$d={[Xd]:``,[Zd]:``},ef={[qd]:``},tf={[Jd]:``},nf={[Yd]:``},rf={open(e){return e?Qd:null}},af={open(e){return e?$d:null}},of={open(e){return e?ef:tf},anchorHidden(e){return e?nf:null}},sf={...of,...Kd},cf=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=nd(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Fd(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:sf,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});function lf(){return typeof window<`u`}function uf(e){return pf(e)?(e.nodeName||``).toLowerCase():`#document`}function df(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ff(e){return((pf(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function pf(e){return lf()?e instanceof Node||e instanceof df(e).Node:!1}function mf(e){return lf()?e instanceof Element||e instanceof df(e).Element:!1}function hf(e){return lf()?e instanceof HTMLElement||e instanceof df(e).HTMLElement:!1}function gf(e){return!lf()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof df(e).ShadowRoot}function _f(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Of(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function vf(e){return/^(table|td|th)$/.test(uf(e))}function yf(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var bf=/transform|translate|scale|rotate|perspective|filter/,xf=/paint|layout|strict|content/,Sf=e=>!!e&&e!==`none`,Cf;function wf(e){let t=mf(e)?Of(e):e;return Sf(t.transform)||Sf(t.translate)||Sf(t.scale)||Sf(t.rotate)||Sf(t.perspective)||!Ef()&&(Sf(t.backdropFilter)||Sf(t.filter))||bf.test(t.willChange||``)||xf.test(t.contain||``)}function Tf(e){let t=Af(e);for(;hf(t)&&!Df(t);){if(wf(t))return t;if(yf(t))return null;t=Af(t)}return null}function Ef(){return Cf??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Cf}function Df(e){return/^(html|body|#document)$/.test(uf(e))}function Of(e){return df(e).getComputedStyle(e)}function kf(e){return mf(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Af(e){if(uf(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||gf(e)&&e.host||ff(e);return gf(t)?t.host:t}function jf(e){let t=Af(e);return Df(t)?(e.ownerDocument||e).body:hf(t)&&_f(t)?t:jf(t)}function Mf(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=jf(e),i=r===e.ownerDocument?.body,a=df(r);if(i){let e=Nf(a);return t.concat(a,a.visualViewport||[],_f(r)?r:[],e&&n?Mf(e):[])}return t.concat(r,Mf(r,[],n))}function Nf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var Pf={...Y},Ff=Pf.useInsertionEffect,If=Ff&&Ff!==Pf.useLayoutEffect?Ff:e=>e();function Z(e){let t=id(Lf).current;return t.next=e,If(t.effect),t.trampoline}function Lf(){let e={next:void 0,callback:Rf,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Rf(){}var Q=typeof document<`u`?Y.useLayoutEffect:()=>{},zf=Y.createContext(void 0);function Bf(e=!1){let t=Y.useContext(zf);if(t===void 0&&!e)throw Error(ed(16));return t}function Vf(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:Y.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function Hf(e){return e?.ownerDocument||document}function Uf(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(df(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Wf(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=Y.useRef(null),s=Bf(!0),c=a??s!==void 0,{props:l}=Vf({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=Y.useCallback(()=>{let e=o.current;Gf(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Q(u,[u]),{getButtonProps:Y.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Sd({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Md(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Gf(r),s=!i&&Kf(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Uf(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Uf(r,e)))},onKeyUp(e){if(!t){if(Md(e),a?.(e),e.target===e.currentTarget&&i&&c&&Gf(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Uf(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Z(e=>{o.current=e,u()})}}function Gf(e){return hf(e)&&e.tagName===`BUTTON`}function Kf(e){return hf(e)&&e.tagName===`A`&&!!e.href}function qf(e,t,n,r){let i=!1,a=!1,o=r??_d;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Jf(e,t,n){let r=n??_d;return{reason:e,event:t??new Event(`base-ui`),...r}}var Yf=`none`,Xf=`trigger-press`,Zf=`trigger-hover`,Qf=`trigger-focus`,$f=`outside-press`,ep=`item-press`,tp=`close-press`,np=`focus-out`,rp=`escape-key`,ip=`list-navigation`,ap=`keyboard`,op=`pointer`,sp=`cancel-open`,cp=`sibling-open`,lp=`imperative-action`,up=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=nd(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Wf({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,qf(tp,e.nativeEvent))}return Fd(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function dp(){let[,e]=Y.useState({});return Y.useCallback(()=>{e({})},[])}var fp=0;function pp(e,t=`mui`){let n=Y.useRef(void 0),r=dp(),i=e??n.current;return Y.useEffect(()=>{n.current??(fp+=1,n.current=`${t}-${fp}`,e??r())},[e,t,r]),i}var mp=Pf.useId;function hp(e,t){if(mp!==void 0){let n=mp();return e??(t?`${t}-${n}`:n)}return pp(e,t)}function gp(e){return hp(e,`base-ui`)}var _p=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=nd(),c=gp(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Fd(`p`,e,{ref:t,props:[{id:c},o]})});function vp(e){Y.useEffect(e,gd)}var yp=0,bp=class e{static create(){return new e}currentId=yp;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=yp,t()},e)}isStarted(){return this.currentId!==yp}clear=()=>{this.currentId!==yp&&(clearTimeout(this.currentId),this.currentId=yp)};disposeEffect=()=>this.clear};function xp(){let e=id(bp.create).current;return vp(e.disposeEffect),e}function Sp(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Cp,platform:wp,maxTouchPoints:Tp}=Sp(),Ep=Cp.toLowerCase(),Dp=wp.toLowerCase(),Op=/^i(os$|p)/.test(Dp)||Dp===`macintel`&&Tp>1,kp=`android`,Ap=Dp===kp||Ep.includes(kp),jp=!Op&&Dp.startsWith(`mac`);Dp.startsWith(`win`),!Ap&&/^(linux|chrome os)/.test(Dp);var Mp=jp||Op,Np=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!Np&&Ep.includes(`firefox`),!Np&&Ep.includes(`chrom`);var Pp=Mp,Fp=/jsdom|happydom/.test(Ep);function Ip(e){e.preventDefault(),e.stopPropagation()}function Lp(e){return`nativeEvent`in e}function Rp(e){return e.pointerType===``&&e.isTrusted?!0:Ap&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function zp(e){return Fp?!1:!Ap&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(Ap||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Bp(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Vp(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function Hp(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Up(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&gf(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Wp(e,t){let n=e;for(;n;){if(mf(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(gf(n)?n.host:null)}return null}function Gp(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Kp=`data-base-ui-focusable`,qp=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,Jp=`ArrowLeft`,Yp=`ArrowRight`,Xp=`ArrowUp`,Zp=`ArrowDown`,Qp=`data-trigger-disabled`;function $p(e,t){if(!mf(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(Qp);for(let[,e]of t.entries())if(Up(e,n))return!e.hasAttribute(Qp);return!1}function em(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function tm(e){return e.matches(`html,body`)}function nm(e){return hf(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function rm(e){return Wp(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${qp}`)!=null}function im(e){return e?e.getAttribute(`role`)===`combobox`&&nm(e):!1}function am(e){if(!e||Fp)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function om(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function sm(e,t){return t!=null&&!Bp(t)?0:typeof e==`function`?e():e}function cm(e,t,n){let r=sm(e,n);return typeof r==`number`?r:r?.[t]}function lm(e){return typeof e==`function`?e():e}function um(e,t){return t||e===`click`||e===`mousedown`}function dm(e){return e?.includes(`mouse`)&&e!==`mousedown`}function fm(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function pm(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function mm(e){let t=id(hm,e).current;return t.next=e,Q(t.effect),t}function hm(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var gm=null;globalThis.requestAnimationFrame;var _m=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},vm=class e{static create(){return new e}static request(e){return _m.request(e)}static cancel(e){return _m.cancel(e)}currentId=gm;request(e){this.cancel(),this.currentId=_m.request(()=>{this.currentId=gm,e()})}cancel=()=>{this.currentId!==gm&&(_m.cancel(this.currentId),this.currentId=gm)};disposeEffect=()=>this.cancel};function ym(){let e=id(vm.create).current;return vp(e.disposeEffect),e}var bm={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},xm={...bm,position:`fixed`,margin:0,top:0,left:0};({...bm});var $=pn(),Sm=Y.forwardRef(function(e,t){let[n,r]=Y.useState();Q(()=>{Pp&&Np&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,$.jsx)(`span`,{...e,ref:t,style:xm,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Cm=Math.min,wm=Math.max,Tm=Math.round,Em=Math.floor,Dm=e=>({x:e,y:e}),Om={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function km(e,t,n){return wm(e,Cm(t,n))}function Am(e,t){return typeof e==`function`?e(t):e}function jm(e){return e.split(`-`)[0]}function Mm(e){return e.split(`-`)[1]}function Nm(e){return e===`x`?`y`:`x`}function Pm(e){return e===`y`?`height`:`width`}function Fm(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Im(e){return Nm(Fm(e))}function Lm(e,t,n){n===void 0&&(n=!1);let r=Mm(e),i=Im(e),a=Pm(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Km(o)),[o,Km(o)]}function Rm(e){let t=Km(e);return[zm(e),t,zm(t)]}function zm(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Bm=[`left`,`right`],Vm=[`right`,`left`],Hm=[`top`,`bottom`],Um=[`bottom`,`top`];function Wm(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Vm:Bm:t?Bm:Vm;case`left`:case`right`:return t?Hm:Um;default:return[]}}function Gm(e,t,n,r){let i=Mm(e),a=Wm(jm(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(zm)))),a}function Km(e){let t=jm(e);return Om[t]+e.slice(t.length)}function qm(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Jm(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:qm(e)}function Ym(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Xm(e,t){return t<0||t>=e.length}function Zm(e,t){return eh(e.current,{disabledIndices:t})}function Qm(e,t){return eh(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function $m(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>eh(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:Xm(e,u)?-1:u,wrapped:d}}function eh(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&th(e,a,r));return a}function th(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!rh(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function nh(e){return e.visibility===`hidden`||e.visibility===`collapse`}function rh(e,t=e?Of(e):null){return!e||!e.isConnected||!t||nh(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var ih=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function ah(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return gf(n)?n.host:null}function oh(e){for(let t of Array.from(e.children))if(uf(t)===`summary`)return t;return null}function sh(e,t){let n=oh(t);return!!n&&(e===n||Up(n,e))}function ch(e){let t=e?uf(e):``;return e!=null&&e.matches(ih)&&(t!==`summary`||e.parentElement!=null&&uf(e.parentElement)===`details`&&oh(e.parentElement)===e)&&(t!==`details`||oh(e)==null)&&(t!==`input`||e.type!==`hidden`)}function lh(e){if(!ch(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=ah(t)){let n=t!==e,r=uf(t)===`slot`;if(t.hasAttribute(`inert`)||n&&uf(t)===`details`&&!t.open&&!sh(e,t)||t.hasAttribute(`hidden`)||!r&&!uh(t,n))return!1}return!0}function uh(e,t){let n=Of(e);return t?n.display!==`none`:rh(e,n)}function dh(e){let t=e.tabIndex;if(t<0){let t=uf(e);if(t===`details`||t===`audio`||t===`video`||hf(e)&&e.isContentEditable)return 0}return t}function fh(e){if(uf(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function ph(e,t){let n=fh(e);if(!n)return!0;let r=t.find(e=>{let t=fh(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=fh(e);return t?.name===n.name&&t.form===n.form})===n}function mh(e){if(hf(e)&&uf(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return hf(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function hh(e,t){mh(e).forEach(e=>{ch(e)&&t.push(e),hh(e,t)})}function gh(e,t,n){mh(e).forEach(e=>{hf(e)&&e.matches(t)&&n.push(e),gh(e,t,n)})}function _h(e){return lh(e)&&dh(e)>=0}function vh(e){let t=[];return hh(e,t),t.filter(lh)}function yh(e){let t=vh(e);return t.filter(e=>dh(e)>=0&&ph(e,t))}function bh(e,t){let n=yh(e),r=n.length;if(r===0)return;let i=Hp(Hf(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function xh(e){return bh(Hf(e).body,1)||e}function Sh(e){return bh(Hf(e).body,-1)||e}function Ch(e,t,n){if(!e)return null;let r=[];hh(Hf(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(lh);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!Up(n,o)&&_h(o)&&ph(o,a))return o}return r[i]}function wh(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Up(n,r)}function Th(e){yh(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Eh(e){let t=[];gh(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Dh(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Dh(e,t.id,n)])}function Oh(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function kh(e){return`data-base-ui-${e}`}var Ah=0;function jh(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(Ah);function a(){i&&!i()||e?.focus({preventScroll:n})}if(r)return a(),hd;let o=requestAnimationFrame(a);return Ah=o,()=>{Ah===o&&(cancelAnimationFrame(o),Ah=0)}}var Mh=`data-base-ui-inert`,Nh=new WeakMap,Ph=new WeakSet,Fh=new WeakMap,Ih=0;function Lh(e){return e?gf(e)?e.host:Lh(e.parentNode):null}var Rh=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Lh(t);return e.contains(n)?n:null}).filter(e=>e!=null),zh=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Bh=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{uf(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Vh(e,t,n,{mark:r=!0}){let i=Rh(t,e),a=r?Bh(t,zh(i),new Set(i)):[],o=[],s=[];if(n){let e=Rh(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);Bh(t,zh(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(Nh.get(e)||0)+1;Nh.set(e,r),o.push(e),r===1&&n&&Ph.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(Fh.get(e)||0)+1;Fh.set(e,t),s.push(e),t===1&&e.setAttribute(Mh,``)}),Ih+=1,()=>{o.forEach(e=>{let t=(Nh.get(e)||0)-1;Nh.set(e,t),t||(Ph.has(e)||e.removeAttribute(`aria-hidden`),Ph.delete(e))}),r&&s.forEach(e=>{let t=(Fh.get(e)||0)-1;Fh.set(e,t),t||e.removeAttribute(Mh)}),--Ih,Ih||(Nh=new WeakMap,Ph=new WeakSet,Fh=new WeakMap)}}function Hh(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=Hf(e[0]).body;return Vh(e,i,n,{mark:r})}var Uh={style:{transition:`none`}},Wh=`data-base-ui-click-trigger`,Gh={fallbackAxisSide:`none`},Kh={fallbackAxisSide:`end`},qh={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},Jh=e(Ta(),1),Yh=Y.createContext(null),Xh=()=>Y.useContext(Yh),Zh=kh(`portal`);function Qh(e={}){let{ref:t,container:n,componentProps:r=_d,elementProps:i}=e,a=hp(),o=Xh()?.portalNode,[s,c]=Y.useState(null),[l,u]=Y.useState(null),d=Z(e=>{e!==null&&u(e)}),f=Y.useRef(null);Q(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(pf(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=Fd(`div`,r,{ref:[t,d],props:[{id:a,[Zh]:``},i]}),m=s&&p?Jh.createPortal(p,s):null;return{node:l,nodeId:Y.isValidElement(p)?p.props.id:void 0,subtree:m}}var $h=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=Qh({container:o,ref:t,componentProps:e,elementProps:c}),f=Y.useRef(null),p=Y.useRef(null),m=Y.useRef(null),h=Y.useRef(null),[g,_]=Y.useState(null),v=Y.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;Y.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&wh(e)&&(e.type===`focusin`?v.current&&=(Eh(l),!1):(Th(l),v.current=!0))}return pm(fm(l,`focusin`,e,!0),fm(l,`focusout`,e,!0))},[l,y]),Q(()=>{!l||b!==!0||!v.current||(Eh(l),v.current=!1)},[b,l]);let S=Y.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,$.jsxs)(Y.Fragment,{children:[d,(0,$.jsxs)(Yh.Provider,{value:S,children:[x&&l&&(0,$.jsx)(Sm,{"data-type":`outside`,ref:f,onFocus:e=>{wh(e,l)?m.current?.focus():Sh(g?g.domReference:null)?.focus()}}),x&&l&&(0,$.jsx)(`span`,{role:s,"aria-owns":u,style:qh}),l&&Jh.createPortal(a,l),x&&l&&(0,$.jsx)(Sm,{"data-type":`outside`,ref:p,onFocus:e=>{wh(e,l)?h.current?.focus():(xh(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,qf(`focus-out`,e.nativeEvent)))}})]})]})});function eg(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var tg=class{nodesRef={current:[]};events=eg();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ng=Y.createContext(null),rg=Y.createContext(null),ig=()=>Y.useContext(ng)?.id||null,ag=e=>{let t=Y.useContext(rg);return e??t};function og(e){let t=hp(),n=ag(e),r=ig();return Q(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function sg(e){let{children:t,id:n}=e,r=ig();return(0,$.jsx)(ng.Provider,{value:Y.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function cg(e){let{children:t,externalTree:n}=e,r=id(()=>n??new tg).current;return(0,$.jsx)(rg.Provider,{value:r,children:t})}function lg(e){return e==null?e:`current`in e?e.current:e}function ug(e,t){let n=df(Gp(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(Rp(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var dg=20,fg=[];function pg(){fg=fg.filter(e=>e.deref()?.isConnected)}function mg(e){pg(),e&&uf(e)!==`body`&&(fg.push(new WeakRef(e)),fg.length>dg&&(fg=fg.slice(-20)))}function hg(){return pg(),fg[fg.length-1]?.deref()}function gg(e){return e?_h(e)?e:yh(e)[0]||e:null}function _g(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=vh(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return _h(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function vg(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=Z(()=>b.current.floatingContext?.nodeId),S=i===!1,C=im(_)&&S,w=mm(i),T=mm(a),E=mm(o),D=mm(u),O=mm(g),k=ag(m),A=Xh(),j=Y.useRef(!1),M=Y.useRef(!1),N=Y.useRef(!1),P=Y.useRef(null),F=Y.useRef(``),I=Y.useRef(``),L=Y.useRef(null),R=Y.useRef(null),z=ad(L,p,A?.beforeInsideRef),B=ad(R,A?.afterInsideRef),ee=xp(),V=xp(),te=ym(),ne=A!=null,H=om(v),U=Z((e=H)=>e?yh(e):[]),re=Z(()=>h?.().filter(e=>e!=null)??[]);Y.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&Up(H,Hp(Hf(H)))&&U().length===0&&!C&&Ip(e)}return fm(Hf(H),`keydown`,e)},[r,H,c,C,U]),Y.useEffect(()=>{if(r||!g)return;let e=Hf(H);function t(){N.current=!1}function n(e){let t=Gp(e),n=re(),r=Up(v,t)||Up(_,t)||Up(A?.portalNode,t)||n.some(e=>e===t||Up(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,Wp(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,V.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return pm(fm(e,`pointerdown`,n,!0),fm(e,`pointerup`,t,!0),fm(e,`pointercancel`,t,!0),fm(e,`keydown`,i,!0),t)},[r,v,_,H,g,A,V,re]),Y.useEffect(()=>{if(r||!l)return;let e=Hf(H);function n(){M.current=!0,V.start(0,()=>{M.current=!1})}function i(e){let t=Gp(e);_h(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=Gp(n);c&&r==null&&a!=null&&Up(v,a)&&mg(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=re(),p=r?.hasAttribute(kh(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,lg(f),lg(d)].includes(r),m=!(Up(_,r)||Up(v,r)||Up(r,v)||Up(A?.portalNode,r)||u.some(e=>e===r||Up(e,r))||l.hasMatchingElement(e=>Up(e,r))||p||k&&(Dh(k.nodesRef.current,o).find(e=>Up(e.context?.elements.floating,r)||Up(e.context?.elements.domReference,r))||Oh(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,om(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&H&&_g(H),s&&i!==_&&!rh(a)&&Hp(e)===e.body){if(hf(H)&&(H.focus(),s===`popup`)){te.request(()=>{H.focus()});return}let e=U(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;hf(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!c)&&r&&m&&!M.current&&(C||r!==hg())&&(j.current=!0,t.setOpen(!1,qf(np,n)))})}function o(){N.current||(b.current.insideReactTree=!0,ee.start(0,()=>{b.current.insideReactTree=!1}))}let u=hf(_)?_:null;if(!(!v&&!u))return pm(u&&fm(u,`focusout`,a),u&&fm(u,`pointerdown`,n),v&&fm(v,`focusin`,i),v&&fm(v,`focusout`,a),v&&A&&fm(v,`focusout`,o,!0))},[r,_,v,H,c,k,A,t,l,s,U,C,x,b,ee,V,te,d,f,re]),Y.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${kh(`portal`)}]`)||[]),t=(k?Oh(k.nodesRef.current,x()):[]).find(e=>im(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Hh([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...re(),t,lg(f),lg(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=Hh([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,re]),Q(()=>{if(!g||r||!hf(H))return;F.current=``,I.current=``;let e=Hf(H),t=Hp(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||Up(H,t))return;let i=null,a=()=>(i??=U(H),i[0]||H),o;o=r===!0||r===null?a():lg(r),o||=a();let s=Up(H,Hp(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&Rp(c);jh(o,{sync:l,preventScroll:o===H,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=Hp(e);return!(t!==o&&Up(H,t))}})})},[r,g,H,U,w,D,O,b]);let W=Y.useRef(null);Q(()=>{if(r||!H){W.current=null;return}W.current&&=(W.current.cancelled=!0,null);let e=Hf(H),t=Hp(e),n=D.current==null;mg(t);function i(e){if(e.open||(F.current=ug(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(kh(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Rp(e.nativeEvent)||zp(e.nativeEvent))j.current=!1;else{let e=!1;Hf(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&uf(t)!==`body`?t:null,s=n?o||a:a||o;return s||=hg()||null,typeof i==`boolean`?s:lg(i)||s||null}return()=>{y.off(`openchange`,i);let t=Hp(e),n=re(),r=Up(v,t)||n.some(e=>e===t||Up(e,t))||k&&Dh(k.nodesRef.current,x(),!1).some(e=>Up(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};W.current=l,queueMicrotask(()=>{W.current===l&&(W.current=null);let n=gg(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&hf(n)&&(!(!i&&n!==t&&t!==e.body)||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,H,T,E,D,y,k,_,x,re]),Q(()=>{if(!Np||g||!v)return;let e=Hp(Hf(v));!hf(e)||!nm(e)||Up(v,e)&&e.blur()},[g,v]),Q(()=>{if(!(r||!A))return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),Q(()=>{if(!(r||!H))return _g(H),()=>{queueMicrotask(pg)}},[r,H]);let ie=!r&&(!c||!C)&&(ne||c);return(0,$.jsxs)(Y.Fragment,{children:[ie&&(0,$.jsx)(Sm,{"data-type":`inside`,ref:z,onFocus:e=>{if(c){let e=U();jh(e[e.length-1])}else A?.portalNode&&(j.current=!1,wh(e,A.portalNode)?xh(_)?.focus():lg(f??A.beforeOutsideRef)?.focus())}}),n,ie&&(0,$.jsx)(Sm,{"data-type":`inside`,ref:B,onFocus:e=>{c?jh(U()[0]):A?.portalNode&&(l&&(j.current=!0),wh(e,A.portalNode)?Sh(_)?.focus():lg(d??A.afterOutsideRef)?.focus())}})]})}function yg(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Xf}=t,l=e.context.dataRef,u=Y.useRef(void 0),d=ym(),f=xp(),p=Y.useMemo(()=>{function t(t,n,r,i){let a=qf(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=Bp(e.pointerType,!0)&&zp(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||Bp(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=Gp(s),p=nm(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;if(r===`mousedown`&&o){u.current=void 0;return}Bp(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return Y.useMemo(()=>n?{reference:p}:_d,[n,p])}function bg(){return!1}function xg(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Sg(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=bg,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=ag(c),m=Z(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=Z(()=>a),{escapeKey:v,outsidePress:y}=xg(s),b=Y.useRef(!1),x=Y.useRef(!1),S=Y.useRef(!1),C=Y.useRef(!1),w=Y.useRef(!1),T=Y.useRef(``),E=Y.useRef(null),D=xp(),O=xp(),k=xp(),A=Z(()=>{O.clear(),d.current.insideReactTree=!1}),j=Z(e=>{let t=d.current.floatingContext?.nodeId;return(p?Dh(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Z(t=>em(t,e.select(`floatingElement`))||em(t,e.select(`domReferenceElement`))),N=Z(t=>{o()&&e.setOpen(!1,qf(Xf,t.nativeEvent))}),P=Z(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=Lp(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=qf(rp,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=Z(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=Z(t=>{if(!l||!n||t.button!==0)return;let r=Gp(t.nativeEvent);Up(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=Z(e=>{!l||!n||(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});Y.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),Y.useEffect(()=>A,[A]),Y.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new bp,i=Hf(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Np?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&Dh(p.nodesRef.current,t).some(t=>em(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=Gp(n),i=`[${kh(`inert`)}]`,a=mf(r)?r.getRootNode():null,o=Array.from((gf(a)?a:Hf(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>Up(e,r))))return;let c=mf(r)?r:null;for(;c&&!Df(c);){let e=Af(c);if(Df(e)||!mf(e))break;c=e}if(!(o.length&&mf(r)&&!tm(r)&&!Up(r,e.select(`floatingElement`))&&o.every(e=>!Up(c,e)))){if(hf(r)&&!(`touches`in n)){let e=Df(r),t=Of(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!Rp(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,qf($f,n)),A())}}}function F(t){f()!==`sloppy`||t.pointerType===`touch`||!e.select(`open`)||!n||M(t)||N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=Gp(e);if(!n)return;let r=fm(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function z(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),!(e.type===`mousedown`&&E.current&&!E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function B(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;if(c(),f()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}typeof h==`function`&&!h(e)||(t.clear(),S.current=!0,A())}}}function ee(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function V(e){L(e,ee)}function te(e){f()!==`sloppy`||!E.current||M(e)||(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function ne(e){L(e,te)}let H=pm(r&&pm(fm(i,`keydown`,P),fm(i,`compositionstart`,a),fm(i,`compositionend`,o)),g&&pm(fm(i,`click`,z,!0),fm(i,`pointerdown`,z,!0),fm(i,`pointerup`,B,!0),fm(i,`pointercancel`,B,!0),fm(i,`mousedown`,z,!0),fm(i,`mouseup`,B,!0),fm(i,`touchstart`,R,{capture:!0,passive:!0}),fm(i,`touchmove`,V,{capture:!0,passive:!0}),fm(i,`touchend`,ne,{capture:!0,passive:!0})));return()=>{H(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=Y.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),z=Y.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return Y.useMemo(()=>n?{reference:R,floating:z,trigger:R}:{},[n,R,z])}function Cg(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),Q(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};mf(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function wg(e,t=!1,n=!1,r=!1){let[i,a]=Y.useState(e&&t?`idle`:void 0),[o,s]=Y.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),Q(()=>{if(!e&&o&&i!==`ending`&&n){let e=vm.request(()=>{a(`ending`)});return()=>{vm.cancel(e)}}},[e,o,i,n]),Q(()=>{if(!e||t||i===void 0)return;let n=vm.request(()=>{a(void 0)});return()=>{vm.cancel(n)}},[t,e,i]),Q(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=vm.request(()=>{a(`idle`)});return()=>{vm.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Tg(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var Eg=null;function Dg(e){if(!Eg){let e=[];Eg=e,queueMicrotask(()=>{Eg=null,Jh.flushSync(()=>{for(let t of e)t()})})}Eg.push(e)}function Og(e,t=!1,n=!1){let r=ym();return Z((i,a=null)=>{r.cancel();let o=lg(e);if(o==null)return;let s=o,c=()=>{if(!n){Jh.flushSync(i);return}Dg(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(Tg(s).map(e=>e.finished.then(hd))).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(Tg(s).some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Hd;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function kg(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=Z(a),s=Og(r,n,i);Y.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function Ag(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=Z(i),{mounted:c,setMounted:l,transitionStatus:u}=wg(t,!1,!1,o),d=!t&&r;Q(()=>{t&&s(!1)},[t,s]);let f=Y.useRef(c),p=Y.useRef(!1),m=dp(),h=()=>{f.current=!1,l(!1),a()};Q(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=Z(()=>{if(f.current){if(t){p.current=!0,m();return}h()}});return kg({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var jg={tabIndex:-1,[Kp]:``};function Mg(e){return t=>t!==`touch`||e.current}function Ng(e,t=!1){let n=hp(),r=ig()!=null,i=id(()=>e(n,r)).current;return Cg({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Pg({handle:e,store:t}){return Q(()=>e.attachStore(t),[e,t]),null}function Fg(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Ig(e,t){let n=Y.useRef(null);return Z(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Fg(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Fg(t))})}function Lg(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function Rg(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function zg(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Ig(e,n),o=Z(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Z(e=>{a(e),e&&o(e)});return Q(()=>(s(t.current),()=>s(null)),[s,t,n,e]),Q(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Bg(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Y.useRef(null),i=e.useState(`open`);Q(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=qf(Yf);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Vg(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Ag({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return id(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Hg(e,t){e.useSyncedValues(t),Q(()=>()=>{e.update({activeTriggerProps:_d,inactiveTriggerProps:_d,popupProps:_d})},[e])}function Ug(e,t){Q(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),Q(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Wg=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},Gg=t((e=>{var t=Pe();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Kg=t(((e,t)=>{t.exports=Gg()})),qg=t((e=>{var t=Pe(),n=Kg();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Jg=t(((e,t)=>{t.exports=qg()})),Yg=[],Xg=void 0;function Zg(){return Xg}function Qg(e){Yg.push(e)}function $g(e){let t=(t,n)=>{let r=id(t_).current,i;try{Xg=r;for(let e of Yg)e.before(r);i=e(t,n);for(let e of Yg)e.after(r);r.didInitialize=!0}finally{Xg=void 0}return i};return t.displayName=e.displayName||e.name,t}function e_(e){return Y.forwardRef($g(e))}function t_(){return{didInitialize:!1}}var n_=Kg(),r_=Jg(),i_=fd(19)?s_:c_;function a_(e,t,n,r,i){return i_(e,t,n,r,i)}function o_(e,t,n,r,i){let a=Y.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,n_.useSyncExternalStore)(e.subscribe,a,a)}Qg({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,n_.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function s_(e,t,n,r,i){let a=Zg();if(!a)return o_(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function c_(e,t,n,r,i){return(0,r_.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var l_=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return a_(this,e,t,n,r)}},u_=class extends l_{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){Y.useDebugValue(e);let n=this;Q(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;Q(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Q(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){Y.useDebugValue(e);let n=this,r=t!==void 0;Q(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return Y.useDebugValue(e),a_(this,this.selectors[e],t,n,r)}useContextCallback(e,t){Y.useDebugValue(e);let n=Z(t??hd);this.context[e]=n}useStateSetter(e){let t=Y.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},d_={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},f_=class extends u_{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:eg(),nested:n,triggerElements:i},d_),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Vp(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function p_(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new f_({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:_d,inactiveTriggerProps:_d,popupProps:_d}}var m_=e=>e.triggerIdProp??e.activeTriggerId,h_=e=>e.openProp??e.open,g_=e=>(e.popupElement?.id??e.floatingId)||void 0;function __(e,t){return t!==void 0&&h_(e)&&m_(e)===t}function v_(e,t){return __(e,t)?!0:t!==void 0&&h_(e)&&m_(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var y_={open:h_,mounted:e=>e.mounted,transitionStatus:e=>h_(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:m_,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:g_,isTriggerActive:(e,t)=>t!==void 0&&m_(e)===t,isOpenedByTrigger:(e,t)=>__(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&m_(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>v_(e,t)?g_(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function b_(e){let t=Y.useCallback(t=>e===void 0?hd:e.subscribeStore(t),[e]),n=Y.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,n_.useSyncExternalStore)(t,n,()=>e?.serverStore)}var x_=jp&&Np;function S_(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Y.useRef(!1),s=Y.useRef(null),c=Y.useRef(!0),l=xp();Y.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=df(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&hf(t)&&t===Hp(Hf(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return pm(fm(r,`blur`,i),x_&&fm(r,`keydown`,a,!0),x_&&fm(r,`pointerdown`,l,!0))},[e,n]),Y.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);mf(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Y.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=Gp(n.nativeEvent);if(mf(a)){if(x_&&!n.relatedTarget){if(!c.current&&!nm(a))return}else if(!am(a))return}let u=$p(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,qf(Qf,d,f));return}l.start(r,()=>{o.current||e.setOpen(!0,qf(Qf,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=mf(r)&&r.hasAttribute(kh(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Hp(Hf(t));!r&&n===t||Up(a.current.floatingContext?.refs.floating.current,n)||Up(t,n)||o||$p(r??n,e.context.triggerElements)||e.setOpen(!1,qf(Qf,i))})}}},[a,r,e,l]);return Y.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var C_=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new bp;restTimeout=new bp;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},w_=new WeakMap;function T_(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&w_.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),w_.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function E_(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=w_.get(n);a&&a!==e&&T_(a),T_(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,w_.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function D_(e){let t=e.context.dataRef.current,n=id(()=>t.hoverInteractionState??C_.create()).current;return t.hoverInteractionState||=n,vp(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function O_(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=ag(),u=ig(),d=D_(e),f=xp(),p=Z(()=>um(c.current.openEvent?.type,d.interactedInside)),m=Z(()=>dm(c.current.openEvent?.type)),h=Z(()=>{T_(d)});Q(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),Y.useEffect(()=>h,[h]),Q(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&mf(s)&&o){let e=s,t=o,n=Hf(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Wp(e,`[data-rootownerid]`)??n.body;return E_(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),Y.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&Dh(l.nodesRef.current,u).length>0)}function a(t){let n=cm(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,qf(Zf,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=Gp(e);if(!rm(t)){d.interactedInside=!1;return}d.interactedInside=Wp(t,`[aria-haspopup]`)!=null}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if($p(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(l&&r&&mf(o)&&Dh(l.nodesRef.current,r,!1).some(e=>Up(e.context?.elements.floating,o)))){if(d.handler){d.handler(n);return}h(),m()&&!p()&&a(n)}}function v(n){!l||!u||t()||f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,qf(Zf,n)),l.events.emit(`floating.closed`,n)})}let y=o;return pm(y&&fm(y,`mouseenter`,g),y&&fm(y,`mouseleave`,_),y&&fm(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var k_={current:null};function A_(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=k_,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=ag(l),v=D_(e),y=Y.useRef(!1),b=mm(i),x=mm(r),S=mm(o),C=mm(n),w=mm(p),T=mm(f),E=Z(()=>um(h.current.openEvent?.type,v.interactedInside)),D=Z(()=>w.current?.()!==!1),O=Z((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!Up(t,n);if(!mf(r))return!1;let a=r;return i.hasMatchingElement(e=>Up(e,a))&&(!t||!Up(t,a))}),k=Z(()=>{v.handler&&=(Hf(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=Z(()=>{T_(v)});return u&&(v.handleCloseOptions=i?.__options),Y.useEffect(()=>k,[k]),Y.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===Zf,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),Y.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=cm(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,qf(Zf,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,qf(Zf,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!mf(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!Bp(v.pointerType))return;let n=lm(S.current),r=cm(x.current,`open`,v.pointerType),i=Gp(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(mf(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(Up(t,i)){c=t;break}}mf(o)&&mf(s)&&!e.context.triggerElements.hasElement(o)&&Up(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&mf(c)&&mf(s)&&Up(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;if(h){D()&&e.setOpen(!0,qf(Zf,t,c));return}m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,qf(Zf,t,c))}):g&&D()&&e.setOpen(!0,qf(Zf,t,c)))}function o(n){if(E()){A();return}k();let r=Hf(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!$p(n.relatedTarget,e.context.triggerElements)){if(b.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=b.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n);return}(v.pointerType!==`touch`||!Up(e.select(`floatingElement`),n.relatedTarget))&&t(n)}}function l(e){Up(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?fm(r,`mouseout`,l):void 0;return s?pm(fm(r,`mousemove`,i,{once:!0}),fm(r,`mouseenter`,i),fm(r,`mouseleave`,o),f):pm(fm(r,`mouseenter`,i),fm(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),Y.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!Bp(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;E_(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=lm(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,qf(Zf,n,r))}v.pointerType===`touch`?Jh.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function j_(e){return Np&&e.movementX===0&&e.movementY===0}function M_(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function N_(e,t){return M_(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function P_(e,t,n){return M_(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function F_(e,t,n){return M_(t,n?e===Jp:e===Yp,e===Zp)}function I_(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:M_(t,n?e===Yp:e===Jp,e===Xp)}function L_(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=om(E),A=im(D),j=mm(k),M=ig(),N=ag(x),P=Y.useRef(f),F=Y.useRef(o??-1),I=Y.useRef(null),L=Y.useRef(!0),R=Z(e=>{i(F.current===-1?null:F.current,e)}),z=Y.useRef(!!E),B=Y.useRef(T),ee=Y.useRef(!1),V=Y.useRef(!1),te=Y.useRef(null),ne=mm(h),H=mm(T),U=mm(o),re=mm(b),W=ym(),ie=ym(),ae=Z(()=>{W.cancel();function e(e){d||(te.current=jh(e,{sync:ee.current,preventScroll:!0}))}let t=n.current[F.current],r=V.current;t&&e(t),(ee.current?e=>e():e=>W.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),ue&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});Q(()=>{O.current.orientation=g},[O,g]),Q(()=>{T||(I.current=null),(!T||f!==`auto`)&&(P.current=f)},[T,f]),Q(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(V.current=!0,R())):z.current&&(F.current=-1,R()))},[a,T,E,o,R]),Q(()=>{if(a){if(!T){ee.current=!1;return}if(E){if(r==null){if(ee.current=!1,U.current!=null)return;if(z.current&&(F.current=-1,ae()),(!B.current||!z.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ie.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||P_(I.current,_,u)||l?Zm(n):Qm(n),I.current=null,R())};t()}}else Xm(n.current,r)||(F.current=r,ae(),V.current=!1)}}},[a,T,E,r,U,l,n,_,u,R,ae,ie]),Q(()=>{if(!a||E||!N||d||!z.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=Hp(Hf(D??t??null)),r=e.some(e=>e.context&&Up(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),Q(()=>{B.current=T,z.current=!!E});let G=r!=null,oe=Z(e=>{if(!H.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),se=Z(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),ce=Z(()=>Zm(n,ne.current)),le=Z(t=>{if(L.current=!1,ee.current=!0,t.which===229||!H.current&&t.currentTarget===j.current)return;if(l&&I_(t.key,g,u,w)){N_(t.key,se())||Ip(t),e.setOpen(!1,qf(ip,t.nativeEvent));let n=S?.current??D;hf(n)&&n.focus();return}r!=null&&r!==F.current&&!Xm(n.current,r)&&(F.current=r);let i=F.current,a=Zm(n,h),o=Qm(n,h);if(A||(t.key===`Home`&&(Ip(t),F.current=a,R(t)),t.key===`End`&&(Ip(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(N_(t.key,g)){Ip(t);let e=Hp(t.currentTarget.ownerDocument);if(T&&!d&&Up(t.currentTarget,e)&&!n.current.some(t=>t!=null&&Up(t,e))){F.current=P_(t.key,g,u)?a:o,R(t),r===F.current&&ae();return}let{index:l,wrapped:f}=$m(n.current,i,{decrement:!P_(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(ee.current=!1),F.current=l,R(t)}}),ue=Y.useMemo(()=>({onFocus(e){ee.current=!0,oe(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){j_(e)||(ee.current=!0,V.current=!1,p&&oe(e))},onPointerLeave(e){if(!H.current||!L.current||e.pointerType===`touch`)return;ee.current=!0;let t=e.relatedTarget;if(!(!p||n.current.includes(t))&&re.current&&(te.current?.(),te.current=null,F.current=-1,R(e),!d)){let e=j.current,t=Hp(Hf(e));e&&Up(e,t)&&e.focus({preventScroll:!0})}}}),[oe,H,j,p,n,R,re,d]),K=Y.useMemo(()=>d&&T&&G&&{"aria-activedescendant":`${y}-${r}`},[d,T,G,y,r]),de=Y.useMemo(()=>({...A?{}:K,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=Gp(t.nativeEvent);if(n&&!Up(j.current,n))return;Ip(t);let r=qf(np,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&hf(i)&&i.focus();return}le(t)},onPointerMove(e){j_(e)||(L.current=!0)}}),[K,le,j,A,e,T,d,D,S]),fe=Y.useMemo(()=>{function t(t){e.setOpen(!0,qf(ip,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&Rp(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&zp(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=F_(n.key,se(),u),o=N_(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||nm(n.currentTarget)))return le(n);if(!(!r&&!m&&i)){if(s){let e=N_(n.key,se());I.current=l&&e?null:n.key}if(l){a&&(Ip(n),r?(F.current=ce(),R(n),d&&j.current?.focus()):t(n));return}o&&(U.current!=null&&(F.current=U.current),Ip(n),!r&&m?t(n):le(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[le,f,ce,l,R,e,m,g,_,se,u,U,d,j]),pe=Y.useMemo(()=>({...K,...fe}),[K,fe]);return Y.useMemo(()=>a?{reference:pe,floating:de,item:ue,trigger:fe}:{},[a,pe,de,fe,ue])}function R_(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=Z(s),f=e.useState(`open`),p=xp(),m=Y.useRef(``),h=Y.useRef(u??i??-1),g=Y.useRef(null),_=Z(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!rh(n)||n?.matches(`:disabled`)?!1:o==null||!th(gd,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!s(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Ip(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Ip(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=Z(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);Up(r,n)||Up(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});Q(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Y.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Y.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var z_=.1,B_=z_*z_,V_=.5;function H_(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function U_(e,t,n,r,i,a,o,s,c,l){let u=!1;return H_(e,t,n,r,i,a)&&(u=!u),H_(e,t,i,a,o,s)&&(u=!u),H_(e,t,o,s,c,l)&&(u=!u),H_(e,t,c,l,n,r)&&(u=!u),u}function W_(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function G_(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function K_(e={}){let{blockPointerEvents:t=!1}=e,n=new bp,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*B_;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Gp(r),g=r.type===`mouseleave`,_=Up(u,h),v=Up(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&mf(r.relatedTarget)&&Up(u,r.relatedTarget))return;function y(){return!!(s&&Dh(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=G_(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=G_(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=G_(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=G_(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!W_(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?V_/2:V_*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+V_+1,o=C||T?S.bottom-V_:S.top,s=C?T?S.bottom-V_:S.top:S.bottom-V_;M=U_(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?V_/2:V_*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-V_,o=C||T?S.top+V_:S.bottom,s=C?T?S.top+V_:S.bottom:S.top+V_;M=U_(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?V_/2:V_*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+V_+1,o=w||E?S.right-V_:S.left,s=w?E?S.right-V_:S.left:S.right-V_;M=U_(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?V_/2:V_*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-V_,o=w||E?S.left+V_:S.right,s=w?E?S.left+V_:S.right:S.left+V_;M=U_(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function q_(e,t,n){let{reference:r,floating:i}=e,a=Fm(t),o=Im(t),s=Pm(o),c=jm(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Mm(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function J_(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Am(t,e),p=Jm(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ym(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ym(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Y_=50,X_=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:J_},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=q_(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Y_&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=q_(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Z_=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Am(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=jm(r),_=Fm(o),v=jm(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Km(o)]:Rm(o)),x=p!==`none`;!d&&x&&b.push(...Gm(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Lm(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Fm(t)||T.every(e=>Fm(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Fm(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},Q_=new Set([`left`,`top`]);async function $_(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=jm(n),s=Mm(n),c=Fm(n)===`y`,l=Q_.has(o)?-1:1,u=a&&c?-1:1,d=Am(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ev=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await $_(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},tv=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Am(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Fm(i),p=Nm(f),m=u[p],h=u[f],g=(e,t)=>km(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},nv=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Am(e,t),u={x:n,y:r},d=Fm(i),f=Nm(d),p=u[f],m=u[d],h=Am(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Q_.has(jm(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},rv=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Am(e,t),c=await i.detectOverflow(t,s),l=jm(n),u=Mm(n),d=Fm(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Cm(p-c[m],g),y=Cm(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*wm(c.left,c.right):S=p-2*wm(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function iv(e){let t=Of(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=hf(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Tm(n)!==a||Tm(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function av(e){return mf(e)?e:e.contextElement}function ov(e){let t=av(e);if(!hf(t))return Dm(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=iv(t),o=(a?Tm(n.width):n.width)/r,s=(a?Tm(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var sv=Dm(0);function cv(e){let t=df(e);return!Ef()||!t.visualViewport?sv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lv(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===df(e)}function uv(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=av(e),o=Dm(1);t&&(r?mf(r)&&(o=ov(r)):o=ov(e));let s=lv(a,n,r)?cv(a):Dm(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=df(a),t=mf(r)?df(r):r,n=e,i=Nf(n);for(;i&&t!==n;){let e=ov(i),t=i.getBoundingClientRect(),r=Of(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=df(i),i=Nf(n)}}return Ym({width:u,height:d,x:c,y:l})}function dv(e,t){let n=kf(e).scrollLeft;return t?t.left+n:uv(ff(e)).left+n}function fv(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-dv(e,n),y:n.top+t.scrollTop}}function pv(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ff(r),s=t?yf(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Dm(1),u=Dm(0),d=hf(r);if((d||!a)&&((uf(r)!==`body`||_f(o))&&(c=kf(r)),d)){let e=uv(r);l=ov(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fv(o,c):Dm(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function mv(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function hv(e){let t=kf(e),n=e.ownerDocument.body,r=wm(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=wm(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+dv(e),o=-t.scrollTop;return Of(n).direction===`rtl`&&(a+=wm(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var gv=25;function _v(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=df(e),a=ff(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Ef()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(dv(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=gv&&(s-=o)}return{width:s,height:c,x:l,y:u}}function vv(e,t){let n=uv(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ov(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function yv(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=_v(e,n,t);else if(t===`document`)r=hv(ff(e));else if(mf(t))r=vv(t,n);else{let n=cv(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ym(r)}function bv(e,t){let n=t.get(e);if(n)return n;let r=Mf(e,[],!1).filter(e=>mf(e)&&uf(e)!==`body`),i=null,a=Of(e).position===`fixed`,o=a?Af(e):e;for(;mf(o)&&!Df(o);){let e=Of(o),t=wf(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Af(o)}return t.set(e,r),r}function xv(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?yf(t)?[]:bv(t,this._c):[].concat(n),r],o=yv(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=yv(t,a[e],i);s=wm(n.top,s),c=Cm(n.right,c),l=Cm(n.bottom,l),u=wm(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Sv(e){let{width:t,height:n}=iv(e);return{width:t,height:n}}function Cv(e,t,n){let r=hf(t),i=ff(t),a=n===`fixed`,o=uv(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Dm(0);if((r||!a)&&((uf(t)!==`body`||_f(i))&&(s=kf(t)),r)){let e=uv(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=dv(i));let l=i&&!r&&!a?fv(i,s):Dm(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function wv(e){return Of(e).position===`static`}function Tv(e,t){if(!hf(e)||Of(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ff(e)===n&&(n=n.ownerDocument.body),n}function Ev(e,t){let n=df(e);if(yf(e))return n;if(!hf(e)){let t=Af(e);for(;t&&!Df(t);){if(mf(t)&&!wv(t))return t;t=Af(t)}return n}let r=Tv(e,t);for(;r&&vf(r)&&wv(r);)r=Tv(r,t);return r&&Df(r)&&wv(r)&&!wf(r)?n:r||Tf(e)||n}var Dv=async function(e){let t=this.getOffsetParent||Ev,n=this.getDimensions,r=await n(e.floating);return{reference:Cv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ov(e){return Of(e).direction===`rtl`}var kv={convertOffsetParentRelativeRectToViewportRelativeRect:pv,getDocumentElement:ff,getClippingRect:xv,getOffsetParent:Ev,getElementRects:Dv,getClientRects:mv,getDimensions:Sv,getScale:ov,isElement:mf,isRTL:Ov};function Av(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jv(e,t,n){let r=null,i,a=ff(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Em(d),h=Em(a.clientWidth-(u+f)),g=Em(a.clientHeight-(d+p)),_=Em(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:wm(0,Cm(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Av(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=df(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Mv(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=av(e),u=i||a?[...l?Mf(l):[],...t?Mf(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?jv(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?uv(e):null;c&&g();function g(){let t=uv(e);h&&!Av(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Nv=ev,Pv=tv,Fv=Z_,Iv=rv,Lv=nv,Rv=(e,t,n)=>{let r=new Map,i=n??{},a={...kv,...i.platform,_c:r};return X_(e,t,{...i,platform:a})},zv=typeof document<`u`?Y.useLayoutEffect:function(){};function Bv(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bv(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Bv(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vv(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hv(e,t){let n=Vv(e);return Math.round(t*n)/n}function Uv(e){let t=Y.useRef(e);return zv(()=>{t.current=e}),t}function Wv(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Y.useState(r);Bv(f,r)||p(r);let[m,h]=Y.useState(null),[g,_]=Y.useState(null),v=Y.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Y.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Y.useRef(null),C=Y.useRef(null),w=Y.useRef(u),T=c!=null,E=Uv(c),D=Uv(i),O=Uv(l),k=Y.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Rv(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Bv(w.current,t)&&(w.current=t,Jh.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);zv(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Y.useRef(!1);zv(()=>(A.current=!0,()=>{A.current=!1}),[]),zv(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Y.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Y.useMemo(()=>({reference:b,floating:x}),[b,x]),N=Y.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Hv(M.floating,u.x),r=Hv(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vv(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Y.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var Gv=(e,t)=>{let n=Nv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kv=(e,t)=>{let n=Pv(e);return{name:n.name,fn:n.fn,options:[e,t]}},qv=(e,t)=>({fn:Lv(e).fn,options:[e,t]}),Jv=(e,t)=>{let n=Fv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yv=(e,t)=>{let n=Iv(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xv=Y.createContext(void 0);function Zv(){let e=Y.useContext(Xv);if(e===void 0)throw Error(ed(26));return e}var Qv=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),$v=`--nested-dialogs`,ey=`data-nested-dialog-open`,ty={...of,...Kd,nestedDialogOpen(e){return e?{[ey]:``}:null}},ny=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=nd(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Zv(),kg({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Mg(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Fd(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...jg,hidden:!m,onKeyDown(e){Qv.has(e.key)&&e.stopPropagation()},style:{[$v]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:ty});return(0,$.jsx)(vg,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function ry(e){return fd(19)?e:e?`true`:void 0}var iy=Y.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,$.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),ay=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=nd(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,$.jsx)(Xv.Provider,{value:n,children:(0,$.jsxs)($h,{ref:t,...r,children:[a&&o===!0&&(0,$.jsx)(iy,{ref:i.context.internalBackdropRef,inert:ry(!s)}),e.children]})}):null}),oy={},sy={},cy=``;function ly(e,t){return _f(e)?e:t}function uy(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ly(t,n)).overflowY)}function dy(e){if(typeof document>`u`)return!1;let t=Hf(e);return df(t).innerWidth-t.documentElement.clientWidth>0}function fy(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=Hf(e),n=t.documentElement,r=t.body,i=ly(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function py(e){let t=Hf(e),n=t.documentElement,r=t.body,i=ly(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function my(e){let t=Hf(e),n=t.documentElement,r=t.body,i=df(n),a=0,o=0,s=!1,c=vm.create();if(Np&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,oy={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},cy=n.style.scrollBehavior,sy={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=ly(n,r);if(s=fy(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,oy),Object.assign(r.style,sy),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=cy)}function d(){u(),c.request(l)}l();let f=fm(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var hy=new class{lockCount=0;restore=null;timeoutLock=bp.create();timeoutUnlock=bp.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Hf(e),n=t.documentElement,r=t.body,i=df(n);if(uy(i,n,r)){let t=new i.MutationObserver(()=>{uy(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Op||!dy(e);this.restore=a?py(e):my(e)}};function gy(e=!0,t=null){Q(()=>{if(e)return hy.acquire(t)},[e,t])}function _y({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=Y.useState(0),[d,f]=Y.useState(0),p=l===0,m=Sg(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Gp(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Up(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return gy(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{!e.select(`open`)&&!e.select(`mounted`)||(u(t),f(n))}),Q(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Q(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Hg(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var vy={...y_,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},yy=class extends u_{constructor(e,t,n){let r=new Wg,i=by(e,r,t,n);super(i,xy(r),vy)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Lg(this.state,e,t.trigger)))}};function by(e,t,n,r=!1){return{...p_(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function xy(e){return{popupRef:Y.createRef(),backdropRef:Y.createRef(),internalBackdropRef:Y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Sy(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=nd(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Ng((e,t)=>new yy({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Ug(b,x),Bg(b);let{forceUnmount:w}=Vg(x,b);Y.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,qf(lp))}),[w,b]);let T=x||S||u!=null;return(0,$.jsxs)(td.Provider,{value:b,children:[u&&(0,$.jsx)(Pg,{handle:u,store:b}),T&&(0,$.jsx)(_y,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var Cy=$g(function(e){return Sy(`dialog`,e)}),wy=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=nd(),c=gp(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Fd(`h2`,e,{ref:t,props:[{id:c},o]})});function Ty(e){let t=Y.useRef(``),n=Y.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Y.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function Ey(e,t){let n=Y.useRef(e),r=Z(t);Q(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Dy(e,t){let{onClick:n,onPointerDown:r}=Ty(Z((n,r)=>{(typeof e==`function`?e():e)||t(r||(Op?`touch`:``))}));return Y.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function Oy(e){let[t,n]=Y.useState(null),r=Dy(e,n);return Ey(e,t=>{t&&!e&&n(null)}),Y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var ky=e_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=nd(!0),f=b_(l)??d;if(!f)throw Error(ed(79));let p=gp(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=Y.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=zg(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=Wf({disabled:a,native:o}),S=yg(m),C=Dy(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return Fd(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[Wh]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:rf})}),Ay=(0,Y.createContext)(void 0),jy=(0,Y.createContext)(null);function My(e){let t=(0,Y.useContext)(jy);return t===null?Object.hasOwn(globalThis,`document`)?document.body:null:t[e]}function Ny(e){let t=(0,Y.useContext)(Ay),n=(0,Y.useRef)(e);n.current=e,(0,Y.useEffect)(()=>t?.(()=>{n.current()}),[t])}var Py=(0,Y.createContext)(null);function Fy({children:e,interactionOwner:t=`local`,modal:n=!0,onOpenChange:r,...i}){return(0,$.jsx)(Py.Provider,{value:{interactionOwner:t,modal:n},children:(0,$.jsx)(Cy,{...i,modal:n,onOpenChange:(e,n)=>{if(t===`host`&&!e&&n.reason===`escape-key`){n.cancel(),n.allowPropagation();return}r?.(e,n)},children:e})})}function Iy(){let e=(0,Y.useContext)(Py);if(!e)throw Error(`Dialog parts must be used inside <Dialog>`);return e}(0,Y.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,$.jsx)(ky,{...n,className:t=>J(`btn`,et(e,t)),ref:r,type:t})});var Ly=(0,Y.forwardRef)(function({container:e,...t},n){let r=My(`dialog`);return e==null&&r===null?null:(0,$.jsx)(ay,{...t,container:e??r,ref:n})}),Ry=(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(cf,{...t,ref:n,className:t=>J(`caps-dialog-backdrop fixed inset-0 bg-black/40`,et(e,t))})}),zy=(0,Y.forwardRef)(function({className:e,finalFocus:t,size:n=`default`,...r},i){let a=Iy();return(0,$.jsx)(ny,{...r,"data-size":n,className:t=>J(`caps-dialog-popup overflow-y-auto overscroll-contain rounded-box bg-base-100 p-lg text-base-content shadow-xl`,n===`fill`?`fixed inset-0 h-full w-full max-w-none`:`caps-dialog-popup-default`,et(e,t)),finalFocus:a.interactionOwner===`host`?!1:t??!0,ref:i})}),By=(0,Y.forwardRef)(function({container:e,keepMounted:t=!0,className:n,size:r=`default`,...i},a){let{modal:o}=Iy();return(0,$.jsxs)(Ly,{container:e,keepMounted:t,children:[o===!0?(0,$.jsx)(Ry,{}):null,(0,$.jsx)(zy,{...i,size:r,className:e=>J(r==="default"&&`fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,et(n,e)),ref:a})]})});function Vy({className:e,...t}){return(0,$.jsx)(`div`,{...t,className:J(`flex justify-end gap-sm`,e)})}function Hy({className:e,...t}){return(0,$.jsx)(`div`,{...t,className:J(`flex flex-col gap-sm`,e)})}var Uy=(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(wy,{...t,className:t=>J(`text-lg font-semibold`,et(e,t)),ref:n})});(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(_p,{...t,className:t=>J(`text-sm text-base-content`,et(e,t)),ref:n})});var Wy=(0,Y.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,$.jsx)(up,{...n,className:t=>J(`btn btn-ghost`,et(e,t)),ref:r,type:t})}),Gy={dot:{y:-4,height:8,cy:0},pill:{y:-16,height:32,cy:0},bang:{y:-16,height:20,cy:12}};function Ky({className:e,glyph:t,motion:n}){let r=`caps-status-${(0,Y.useId)().replaceAll(`:`,``)}`,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(Gy[t]).current,d=(0,Y.useRef)(t===`dot`?1:4).current,f=(0,Y.useRef)(+(t===`bang`)).current,p=(0,Y.useRef)(t),m=xr(s),{reduced:h}=m;return(0,Y.useLayoutEffect)(()=>{if(!i.current||!a.current||!c.current||!l.current)return;let e=Gy[t],n=h||p.current===t;p.current=t;let r=si(i.current),o=n?{duration:0}:yr(r,{bounce:.3,duration:360}),s=ui(i.current,{y:e.y,height:e.height,...o}),u=ui(a.current,{cy:e.cy,...n?{duration:0}:{delay:ti(r,35),...yr(r,{bounce:.3,duration:420})}}),d=ui(c.current,{gradientTransform:`matrix(1 0 0 ${t===`dot`?`1`:`4`} 0 0)`,...o}),f=ui(l.current,{opacity:+(t===`bang`),...n?Jr:Nr(r,{ease:`inOutSine`,duration:220})});return()=>{s.cancel(),u.cancel(),d.cancel(),f.cancel()}},[t,h]),(0,Y.useLayoutEffect)(()=>{if(!o.current||!s.current||h||n===`none`)return;let e=n===`pulse`?ui(o.current,{opacity:[1,.45],...Nr(m,{ease:`inOutSine`,duration:750}),alternate:!0,loop:!0}):ui(o.current,{keyframes:{"0%":{translateY:0,scaleX:1,scaleY:1},"18%":{translateY:.25,scaleX:1.1,scaleY:.91},"42%":{translateY:-1.3,scaleX:.94,scaleY:1.06},"62%":{translateY:-1.65,scaleX:1,scaleY:1},"82%":{translateY:.15,scaleX:1.06,scaleY:.95},"100%":{translateY:0,scaleX:1,scaleY:1}},...Nr(m,{ease:`inOutSine`,duration:1e3}),loop:!0}),t=Rr(s.current,t=>{t?e.resume():e.pause()});return()=>{t(),e.revert()}},[n,h,m]),(0,$.jsxs)(`svg`,{ref:s,"aria-hidden":`true`,className:`caps-status-bead ${e??``}`,width:`8`,height:`8`,viewBox:`-4 -4 8 8`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)($r,{id:r,values:Br}),(0,$.jsx)(Kr,{ref:c,id:`${r}-surface`,transform:`matrix(1 0 0 ${String(d)} 0 0)`}),(0,$.jsxs)(`radialGradient`,{id:`${r}-drop-light`,gradientUnits:`userSpaceOnUse`,cx:`-1.2`,cy:`10.4`,r:`5.6`,children:[(0,$.jsx)(`stop`,{offset:`0`,stopColor:`var(--color-white)`,style:{stopOpacity:`calc(var(--depth) * 0.5)`}}),(0,$.jsx)(`stop`,{offset:`1`,stopColor:`var(--color-white)`,stopOpacity:`0`})]}),(0,$.jsx)(Dr,{id:`${r}-shadow`}),(0,$.jsx)(`mask`,{id:`${r}-silhouette`,maskUnits:`userSpaceOnUse`,x:`-12`,y:`-24`,width:`24`,height:`48`,style:{maskType:`alpha`},children:(0,$.jsxs)(`g`,{fill:`var(--color-white)`,filter:`url(#${r})`,children:[(0,$.jsx)(`rect`,{ref:i,x:`-4`,y:u.y,width:`8`,height:u.height,rx:`4`}),(0,$.jsx)(`circle`,{ref:a,cx:`0`,cy:u.cy,r:`4`})]})})]}),(0,$.jsx)(`g`,{ref:o,filter:`url(#${r}-shadow)`,children:(0,$.jsxs)(`g`,{mask:`url(#${r}-silhouette)`,children:[(0,$.jsx)(`rect`,{x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-surface)`}),(0,$.jsx)(`rect`,{ref:l,x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-drop-light)`,opacity:f})]})})]})}var qy=.28;function Jy(e,t){switch(e){case`ring`:return{dashes:1,track:0,arc:0,sweep:0,disc:0,tick:0,cross:0};case`arc`:return{dashes:0,track:1,arc:1,sweep:t===void 0?qy:Math.min(1,Math.max(0,t)),disc:0,tick:0,cross:0};case`check`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:1,cross:0};case`cross`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:0,cross:1}}}var Yy=7.25;function Xy({className:e,glyph:t,progress:n}){let r=`caps-status-mark-${(0,Y.useId)().replaceAll(`:`,``)}`,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useRef)(Jy(t,n)).current,p=(0,Y.useRef)(t),m=ai();(0,Y.useLayoutEffect)(()=>{let e=i.current,r=a.current,c=o.current,f=s.current,h=l.current,g=u.current,_=d.current;if(!e||!r||!c||!f||!h||!g||!_)return;let v=Jy(t,n),y=p.current;p.current=t;let b=si(e),x=m||y===t&&t!==`arc`,S=x?m?{ease:b.ease,duration:b.fast}:Jr:Nr(b,{ease:`outQuad`,duration:160}),C=(t===`check`||t===`cross`)&&!x,w=Nr(b,{ease:`inOutSine`,duration:220}),T=[ui(r,{opacity:v.dashes,...S}),ui(c,{opacity:v.track*.28,...S}),ui(f,{opacity:v.arc,"stroke-dasharray":`${String(v.sweep)} 1`,...x?m?Jr:S:w}),ui(h,{r:v.disc*Yy,...C?{delay:w.duration*.7,...yr(b,{bounce:.35,duration:360})}:m?Jr:Nr(b,{ease:`inCubic`,duration:140})}),ui(g,{"stroke-dashoffset":1-v.tick,...C&&v.tick>0?{delay:w.duration*.7+b.fast,...Nr(b,{ease:`outCubic`,duration:240})}:Jr}),ui(_,{"stroke-dashoffset":1-v.cross,...C&&v.cross>0?{delay:w.duration*.7+b.fast,...Nr(b,{ease:`outCubic`,duration:240})}:Jr})];return t===`cross`&&C&&b.shake>0&&T.push(ui(e,{translateX:[0,-b.shake,b.shake,-b.shake/2,0],delay:w.duration+b.fast,...Nr(b,{ease:`linear`,duration:300})})),()=>{for(let e of T)e.cancel()}},[t,n,m]);let h=t===`arc`&&n===void 0&&!m;return(0,Y.useLayoutEffect)(()=>{if(!h||!c.current||!i.current)return;let e=si(i.current),t=ui(c.current,{rotate:[0,360],...Nr(e,{ease:`linear`,duration:900}),loop:!0}),n=Rr(i.current,e=>{e?t.resume():t.pause()});return()=>{n(),t.revert()}},[h]),(0,$.jsxs)(`svg`,{ref:i,"aria-hidden":`true`,className:`caps-status-mark ${e??``}`,viewBox:`0 0 16 16`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(Kr,{id:`${r}-surface`,transform:`matrix(1.6 0 0 1.6 8 8)`}),(0,$.jsxs)(`mask`,{id:`${r}-knock`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`16`,height:`16`,children:[(0,$.jsx)(`rect`,{width:`16`,height:`16`,fill:`var(--color-white)`}),(0,$.jsx)(`path`,{ref:u,d:`M4.9 8.3 7.1 10.5 11.2 5.9`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.tick}),(0,$.jsx)(`path`,{ref:d,d:`M5.4 5.4 10.6 10.6 M10.6 5.4 5.4 10.6`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.cross})]})]}),(0,$.jsx)(`circle`,{ref:a,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`1.7 2.2`,opacity:f.dashes}),(0,$.jsx)(`circle`,{ref:o,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:f.track*.28}),(0,$.jsx)(`g`,{ref:c,className:`caps-status-mark-spin`,children:(0,$.jsx)(`circle`,{ref:s,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`${String(f.sweep)} 1`,transform:`rotate(-90 8 8)`,opacity:f.arc})}),(0,$.jsx)(`circle`,{ref:l,cx:`8`,cy:`8`,r:f.disc*Yy,fill:`url(#${r}-surface)`,mask:`url(#${r}-knock)`})]})}var Zy=new Set([`ring`,`arc`,`check`,`cross`]);function Qy(e){return Zy.has(e)}var $y={neutral:`text-base-content`,primary:`text-primary`,secondary:`text-secondary`,accent:`text-accent`,success:`text-success`,info:`text-info`,warning:`text-warning`,error:`text-error`},eb=(0,Y.forwardRef)(function({className:e,label:t,glyph:n=`dot`,motion:r=`none`,tone:i=`neutral`,size:a=`default`,appearance:o=`plain`,progress:s,...c},l){return(0,$.jsxs)(`span`,{...c,className:J(`caps-status`,a===`compact`&&`caps-status-compact`,o===`chip`&&`caps-status-chip`,e),"data-tone":o===`chip`?i:void 0,"data-glyph":n,"data-motion":r,ref:l,children:[Qy(n)?(0,$.jsx)(Xy,{className:$y[i],glyph:n,progress:s}):(0,$.jsx)(Ky,{className:$y[i],glyph:n,motion:r}),t===void 0?null:(0,$.jsx)(`span`,{children:t})]})}),tb=(0,Y.forwardRef)(function({className:e,count:t,density:n=`row`,dismissAriaLabel:r,dismissLabel:i=`Dismiss`,message:a,onDismiss:o,onRetry:s,retryAriaLabel:c,retryLabel:l=`Retry`,role:u=`status`,...d},f){return(0,$.jsxs)(`div`,{...d,className:J(`caps-failure-line`,e),"data-density":n,ref:f,role:u,children:[(0,$.jsx)(eb,{glyph:`dot`,tone:`error`}),(0,$.jsxs)(`span`,{className:`caps-failure-line-copy`,children:[(0,$.jsx)(`span`,{children:a}),t!==void 0&&t>1?(0,$.jsxs)(`span`,{className:`caps-failure-line-count`,children:[`Failed `,t,` times`]}):null]}),s||o?(0,$.jsxs)(`span`,{className:`caps-failure-line-actions`,children:[s?(0,$.jsx)(Xr,{"aria-label":c,size:`sm`,variant:`outline`,onClick:s,children:l}):null,o?(0,$.jsx)(Xr,{"aria-label":r,size:`sm`,variant:`ghost`,onClick:o,children:i}):null]}):null]})}),nb={queued:`Waiting to start`,generating:`Generating`,refining:`Refining`,done:void 0,failed:void 0},rb=(0,Y.forwardRef)(function({status:e,children:t,aspectRatio:n,label:r,indicator:i,failure:a,className:o,style:s,...c},l){let u=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>u.current);let d=(0,Y.useRef)(e),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(e);m!==e&&(h(e),p(e===`done`)),(0,Y.useLayoutEffect)(()=>{let t=u.current,n=d.current;if(d.current=e,!t||n===e)return;if(!kr(t)){p(!1);return}let r=si(t),i=_r(r,r.ease),a=[],o=t.querySelector(`:scope > [data-layer="media"]`),s=t.querySelector(`:scope > [data-layer="placeholder"]`),c=t.querySelector(`:scope > [data-layer="failure"]`);if(e===`done`&&o){let e=o.animate(r.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,filter:`blur(10px)`,transform:`scale(1.03)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:r.reduced?r.fast:r.slow*2,easing:i,fill:`backwards`});e.addEventListener(`finish`,()=>{p(!1)}),a.push(e),s&&a.push(s.animate([{opacity:1},{opacity:0}],{duration:r.reduced?r.fast:r.slow,easing:i,fill:`forwards`}))}return e===`failed`&&c&&a.push(c.animate([{opacity:0,transform:`translateY(${String(r.distance)}px)`},{opacity:1,transform:`none`}],{duration:r.normal,easing:i})),n===`failed`&&s&&a.push(s.animate([{opacity:.4},{opacity:1}],{duration:r.normal,easing:i})),()=>{for(let e of a)e.cancel()}},[e]);let g=e===`queued`||e===`generating`||e===`refining`,_=r??nb[e],v=e===`done`||e===`refining`;return(0,$.jsxs)(`div`,{...c,ref:u,className:J(`caps-generation-frame`,o),"data-status":e,"data-aspect":n===void 0?void 0:``,"aria-busy":g,style:n===void 0?s:{aspectRatio:n,...s},children:[e===`done`&&!f?null:(0,$.jsxs)(`div`,{className:J(`caps-generation-placeholder`,e===`queued`&&`skeleton`),"data-layer":`placeholder`,role:e===`done`?void 0:`status`,"aria-hidden":e===`done`||void 0,children:[e===`generating`||e===`refining`||e===`done`?i??(0,$.jsx)(Sr,{decorative:!0,size:`lg`,variant:`bloom`}):null,_===void 0?null:(0,$.jsx)(jr,{children:_})]}),v?(0,$.jsx)(`div`,{className:`caps-generation-media`,"data-layer":`media`,children:t}):null,e===`failed`&&a!==void 0?(0,$.jsx)(`div`,{className:`caps-generation-failure`,"data-layer":`failure`,role:`alert`,children:a}):null]})}),ib=Y.createContext(void 0);function ab(){let e=Y.useContext(ib);if(e===void 0)throw Error(ed(53));return e}function ob(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var sb=`base-ui-disable-scrollbar`,cb={className:sb,getElement(e){return(0,$.jsx)(`style`,{nonce:e,href:sb,precedence:`base-ui:low`,children:`.${sb}{scrollbar-width:none}.${sb}::-webkit-scrollbar{display:none}`})}},lb=`data-has-overflow-x`,ub=`data-has-overflow-y`,db=`data-overflow-x-start`,fb=`data-overflow-x-end`,pb=`data-overflow-y-start`,mb=`data-overflow-y-end`,hb=e=>t=>t?{[e]:``}:null,gb={hasOverflowX:hb(lb),hasOverflowY:hb(ub),overflowXStart:hb(db),overflowXEnd:hb(fb),overflowYStart:hb(pb),overflowYEnd:hb(mb),cornerHidden:()=>null},_b=Y.createContext(void 0),vb={disableStyleElements:!1};function yb(){return Y.useContext(_b)??vb}var bb=`--scroll-area-corner-height`,xb=`--scroll-area-corner-width`,Sb=`data-orientation`,Cb={x:0,y:0},wb={width:0,height:0},Tb={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Eb={x:!0,y:!0,corner:!0},Db=Y.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=Ob(i),d=gp(),f=xp(),p=xp(),{nonce:m,disableStyleElements:h}=yb(),[g,_]=Y.useState(!1),[v,y]=Y.useState(!1),[b,x]=Y.useState(!1),[S,C]=Y.useState(!1),[w,T]=Y.useState(!1),[E,D]=Y.useState(wb),[O,k]=Y.useState(wb),[A,j]=Y.useState(Tb),[M,N]=Y.useState(Eb),P=Y.useRef(null),F=Y.useRef(null),I=Y.useRef(null),L=Y.useRef(null),R=Y.useRef(null),z=Y.useRef(null),B=Y.useRef(null),ee=Y.useRef(null),V=Y.useRef(0),te=Y.useRef(0),ne=Y.useRef(0),H=Y.useRef(0),U=Y.useRef(`vertical`),re=Y.useRef(Cb),W=Y.useRef(null);function ie(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let ae=Z(e=>{let t=e.x-re.current.x,n=e.y-re.current.y;re.current=e,n!==0&&ie(!0),t!==0&&ie(!1)}),G=Z(()=>{let e=F.current;e&&W.current===null&&(W.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),oe=Z(e=>{if(e.button!==0||ee.current!==null&&(U.current===`vertical`?R.current:z.current)?.hasPointerCapture(ee.current))return;ee.current=e.pointerId,V.current=e.clientY,te.current=e.clientX,U.current=e.currentTarget.getAttribute(Sb);let t=F.current;t&&(ne.current=t.scrollTop,H.current=t.scrollLeft,G()),(U.current===`vertical`?R.current:z.current)?.setPointerCapture(e.pointerId)}),se=Z(e=>{if(e.pointerId!==ee.current)return;ee.current=null,(U.current===`vertical`?x:y)(!1),W.current!==null&&(F.current&&(F.current.style.scrollSnapType=W.current),W.current=null);let t=U.current===`vertical`?R.current:z.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ce=Z(e=>{if(e.pointerId!==ee.current)return;if(e.buttons%2==0){se(e);return}let t=F.current;if(!t)return;let n=U.current===`vertical`,r=n?R.current:z.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=ob(i,`padding`,a),s=ob(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-te.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?ne.current:H.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ie(n)});function le(e){C(e.pointerType===`touch`)}function ue(e){if(le(e),e.pointerType!==`touch`){let t=Up(P.current,e.target);_(t)}}let K=Y.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),de={role:`presentation`,onPointerEnter:ue,onPointerMove:ue,onPointerDown:le,onPointerLeave(){_(!1)},style:{position:`relative`,[bb]:`${E.height}px`,[xb]:`${E.width}px`}},fe=Fd(`div`,e,{state:K,ref:[t,P],props:[de,o],stateAttributesMapping:gb}),pe=Y.useMemo(()=>({handlePointerDown:oe,handlePointerMove:ce,handlePointerUp:se,handleScroll:ae,disableViewportSnap:G,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:B,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:z,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:K,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[oe,ce,se,ae,G,E,O,w,S,v,b,g,d,M,A,K,s,c,l,u]);return(0,$.jsxs)(ib.Provider,{value:pe,children:[!h&&cb.getElement(m),fe]})});function Ob(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}function kb(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var Ab=Y.createContext(void 0);function jb(){let e=Y.useContext(Ab);if(e===void 0)throw Error(ed(55));return e}var Mb=Y.createContext(void 0);function Nb(){return Y.useContext(Mb)?.direction??`ltr`}function Pb(e,t){if(t<=0)return 0;let n=kb(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var Fb=`--scroll-area-overflow-x-start`,Ib=`--scroll-area-overflow-x-end`,Lb=`--scroll-area-overflow-y-start`,Rb=`--scroll-area-overflow-y-end`,zb=`--scroll-area-thumb-height`,Bb=`--scroll-area-thumb-width`,Vb=[Fb,Ib,Lb,Rb],Hb=!1;function Ub(){Hb||Np||(typeof CSS<`u`&&`registerProperty`in CSS&&Vb.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),Hb=!0)}var Wb=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=ab(),T=Nb(),E=Y.useRef(!0),D=Y.useRef([NaN,NaN,NaN,NaN]),O=xp(),k=xp(),A=Z(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=Gb(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=Pb(T===`rtl`?-w:w,P),L=P-I);let R=A?0:Pb(x,F),z=A?0:F-R,B=j?0:b,ee=A?0:y,V=0,te=0;!j&&!A&&(V=t?.offsetWidth||0,te=n?.offsetHeight||0);let ne=f.width===0&&f.height===0,H=ne?V:0,U=ne?te:0,re=ob(n,`padding`,`x`),W=ob(t,`padding`,`y`),ie=ob(i,`margin`,`x`),ae=ob(r,`margin`,`y`),G=B-re-ie,oe=ee-W-ae,se=n?Math.min(n.offsetWidth-H,G):G,ce=t?Math.min(t.offsetHeight-U,oe):oe,le=Math.max(16,se*M),ue=Math.max(16,ce*N);if(m(e=>Kb(e,{width:le,height:ue})),t&&r){let e=qb(r,zb,x,F,h,ue,t.offsetHeight-ue-W-ae);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-le-re-ie,t=qb(i,Bb,T===`rtl`?-w:w,P,_,le,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let K=[I,L,R,z];Vb.forEach((t,n)=>{e.style.setProperty(t,`${K[n]}px`)}),a&&p(e=>Kb(e,{width:V,height:te})),g(e=>Kb(e,k));let de={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&z>C.yEnd};S(e=>Kb(e,de))});Q(()=>{Ub()},[]),Q(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),Q(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),Q(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=Tg(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(hd))).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:cb.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=Fd(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:gb}),P=Y.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,$.jsx)(Ab.Provider,{value:P,children:N})});function Gb(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function Kb(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function qb(e,t,n,r,i,a,o){let s=kb(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var Jb=Y.createContext(void 0);function Yb(){let e=Y.useContext(Jb);if(e===void 0)throw Error(ed(54));return e}var Xb=Y.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=ab(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=Nb(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;Y.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return fm(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Gp(e.nativeEvent),n=T?h.current:g.current;if(n&&Up(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=ob(n,`margin`,a),s=ob(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${bb})`,insetInlineEnd:0,[zb]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${xb})`,bottom:0,[Bb]:`${S.width}px`}}},M=Fd(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:gb});return A?(0,$.jsx)(Jb.Provider,{value:i,children:M}):null}),Zb=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=jb(),{hasMeasuredScrollbar:s,viewportState:c}=ab(),l=Y.useRef(null),u=Y.useRef(s);return Q(()=>{if(typeof ResizeObserver>`u`)return;let e=!1,t=new ResizeObserver(()=>{!e&&(e=!0,!u.current)||o()});return l.current&&t.observe(l.current),()=>{t.disconnect()}},[o]),Fd(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:gb,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})}),Qb=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=ab(),m=Yb(),h=m===`vertical`;return Fd(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})});function $b(e,t,n){let r=(Math.abs(t)-Math.abs(e))/Math.max(16,n);if(Math.abs(r)<.035)return null;let i=Math.min(.04,Math.abs(r)*.3),a=r>0,o=Math.sign(t||e);return{scaleY:1+(a?i:-i),scaleX:1+(a?-i/2:i/2),origin:(a?o>0:o<0)?`center top`:`center bottom`}}function ex(e,t,n){if(t<=0||Math.abs(n)<4)return null;let r=e<=0&&n<0,i=e>=t-1&&n>0;if(!r&&!i)return null;let a=Math.min(.06,Math.abs(n)/120*.06);return{scaleY:1-a,scaleX:1+a/2,origin:r?`center top`:`center bottom`}}var tx=(0,Y.forwardRef)(function({children:e,className:t,surface:n=!1,surfaceSize:r,surfaceDepth:i,screen:a=!1,...o},s){let c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=ai();(0,Y.useEffect)(()=>{let e=c.current,t=e?.querySelector(`.caps-scroll-viewport`);if(!t||!e)return;let n=null,r,i=t.scrollTop,a=performance.now(),o=0,s=e=>{let t=l.current;if(!e||u||!t)return;n?.cancel(),t.style.transformOrigin=e.origin;let r=si(t),i=Nr(r,{ease:`outQuad`,duration:45}),a=yr(r,{bounce:.18,duration:180});n=ui(t,{scaleY:[{to:e.scaleY,...i},{to:1,...a}],scaleX:[{to:e.scaleX,...i},{to:1,...a}]})},d=(e,t)=>{let n=$b(o,e,t);o=e,s(n)},f=e=>{if(e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;let n=e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1,i=ex(t.scrollTop,t.scrollHeight-t.clientHeight,e.deltaY*n);i&&(clearTimeout(r),o=0,s(i))},p=()=>{let e=performance.now(),n=e-a,s=n>100?16:Math.max(16,n),c=t.scrollTop-i;n>100&&(o=0),d(c/s,s),i=t.scrollTop,a=e,clearTimeout(r),r=setTimeout(()=>{d(0,32)},64)};return t.addEventListener(`scroll`,p,{passive:!0}),e.addEventListener(`wheel`,f,{passive:!0}),()=>{clearTimeout(r),n?.cancel(),l.current&&(l.current.style.transform=`none`),t.removeEventListener(`scroll`,p),e.removeEventListener(`wheel`,f)}},[a,n,u]);let d=(0,$.jsx)(Wb,{render:a?(0,$.jsx)(An,{}):(0,$.jsx)(`div`,{}),...o,ref:s,className:`caps-scroll-viewport`,children:(0,$.jsx)(Zb,{style:{minWidth:0},children:e})});return(0,$.jsxs)(Db,{render:n?(0,$.jsx)(or,{size:r??`md`,depth:i??`shallow`}):(0,$.jsx)(`div`,{}),ref:c,className:J(`caps-scroll-area`,t),children:[a?(0,$.jsx)(`div`,{className:`caps-display-gasket caps-scroll-display`,children:d}):d,(0,$.jsx)(or,{size:`sm`,depth:`deep`,placement:`embedded`,className:`caps-scroll-track-surface`,children:(0,$.jsx)(Xb,{className:`caps-scroll-track`,children:(0,$.jsx)(Qb,{className:`caps-scroll-thumb`,children:(0,$.jsx)(`span`,{className:`caps-scroll-thumb-surface`,ref:l})})})})]})}),nx=Ze(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),rx=Ze(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ix=Ze(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ax=Ze(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),ox=Ze(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),sx=Ze(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),cx=Ze(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),lx=Ze(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),ux=Ze(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),dx=Ze(`ImagePlus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),fx=Ze(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),px=Ze(`Maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),mx=Ze(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),hx=Ze(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),gx=Ze(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),_x=Ze(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),vx=Ze(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),yx=Ge([Yt({kind:Vt(`compose`),text:rt.pipe(qt(Ye(1)),qt(cn(2e3)))}),Yt({kind:Vt(`navigate`),params:Te(Yt({key:rt.pipe(qt(Ye(1)),qt(cn(64))),value:rt.pipe(qt(cn(1024)))})).pipe(qt(cn(16)))})]);Ge([Yt({role:rt.pipe(qt(Ye(1)),qt(cn(80))),intent:yx}),Yt({appId:rt.pipe(qt(Ye(1)),qt(cn(128))),intent:yx})],{mode:`oneOf`});var bx=G({displayName:K().min(1).max(80).nullable()}).nullable(),xx=st(`apps.open`,1,ce(()=>Pt({open:ut,role:wt(at(bx))})));st(`apps.call`,1,ce(()=>Pt({call:wt(at(M().transform(e=>$e(e))))})));var Sx=K().regex(/^[a-zA-Z0-9._-]{1,128}$/).refine(e=>e!==`.`&&e!==`..`),Cx=K().regex(/^[0-9a-f]{40}$/);G({ref:K().startsWith(`refs/`).max(1024),before:Cx,after:Cx}),ce(()=>K().min(1).max(512));var wx=`files`,Tx=G({name:K(),email:K()}),Ex=G({hash:Cx,treeHash:Cx,message:K(),author:Tx,committer:Tx,parents:rn(Cx),authoredAt:o(),committedAt:o()}),Dx=G({name:K(),mode:K(),hash:Cx,type:q([`blob`,`tree`,`commit`])});G({ref:K(),commit:Ex,path:K(),entries:rn(Dx)});var Ox=65536,kx=K().min(1).max(1024).refine(e=>!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`.git`),`Choose a relative repository file path.`),Ax=K().min(1).max(256),jx={repo:Sx,branch:Ax,path:kx},Mx=q([`pending`,`synced`,`conflict`,`failed`]),Nx=G({text:K(),revision:o().int().positive(),state:Mx,theirs:G({blob:Cx.nullable(),commit:Cx}).optional(),failure:q([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`]).optional()});G({...jx,baseBlob:Cx.nullable(),baseCommit:Cx,text:K().max(Ox),revision:o().int().positive().nullable()});var Px=S([G({kind:bt(`saved`),revision:o().int().positive(),state:bt(`pending`)}),G({kind:bt(`synced`),revision:o().int().positive(),commit:Cx}),G({kind:bt(`conflict`),revision:o().int().nonnegative(),theirs:Nx.shape.theirs.optional()}),G({kind:bt(`failed`),revision:o().int().positive(),reason:q([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`])}),G({kind:bt(`refused`),reason:q([`not-source-writer`,`background-unavailable`])})]);G({...jx,revision:o().int().positive()}),S([G({kind:q([`discarded`,`not_found`])}),G({kind:bt(`conflict`),revision:o().int().positive()})]),G({settled:rn(G({...jx,result:Px})),more:xe()}),G({version:o().int().positive().nullable(),commit:Cx,blob:Cx.nullable(),pending:Nx.optional(),ref:K(),path:K(),size:o(),binary:xe(),text:K().nullable()}),G({ref:K(),commits:rn(G({commit:Ex,agent:K().nullable()})),next:K().optional()}),G({ref:K(),commit:Ex,paths:rn(K()),truncated:xe()}),G({kind:bt(`rebuilding`)}),G({done:xe(),cursor:K().nullable()}),S([G({repository:Sx,branch:Ax,path:kx}),G({path:K().min(1).max(1024)})]);var Fx=24,Ix={all:e=>Jn.of(e,`prints`,`gallery`),listings:e=>[...Ix.all(e),`listing`],listing:(e,t)=>[...Ix.listings(e),t],file:(e,t)=>[...Ix.all(e),`file`,t]};function Lx(e,t){let n=e?.context.get().computerId;return va({queryKey:Ix.listing(e,t),initialPageParam:0,enabled:!!(n&&t&&e.capabilities.has(gn)&&e.capabilities.has(mn)),queryFn:async({pageParam:r,signal:i})=>{if(!e||!n||!t)throw new u(`No Computer folder selected`,{code:`SELECTION_CHANGED`,retryable:!1});let a=[],o=r;do{if(i.throwIfAborted(),e.context.get().computerId!==n)throw new u(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});let r=await xn(e.capabilities,{path:t,limit:Fx-a.length,offset:o});if(i.throwIfAborted(),r.nextOffset!==null&&r.nextOffset<=o)throw new u(`Directory pagination did not advance`,{code:`PROTOCOL`,retryable:!1});a.push(...r.entries.filter(e=>e.type===`file`&&/\.(avif|gif|jpe?g|png|svg|webp|mp4)$/i.test(e.name)).map(e=>({...e,path:`${r.path.replace(/\/$/,``)}/${e.name}`}))),o=r.nextOffset}while(a.length<Fx&&o!==null);return{entries:a,nextOffset:o}},getNextPageParam:e=>e.nextOffset})}function Rx(e,t,n){return{...Ir(e,mn,[...Ix.file(e,t.path),t.modifiedAt,t.size],async(n,r)=>{if(!e)throw new u(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});let i=await hn(e.capabilities,{path:t.path},{signal:r});return new File([i],i.name,{type:i.type,lastModified:t.modifiedAt})}),enabled:!!(n&&e?.context.get().computerId&&e.capabilities.has(mn)),structuralSharing:!1}}function zx(e,t){let n=e?.app??null,r=Su(n),i=ge(),[a,o]=(0,Y.useState)(()=>new Set),s=(0,Y.useCallback)(e=>{if(!r)return;let t=`${r}:${e}`;o(e=>e.has(t)?e:new Set([...e,t]))},[r]),c=(0,Y.useCallback)(e=>{s(e),i.resetQueries({queryKey:Ix.file(n,e)})},[n,i,s]),l=Lx(n,t),u=xa(l),d=(0,Y.useMemo)(()=>l.enabled?u.data?.pages.flatMap(e=>e.entries)??[]:[],[u.data,l.enabled]),f=(0,Y.useCallback)(e=>({files:e.flatMap((e,t)=>e.data?[{path:d[t].path,file:e.data}]:[]),failures:e.flatMap((e,t)=>e.isError?[d[t].name]:[]),loading:e.some(e=>e.isLoading)}),[d]),p=_a({queries:d.map(e=>Rx(n,e,!!(r&&a.has(`${r}:${e.path}`)))),combine:f});return(0,Y.useEffect)(()=>{if(!n)return;let e=Ix.all(n),t=Ix.listings(n),a=!0;i.invalidateQueries({queryKey:e});let o=()=>{i.cancelQueries({queryKey:e})},s=n.context.subscribe(e=>{e.computerId!==r&&o()}),c=n.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&o()}),l=n.capabilities.subscribe(()=>{queueMicrotask(()=>{!a||n.context.get().computerId!==r||i.resetQueries({queryKey:t})})});return()=>{a=!1,s(),c(),l(),o()}},[n,r,e,i]),{entries:d,loadFile:s,retryFile:c,files:p.files,failures:p.failures,error:u.error,loading:u.isFetching||p.loading,hasNextPage:u.hasNextPage,nextPageReady:u.hasNextPage&&!u.isFetching&&!u.error,refresh:()=>{u.refetch({cancelRefetch:!1})},loadMore:()=>{u.isFetching||u.fetchNextPage({cancelRefetch:!1})}}}function Bx(e){return e.replace(/\s/gu,` `).replace(/ +/g,` `).trim()}function Vx(e,t){let[n,r]=(0,Y.useState)([]),i=(0,Y.useRef)(new Map),a=(0,Y.useRef)(Promise.resolve()),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(new Map),l=(0,Y.useRef)(e);l.current=e;let u=(0,Y.useRef)(t);u.current=t;let d=(e,t,n)=>{let a=i.current.get(e);a&&i.current.set(e,{...a,status:t,message:n}),r([...i.current.values()])},f=(0,Y.useCallback)(async(e,t)=>{let n=()=>t.signal.aborted;if(n()){d(e.id,`cancelled`,`Cancelled before sending`),c.current.delete(e.id);return}let r=e.dimensions;if(!r)try{let t=await vn(e.file,e.previewUrl);r={width:t.width,height:t.height},e.dimensions=r;let n=i.current.get(e.id);n&&i.current.set(e.id,{...n,dimensions:r})}catch(t){Sn(`decode-upload-image`,t),d(e.id,`error`,`Could not decode this image. No upload was sent.`),c.current.delete(e.id);return}try{if(n()){d(e.id,`cancelled`,`Cancelled before sending`);return}if(e.app.context.get().computerId!==e.computerId){d(e.id,`error`,`Computer changed. Select the original Computer and retry. No upload was sent.`);return}u.current({id:e.id,path:e.path,computerId:e.computerId,app:e.app,width:r.width,height:r.height}),d(e.id,`sending`,`Sending; awaiting Computer completion`),await _n(e.app.capabilities,{path:e.path,content:e.file.slice()},{signal:t.signal}),d(e.id,`complete`,`Written to Computer`);try{await l.current(e.path,e.app,e.computerId)}catch(t){Sn(`refresh-upload-preview`,t),d(e.id,`complete`,`Written; fresh preview unavailable`)}}catch(t){n()||Sn(`write-computer-upload`,t),d(e.id,n()?`cancelled`:`error`,n()?`Cancelled request; check Computer before retrying`:`Completion not confirmed; check Computer or retry`)}finally{c.current.delete(e.id)}},[]),p=e=>{let t=new AbortController;c.current.set(e.id,t),d(e.id,`queued`,`Queued`),a.current=a.current.then(()=>f(e,t))},m=(0,Y.useCallback)(()=>{for(let e of c.current.values())e.abort()},[]);return(0,Y.useEffect)(()=>()=>{m();for(let e of i.current.values())URL.revokeObjectURL(e.previewUrl)},[m]),{items:n,error:o,cancelAll:m,add(e,t,n){s(null);let r=[...i.current.values()].reduce((e,t)=>e+t.file.size,0);for(let a of e){if(!a.type.startsWith(`image/`)){s(`Only image files can be uploaded here`);continue}if(i.current.size>=8||r+a.size>67108864){s(`Upload queue limit: eight files and 64 MiB. Remove finished rows before adding more.`);break}let e=n.context.get().computerId;if(!e){s(`Select a Computer before uploading images.`);continue}let o=`${t.replace(/\/$/,``)}/upload-${bl(8)}-${Bx(a.name)}`;if(i.current.has(o)){s(`This path is already in the queue. Retry or remove its existing row.`);continue}let c={computerId:e,id:o,file:a,previewUrl:URL.createObjectURL(a),app:n,path:o,status:`queued`,message:`Queued`};i.current.set(c.id,c),r+=a.size,p(c)}},cancel(e){c.current.get(e)?.abort()},retry(e){let t=n.find(t=>t.id===e);t&&!c.current.has(e)&&p(t)},remove(e){if(!c.current.has(e)){let t=i.current.get(e);t&&URL.revokeObjectURL(t.previewUrl),i.current.delete(e),r([...i.current.values()])}}}}function Hx(e){return e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name}function Ux(e){return e.connection.app.ui.openNavigation({computerId:e.computerId,path:e.path})}function Wx(e){let[t,n]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(n(!1),!e?.capabilities.has(xx))return;let t=!0;return e.capabilities.require(xx).role(wx).then(e=>{t&&n(e!==null)},e=>{Sn(`files-editor-role`,e)}),()=>{t=!1}},[e]),t}function Gx(e,t){let n=t.path,r=Su(e?.app),i=(0,Y.useRef)(new Set),a=(0,Y.useRef)(0),o=(0,Y.useRef)(e);o.current=e;let s=e?.app.capabilities.has(gn)===!0,c=e?.app.capabilities.has(mn)===!0,l=e?.app.capabilities.has(yn)===!0,u=zx(e,t.galleryPath),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)([]),[h,g]=(0,Y.useState)([]),[_,v]=(0,Y.useState)([]);(0,Y.useEffect)(()=>{v([])},[e]);let y=e=>{v(t=>t.some(t=>t.key===e.key)?t.map(t=>t.key===e.key?e:t):[...t,e])},[b,x]=(0,Y.useState)(!1),S=(0,Y.useMemo)(()=>[...u.error?[`Could not refresh the Media gallery`]:[],...u.failures],[u.error,u.failures]),C=(0,Y.useRef)(new WeakMap),w=(0,Y.useMemo)(()=>{if(!c||!s)return d.filter(e=>e.kind===`local`);let t=r?u.files.map(({file:t,path:n})=>({kind:`computer`,computerId:r,connection:e,file:t,path:n})):[],i=d.filter(t=>t.kind===`local`||t.computerId===r&&t.connection===e&&t.path.slice(0,t.path.lastIndexOf(`/`))===n?.replace(/\/$/,``));return[...t.filter(e=>!i.some(t=>t.kind===`computer`&&e.kind===`computer`&&t.path===e.path)),...i]},[e,r,n,u.files,d,c,s]),T=(0,Y.useCallback)(()=>{a.current+=1;for(let e of i.current)e.abort();i.current.clear()},[]);(0,Y.useEffect)(()=>{if(!e)return()=>{T()};let t=e.app.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&T()});return()=>{t(),T()}},[e,T]),(0,Y.useEffect)(()=>{if(e)return e.app.context.subscribe(e=>{e.computerId!==r&&T()})},[e,r,T]),(0,Y.useEffect)(()=>{v([]),f(e=>e.filter(e=>e.kind===`local`))},[r]);let E=(0,Y.useCallback)(async(e,t,n)=>{let r=n??t.app.context.get().computerId;if(!r){g([`The selected Computer is unavailable`]);return}if(o.current!==t){g([`Computer selection changed`]);return}if(t.app.context.get().computerId!==r){g([`Computer selection changed before the preview was loaded`]);return}let s=a.current,c=new AbortController;i.current.add(c);try{let n=await hn(t.app.capabilities,{path:e},{signal:c.signal});if(c.signal.aborted||s!==a.current)return;v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,previewFile:n}:t)),f(i=>[...i.filter(t=>t.kind!==`computer`||t.path!==e||t.computerId!==r),{kind:`computer`,computerId:r,file:n,path:e,connection:t}])}catch(t){c.signal.aborted||(Sn(`read-computer-file`,t),g([`Could not read ${e}`]),v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,error:`Saved; preview unavailable. Retry loading it.`}:t)))}finally{i.current.delete(c)}},[]),D=(0,Y.useCallback)(t=>{let n=d.find(n=>n.kind===`computer`&&n.connection===e&&n.computerId===r&&n.path===t);n?.kind===`computer`?E(t,n.connection,n.computerId):u.retryFile(t)},[d,e,r,E,u.retryFile]),O=(0,Y.useRef)(new Set),k=(0,Y.useRef)(new Set),A=(0,Y.useCallback)(e=>{URL.revokeObjectURL(e),O.current.delete(e)},[]);(0,Y.useEffect)(()=>{let e=!0,t=new Set,n=new Map,r=new Set,i=[...w].sort((e,t)=>t.file.lastModified-e.file.lastModified||e.file.name.localeCompare(t.file.name)).map(e=>{let t=URL.createObjectURL(e.file);return O.current.add(t),{source:e,file:e.file,url:t}}),a=i.length;return g(S),x(a>0),a===0&&m([]),i.forEach(({file:o,url:s,source:c},l)=>{let u=C.current.get(o);u||(u=(async()=>{let e=URL.createObjectURL(o);try{let{width:t,height:n}=await vn(o,e);return{width:t,height:n}}finally{URL.revokeObjectURL(e)}})(),C.current.set(o,u)),u.then(r=>{e&&(n.set(l,{...r,file:o,url:s,source:c}),t.add(s),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})),v(e=>e.map(e=>e.previewFile===o?{...e,resolved:!0,previewFile:void 0,error:void 0}:e)))}).catch(t=>{e&&(Sn(`decode-gallery-image`,t),A(s),r.add(o.name),g([...S,...r]),c.kind===`computer`&&v(e=>e.map(e=>e.key===`${c.computerId}:${c.path}`?{...e,error:`Could not decode the saved image.`}:e)))}).finally(()=>{--a,e&&a===0&&(x(!1),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})))})}),()=>{e=!1;for(let{url:e}of i)t.has(e)||A(e)}},[w,S,A]),(0,Y.useEffect)(()=>{let e=new Set(p.map(e=>e.url));for(let t of k.current)e.has(t)||A(t);k.current=e},[p,A]),(0,Y.useEffect)(()=>{let e=O.current;return()=>{for(let t of e)URL.revokeObjectURL(t);e.clear()}},[]);let j=Vx(async(e,t,n)=>{let r=o.current,i=r?.app===t&&t.context.get().computerId===n?r:null;i&&await E(e,i,n)},e=>{o.current?.app===e.app&&e.app.context.get().computerId===e.computerId&&y({key:`${e.computerId}:${e.path}`,path:e.path,computerId:e.computerId,width:e.width,height:e.height,uploadId:e.id})});return(0,Y.useEffect)(()=>{let t=j.cancelAll,n=e?.app.lifecycle.subscribe(e=>{(e===`disposing`||e===`disconnected`||e===`disposed`)&&t()});return()=>{n?.(),t()}},[e,j.cancelAll]),{images:p,failed:h,loading:b,gallery:u,gallerySlots:_,canBrowse:s,canRead:c,canWrite:l,reserveSlot:y,addComputerFile:E,retryFile:D,uploads:j,uploadFiles:async i=>{if(!e||!l||n===null)return;let a=e,s=r,c=await t.ensureCreated();if(c){g([c]);return}o.current===a&&a.app.context.get().computerId===s&&j.add(i,n,a.app)},failSlot:(e,t)=>{v(n=>n.map(n=>n.key===e?{...n,error:t}:n))},clearSlotError:e=>{v(t=>t.map(t=>t.key===e?{...t,error:void 0}:t))},removeSlot:e=>{v(t=>t.filter(t=>t.key!==e))}}}function Kx(e){return e.map(e=>e.key)}function qx(e,t,n){let r=e.indexOf(t);return r<0?null:e[r+n]??null}function Jx(e,t,n){if(e.includes(t))return t;let r=n.indexOf(t);if(r>=0){let t=new Set(e);for(let e=1;e<n.length;e+=1)for(let i of[e,-e]){let e=r+i;if(e<0||e>=n.length)continue;let a=n[e];if(t.has(a))return a}}return e[0]??null}var Yx=(0,Y.lazy)(async()=>({default:(await er(()=>import(`./print-download-button-B6tCroD1.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)).PrintDownloadButton}));function Xx({url:e,path:t,onError:n,autoPlay:r}){let i=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=i.current;if(!t)return;let a=!1;return r&&t.play().catch(t=>{a||t instanceof DOMException&&(t.name===`NotAllowedError`||t.name===`AbortError`)||(Sn(`play-print-video`,t),n(e))}),()=>{a=!0,t.pause()}},[e,n,r]),(0,$.jsx)(`video`,{ref:i,src:e,"aria-label":t,controls:!0,playsInline:!0,preload:`auto`,className:`block max-h-full max-w-full object-contain`,onError:()=>{n(e)}})}function Zx({item:e,actualSize:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=e.pending===!0&&!e.onVisible,[s,c]=(0,Y.useState)(o);o&&!s&&c(!0);let l=e.pendingLabel??`Loading print…`,u=o?`Not saved`:`Prints can’t show this file`,d=(0,$.jsx)(`img`,{src:e.url,alt:e.path,decoding:`async`,width:t?e.width:void 0,height:t?e.height:void 0,className:t?`block max-w-none`:`block max-h-full max-w-full object-contain`,onLoad:()=>{r(e.url)},onError:()=>{a(e.url)}},e.url);return(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-hidden`,"data-print-viewer-stage":!0,children:e.error||i===e.url?(0,$.jsx)(rb,{status:`failed`,className:`h-full w-full`,failure:(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,$.jsx)(`p`,{className:`max-w-full break-words text-sm`,children:e.path}),(0,$.jsx)(tb,{density:`tile`,message:e.error?`${u}: ${e.error}`:u,onRetry:e.onRetry,onDismiss:e.onDismiss})]})}):bn(e.path)&&e.url?(0,$.jsx)(Xx,{url:e.url,path:e.path,onError:a,autoPlay:!s}):e.url?(0,$.jsxs)($.Fragment,{children:[t?(0,$.jsx)(tx,{className:`h-full w-full`,role:`region`,"aria-label":`Actual-size print`,tabIndex:0,"data-print-viewer-scroll":!0,children:d}):d,n===e.url?null:(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsx)(Sr,{label:`Loading print`,variant:`bloom`})})]}):(0,$.jsx)(rb,{status:`generating`,label:l,className:`h-full w-full`,indicator:(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,$.jsx)(Sr,{decorative:!0,variant:`bloom`}),(0,$.jsx)(`p`,{className:`text-sm`,children:l})]})})})}function Qx({source:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(!1);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xt,{label:`Open in Inkcap`,icon:(0,$.jsx)(ox,{}),disabled:t,onClick:()=>{n(!0),i(!1),Ux(e).catch(e=>{Sn(`open-print-in-inkcap`,e),i(!0)}).finally(()=>{n(!1)})}}),r?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Could not open `,e.path,` in Inkcap.`]}):null]})}function $x({items:e,images:t,viewerKey:n,app:r,onNavigate:i,onClose:a,renderInfo:o}){let s=(0,Y.useRef)(null),c=Wx(r),l=Kx(e),u=(0,Y.useRef)(l),d=n===null?null:Jx(l,n,u.current);(0,Y.useEffect)(()=>{u.current=l,n!==null&&d!==n&&(d===null?a(n):i(d))},[l,d,n,a,i]),(0,Y.useEffect)(()=>{if(d===null)return;let t=e.findIndex(e=>e.key===d);for(let n of e.slice(Math.max(0,t-1),t+2))n.onVisible?.()},[e,d]);let[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{h(null)},[d]),(0,Y.useEffect)(()=>{p(null)},[n]);let g=e.find(e=>e.key===d),_=t.find(e=>Hx(e)===d);if(!g||d===null)return null;let v=qx(l,d,-1),y=qx(l,d,1),b=g.path.split(`/`).at(-1)??g.path,x=()=>{a(d)},S=e=>{e!==null&&i(e)};return(0,$.jsx)(Fy,{open:!0,onOpenChange:e=>{e||x()},children:(0,$.jsxs)(Ly,{children:[(0,$.jsx)(Ry,{}),(0,$.jsxs)(zy,{ref:s,size:`fill`,initialFocus:s,finalFocus:!1,className:`flex min-h-0 flex-col gap-sm`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select, video, [data-print-viewer-scroll], [contenteditable=true]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),S(e.key===`ArrowLeft`?v:y)):e.key.toLowerCase()===`i`&&_&&(e.preventDefault(),p(f===d?null:d)))},children:[(0,$.jsx)(ir,{fit:`fill`,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(ri,{title:(0,$.jsx)(Uy,{className:`truncate`,children:b}),status:(0,$.jsxs)(`span`,{"aria-live":`polite`,"aria-atomic":`true`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[b,`, `]}),l.indexOf(d)+1,` of `,l.length]})}),(0,$.jsxs)(`div`,{className:`@container relative flex min-h-0 min-w-0 flex-1`,children:[(0,$.jsx)(Zx,{item:g,actualSize:m===d},d),f===d&&_?o(_,()=>{p(null)}):null]})]})}),(0,$.jsxs)(`div`,{className:`prints-viewer-actions`,children:[(0,$.jsx)(Wr,{size:`default`,iconSize:`md`,"aria-label":`Previous print`,title:`Previous print (Left arrow)`,"aria-keyshortcuts":`ArrowLeft`,icon:(0,$.jsx)(nx,{}),disabled:v===null,onClick:()=>{S(v)}}),(0,$.jsx)(Wr,{size:`default`,iconSize:`md`,"aria-label":`Next print`,title:`Next print (Right arrow)`,"aria-keyshortcuts":`ArrowRight`,icon:(0,$.jsx)(rx,{}),disabled:y===null,onClick:()=>{S(y)}}),(0,$.jsx)(Wr,{size:`default`,iconSize:`md`,"aria-label":`Image info`,title:`Image info (I)`,"aria-keyshortcuts":`i`,"aria-expanded":f===d,icon:(0,$.jsx)(fx,{}),disabled:!_,onClick:()=>{p(f===d?null:d)}}),bn(g.path)?null:(0,$.jsx)(Wr,{size:`default`,iconSize:`md`,"aria-label":`Actual size`,title:`Actual size`,"aria-pressed":m===d,active:m===d,icon:(0,$.jsx)(px,{}),disabled:!g.url||!!g.error,onClick:()=>{h(m===d?null:d)}}),_?(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(Yx,{source:_.source,app:r},_.url)}):null,c&&_?.source.kind===`computer`?(0,$.jsx)(Qx,{source:_.source},d):null,(0,$.jsx)(Wr,{size:`default`,iconSize:`md`,"aria-label":`Close viewer`,title:`Close viewer (Escape)`,icon:(0,$.jsx)(Tr,{}),onClick:x})]})]})]})})}var eS=e=>rt.pipe(qt(Ye(1)),qt(cn(e))),tS=fe.pipe(qt($t()),qt(ve(Number.isSafeInteger,{message:`Expected a safe integer`}))),nS=tS.pipe(qt(ct(0))),rS=tS.pipe(qt(Ue(0))),iS=Yt({bytes:nS,costMilliunits:rS,destination:Yt({computerId:eS(256),path:eS(4096)}),format:I([`png`,`jpeg`,`gif`,`webp`,`mp4`]),height:nS,model:eS(256),width:nS}),aS=Yt({operation:Vt(`complete-generation`),reference:pt,result:iS,derivedFrom:f(eS(256)),references:f(Te(Ve(eS(256))))}),oS=Yt({prompt:ze,references:B.pipe(qt(Ue(0)))}),sS=Yt({reason:I([...Oe,`UNKNOWN`]),message:ze.pipe(qt(cn(512)))}),cS=Yt({reference:pt,input:Ht,typed:oS,style:f(ar),characters:f(Te(Gr)),failure:f(sS)});Ge([Yt({operation:Vt(`remember-generation`),record:cS}),Yt({operation:Vt(`fail-generation`),reference:pt,failure:sS}),Yt({operation:Vt(`forget-generation`),reference:pt}),Yt({operation:Vt(`list-generations`),after:Ve(rt)})]);function lS(e){return{reference:e.reference,input:Kt(e.input),typed:e.typed,style:e.style,characters:e.characters,failure:e.failure}}async function uS(e,t){let n=lS(tt(cS,{onExcessProperty:`error`})(t)),r=lS(tt(cS,{onExcessProperty:`error`})(await e.require(Mn).request(JSON.stringify({operation:`remember-generation`,record:n}))));if(JSON.stringify(r)!==JSON.stringify(n))throw new u(`Prints did not confirm the original generation command`,{code:`PROTOCOL`,retryable:!1});return r}async function dS(e,t,n){tt(cS,{onExcessProperty:`error`})(await e.require(Mn).request(JSON.stringify({operation:`fail-generation`,reference:t,failure:n})))}async function fS(e,t){tt(Yt({removed:Me}))(await e.require(Mn).request(JSON.stringify({operation:`forget-generation`,reference:t})))}async function pS(e,t=null){let n=tt(Yt({records:Te(cS),next:Ve(rt)}),{onExcessProperty:`error`})(await e.require(Mn).request(JSON.stringify({operation:`list-generations`,after:t})));return{records:n.records.map(lS),next:n.next}}async function mS(e,t,n){let r=tt(aS,{onExcessProperty:`error`})({operation:`complete-generation`,reference:t,result:n}),i=tt(Yt({printId:rt,computerId:rt}))(await e.require(Mn).request(JSON.stringify(r)));if(i.printId!==t.requestId||i.computerId!==t.computerId)throw new u(`Prints did not confirm the saved generation`,{code:`PROTOCOL`,retryable:!1})}var hS=St(Yt({reference:pt}));function gS({connection:e,folder:t,effects:n,styles:r,characters:i}){let a=e?.app??null,o=Su(a),s=(0,Y.useRef)(e);s.current=e;let c=(0,Y.useRef)(n);c.current=n;let l=ge(),d=Jn.of(a,`prints`,`generation`),f=[...d,`recovery`],p=Xn(Ur(a)),m=p.isError?void 0:p.data,h=m?.models??[],g=a?.capabilities.has(Dt)===!0,_=m?.canGenerate??!1,v=p.error?k(p.error).message:m?.models.length===0?`The granted Media model registry is empty.`:null,y=xa({queryKey:f,enabled:a!==null&&o!==null,initialPageParam:null,queryFn:async({pageParam:e,signal:t})=>{if(!a)throw new u(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});if(a.context.get().computerId!==o)throw new u(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});let n=await pS(a.capabilities,e);return t.throwIfAborted(),n},getNextPageParam:e=>e.next}),b=(0,Y.useMemo)(()=>Array.from(new Map(y.data?.pages.flatMap(e=>e.records).map(e=>[e.reference.requestId,e])??[]).values()),[y.data]),x=(0,Y.useRef)(new Map),S=(0,Y.useRef)(new Set),C=(0,Y.useRef)(0),w=(0,Y.useRef)(null),[T,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),A=e=>{E(e),c.current.notifyFailure(e.message)},j=e=>{O(e),c.current.notifyFailure(e)},M=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{M.current!==y.error&&(M.current=y.error,y.error&&c.current.notifyFailure(k(y.error).message))},[y.error]);let N=e=>s.current===e.connection&&e.connection.app.context.get().computerId===e.reference.computerId,P=(e,t,n)=>{l.setQueryData(e,e=>e&&{...e,pages:e.pages.map(e=>({...e,records:e.records.map(e=>e.reference.requestId===t?{...e,failure:n}:e)}))})},F=(e,t)=>{l.setQueryData(e,e=>e&&{...e,pages:e.pages.map(e=>({...e,records:e.records.filter(e=>e.reference.requestId!==t)}))})},I=Nt({mutationKey:[...d,`run`],mutationFn:async e=>{e.controller.signal.throwIfAborted();let t=lS({reference:e.reference,input:e.input,typed:e.typed,style:e.style,characters:e.characters});await uS(e.connection.app.capabilities,t),P(e.recoveryKey,e.reference.requestId,void 0),e.controller.signal.throwIfAborted();let n=await e.session.restoreAttempt(e.reference),r;try{r=await n.generate(t.input,{signal:e.controller.signal})}finally{n[Symbol.dispose]()}return await mS(e.connection.app.capabilities,t.reference,r),{input:e.input,result:r}},onMutate:e=>{if(!N(e)||e.controller.signal.aborted)return;let t=zn(e.session.models,e.input.settings.model),n={key:`${e.reference.computerId}:${e.input.destination.path}`,computerId:e.reference.computerId,path:e.input.destination.path,width:e.draft.width,height:e.draft.height,pendingLabel:Dn(t)};t?.kind===`video`&&(n.startedAt=Date.now(),n.resumed=e.resumed===!0),c.current.reserve(n)},onSuccess:(e,t)=>{F(t.recoveryKey,t.reference.requestId),w.current?.reference.requestId===t.reference.requestId&&(w.current=null),!(!N(t)||t.controller.signal.aborted)&&c.current.saved(e,t.connection)},onError:(e,n)=>{if(Sn(`generate-media`,e),n.controller.signal.aborted)return;let r=tr(e);dS(n.connection.app.capabilities,n.reference,r).catch(e=>{Sn(`fail-generation`,e)}),N(n)&&(P(n.recoveryKey,n.reference.requestId,r),t.recheck(),c.current.failed(`${n.reference.computerId}:${n.input.destination.path}`,r.message))},onSettled:(e,t,n)=>{x.current.get(n.reference.requestId)===n.controller&&x.current.delete(n.reference.requestId)}}),L=Nt({mutationKey:[...d,`discard`],mutationFn:async e=>{await fS(e.connection.app.capabilities,e.reference)},onSuccess:(e,t)=>{F(t.recoveryKey,t.reference.requestId),w.current?.reference.requestId===t.reference.requestId&&(w.current=null)},onError:(e,t)=>{N(t)&&j(k(e).message)},onSettled:(e,t,n)=>{x.current.get(n.reference.requestId)===n.controller&&x.current.delete(n.reference.requestId)}}),R=ba({filters:{mutationKey:d,status:`pending`},select:e=>Ae(hS(e.state.variables))?.reference.requestId}),z=new Set(R.filter(e=>e!==void 0));(0,Y.useEffect)(()=>{S.current.clear(),E(null),O(null),w.current=null;let e=Jn.of(a,`prints`,`generation`,`recovery`),t=a?.capabilities.subscribe(()=>{queueMicrotask(()=>{l.resetQueries({queryKey:e,exact:!0})})}),n=()=>{C.current+=1;for(let e of x.current.values())e.abort();x.current.clear(),l.cancelQueries({queryKey:e})},r=a?.context.subscribe(e=>{e.computerId!==o&&n()}),i=a?.lifecycle.subscribe(e=>{(e===`disposing`||e===`disposed`||e===`disconnected`)&&n()});return()=>{r?.(),i?.(),t?.(),n()}},[a,o,e,l]);let B=e=>{let t=e.reference.requestId;if(x.current.has(t))return!1;if(!N(e))return j(`Select the original Computer to retry this generation.`),!1;if(m?.computerId!==e.reference.computerId)return j(`Media access is unavailable for the original Computer.`),!1;let n=new AbortController;return x.current.set(t,n),w.current=e,E(null),O(null),C.current+=1,I.mutate({...e,session:m,controller:n,ticket:C.current,recoveryKey:f}),!0};(0,Y.useEffect)(()=>{if(!(!e||!m||!y.isSuccess))for(let t of b){let n=t.reference.requestId;S.current.has(n)||t.reference.computerId!==o||zn(m.models,t.input.settings.model)?.kind!==`video`||B({connection:e,...t,resumed:!0,draft:{...t.input.settings,references:t.input.settings.references??[],destination:t.input.destination.path}})&&S.current.add(n)}},[e,o,m,y.isSuccess,b]);let ee=async n=>{if(!e?.app.capabilities.has(yn)||!_)return!1;if(t.path===null)return t.setEditing(!0),!1;w.current=null;let a=zn(h,n.model);if(a===void 0)return A({kind:`error`,mediaKind:null,message:`Choose a model from the granted registry.`}),!1;let c=gr({prompt:n.prompt,saved:i,references:n.references,computerId:o,model:{label:a.label,maxReferences:a.input.maxReferences}});if(c.kind===`refused`)return A({kind:`error`,mediaKind:a.kind,message:c.message}),!1;let l=hr({...n,references:c.references},a);if(l)return A({kind:`error`,mediaKind:a.kind,message:l}),!1;let u=n.style===void 0?void 0:r.find(e=>e.name===n.style);if(n.style!==void 0&&u===void 0)return A({kind:`error`,mediaKind:a.kind,message:`The "${n.style}" style no longer exists. Pick another or none.`}),!1;let d=c.characters.map(e=>e.name),f=br(u?.text,c.prompt),p=rr(f,kn(a),u?.name,d);if(p!==void 0)return A({kind:`error`,mediaKind:a.kind,message:p}),!1;if(!g||!m)return E(null),!1;let v=e,y=v.app.context.get().computerId,b=C.current,x={...n,prompt:f,references:c.references,destination:Gn(n,t.path,a)},S=ci(x,a),T;try{let e=await t.ensureCreated();if(e)return A({kind:`error`,mediaKind:a.kind,message:e}),!1;if(C.current!==b||s.current!==v||v.app.context.get().computerId!==y)return!1;let n=await m.createAttempt();T=n.reference,n[Symbol.dispose]()}catch(e){return C.current===b&&s.current===v&&v.app.context.get().computerId===y&&A({kind:`error`,mediaKind:a.kind,...Qn(e)}),!1}return C.current!==b||s.current!==v||v.app.context.get().computerId!==y?!1:B({connection:v,reference:T,input:S,draft:x,typed:{prompt:n.prompt.trim(),references:n.references.length},style:u?.name,characters:d})},V=I.variables;return{state:T??(V&&N(V)&&V.ticket===C.current?I.isPending?{kind:`pending`,draft:V.draft}:I.isError?{kind:`error`,mediaKind:zn(V.session.models,V.input.settings.model)?.kind??null,...Qn(I.error)}:{kind:`completed`,record:I.data}:null)??(!e||!g||o===null?{kind:`unavailable`,reason:`Image creation is unavailable for this Computer right now.`}:v?{kind:`unavailable`,reason:v}:m?{kind:`ready`}:{kind:`loading`}),models:h,modelsLoading:p.isFetching,modelsError:v,canGenerate:_,mediaCapability:g,retryModels:()=>{p.refetch()},submit:ee,isRunning:()=>x.current.size>0,activeGenerations:z,pendingGenerations:b,recoveryError:D??(y.error?k(y.error).message:null),reportRecoveryError:e=>{j(k(e).message)},hasMore:y.hasNextPage,loadMore:()=>{y.isFetching||y.fetchNextPage()},resume:t=>{if(!e||m?.computerId!==t.reference.computerId){j(`Select the original Computer to retry this generation.`);return}B({connection:e,...t,draft:{...t.input.settings,references:t.input.settings.references??[],destination:t.input.destination.path}})},discard:t=>{if(!e||x.current.has(t.reference.requestId))return;let n=new AbortController;x.current.set(t.reference.requestId,n),L.mutate({...t,connection:e,controller:n,draft:{...t.input.settings,references:t.input.settings.references??[]},recoveryKey:f})},retryPath:e=>{let t=w.current;return t?.input.destination.path!==e||!N(t)?!1:(B(t),!0)},retry:w.current&&N(w.current)?()=>{w.current&&B(w.current)}:void 0,failedPrompt:w.current?.typed.prompt,dismissFailed:()=>{let e=w.current;if(!e||x.current.has(e.reference.requestId)){I.reset();return}w.current=null,I.reset();let t=new AbortController;x.current.set(e.reference.requestId,t),L.mutate({...e,controller:t,recoveryKey:f})},errorKey:`generation:${w.current?.reference.requestId??`draft`}:${String(C.current)}`}}function _S({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function vS(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var yS=[],bS=0,{link:xS,unlink:SS,propagate:CS,checkDirty:wS,shallowPropagate:TS}=_S({update(e){return e._update()},notify(e){yS[DS++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,jS(e))}}),ES=0,DS=0,OS,kS=0;function AS(e){try{++kS,e()}finally{--kS||MS()}}function jS(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=SS(n,e)}function MS(){if(!(kS>0)){for(;ES<DS;){let e=yS[ES];yS[ES++]=void 0,e.notify()}ES=0,DS=0}}function NS(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return OS!==void 0&&xS(i,OS,bS),i._snapshot},subscribe(e){let t=vS(e),n={current:!1},r=PS(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=OS,o=t?.compare??Object.is;if(n)OS=i,++bS,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{OS=a,n&&(i.flags&=-5),jS(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&wS(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&TS(e)}}else e&32&&(i.flags=e&-33);return OS!==void 0&&xS(i,OS,bS),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(CS(e),TS(e),MS())}},i}function PS(e){let t=()=>{let t=OS;OS=n,++bS,n.depsTail=void 0,n.flags=6;try{return e()}finally{OS=t,n.flags&=-5,jS(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&wS(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,jS(this)}};return t(),n}var FS=class{constructor(e,t){this.atom=NS(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(vS(e))}},IS=class{constructor(e){this.atom=NS(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(vS(e))}};function LS(e,t){return typeof e==`function`?new IS(e):t?new FS(e,t):new FS(e)}var RS=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function zS(e,t){return new RS(e,t).maybeExecute}var BS=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},VS=new class extends BS{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function HS(e,t){return typeof e==`function`?e(t):e}function US(e,t){return ZS(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function WS(e,t,n){let r=ZS(t);function i(e){if(!r.length)return HS(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function GS(e,t){let n=ZS(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var KS=46,qS=91,JS=93,YS=48,XS=57;function ZS(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===qS),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===KS||s===qS||s===JS){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==YS),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==JS&&(a!==-1||s!==JS)&&(a!==s||s!==KS&&s!==qS)&&n.push(``);r=o+1,i=!0}else(s<YS||s>XS)&&(i=!1);a=s}return n.length||n.push(``),n}function QS(e){return!(Array.isArray(e)&&e.length===0)}function $S(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function eC(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var tC=e=>!!e&&typeof e==`object`&&`fields`in e;function nC(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!nC(e[i],t[i]))return!1;return!0}var rC=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},iC=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function aC(e,t){return e==null?t:{...e,...t}}for(var oC=256,sC=[],cC;oC--;)sC[oC]=(oC+256).toString(16).substring(1);function lC(){let e=0,t,n=``;if(!cC||oC+16>256){for(cC=Array(256),e=256;e--;)cC[e]=256*Math.random()|0;e=0,oC=0}for(;e<16;e++)t=cC[oC+e],n+=e===6?sC[t&15|64]:e===8?sC[t&63|128]:sC[t],e&1&&e>1&&e<11&&(n+=`-`);return oC++,n}var uC=zS(e=>VS.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function dC(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=dC(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,dC(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(dC(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=dC(e[n]));return t}function fC(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var pC=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function mC(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var hC=(e,t)=>{let n=mC(e,t);return{form:n,fields:n}},gC={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:hC(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:hC(r.issues,e)}},_C=e=>!!e&&`~standard`in e,vC={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function yC(e){function t(t){let n=e.getFieldMeta(t)??vC;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>vC;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function bC(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var xC=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{uC(this)}),t=VS.on(`request-form-state`,e=>{e.payload.id===this._formId&&VS.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=VS.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=VS.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),VS.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return VS.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!nC(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!nC(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(AS(()=>{this.baseStore.setState(()=>bC(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=yC(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}VS.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=WS(t,e.instance.name,e.instance.options.defaultValue))}),bC({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return AS(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return AS(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=$S(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||pC}),r=!1,i={};return AS(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=SC(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=CC(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??vC,r=a?.[e],{newErrorValue:s,newSource:c}=rC({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=vC)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=CC(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=CC(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=eC(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||pC});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=CC(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=SC(r);s&&(i=i?{...i,...s}:s);let c=CC(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??vC,r=i?.[e],{newErrorValue:a,newSource:o}=rC({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=vC)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),AS(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),VS.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),VS.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}AS(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),AS(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),VS.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),VS.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>US(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:HS(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=vC,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;AS(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:WS(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t!==n&&t.startsWith(n)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=GS(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),yC(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],aC(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),yC(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),aC(r,{dontValidate:!0})),yC(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),aC(n,{dontValidate:!0})),yC(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return WS(WS(e,`${t}`,i),`${n}`,r)},aC(r,{dontValidate:!0})),yC(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},aC(r,{dontValidate:!0})),yC(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],aC(t,{dontValidate:!0})),yC(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=US(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:vC},values:i===void 0?t.values:WS(t.values,e,i)}})},this.setErrorMap=e=>{AS(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(tC(t)){let{formError:e,fieldErrors:r}=SC(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>gC.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>gC.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??lC(),this._devtoolsSubmissionOverride=!1;let t=bC({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!tC(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=LS(t);let n;this.fieldMetaDerived=LS(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=US(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!QS(u),f=!o.isDirty,p=nC(l,this.getFieldInfo(a)?.instance?.options.defaultValue??US(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=LS(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!fC(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&fC(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=LS(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&tC(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&nC(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return _C(e.validate)?gC[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function SC(e){return e?tC(e)?{formError:SC(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function CC(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var wC=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...vC,isTouched:e.fieldMetaBase[this.name]?.isTouched??vC.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??vC.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??vC.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(nC(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,aC(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,aC(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,aC(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,aC(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,aC(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,aC(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,aC(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,aC(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=$S(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||pC}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=$S(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||pC});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;AS(()=>{let e=(e,n)=>{let r=EC(n.cause),a=n.validate?TC(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=iC({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=EC(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=eC(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||pC}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=eC(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||pC});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));AS(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=EC(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=TC(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=iC({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),AS(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>fC(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[EC(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[EC(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>gC.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>gC.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)fC(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=LS(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...vC,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!nC(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return _C(e.validate)?gC[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function TC(e){if(e)return e}function EC(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function DC(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function OC(e){return{...vC,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var kC=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??DC({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(nC(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...vC,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??DC({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;jC(t)&&(n=t.group,r=t.fields);let i=AC(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:DC({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,aC(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof wC&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&fC(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=rC({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=vC)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=$S(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||pC}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=$S(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||pC});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;AS(()=>{let t=(t,r)=>{let i=NC(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&jC(s)&&(c=s.group,l=s.fields);let u=AC(c),d=n[i],{newErrorValue:f,newSource:p}=iC({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=NC(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=eC(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||pC}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=eC(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||pC});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=NC(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&jC(o)&&(l=o.group,u=o.fields);let d=AC(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=iC({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return AS(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>fC(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[NC(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>fC(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),AS(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}AS(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),AS(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=LS(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??OC(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!nC(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(_C(e.validate)){let t=gC[e.type](e.value,e.validate);return e.type===`validate`?MC(t):t.then(MC)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function AC(e){if(e)return e}function jC(e){return!!e&&typeof e==`object`&&`fields`in e}function MC(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function NC(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function PC(e,t){if(!t)return;let n=Object.assign({},e,{state:dC(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return AS(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}function FC(e,t){return e===t}function IC(e,t=e=>e,n){let r=n?.compare??FC,i=(0,Y.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Y.useCallback)(()=>e.get(),[e]);return(0,r_.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var LC=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function RC(e){let[t,n]=(0,Y.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,Y.useState)(()=>new wC({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new wC({...e}),i(a),n({form:e.form,name:e.name}));let o=IC(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=IC(a.store,e=>e.meta.isTouched),c=IC(a.store,e=>e.meta.isBlurred),l=IC(a.store,e=>e.meta.isDirty),u=IC(a.store,e=>e.meta.errorMap),d=IC(a.store,e=>e.meta.errorSourceMap),f=IC(a.store,e=>e.meta.isValidating),p=(0,Y.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return LC(a.mount,[a]),LC(()=>{a.update(e)}),p}var zC=(({children:e,...t})=>{let n=RC(t),r=(0,Y.useMemo)(()=>HS(e,n),[e,n]);return(0,$.jsx)($.Fragment,{children:r})});function BC(){return(0,Y.useState)(()=>lC())[0]}var VC=Y,HC=`18.3.1`.split(`.`)[0]===`17`?BC:VC.useId;function UC(e){let[t,n]=(0,Y.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,Y.useState)(()=>new kC({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new kC({...e})),n({form:e.form,name:e.name}));let a=IC(r.store,e=>e.value),o=IC(r.store,e=>e.meta.isTouched),s=IC(r.store,e=>e.meta.isBlurred),c=IC(r.store,e=>e.meta.isDirty),l=IC(r.store,e=>e.meta.errorMap),u=IC(r.store,e=>e.meta.errorSourceMap),d=IC(r.store,e=>e.meta.isValidating),f=IC(r.store,e=>e.meta.isSubmitting),p=IC(r.store,e=>e.meta.isSubmitted),m=IC(r.store,e=>e.meta.submissionAttempts),h=IC(r.store,e=>e.meta.isSubmitSuccessful),g=IC(r.store,e=>e.meta.canSubmit),_=IC(r.store,e=>e.meta.isValid),v=IC(r.store,e=>e.meta.isFieldsValid),y=IC(r.store,e=>e.meta.isFieldsValidating),b=IC(r.store,e=>e.meta.isGroupValid),x=(0,Y.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return LC(r.mount,[r]),LC(()=>{r.update(e)}),x}var WC=(({children:e,...t})=>{let n=UC(t),r=(0,Y.useMemo)(()=>HS(e,n),[e,n]);return(0,$.jsx)($.Fragment,{children:r})});function GC({form:e,selector:t=e=>e,children:n}){let r=IC(e.store,t);return(0,$.jsx)($.Fragment,{children:HS(n,r)})}function KC(e){let t=HC(),[n,r]=(0,Y.useState)(e?.formId),[i,a]=(0,Y.useState)(()=>new xC({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new xC({...e,formId:n})),r(n)}let o=(0,Y.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,$.jsx)(zC,{...e,form:i})},e.FormGroup=function(e){return(0,$.jsx)(WC,{...e,form:i})},e.Subscribe=function(e){return(0,$.jsx)(GC,{form:i,selector:e.selector,children:e.children})},e},[i]);LC(i.mount,[]),LC(()=>{i.update(e)});let s=(0,Y.useRef)(!1);return LC(()=>{s.current&&e?.transform&&PC(i,e.transform)},[i,e?.transform]),LC(()=>{s.current=!0}),o}var qC=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,$.jsx)(`input`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:J(`input caps-input w-full`,e),ref:r})});(0,Y.forwardRef)(function({leading:e,className:t,...n},r){return(0,$.jsxs)(`span`,{className:`caps-search-input`,"data-leading":e?`true`:void 0,children:[e?(0,$.jsx)(`span`,{className:`caps-search-leading`,"aria-hidden":`true`,children:e}):null,(0,$.jsx)(qC,{...n,type:`search`,className:t,ref:r})]})});function JC(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var YC=e=>{switch(e){case`success`:return QC;case`info`:return ew;case`warning`:return $C;case`error`:return tw;default:return null}},XC=Array(12).fill(0),ZC=({visible:e,className:t})=>Y.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},Y.createElement(`div`,{className:`sonner-spinner`},XC.map((e,t)=>Y.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),QC=Y.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},Y.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),$C=Y.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},Y.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),ew=Y.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},Y.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),tw=Y.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},Y.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),nw=Y.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},Y.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),Y.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),rw=()=>{let[e,t]=Y.useState(document.hidden);return Y.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},iw=1,aw=100,ow=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:iw++,sw=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-aw;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=ow(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],Y.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(lw(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!Y.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!Y.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!Y.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!Y.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=ow(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},cw=(e,t)=>sw.message(e,t),lw=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,uw=Object.assign(cw,{success:sw.success,info:sw.info,warning:sw.warning,error:sw.error,custom:sw.custom,message:sw.message,promise:sw.promise,dismiss:sw.dismiss,loading:sw.loading},{getHistory:()=>sw.toasts,getToasts:()=>sw.getActiveToasts()});JC(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function dw(e){return e.label!==void 0}var fw=3,pw=`24px`,mw=`16px`,hw=4e3,gw=356,_w=14,vw=45,yw=200;function bw(...e){return e.filter(Boolean).join(` `)}function xw(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Sw=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=Y.useState(null),[O,k]=Y.useState(null),[A,j]=Y.useState(!1),[M,N]=Y.useState(!1),[P,F]=Y.useState(!1),[I,L]=Y.useState(!1),[R,z]=Y.useState(!1),[B,ee]=Y.useState(0),[V,te]=Y.useState(0),ne=Y.useRef(n.duration||y||hw),H=Y.useRef(null),U=Y.useRef(null),re=c===0,W=c+1<=o,ie=n.type,ae=ie??`default`,G=n.dismissible!==!1,oe=n.className||``,se=n.descriptionClassName||``,ce=Y.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),le=Y.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ue=Y.useMemo(()=>n.duration||y||hw,[n.duration,y]),K=Y.useRef(0),de=Y.useRef(0),fe=Y.useRef(0),pe=Y.useRef(null),[me,he]=b.split(`-`),ge=Y.useMemo(()=>s.reduce((e,t,n)=>n>=ce?e:e+t.height,0),[s,ce]),_e=rw(),ve=Y.useMemo(()=>e.swipeDirections??xw(b),[e.swipeDirections,b]),q=n.invert||t,ye=ie===`loading`;de.current=Y.useMemo(()=>ce*x+ge,[ce,ge]),Y.useEffect(()=>{ne.current=ue},[ue]),Y.useEffect(()=>{j(!0)},[]),Y.useEffect(()=>{let e=U.current;if(e){let t=e.getBoundingClientRect().height;return te(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),Y.useLayoutEffect(()=>{if(!A)return;let e=U.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,te(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let be=Y.useCallback(()=>{N(!0),ee(de.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},yw)},[n,d,a,de]);Y.useEffect(()=>{if(n.promise&&ie===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||_e?(()=>{if(fe.current<K.current){let e=new Date().getTime()-K.current;ne.current-=e}fe.current=new Date().getTime()})():ne.current!==1/0&&(K.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),be()},ne.current)),()=>clearTimeout(e)},[u,i,n,ie,_e,be]),Y.useEffect(()=>{n.delete&&(be(),n.onDismiss==null||n.onDismiss.call(n,n))},[be,n.delete]);function xe(){return w?.loading?Y.createElement(`div`,{className:bw(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":ie===`loading`},w.loading):Y.createElement(ZC,{className:bw(C?.loader,n?.classNames?.loader),visible:ie===`loading`})}let Se=n.icon||w?.[ie]||YC(ie);return Y.createElement(`li`,{tabIndex:0,ref:U,className:bw(_,oe,C?.toast,n?.classNames?.toast,C?.[ae],n?.classNames?.[ae]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":R,"data-removed":M,"data-visible":W,"data-y-position":me,"data-x-position":he,"data-index":c,"data-front":re,"data-swiping":P,"data-dismissible":G,"data-type":ie,"data-invert":q,"data-swipe-out":I,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?B:de.current}px`,"--initial-height":S?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{F(!1),D(null),pe.current=null},onPointerDown:e=>{e.button!==2&&(ye||!G||(H.current=new Date,ee(de.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(F(!0),pe.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(I||!G)return;pe.current=null;let e=Number(U.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(U.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-H.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if((E===`x`?ve.includes(e>0?`right`:`left`):ve.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=vw||a>.11)){ee(de.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),be(),L(!0);return}var o,s;(o=U.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=U.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),z(!1),F(!1),D(null)},onPointerMove:e=>{var t,n;if(!pe.current||!G||window.getSelection()?.toString().length>0)return;let r=e.clientY-pe.current.y,i=e.clientX-pe.current.x;!E&&(Math.abs(i)>1||Math.abs(r)>1)&&D(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(ve.includes(`top`)||ve.includes(`bottom`)){if(ve.includes(`top`)&&r<0||ve.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(E===`x`&&(ve.includes(`left`)||ve.includes(`right`))){if(ve.includes(`left`)&&i<0||ve.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&z(!0),(t=U.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=U.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},le&&!n.jsx&&ie!==`loading`?Y.createElement(`button`,{"aria-label":T,"data-disabled":ye,"data-close-button":!0,onClick:ye||!G?()=>{}:()=>{be(),n.onDismiss==null||n.onDismiss.call(n,n)},className:bw(C?.closeButton,n?.classNames?.closeButton)},w?.close??nw):null,(ie||n.icon||n.promise)&&n.icon!==null&&(w?.[ie]!==null||n.icon)?Y.createElement(`div`,{"data-icon":``,className:bw(C?.icon,n?.classNames?.icon)},ie===`loading`?n.icon||xe():n.promise?xe():null,ie===`loading`?null:Se):null,Y.createElement(`div`,{"data-content":``,className:bw(C?.content,n?.classNames?.content)},Y.createElement(`div`,{"data-title":``,className:bw(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?Y.createElement(`div`,{"data-description":``,className:bw(v,se,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),Y.isValidElement(n.cancel)?n.cancel:n.cancel&&dw(n.cancel)?Y.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{dw(n.cancel)&&G&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),be())},className:bw(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,Y.isValidElement(n.action)?n.action:n.action&&dw(n.action)?Y.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{dw(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&be())},className:bw(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Cw(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function ww(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?mw:pw;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Tw=Y.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=fw,toastOptions:g,dir:_=Cw(),gap:v=_w,icons:y,customAriaLabel:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=Y.useState([]),w=Y.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=Y.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=Y.useState([]),[O,k]=Y.useState(!1),[A,j]=Y.useState(!1),[M,N]=Y.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),P=Y.useRef(null),F=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),I=Y.useRef(null),L=Y.useRef(!1),R=Y.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||sw.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return Y.useEffect(()=>sw.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Jh.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),Y.useEffect(()=>{if(d!==`system`){N(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?N(`dark`):N(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{N(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{N(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),Y.useEffect(()=>{S.length<=1&&k(!1)},[S]),Y.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=P.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===P.current||P.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),Y.useEffect(()=>{if(P.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,L.current=!1)}},[P.current]),Y.createElement(`section`,{ref:t,"aria-label":b??`${x} ${F}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?Y.createElement(`ol`,{key:t,dir:_===`auto`?Cw():_,tabIndex:-1,ref:P,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${gw}px`,"--gap":`${v}px`,...m,...ww(l,u)},onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,I.current&&=(I.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||L.current||(L.current=!0,I.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>Y.createElement(Sw,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:R,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:v,expanded:O,swipeDirections:e.swipeDirections}))):null}))});function Ew({className:e,...t}){let n=My(`toast`);return n?(0,Jh.createPortal)((0,$.jsx)(Tw,{position:`top-right`,swipeDirections:[`right`,`top`],offset:16,gap:8,icons:{close:(0,$.jsx)(Tr,{"aria-hidden":`true`,size:12}),success:(0,$.jsx)(eb,{glyph:`dot`,tone:`success`}),error:(0,$.jsx)(eb,{glyph:`dot`,tone:`error`}),warning:(0,$.jsx)(eb,{glyph:`dot`,tone:`warning`}),info:(0,$.jsx)(eb,{glyph:`dot`,tone:`info`}),loading:(0,$.jsx)(Sr,{decorative:!0,size:`sm`,tone:`current`,variant:`wander`})},className:J(`caps-toaster`,e),...t}),n):null}var Dw=(0,Y.forwardRef)(function({children:e,className:t,optional:n,required:r,...i},a){return(0,$.jsxs)(`label`,{...i,className:J(`label caps-label cursor-pointer justify-start gap-sm text-sm font-semibold text-base-content`,t),ref:a,children:[e,r?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`text-error`,children:`*`}):null,n&&!r?(0,$.jsx)(`span`,{className:`caps-label-optional`,children:`Optional`}):null]})}),Ow=(0,Y.forwardRef)(function({children:e,className:t,...n},r){return(0,$.jsx)(`div`,{...n,className:J(`caps-input-group join flex w-full items-stretch [&>*]:join-item [&>*:first-child]:rounded-e-none [&>*:last-child]:rounded-s-none [&>*:not(:first-child):not(:last-child)]:rounded-none [&>.btn]:shrink-0 [&>.input]:min-w-0 [&>.input]:flex-1 [&>.select]:min-w-0 [&>.select]:flex-1`,t),ref:r,children:Y.Children.map(e,e=>(0,Y.isValidElement)(e)?(0,Y.cloneElement)(e,{className:J(`join-item caps-input-group-control`,e.props.className)}):e)})}),kw=(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,className:J(`join-item flex items-center border border-base-300 bg-base-200 px-md text-sm text-base-content`,e),ref:n})});function Aw(e){let t=e.parentElement;if(!t||e.previousElementSibling===null)return 0;let n=getComputedStyle(t);if(!(n.display.includes(`grid`)||n.display.includes(`flex`)&&n.flexDirection.startsWith(`column`)))return 0;let r=Number.parseFloat(n.rowGap);return Number.isFinite(r)?r:0}(0,Y.forwardRef)(function({show:e,appear:t=!1,children:n,className:r,...i},a){let o=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(a,()=>o.current);let s=ai(),[c,l]=(0,Y.useState)(e),u=(0,Y.useRef)(!0);return e&&!c&&l(!0),(0,Y.useLayoutEffect)(()=>{let n=o.current,r=u.current;if(u.current=!1,!n||r&&!t)return;if(!kr(n)){e||l(!1);return}let i=si(n),a=`translateY(${String(i.distance)}px)`,c=_r(i,i.ease),d=n.getBoundingClientRect().height,f=Aw(n),p=(e,t)=>{n.style.overflow=`clip`;let r=e=>({height:`${String(e)}px`,marginBlockStart:`${String(e===0?-f:0)}px`}),a=n.animate([r(e),r(t)],{duration:i.normal,easing:c}),o=()=>{n.style.removeProperty(`overflow`)};return a.addEventListener(`finish`,o),a.addEventListener(`cancel`,o),a};if(e){let e=[n.animate([{opacity:0,transform:a},{opacity:1,transform:`none`}],{duration:i.normal,easing:c})];return!s&&d>0&&e.push(p(0,d)),()=>{for(let t of e)t.cancel()}}let m=n.animate([{opacity:1,transform:`none`},{opacity:0,transform:a}],{duration:i.fast,easing:_r(i,i.easeExit),fill:`forwards`}),h=!s&&d>0?p(d,0):m;return h!==m&&h.effect?.updateTiming({fill:`forwards`}),h.addEventListener(`finish`,()=>{l(!1)}),()=>{m.cancel(),h.cancel()}},[e,t,s]),c?(0,$.jsx)(`div`,{...i,ref:o,className:J(`caps-presence`,r),"data-present":e,"aria-hidden":!e||void 0,children:n}):null});var jw=(0,Y.forwardRef)(function({open:e,children:t,className:n,...r},i){return(0,$.jsx)(`div`,{...r,ref:i,className:J(`caps-collapse`,n),"data-open":e,"aria-hidden":!e||void 0,children:(0,$.jsx)(`div`,{className:`caps-collapse-clip`,children:t})})});(0,Y.forwardRef)(function({swapKey:e,anchor:t=`start`,children:n,className:r,...i},a){let o=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(a,()=>o.current);let s=ai(),[c,l]=(0,Y.useState)({key:e,content:n}),[u,d]=(0,Y.useState)([]);c.key===e?c.content!==n&&l({key:e,content:n}):(d([...u.filter(t=>t.key!==e&&t.key!==c.key),c]),l({key:e,content:n}));let f=(0,Y.useRef)(null);return(0,Y.useLayoutEffect)(()=>{let e=o.current;if(!e||!(`ResizeObserver`in globalThis))return;f.current=e.getBoundingClientRect();let t=new ResizeObserver(()=>{e.getAnimations().length===0&&(f.current=e.getBoundingClientRect())});return t.observe(e),()=>{t.disconnect()}},[]),(0,Y.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=[...e.querySelectorAll(`:scope > [data-swap-leaving]`)],n=e.querySelector(`:scope > [data-swap-current]`);if(n===null||t.length===0)return;if(!kr(e)){d([]);return}let r=f.current,i=e.getBoundingClientRect(),a=si(e),c=[n.animate([{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(a.distance/2)}px)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:a.normal,easing:_r(a,a.ease)})];for(let e of t){let t=e.animate([{opacity:1,filter:`blur(0px)`,transform:`none`},{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(-a.distance/2)}px)`}],{duration:a.fast,easing:_r(a,a.easeExit),fill:`forwards`}),n=e.dataset.swapLeaving;t.onfinish=()=>{d(e=>e.filter(e=>e.key!==n))},c.push(t)}let l=r!==null&&(Math.abs(r.height-i.height)>.5||Math.abs(r.width-i.width)>.5);return!s&&l&&c.push(e.animate([{width:`${String(r.width)}px`,height:`${String(r.height)}px`},{width:`${String(i.width)}px`,height:`${String(i.height)}px`}],{duration:a.normal,easing:_r(a,a.ease)})),()=>{for(let e of c)e.cancel()}},[e,s]),(0,$.jsx)(`div`,{...i,ref:o,className:J(`caps-swap`,r),"data-anchor":t,children:[...u.map(e=>(0,$.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-leaving":e.key,"aria-hidden":`true`,children:e.content},e.key)),(0,$.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-current":``,children:n},e)]})});function Mw({children:e,...t}){let[n,r]=(0,Y.useState)(e);return e&&e!==n&&r(e),(0,$.jsx)(jw,{...t,className:J(`caps-field-error-reveal`,t.className),open:!!e,children:(0,$.jsx)(`div`,{className:`caps-field-error`,role:`alert`,"aria-hidden":!e,children:n})})}function Nw({children:e,divider:t=!0,error:n,layout:r=`end`,status:i,...a}){return(0,$.jsxs)(`footer`,{...a,className:J(`caps-form-footer`,a.className),"data-divider":t,"data-layout":r,children:[(0,$.jsx)(Mw,{children:n}),(0,$.jsxs)(`div`,{className:`caps-form-footer-row`,children:[i?(0,$.jsx)(`div`,{className:`caps-form-footer-status`,role:`status`,children:i}):null,(0,$.jsx)(`div`,{className:`caps-form-footer-actions`,children:e})]})]})}var Pw=(0,Y.forwardRef)(function({busy:e=!1,children:t,className:n,layout:r,...i},a){return(0,$.jsx)(`form`,{...i,"aria-busy":e||void 0,className:J(`caps-form`,n),"data-layout":r,ref:a,children:(0,$.jsx)(`fieldset`,{className:`caps-form-body`,disabled:e,children:t})})}),Fw={2:`h2`,3:`h3`,4:`h4`},Iw=(0,Y.forwardRef)(function({children:e,className:t,description:n,layout:r,level:i=3,title:a,...o},s){let c=(0,Y.useId)(),l=Fw[i];return(0,$.jsxs)(`section`,{...o,"aria-labelledby":`${c}-title`,className:J(`caps-form-section`,t),"data-layout":r,ref:s,children:[(0,$.jsxs)(`header`,{className:`caps-form-section-copy`,children:[(0,$.jsx)(l,{className:`caps-form-section-title`,id:`${c}-title`,children:a}),n?(0,$.jsx)(`p`,{className:`caps-form-section-description`,children:n}):null]}),(0,$.jsx)(`div`,{className:`caps-form-section-fields`,children:e})]})}),Lw=(0,Y.forwardRef)(function({children:e,className:t,description:n,error:r,icon:i,layout:a,legend:o,legendTitle:s,...c},l){let u=(0,Y.useId)(),d=[n?`${u}-description`:c[`aria-describedby`],r?`${u}-error`:null].filter(Boolean).join(` `)||void 0;return(0,$.jsxs)(`fieldset`,{...c,"aria-describedby":d,"aria-invalid":r?!0:c[`aria-invalid`],className:J(`caps-fieldset`,t),"data-layout":a,ref:l,children:[(0,$.jsxs)(`legend`,{className:`caps-fieldset-legend`,title:s,children:[i?(0,$.jsx)(`span`,{className:`caps-field-icon`,"aria-hidden":`true`,children:i}):null,o]}),n?(0,$.jsx)(`p`,{className:`caps-fieldset-description`,id:`${u}-description`,children:n}):null,(0,$.jsx)(`div`,{className:`caps-fieldset-fields`,children:e}),r===void 0?null:(0,$.jsx)(Mw,{id:`${u}-error`,children:r})]})});function Rw(e){let t=[];return Y.Children.forEach(e.props.children,e=>{(0,Y.isValidElement)(e)&&e.type!==kw&&t.push(e)}),t[0]??null}var zw=(0,Y.forwardRef)(function({children:e,className:t,description:n,error:r,icon:i,label:a,labelTitle:o,optional:s,orientation:c=`vertical`,readout:l=!1,required:u,...d},f){let p=(0,Y.useId)(),m=(0,Y.isValidElement)(e)?e:null,h=m?.type===Ow,g=h?Rw(m):m,_=g?.props.id??p,v=`${_}-description`,y=`${_}-error`,b=[g?.props[`aria-describedby`],n?v:null,r?y:null].filter(Boolean).join(` `)||void 0,x=u===!0||g?.props.required,S=r?!0:g?.props[`aria-invalid`],C=u===!0||g?.props[`aria-required`],w={id:_};x!==void 0&&(w.required=x),b!==void 0&&(w[`aria-describedby`]=b),S!==void 0&&(w[`aria-invalid`]=S),C!==void 0&&(w[`aria-required`]=C);let T=m&&g&&!l?h?(0,Y.cloneElement)(m,void 0,Y.Children.map(m.props.children,e=>e===g?(0,Y.cloneElement)(g,w):e)):(0,Y.cloneElement)(m,w):e,E=a?(0,$.jsx)(Dw,{htmlFor:l?void 0:_,title:o,className:c===`inline`?`font-normal`:void 0,...u===void 0?{}:{required:u},...s===void 0?{}:{optional:s},children:a}):null,D=a||n?(0,$.jsxs)(`div`,{className:`caps-field-copy`,children:[E,n?(0,$.jsx)(`p`,{className:`caps-field-description`,id:v,children:n}):null]}):null,O=i?(0,$.jsxs)(`div`,{className:`caps-field-lead`,children:[(0,$.jsx)(`span`,{className:`caps-field-icon`,"aria-hidden":`true`,children:i}),D]}):D;return(0,$.jsxs)(`div`,{...d,className:J(`caps-field`,t),"data-orientation":c,ref:f,children:[c===`horizontal`?(0,$.jsxs)(`div`,{className:`caps-field-row`,children:[O,T]}):c===`inline`?(0,$.jsxs)(`div`,{className:`caps-field-row`,children:[T,O]}):(0,$.jsxs)($.Fragment,{children:[O,T]}),(0,$.jsx)(Mw,{id:y,children:r})]})});function Bw(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}var Vw=`M 9.86 38.14 A 20 20 0 1 1 38.14 38.14`,Hw=6,Uw=new Map([[`ArrowUp`,1],[`ArrowDown`,-1],[`PageUp`,10],[`PageDown`,-10]]),Ww=(0,Y.forwardRef)(function({className:e,decrementLabel:t=`Decrease`,defaultValue:n=null,disabled:r,incrementLabel:i=`Increase`,invalid:a,max:o,min:s,onBlur:c,onKeyDown:l,onValueChange:u,step:d=1,unit:f,value:p,wrap:m=!1,...h},g){let[_,v]=(0,Y.useState)(n),[y,b]=(0,Y.useState)(null),x=p===void 0?_:p,S=Bw(d),C=e=>{let t=Number(e.toFixed(S));return s!==void 0&&t<s?s:o!==void 0&&t>o?o:t},w=e=>{let t=e===null?null:C(e);v(t),b(null),t!==x&&u?.(t)},T=()=>{if(y===null)return;let e=Number(y);w(y.trim()===``||!Number.isFinite(e)?null:e)},E=e=>{let t=(x??s??0)+e*d;if(m&&s!==void 0&&o!==void 0){if(t>o){w(s);return}if(t<s){w(o);return}}w(t)},D=s!==void 0&&x!==null&&x<=s,O=o!==void 0&&x!==null&&x>=o,k=r===!0,A=(0,Y.useRef)(null),j=s!==void 0&&o!==void 0&&o>s?((x??s)-s)/(o-s):null,M=e=>{k||(e.currentTarget.setPointerCapture(e.pointerId),A.current={y:e.clientY,value:x??s??0})},N=e=>{if(!A.current)return;let t=Math.trunc((A.current.y-e.clientY)/Hw),n=C(A.current.value+t*d);n!==x&&w(n)},P=()=>{A.current=null};return(0,$.jsxs)(`span`,{className:J(`caps-number-field`,e),"data-at-max":O||void 0,"data-at-min":D||void 0,"data-disabled":k||void 0,"data-wrap":m||void 0,children:[j===null?null:(0,$.jsxs)(`svg`,{className:`caps-number-field-dial`,viewBox:`0 0 48 48`,"aria-hidden":`true`,focusable:`false`,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:P,children:[(0,$.jsx)(`path`,{className:`caps-number-field-dial-track`,d:Vw,pathLength:100}),(0,$.jsx)(`path`,{className:`caps-number-field-dial-level`,d:Vw,pathLength:100,strokeDasharray:`${String(Math.max(.5,j*100))} 100`})]}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-decrement`,"aria-label":t,"aria-controls":h.id,tabIndex:-1,disabled:k||D&&!m,onClick:()=>{E(-1)},children:(0,$.jsx)(mx,{"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`caps-number-field-readout`,children:[(0,$.jsx)(`input`,{...h,"aria-invalid":a?!0:h[`aria-invalid`]===!1?void 0:h[`aria-invalid`],className:`input caps-input caps-number-field-input`,disabled:r,inputMode:h.inputMode??(S>0?`decimal`:`numeric`),max:o,min:s,onBlur:e=>{T(),c?.(e)},onChange:e=>{b(e.target.value)},onKeyDown:e=>{if(l?.(e),e.defaultPrevented)return;let t=Uw.get(e.key);t===void 0?e.key===`Home`&&s!==void 0?(e.preventDefault(),w(s)):e.key===`End`&&o!==void 0?(e.preventDefault(),w(o)):e.key===`Enter`&&T():(e.preventDefault(),E(t))},ref:g,step:d,type:`number`,value:y??(x===null?``:String(x))}),f?(0,$.jsx)(`span`,{className:`caps-number-field-unit`,"aria-hidden":`true`,children:f}):null]}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-increment`,"aria-label":i,"aria-controls":h.id,tabIndex:-1,disabled:k||O&&!m,onClick:()=>{E(1)},children:(0,$.jsx)(hx,{"aria-hidden":`true`})})]})}),Gw=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,$.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,$.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:J(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,$.jsx)(ax,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})}),Kw={2:`h2`,3:`h3`,4:`h4`};function qw(e,t){let{reduced:n}=t,r=e&&!n,i=ti(t,600),[a,o]=(0,Y.useState)(r);return(0,Y.useEffect)(()=>{if(o(r),!r)return;let e=globalThis.setTimeout(()=>{o(!1)},i);return()=>{globalThis.clearTimeout(e)}},[r,i]),a}var Jw=(0,$.jsx)(Sr,{decorative:!0,pace:`idle`,size:`md`,tone:`primary`,variant:`wander`}),Yw=(0,Y.forwardRef)(function({actions:e,className:t,description:n,headingLevel:r=2,primaryAction:i,suggestions:a,thinking:o=!1,title:s,visual:c,renderVisual:l,variant:u=`plain`,...d},f){let p=(0,Y.useId)(),m=(0,Y.useRef)(null),h=xr(m),g=qw(u===`speech`,h)&&!o,_=Kw[r],v=c??(u===`panel`?`blobs`:void 0),y=l?l({speaking:g,thinking:o}):v===`blobs`?Jw:v,b=`${p}-reason`,x=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{ref:m,className:`empty-state-title`,id:d[`aria-labelledby`]?void 0:p,children:s}),(0,$.jsx)(`p`,{children:n}),i?(0,$.jsxs)(`div`,{className:`empty-state-primary`,children:[(0,$.jsx)(Xr,{"aria-describedby":i.disabled&&i.disabledReason?b:void 0,disabled:i.disabled,loading:i.pending===!0,onClick:i.onSelect,variant:`primary`,children:i.label}),i.disabled&&i.disabledReason?(0,$.jsx)(`span`,{className:`empty-state-reason`,id:b,children:i.disabledReason}):null]}):null,a&&a.length>0?(0,$.jsx)(`ul`,{"aria-label":`Try one of these`,className:`empty-state-suggestions`,children:a.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsx)(Xr,{disabled:e.disabled,loading:e.pending===!0,size:`sm`,variant:`outline`,onClick:e.onSelect,children:e.label})},`${String(t)}:${e.label}`))}):null,e?(0,$.jsx)(`div`,{className:`empty-state-actions`,children:e}):null]});return(0,$.jsxs)(`section`,{...d,"aria-labelledby":d[`aria-labelledby`]??p,className:J(`empty-state`,u!==`plain`&&`empty-state-${u}`,t),ref:f,children:[y?(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`empty-state-visual`,children:y}):null,u===`speech`?(0,$.jsx)(`div`,{className:`empty-state-bubble`,children:x}):x]})}),Xw=8e3,Zw=(0,Y.forwardRef)(function({className:e,detail:t,framed:n=!0,icon:r,message:i,onRetry:a,size:o=`md`,slowAfterMs:s=Xw,variant:c=`line`,...l},u){let[d,f]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(f(!1),!Number.isFinite(s))return;let e=globalThis.setTimeout(()=>{f(!0)},s);return()=>{globalThis.clearTimeout(e)}},[s,i]),(0,$.jsxs)(`div`,{...l,className:J(`caps-loading-state`,e),"data-framed":n?void 0:`false`,"data-icon":r?``:void 0,"data-size":o,"data-slow":d||void 0,ref:u,role:`status`,children:[r?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`caps-loading-state-icon`,children:r}):null,(0,$.jsx)(Sr,{decorative:!0,size:o,variant:c}),(0,$.jsxs)(`span`,{className:`caps-loading-state-copy`,children:[(0,$.jsx)(`span`,{children:i}),t?(0,$.jsx)(`span`,{className:`caps-loading-state-detail`,children:t}):null,d?(0,$.jsx)(`span`,{className:`caps-loading-state-detail`,children:`Still working…`}):null]}),d&&a?(0,$.jsx)(Xr,{className:`caps-loading-state-retry`,size:`sm`,variant:`outline`,onClick:a,children:`Retry`}):null]})});function Qw(e,t){return{kind:`button`,id:`folder`,text:t.checking?`Checking…`:`prints`,icon:`folder`,title:e===null?`Choose where Prints saves images`:At(`Save prints to ${e}`,1024),opens:`dialog`,expanded:t.editing}}function $w(e,t=/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)){return e.startsWith(`<leader>`)?`Ctrl K ${e.slice(8)}`:e.split(` `).map(e=>e.split(`+`).map(e=>e===`mod`?t?`⌘`:`Ctrl`:e===`escape`?`Esc`:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join(e===`ctrl+k`||e===`mod+k`?` `:`+`)).join(` `)}function eT(e){let t=new Map;for(let n of e.bindings)t.set(n.commandId,[...t.get(n.commandId)??[],$w(n.binding)]);return e.slash.map(e=>({alias:e.alias,commandId:e.commandId,command:e.command,title:e.title,description:e.description,category:e.category,order:e.order,grammar:e.arguments,consumesDraft:e.consumesDraft,keys:t.get(e.commandId)??[],availability:e.availability}))}function tT(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();if(r.length===0)return{tier:0,spread:0,indices:[]};let i=e=>Array.from({length:r.length},(t,n)=>e+n);if(n.startsWith(r))return{tier:0,spread:n.length-r.length,indices:i(0)};let a=n.search(RegExp(`[-_\\s]${r.replaceAll(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}`,`u`));if(a>=0)return{tier:1,spread:a,indices:i(a+1)};let o=n.indexOf(r);if(o>=0)return{tier:2,spread:o,indices:i(o)};let s=[],c=0;for(let e of r){let t=n.indexOf(e,c);if(t<0)return;s.push(t),c=t+1}let l=s[0]??0;return{tier:3,spread:(s.at(-1)??0)-l-r.length+1,indices:s}}function nT(e,t,n,r){return e.map(e=>({entry:e,match:tT(t(e),n)})).filter(e=>e.match!==void 0).sort((e,n)=>e.match.tier-n.match.tier||e.match.spread-n.match.spread||r(e.entry)-r(n.entry)||t(e.entry).localeCompare(t(n.entry))).map(({entry:e,match:t})=>({entry:e,indices:t.indices}))}var rT=[`help`,`login`,`model`];function iT(e,t,n={}){if(!t.startsWith(`/`)||t.includes(`
|
|
10
|
-
`))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:nT(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||rT.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=rT.indexOf(e.alias);return r.length===0&&t>=0?t-rT.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}var aT=Du({keyCode:ku(229)});function oT(e){return e.nativeEvent.isComposing||je(aT,e.nativeEvent).success}function sT(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:_r(t,t.easeExit),fill:`backwards`})}function cT(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:_r(t,t.ease),fill:`backwards`})}function lT(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:_r(t,t.ease),fill:`backwards`})}function uT(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:_r(t,`ease-out`)})}var dT=(0,Y.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(u,()=>d.current);let f=(0,Y.useRef)(e);(0,Y.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!kr(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=si(t),o=[];return e===`busy`?o.push(sT(r,a),lT(i,a,1)):n===`busy`&&o.push(lT(i,a,0),cT(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(uT(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,$.jsx)(xt,{...l,ref:d,className:J(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,$.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,$.jsx)(`span`,{"data-glyph":`arrow`,children:(0,$.jsx)(ix,{"aria-hidden":`true`,size:r})}),(0,$.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,$.jsx)(Sr,{decorative:!0,size:`sm`}):(0,$.jsx)(_x,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),fT=(0,Y.forwardRef)(function({className:e,label:t,...n},r){return(0,$.jsx)(xt,{...n,ref:r,className:J(`parakeet-composer-model-key`,e),label:t,readout:(0,$.jsx)(ax,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),pT=(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,ref:n,className:J(`caps-popover-anchor`,e)})}),mT=(0,Y.forwardRef)(function({className:e,open:t,side:n=`top`,...r},i){return t?(0,$.jsx)(`div`,{...r,ref:i,className:J(`caps-popover`,e),"data-side":n}):null}),hT=(0,Y.forwardRef)(function({active:e,className:t,onMouseDown:n,...r},i){return(0,$.jsx)(`div`,{role:`option`,"aria-selected":e,...r,ref:i,className:J(`caps-popover-option`,t),"data-active":e,onMouseDown:e=>{e.preventDefault(),n?.(e)}})});function gT({items:e,openId:t,onOpenChange:n,leading:r,trailing:i,renderTrigger:a,placement:o=`housing`,align:s=`end`,hostInset:c,className:l,...u}){let d=(0,Y.useId)(),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(new Map),h=e.find(e=>e.id===t&&!e.disabled),g=h?.id,_=()=>{g&&m.current.get(g)?.focus(),n(null)};return(0,Y.useEffect)(()=>{g&&p.current?.focus()},[g]),(0,Y.useEffect)(()=>{c===void 0?f.current?.style.removeProperty(`--caps-status-tray-host-inset`):f.current?.style.setProperty(`--caps-status-tray-host-inset`,`${String(Math.max(0,c))}px`)},[c]),(0,Y.useEffect)(()=>{if(!g)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),m.current.get(g)?.focus(),n(null))},t=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&n(null)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[g,n]),(0,$.jsxs)(pT,{...u,ref:f,className:J(`caps-status-tray`,l),"data-placement":o,"data-align":s,children:[h?(0,$.jsxs)(mT,{open:!0,ref:p,tabIndex:-1,side:`top`,id:`${d}-${h.id}`,role:`dialog`,"aria-labelledby":`${d}-title`,className:`caps-status-tray-panel`,"data-status-tray-panel":h.id,children:[(0,$.jsxs)(`div`,{className:`caps-status-tray-head`,children:[h.tone?(0,$.jsx)(eb,{size:`compact`,tone:h.tone,glyph:h.glyph??`dot`}):null,(0,$.jsx)(`span`,{id:`${d}-title`,className:`caps-status-tray-title`,children:h.title??h.label}),h.actions,(0,$.jsx)(Wr,{"aria-label":`Close tray`,icon:(0,$.jsx)(Tr,{"aria-hidden":`true`}),onClick:_})]}),(0,$.jsx)(`div`,{className:`caps-status-tray-body`,children:h.content})]}):null,o===`host`?null:(0,$.jsxs)(`div`,{className:`caps-status-tray-row`,children:[r,(0,$.jsx)(`div`,{className:`caps-status-tray-chips`,children:e.map(e=>{let r={ref:t=>{t?m.current.set(e.id,t):m.current.delete(e.id)},type:`button`,className:a?void 0:`caps-status-tray-chip`,"aria-expanded":g===e.id,"aria-controls":g===e.id?`${d}-${e.id}`:void 0,"aria-label":e.accessibleLabel,disabled:e.disabled,title:e.disabled?e.accessibleLabel:void 0,"aria-haspopup":`dialog`,"data-status-tray-chip":e.id,onClick:()=>{n(t===e.id?null:e.id)},children:(0,$.jsxs)($.Fragment,{children:[e.tone?(0,$.jsx)(eb,{size:`compact`,glyph:e.glyph??`dot`,motion:e.motion??`none`,tone:e.tone}):null,(0,$.jsx)(`span`,{className:`caps-status-tray-label`,children:e.label}),e.count!==void 0&&e.count>0?(0,$.jsx)(`span`,{className:`caps-status-tray-count`,children:e.count}):null]})};return(0,$.jsxs)(Y.Fragment,{children:[a?a(r):(0,$.jsx)(`button`,{...r}),e.after]},e.id)})}),i]})]})}function _T({children:e,className:t,...n}){return(0,$.jsx)(`div`,{...n,className:J(`caps-status-tray-list`,t),children:e})}function vT({icon:e,primary:t,secondary:n,actions:r,className:i,...a}){return(0,$.jsxs)(`div`,{...a,className:J(`caps-status-tray-item`,i),children:[e?(0,$.jsx)(`span`,{className:`caps-status-tray-icon`,children:e}):null,(0,$.jsxs)(`span`,{className:`caps-status-tray-text`,children:[(0,$.jsx)(`span`,{className:`caps-status-tray-primary`,children:t}),n?(0,$.jsx)(`span`,{className:`caps-status-tray-secondary`,children:n}):null]}),r?(0,$.jsx)(`span`,{className:`caps-status-tray-actions`,children:r}):null]})}function yT({children:e=`All caught up.`,title:t}){return(0,$.jsxs)(`div`,{className:`caps-status-tray-note`,children:[t?(0,$.jsx)(`strong`,{className:`caps-status-tray-note-title`,children:t}):null,(0,$.jsx)(`p`,{children:e})]})}var bT=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,$.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:J(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})});function xT(e,t){return`${e}-${String(t)}`}function ST(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function CT(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?xT(e.listId,e.selected):void 0}}function wT({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,$.jsx)(mT,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,$.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,$.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,$.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,$.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,$.jsxs)(hT,{id:xT(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,$.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,$.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,$.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var TT={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},ET={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function DT({state:e}){let t=`caps-checkbox-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=ai();return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=si(n.current),c=Nr(s,{ease:`inCubic`,duration:160}),l=ui(n.current,{d:{to:TT[e],...o?Jr:Nr(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?Jr:t?Nr(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Nr(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:ti(s,120),...yr(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,$.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(Kr,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,$.jsx)(Dr,{id:`${t}-shadow`}),(0,$.jsx)(wr,{id:`${t}-inset`}),(0,$.jsx)($r,{id:`${t}-goo`,values:ET}),(0,$.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,$.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,$.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,$.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,$.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,$.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,$.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,$.jsx)(`path`,{ref:n,d:TT[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,$.jsx)(`clipPath`,{id:`${t}-well`,children:(0,$.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,$.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,$.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,$.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,$.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,$.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,$.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var OT=(0,Y.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,Y.useRef)(null),[d,f]=(0,Y.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,Y.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,Y.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,Y.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,$.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,$.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:J(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,$.jsx)(DT,{state:m}):n]})}),kT=`data-glide-stand-in`;function AT(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+e.scrollLeft-e.clientLeft,y:r.top-n.top+e.scrollTop-e.clientTop,width:r.width,height:r.height}}function jT(e){return{transform:`translate(${String(e.x)}px, ${String(e.y)}px)`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}}function MT(e){let t=(0,Y.useRef)(null);return(0,Y.useCallback)(n=>{t.current?.(),t.current=n?NT(n,e):null},[e])}function NT(e,t){if(!kr(e))return()=>void 0;let n=e.ownerDocument,r=e.querySelector(t),i=r?AT(e,r):null,a=null,o=null,s=new Set,c=()=>{for(let e of s)e.removeAttribute(kT);s.clear(),a&&(a.hidden=!0),o=null},l=()=>{if(a)return a;let t=n.createElement(`span`);return t.className=`caps-glide`,t.setAttribute(`aria-hidden`,`true`),e.prepend(t),e.classList.add(`caps-glide-host`),getComputedStyle(e).position===`static`&&e.classList.add(`caps-glide-anchor`),a=t,t},u=(t,n)=>{let r=si(e),u=AT(e,t),d=o&&a?AT(e,a):i;if(i=u,o?.cancel(),c(),r.reduced||d===null||Math.abs(d.y-u.y)<1&&Math.abs(d.x-u.x)<1)return;t.setAttribute(kT,`measure`);let f=getComputedStyle(t),p=f.backgroundColor,m=f.borderRadius;for(let e of[t,n])e&&(e.setAttribute(kT,``),s.add(e));let h=l();h.hidden=!1,h.style.backgroundColor=p,h.style.borderRadius=m;let g=h.animate([jT(d),jT(u)],{duration:r.normal,easing:_r(r,r.ease),fill:`forwards`});o=g,g.addEventListener(`finish`,()=>{o===g&&c()})},d=()=>{let n=e.querySelector(t);if(n===r)return;let i=r;r=n,n&&u(n,i)},f=new MutationObserver(d);return f.observe(e,{subtree:!0,attributes:!0,attributeFilter:[`data-highlighted`,`data-active`,`data-navigation`,`aria-selected`]}),e.addEventListener(`pointerover`,d),e.addEventListener(`pointerout`,d),()=>{f.disconnect(),e.removeEventListener(`pointerover`,d),e.removeEventListener(`pointerout`,d),o?.cancel(),c(),a?.remove()}}function PT({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,Y.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}function FT({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Y.useRef(e!==void 0),[a,o]=Y.useState(()=>t);return[i&&e!==void 0?e:a,Y.useCallback(e=>{i||o(e)},[])]}var IT=Pn(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),LT=(0,Y.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,$.jsx)(`div`,{...a,className:J(IT({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,Y.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,$.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,$.jsx)(LT,{...i,className:J(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,Y.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,$.jsx)(`div`,{...n,className:J(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,Y.forwardRef)(function({className:e,level:t=3,...n},r){return(0,$.jsx)(t===2?`h2`:`h3`,{...n,className:J(`caps-card-title`,e),ref:r})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`p`,{...t,className:J(`caps-card-description`,e),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,className:J(`caps-card-content`,e),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,className:J(`caps-card-footer`,e),ref:n})});var RT=(0,Y.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,$.jsxs)(`div`,{...a,ref:o,className:J(`caps-composer`,n),children:[t===void 0?null:(0,$.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,$.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,$.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,$.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function zT({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function BT({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,$.jsxs)(pT,{className:`parakeet-composer-anchor`,children:[a,(0,$.jsxs)(LT,{...s,className:J(`parakeet-composer-shell`,r),children:[(0,$.jsx)(RT,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,$.jsx)(gT,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,$.jsx)(xt,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,$.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,$.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,$.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}function VT(e,t){(0,Y.useLayoutEffect)(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${String(t.scrollHeight)}px`)},[e,t])}var HT=Y.createContext(void 0);function UT(e){let t=Y.useContext(HT);if(t===void 0&&!e)throw Error(ed(33));return t}var WT=Y.createContext(void 0);function GT(e){let t=Y.useContext(WT);if(t===void 0&&!e)throw Error(ed(36));return t}var KT=Y.createContext(void 0);function qT(e=!0){let t=Y.useContext(KT);if(t===void 0&&!e)throw Error(ed(25));return t}var JT=Y.createContext(null);function YT(e=`root`){let t=Y.useContext(JT),n=Y.useContext(WT);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var XT={visible:!0,ref:null};function ZT(){return XT}function QT(e,t,n=`root`){let r=YT(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??ZT)({label:e.label,children:e.children,render:e.render}),a=ad(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var $T=Y.createContext(void 0);function eE(){let e=Y.useContext($T);if(e===void 0)throw Error(ed(30));return e}function tE(e){e.preventDefault()}function nE(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=GT(),u=qT(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return Y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?tE:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:ep})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!jp&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Uf(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var rE={type:`regular-item`};function iE(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Y.useRef(null),{getButtonProps:d,buttonRef:f}=Wf({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=nE({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Y.useCallback(e=>Sd(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=ad(u,f);return Y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var aE=Y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function oE(){return Y.useContext(aE)}function sE(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=oE(),u=Y.useRef(-1),[d,f]=Y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Y.useRef(null),h=Y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Q(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var cE=`data-checked`,lE=`data-unchecked`,uE={checked(e){return e?{[cE]:``}:{[lE]:``}},...Kd},dE=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=GT(),m=sE({guess:!0,label:a}),h=gp(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=iE({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:rE}),C=Y.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=qf(ep,e.nativeEvent,void 0,{preventUnmountOnClose:hd});u?.(!l,t)}let T=Fd(`div`,e,{state:C,stateAttributesMapping:uE,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,$.jsx)($T.Provider,{value:C,children:T})}),fE=Y.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=FT({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=QT(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(dE,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),pE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=eE(),c=Y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=wg(s.checked);return kg({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Fd(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:uE,props:{"aria-hidden":!0,...o},enabled:a||u})}),mE=Y.createContext(void 0);function hE(){let e=Y.useContext(mE);if(e===void 0)throw Error(ed(31));return e}var gE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gp(a),c=hE();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Fd(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),_E=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=GT(),f=sE({guess:!0,label:a}),p=gp(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=iE({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:rE});return Fd(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),vE=Y.forwardRef(function(e,t){let n=QT(e,t);return n.visible?(0,$.jsx)(_E,{...e,ref:n.ref}):null}),yE=Y.createContext(void 0);function bE(e){let t=Y.useContext(yE);if(t===void 0&&!e)throw Error(ed(69));return t}function xE(e){return e===`starting`?Uh:_d}var SE=Y.createContext(void 0);function CE(){return Y.useContext(SE)}function wE(e,t){let n=zd(e.render);if(Y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function TE(e,t,n){let r=wE(e,t),i=r===t?void 0:r;return[r,Y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function EE(e,t,n){let r=zd(e.render),i=Y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var DE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=GT(),m=CE(),{side:h,align:g}=UT(),_=bE(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=TE(e,u,d),L=EE(e,C,N),R=w.type===`menu`?m:void 0,z=w.type===`context-menu`,B=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(B=()=>l.state.activeIndex===null&&P),kg({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Y.useEffect(()=>{function e(e){l.setOpen(!1,qf(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),O_(D,{enabled:A&&!j&&!z&&w.type!==`menubar`,closeDelay:k});let ee=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:te}=(Y.useContext(JT)?.useParentHandoff??kE)(l,w,v,f),ne=Fd(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,ee,I],stateAttributesMapping:sf,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&Qv.has(e.key)&&e.stopPropagation()},onFocus:te},xE(y),c,{"data-rootownerid":E}]}),H=w.type===void 0||z;(C||w.type===`menubar`&&T!==`outside-press`)&&(H=!0);let U=R?.getReturnElement??V;return(0,$.jsx)(vg,{context:D,openInteractionType:M,modal:z,disabled:!x,returnFocus:a??U??H,explicitReturnFocus:a===void 0&&U?!1:void 0,initialFocus:B,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ne})}),OE={parentVirtualFocusRef:void 0,handleFocus:void 0};function kE(){return OE}var AE=Y.forwardRef(function(e,t){let n=YT()?.Popup??DE;return(0,$.jsx)(n,{...e,ref:t})}),jE=Y.createContext(void 0);function ME(){let e=Y.useContext(jE);if(e===void 0)throw Error(ed(32));return e}var NE=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=GT();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(jE.Provider,{value:n,children:(0,$.jsx)($h,{ref:t,...r,portalOwnerRole:o})})});function PE(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=Y.useState(null),d=Y.useRef(null),f=ag(n),p=Y.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Wv({...e,elements:{...p,...l&&{reference:l}}}),h=Y.useCallback(e=>{let t=mf(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=Y.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=Y.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=Y.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return Q(()=>{o&&(d.current=o)},[o]),Q(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),Y.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var FE=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Am(e,t)||{};if(l==null)return{};let d=Jm(u),f={x:n,y:r},p=Im(i),m=Pm(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=km(D,k,O),j=!c.arrow&&Mm(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),IE=(e,t)=>{let{name:n,fn:r}=FE(e);return{name:n,fn:r,options:[e,t]}},LE={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},RE={sideX:`left`,sideY:`top`},zE=`--available-width`,BE=`--available-height`,VE=`--anchor-width`,HE=`--anchor-height`,UE=`--transform-origin`,WE=zE,GE=BE;function KE(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function qE(e,t,n){let{rects:r,placement:i}=e;return{side:KE(t,jm(i),n),align:Mm(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function JE(e){return YE(e,PE)}function YE(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=Z(O),A=O?k:n,j=mm(n),M=mm(g),N=Nb()===`rtl`,[P,F]=Y.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?jm(P):null,R=P&&I?Mm(P)||`center`:null,z=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],B=R||o,ee=B===`center`?z:`${z}-${B}`,V=l;typeof V==`number`?V={top:V,right:V,bottom:V,left:V}:V&&={top:V.top||0,right:V.right||0,bottom:V.bottom||0,left:V.left||0};let te=+(i===`bottom`),ne=+(i===`top`),H=+(i===`right`),U=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:V},W=Y.useRef(null),ie=mm(a),ae=mm(s),G=typeof a==`function`?0:a,oe=typeof s==`function`?0:s,se=[];p&&se.push(p),se.push(Gv(e=>{let t=qE(e,i,N),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[G,oe,N,i]));let ce=w===`none`&&C!==`shift`,le=!ce&&(u||E||C===`shift`),ue=C===`none`?null:Jv({...re,padding:{top:V.top+1+te,right:V.right+1+U,bottom:V.bottom+1+ne,left:V.left+1+H},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),K=ce?null:Kv({...re,rootBoundary:D,mainAxis:w!==`none`,crossAxis:le,limiter:u||E?void 0:qv(e=>{if(!W.current)return{};let{width:t,height:n}=W.current.getBoundingClientRect(),r=Fm(jm(e.placement)),i=r===`y`?t:n,a=r===`y`?V.left+V.right:V.top+V.bottom;return{offset:i/2+a/2}})},[re,u,E,D,V,w]);C===`shift`||w===`shift`||B===`center`?se.push(K,ue):se.push(ue,K),se.push(Yv({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(WE,`${t}px`),i.setProperty(GE,`${n}px`);let a=df(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(VE,`${u}px`),i.setProperty(HE,`${d}px`)}}),IE(e=>({element:W.current||Hf(e.elements.floating).createElement(`div`),padding:W.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=jm(r),u=Mm(r),d=Fm(l)===`y`,f=W.current,p=typeof a==`function`?a(qE(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return le&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(UE,d?`${m} ${h}`:`${h} ${m}`),{}}},LE,b),Q(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=Y.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:ve,context:q,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:ee,middleware:se,strategy:r,whileElementsMounted:m?void 0:(...e)=>Mv(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=ge.adaptiveOrigin||RE,Ce=ye?r:`fixed`,we=Y.useMemo(()=>{let e;return e=ye?b?{position:Ce,[xe]:me,[Se]:he}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[WE]=`100vw`,e[GE]=`100vh`,ye||(e.opacity=0),e},[b,Ce,xe,me,Se,he,be,ye]),Te=Y.useRef(null);Q(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(XE(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[g,fe,A,j]),Y.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&XE(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[g,fe,A,j]),Y.useEffect(()=>{if(m&&g&&pe.reference&&pe.floating)return Mv(pe.reference,pe.floating,_e,de)},[m,g,pe,_e,de]);let Ee=jm(ve),De=KE(i,Ee,N),Oe=Mm(ve)||`center`,ke=!!ge.hide?.referenceHidden;Q(()=>{x&&g&&ye&&(Ee!==z||I&&Oe!==B)&&F(ve)},[x,I,g,ye,ve,Ee,Oe,z,B]);let Ae=Y.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),je=ge.arrow?.centerOffset!==0;return Y.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:W,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:q,isPositioned:ye,update:_e}),[we,Ae,W,je,De,Oe,Ee,ke,fe,q,ye,_e])}function XE(e){return e!=null&&`current`in e}function ZE(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=Y.useState(0),s=id($E).current,c=id(QE).current,l=Y.useRef(0),u=Y.useRef(!0),d=Y.useRef(null),f=Y.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!nD(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&rD(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=tD(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=eD(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Q(()=>{u.current&&v()}),Q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=Y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,$.jsx)(aE.Provider,{value:b,children:t})}function QE(){return new Map}function $E(){return new Set}function eD(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>rD(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function tD(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function nD(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function rD(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function iD(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Og(r);Q(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Q(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function aD(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Fd(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},xE(r),i],stateAttributesMapping:of})}var oD=20;function sD(e,t,n,r){let[i,a]=Y.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Hf(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-oD)},[e,t,n]),gy(e&&(!t||i),r)}var cD=Y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Gh,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=GT(),x=ME(),S=qT(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),z=n,B=c,ee=l,V=s,te=h;C.type===`context-menu`&&(z=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(ee=e.alignOffset??2,B=e.sideOffset??-5));let ne=o,H=V;C.type===`menu`?(ne??=`inline-end`,H??=`start`,te=e.collisionAvoidance??Kh):C.type===`menubar`&&(ne??=C.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let U=C.type===`context-menu`,re=JE({anchor:z,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ne,sideOffset:B,align:H,alignOffset:ee,arrowPadding:U?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:te,shift:U?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});Y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,qf(cp)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),Y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,qf(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let W=xp();Y.useEffect(()=>{D||W.clear()},[D,W]),Y.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?W.isStarted()||W.start(e,()=>{v.setOpen(!1,qf(cp))}):v.setOpen(!1,qf(cp))}else W.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,W]),Y.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),iD({store:v,domReference:R,positionerElement:M,open:D});let ie={open:D,side:re.side,align:re.align,anchorHidden:re.anchorHidden,nested:C.type===`menu`,instant:N},ae=C.type===`menubar`&&C.context.modal;sD(D&&(ae||O&&F!==`trigger-hover`),k===`touch`,M,A);let G=aD(e,ie,{styles:re.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),oe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),se=null;return C.type===`menubar`?se=C.context.contentElement:C.type===void 0&&(se=A),(0,$.jsxs)(HT.Provider,{value:re,children:[oe&&(0,$.jsx)(iy,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:ry(!D),cutout:se}),(0,$.jsx)(sg,{id:I,children:(0,$.jsx)(ZE,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:G})})]})}),lD=Y.createContext(null);function uD(e){let t=Y.useContext(lD);if(t===null&&!e)throw Error(ed(5));return t}function dD(e){return e==null?Yf:e.type.startsWith(`key`)?ap:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?op:Yf}var fD={...y_,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=y_.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Np&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!y_.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},pD=class extends u_{constructor(e,t,n=!1){let r=new Wg,i=hD(r,t,n,e);super(i,mD(r),fD),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function mD(e){return{positionerRef:Y.createRef(),popupRef:Y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function hD(e,t,n=!1,r){return{...p_(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:_d,inputProps:_d,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new tg,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:_d,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var gD=Y.createContext(null);function _D(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function vD(e,t){return e===`list-navigation`||_D(e,t)}var yD=$g(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=qT(!0),C=GT(!0),w=uD(!0),T=C?.store,E=C?.virtualFocus??!1,D=Y.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=gp(),k=gp(),[A,j]=Y.useState(void 0),M=(A??k)||void 0,N=ig(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=id(()=>F?P?.state.instantType:void 0).current,L=id(()=>{let e=new pD({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),z=og(R),B=L.useState(`open`),ee=L.useState(`activeTriggerElement`),V=L.useState(`positionerElement`),te=L.useState(`hoverEnabled`),ne=L.useState(`disabled`),H=L.useState(`lastOpenChangeReason`),U=L.useState(`parent`),re=L.useState(`activeIndex`),W=L.useState(`keyboardOpen`),ie=L.useState(`payload`),ae=L.useState(`floatingParentNodeId`),G=Y.useRef(null),oe=Y.useRef(U.type!==`context-menu`),se=xp(),ce=Y.useRef(!0),le=xp(),ue=ae!=null,{openMethod:K,triggerProps:de}=Oy(B);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:U.type===void 0?c:void 0,openMethod:K,rootId:O}),Bg(L);let{forceUnmount:fe,transitionStatus:pe}=Vg(B,L,()=>{L.set(`allowMouseEnter`,!1)},F),me=Og(L.context.popupRef);Y.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!B){e();return}if(pe!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return me(e,t.signal),()=>{t.abort()}},[I,B,pe,me,L]),Q(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:z,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:z,floatingParentNodeId:N})},[S,C,z,N,ee,L]),Y.useEffect(()=>{if(B||(G.current=null),U.type===`context-menu`){if(!B){se.clear(),oe.current=!1;return}se.start(500,()=>{oe.current=!0})}},[se,B,U.type]),Q(()=>{!B&&!te&&L.set(`hoverEnabled`,!0)},[B,te,L]);let he=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||B===e&&t.trigger===ee&&H===n)return;let i=Rg(t);if(!e&&t.trigger==null&&(t.trigger=ee??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);G.current=t.event;let s=Lg(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&vD(n,a),s.instantType=U.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:_D(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ge=Cg({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:he}),_e=ge.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>he(e,t);return _e.on(`setOpen`,e),()=>{_e?.off(`setOpen`,e)}},[_e,he]),Q(()=>L.subscribeToParentMenu(),[L]);let ve=Y.useCallback(()=>{L.setOpen(!1,qf(lp))},[L]);Y.useImperativeHandle(d,()=>({unmount:fe,close:ve}),[fe,ve]);let q;U.type===`context-menu`&&(q=U.context),Y.useImperativeHandle(q?.positionerRef,()=>V,[V]),Y.useImperativeHandle(q?.actionsRef,()=>({setOpen:he}),[he]);let ye=Sg(ge,{enabled:!ne,bubbles:{escapeKey:f&&U.type===`menu`},outsidePress(){return U.type!==`context-menu`||G.current?.type===`contextmenu`||oe.current},externalTree:ue?R:void 0}),be=Nb(),xe=L_(ge,{enabled:!ne,listRef:L.context.itemDomElements,activeIndex:re,virtual:v,nested:U.type===`menubar`||!v&&U.type!==void 0,parentOrientation:U.type===`menubar`?U.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?W:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:be===`rtl`,disabledIndices:gd,onNavigate(e,t){L.setActiveIndex(e,dD(t),t?.nativeEvent)},openOnArrowKeyDown:U.type!==`context-menu`&&!(v&&_),externalTree:!v&&ue?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Se=Y.useCallback(e=>{L.context.typingRef.current=e},[L]),Ce=R_(ge,{enabled:!ne&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:re,resetMs:500,onMatch:(e,t)=>{B&&e!==re&&L.setActiveIndex(e,ap,t.nativeEvent)},onTyping:Se}),we=Z(a),Te=Y.useRef(-1),Ee=Z(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Te.current===n&&L.context.reportedItem===t)return;Te.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Yf,L.context.highlightEvent=void 0,a&&we(t,Jf(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{Ee()},[re,Ee]);let De=Y.useMemo(()=>{if(!v)return xe.reference;if(!xe.trigger)return _d;let{onFocus:e,...t}=xe.trigger;return t},[v,xe.reference,xe.trigger]);L.useSyncedValue(`inputProps`,v?xe.reference??_d:_d);let Oe=Y.useMemo(()=>{let e=Sd(Ce.reference,De,ye.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=B,e},[L,Ce.reference,De,ye.reference,de,B]),ke=Y.useMemo(()=>{let e=Sd(xe.trigger,ye.trigger,de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[xe.trigger,ye.trigger,de]);id(()=>(L.update({inactiveTriggerProps:ke}),null)),Hg(L,{floatingRootContext:ge,activeTriggerProps:Oe,inactiveTriggerProps:ke,popupProps:Y.useMemo(()=>Sd(jg,{onMouseMove(){L.set(`allowMouseEnter`,!0),U.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ce.floating,xe.floating,ye.floating),[U.type,L,Ce.floating,xe.floating,ye.floating]),itemProps:xe.item??_d});let Ae=Y.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ee}),[L,D,u,l,b,k,v,E,Ee]),je=typeof t==`function`?t({payload:ie}):t,Me=(0,$.jsxs)(WT.Provider,{value:Ae,children:[p&&(0,$.jsx)(Pg,{handle:p,store:L}),je]});return(U.type===void 0||U.type===`context-menu`)&&(Me=(0,$.jsx)(cg,{externalTree:R,children:Me})),Me});function bD(e){let t=Y.useContext(gD);if(t===null)return(0,$.jsx)(yD,{...e});let n=t.Root;return(0,$.jsx)(gD.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var xD=5;function SD(e,t){let n=CD(t);return e.clientX>=n.left-xD&&e.clientX<=n.right+xD&&e.clientY>=n.top-xD&&e.clientY<=n.bottom+xD}function CD(e){let t=e.getBoundingClientRect(),n=df(e);if(Fp)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function wD(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Bf(),{ref:i,index:a}=sE(e),o=n===a,s=Y.useRef(null),c=ad(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function TD(e){let{render:t,className:n,style:r,state:i=_d,props:a=gd,refs:o=gd,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=wD({metadata:s});return Fd(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function ED(e){if(hf(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Df(e))return ED(Af(e))}function DD(e,t){function n(n,r,i){let a=n.currentTarget;Jh.flushSync(()=>{e.setOpen(!1,qf(np,n.nativeEvent,a))}),Ch(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&wh(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function OD(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Y.useRef(!1);return Y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Hf(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:_d,[t,n,r])}var kD=e_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=GT(!0),h=b_(d)??m?.store;if(!h)throw Error(ed(85));let g=gp(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=Y.useRef(null),S=jD(),C=Bf(!0),w=ag(),T=Y.useMemo(()=>w??new tg,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=zg(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:og(T),floatingParentNodeId:ig(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Wf({disabled:A,native:o});Y.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=Y.useRef(null),P=xp(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Up(N.current,t)||Up(h.select(`positionerElement`),t)||t===N.current||(t==null||ED(t)!==h.select(`rootId`))&&(SD(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:sp}))});Y.useEffect(()=>{let e=Hf(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=A_(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:K_({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=AD(y,h.select(`lastOpenChangeReason`)),z=yg(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),B=S_(v,{enabled:!A&&I}),ee=OD({open:y,enabled:O,mouseDownAction:`open`}),V=Y.useMemo(()=>Sd(B.reference,z.reference),[B.reference,z.reference]),te=h.useState(`triggerProps`,D),ne=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:H,handleFocusTargetFocus:U}=DD(h,x),re={disabled:A,open:y},W=[N,t,M,E,x],ie=[V,L??_d,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Hf(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ne,O?{role:`menuitem`}:{},ee,p,j],ae=Fd(`button`,e,{enabled:!O,stateAttributesMapping:af,state:re,ref:W,props:ie});return O?(0,$.jsx)(TD,{tag:`button`,render:n,className:r,style:i,state:re,refs:W,props:ie,stateAttributesMapping:af}):y?(0,$.jsxs)(Y.Fragment,{children:[(0,$.jsx)(Sm,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:H},`${g}-pre-focus-guard`),(0,$.jsx)(Y.Fragment,{children:ae},g),(0,$.jsx)(Sm,{ref:h.context.triggerFocusTargetRef,onFocus:U},`${g}-post-focus-guard`)]}):(0,$.jsx)(Y.Fragment,{children:ae},g)});function AD(e,t){let n=xp(),[r,i]=Y.useState(!1);return Q(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function jD(){let e=uD(!0);return Y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var MD=Y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Fd(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),ND=(0,Y.createContext)(null);function PD({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Y.useRef)(null),o=e??a;return Ny(()=>o.current?.close()),(0,$.jsx)(ND.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(bD,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function FD(){let e=(0,Y.useContext)(ND);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var ID=(0,Y.forwardRef)(function({className:e,render:t,type:n=`button`,...r},i){return(0,$.jsx)(kD,{...r,className:t=>J(`btn caps-dropdown-trigger`,et(e,t)),ref:i,render:t,type:n})}),LD=(0,Y.forwardRef)(function({container:e,...t},n){let r=My(`popover`);return e==null&&r===null?null:(0,$.jsx)(NE,{...t,container:e??r,ref:n})}),RD=(0,Y.forwardRef)(function({collisionBoundary:e,...t},n){let r=My(`popover`);return(0,$.jsx)(cD,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),zD=(0,Y.forwardRef)(function({className:e,finalFocus:t,...n},r){let{interactionOwner:i}=FD(),a=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(r,()=>a.current);let o=MT(`.caps-dropdown-item[data-highlighted]`),s=(0,Y.useCallback)(e=>{a.current=e,o(e)},[o]);return(0,$.jsx)(AE,{...n,className:t=>J(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,et(e,t)),finalFocus:i===`host`?!1:t??!0,ref:s})}),BD=(0,Y.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(LD,{container:r,keepMounted:i,children:(0,$.jsx)(RD,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(zD,{...s,ref:c,children:n})})})}),VD=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`;(0,Y.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:r=`default`,...i},a){return(0,$.jsx)(vE,{...i,className:t=>J(VD,r===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,et(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:a})});var HD=(0,Y.forwardRef)(function({children:e,className:t,onClick:n,onSelect:r,...i},a){return(0,$.jsxs)(fE,{...i,className:e=>J(VD,et(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||r?.(e)},ref:a,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(pE,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})});(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(MD,{...t,className:t=>J(`my-xs h-px bg-base-300`,et(e,t)),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(gE,{...t,className:t=>J(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,et(e,t)),ref:n})});function UD({disabled:e,emptyLabel:t,models:n,onChange:r,value:i}){let a=n.find(e=>e.id===i),[o,s]=(0,Y.useState)(null);return(0,$.jsx)(`span`,{className:`contents`,ref:s,children:(0,$.jsxs)(PD,{children:[(0,$.jsx)(ID,{"aria-label":`Generation model`,"data-generation-model":i,disabled:e||n.length===0,render:(e,n)=>(0,$.jsx)(fT,{...e,expanded:n.open,label:a===void 0?t:sr(a)})}),(0,$.jsx)(BD,{"data-generation-model-menu":!0,container:o,side:`top`,align:`start`,"aria-label":`Generation models`,children:n.map(e=>(0,$.jsx)(HD,{"data-generation-model-option":e.id,checked:e.id===i,closeOnClick:!0,onSelect:()=>{r(e.id)},children:sr(e)},e.id))})]})})}function WD(e){let t=Su(e),n=(0,Y.useRef)(e);n.current=e;let r=ge(),i=Xn(vr(e)),a=xa(Lx(e,i.data?.configured?i.data.path:null)),[o,s]=(0,Y.useState)(null),c=n=>n?.app===e&&n.computerId===t,l=Nt({mutationKey:Lr.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new u(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(yn).mkdir({path:r}),a(),await xn(e.capabilities,{path:r,limit:1,offset:0}),a(),jn(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&s(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:Ix.listing(n.owner,n.path),exact:!0})])}),d=l.variables?.owner===e&&l.variables.id===t,f=i.isFetching||d&&l.isPending,p=async(n,r)=>{if(!e||!t||f)return`Computer selection changed. Try again.`;let i=n.trim();if(!Tt(wn)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await l.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:Lr.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},m=i.isError||a.isError;return{path:m?null:i.data?.path??null,galleryPath:m||!i.data?.configured?null:i.data.path,computerId:t,available:e?.capabilities.has(Mn)===!0,writable:e?.capabilities.has(yn)===!0,busy:f,error:m?`Your media folder is unavailable. Choose or create a folder.`:null,editing:c(o),setEditing:n=>{s(n?{app:e,computerId:t}:null)},choose:p,ensureCreated:async()=>i.data?i.data.configured?null:p(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:Ix.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:Lr.folder(e),exact:!0})}}}var GD=St(rt),KD=St(Yt({message:rt}));function qD(e){for(let t of e.errors){let e=w(Le(zt(KD(t),e=>e.message),()=>GD(t)));if(e!==void 0&&e.length>0)return e}}var JD={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},YD=(0,Y.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,$.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:J(`progress caps-gooey-motion caps-gooey-progress w-full`,JD[t],e),ref:r})});(0,Y.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,$.jsxs)(`div`,{...a,ref:o,className:J(`caps-game-meter`,i),children:[(0,$.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,$.jsx)(YD,{"aria-label":e,value:t,max:n,tone:r})]})});function XD({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,$.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,$.jsx)($D,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function ZD({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,$.jsx)(Wr,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,$.jsx)(Zr,{}):(0,$.jsx)(Tr,{}),onClick:()=>void n(t),type:`button`}):null}function QD({item:e}){return(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,$.jsx)(`div`,{className:`caps-upload-details`,children:(0,$.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function $D({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,$.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,$.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,$.jsx)(lx,{className:`size-4`})}),(0,$.jsx)(QD,{item:e}),(0,$.jsx)(eO,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,$.jsx)(YD,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function eO({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,$.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,$.jsx)(ZD,{action:e.retry,id:t,onAction:i,retry:!0}),(0,$.jsx)(ZD,{action:e.cancel,id:t,onAction:n}),(0,$.jsx)(ZD,{action:e.remove,id:t,onAction:r})]})}var tO=Y.createContext(void 0);function nO(e){let t=Y.useContext(tO);if(t===void 0&&!e)throw Error(ed(47));return t}var rO={...y_,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!y_.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&y_.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>y_.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},iO=class extends u_{constructor(e,t,n){let r=new Wg;super(aO(e,r,t,n),oO(r),rO)}setOpen=(e,t)=>{let n=t.reason===Zf,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Rg(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Lg(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Jh.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function aO(e,t,n,r=!1){let i={...p_(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function oO(e){return{popupRef:Y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),stickIfOpenTimeout:new bp,stickIfOpen:!0,triggerElements:e}}var sO=$g(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=lO(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Ug(u,d),Bg(u);let{forceUnmount:m}=Vg(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),Y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,qf(lp))}),[m,u]);let h=d||f||s!=null;return(0,$.jsxs)(tO.Provider,{value:u,children:[s&&(0,$.jsx)(Pg,{handle:s,store:u}),h&&(0,$.jsx)(uO,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function cO(e){return nO(!0)?(0,$.jsx)(sO,{props:e}):(0,$.jsx)(cg,{children:(0,$.jsx)(sO,{props:e})})}function lO(e,t){let n=Ng((e,n)=>new iO(t,e,n));return Y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function uO({store:e,modal:t}){let n=Sg(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Hg(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var dO=e_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=nO(!0),h=b_(s)??m;if(!h)throw Error(ed(74));let g=gp(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=Y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=zg(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=A_(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:K_(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=yg(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=Dy(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=Wf({disabled:a,native:o}),N={open(e){return w?af.open(e):rf.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=DD(h,x),I=Fd(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[Wh]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,$.jsx)(Y.Fragment,{children:I},g);return E?(0,$.jsxs)(Y.Fragment,{children:[(0,$.jsx)(Sm,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,$.jsx)(Sm,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),fO=Y.createContext(void 0);function pO(){let e=Y.useContext(fO);if(e===void 0)throw Error(ed(45));return e}var mO=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return nO().useState(`mounted`)||n?(0,$.jsx)(fO.Provider,{value:n,children:(0,$.jsx)($h,{ref:t,...r})}):null}),hO=Y.createContext(void 0);function gO(){let e=Y.useContext(hO);if(!e)throw Error(ed(46));return e}var _O=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Kh,..._}=e,v=nO(),y=pO(),b=og(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=JE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});iD({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;sD(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=aD(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,$.jsxs)(hO.Provider,{value:j,children:[S&&M&&(0,$.jsx)(iy,{inert:ry(!C),cutout:T}),(0,$.jsx)(sg,{id:b,children:P})]})}),vO=Y.createContext(void 0);function yO(){let[e,t]=Y.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var bO=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=nO(),l=gO(),u=bE(!0)!=null,{context:d,hasClosePart:f}=yO(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);kg({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),O_(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Mg(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Fd(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...jg,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Qv.has(e.key)&&e.stopPropagation()}},xE(g),s],stateAttributesMapping:sf});return(0,$.jsx)(vg,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:hf(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,$.jsx)(vO.Provider,{value:d,children:M})})}),xO=(0,Y.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,$.jsxs)(`button`,{...r,ref:i,type:n,className:J(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(ax,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function SO({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(t),[x,S]=(0,Y.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,Y.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=PT({getKey:n,isDisabled:o,items:T});(0,Y.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(oT(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,Y.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function CO(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,Y.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:R,onPointerMove:z,activeItem:B,activeKey:ee,commit:V,groups:te,inputValue:ne,listboxId:H,onInputChange:U,onInputKeyDown:re,open:W,optionId:ie,selectedKeys:ae,setOpen:G}=SO({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});Ny(()=>{O&&G(!1)});let oe=My(`popover`),se=s===void 0?oe:s,ce=MT(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),le=(0,$.jsx)(qC,{..._,...O?{}:L,"aria-activedescendant":B?ie(f(B)):void 0,"aria-autocomplete":`list`,"aria-controls":H,"aria-expanded":!0,className:J(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),U(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||re(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ne}),ue=(0,$.jsx)(`div`,{id:H,ref:ce,className:`caps-combobox-list`,"data-navigation":R?`keyboard`:`pointer`,onPointerMove:z,role:`listbox`,"aria-multiselectable":C??void 0,children:te.every(e=>e.items.length===0)?(0,$.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):te.map(e=>(0,$.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,$.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=ee===t,i={active:r,disabled:n,selected:ae.includes(t)};return(0,$.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&R,disabled:n,id:ie(t),onClick:()=>{V(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,$.jsx)(Hr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,$.jsx)(`div`,{...j,className:J(j.className),ref:D,children:(0,$.jsxs)(cO,{modal:!0,onOpenChange:G,open:W,children:[(0,$.jsx)(dO,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),se===null?null:(0,$.jsx)(mO,{container:se,children:(0,$.jsx)(_O,{align:`start`,side:`bottom`,sideOffset:4,children:(0,$.jsxs)(bO,{"data-active-tone":o,className:J(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,$.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})})]})}):(0,$.jsx)(`div`,{...j,className:J(j.className),ref:D,children:(0,$.jsxs)(`div`,{className:J(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,$.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})}function wO({icon:e,caption:t}){return(0,$.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,$.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,$.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var TO=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,$.jsx)(OT,{...a,appearance:r??`default`,"aria-label":e,className:J(`caps-icon-choice-input`,i),indicator:(0,$.jsx)(wO,{icon:t,caption:n}),ref:o})})}),EO=(0,Y.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,Y.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,$.jsx)(`label`,{className:`caps-check-key`,children:(0,$.jsx)(OT,{...i,"aria-label":e,"aria-describedby":s,className:J(`caps-check-key-input`,r),indicator:(0,$.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,$.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,$.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,$.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,$.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,$.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function DO({className:e,...t}){return(0,$.jsx)(`div`,{...t,className:J(`caps-check-keys`,e)})}function OO({checked:e}){let t=`caps-radio-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=(0,Y.useRef)(null),o=xr(a),{reduced:s}=o;return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Nr(o,{ease:`outCubic`,duration:75}),c=e?yr(o,{bounce:.65,duration:300}):Nr(o,{ease:`inCubic`,duration:100}),l=ui(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,$.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(Kr,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,$.jsx)(Dr,{id:`${t}-shadow`}),(0,$.jsx)(wr,{id:`${t}-inset`}),(0,$.jsx)(`clipPath`,{id:`${t}-well`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,$.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,$.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,$.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var kO=(0,Y.createContext)(null),AO=(0,Y.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,Y.useId)(),d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,Y.useState)(n),h=s??p;return(0,Y.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,$.jsx)(kO.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,$.jsx)(`fieldset`,{...c,className:J(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),jO=(0,Y.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,Y.useContext)(kO);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,$.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,$.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:J(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,$.jsx)(OO,{checked:c}):t]})}),MO=(0,Y.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,Y.useContext)(kO),s=(0,Y.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,$.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,$.jsx)(jO,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,$.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,$.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,$.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,$.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),NO=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,$.jsx)(jO,{...a,"aria-label":e,className:J(`caps-icon-choice-input`,i),indicator:(0,$.jsx)(wO,{icon:t,caption:n}),ref:o})})});(0,Y.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,$.jsx)(jO,{...r,"aria-label":e,className:J(`caps-icon-choice-input`,n),indicator:(0,$.jsx)(wO,{icon:(0,$.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var PO=St(rt),FO=St(Me),IO=St(Ve(E)),LO=St(Te(rt)),RO=Te(Ft(File)),zO=St(RO),BO=Ge([rt,E,Me,Fe,Ut,Te(rt),RO]),VO=St(BO),HO=e=>Ce(PO(e.state.value),()=>``),UO=e=>Ce(FO(e.state.value),()=>!1),WO=e=>Ce(IO(e.state.value),()=>null),GO=e=>Ce(LO(e.state.value),()=>[]),KO=e=>Ce(zO(e.state.value),()=>[]),qO=e=>Ce(VO(e.state.value),()=>null);function JO({field:e,spec:t,locked:n,...r}){let[i,a]=(0,Y.useState)(!1);return(0,$.jsxs)(Ow,{children:[(0,$.jsx)(qC,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:HO(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,$.jsx)(sx,{"aria-hidden":`true`}):(0,$.jsx)(cx,{"aria-hidden":`true`})})]})}var YO={text:`text`,email:`email`,url:`url`,tel:`tel`};function XO({spec:e,field:t,locked:n,...r}){let i=KO(t),a=n||e.readOnly===!0,o=(0,Y.useRef)(null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,$.jsx)(jr,{asChild:!0,children:(0,$.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,$.jsx)(XD,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function ZO({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,$.jsx)(qC,{...a,type:YO[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,$.jsx)(bT,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,$.jsx)(JO,{...r,field:t,spec:e,locked:n});case`money`:return(0,$.jsxs)(Ow,{children:[(0,$.jsx)(kw,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,$.jsx)(qC,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,$.jsx)(qC,{...a,type:`date`,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,$.jsx)(Ww,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:WO(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,$.jsxs)(Gw,{...a,value:HO(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,$.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,$.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,$.jsx)(CO,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:HO(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,$.jsx)(xO,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===HO(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,$.jsx)(XO,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,$.jsx)(OT,{...a,disabled:n||e.readOnly===!0,checked:UO(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,$.jsx)(Mr,{...a,disabled:n||e.readOnly===!0,checked:UO(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var QO=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function $O({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=GO(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,$.jsx)(Lw,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,$.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,$.jsx)(TO,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,$.jsx)(DO,{children:e.options.map(r=>(0,$.jsx)(EO,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,$.jsx)(Lw,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,$.jsx)(AO,{name:e.name,"aria-label":o,value:HO(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,$.jsx)(NO,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,$.jsx)(MO,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,$.jsx)(zw,{label:t.label,orientation:`inline`,children:(0,$.jsx)(jO,{value:t.value,disabled:t.disabled})},t.value))})})}function ek({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:qO(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function tk({form:e,spec:t,locked:n,layout:r}){let i=RC({form:e,name:t.name}),a=IC(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?qD(i.state.meta):void 0;if(t.render===void 0&&QO.has(t.kind))return(0,$.jsx)($O,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,$.jsx)(zw,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,$.jsx)(ZO,{spec:t,field:i,locked:n}):(0,$.jsx)(ek,{spec:t,field:i,locked:n,error:o,render:t.render})})}var nk=St(r(rt,BO));function rk({form:e,spec:t,locked:n,layout:r}){let i=t.when;return IC(e.store,e=>i===void 0||i(Ce(nk(e.values),()=>({}))))?(0,$.jsx)(tk,{form:e,spec:t,locked:n,layout:r}):null}function ik({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,$.jsx)(rk,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,$.jsx)(Iw,{title:t.title,description:t.description,layout:r,children:i})}function ak({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,$.jsx)(ik,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,$.jsx)(rk,{form:i,spec:a,locked:n,layout:r},t)})}var ok=class{annotation;constructor(e){this.annotation=e}},sk=class{sections;constructor(e){this.sections=e}},ck=`caps/form`,lk=0;function uk(e){lk+=1;let t={[`${ck}:${String(lk)}`]:new ok(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}rt.annotate(uk({kind:`secret`})).pipe(jt(`Secret`));var dk=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function fk(e){return Object.values(e??{}).reduce((e,t)=>t instanceof ok?{...e,...t.annotation}:e,{})}function pk(e){return e.reduce((e,t)=>({...e,...fk(t)}),{})}function mk(e){let t=e?.[ck];return t instanceof sk?t.sections:{}}var hk=St(rt);function gk(e){if(yt(e))return P(hk(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!x(e))return null;let t=[];for(let n of e.types){if(ue(n))continue;let e=gk(n);if(e===null)return null;t.push(...e)}return t}function _k(e){if(ae(e))return{type:`string`,literals:[]};if(gt(e))return{type:`number`,nullable:!1};if(se(e))return{type:`boolean`};let t=gk(e);if(t!==null)return{type:`string`,literals:t};if(m(e)){let[t]=e.rest;if(t===void 0)return null;if(ae(t))return{type:`strings`,literals:[]};let n=gk(t);return n===null?null:{type:`strings`,literals:n}}if(x(e)){let t=e.types.filter(e=>!ue(e)&&!a(e)),n=e.types.some(e=>a(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=_k(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function vk(e){let t=e.ast;if(!U(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=dn(e.type),r=pk([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:_k(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:me(e.type),description:V(e.type)}}),sections:mk(j(t))}}function yk(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof We)n=!0,t=t.unwrap();else if(t instanceof Et)r=!0,t=t.unwrap();else if(t instanceof nt)t=t.unwrap();else if(t instanceof en)t=t.in;else return{node:t,optional:n,nullable:r}}function bk(e){if(e instanceof on){let t=e.options.map(e=>bk(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof ot?e.options:e instanceof It?[...e.values]:null;if(t===null)return null;let n=t.map(e=>hk(e));return n.every(R)?n.map(e=>e.value):null}function xk(e){let{node:t,nullable:n}=yk(e);if(t instanceof ln)return{type:`string`,literals:[]};if(t instanceof dt)return{type:`number`,nullable:n};if(t instanceof Zt)return{type:`boolean`};let r=bk(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof Ct){let e=yk(t.element).node;if(e instanceof ln)return{type:`strings`,literals:[]};let n=bk(e);return n===null?null:{type:`strings`,literals:n}}return null}function Sk(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof We||e instanceof Et||e instanceof nt?e.unwrap():e instanceof en?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>he.get(e))}function Ck(e){return Sk(e).reduce((e,t)=>({...e,...t}),{})}function wk(e){return Object.entries(e.shape)}function Tk(e){let t=yk(e).node;if(!(t instanceof lt))throw Error(`A schema form needs a z.object.`);return{fields:wk(t).map(([e,t])=>{let n=pk(Sk(t)),r=n.kind===`file`?{type:`files`}:xk(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=Ck(t);return{name:e,valueType:r,optional:yk(t).optional,annotation:n,title:i.title,description:i.description}}),sections:mk(Ck(e))}}function Ek(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??dk(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function Dk(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function Ok(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function kk(e){let t=e instanceof Xe?Tk(e):vk(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=Ek(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??dk(e.name),help:a,kind:n??Dk(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=Ok(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function Ak(e){let t=e instanceof Xe?e:v(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>jk(e)):jk(n)}}}}function jk(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var Mk=`onServer`;function Nk(e){let t=e.querySelector(`[aria-invalid="true"]`),n=t?.matches(`input, select, textarea, button, [tabindex]`)?t:t?.querySelector(`input, select, textarea, button`);return n?.focus(),n!=null}function Pk(e){if(Nk(e))return()=>void 0;let t=new MutationObserver(()=>{Nk(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function Fk(e){return e.state.meta.errorMap.onServer!==void 0}function Ik(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[Mk]:void 0}}))}function Lk(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[Mk]:n}}))}function Rk(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(e.defaultValues),[s,c]=(0,Y.useState)(null);nC(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,Y.useMemo)(()=>kk(l),[l]),d=(0,Y.useMemo)(()=>Ak(l),[l]),f=KC({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),Fk(e)&&Ik(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await Ak(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&Lk(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function zk(e){return{dirty:IC(e.form.store,e=>!e.isDefaultValue),submitting:IC(e.form.store,e=>e.isSubmitting),canSubmit:IC(e.form.store,e=>e.canSubmit)}}function Bk({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=zk(e),f=(0,Y.useRef)(null),p=(0,Y.useRef)(()=>void 0);return(0,Y.useEffect)(()=>()=>{p.current()},[]),(0,$.jsxs)(Pw,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{p.current();let t=f.current;t!==null&&!e.form.state.isValid&&(p.current=Pk(t))})},children:[c??(0,$.jsx)(ak,{model:e,disabled:l,layout:o}),s===void 0?(0,$.jsx)(Uk,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function Vk({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=Rk({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,$.jsx)(Bk,{...a,model:o})}function Hk(e){return`model`in e?(0,$.jsx)(Bk,{...e}):(0,$.jsx)(Vk,{...e})}function Uk({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=zk(e),d=u?null:e.saved&&!l?(0,$.jsx)(eb,{tone:`success`,size:`compact`,label:e.saved}):l?(0,$.jsx)(eb,{tone:`neutral`,size:`compact`,label:o}):null;return(0,$.jsxs)(Nw,{...c,error:e.error,status:d,children:[r?(0,$.jsx)(Xr,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,$.jsx)(Xr,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,$.jsx)(Xr,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var Wk={error:0,warning:1,info:2};function Gk(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||Wk[e.tone]-Wk[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function Kk(e,t,n){let r=Gk(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:At(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var qk={Setup:(0,$.jsx)(gx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,$.jsx)(dx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,$.jsx)(vx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function Jk({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,$.jsx)(gT,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,$.jsx)(Yk,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function Yk({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,$.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,$.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,$.jsx)(Vr,{level:3,children:e}),(0,$.jsx)(_T,{children:t.map(e=>(0,$.jsx)(vT,{icon:qk[e.group],primary:(0,$.jsxs)(`span`,{className:`prints-notice-copy`,children:[(0,$.jsx)(`span`,{children:e.title}),e.detail?(0,$.jsx)(`span`,{className:`prints-notice-detail`,children:e.detail}):null]}),actions:(0,$.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map((e,t)=>(0,$.jsx)(Xr,{variant:t===0?`outline`:`ghost`,size:t===0?`sm`:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,$.jsx)(Wr,{"aria-label":`Dismiss ${e.title}`,icon:(0,$.jsx)(Tr,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,$.jsx)(yT,{children:`All caught up.`}),t&&t.items.length>0?(0,$.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,$.jsx)(Vr,{level:3,children:`Uploading`}),(0,$.jsx)(XD,{...t})]}):null,(0,$.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,$.jsx)(`span`,{className:`prints-footer-note`,children:`Clear dismisses finished items`}),(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function Xk({folder:e}){return(0,$.jsx)(Fy,{open:e.editing,onOpenChange:e.setEditing,children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Save prints to`})}),(0,$.jsx)(Qk,{folder:e},e.computerId),(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Zk=Yt({path:Ot.check(ve(Tt(wn),{message:`Enter an absolute Computer folder, such as /media.`})).annotate(uk({label:`Folder`,placeholder:`/media`}))});function Qk({folder:e}){let t=(0,Y.useRef)(!1),n=Rk({schema:Zk,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hk,{model:n,disabled:i,footer:(0,$.jsxs)(Nw,{divider:!1,children:[(0,$.jsx)(xt,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,$.jsx)(xt,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,$.jsx)(vT,{role:`alert`,icon:(0,$.jsx)(ux,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,$.jsx)(yT,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}var $k={image:`Image`,video:`Video`,media:`Media`};function eA({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,mediaSetupMissing:s,canWrite:c,generationError:l,recoveryError:d,pendingGenerations:f,activeGenerations:p,gallerySlots:m,computerId:h,failed:g,uploadError:_,uploads:v,permissions:y,resume:b,discard:x,retryUpload:S}){let C=[];if(e)h===null?C.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&!s&&C.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{y()}}]}):C.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):C.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=k(new u(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));C.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}if(e&&h!==null&&!c&&C.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`}),l!==null){let e=`${$k[l.mediaKind??`media`]} failed`;C.push({key:l.key,group:`Images`,tone:`error`,short:e,title:`${e}: ${l.message}`,detail:l.prompt,blocking:l.dismiss!==void 0,actions:[...l.billing?[{label:`Open Billing`,run:l.billing}]:l.retry?[{label:`Retry`,run:l.retry}]:[],...l.dismiss?[{label:`Dismiss`,run:l.dismiss}]:[]]})}d!==null&&C.push({key:`recovery:${d}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:d});for(let e of f){if(p.has(e.reference.requestId)||m.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`${$k[zn(a,e.input.settings.model)?.kind??`media`]} failed`;C.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`error`,blocking:!0,short:t,title:`${t}: ${e.failure?.message??`Stopped when Prints closed. Retry to run it again.`}`,detail:e.reference.computerId===h?e.typed.prompt:`${e.typed.prompt} · select the original Computer to retry`,actions:[...e.reference.computerId===h?[{label:`Retry`,run:()=>{b(e)}}]:[],{label:`Dismiss`,run:()=>{x(e)}}]})}g.length>0&&C.push({key:`files:${g.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:g.join(`, `)}),_!==null&&C.push({key:`uploads:${_}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:_});for(let e of v)(e.status===`error`||e.status===`cancelled`)&&C.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{S(e.id)}}]});return C}function tA(e,t){let n=Xn(Yr(e)),r=Nt(Fr({queryKey:Lr.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>Nn(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var nA=0,rA=1,iA=2,aA=0,oA=1;function sA(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function cA(e,t){let n=e.list;if(n.index===t)return n.next===null?aA:(e.list=n.next,oA);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,oA;r=n,n=n.next}}var lA={low:0,max:0,high:0,C:iA,P:void 0,R:void 0,L:void 0,list:void 0};lA.P=lA,lA.L=lA,lA.R=lA;function uA(e){let t=e.high;e.max=e.L===lA&&e.R===lA?t:e.L===lA?Math.max(e.R.max,t):e.R===lA?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function dA(e){let t=e;for(;t.P!==lA;)uA(t.P),t=t.P}function fA(e,t){if(t.R===lA)return;let n=t.R;t.R=n.L,n.L!==lA&&(n.L.P=t),n.P=t.P,t.P===lA?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,uA(t),uA(n)}function pA(e,t){if(t.L===lA)return;let n=t.L;t.L=n.R,n.R!==lA&&(n.R.P=t),n.P=t.P,t.P===lA?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,uA(t),uA(n)}function mA(e,t,n){t.P===lA?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function hA(e,t){let n;for(;t!==lA&&t.C===rA;)t===t.P.L?(n=t.P.R,n.C===nA&&(n.C=rA,t.P.C=nA,fA(e,t.P),n=t.P.R),n.L.C===rA&&n.R.C===rA?(n.C=nA,t=t.P):(n.R.C===rA&&(n.L.C=rA,n.C=nA,pA(e,n),n=t.P.R),n.C=t.P.C,t.P.C=rA,n.R.C=rA,fA(e,t.P),t=e.root)):(n=t.P.L,n.C===nA&&(n.C=rA,t.P.C=nA,pA(e,t.P),n=t.P.L),n.R.C===rA&&n.L.C===rA?(n.C=nA,t=t.P):(n.L.C===rA&&(n.R.C=rA,n.C=nA,fA(e,n),n=t.P.L),n.C=t.P.C,t.P.C=rA,n.L.C=rA,pA(e,t.P),t=e.root));t.C=rA}function gA(e){for(;e.L!==lA;)e=e.L;return e}function _A(e,t){let n;for(;t.P.C===nA;)t.P===t.P.P.L?(n=t.P.P.R,n.C===nA?(t.P.C=rA,n.C=rA,t.P.P.C=nA,t=t.P.P):(t===t.P.R&&(t=t.P,fA(e,t)),t.P.C=rA,t.P.P.C=nA,pA(e,t.P.P))):(n=t.P.P.L,n.C===nA?(t.P.C=rA,n.C=rA,t.P.P.C=nA,t=t.P.P):(t===t.P.L&&(t=t.P,pA(e,t)),t.P.C=rA,t.P.P.C=nA,fA(e,t.P.P)));e.root.C=rA}function vA(){let e={root:lA,size:0},t={};return{insert(n,r,i){let a=e.root,o=lA;for(;a!==lA&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==lA){if(!sA(o,r,i))return;o.high=Math.max(o.high,r),uA(o),dA(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:nA,P:o,L:lA,R:lA,list:{index:i,high:r,next:null}};o===lA?e.root=s:(s.low<o.low?o.L=s:o.R=s,dA(s)),_A(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=cA(r,n);if(i===void 0)return;if(i===oA){r.high=r.list.high,uA(r),dA(r),e.size--;return}let a=r,o=a.C,s;r.L===lA?(s=r.R,mA(e,r,r.R)):r.R===lA?(s=r.L,mA(e,r,r.L)):(a=gA(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(mA(e,a,a.R),a.R=r.R,a.R.P=a),mA(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),uA(s),dA(s),o===rA&&hA(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===lA||t>e.max)&&(e.L!==lA&&i.push(e.L),e.R!==lA&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var yA=e=>{let t=Y.useRef(e);return Y.useEffect(()=>{t.current=e}),t},bA=(e,t)=>{let n=t||xA,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},xA=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],SA=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},CA=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},wA=e=>{let t=e.length,n=CA(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=CA(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=CA(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},TA=(e,t)=>{let n,{g:r,s:i}=wA(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},EA=new WeakMap;function DA(){let e=Y.useState(OA)[1];return Y.useRef(()=>e({})).current}var OA={},kA=Y.createElement;function AA(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=IA,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=DA(),w=RA(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=yA(b);h=v*h;let L=g+h,R=N<L&&M<T;if(O(Math.max(0,g-h/2),L,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(kA(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},MA(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),R){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=LA(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(kA(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},MA(y,t,e,E)))}}Y.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),jA=`1`},[x,S,r,I]),Y.useEffect(()=>{R&&C()},[R,t]);let z=NA(_,k(T,p));return kA(i,{ref:u,key:jA,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?FA(z,s):z,children:P})}var jA=`0`,MA=TA([SA,{},WeakMap,SA],(e,t,n,r)=>kA(e,{index:t,data:n,width:r})),NA=bA((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),PA=(e,t)=>e[0]===t[0]&&e[1]===t[1],FA=bA((e,t)=>Object.assign({},e,t),PA);function IA(e,t){return t}var LA=bA(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),RA=bA((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),EA.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},PA),zA=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=vA(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=BA(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},BA=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},VA=0,HA=320,UA=656;function WA(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=4?2:t>=1280?4:t>=UA?3:2}function GA({item:e}){return bn(e.path)?(0,$.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,$.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var KA=(0,Y.memo)(function({item:e}){let t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,Y.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,Y.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return er(async()=>{let{animate:e,spring:t}=await import(`./modules-C4mfDnjH.js`).then(e=>e.t);return{animate:e,spring:t}},__vite__mapDeps([4,1]),import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,$.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[e.error?(0,$.jsx)(`div`,{className:`block h-full w-full overflow-hidden bg-base-200`,"data-media-failed":!0,title:e.path,children:(0,$.jsx)(rb,{status:`failed`,failure:(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-xs`,children:[e.prompt?(0,$.jsx)(`p`,{className:`m-0 max-w-full truncate px-md text-xs text-(--stipe-fg-muted)`,children:e.prompt}):null,(0,$.jsx)(tb,{density:`tile`,message:e.error,onRetry:e.onRetry,onDismiss:e.onDismiss})]})})}):(0,$.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,onClick:()=>{e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,$.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n?(0,$.jsx)(rb,{"data-media-pending":e.pending?`true`:void 0,indicator:(0,$.jsx)(Sr,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`}),label:e.pendingLabel??`Preparing image…`,status:e.pending?`generating`:`done`,children:e.pending?null:(0,$.jsx)(GA,{item:e})}):(0,$.jsx)(GA,{item:e})})}),(0,$.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&e.onInfo?(0,$.jsx)(Wr,{"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,$.jsx)(fx,{})}):null,!e.pending&&e.onToggleReference?(0,$.jsx)(Wr,{className:`prints-gallery-reference`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,$.jsx)(Hr,{}):(0,$.jsx)(dx,{})}):null]})]})}),qA=(0,Y.memo)(function({children:e,style:t,...n}){return(0,$.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function JA(e,t){let[n,r]=(0,Y.useState)({height:0,width:0});return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function YA(e){let[t,n]=(0,Y.useState)(0),[r,i]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function XA(e,t){let n=Math.max(1,WA(e.length,t));return(0,Y.useMemo)(()=>{let r=Math.floor((t-(n-1)*VA)/n),i=zA(n,r,VA);return r>0&&e.forEach((e,t)=>{let n=e.height>0?e.width/e.height:1;i.set(t,r/n)}),i},[e,t,n])}var ZA=(0,Y.memo)(function({data:e,width:t}){let n=e.height>0?e.width/e.height:1;return(0,$.jsx)(`div`,{"data-media-tile":e.key,style:{height:t/n,width:t},children:(0,$.jsx)(KA,{item:e})})});function QA(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function $A(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||QA(e,t))&&n()}function ej(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var tj=(0,Y.memo)(function({items:e,scrollRef:t,focus:n}){let r=JA(t,e.length),i=r.width||HA,a=XA(e,i),{isScrolling:o,scrollTop:s}=YA(t),c=(0,Y.useRef)(new Set),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!n)return;let o=l.current===n.requestId;if(o&&u.current===i)return;let s=t.current,c=e.findIndex(e=>e.key===n.key),d=a.get(c);if(!s||!d||r.height===0)return;let f=s.querySelector(`[data-media-grid]`);if(!f)return;let p=ej(s,f,d);if(o){$A(s,n.key,()=>{u.current=i});return}QA(s,n.key)?(l.current=n.requestId,u.current=i,n.onFocus()):s.scrollTo({top:p,behavior:`instant`})},[n,e,r.height,t,s,a,i]),(0,Y.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.reduce((e,t,n)=>t.pending&&!t.onVisible&&!c.current.has(t.key)?n:e,-1);if(c.current=new Set(e.map(e=>e.key)),i<0)return;let o=a.get(i),s=n.querySelector(`[data-media-grid]`);if(!o||!s)return;let l=s.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop+o.top,u=l+o.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-Math.max(0,(n.clientHeight-o.height)/2)),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,a]);let d=(0,Y.useCallback)(({data:e,width:t})=>(0,$.jsx)(ZA,{data:e,width:t}),[]);return AA({as:qA,height:r.height,isScrolling:o,itemKey:e=>e.key,items:e,overscanBy:2,positioner:a,render:d,scrollTop:s})});function nj({items:e,scrollRef:t,focus:n}){return(0,$.jsx)(`section`,{"data-media-mosaic":!0,children:(0,$.jsx)(tj,{items:e,scrollRef:t,focus:n})})}function rj(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...t.filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}var ij=`prints-prompt-counter`;function aj({busy:e,disabled:t,disabledReason:n,draft:r,label:i,onGenerate:a,promptOver:o}){return(0,$.jsx)(dT,{"aria-describedby":o?ij:void 0,"aria-label":i,className:`prints-generate`,"data-generation-submit":!0,disabled:t||o,onClick:a,state:zT({draft:r,busy:e}),title:t&&n?n:i})}function oj({caretRequest:e,disabled:t,maxLength:n,addedLength:r=0,menu:i,mentionCount:a,onCaret:o,onChange:s,onMentionDismiss:c,onMentionMove:l,onMentionPick:u,onSend:d,onSlashMove:f,onSlashPick:p,placeholder:m,slashCount:h,value:g}){let _=(0,Y.useRef)(null),v=(0,Y.useRef)(g),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(-1),[C,w]=(0,Y.useState)(!1),T=(0,Y.useRef)(!1),E=(0,Y.useRef)(!1);v.current=g,(0,Y.useLayoutEffect)(()=>{if(C||t||!E.current)return;E.current=!1;let e=_.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[t,C]),(0,Y.useLayoutEffect)(()=>{let t=_.current;!t||e?.value!==g||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,g]),VT(_,g);let D=(0,Y.useCallback)(async()=>{let e=v.current.trim();if(!(!e||t||T.current)&&!(n!==void 0&&e.length+r>n)){E.current=_.current===_.current?.ownerDocument.activeElement,T.current=!0,w(!0);try{if(!await d())return;b(t=>t.at(-1)===e?t:[...t,e].slice(-20)),S(-1)}finally{T.current=!1,w(!1)}}},[t,n,d,r]),O=g.trim().length,k=O>0?O+r:0,A=n!==void 0&&k>n;return(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(bT,{"aria-invalid":A?!0:void 0,"aria-label":`Image prompt`,className:`w-full`,"data-generation-prompt":!0,...CT(i),disabled:t===!0||C,onChange:e=>{s(e.currentTarget.value),o(e.currentTarget.selectionStart),S(-1)},onSelect:e=>{o(e.currentTarget.selectionStart)},onKeyDown:e=>{if(oT(e))return;let t=ST(e);if(a>0&&t!==null){e.preventDefault(),t===`next`?l(1):t===`previous`?l(-1):t===`accept`?u():c();return}if(g.startsWith(`/`)&&t!==null&&(h>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)s(g.slice(1));else if(h)t===`next`?f(1):t===`previous`?f(-1):p();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),D();return}if(e.key===`ArrowUp`&&_.current?.selectionStart===0&&y.length&&(x===-1||x>0)){e.preventDefault();let t=x===-1?y.length-1:x-1;S(t),s(y[t]);return}if(e.key===`ArrowDown`&&x!==-1){e.preventDefault();let t=x+1;t>=y.length?(S(-1),s(``)):(S(t),s(y[t]))}},placeholder:m,ref:_,rows:1,value:g}),n!==void 0&&k>0?(0,$.jsx)(`p`,{className:`px-3 pb-1 text-xs tabular-nums ${A?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:ij,role:A?`alert`:`status`,children:A?`${String(k)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${r>0?` or its style and characters`:``} by ${String(k-n)} or pick another model.`:`${String(k)} / ${String(n)}`}):null]})}function sj({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,$.jsx)(wT,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function cj(e,t){let[n,r]=(0,Y.useState)(0),i=t.startsWith(`/`),a=(0,Y.useMemo)(()=>{if(!i)return[];let n=iT(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,Y.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function lj({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,$.jsx)(wT,{open:!0,rows:r.map(t=>{let n=t.references.at(0)?.path,r=e.find(e=>e.path===n);return{key:String(t.id),label:`@${t.name}`,detail:t.description||void 0,media:(0,$.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:r?(0,$.jsx)(`img`,{src:r.url,alt:``}):null})}}),selected:t,listId:n,label:`Characters`,kind:`characters`,onHighlight:i,onChoose:a})}function uj(e,t){let[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),u=o===t?null:Or(t,n),d=u?oi(e,u.query):[];return(0,Y.useEffect)(()=>{a(0)},[t]),{caretRequest:c,matches:d,index:i,setCaret:r,highlight:a,dismiss:()=>{s(t)},move:e=>{a(t=>d.length?(t+e+d.length)%d.length:0)},complete:e=>{let i=d.at(e);if(!u||!i)return null;let a=`${t.slice(0,u.start)}@${i.name} ${t.slice(n)}`,o=u.start+i.name.length+2;return l({value:a,caret:o}),r(o),a}}}function dj(e){let t=ge(),n=Xn(Qr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(Lr.characters(e),n)}}),i=Nt(r((e,t,n)=>ei(e.capabilities,t,n))),a=Nt(r((e,t,n)=>zr(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?k(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var fj=Tt(Gr),pj=e=>e.split(`/`).at(-1)??e;function mj({paths:e,images:t}){return(0,$.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,$.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,$.jsx)(`img`,{src:n.url,alt:pj(e)}):null},e)})})}function hj({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,Y.useState)(null),f=(0,Y.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):fj(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,$.jsx)(Fy,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Characters`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,$.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,$.jsx)(mj,{paths:e.references.map(e=>e.path),images:t}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,$.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,$.jsx)(Xr,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,$.jsx)(qC,{"aria-label":`Character name`,"aria-invalid":!fj(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,$.jsx)(bT,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,$.jsxs)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,$.jsx)(vx,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,$.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,$.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,$.jsx)(`li`,{title:e.path,children:(0,$.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,$.jsx)(`img`,{src:e.url,alt:``}),(0,$.jsx)(`span`,{className:`prints-character-check`,children:(0,$.jsx)(OT,{"aria-label":`Use ${pj(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,$.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,$.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var gj=Yt({destination:nn(Ve(rt)),height:nn(B),model:nn(rt),prompt:nn(rt),references:nn(Te(Yt({computerId:nn(rt),path:rt,role:nn(I([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:nn(Ve(Me)),steps:nn(Ve(B)),style:nn(Ve(rt)),width:nn(B)}),_j=re(K(),h()).parse(structuredClone(be(gj,{onExcessProperty:`error`}).schema)),vj=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),yj=vj(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),bj=vj(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,_j),xj=vj(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function Sj(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(yj,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(bj,({arguments:e})=>{if(n)return;let r=tt(gj,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(xj,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function Cj(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...Pr.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(qn[t].width)} × ${String(qn[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function wj(e,t){let n=(0,Y.useRef)(e);n.current=e;let r=wu(t,{sourceId:`media-prompt`,namespace:`media`},(0,Y.useCallback)(()=>Cj(()=>n.current),[])),i=(0,Y.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,Y.useMemo)(()=>eT(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function Tj(e){let t=ge(),n=Xn(Cr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(Lr.styles(e),n)}}),i=Nt(r((e,t,n)=>ni(e.capabilities,t,n))),a=Nt(r((e,t,n)=>ii(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?k(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function Ej(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function Dj(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function Oj(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?Ej(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=zn(i,n.model),c=o??s??zn(i,a.model);if(c===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let l=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${sr(c)} instead.`:null,u=n.references.slice(0,n.typed.references),d=e===`animate`?{path:r,role:`first-frame`}:{path:r},f=[d,...u.filter(e=>!lr(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&c.input.maxReferences===0)return{kind:`refused`,message:`${c.label} does not take reference images.`};let p=e===`reuse`?u:e===`remix`?f:[d],m=Fn(a,c),h={width:n.width??m.width,height:n.height??m.height},g=o===void 0?pr(h,c,void 0):Dj(c,h.width,h.height)??m,_=o===void 0&&c.input.steps!==`fixed`&&n.steps!==null&&c.id===n.model?n.steps:m.steps,v=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:l,draft:{...m,destination:void 0,prompt:n.typed.prompt,references:p,steps:_,style:v,width:g.width,height:g.height}}}function kj({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,$.jsxs)(Gw,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,$.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,$.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function Aj({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,Y.useState)(null);return(0,$.jsx)(Fy,{open:n,onOpenChange:r,children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Styles`})}),(0,$.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,$.jsx)(Xr,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(qC,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,$.jsx)(bT,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,$.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var jj=(0,Y.lazy)(async()=>({default:(await er(()=>import(`./print-info-drawer-D_j9bQ2B.js`),__vite__mapDeps([5,1,2,6,4]),import.meta.url)).PrintInfoDrawer})),Mj=[`a mushroom knight`,`moss on a keyboard`,`a tiny house made of mushrooms`];function Nj(e){uw.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function Pj(e){let t=(0,Y.useRef)(!1),n=KC({defaultValues:Yn(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,Y.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function Fj({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,onEditStyles:o,onEditCharacters:s}){let c=t?.input.dimensions===`none`,l=t!==void 0&&t.sizes!==null,u=t?.video??null;return(0,$.jsxs)(`div`,{className:`prints-settings`,children:[(0,$.jsx)(zw,{label:`Style`,orientation:`horizontal`,children:n}),(0,$.jsx)(zw,{label:`Size`,orientation:`horizontal`,children:(0,$.jsx)(Gw,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:c,title:c?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:c?`provider`:i,children:c?(0,$.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,$.jsxs)($.Fragment,{children:[l&&!r.some(e=>e.value===i)?(0,$.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,r.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)),l?null:(0,$.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!c&&!l&&i===`custom`?(0,$.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,$.jsx)(e.Field,{name:`width`,children:e=>(0,$.jsx)(zw,{label:`Width`,children:(0,$.jsx)(qC,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,$.jsx)(e.Field,{name:`height`,children:e=>(0,$.jsx)(zw,{label:`Height`,children:(0,$.jsx)(qC,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,u?(0,$.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,$.jsx)(zw,{label:`Length`,orientation:`horizontal`,children:(0,$.jsx)(Gw,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(u.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:u.durations.map(e=>(0,$.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,u?.supportsAudio?(0,$.jsx)(e.Field,{name:`generateAudio`,children:e=>u.defaultGenerateAudio===null?(0,$.jsx)(zw,{label:`Audio`,orientation:`horizontal`,children:(0,$.jsxs)(Gw,{"aria-label":`Video audio`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,$.jsx)(`option`,{value:``,children:`Model default`}),(0,$.jsx)(`option`,{value:`on`,children:`On`}),(0,$.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,$.jsx)(zw,{label:`Audio`,orientation:`horizontal`,children:(0,$.jsx)(Mr,{"aria-label":`Video audio`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,$.jsx)(e.Field,{name:`steps`,children:e=>(0,$.jsx)(zw,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,$.jsx)(qC,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,$.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{o()},children:`Edit styles…`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Characters…`})]})]})}function Ij({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,values:c,computerId:l,mediaDirectory:u,referenceImages:d,characters:f,characterDialog:p,onSubmit:m,styleControls:h,addedLength:g}){let _=zn(i,c.model),v=c.prompt.trim().length,y=_!==void 0&&v>0&&v+g>_.maxPromptLength,b=Wn(_),x=_?.video??null,S=qr(c.references,_),C=_===void 0?void 0:Ln(S,_,x?.formats.find(e=>e.width===c.width&&e.height===c.height)?.resolution),w=_?.input.maxReferences??0,T=c.references.length>w,[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),A=_!==void 0&&_.sizes!==null,j=mr(_),M=A?`${String(c.width)}x${String(c.height)}`:E?`custom`:j.find(e=>e.width===c.width&&e.height===c.height)?.value??`custom`,[N,P]=(0,Y.useState)(!1),F=wj({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{D(!1),r.setFieldValue(`width`,qn[e].width),r.setFieldValue(`height`,qn[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),P(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[I,L]=(0,Y.useState)(!1),R=uj(f,c.prompt),z=cj(F.items,c.prompt),B=(0,Y.useId)(),ee=`${B}-commands`,V=`${B}-characters`,te=gr({computerId:l,prompt:c.prompt,saved:f,references:c.references,model:_===void 0?void 0:{label:_.label,maxReferences:_.input.maxReferences}}),ne=Ar(c.prompt,f).characters,H=e=>{let t=z.slashMatches.at(e);t&&(z.resetSlash(),F.run(t.command))},U=h({open:N,onOpenChange:P}),re=[c.style,Un(_,c.width,c.height),x&&c.durationSeconds!==void 0?`${String(c.durationSeconds)}s`:void 0,x?.supportsAudio&&c.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),W=(0,$.jsx)(Fj,{form:r,selected:_,stylePicker:U.picker,sizeChoices:j,sizeMode:M,onCustomSize:D,onEditStyles:()=>{k(!1),P(!0)},onEditCharacters:()=>{k(!1),L(!0)}});return(0,$.jsxs)(BT,{"aria-label":`Image generation`,"data-generation-form":!0,attachments:c.references.length>0?(0,$.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,children:c.references.map((e,t)=>{let n=l!==null&&lr(e,l)?d.find(t=>t.path===e.path):void 0,i=S[t]?.role,a=dr(b,S,t);return(0,$.jsxs)(`div`,{className:`prints-reference-tile`,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,$.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,$.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,$.jsxs)(`span`,{children:[`Ref `,t+1]})}),i===void 0?null:a===void 0?(0,$.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:Tn[i]}):(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${Tn[i]}. Use as ${Tn[a]}`,title:`Use as ${Tn[a]}`,onClick:()=>{r.setFieldValue(`references`,S.map((e,n)=>n===t?{...e,role:a}:e))},children:Tn[i]}),(0,$.jsx)(Wr,{icon:(0,$.jsx)(Tr,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,c.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??l,e.path]))})}):void 0,input:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),m()},children:(0,$.jsx)(r.Field,{name:`prompt`,children:e=>(0,$.jsxs)(`div`,{className:`prints-prompt`,children:[z.slashOpen?(0,$.jsx)(sj,{index:z.slashIndex,listId:ee,matches:z.slashMatches,onHighlight:z.highlightSlash,onPick:H}):null,!z.slashOpen&&R.matches.length>0?(0,$.jsx)(lj,{images:d,index:R.index,listId:V,matches:R.matches,onHighlight:R.highlight,onPick:t=>{let n=R.complete(t);n!==null&&e.handleChange(n)}}):null,(0,$.jsx)(oj,{caretRequest:R.caretRequest,menu:z.slashOpen?{open:z.slashMatches.length>0,listId:ee,selected:z.slashIndex}:{open:R.matches.length>0,listId:V,selected:R.index},mentionCount:z.slashOpen?0:R.matches.length,onCaret:R.setCaret,onMentionDismiss:R.dismiss,onMentionMove:R.move,onMentionPick:()=>{let t=R.complete(R.index);t!==null&&e.handleChange(t)},disabled:!o||a||i.length===0||s,maxLength:_?.maxPromptLength,addedLength:g,onChange:t=>{e.handleChange(t)},onSend:m,onSlashMove:z.moveSlash,onSlashPick:()=>{H(z.slashIndex)},placeholder:`What are we making?`,slashCount:z.slashMatches.length,value:e.state.value}),c.references.length>0||C!==void 0||ne.length>0?(0,$.jsxs)(`div`,{className:`prints-composer-notes`,children:[c.references.length>0?(0,$.jsxs)(`span`,{className:`prints-reference-count`,"data-generation-references":!0,"data-over-limit":T?``:void 0,role:T?`alert`:void 0,children:[c.references.length,` / `,w,` `,`references`,T?w===0?` — this model takes none; remove them or pick another model`:` — over this model's limit; remove some to generate`:null]}):null,C===void 0?null:(0,$.jsx)(`span`,{className:`prints-reference-count`,"data-generation-reference-roles":!0,"data-over-limit":``,role:`alert`,children:C}),ne.length>0?(0,$.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,"data-over-limit":te.kind===`refused`?``:void 0,role:te.kind===`refused`?`alert`:void 0,children:te.kind===`refused`?te.message:`Characters: ${ne.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t?(0,$.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,$.jsx)(`span`,{children:t.group===`Images`&&t.detail?t.detail:(0,$.jsxs)($.Fragment,{children:[t.title,`. `,t.detail]})}),t.actions?.map(e=>(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,$.jsxs)($.Fragment,{children:[e,(0,$.jsx)(r.Field,{name:`model`,children:e=>(0,$.jsx)(UD,{models:i,emptyLabel:l===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:t=>{let n=zn(i,t);if(e.handleChange(t),!n)return;let a=r.store.state.fieldMeta,o=Fn(c,n),s=pr(c,n,_);(n.input.dimensions===`none`||n.sizes!==null)&&D(!1),r.setFieldValue(`width`,s.width),r.setFieldValue(`height`,s.height),r.setFieldValue(`durationSeconds`,o.durationSeconds),r.setFieldValue(`generateAudio`,o.generateAudio),(n.input.steps===`fixed`||!a.steps?.isTouched)&&r.setFieldValue(`steps`,o.steps)},value:e.state.value})}),l&&u?(0,$.jsx)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Where new prints are saved`,children:`Saved in your Prints folder`}):null]}),action:(0,$.jsx)(aj,{busy:s,draft:c.prompt,disabled:!o||a||i.length===0||s,label:Vn(_),onGenerate:()=>{m()},promptOver:y}),items:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,$.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,$.jsx)(gx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),re.length>0?re.join(` · `):`Settings`]}),content:W}],openId:O?`settings`:null,onOpenChange:e=>{k(e===`settings`)}},children:[U.dialog,p({open:I,onOpenChange:L})]})}function Lj({connection:e}){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(e);n.current=e;let r=WD(e?.app??null),i=xu(e?.app??null)?.setup?.media===`missing`,[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=()=>{let t=e?.app;t&&(o(!0),c(!1),t.ui.openSetup(`media`).then(e=>{o(!1),c(e===`unavailable`)},e=>{o(!1),c(!0),Sn(`open-media-setup`,e)}))},u=s?(0,$.jsxs)($.Fragment,{children:[`Image setup couldn’t open.`,` `,(0,$.jsx)(`a`,{href:`https://github.com/fungi-computer/oyster#deploy-to-cloudflare`,target:`_blank`,rel:`noreferrer`,children:`Open the image setup guide`}),`.`]}):`Image generation isn’t set up yet.`,[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=tA(e?.app??null,r.computerId),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(),S=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{_(null),y(null),x(void 0)},[e,r.computerId,r.path]);let C=r.path,{gallery:w,images:T,failed:E,loading:D,gallerySlots:O,canBrowse:k,canRead:A,canWrite:j,reserveSlot:M,failSlot:N,clearSlotError:P,removeSlot:F,addComputerFile:I,retryFile:L,uploads:R,uploadFiles:z}=Gx(e,r),[B,ee]=(0,Y.useState)(Date.now),V=O.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,Y.useEffect)(()=>{if(!V)return;let e=setInterval(()=>{ee(Date.now())},1e3);return()=>{clearInterval(e)}},[V]);let te=Qu(e,(e,t,n)=>(w.refresh(),I(e,t,n)));(0,Y.useLayoutEffect)(()=>{x(void 0),te.target&&(_(null),y(null))},[te.target]);let ne=w.entries.some(e=>e.path===te.target?.path);(0,Y.useEffect)(()=>{te.target&&!ne&&w.nextPageReady&&w.loadMore()},[te.target,ne,w.nextPageReady,w.loadMore]);let H=T.find(e=>e.source.kind===`computer`&&e.source.computerId===te.target?.computerId&&e.source.path===te.target.path),U=Tj(e?.app??null),re=dj(e?.app??null),W=gS({connection:e,folder:r,styles:U.styles,characters:re.characters,effects:{reserve:M,failed:N,notifyFailure:Nj,saved:({result:e},t)=>{A?I(e.destination.path,t,e.destination.computerId):N(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:ie,models:ae,modelsLoading:G,modelsError:oe,canGenerate:se,mediaCapability:ce,pendingGenerations:le,activeGenerations:ue,recoveryError:K}=W,de=(0,Y.useRef)(ae),fe=(0,Y.useRef)(W);fe.current=W;let pe=(0,Y.useRef)(null),me=(0,Y.useRef)(null),he=(0,Y.useRef)(0),[ge,_e]=(0,Y.useState)(null),ve=(0,Y.useRef)(W.submit);ve.current=async e=>{let t=await W.submit(e);return t&&_e(null),t};let q=Pj(ve),ye=e=>{q.setFieldValue(`model`,e.model),q.setFieldValue(`width`,e.width),q.setFieldValue(`height`,e.height),q.setFieldValue(`steps`,e.steps),q.setFieldValue(`durationSeconds`,e.durationSeconds),q.setFieldValue(`generateAudio`,e.generateAudio),q.setFieldValue(`prompt`,e.prompt),q.setFieldValue(`references`,e.references),q.setFieldValue(`style`,e.style),q.setFieldValue(`destination`,void 0)},be=(0,Y.useRef)(q);be.current=q;let xe=IC(q.store,e=>e.values),Se=IC(q.store,e=>e.isSubmitting),Ce=e?.app;(0,Y.useEffect)(()=>{if(Ce)return Sj(Ce,{readDraft:()=>be.current.store.state.values,readModels:()=>de.current,setDraft:e=>{let t=be.current;if(e.model!==void 0){let n=zn(de.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=Fn(t.store.state.values,n),i=zn(de.current,t.store.state.values.model),a=pr(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>be.current.store.state.isSubmitting||fe.current.isRunning()?Promise.resolve(!1):be.current.submitCurrent()})},[Ce]),(0,Y.useEffect)(()=>{de.current=ae},[ae]),(0,Y.useEffect)(()=>{if(ae.length===0||oe)return;let e=ae.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??ae[0];if(!q.store.state.fieldMeta.model?.isTouched){let t=Fn(q.store.state.values,e);q.setFieldValue(`model`,t.model),q.store.state.fieldMeta.width?.isTouched||q.setFieldValue(`width`,t.width),q.store.state.fieldMeta.height?.isTouched||q.setFieldValue(`height`,t.height),q.store.state.fieldMeta.steps?.isTouched||q.setFieldValue(`steps`,t.steps)}},[q,oe,ae]);let we=zn(ae,xe.model),Te=xe.references,Ee=we?.input.maxReferences??0,De=(0,Y.useRef)({addComputerFile:I,retryPath:W.retryPath,uploads:R});De.current={addComputerFile:I,retryPath:W.retryPath,uploads:R};let Oe=H?Hx(H):null,ke=(0,Y.useMemo)(()=>T.map(e=>({key:Hx(e),selected:Hx(e)===Oe,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:Te.some(t=>e.source.kind===`computer`&&lr(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:Te.length>=Ee&&!Te.some(t=>e.source.kind===`computer`&&lr(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&Ee>0?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=Te.some(e=>lr(e,n)&&e.path===t);q.setFieldValue(`references`,r?Te.filter(e=>!lr(e,n)||e.path!==t):[...Te,{path:t}])}:void 0,onInfo:()=>{_(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{_(null),y(Hx(e))}})),[T,Te,Ee,q,Oe]),Ae=(0,Y.useMemo)(()=>{let e=r.computerId;if(!e)return ke;let t=new Map(ke.map(e=>[e.key,e])),n=[...w.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{w.loadFile(n.path)},error:E.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{L(n.path)}}}),i=new Set(n.map(e=>e.key));return[...n,...ke.filter(e=>!i.has(e.key)&&e.key!==Oe)]},[ke,w.entries,w.loadFile,L,E,r.computerId,Oe]),je=ie.kind===`pending`,Me=[...ue].sort().join(`|`),Ne=O.filter(e=>e.error!==void 0).length,Pe=(0,Y.useMemo)(()=>le.filter(e=>e.reference.computerId===r.computerId&&!Me.split(`|`).includes(e.reference.requestId)&&!O.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path)).map(e=>({key:`${e.reference.computerId}:${e.input.destination.path}`,path:e.input.destination.path,width:1024,height:1280,url:``,pending:!0,error:e.failure?.message??`Stopped when Prints closed. Retry to run it again.`,prompt:e.typed.prompt,onOpen:()=>void 0,onRetry:()=>{fe.current.resume(e)},onDismiss:()=>{fe.current.discard(e)}})),[le,r.computerId,Me,O]),Fe=(0,Y.useMemo)(()=>[...Pe,...rj(Ae,O,e=>{let t=R.items.find(t=>t.id===e.uploadId),r=e.error??(t?.status===`error`||t?.status===`cancelled`?t.message:void 0);return{key:e.key,path:e.path,width:e.width,height:r===void 0?e.height:Math.max(e.height,e.width*1.25),url:``,pending:!0,error:r,prompt:r===void 0?void 0:le.find(t=>t.reference.computerId===e.computerId&&t.input.destination.path===e.path)?.typed.prompt??(Ne===1?W.failedPrompt:void 0),pendingLabel:t?.status===`complete`||ie.kind===`completed`?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:Dn(ae.find(e=>e.kind===`video`),B-e.startedAt,e.resumed),onOpen:()=>void 0,onRetry:r&&(A||t&&t.status!==`complete`)?()=>{if(P(e.key),t&&t.status!==`complete`){De.current.uploads.retry(t.id);return}!e.uploadId&&De.current.retryPath(e.path)||n.current&&De.current.addComputerFile(e.path,n.current,e.computerId)}:void 0,onDismiss:r?()=>{F(e.key),e.uploadId&&De.current.uploads.remove(e.uploadId)}:void 0}})],[Pe,le,Ne,W.failedPrompt,Ae,O,R.items,ie.kind,A,ae,B]),Ie=Se||je,Le=!i&&ce&&se&&j&&C!==null&&ie.kind===`ready`&&!G&&ae.length>0,Re=O.some(e=>e.error!==void 0),ze=R.items.filter(e=>e.computerId===r.computerId),Be=ie.kind===`error`&&oe===null?{key:W.errorKey,mediaKind:ie.mediaKind,message:ie.message,billing:ie.action===`billing`&&e?()=>{e.app.ui.openTeamBilling().catch(t=>{Sn(`open-team-billing`,t),n.current===e&&W.reportRecoveryError(t)})}:void 0,prompt:W.failedPrompt,retry:Re?W.retry:void 0,dismiss:Re?()=>{for(let e of O)e.error!==void 0&&F(e.key);W.dismissFailed()}:void 0}:null,Ve=eA({connected:e!==null,mediaCapability:ce,modelsError:oe,retryModels:W.retryModels,modelsLoading:G,models:ae,canGenerate:se,mediaSetupMissing:i,canWrite:j,generationError:Be,recoveryError:K,pendingGenerations:le,activeGenerations:ue,gallerySlots:O,computerId:r.computerId,failed:E,uploadError:R.error,uploads:ze,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{W.reportRecoveryError(e)})},resume:e=>{W.resume(e)},discard:e=>{W.discard(e)},retryUpload:e=>{R.retry(e)}});h.error&&Ve.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:h.error});let He=h.visible(Ve),Ue={generating:ue.size,uploading:ze.filter(e=>e.status===`sending`||e.status===`queued`).length},We={items:ze.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{R.cancel(e)},onRetry:e=>{R.retry(e)},onRemove:e=>{R.remove(e)}},Ge=new Set([...w.entries.map(e=>`${r.computerId??``}:${e.path}`),...T.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,Ke=Kk(He,Ue,d);Cu(e?.app,[...r.available?[Qw(r.path,{checking:r.busy&&r.path===null,editing:r.editing})]:[],...Ke===null?[]:[Ke],...k?[{kind:`text`,id:`prints`,text:`${String(Ge)} ${Ge===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(m(e.anchor?.start),f(e=>!e),!0):e.itemId!==`folder`||!r.available?!1:(r.setEditing(!0),!0),t=>{Sn(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{Sn(`prints.status.toast`,e)})});let qe=T.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url}]:[]),Je=e=>{y(null),S.current+=1,x({key:e,requestId:`viewer-close-${String(S.current)}`,onFocus:()=>void 0})},Ye=(t,n,r)=>(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(jj,{image:t,app:e?.app??null,referenceImages:qe,models:ae,canAnimate:Ej(ae)!==void 0,download:r,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=Oj(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:ae,styles:U.styles.map(e=>e.name),current:q.store.state.values});return r.kind===`refused`?r.message:(ye(r.draft),_e(r.notice===null?null:{model:r.draft.model,message:r.notice}),_(null),v!==null&&Je(Hx(t)),null)},onClose:n},t.url)}),Xe={label:`Upload images`,onSelect:()=>me.current?.click(),disabled:!j||C===null,disabledReason:`Choose a writable Computer and folder to upload images.`},Ze=(0,$.jsx)(Xr,{variant:`ghost`,size:`sm`,loading:a,onClick:l,children:`Set up image generation`});return(0,$.jsxs)(`main`,{ref:t,className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":ie.kind,"data-computer-capability":k?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&j&&(e.preventDefault(),z(t.map(e=>(he.current+=1,new File([e],`paste-${String(he.current)}-${Bx(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,$.jsx)(Ew,{id:`prints-generation-notices`}),(0,$.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,$.jsx)(tx,{screen:Fe.length>0,surface:Fe.length>0,surfaceSize:`lg`,surfaceDepth:`deep`,ref:pe,className:`prints-gallery-scroll flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":D||w.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&j&&z(t)},children:(0,$.jsxs)(`div`,{className:`prints-gallery-content`,children:[Fe.length>0?(0,$.jsx)(nj,{items:Fe,scrollRef:pe,focus:v===null?b??(H&&te.target?{key:`${te.target.computerId}:${te.target.path}`,requestId:te.target.requestId,onFocus:()=>{_(null),y(Hx(H))}}:void 0):void 0}):D||w.loading?(0,$.jsx)(Zw,{"data-media-loading":!0,framed:!1,message:`Loading prints…`,detail:`Your library is on its way.`,variant:`wander`}):(0,$.jsx)(Yw,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`speech`,className:`prints-invitation`,visual:`blobs`,title:i?`Make and collect images`:`Make your first print`,description:i?`Upload images to start your collection. Open any image to view or download it.`:r.computerId===null?`Your images will appear here.`:r.available&&C===null?`Pick a folder in the composer below, then describe something or drop in images.`:`Describe something and it lands here, or drop in images from your Computer.`,primaryAction:i?Xe:void 0,actions:i?(0,$.jsxs)(`div`,{className:`prints-image-setup`,children:[(0,$.jsx)(`span`,{children:u}),Ze]}):(0,$.jsx)(Xr,{variant:`ghost`,size:`sm`,disabled:!j||C===null,onClick:()=>me.current?.click(),children:`Upload images`}),suggestions:i?void 0:Mj.map(e=>({label:e,disabled:!Le,onSelect:()=>{q.setFieldValue(`prompt`,e),t.current?.querySelector(`[data-generation-prompt]`)?.focus()}}))}),w.hasNextPage&&(0,$.jsx)(Xr,{variant:`ghost`,disabled:w.loading,onClick:w.loadMore,children:w.loading?`Loading images…`:`Load more images`})]})}),te.error?(0,$.jsx)(`p`,{role:`alert`,children:`Could not open this print. It may no longer be available on this Computer.`}):null,g&&(g.source.kind===`local`||g.source.connection===e&&g.source.computerId===r.computerId)?Ye(g,()=>{_(null)}):null]}),(0,$.jsx)($x,{items:Fe,images:T,viewerKey:v,app:e?.app??null,onNavigate:y,onClose:Je,renderInfo:(e,t)=>Ye(e,t,null)}),i&&Fe.length>0?(0,$.jsxs)(`div`,{className:`prints-library-actions`,children:[(0,$.jsx)(Xr,{size:`sm`,onClick:Xe.onSelect,disabled:Xe.disabled,children:`Upload images`}),Ze,s?(0,$.jsx)(`div`,{className:`prints-image-setup`,children:u}):null]}):null,(0,$.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,$.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,$.jsx)(`input`,{ref:me,type:`file`,disabled:!j||C===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{z(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),i?null:(0,$.jsx)(Ij,{addedLength:Er(xe.prompt,U.styles.find(e=>e.name===xe.style)?.text,re.characters),styleControls:e=>({picker:(0,$.jsx)(kj,{styles:U.styles,selected:xe.style,disabled:!ce||G||Ie,onSelect:e=>{q.setFieldValue(`style`,e)}}),dialog:(0,$.jsx)(Aj,{open:e.open,onOpenChange:e.onOpenChange,styles:U.styles,selected:xe.style,busy:U.busy,error:U.error,onSelect:e=>{q.setFieldValue(`style`,e)},onSave:U.save,onDelete:(e,t)=>{U.remove(e.id,t)}})}),characters:re.characters,characterDialog:e=>(0,$.jsx)(hj,{open:e.open,onOpenChange:e.onOpenChange,characters:re.characters,images:qe,busy:re.busy,error:re.error,canUpload:j&&C!==null,onUpload:()=>me.current?.click(),onSave:re.save,onDelete:(e,t)=>{re.remove(e.id,t)}}),guidance:He.find(e=>e.blocking&&e.group===`Setup`)??(ge!==null&&ge.model===xe.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:ge.message,actions:[{label:`Dismiss`,run:()=>{_e(null)}}]}:void 0),commandApp:Ce,actions:(0,$.jsx)(xt,{"aria-label":`Upload images`,title:j?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,$.jsx)(vx,{}),label:null,className:`prints-upload-key`,disabled:!j||C===null,onClick:()=>me.current?.click()}),form:q,mediaCapability:ce&&se&&j&&C!==null,models:ae,modelsLoading:G,onSubmit:q.submitCurrent,submitting:Ie,values:xe,computerId:r.computerId,mediaDirectory:C,referenceImages:qe}),Ke===null?null:(0,$.jsx)(Jk,{notices:He,uploads:We,open:d,inset:p,onOpenChange:f,onDismiss:h.dismiss,onDismissAll:()=>{h.dismissAll(Ve)},onLoadMore:W.hasMore?W.loadMore:void 0})]}),(0,$.jsx)(Xk,{folder:r})]})}var Rj=document.getElementById(`media-root`);if(!Rj)throw Error(`Media root is missing`);vu(Rj,{name:`Prints`,queryClient:En()},({app:e})=>(0,Y.createElement)(Lj,{connection:e?{app:e}:null}));
|
|
10
|
+
`))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:nT(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||rT.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=rT.indexOf(e.alias);return r.length===0&&t>=0?t-rT.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}var aT=Du({keyCode:ku(229)});function oT(e){return e.nativeEvent.isComposing||je(aT,e.nativeEvent).success}function sT(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:_r(t,t.easeExit),fill:`backwards`})}function cT(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:_r(t,t.ease),fill:`backwards`})}function lT(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:_r(t,t.ease),fill:`backwards`})}function uT(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:_r(t,`ease-out`)})}var dT=(0,Y.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(u,()=>d.current);let f=(0,Y.useRef)(e);(0,Y.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!kr(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=si(t),o=[];return e===`busy`?o.push(sT(r,a),lT(i,a,1)):n===`busy`&&o.push(lT(i,a,0),cT(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(uT(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,$.jsx)(xt,{...l,ref:d,className:J(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,$.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,$.jsx)(`span`,{"data-glyph":`arrow`,children:(0,$.jsx)(ix,{"aria-hidden":`true`,size:r})}),(0,$.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,$.jsx)(Sr,{decorative:!0,size:`sm`}):(0,$.jsx)(_x,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),fT=(0,Y.forwardRef)(function({className:e,label:t,...n},r){return(0,$.jsx)(xt,{...n,ref:r,className:J(`parakeet-composer-model-key`,e),label:t,readout:(0,$.jsx)(ax,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),pT=(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,ref:n,className:J(`caps-popover-anchor`,e)})}),mT=(0,Y.forwardRef)(function({className:e,open:t,side:n=`top`,...r},i){return t?(0,$.jsx)(`div`,{...r,ref:i,className:J(`caps-popover`,e),"data-side":n}):null}),hT=(0,Y.forwardRef)(function({active:e,className:t,onMouseDown:n,...r},i){return(0,$.jsx)(`div`,{role:`option`,"aria-selected":e,...r,ref:i,className:J(`caps-popover-option`,t),"data-active":e,onMouseDown:e=>{e.preventDefault(),n?.(e)}})});function gT({items:e,openId:t,onOpenChange:n,leading:r,trailing:i,renderTrigger:a,placement:o=`housing`,align:s=`end`,hostInset:c,className:l,...u}){let d=(0,Y.useId)(),f=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(new Map),h=e.find(e=>e.id===t&&!e.disabled),g=h?.id,_=()=>{g&&m.current.get(g)?.focus(),n(null)};return(0,Y.useEffect)(()=>{g&&p.current?.focus()},[g]),(0,Y.useEffect)(()=>{c===void 0?f.current?.style.removeProperty(`--caps-status-tray-host-inset`):f.current?.style.setProperty(`--caps-status-tray-host-inset`,`${String(Math.max(0,c))}px`)},[c]),(0,Y.useEffect)(()=>{if(!g)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),m.current.get(g)?.focus(),n(null))},t=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&n(null)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[g,n]),(0,$.jsxs)(pT,{...u,ref:f,className:J(`caps-status-tray`,l),"data-placement":o,"data-align":s,children:[h?(0,$.jsxs)(mT,{open:!0,ref:p,tabIndex:-1,side:`top`,id:`${d}-${h.id}`,role:`dialog`,"aria-labelledby":`${d}-title`,className:`caps-status-tray-panel`,"data-status-tray-panel":h.id,children:[(0,$.jsxs)(`div`,{className:`caps-status-tray-head`,children:[h.tone?(0,$.jsx)(eb,{size:`compact`,tone:h.tone,glyph:h.glyph??`dot`}):null,(0,$.jsx)(`span`,{id:`${d}-title`,className:`caps-status-tray-title`,children:h.title??h.label}),h.actions,(0,$.jsx)(Wr,{"aria-label":`Close tray`,icon:(0,$.jsx)(Tr,{"aria-hidden":`true`}),onClick:_})]}),(0,$.jsx)(`div`,{className:`caps-status-tray-body`,children:h.content})]}):null,o===`host`?null:(0,$.jsxs)(`div`,{className:`caps-status-tray-row`,children:[r,(0,$.jsx)(`div`,{className:`caps-status-tray-chips`,children:e.map(e=>{let r={ref:t=>{t?m.current.set(e.id,t):m.current.delete(e.id)},type:`button`,className:a?void 0:`caps-status-tray-chip`,"aria-expanded":g===e.id,"aria-controls":g===e.id?`${d}-${e.id}`:void 0,"aria-label":e.accessibleLabel,disabled:e.disabled,title:e.disabled?e.accessibleLabel:void 0,"aria-haspopup":`dialog`,"data-status-tray-chip":e.id,onClick:()=>{n(t===e.id?null:e.id)},children:(0,$.jsxs)($.Fragment,{children:[e.tone?(0,$.jsx)(eb,{size:`compact`,glyph:e.glyph??`dot`,motion:e.motion??`none`,tone:e.tone}):null,(0,$.jsx)(`span`,{className:`caps-status-tray-label`,children:e.label}),e.count!==void 0&&e.count>0?(0,$.jsx)(`span`,{className:`caps-status-tray-count`,children:e.count}):null]})};return(0,$.jsxs)(Y.Fragment,{children:[a?a(r):(0,$.jsx)(`button`,{...r}),e.after]},e.id)})}),i]})]})}function _T({children:e,className:t,...n}){return(0,$.jsx)(`div`,{...n,className:J(`caps-status-tray-list`,t),children:e})}function vT({icon:e,primary:t,secondary:n,actions:r,className:i,...a}){return(0,$.jsxs)(`div`,{...a,className:J(`caps-status-tray-item`,i),children:[e?(0,$.jsx)(`span`,{className:`caps-status-tray-icon`,children:e}):null,(0,$.jsxs)(`span`,{className:`caps-status-tray-text`,children:[(0,$.jsx)(`span`,{className:`caps-status-tray-primary`,children:t}),n?(0,$.jsx)(`span`,{className:`caps-status-tray-secondary`,children:n}):null]}),r?(0,$.jsx)(`span`,{className:`caps-status-tray-actions`,children:r}):null]})}function yT({children:e=`All caught up.`,title:t}){return(0,$.jsxs)(`div`,{className:`caps-status-tray-note`,children:[t?(0,$.jsx)(`strong`,{className:`caps-status-tray-note-title`,children:t}):null,(0,$.jsx)(`p`,{children:e})]})}var bT=(0,Y.forwardRef)(function({className:e,invalid:t,...n},r){return(0,$.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:J(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})});function xT(e,t){return`${e}-${String(t)}`}function ST(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function CT(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?xT(e.listId,e.selected):void 0}}function wT({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,$.jsx)(mT,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,$.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,$.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,$.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,$.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,$.jsxs)(hT,{id:xT(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,$.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,$.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,$.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var TT={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},ET={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function DT({state:e}){let t=`caps-checkbox-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=ai();return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=si(n.current),c=Nr(s,{ease:`inCubic`,duration:160}),l=ui(n.current,{d:{to:TT[e],...o?Jr:Nr(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?Jr:t?Nr(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Nr(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:ti(s,120),...yr(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,$.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(Kr,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,$.jsx)(Dr,{id:`${t}-shadow`}),(0,$.jsx)(wr,{id:`${t}-inset`}),(0,$.jsx)($r,{id:`${t}-goo`,values:ET}),(0,$.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,$.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,$.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,$.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,$.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,$.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,$.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,$.jsx)(`path`,{ref:n,d:TT[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,$.jsx)(`clipPath`,{id:`${t}-well`,children:(0,$.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,$.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,$.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,$.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,$.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,$.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,$.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var OT=(0,Y.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,Y.useRef)(null),[d,f]=(0,Y.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,Y.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,Y.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,Y.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,$.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,$.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:J(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,$.jsx)(DT,{state:m}):n]})}),kT=`data-glide-stand-in`;function AT(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+e.scrollLeft-e.clientLeft,y:r.top-n.top+e.scrollTop-e.clientTop,width:r.width,height:r.height}}function jT(e){return{transform:`translate(${String(e.x)}px, ${String(e.y)}px)`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}}function MT(e){let t=(0,Y.useRef)(null);return(0,Y.useCallback)(n=>{t.current?.(),t.current=n?NT(n,e):null},[e])}function NT(e,t){if(!kr(e))return()=>void 0;let n=e.ownerDocument,r=e.querySelector(t),i=r?AT(e,r):null,a=null,o=null,s=new Set,c=()=>{for(let e of s)e.removeAttribute(kT);s.clear(),a&&(a.hidden=!0),o=null},l=()=>{if(a)return a;let t=n.createElement(`span`);return t.className=`caps-glide`,t.setAttribute(`aria-hidden`,`true`),e.prepend(t),e.classList.add(`caps-glide-host`),getComputedStyle(e).position===`static`&&e.classList.add(`caps-glide-anchor`),a=t,t},u=(t,n)=>{let r=si(e),u=AT(e,t),d=o&&a?AT(e,a):i;if(i=u,o?.cancel(),c(),r.reduced||d===null||Math.abs(d.y-u.y)<1&&Math.abs(d.x-u.x)<1)return;t.setAttribute(kT,`measure`);let f=getComputedStyle(t),p=f.backgroundColor,m=f.borderRadius;for(let e of[t,n])e&&(e.setAttribute(kT,``),s.add(e));let h=l();h.hidden=!1,h.style.backgroundColor=p,h.style.borderRadius=m;let g=h.animate([jT(d),jT(u)],{duration:r.normal,easing:_r(r,r.ease),fill:`forwards`});o=g,g.addEventListener(`finish`,()=>{o===g&&c()})},d=()=>{let n=e.querySelector(t);if(n===r)return;let i=r;r=n,n&&u(n,i)},f=new MutationObserver(d);return f.observe(e,{subtree:!0,attributes:!0,attributeFilter:[`data-highlighted`,`data-active`,`data-navigation`,`aria-selected`]}),e.addEventListener(`pointerover`,d),e.addEventListener(`pointerout`,d),()=>{f.disconnect(),e.removeEventListener(`pointerover`,d),e.removeEventListener(`pointerout`,d),o?.cancel(),c(),a?.remove()}}function PT({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,Y.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}function FT({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Y.useRef(e!==void 0),[a,o]=Y.useState(()=>t);return[i&&e!==void 0?e:a,Y.useCallback(e=>{i||o(e)},[])]}var IT=Pn(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),LT=(0,Y.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,$.jsx)(`div`,{...a,className:J(IT({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,Y.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,$.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,$.jsx)(LT,{...i,className:J(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,Y.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,$.jsx)(`div`,{...n,className:J(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,Y.forwardRef)(function({className:e,level:t=3,...n},r){return(0,$.jsx)(t===2?`h2`:`h3`,{...n,className:J(`caps-card-title`,e),ref:r})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`p`,{...t,className:J(`caps-card-description`,e),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,className:J(`caps-card-content`,e),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(`div`,{...t,className:J(`caps-card-footer`,e),ref:n})});var RT=(0,Y.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,$.jsxs)(`div`,{...a,ref:o,className:J(`caps-composer`,n),children:[t===void 0?null:(0,$.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,$.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,$.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,$.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function zT({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function BT({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,$.jsxs)(pT,{className:`parakeet-composer-anchor`,children:[a,(0,$.jsxs)(LT,{...s,className:J(`parakeet-composer-shell`,r),children:[(0,$.jsx)(RT,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,$.jsx)(gT,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,$.jsx)(xt,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,$.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,$.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,$.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}function VT(e,t){(0,Y.useLayoutEffect)(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${String(t.scrollHeight)}px`)},[e,t])}var HT=Y.createContext(void 0);function UT(e){let t=Y.useContext(HT);if(t===void 0&&!e)throw Error(ed(33));return t}var WT=Y.createContext(void 0);function GT(e){let t=Y.useContext(WT);if(t===void 0&&!e)throw Error(ed(36));return t}var KT=Y.createContext(void 0);function qT(e=!0){let t=Y.useContext(KT);if(t===void 0&&!e)throw Error(ed(25));return t}var JT=Y.createContext(null);function YT(e=`root`){let t=Y.useContext(JT),n=Y.useContext(WT);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var XT={visible:!0,ref:null};function ZT(){return XT}function QT(e,t,n=`root`){let r=YT(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??ZT)({label:e.label,children:e.children,render:e.render}),a=ad(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var $T=Y.createContext(void 0);function eE(){let e=Y.useContext($T);if(e===void 0)throw Error(ed(30));return e}function tE(e){e.preventDefault()}function nE(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=GT(),u=qT(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return Y.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?tE:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:ep})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!jp&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Uf(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var rE={type:`regular-item`};function iE(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Y.useRef(null),{getButtonProps:d,buttonRef:f}=Wf({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=nE({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Y.useCallback(e=>Sd(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=ad(u,f);return Y.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var aE=Y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function oE(){return Y.useContext(aE)}function sE(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=oE(),u=Y.useRef(-1),[d,f]=Y.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Y.useRef(null),h=Y.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Q(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var cE=`data-checked`,lE=`data-unchecked`,uE={checked(e){return e?{[cE]:``}:{[lE]:``}},...Kd},dE=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=GT(),m=sE({guess:!0,label:a}),h=gp(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:S}=iE({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:rE}),C=Y.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function w(e){let t=qf(ep,e.nativeEvent,void 0,{preventUnmountOnClose:hd});u?.(!l,t)}let T=Fd(`div`,e,{state:C,stateAttributesMapping:uE,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:w},f,x],ref:[S,t,m.ref]});return(0,$.jsx)($T.Provider,{value:C,children:T})}),fE=Y.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=FT({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=QT(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(dE,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),pE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=eE(),c=Y.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=wg(s.checked);return kg({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}}),Fd(`span`,e,{state:{checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l},ref:[t,c],stateAttributesMapping:uE,props:{"aria-hidden":!0,...o},enabled:a||u})}),mE=Y.createContext(void 0);function hE(){let e=Y.useContext(mE);if(e===void 0)throw Error(ed(31));return e}var gE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gp(a),c=hE();return Q(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Fd(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),_E=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=GT(),f=sE({guess:!0,label:a}),p=gp(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=iE({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:rE});return Fd(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),vE=Y.forwardRef(function(e,t){let n=QT(e,t);return n.visible?(0,$.jsx)(_E,{...e,ref:n.ref}):null}),yE=Y.createContext(void 0);function bE(e){let t=Y.useContext(yE);if(t===void 0&&!e)throw Error(ed(69));return t}function xE(e){return e===`starting`?Uh:_d}var SE=Y.createContext(void 0);function CE(){return Y.useContext(SE)}function wE(e,t){let n=zd(e.render);if(Y.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function TE(e,t,n){let r=wE(e,t),i=r===t?void 0:r;return[r,Y.useCallback(e=>n?.(e?i:void 0),[i,n])]}function EE(e,t,n){let r=zd(e.render),i=Y.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var DE=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=GT(),m=CE(),{side:h,align:g}=UT(),_=bE(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=TE(e,u,d),L=EE(e,C,N),R=w.type===`menu`?m:void 0,z=w.type===`context-menu`,B=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(B=()=>l.state.activeIndex===null&&P),kg({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Y.useEffect(()=>{function e(e){l.setOpen(!1,qf(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),O_(D,{enabled:A&&!j&&!z&&w.type!==`menubar`,closeDelay:k});let ee=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:V,handleFocus:te}=(Y.useContext(JT)?.useParentHandoff??kE)(l,w,v,f),ne=Fd(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,ee,I],stateAttributesMapping:sf,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&Qv.has(e.key)&&e.stopPropagation()},onFocus:te},xE(y),c,{"data-rootownerid":E}]}),H=w.type===void 0||z;(C||w.type===`menubar`&&T!==`outside-press`)&&(H=!0);let U=R?.getReturnElement??V;return(0,$.jsx)(vg,{context:D,openInteractionType:M,modal:z,disabled:!x,returnFocus:a??U??H,explicitReturnFocus:a===void 0&&U?!1:void 0,initialFocus:B,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ne})}),OE={parentVirtualFocusRef:void 0,handleFocus:void 0};function kE(){return OE}var AE=Y.forwardRef(function(e,t){let n=YT()?.Popup??DE;return(0,$.jsx)(n,{...e,ref:t})}),jE=Y.createContext(void 0);function ME(){let e=Y.useContext(jE);if(e===void 0)throw Error(ed(32));return e}var NE=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=GT();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(jE.Provider,{value:n,children:(0,$.jsx)($h,{ref:t,...r,portalOwnerRole:o})})});function PE(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=Y.useState(null),d=Y.useRef(null),f=ag(n),p=Y.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Wv({...e,elements:{...p,...l&&{reference:l}}}),h=Y.useCallback(e=>{let t=mf(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=Y.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=Y.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=Y.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return Q(()=>{o&&(d.current=o)},[o]),Q(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),Y.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var FE=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Am(e,t)||{};if(l==null)return{};let d=Jm(u),f={x:n,y:r},p=Im(i),m=Pm(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=km(D,k,O),j=!c.arrow&&Mm(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),IE=(e,t)=>{let{name:n,fn:r}=FE(e);return{name:n,fn:r,options:[e,t]}},LE={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},RE={sideX:`left`,sideY:`top`},zE=`--available-width`,BE=`--available-height`,VE=`--anchor-width`,HE=`--anchor-height`,UE=`--transform-origin`,WE=zE,GE=BE;function KE(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function qE(e,t,n){let{rects:r,placement:i}=e;return{side:KE(t,jm(i),n),align:Mm(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function JE(e){return YE(e,PE)}function YE(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=Z(O),A=O?k:n,j=mm(n),M=mm(g),N=Nb()===`rtl`,[P,F]=Y.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?jm(P):null,R=P&&I?Mm(P)||`center`:null,z=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],B=R||o,ee=B===`center`?z:`${z}-${B}`,V=l;typeof V==`number`?V={top:V,right:V,bottom:V,left:V}:V&&={top:V.top||0,right:V.right||0,bottom:V.bottom||0,left:V.left||0};let te=+(i===`bottom`),ne=+(i===`top`),H=+(i===`right`),U=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:V},W=Y.useRef(null),ie=mm(a),ae=mm(s),G=typeof a==`function`?0:a,oe=typeof s==`function`?0:s,se=[];p&&se.push(p),se.push(Gv(e=>{let t=qE(e,i,N),n=typeof ie.current==`function`?ie.current(t):ie.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[G,oe,N,i]));let ce=w===`none`&&C!==`shift`,le=!ce&&(u||E||C===`shift`),ue=C===`none`?null:Jv({...re,padding:{top:V.top+1+te,right:V.right+1+U,bottom:V.bottom+1+ne,left:V.left+1+H},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),K=ce?null:Kv({...re,rootBoundary:D,mainAxis:w!==`none`,crossAxis:le,limiter:u||E?void 0:qv(e=>{if(!W.current)return{};let{width:t,height:n}=W.current.getBoundingClientRect(),r=Fm(jm(e.placement)),i=r===`y`?t:n,a=r===`y`?V.left+V.right:V.top+V.bottom;return{offset:i/2+a/2}})},[re,u,E,D,V,w]);C===`shift`||w===`shift`||B===`center`?se.push(K,ue):se.push(ue,K),se.push(Yv({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(WE,`${t}px`),i.setProperty(GE,`${n}px`);let a=df(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(VE,`${u}px`),i.setProperty(HE,`${d}px`)}}),IE(e=>({element:W.current||Hf(e.elements.floating).createElement(`div`),padding:W.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=jm(r),u=Mm(r),d=Fm(l)===`y`,f=W.current,p=typeof a==`function`?a(qE(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return le&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(UE,d?`${m} ${h}`:`${h} ${m}`),{}}},LE,b),Q(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=Y.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:ve,context:q,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:ee,middleware:se,strategy:r,whileElementsMounted:m?void 0:(...e)=>Mv(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=ge.adaptiveOrigin||RE,Ce=ye?r:`fixed`,we=Y.useMemo(()=>{let e;return e=ye?b?{position:Ce,[xe]:me,[Se]:he}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[WE]=`100vw`,e[GE]=`100vh`,ye||(e.opacity=0),e},[b,Ce,xe,me,Se,he,be,ye]),Te=Y.useRef(null);Q(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(XE(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[g,fe,A,j]),Y.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&XE(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[g,fe,A,j]),Y.useEffect(()=>{if(m&&g&&pe.reference&&pe.floating)return Mv(pe.reference,pe.floating,_e,de)},[m,g,pe,_e,de]);let Ee=jm(ve),De=KE(i,Ee,N),Oe=Mm(ve)||`center`,ke=!!ge.hide?.referenceHidden;Q(()=>{x&&g&&ye&&(Ee!==z||I&&Oe!==B)&&F(ve)},[x,I,g,ye,ve,Ee,Oe,z,B]);let Ae=Y.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),je=ge.arrow?.centerOffset!==0;return Y.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:W,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:q,isPositioned:ye,update:_e}),[we,Ae,W,je,De,Oe,Ee,ke,fe,q,ye,_e])}function XE(e){return e!=null&&`current`in e}function ZE(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Z(i),[,o]=Y.useState(0),s=id($E).current,c=id(QE).current,l=Y.useRef(0),u=Y.useRef(!0),d=Y.useRef(null),f=Y.useRef(null),p=Z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Z((e,t)=>{c.set(e,t),p()}),h=Z(e=>{c.delete(e),p()}),g=Z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!nD(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&rD(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=tD(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Z(()=>{let[e,t]=eD(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Q(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Q(()=>{u.current&&v()}),Q(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Z(e=>(s.add(e),()=>{s.delete(e)})),b=Y.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,$.jsx)(aE.Provider,{value:b,children:t})}function QE(){return new Map}function $E(){return new Set}function eD(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>rD(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function tD(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function nD(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function rD(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function iD(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Y.useRef(null),o=Y.useRef(null),s=Og(r);Q(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Q(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}function aD(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Fd(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},xE(r),i],stateAttributesMapping:of})}var oD=20;function sD(e,t,n,r){let[i,a]=Y.useState(!1);Q(()=>{if(!e||!t||n==null){a(!1);return}let r=Hf(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-oD)},[e,t,n]),gy(e&&(!t||i),r)}var cD=Y.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Gh,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=GT(),x=ME(),S=qT(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),z=n,B=c,ee=l,V=s,te=h;C.type===`context-menu`&&(z=n??C.context?.anchor,V??=`start`,!o&&V!==`center`&&(ee=e.alignOffset??2,B=e.sideOffset??-5));let ne=o,H=V;C.type===`menu`?(ne??=`inline-end`,H??=`start`,te=e.collisionAvoidance??Kh):C.type===`menubar`&&(ne??=C.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let U=C.type===`context-menu`,re=JE({anchor:z,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ne,sideOffset:B,align:H,alignOffset:ee,arrowPadding:U?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:te,shift:U?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});Y.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,qf(cp)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),Y.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,qf(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let W=xp();Y.useEffect(()=>{D||W.clear()},[D,W]),Y.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?W.isStarted()||W.start(e,()=>{v.setOpen(!1,qf(cp))}):v.setOpen(!1,qf(cp))}else W.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,W]),Y.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),iD({store:v,domReference:R,positionerElement:M,open:D});let ie={open:D,side:re.side,align:re.align,anchorHidden:re.anchorHidden,nested:C.type===`menu`,instant:N},ae=C.type===`menubar`&&C.context.modal;sD(D&&(ae||O&&F!==`trigger-hover`),k===`touch`,M,A);let G=aD(e,ie,{styles:re.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),oe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),se=null;return C.type===`menubar`?se=C.context.contentElement:C.type===void 0&&(se=A),(0,$.jsxs)(HT.Provider,{value:re,children:[oe&&(0,$.jsx)(iy,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:ry(!D),cutout:se}),(0,$.jsx)(sg,{id:I,children:(0,$.jsx)(ZE,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:G})})]})}),lD=Y.createContext(null);function uD(e){let t=Y.useContext(lD);if(t===null&&!e)throw Error(ed(5));return t}function dD(e){return e==null?Yf:e.type.startsWith(`key`)?ap:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?op:Yf}var fD={...y_,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=y_.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Np&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!y_.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},pD=class extends u_{constructor(e,t,n=!1){let r=new Wg,i=hD(r,t,n,e);super(i,mD(r),fD),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function mD(e){return{positionerRef:Y.createRef(),popupRef:Y.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function hD(e,t,n=!1,r){return{...p_(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:_d,inputProps:_d,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new tg,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:_d,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var gD=Y.createContext(null);function _D(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function vD(e,t){return e===`list-navigation`||_D(e,t)}var yD=$g(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=qT(!0),C=GT(!0),w=uD(!0),T=C?.store,E=C?.virtualFocus??!1,D=Y.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=gp(),k=gp(),[A,j]=Y.useState(void 0),M=(A??k)||void 0,N=ig(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=id(()=>F?P?.state.instantType:void 0).current,L=id(()=>{let e=new pD({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),z=og(R),B=L.useState(`open`),ee=L.useState(`activeTriggerElement`),V=L.useState(`positionerElement`),te=L.useState(`hoverEnabled`),ne=L.useState(`disabled`),H=L.useState(`lastOpenChangeReason`),U=L.useState(`parent`),re=L.useState(`activeIndex`),W=L.useState(`keyboardOpen`),ie=L.useState(`payload`),ae=L.useState(`floatingParentNodeId`),G=Y.useRef(null),oe=Y.useRef(U.type!==`context-menu`),se=xp(),ce=Y.useRef(!0),le=xp(),ue=ae!=null,{openMethod:K,triggerProps:de}=Oy(B);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:U.type===void 0?c:void 0,openMethod:K,rootId:O}),Bg(L);let{forceUnmount:fe,transitionStatus:pe}=Vg(B,L,()=>{L.set(`allowMouseEnter`,!1)},F),me=Og(L.context.popupRef);Y.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!B){e();return}if(pe!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return me(e,t.signal),()=>{t.abort()}},[I,B,pe,me,L]),Q(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:z,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:z,floatingParentNodeId:N})},[S,C,z,N,ee,L]),Y.useEffect(()=>{if(B||(G.current=null),U.type===`context-menu`){if(!B){se.clear(),oe.current=!1;return}se.start(500,()=>{oe.current=!0})}},[se,B,U.type]),Q(()=>{!B&&!te&&L.set(`hoverEnabled`,!0)},[B,te,L]);let he=Z((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||B===e&&t.trigger===ee&&H===n)return;let i=Rg(t);if(!e&&t.trigger==null&&(t.trigger=ee??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!ce.current)return;e&&n===`trigger-focus`?(ce.current=!1,le.start(300,()=>{ce.current=!0})):(ce.current=!0,le.clear());let o=!e&&(n===`escape-key`||n==null);G.current=t.event;let s=Lg(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&vD(n,a),s.instantType=U.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:_D(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),ge=Cg({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:he}),_e=ge.context.events;Q(()=>{let e=({open:e,eventDetails:t})=>he(e,t);return _e.on(`setOpen`,e),()=>{_e?.off(`setOpen`,e)}},[_e,he]),Q(()=>L.subscribeToParentMenu(),[L]);let ve=Y.useCallback(()=>{L.setOpen(!1,qf(lp))},[L]);Y.useImperativeHandle(d,()=>({unmount:fe,close:ve}),[fe,ve]);let q;U.type===`context-menu`&&(q=U.context),Y.useImperativeHandle(q?.positionerRef,()=>V,[V]),Y.useImperativeHandle(q?.actionsRef,()=>({setOpen:he}),[he]);let ye=Sg(ge,{enabled:!ne,bubbles:{escapeKey:f&&U.type===`menu`},outsidePress(){return U.type!==`context-menu`||G.current?.type===`contextmenu`||oe.current},externalTree:ue?R:void 0}),be=Nb(),xe=L_(ge,{enabled:!ne,listRef:L.context.itemDomElements,activeIndex:re,virtual:v,nested:U.type===`menubar`||!v&&U.type!==void 0,parentOrientation:U.type===`menubar`?U.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?W:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:be===`rtl`,disabledIndices:gd,onNavigate(e,t){L.setActiveIndex(e,dD(t),t?.nativeEvent)},openOnArrowKeyDown:U.type!==`context-menu`&&!(v&&_),externalTree:!v&&ue?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Se=Y.useCallback(e=>{L.context.typingRef.current=e},[L]),Ce=R_(ge,{enabled:!ne&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:re,resetMs:500,onMatch:(e,t)=>{B&&e!==re&&L.setActiveIndex(e,ap,t.nativeEvent)},onTyping:Se}),we=Z(a),Te=Y.useRef(-1),Ee=Z(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Te.current===n&&L.context.reportedItem===t)return;Te.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=Yf,L.context.highlightEvent=void 0,a&&we(t,Jf(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});Q(()=>{Ee()},[re,Ee]);let De=Y.useMemo(()=>{if(!v)return xe.reference;if(!xe.trigger)return _d;let{onFocus:e,...t}=xe.trigger;return t},[v,xe.reference,xe.trigger]);L.useSyncedValue(`inputProps`,v?xe.reference??_d:_d);let Oe=Y.useMemo(()=>{let e=Sd(Ce.reference,De,ye.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=B,e},[L,Ce.reference,De,ye.reference,de,B]),ke=Y.useMemo(()=>{let e=Sd(xe.trigger,ye.trigger,de);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[xe.trigger,ye.trigger,de]);id(()=>(L.update({inactiveTriggerProps:ke}),null)),Hg(L,{floatingRootContext:ge,activeTriggerProps:Oe,inactiveTriggerProps:ke,popupProps:Y.useMemo(()=>Sd(jg,{onMouseMove(){L.set(`allowMouseEnter`,!0),U.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ce.floating,xe.floating,ye.floating),[U.type,L,Ce.floating,xe.floating,ye.floating]),itemProps:xe.item??_d});let Ae=Y.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ee}),[L,D,u,l,b,k,v,E,Ee]),je=typeof t==`function`?t({payload:ie}):t,Me=(0,$.jsxs)(WT.Provider,{value:Ae,children:[p&&(0,$.jsx)(Pg,{handle:p,store:L}),je]});return(U.type===void 0||U.type===`context-menu`)&&(Me=(0,$.jsx)(cg,{externalTree:R,children:Me})),Me});function bD(e){let t=Y.useContext(gD);if(t===null)return(0,$.jsx)(yD,{...e});let n=t.Root;return(0,$.jsx)(gD.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var xD=5;function SD(e,t){let n=CD(t);return e.clientX>=n.left-xD&&e.clientX<=n.right+xD&&e.clientY>=n.top-xD&&e.clientY<=n.bottom+xD}function CD(e){let t=e.getBoundingClientRect(),n=df(e);if(Fp)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function wD(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Bf(),{ref:i,index:a}=sE(e),o=n===a,s=Y.useRef(null),c=ad(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function TD(e){let{render:t,className:n,style:r,state:i=_d,props:a=gd,refs:o=gd,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=wD({metadata:s});return Fd(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function ED(e){if(hf(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Df(e))return ED(Af(e))}function DD(e,t){function n(n,r,i){let a=n.currentTarget;Jh.flushSync(()=>{e.setOpen(!1,qf(np,n.nativeEvent,a))}),Ch(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&wh(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function OD(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Y.useRef(!1);return Y.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Hf(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:_d,[t,n,r])}var kD=e_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=GT(!0),h=b_(d)??m?.store;if(!h)throw Error(ed(85));let g=gp(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=Y.useRef(null),S=jD(),C=Bf(!0),w=ag(),T=Y.useMemo(()=>w??new tg,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=zg(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:og(T),floatingParentNodeId:ig(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Wf({disabled:A,native:o});Y.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=Y.useRef(null),P=xp(),F=Z(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Up(N.current,t)||Up(h.select(`positionerElement`),t)||t===N.current||(t==null||ED(t)!==h.select(`rootId`))&&(SD(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:sp}))});Y.useEffect(()=>{let e=Hf(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=A_(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:K_({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=AD(y,h.select(`lastOpenChangeReason`)),z=yg(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),B=S_(v,{enabled:!A&&I}),ee=OD({open:y,enabled:O,mouseDownAction:`open`}),V=Y.useMemo(()=>Sd(B.reference,z.reference),[B.reference,z.reference]),te=h.useState(`triggerProps`,D),ne=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:H,handleFocusTargetFocus:U}=DD(h,x),re={disabled:A,open:y},W=[N,t,M,E,x],ie=[V,L??_d,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),Hf(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ne,O?{role:`menuitem`}:{},ee,p,j],ae=Fd(`button`,e,{enabled:!O,stateAttributesMapping:af,state:re,ref:W,props:ie});return O?(0,$.jsx)(TD,{tag:`button`,render:n,className:r,style:i,state:re,refs:W,props:ie,stateAttributesMapping:af}):y?(0,$.jsxs)(Y.Fragment,{children:[(0,$.jsx)(Sm,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:H},`${g}-pre-focus-guard`),(0,$.jsx)(Y.Fragment,{children:ae},g),(0,$.jsx)(Sm,{ref:h.context.triggerFocusTargetRef,onFocus:U},`${g}-post-focus-guard`)]}):(0,$.jsx)(Y.Fragment,{children:ae},g)});function AD(e,t){let n=xp(),[r,i]=Y.useState(!1);return Q(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function jD(){let e=uD(!0);return Y.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var MD=Y.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Fd(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),ND=(0,Y.createContext)(null);function PD({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Y.useRef)(null),o=e??a;return Ny(()=>o.current?.close()),(0,$.jsx)(ND.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(bD,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function FD(){let e=(0,Y.useContext)(ND);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var ID=(0,Y.forwardRef)(function({className:e,render:t,type:n=`button`,...r},i){return(0,$.jsx)(kD,{...r,className:t=>J(`btn caps-dropdown-trigger`,et(e,t)),ref:i,render:t,type:n})}),LD=(0,Y.forwardRef)(function({container:e,...t},n){let r=My(`popover`);return e==null&&r===null?null:(0,$.jsx)(NE,{...t,container:e??r,ref:n})}),RD=(0,Y.forwardRef)(function({collisionBoundary:e,...t},n){let r=My(`popover`);return(0,$.jsx)(cD,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),zD=(0,Y.forwardRef)(function({className:e,finalFocus:t,...n},r){let{interactionOwner:i}=FD(),a=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(r,()=>a.current);let o=MT(`.caps-dropdown-item[data-highlighted]`),s=(0,Y.useCallback)(e=>{a.current=e,o(e)},[o]);return(0,$.jsx)(AE,{...n,className:t=>J(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,et(e,t)),finalFocus:i===`host`?!1:t??!0,ref:s})}),BD=(0,Y.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(LD,{container:r,keepMounted:i,children:(0,$.jsx)(RD,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(zD,{...s,ref:c,children:n})})})}),VD=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`;(0,Y.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:r=`default`,...i},a){return(0,$.jsx)(vE,{...i,className:t=>J(VD,r===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,et(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:a})});var HD=(0,Y.forwardRef)(function({children:e,className:t,onClick:n,onSelect:r,...i},a){return(0,$.jsxs)(fE,{...i,className:e=>J(VD,et(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||r?.(e)},ref:a,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(pE,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})});(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(MD,{...t,className:t=>J(`my-xs h-px bg-base-300`,et(e,t)),ref:n})}),(0,Y.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(gE,{...t,className:t=>J(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,et(e,t)),ref:n})});function UD({disabled:e,emptyLabel:t,models:n,onChange:r,value:i}){let a=n.find(e=>e.id===i),[o,s]=(0,Y.useState)(null);return(0,$.jsx)(`span`,{className:`contents`,ref:s,children:(0,$.jsxs)(PD,{children:[(0,$.jsx)(ID,{"aria-label":`Generation model`,"data-generation-model":i,disabled:e||n.length===0,render:(e,n)=>(0,$.jsx)(fT,{...e,expanded:n.open,label:a===void 0?t:sr(a)})}),(0,$.jsx)(BD,{"data-generation-model-menu":!0,container:o,side:`top`,align:`start`,"aria-label":`Generation models`,children:n.map(e=>(0,$.jsx)(HD,{"data-generation-model-option":e.id,checked:e.id===i,closeOnClick:!0,onSelect:()=>{r(e.id)},children:sr(e)},e.id))})]})})}function WD(e){let t=Su(e),n=(0,Y.useRef)(e);n.current=e;let r=ge(),i=Xn(vr(e)),a=xa(Lx(e,i.data?.configured?i.data.path:null)),[o,s]=(0,Y.useState)(null),c=n=>n?.app===e&&n.computerId===t,l=Nt({mutationKey:Lr.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new u(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(yn).mkdir({path:r}),a(),await xn(e.capabilities,{path:r,limit:1,offset:0}),a(),jn(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&s(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:Ix.listing(n.owner,n.path),exact:!0})])}),d=l.variables?.owner===e&&l.variables.id===t,f=i.isFetching||d&&l.isPending,p=async(n,r)=>{if(!e||!t||f)return`Computer selection changed. Try again.`;let i=n.trim();if(!Tt(wn)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await l.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:Lr.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},m=i.isError||a.isError;return{path:m?null:i.data?.path??null,galleryPath:m||!i.data?.configured?null:i.data.path,computerId:t,available:e?.capabilities.has(Mn)===!0,writable:e?.capabilities.has(yn)===!0,busy:f,error:m?`Your media folder is unavailable. Choose or create a folder.`:null,editing:c(o),setEditing:n=>{s(n?{app:e,computerId:t}:null)},choose:p,ensureCreated:async()=>i.data?i.data.configured?null:p(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:Ix.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:Lr.folder(e),exact:!0})}}}var GD=St(rt),KD=St(Yt({message:rt}));function qD(e){for(let t of e.errors){let e=w(Le(zt(KD(t),e=>e.message),()=>GD(t)));if(e!==void 0&&e.length>0)return e}}var JD={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},YD=(0,Y.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,$.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:J(`progress caps-gooey-motion caps-gooey-progress w-full`,JD[t],e),ref:r})});(0,Y.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,$.jsxs)(`div`,{...a,ref:o,className:J(`caps-game-meter`,i),children:[(0,$.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,$.jsx)(YD,{"aria-label":e,value:t,max:n,tone:r})]})});function XD({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,$.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,$.jsx)($D,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function ZD({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,$.jsx)(Wr,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,$.jsx)(Zr,{}):(0,$.jsx)(Tr,{}),onClick:()=>void n(t),type:`button`}):null}function QD({item:e}){return(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,$.jsx)(`div`,{className:`caps-upload-details`,children:(0,$.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function $D({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,$.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,$.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,$.jsx)(lx,{className:`size-4`})}),(0,$.jsx)(QD,{item:e}),(0,$.jsx)(eO,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,$.jsx)(YD,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function eO({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,$.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,$.jsx)(ZD,{action:e.retry,id:t,onAction:i,retry:!0}),(0,$.jsx)(ZD,{action:e.cancel,id:t,onAction:n}),(0,$.jsx)(ZD,{action:e.remove,id:t,onAction:r})]})}var tO=Y.createContext(void 0);function nO(e){let t=Y.useContext(tO);if(t===void 0&&!e)throw Error(ed(47));return t}var rO={...y_,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!y_.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&y_.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>y_.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},iO=class extends u_{constructor(e,t,n){let r=new Wg;super(aO(e,r,t,n),oO(r),rO)}setOpen=(e,t)=>{let n=t.reason===Zf,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Rg(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Lg(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Jh.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function aO(e,t,n,r=!1){let i={...p_(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function oO(e){return{popupRef:Y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Y.createRef(),beforeTriggerFocusGuardRef:Y.createRef(),beforeContentFocusGuardRef:Y.createRef(),stickIfOpenTimeout:new bp,stickIfOpen:!0,triggerElements:e}}var sO=$g(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=lO(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Ug(u,d),Bg(u);let{forceUnmount:m}=Vg(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),Y.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),Y.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,qf(lp))}),[m,u]);let h=d||f||s!=null;return(0,$.jsxs)(tO.Provider,{value:u,children:[s&&(0,$.jsx)(Pg,{handle:s,store:u}),h&&(0,$.jsx)(uO,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function cO(e){return nO(!0)?(0,$.jsx)(sO,{props:e}):(0,$.jsx)(cg,{children:(0,$.jsx)(sO,{props:e})})}function lO(e,t){let n=Ng((e,n)=>new iO(t,e,n));return Y.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function uO({store:e,modal:t}){let n=Sg(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Hg(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var dO=e_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=nO(!0),h=b_(s)??m;if(!h)throw Error(ed(74));let g=gp(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=Y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=zg(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=A_(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:K_(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=yg(v,{stickIfOpen:Z(()=>h.context.stickIfOpen)}),k=Dy(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=Wf({disabled:a,native:o}),N={open(e){return w?af.open(e):rf.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=DD(h,x),I=Fd(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[Wh]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,$.jsx)(Y.Fragment,{children:I},g);return E?(0,$.jsxs)(Y.Fragment,{children:[(0,$.jsx)(Sm,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,$.jsx)(Sm,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),fO=Y.createContext(void 0);function pO(){let e=Y.useContext(fO);if(e===void 0)throw Error(ed(45));return e}var mO=Y.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return nO().useState(`mounted`)||n?(0,$.jsx)(fO.Provider,{value:n,children:(0,$.jsx)($h,{ref:t,...r})}):null}),hO=Y.createContext(void 0);function gO(){let e=Y.useContext(hO);if(!e)throw Error(ed(46));return e}var _O=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Kh,..._}=e,v=nO(),y=pO(),b=og(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=JE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});iD({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;sD(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=aD(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,$.jsxs)(hO.Provider,{value:j,children:[S&&M&&(0,$.jsx)(iy,{inert:ry(!C),cutout:T}),(0,$.jsx)(sg,{id:b,children:P})]})}),vO=Y.createContext(void 0);function yO(){let[e,t]=Y.useState(0),n=Z(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Y.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var bO=Y.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=nO(),l=gO(),u=bE(!0)!=null,{context:d,hasClosePart:f}=yO(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);kg({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),O_(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Mg(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Fd(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...jg,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Qv.has(e.key)&&e.stopPropagation()}},xE(g),s],stateAttributesMapping:sf});return(0,$.jsx)(vg,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:hf(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,$.jsx)(vO.Provider,{value:d,children:M})})}),xO=(0,Y.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,$.jsxs)(`button`,{...r,ref:i,type:n,className:J(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(ax,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function SO({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(t),[x,S]=(0,Y.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,Y.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=PT({getKey:n,isDisabled:o,items:T});(0,Y.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(oT(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,Y.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function CO(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,Y.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:R,onPointerMove:z,activeItem:B,activeKey:ee,commit:V,groups:te,inputValue:ne,listboxId:H,onInputChange:U,onInputKeyDown:re,open:W,optionId:ie,selectedKeys:ae,setOpen:G}=SO({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});Ny(()=>{O&&G(!1)});let oe=My(`popover`),se=s===void 0?oe:s,ce=MT(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),le=(0,$.jsx)(qC,{..._,...O?{}:L,"aria-activedescendant":B?ie(f(B)):void 0,"aria-autocomplete":`list`,"aria-controls":H,"aria-expanded":!0,className:J(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),U(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||re(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ne}),ue=(0,$.jsx)(`div`,{id:H,ref:ce,className:`caps-combobox-list`,"data-navigation":R?`keyboard`:`pointer`,onPointerMove:z,role:`listbox`,"aria-multiselectable":C??void 0,children:te.every(e=>e.items.length===0)?(0,$.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):te.map(e=>(0,$.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,$.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=ee===t,i={active:r,disabled:n,selected:ae.includes(t)};return(0,$.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&R,disabled:n,id:ie(t),onClick:()=>{V(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,$.jsx)(Hr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,$.jsx)(`div`,{...j,className:J(j.className),ref:D,children:(0,$.jsxs)(cO,{modal:!0,onOpenChange:G,open:W,children:[(0,$.jsx)(dO,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),se===null?null:(0,$.jsx)(mO,{container:se,children:(0,$.jsx)(_O,{align:`start`,side:`bottom`,sideOffset:4,children:(0,$.jsxs)(bO,{"data-active-tone":o,className:J(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,$.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})})]})}):(0,$.jsx)(`div`,{...j,className:J(j.className),ref:D,children:(0,$.jsxs)(`div`,{className:J(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,$.jsx)(`div`,{className:`caps-combobox-search`,children:le}),ue]})})}function wO({icon:e,caption:t}){return(0,$.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,$.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,$.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var TO=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,$.jsx)(OT,{...a,appearance:r??`default`,"aria-label":e,className:J(`caps-icon-choice-input`,i),indicator:(0,$.jsx)(wO,{icon:t,caption:n}),ref:o})})}),EO=(0,Y.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,Y.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,$.jsx)(`label`,{className:`caps-check-key`,children:(0,$.jsx)(OT,{...i,"aria-label":e,"aria-describedby":s,className:J(`caps-check-key-input`,r),indicator:(0,$.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,$.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,$.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,$.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,$.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,$.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function DO({className:e,...t}){return(0,$.jsx)(`div`,{...t,className:J(`caps-check-keys`,e)})}function OO({checked:e}){let t=`caps-radio-${(0,Y.useId)().replaceAll(`:`,``)}`,n=(0,Y.useRef)(null),r=(0,Y.useRef)(e).current,i=(0,Y.useRef)(e),a=(0,Y.useRef)(null),o=xr(a),{reduced:s}=o;return(0,Y.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Nr(o,{ease:`outCubic`,duration:75}),c=e?yr(o,{bounce:.65,duration:300}):Nr(o,{ease:`inCubic`,duration:100}),l=ui(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,$.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsx)(Kr,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,$.jsx)(Dr,{id:`${t}-shadow`}),(0,$.jsx)(wr,{id:`${t}-inset`}),(0,$.jsx)(`clipPath`,{id:`${t}-well`,children:(0,$.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,$.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,$.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,$.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var kO=(0,Y.createContext)(null),AO=(0,Y.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,Y.useId)(),d=(0,Y.useRef)(null);(0,Y.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,Y.useState)(n),h=s??p;return(0,Y.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,$.jsx)(kO.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,$.jsx)(`fieldset`,{...c,className:J(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),jO=(0,Y.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,Y.useContext)(kO);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,$.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,$.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:J(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,$.jsx)(OO,{checked:c}):t]})}),MO=(0,Y.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,Y.useContext)(kO),s=(0,Y.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,$.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,$.jsx)(jO,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,$.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,$.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,$.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,$.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),NO=(0,Y.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,$.jsx)(jO,{...a,"aria-label":e,className:J(`caps-icon-choice-input`,i),indicator:(0,$.jsx)(wO,{icon:t,caption:n}),ref:o})})});(0,Y.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,$.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,$.jsx)(jO,{...r,"aria-label":e,className:J(`caps-icon-choice-input`,n),indicator:(0,$.jsx)(wO,{icon:(0,$.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var PO=St(rt),FO=St(Me),IO=St(Ve(E)),LO=St(Te(rt)),RO=Te(Ft(File)),zO=St(RO),BO=Ge([rt,E,Me,Fe,Ut,Te(rt),RO]),VO=St(BO),HO=e=>Ce(PO(e.state.value),()=>``),UO=e=>Ce(FO(e.state.value),()=>!1),WO=e=>Ce(IO(e.state.value),()=>null),GO=e=>Ce(LO(e.state.value),()=>[]),KO=e=>Ce(zO(e.state.value),()=>[]),qO=e=>Ce(VO(e.state.value),()=>null);function JO({field:e,spec:t,locked:n,...r}){let[i,a]=(0,Y.useState)(!1);return(0,$.jsxs)(Ow,{children:[(0,$.jsx)(qC,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:HO(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,$.jsx)(sx,{"aria-hidden":`true`}):(0,$.jsx)(cx,{"aria-hidden":`true`})})]})}var YO={text:`text`,email:`email`,url:`url`,tel:`tel`};function XO({spec:e,field:t,locked:n,...r}){let i=KO(t),a=n||e.readOnly===!0,o=(0,Y.useRef)(null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,$.jsx)(jr,{asChild:!0,children:(0,$.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,$.jsx)(Xr,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,$.jsx)(XD,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function ZO({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,$.jsx)(qC,{...a,type:YO[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,$.jsx)(bT,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,$.jsx)(JO,{...r,field:t,spec:e,locked:n});case`money`:return(0,$.jsxs)(Ow,{children:[(0,$.jsx)(kw,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,$.jsx)(qC,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,$.jsx)(qC,{...a,type:`date`,readOnly:e.readOnly,value:HO(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,$.jsx)(Ww,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:WO(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,$.jsxs)(Gw,{...a,value:HO(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,$.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,$.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,$.jsx)(CO,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:HO(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,$.jsx)(xO,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===HO(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,$.jsx)(XO,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,$.jsx)(OT,{...a,disabled:n||e.readOnly===!0,checked:UO(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,$.jsx)(Mr,{...a,disabled:n||e.readOnly===!0,checked:UO(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var QO=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function $O({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=GO(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,$.jsx)(Lw,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,$.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,$.jsx)(TO,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,$.jsx)(DO,{children:e.options.map(r=>(0,$.jsx)(EO,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,$.jsx)(Lw,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,$.jsx)(AO,{name:e.name,"aria-label":o,value:HO(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,$.jsx)(NO,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,$.jsx)(MO,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,$.jsx)(zw,{label:t.label,orientation:`inline`,children:(0,$.jsx)(jO,{value:t.value,disabled:t.disabled})},t.value))})})}function ek({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:qO(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function tk({form:e,spec:t,locked:n,layout:r}){let i=RC({form:e,name:t.name}),a=IC(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?qD(i.state.meta):void 0;if(t.render===void 0&&QO.has(t.kind))return(0,$.jsx)($O,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,$.jsx)(zw,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,$.jsx)(ZO,{spec:t,field:i,locked:n}):(0,$.jsx)(ek,{spec:t,field:i,locked:n,error:o,render:t.render})})}var nk=St(r(rt,BO));function rk({form:e,spec:t,locked:n,layout:r}){let i=t.when;return IC(e.store,e=>i===void 0||i(Ce(nk(e.values),()=>({}))))?(0,$.jsx)(tk,{form:e,spec:t,locked:n,layout:r}):null}function ik({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,$.jsx)(rk,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,$.jsx)(Iw,{title:t.title,description:t.description,layout:r,children:i})}function ak({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,$.jsx)(ik,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,$.jsx)(rk,{form:i,spec:a,locked:n,layout:r},t)})}var ok=class{annotation;constructor(e){this.annotation=e}},sk=class{sections;constructor(e){this.sections=e}},ck=`caps/form`,lk=0;function uk(e){lk+=1;let t={[`${ck}:${String(lk)}`]:new ok(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}rt.annotate(uk({kind:`secret`})).pipe(jt(`Secret`));var dk=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function fk(e){return Object.values(e??{}).reduce((e,t)=>t instanceof ok?{...e,...t.annotation}:e,{})}function pk(e){return e.reduce((e,t)=>({...e,...fk(t)}),{})}function mk(e){let t=e?.[ck];return t instanceof sk?t.sections:{}}var hk=St(rt);function gk(e){if(yt(e))return P(hk(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!x(e))return null;let t=[];for(let n of e.types){if(ue(n))continue;let e=gk(n);if(e===null)return null;t.push(...e)}return t}function _k(e){if(ae(e))return{type:`string`,literals:[]};if(gt(e))return{type:`number`,nullable:!1};if(se(e))return{type:`boolean`};let t=gk(e);if(t!==null)return{type:`string`,literals:t};if(m(e)){let[t]=e.rest;if(t===void 0)return null;if(ae(t))return{type:`strings`,literals:[]};let n=gk(t);return n===null?null:{type:`strings`,literals:n}}if(x(e)){let t=e.types.filter(e=>!ue(e)&&!a(e)),n=e.types.some(e=>a(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=_k(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function vk(e){let t=e.ast;if(!U(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=dn(e.type),r=pk([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:_k(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:me(e.type),description:V(e.type)}}),sections:mk(j(t))}}function yk(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof We)n=!0,t=t.unwrap();else if(t instanceof Et)r=!0,t=t.unwrap();else if(t instanceof nt)t=t.unwrap();else if(t instanceof en)t=t.in;else return{node:t,optional:n,nullable:r}}function bk(e){if(e instanceof on){let t=e.options.map(e=>bk(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof ot?e.options:e instanceof It?[...e.values]:null;if(t===null)return null;let n=t.map(e=>hk(e));return n.every(R)?n.map(e=>e.value):null}function xk(e){let{node:t,nullable:n}=yk(e);if(t instanceof ln)return{type:`string`,literals:[]};if(t instanceof dt)return{type:`number`,nullable:n};if(t instanceof Zt)return{type:`boolean`};let r=bk(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof Ct){let e=yk(t.element).node;if(e instanceof ln)return{type:`strings`,literals:[]};let n=bk(e);return n===null?null:{type:`strings`,literals:n}}return null}function Sk(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof We||e instanceof Et||e instanceof nt?e.unwrap():e instanceof en?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>he.get(e))}function Ck(e){return Sk(e).reduce((e,t)=>({...e,...t}),{})}function wk(e){return Object.entries(e.shape)}function Tk(e){let t=yk(e).node;if(!(t instanceof lt))throw Error(`A schema form needs a z.object.`);return{fields:wk(t).map(([e,t])=>{let n=pk(Sk(t)),r=n.kind===`file`?{type:`files`}:xk(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=Ck(t);return{name:e,valueType:r,optional:yk(t).optional,annotation:n,title:i.title,description:i.description}}),sections:mk(Ck(e))}}function Ek(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??dk(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function Dk(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function Ok(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function kk(e){let t=e instanceof Xe?Tk(e):vk(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=Ek(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??dk(e.name),help:a,kind:n??Dk(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=Ok(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function Ak(e){let t=e instanceof Xe?e:v(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>jk(e)):jk(n)}}}}function jk(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var Mk=`onServer`;function Nk(e){let t=e.querySelector(`[aria-invalid="true"]`),n=t?.matches(`input, select, textarea, button, [tabindex]`)?t:t?.querySelector(`input, select, textarea, button`);return n?.focus(),n!=null}function Pk(e){if(Nk(e))return()=>void 0;let t=new MutationObserver(()=>{Nk(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function Fk(e){return e.state.meta.errorMap.onServer!==void 0}function Ik(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[Mk]:void 0}}))}function Lk(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[Mk]:n}}))}function Rk(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(e.defaultValues),[s,c]=(0,Y.useState)(null);nC(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,Y.useMemo)(()=>kk(l),[l]),d=(0,Y.useMemo)(()=>Ak(l),[l]),f=KC({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),Fk(e)&&Ik(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await Ak(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&Lk(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function zk(e){return{dirty:IC(e.form.store,e=>!e.isDefaultValue),submitting:IC(e.form.store,e=>e.isSubmitting),canSubmit:IC(e.form.store,e=>e.canSubmit)}}function Bk({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=zk(e),f=(0,Y.useRef)(null),p=(0,Y.useRef)(()=>void 0);return(0,Y.useEffect)(()=>()=>{p.current()},[]),(0,$.jsxs)(Pw,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{p.current();let t=f.current;t!==null&&!e.form.state.isValid&&(p.current=Pk(t))})},children:[c??(0,$.jsx)(ak,{model:e,disabled:l,layout:o}),s===void 0?(0,$.jsx)(Uk,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function Vk({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=Rk({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,$.jsx)(Bk,{...a,model:o})}function Hk(e){return`model`in e?(0,$.jsx)(Bk,{...e}):(0,$.jsx)(Vk,{...e})}function Uk({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=zk(e),d=u?null:e.saved&&!l?(0,$.jsx)(eb,{tone:`success`,size:`compact`,label:e.saved}):l?(0,$.jsx)(eb,{tone:`neutral`,size:`compact`,label:o}):null;return(0,$.jsxs)(Nw,{...c,error:e.error,status:d,children:[r?(0,$.jsx)(Xr,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,$.jsx)(Xr,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,$.jsx)(Xr,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var Wk={error:0,warning:1,info:2};function Gk(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||Wk[e.tone]-Wk[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function Kk(e,t,n){let r=Gk(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:At(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var qk={Setup:(0,$.jsx)(gx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,$.jsx)(dx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,$.jsx)(vx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function Jk({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,$.jsx)(gT,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,$.jsx)(Yk,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function Yk({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,$.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,$.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,$.jsx)(Vr,{level:3,children:e}),(0,$.jsx)(_T,{children:t.map(e=>(0,$.jsx)(vT,{icon:qk[e.group],primary:(0,$.jsxs)(`span`,{className:`prints-notice-copy`,children:[(0,$.jsx)(`span`,{children:e.title}),e.detail?(0,$.jsx)(`span`,{className:`prints-notice-detail`,children:e.detail}):null]}),actions:(0,$.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map((e,t)=>(0,$.jsx)(Xr,{variant:t===0?`outline`:`ghost`,size:t===0?`sm`:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,$.jsx)(Wr,{"aria-label":`Dismiss ${e.title}`,icon:(0,$.jsx)(Tr,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,$.jsx)(yT,{children:`All caught up.`}),t&&t.items.length>0?(0,$.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,$.jsx)(Vr,{level:3,children:`Uploading`}),(0,$.jsx)(XD,{...t})]}):null,(0,$.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,$.jsx)(`span`,{className:`prints-footer-note`,children:`Clear dismisses finished items`}),(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function Xk({folder:e}){return(0,$.jsx)(Fy,{open:e.editing,onOpenChange:e.setEditing,children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Save prints to`})}),(0,$.jsx)(Qk,{folder:e},e.computerId),(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var Zk=Yt({path:Ot.check(ve(Tt(wn),{message:`Enter an absolute Computer folder, such as /media.`})).annotate(uk({label:`Folder`,placeholder:`/media`}))});function Qk({folder:e}){let t=(0,Y.useRef)(!1),n=Rk({schema:Zk,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hk,{model:n,disabled:i,footer:(0,$.jsxs)(Nw,{divider:!1,children:[(0,$.jsx)(xt,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,$.jsx)(xt,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,$.jsx)(vT,{role:`alert`,icon:(0,$.jsx)(ux,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,$.jsx)(yT,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}var $k={image:`Image`,video:`Video`,media:`Media`};function eA({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,mediaSetupMissing:s,canWrite:c,generationError:l,recoveryError:d,pendingGenerations:f,activeGenerations:p,gallerySlots:m,computerId:h,failed:g,uploadError:_,uploads:v,permissions:y,resume:b,discard:x,retryUpload:S}){let C=[];if(e)h===null?C.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&!s&&C.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{y()}}]}):C.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):C.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=k(new u(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));C.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}if(e&&h!==null&&!c&&C.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`}),l!==null){let e=`${$k[l.mediaKind??`media`]} failed`;C.push({key:l.key,group:`Images`,tone:`error`,short:e,title:`${e}: ${l.message}`,detail:l.prompt,blocking:l.dismiss!==void 0,actions:[...l.billing?[{label:`Open Billing`,run:l.billing}]:l.retry?[{label:`Retry`,run:l.retry}]:[],...l.dismiss?[{label:`Dismiss`,run:l.dismiss}]:[]]})}d!==null&&C.push({key:`recovery:${d}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:d});for(let e of f){if(p.has(e.reference.requestId)||m.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`${$k[zn(a,e.input.settings.model)?.kind??`media`]} failed`;C.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`error`,blocking:!0,short:t,title:`${t}: ${e.failure?.message??`Stopped when Prints closed. Retry to run it again.`}`,detail:e.reference.computerId===h?e.typed.prompt:`${e.typed.prompt} · select the original Computer to retry`,actions:[...e.reference.computerId===h?[{label:`Retry`,run:()=>{b(e)}}]:[],{label:`Dismiss`,run:()=>{x(e)}}]})}g.length>0&&C.push({key:`files:${g.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:g.join(`, `)}),_!==null&&C.push({key:`uploads:${_}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:_});for(let e of v)(e.status===`error`||e.status===`cancelled`)&&C.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{S(e.id)}}]});return C}function tA(e,t){let n=Xn(Yr(e)),r=Nt(Fr({queryKey:Lr.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>Nn(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var nA=0,rA=1,iA=2,aA=0,oA=1;function sA(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function cA(e,t){let n=e.list;if(n.index===t)return n.next===null?aA:(e.list=n.next,oA);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,oA;r=n,n=n.next}}var lA={low:0,max:0,high:0,C:iA,P:void 0,R:void 0,L:void 0,list:void 0};lA.P=lA,lA.L=lA,lA.R=lA;function uA(e){let t=e.high;e.max=e.L===lA&&e.R===lA?t:e.L===lA?Math.max(e.R.max,t):e.R===lA?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function dA(e){let t=e;for(;t.P!==lA;)uA(t.P),t=t.P}function fA(e,t){if(t.R===lA)return;let n=t.R;t.R=n.L,n.L!==lA&&(n.L.P=t),n.P=t.P,t.P===lA?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,uA(t),uA(n)}function pA(e,t){if(t.L===lA)return;let n=t.L;t.L=n.R,n.R!==lA&&(n.R.P=t),n.P=t.P,t.P===lA?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,uA(t),uA(n)}function mA(e,t,n){t.P===lA?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function hA(e,t){let n;for(;t!==lA&&t.C===rA;)t===t.P.L?(n=t.P.R,n.C===nA&&(n.C=rA,t.P.C=nA,fA(e,t.P),n=t.P.R),n.L.C===rA&&n.R.C===rA?(n.C=nA,t=t.P):(n.R.C===rA&&(n.L.C=rA,n.C=nA,pA(e,n),n=t.P.R),n.C=t.P.C,t.P.C=rA,n.R.C=rA,fA(e,t.P),t=e.root)):(n=t.P.L,n.C===nA&&(n.C=rA,t.P.C=nA,pA(e,t.P),n=t.P.L),n.R.C===rA&&n.L.C===rA?(n.C=nA,t=t.P):(n.L.C===rA&&(n.R.C=rA,n.C=nA,fA(e,n),n=t.P.L),n.C=t.P.C,t.P.C=rA,n.L.C=rA,pA(e,t.P),t=e.root));t.C=rA}function gA(e){for(;e.L!==lA;)e=e.L;return e}function _A(e,t){let n;for(;t.P.C===nA;)t.P===t.P.P.L?(n=t.P.P.R,n.C===nA?(t.P.C=rA,n.C=rA,t.P.P.C=nA,t=t.P.P):(t===t.P.R&&(t=t.P,fA(e,t)),t.P.C=rA,t.P.P.C=nA,pA(e,t.P.P))):(n=t.P.P.L,n.C===nA?(t.P.C=rA,n.C=rA,t.P.P.C=nA,t=t.P.P):(t===t.P.L&&(t=t.P,pA(e,t)),t.P.C=rA,t.P.P.C=nA,fA(e,t.P.P)));e.root.C=rA}function vA(){let e={root:lA,size:0},t={};return{insert(n,r,i){let a=e.root,o=lA;for(;a!==lA&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==lA){if(!sA(o,r,i))return;o.high=Math.max(o.high,r),uA(o),dA(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:nA,P:o,L:lA,R:lA,list:{index:i,high:r,next:null}};o===lA?e.root=s:(s.low<o.low?o.L=s:o.R=s,dA(s)),_A(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=cA(r,n);if(i===void 0)return;if(i===oA){r.high=r.list.high,uA(r),dA(r),e.size--;return}let a=r,o=a.C,s;r.L===lA?(s=r.R,mA(e,r,r.R)):r.R===lA?(s=r.L,mA(e,r,r.L)):(a=gA(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(mA(e,a,a.R),a.R=r.R,a.R.P=a),mA(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),uA(s),dA(s),o===rA&&hA(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===lA||t>e.max)&&(e.L!==lA&&i.push(e.L),e.R!==lA&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var yA=e=>{let t=Y.useRef(e);return Y.useEffect(()=>{t.current=e}),t},bA=(e,t)=>{let n=t||xA,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},xA=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],SA=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},CA=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},wA=e=>{let t=e.length,n=CA(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=CA(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=CA(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},TA=(e,t)=>{let n,{g:r,s:i}=wA(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},EA=new WeakMap;function DA(){let e=Y.useState(OA)[1];return Y.useRef(()=>e({})).current}var OA={},kA=Y.createElement;function AA(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=IA,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=DA(),w=RA(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),N=j(),P=[],F=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,I=yA(b);h=v*h;let L=g+h,R=N<L&&M<T;if(O(Math.max(0,g-h/2),L,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};P.push(kA(d,{key:a,ref:w(e),role:F,style:typeof f==`object`&&f?Object.assign({},o,f):o},MA(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),R){let e=Math.min(T-M,Math.ceil((g+h-N)/p*D)),t=M,n=LA(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);P.push(kA(d,{key:i,ref:w(t),role:F,style:typeof f==`object`?Object.assign({},n,f):n},MA(y,t,e,E)))}}Y.useEffect(()=>{typeof I.current==`function`&&S!==void 0&&I.current(x,S,r),jA=`1`},[x,S,r,I]),Y.useEffect(()=>{R&&C()},[R,t]);let z=NA(_,k(T,p));return kA(i,{ref:u,key:jA,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?FA(z,s):z,children:P})}var jA=`0`,MA=TA([SA,{},WeakMap,SA],(e,t,n,r)=>kA(e,{index:t,data:n,width:r})),NA=bA((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),PA=(e,t)=>e[0]===t[0]&&e[1]===t[1],FA=bA((e,t)=>Object.assign({},e,t),PA);function IA(e,t){return t}var LA=bA(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),RA=bA((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),EA.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},PA),zA=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=vA(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=BA(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},BA=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},VA=0,HA=320,UA=656;function WA(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=4?2:t>=1280?4:t>=UA?3:2}function GA({item:e}){return bn(e.path)?(0,$.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,$.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var KA=(0,Y.memo)(function({item:e}){let t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,Y.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,Y.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return er(async()=>{let{animate:e,spring:t}=await import(`./modules-C4mfDnjH.js`).then(e=>e.t);return{animate:e,spring:t}},__vite__mapDeps([4,1]),import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,$.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[e.error?(0,$.jsx)(`div`,{className:`block h-full w-full overflow-hidden bg-base-200`,"data-media-failed":!0,title:e.path,children:(0,$.jsx)(rb,{status:`failed`,failure:(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-xs`,children:[e.prompt?(0,$.jsx)(`p`,{className:`m-0 max-w-full truncate px-md text-xs text-(--stipe-fg-muted)`,children:e.prompt}):null,(0,$.jsx)(tb,{density:`tile`,message:e.error,onRetry:e.onRetry,onDismiss:e.onDismiss})]})})}):(0,$.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,onClick:()=>{e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,$.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n?(0,$.jsx)(rb,{"data-media-pending":e.pending?`true`:void 0,indicator:(0,$.jsx)(Sr,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`}),label:e.pendingLabel??`Preparing image…`,status:e.pending?`generating`:`done`,children:e.pending?null:(0,$.jsx)(GA,{item:e})}):(0,$.jsx)(GA,{item:e})})}),(0,$.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&e.onInfo?(0,$.jsx)(Wr,{"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,$.jsx)(fx,{})}):null,!e.pending&&e.onToggleReference?(0,$.jsx)(Wr,{className:`prints-gallery-reference`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,$.jsx)(Hr,{}):(0,$.jsx)(dx,{})}):null]})]})}),qA=(0,Y.memo)(function({children:e,style:t,...n}){return(0,$.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function JA(e,t){let[n,r]=(0,Y.useState)({height:0,width:0});return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function YA(e){let[t,n]=(0,Y.useState)(0),[r,i]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function XA(e,t){let n=Math.max(1,WA(e.length,t));return(0,Y.useMemo)(()=>{let r=Math.floor((t-(n-1)*VA)/n),i=zA(n,r,VA);return r>0&&e.forEach((e,t)=>{let n=e.height>0?e.width/e.height:1;i.set(t,r/n)}),i},[e,t,n])}var ZA=(0,Y.memo)(function({data:e,width:t}){let n=e.height>0?e.width/e.height:1;return(0,$.jsx)(`div`,{"data-media-tile":e.key,style:{height:t/n,width:t},children:(0,$.jsx)(KA,{item:e})})});function QA(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function $A(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||QA(e,t))&&n()}function ej(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var tj=(0,Y.memo)(function({items:e,scrollRef:t,focus:n}){let r=JA(t,e.length),i=r.width||HA,a=XA(e,i),{isScrolling:o,scrollTop:s}=YA(t),c=(0,Y.useRef)(new Set),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!n)return;let o=l.current===n.requestId;if(o&&u.current===i)return;let s=t.current,c=e.findIndex(e=>e.key===n.key),d=a.get(c);if(!s||!d||r.height===0)return;let f=s.querySelector(`[data-media-grid]`);if(!f)return;let p=ej(s,f,d);if(o){$A(s,n.key,()=>{u.current=i});return}QA(s,n.key)?(l.current=n.requestId,u.current=i,n.onFocus()):s.scrollTo({top:p,behavior:`instant`})},[n,e,r.height,t,s,a,i]),(0,Y.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.reduce((e,t,n)=>t.pending&&!t.onVisible&&!c.current.has(t.key)?n:e,-1);if(c.current=new Set(e.map(e=>e.key)),i<0)return;let o=a.get(i),s=n.querySelector(`[data-media-grid]`);if(!o||!s)return;let l=s.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop+o.top,u=l+o.height;l>=n.scrollTop&&u<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,l-Math.max(0,(n.clientHeight-o.height)/2)),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,a]);let d=(0,Y.useCallback)(({data:e,width:t})=>(0,$.jsx)(ZA,{data:e,width:t}),[]);return AA({as:qA,height:r.height,isScrolling:o,itemKey:e=>e.key,items:e,overscanBy:2,positioner:a,render:d,scrollTop:s})});function nj({items:e,scrollRef:t,focus:n}){return(0,$.jsx)(`section`,{"data-media-mosaic":!0,children:(0,$.jsx)(tj,{items:e,scrollRef:t,focus:n})})}function rj(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...t.filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}var ij=`prints-prompt-counter`;function aj({busy:e,disabled:t,disabledReason:n,draft:r,label:i,onGenerate:a,promptOver:o}){return(0,$.jsx)(dT,{"aria-describedby":o?ij:void 0,"aria-label":i,className:`prints-generate`,"data-generation-submit":!0,disabled:t||o,onClick:a,state:zT({draft:r,busy:e}),title:t&&n?n:i})}function oj({caretRequest:e,disabled:t,maxLength:n,addedLength:r=0,menu:i,mentionCount:a,onCaret:o,onChange:s,onMentionDismiss:c,onMentionMove:l,onMentionPick:u,onSend:d,onSlashMove:f,onSlashPick:p,placeholder:m,slashCount:h,value:g}){let _=(0,Y.useRef)(null),v=(0,Y.useRef)(g),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(-1),[C,w]=(0,Y.useState)(!1),T=(0,Y.useRef)(!1),E=(0,Y.useRef)(!1);v.current=g,(0,Y.useLayoutEffect)(()=>{if(C||t||!E.current)return;E.current=!1;let e=_.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[t,C]),(0,Y.useLayoutEffect)(()=>{let t=_.current;!t||e?.value!==g||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,g]),VT(_,g);let D=(0,Y.useCallback)(async()=>{let e=v.current.trim();if(!(!e||t||T.current)&&!(n!==void 0&&e.length+r>n)){E.current=_.current===_.current?.ownerDocument.activeElement,T.current=!0,w(!0);try{if(!await d())return;b(t=>t.at(-1)===e?t:[...t,e].slice(-20)),S(-1)}finally{T.current=!1,w(!1)}}},[t,n,d,r]),O=g.trim().length,k=O>0?O+r:0,A=n!==void 0&&k>n;return(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(bT,{"aria-invalid":A?!0:void 0,"aria-label":`Image prompt`,className:`w-full`,"data-generation-prompt":!0,...CT(i),disabled:t===!0||C,onChange:e=>{s(e.currentTarget.value),o(e.currentTarget.selectionStart),S(-1)},onSelect:e=>{o(e.currentTarget.selectionStart)},onKeyDown:e=>{if(oT(e))return;let t=ST(e);if(a>0&&t!==null){e.preventDefault(),t===`next`?l(1):t===`previous`?l(-1):t===`accept`?u():c();return}if(g.startsWith(`/`)&&t!==null&&(h>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)s(g.slice(1));else if(h)t===`next`?f(1):t===`previous`?f(-1):p();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),D();return}if(e.key===`ArrowUp`&&_.current?.selectionStart===0&&y.length&&(x===-1||x>0)){e.preventDefault();let t=x===-1?y.length-1:x-1;S(t),s(y[t]);return}if(e.key===`ArrowDown`&&x!==-1){e.preventDefault();let t=x+1;t>=y.length?(S(-1),s(``)):(S(t),s(y[t]))}},placeholder:m,ref:_,rows:1,value:g}),n!==void 0&&k>0?(0,$.jsx)(`p`,{className:`px-3 pb-1 text-xs tabular-nums ${A?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:ij,role:A?`alert`:`status`,children:A?`${String(k)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${r>0?` or its style and characters`:``} by ${String(k-n)} or pick another model.`:`${String(k)} / ${String(n)}`}):null]})}function sj({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,$.jsx)(wT,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function cj(e,t){let[n,r]=(0,Y.useState)(0),i=t.startsWith(`/`),a=(0,Y.useMemo)(()=>{if(!i)return[];let n=iT(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,Y.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function lj({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,$.jsx)(wT,{open:!0,rows:r.map(t=>{let n=t.references.at(0)?.path,r=e.find(e=>e.path===n);return{key:String(t.id),label:`@${t.name}`,detail:t.description||void 0,media:(0,$.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:r?(0,$.jsx)(`img`,{src:r.url,alt:``}):null})}}),selected:t,listId:n,label:`Characters`,kind:`characters`,onHighlight:i,onChoose:a})}function uj(e,t){let[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(null),u=o===t?null:Or(t,n),d=u?oi(e,u.query):[];return(0,Y.useEffect)(()=>{a(0)},[t]),{caretRequest:c,matches:d,index:i,setCaret:r,highlight:a,dismiss:()=>{s(t)},move:e=>{a(t=>d.length?(t+e+d.length)%d.length:0)},complete:e=>{let i=d.at(e);if(!u||!i)return null;let a=`${t.slice(0,u.start)}@${i.name} ${t.slice(n)}`,o=u.start+i.name.length+2;return l({value:a,caret:o}),r(o),a}}}function dj(e){let t=ge(),n=Xn(Qr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(Lr.characters(e),n)}}),i=Nt(r((e,t,n)=>ei(e.capabilities,t,n))),a=Nt(r((e,t,n)=>zr(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?k(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var fj=Tt(Gr),pj=e=>e.split(`/`).at(-1)??e;function mj({paths:e,images:t}){return(0,$.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,$.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,$.jsx)(`img`,{src:n.url,alt:pj(e)}):null},e)})})}function hj({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,Y.useState)(null),f=(0,Y.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):fj(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,$.jsx)(Fy,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Characters`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,$.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,$.jsx)(mj,{paths:e.references.map(e=>e.path),images:t}),(0,$.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,$.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,$.jsx)(Xr,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,$.jsx)(qC,{"aria-label":`Character name`,"aria-invalid":!fj(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,$.jsx)(bT,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,$.jsxs)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,$.jsx)(vx,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,$.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,$.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,$.jsx)(`li`,{title:e.path,children:(0,$.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,$.jsx)(`img`,{src:e.url,alt:``}),(0,$.jsx)(`span`,{className:`prints-character-check`,children:(0,$.jsx)(OT,{"aria-label":`Use ${pj(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,$.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,$.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var gj=Yt({destination:nn(Ve(rt)),height:nn(B),model:nn(rt),prompt:nn(rt),references:nn(Te(Yt({computerId:nn(rt),path:rt,role:nn(I([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:nn(Ve(Me)),steps:nn(Ve(B)),style:nn(Ve(rt)),width:nn(B)}),_j=re(K(),h()).parse(structuredClone(be(gj,{onExcessProperty:`error`}).schema)),vj=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),yj=vj(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),bj=vj(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,_j),xj=vj(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function Sj(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(yj,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(bj,({arguments:e})=>{if(n)return;let r=tt(gj,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(xj,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function Cj(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...Pr.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(qn[t].width)} × ${String(qn[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function wj(e,t){let n=(0,Y.useRef)(e);n.current=e;let r=wu(t,{sourceId:`media-prompt`,namespace:`media`},(0,Y.useCallback)(()=>Cj(()=>n.current),[])),i=(0,Y.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,Y.useMemo)(()=>eT(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function Tj(e){let t=ge(),n=Xn(Cr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(Lr.styles(e),n)}}),i=Nt(r((e,t,n)=>ni(e.capabilities,t,n))),a=Nt(r((e,t,n)=>ii(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?k(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function Ej(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function Dj(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function Oj(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?Ej(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=zn(i,n.model),c=o??s??zn(i,a.model);if(c===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let l=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${sr(c)} instead.`:null,u=n.references.slice(0,n.typed.references),d=e===`animate`?{path:r,role:`first-frame`}:{path:r},f=[d,...u.filter(e=>!lr(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&c.input.maxReferences===0)return{kind:`refused`,message:`${c.label} does not take reference images.`};let p=e===`reuse`?u:e===`remix`?f:[d],m=Fn(a,c),h={width:n.width??m.width,height:n.height??m.height},g=o===void 0?pr(h,c,void 0):Dj(c,h.width,h.height)??m,_=o===void 0&&c.input.steps!==`fixed`&&n.steps!==null&&c.id===n.model?n.steps:m.steps,v=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:l,draft:{...m,destination:void 0,prompt:n.typed.prompt,references:p,steps:_,style:v,width:g.width,height:g.height}}}function kj({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,$.jsxs)(Gw,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,$.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,$.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function Aj({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,Y.useState)(null);return(0,$.jsx)(Fy,{open:n,onOpenChange:r,children:(0,$.jsxs)(By,{children:[(0,$.jsx)(Hy,{children:(0,$.jsx)(Uy,{children:`Styles`})}),(0,$.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,$.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,$.jsx)(Xr,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(qC,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,$.jsx)(bT,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,$.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,$.jsx)(Vy,{children:(0,$.jsx)(Wy,{render:(0,$.jsx)(Xr,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var jj=(0,Y.lazy)(async()=>({default:(await er(()=>import(`./print-info-drawer-HknyLAui.js`),__vite__mapDeps([5,1,2,6,4]),import.meta.url)).PrintInfoDrawer})),Mj=[`a mushroom knight`,`moss on a keyboard`,`a tiny house made of mushrooms`];function Nj(e){uw.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function Pj(e){let t=(0,Y.useRef)(!1),n=KC({defaultValues:Yn(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,Y.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function Fj({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,onEditStyles:o,onEditCharacters:s}){let c=t?.input.dimensions===`none`,l=t!==void 0&&t.sizes!==null,u=t?.video??null;return(0,$.jsxs)(`div`,{className:`prints-settings`,children:[(0,$.jsx)(zw,{label:`Style`,orientation:`horizontal`,children:n}),(0,$.jsx)(zw,{label:`Size`,orientation:`horizontal`,children:(0,$.jsx)(Gw,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:c,title:c?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:c?`provider`:i,children:c?(0,$.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,$.jsxs)($.Fragment,{children:[l&&!r.some(e=>e.value===i)?(0,$.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,r.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)),l?null:(0,$.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!c&&!l&&i===`custom`?(0,$.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,$.jsx)(e.Field,{name:`width`,children:e=>(0,$.jsx)(zw,{label:`Width`,children:(0,$.jsx)(qC,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,$.jsx)(e.Field,{name:`height`,children:e=>(0,$.jsx)(zw,{label:`Height`,children:(0,$.jsx)(qC,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,u?(0,$.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,$.jsx)(zw,{label:`Length`,orientation:`horizontal`,children:(0,$.jsx)(Gw,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(u.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:u.durations.map(e=>(0,$.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,u?.supportsAudio?(0,$.jsx)(e.Field,{name:`generateAudio`,children:e=>u.defaultGenerateAudio===null?(0,$.jsx)(zw,{label:`Audio`,orientation:`horizontal`,children:(0,$.jsxs)(Gw,{"aria-label":`Video audio`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,$.jsx)(`option`,{value:``,children:`Model default`}),(0,$.jsx)(`option`,{value:`on`,children:`On`}),(0,$.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,$.jsx)(zw,{label:`Audio`,orientation:`horizontal`,children:(0,$.jsx)(Mr,{"aria-label":`Video audio`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,$.jsx)(e.Field,{name:`steps`,children:e=>(0,$.jsx)(zw,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,$.jsx)(qC,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,$.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{o()},children:`Edit styles…`}),(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Characters…`})]})]})}function Ij({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,values:c,computerId:l,mediaDirectory:u,referenceImages:d,characters:f,characterDialog:p,onSubmit:m,styleControls:h,addedLength:g}){let _=zn(i,c.model),v=c.prompt.trim().length,y=_!==void 0&&v>0&&v+g>_.maxPromptLength,b=Wn(_),x=_?.video??null,S=qr(c.references,_),C=_===void 0?void 0:Ln(S,_,x?.formats.find(e=>e.width===c.width&&e.height===c.height)?.resolution),w=_?.input.maxReferences??0,T=c.references.length>w,[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),A=_!==void 0&&_.sizes!==null,j=mr(_),M=A?`${String(c.width)}x${String(c.height)}`:E?`custom`:j.find(e=>e.width===c.width&&e.height===c.height)?.value??`custom`,[N,P]=(0,Y.useState)(!1),F=wj({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{D(!1),r.setFieldValue(`width`,qn[e].width),r.setFieldValue(`height`,qn[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),P(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[I,L]=(0,Y.useState)(!1),R=uj(f,c.prompt),z=cj(F.items,c.prompt),B=(0,Y.useId)(),ee=`${B}-commands`,V=`${B}-characters`,te=gr({computerId:l,prompt:c.prompt,saved:f,references:c.references,model:_===void 0?void 0:{label:_.label,maxReferences:_.input.maxReferences}}),ne=Ar(c.prompt,f).characters,H=e=>{let t=z.slashMatches.at(e);t&&(z.resetSlash(),F.run(t.command))},U=h({open:N,onOpenChange:P}),re=[c.style,Un(_,c.width,c.height),x&&c.durationSeconds!==void 0?`${String(c.durationSeconds)}s`:void 0,x?.supportsAudio&&c.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),W=(0,$.jsx)(Fj,{form:r,selected:_,stylePicker:U.picker,sizeChoices:j,sizeMode:M,onCustomSize:D,onEditStyles:()=>{k(!1),P(!0)},onEditCharacters:()=>{k(!1),L(!0)}});return(0,$.jsxs)(BT,{"aria-label":`Image generation`,"data-generation-form":!0,attachments:c.references.length>0?(0,$.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,children:c.references.map((e,t)=>{let n=l!==null&&lr(e,l)?d.find(t=>t.path===e.path):void 0,i=S[t]?.role,a=dr(b,S,t);return(0,$.jsxs)(`div`,{className:`prints-reference-tile`,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,$.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,$.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,$.jsxs)(`span`,{children:[`Ref `,t+1]})}),i===void 0?null:a===void 0?(0,$.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:Tn[i]}):(0,$.jsx)(Xr,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${Tn[i]}. Use as ${Tn[a]}`,title:`Use as ${Tn[a]}`,onClick:()=>{r.setFieldValue(`references`,S.map((e,n)=>n===t?{...e,role:a}:e))},children:Tn[i]}),(0,$.jsx)(Wr,{icon:(0,$.jsx)(Tr,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,c.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??l,e.path]))})}):void 0,input:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),m()},children:(0,$.jsx)(r.Field,{name:`prompt`,children:e=>(0,$.jsxs)(`div`,{className:`prints-prompt`,children:[z.slashOpen?(0,$.jsx)(sj,{index:z.slashIndex,listId:ee,matches:z.slashMatches,onHighlight:z.highlightSlash,onPick:H}):null,!z.slashOpen&&R.matches.length>0?(0,$.jsx)(lj,{images:d,index:R.index,listId:V,matches:R.matches,onHighlight:R.highlight,onPick:t=>{let n=R.complete(t);n!==null&&e.handleChange(n)}}):null,(0,$.jsx)(oj,{caretRequest:R.caretRequest,menu:z.slashOpen?{open:z.slashMatches.length>0,listId:ee,selected:z.slashIndex}:{open:R.matches.length>0,listId:V,selected:R.index},mentionCount:z.slashOpen?0:R.matches.length,onCaret:R.setCaret,onMentionDismiss:R.dismiss,onMentionMove:R.move,onMentionPick:()=>{let t=R.complete(R.index);t!==null&&e.handleChange(t)},disabled:!o||a||i.length===0||s,maxLength:_?.maxPromptLength,addedLength:g,onChange:t=>{e.handleChange(t)},onSend:m,onSlashMove:z.moveSlash,onSlashPick:()=>{H(z.slashIndex)},placeholder:`What are we making?`,slashCount:z.slashMatches.length,value:e.state.value}),c.references.length>0||C!==void 0||ne.length>0?(0,$.jsxs)(`div`,{className:`prints-composer-notes`,children:[c.references.length>0?(0,$.jsxs)(`span`,{className:`prints-reference-count`,"data-generation-references":!0,"data-over-limit":T?``:void 0,role:T?`alert`:void 0,children:[c.references.length,` / `,w,` `,`references`,T?w===0?` — this model takes none; remove them or pick another model`:` — over this model's limit; remove some to generate`:null]}):null,C===void 0?null:(0,$.jsx)(`span`,{className:`prints-reference-count`,"data-generation-reference-roles":!0,"data-over-limit":``,role:`alert`,children:C}),ne.length>0?(0,$.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,"data-over-limit":te.kind===`refused`?``:void 0,role:te.kind===`refused`?`alert`:void 0,children:te.kind===`refused`?te.message:`Characters: ${ne.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t?(0,$.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,$.jsx)(`span`,{children:t.group===`Images`&&t.detail?t.detail:(0,$.jsxs)($.Fragment,{children:[t.title,`. `,t.detail]})}),t.actions?.map(e=>(0,$.jsx)(Xr,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,$.jsxs)($.Fragment,{children:[e,(0,$.jsx)(r.Field,{name:`model`,children:e=>(0,$.jsx)(UD,{models:i,emptyLabel:l===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:t=>{let n=zn(i,t);if(e.handleChange(t),!n)return;let a=r.store.state.fieldMeta,o=Fn(c,n),s=pr(c,n,_);(n.input.dimensions===`none`||n.sizes!==null)&&D(!1),r.setFieldValue(`width`,s.width),r.setFieldValue(`height`,s.height),r.setFieldValue(`durationSeconds`,o.durationSeconds),r.setFieldValue(`generateAudio`,o.generateAudio),(n.input.steps===`fixed`||!a.steps?.isTouched)&&r.setFieldValue(`steps`,o.steps)},value:e.state.value})}),l&&u?(0,$.jsx)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Where new prints are saved`,children:`Saved in your Prints folder`}):null]}),action:(0,$.jsx)(aj,{busy:s,draft:c.prompt,disabled:!o||a||i.length===0||s,label:Vn(_),onGenerate:()=>{m()},promptOver:y}),items:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,$.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,$.jsx)(gx,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),re.length>0?re.join(` · `):`Settings`]}),content:W}],openId:O?`settings`:null,onOpenChange:e=>{k(e===`settings`)}},children:[U.dialog,p({open:I,onOpenChange:L})]})}function Lj({connection:e}){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(e);n.current=e;let r=WD(e?.app??null),i=xu(e?.app??null)?.setup?.media===`missing`,[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=()=>{let t=e?.app;t&&(o(!0),c(!1),t.ui.openSetup(`media`).then(e=>{o(!1),c(e===`unavailable`)},e=>{o(!1),c(!0),Sn(`open-media-setup`,e)}))},u=s?(0,$.jsxs)($.Fragment,{children:[`Image setup couldn’t open.`,` `,(0,$.jsx)(`a`,{href:`https://github.com/fungi-computer/oyster#deploy-to-cloudflare`,target:`_blank`,rel:`noreferrer`,children:`Open the image setup guide`}),`.`]}):`Image generation isn’t set up yet.`,[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(),h=tA(e?.app??null,r.computerId),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(),S=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{_(null),y(null),x(void 0)},[e,r.computerId,r.path]);let C=r.path,{gallery:w,images:T,failed:E,loading:D,gallerySlots:O,canBrowse:k,canRead:A,canWrite:j,reserveSlot:M,failSlot:N,clearSlotError:P,removeSlot:F,addComputerFile:I,retryFile:L,uploads:R,uploadFiles:z}=Gx(e,r),[B,ee]=(0,Y.useState)(Date.now),V=O.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,Y.useEffect)(()=>{if(!V)return;let e=setInterval(()=>{ee(Date.now())},1e3);return()=>{clearInterval(e)}},[V]);let te=Qu(e,(e,t,n)=>(w.refresh(),I(e,t,n)));(0,Y.useLayoutEffect)(()=>{x(void 0),te.target&&(_(null),y(null))},[te.target]);let ne=w.entries.some(e=>e.path===te.target?.path);(0,Y.useEffect)(()=>{te.target&&!ne&&w.nextPageReady&&w.loadMore()},[te.target,ne,w.nextPageReady,w.loadMore]);let H=T.find(e=>e.source.kind===`computer`&&e.source.computerId===te.target?.computerId&&e.source.path===te.target.path),U=Tj(e?.app??null),re=dj(e?.app??null),W=gS({connection:e,folder:r,styles:U.styles,characters:re.characters,effects:{reserve:M,failed:N,notifyFailure:Nj,saved:({result:e},t)=>{A?I(e.destination.path,t,e.destination.computerId):N(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:ie,models:ae,modelsLoading:G,modelsError:oe,canGenerate:se,mediaCapability:ce,pendingGenerations:le,activeGenerations:ue,recoveryError:K}=W,de=(0,Y.useRef)(ae),fe=(0,Y.useRef)(W);fe.current=W;let pe=(0,Y.useRef)(null),me=(0,Y.useRef)(null),he=(0,Y.useRef)(0),[ge,_e]=(0,Y.useState)(null),ve=(0,Y.useRef)(W.submit);ve.current=async e=>{let t=await W.submit(e);return t&&_e(null),t};let q=Pj(ve),ye=e=>{q.setFieldValue(`model`,e.model),q.setFieldValue(`width`,e.width),q.setFieldValue(`height`,e.height),q.setFieldValue(`steps`,e.steps),q.setFieldValue(`durationSeconds`,e.durationSeconds),q.setFieldValue(`generateAudio`,e.generateAudio),q.setFieldValue(`prompt`,e.prompt),q.setFieldValue(`references`,e.references),q.setFieldValue(`style`,e.style),q.setFieldValue(`destination`,void 0)},be=(0,Y.useRef)(q);be.current=q;let xe=IC(q.store,e=>e.values),Se=IC(q.store,e=>e.isSubmitting),Ce=e?.app;(0,Y.useEffect)(()=>{if(Ce)return Sj(Ce,{readDraft:()=>be.current.store.state.values,readModels:()=>de.current,setDraft:e=>{let t=be.current;if(e.model!==void 0){let n=zn(de.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=Fn(t.store.state.values,n),i=zn(de.current,t.store.state.values.model),a=pr(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>be.current.store.state.isSubmitting||fe.current.isRunning()?Promise.resolve(!1):be.current.submitCurrent()})},[Ce]),(0,Y.useEffect)(()=>{de.current=ae},[ae]),(0,Y.useEffect)(()=>{if(ae.length===0||oe)return;let e=ae.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??ae[0];if(!q.store.state.fieldMeta.model?.isTouched){let t=Fn(q.store.state.values,e);q.setFieldValue(`model`,t.model),q.store.state.fieldMeta.width?.isTouched||q.setFieldValue(`width`,t.width),q.store.state.fieldMeta.height?.isTouched||q.setFieldValue(`height`,t.height),q.store.state.fieldMeta.steps?.isTouched||q.setFieldValue(`steps`,t.steps)}},[q,oe,ae]);let we=zn(ae,xe.model),Te=xe.references,Ee=we?.input.maxReferences??0,De=(0,Y.useRef)({addComputerFile:I,retryPath:W.retryPath,uploads:R});De.current={addComputerFile:I,retryPath:W.retryPath,uploads:R};let Oe=H?Hx(H):null,ke=(0,Y.useMemo)(()=>T.map(e=>({key:Hx(e),selected:Hx(e)===Oe,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:Te.some(t=>e.source.kind===`computer`&&lr(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:Te.length>=Ee&&!Te.some(t=>e.source.kind===`computer`&&lr(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&Ee>0?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=Te.some(e=>lr(e,n)&&e.path===t);q.setFieldValue(`references`,r?Te.filter(e=>!lr(e,n)||e.path!==t):[...Te,{path:t}])}:void 0,onInfo:()=>{_(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{_(null),y(Hx(e))}})),[T,Te,Ee,q,Oe]),Ae=(0,Y.useMemo)(()=>{let e=r.computerId;if(!e)return ke;let t=new Map(ke.map(e=>[e.key,e])),n=[...w.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{w.loadFile(n.path)},error:E.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{L(n.path)}}}),i=new Set(n.map(e=>e.key));return[...n,...ke.filter(e=>!i.has(e.key)&&e.key!==Oe)]},[ke,w.entries,w.loadFile,L,E,r.computerId,Oe]),je=ie.kind===`pending`,Me=[...ue].sort().join(`|`),Ne=O.filter(e=>e.error!==void 0).length,Pe=(0,Y.useMemo)(()=>le.filter(e=>e.reference.computerId===r.computerId&&!Me.split(`|`).includes(e.reference.requestId)&&!O.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path)).map(e=>({key:`${e.reference.computerId}:${e.input.destination.path}`,path:e.input.destination.path,width:1024,height:1280,url:``,pending:!0,error:e.failure?.message??`Stopped when Prints closed. Retry to run it again.`,prompt:e.typed.prompt,onOpen:()=>void 0,onRetry:()=>{fe.current.resume(e)},onDismiss:()=>{fe.current.discard(e)}})),[le,r.computerId,Me,O]),Fe=(0,Y.useMemo)(()=>[...Pe,...rj(Ae,O,e=>{let t=R.items.find(t=>t.id===e.uploadId),r=e.error??(t?.status===`error`||t?.status===`cancelled`?t.message:void 0);return{key:e.key,path:e.path,width:e.width,height:r===void 0?e.height:Math.max(e.height,e.width*1.25),url:``,pending:!0,error:r,prompt:r===void 0?void 0:le.find(t=>t.reference.computerId===e.computerId&&t.input.destination.path===e.path)?.typed.prompt??(Ne===1?W.failedPrompt:void 0),pendingLabel:t?.status===`complete`||ie.kind===`completed`?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:Dn(ae.find(e=>e.kind===`video`),B-e.startedAt,e.resumed),onOpen:()=>void 0,onRetry:r&&(A||t&&t.status!==`complete`)?()=>{if(P(e.key),t&&t.status!==`complete`){De.current.uploads.retry(t.id);return}!e.uploadId&&De.current.retryPath(e.path)||n.current&&De.current.addComputerFile(e.path,n.current,e.computerId)}:void 0,onDismiss:r?()=>{F(e.key),e.uploadId&&De.current.uploads.remove(e.uploadId)}:void 0}})],[Pe,le,Ne,W.failedPrompt,Ae,O,R.items,ie.kind,A,ae,B]),Ie=Se||je,Le=!i&&ce&&se&&j&&C!==null&&ie.kind===`ready`&&!G&&ae.length>0,Re=O.some(e=>e.error!==void 0),ze=R.items.filter(e=>e.computerId===r.computerId),Be=ie.kind===`error`&&oe===null?{key:W.errorKey,mediaKind:ie.mediaKind,message:ie.message,billing:ie.action===`billing`&&e?()=>{e.app.ui.openTeamBilling().catch(t=>{Sn(`open-team-billing`,t),n.current===e&&W.reportRecoveryError(t)})}:void 0,prompt:W.failedPrompt,retry:Re?W.retry:void 0,dismiss:Re?()=>{for(let e of O)e.error!==void 0&&F(e.key);W.dismissFailed()}:void 0}:null,Ve=eA({connected:e!==null,mediaCapability:ce,modelsError:oe,retryModels:W.retryModels,modelsLoading:G,models:ae,canGenerate:se,mediaSetupMissing:i,canWrite:j,generationError:Be,recoveryError:K,pendingGenerations:le,activeGenerations:ue,gallerySlots:O,computerId:r.computerId,failed:E,uploadError:R.error,uploads:ze,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{W.reportRecoveryError(e)})},resume:e=>{W.resume(e)},discard:e=>{W.discard(e)},retryUpload:e=>{R.retry(e)}});h.error&&Ve.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:h.error});let He=h.visible(Ve),Ue={generating:ue.size,uploading:ze.filter(e=>e.status===`sending`||e.status===`queued`).length},We={items:ze.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{R.cancel(e)},onRetry:e=>{R.retry(e)},onRemove:e=>{R.remove(e)}},Ge=new Set([...w.entries.map(e=>`${r.computerId??``}:${e.path}`),...T.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,Ke=Kk(He,Ue,d);Cu(e?.app,[...r.available?[Qw(r.path,{checking:r.busy&&r.path===null,editing:r.editing})]:[],...Ke===null?[]:[Ke],...k?[{kind:`text`,id:`prints`,text:`${String(Ge)} ${Ge===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(m(e.anchor?.start),f(e=>!e),!0):e.itemId!==`folder`||!r.available?!1:(r.setEditing(!0),!0),t=>{Sn(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{Sn(`prints.status.toast`,e)})});let qe=T.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url}]:[]),Je=e=>{y(null),S.current+=1,x({key:e,requestId:`viewer-close-${String(S.current)}`,onFocus:()=>void 0})},Ye=(t,n,r)=>(0,$.jsx)(Y.Suspense,{fallback:null,children:(0,$.jsx)(jj,{image:t,app:e?.app??null,referenceImages:qe,models:ae,canAnimate:Ej(ae)!==void 0,download:r,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=Oj(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:ae,styles:U.styles.map(e=>e.name),current:q.store.state.values});return r.kind===`refused`?r.message:(ye(r.draft),_e(r.notice===null?null:{model:r.draft.model,message:r.notice}),_(null),v!==null&&Je(Hx(t)),null)},onClose:n},t.url)}),Xe={label:`Upload images`,onSelect:()=>me.current?.click(),disabled:!j||C===null,disabledReason:`Choose a writable Computer and folder to upload images.`},Ze=(0,$.jsx)(Xr,{variant:`ghost`,size:`sm`,loading:a,onClick:l,children:`Set up image generation`});return(0,$.jsxs)(`main`,{ref:t,className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":ie.kind,"data-computer-capability":k?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&j&&(e.preventDefault(),z(t.map(e=>(he.current+=1,new File([e],`paste-${String(he.current)}-${Bx(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,$.jsx)(Ew,{id:`prints-generation-notices`}),(0,$.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,$.jsx)(tx,{screen:Fe.length>0,surface:Fe.length>0,surfaceSize:`lg`,surfaceDepth:`deep`,ref:pe,className:`prints-gallery-scroll flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":D||w.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&j&&z(t)},children:(0,$.jsxs)(`div`,{className:`prints-gallery-content`,children:[Fe.length>0?(0,$.jsx)(nj,{items:Fe,scrollRef:pe,focus:v===null?b??(H&&te.target?{key:`${te.target.computerId}:${te.target.path}`,requestId:te.target.requestId,onFocus:()=>{_(null),y(Hx(H))}}:void 0):void 0}):D||w.loading?(0,$.jsx)(Zw,{"data-media-loading":!0,framed:!1,message:`Loading prints…`,detail:`Your library is on its way.`,variant:`wander`}):(0,$.jsx)(Yw,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`speech`,className:`prints-invitation`,visual:`blobs`,title:i?`Make and collect images`:`Make your first print`,description:i?`Upload images to start your collection. Open any image to view or download it.`:r.computerId===null?`Your images will appear here.`:r.available&&C===null?`Pick a folder in the composer below, then describe something or drop in images.`:`Describe something and it lands here, or drop in images from your Computer.`,primaryAction:i?Xe:void 0,actions:i?(0,$.jsxs)(`div`,{className:`prints-image-setup`,children:[(0,$.jsx)(`span`,{children:u}),Ze]}):(0,$.jsx)(Xr,{variant:`ghost`,size:`sm`,disabled:!j||C===null,onClick:()=>me.current?.click(),children:`Upload images`}),suggestions:i?void 0:Mj.map(e=>({label:e,disabled:!Le,onSelect:()=>{q.setFieldValue(`prompt`,e),t.current?.querySelector(`[data-generation-prompt]`)?.focus()}}))}),w.hasNextPage&&(0,$.jsx)(Xr,{variant:`ghost`,disabled:w.loading,onClick:w.loadMore,children:w.loading?`Loading images…`:`Load more images`})]})}),te.error?(0,$.jsx)(`p`,{role:`alert`,children:`Could not open this print. It may no longer be available on this Computer.`}):null,g&&(g.source.kind===`local`||g.source.connection===e&&g.source.computerId===r.computerId)?Ye(g,()=>{_(null)}):null]}),(0,$.jsx)($x,{items:Fe,images:T,viewerKey:v,app:e?.app??null,onNavigate:y,onClose:Je,renderInfo:(e,t)=>Ye(e,t,null)}),i&&Fe.length>0?(0,$.jsxs)(`div`,{className:`prints-library-actions`,children:[(0,$.jsx)(Xr,{size:`sm`,onClick:Xe.onSelect,disabled:Xe.disabled,children:`Upload images`}),Ze,s?(0,$.jsx)(`div`,{className:`prints-image-setup`,children:u}):null]}):null,(0,$.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,$.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,$.jsx)(`input`,{ref:me,type:`file`,disabled:!j||C===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{z(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),i?null:(0,$.jsx)(Ij,{addedLength:Er(xe.prompt,U.styles.find(e=>e.name===xe.style)?.text,re.characters),styleControls:e=>({picker:(0,$.jsx)(kj,{styles:U.styles,selected:xe.style,disabled:!ce||G||Ie,onSelect:e=>{q.setFieldValue(`style`,e)}}),dialog:(0,$.jsx)(Aj,{open:e.open,onOpenChange:e.onOpenChange,styles:U.styles,selected:xe.style,busy:U.busy,error:U.error,onSelect:e=>{q.setFieldValue(`style`,e)},onSave:U.save,onDelete:(e,t)=>{U.remove(e.id,t)}})}),characters:re.characters,characterDialog:e=>(0,$.jsx)(hj,{open:e.open,onOpenChange:e.onOpenChange,characters:re.characters,images:qe,busy:re.busy,error:re.error,canUpload:j&&C!==null,onUpload:()=>me.current?.click(),onSave:re.save,onDelete:(e,t)=>{re.remove(e.id,t)}}),guidance:He.find(e=>e.blocking&&e.group===`Setup`)??(ge!==null&&ge.model===xe.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:ge.message,actions:[{label:`Dismiss`,run:()=>{_e(null)}}]}:void 0),commandApp:Ce,actions:(0,$.jsx)(xt,{"aria-label":`Upload images`,title:j?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,$.jsx)(vx,{}),label:null,className:`prints-upload-key`,disabled:!j||C===null,onClick:()=>me.current?.click()}),form:q,mediaCapability:ce&&se&&j&&C!==null,models:ae,modelsLoading:G,onSubmit:q.submitCurrent,submitting:Ie,values:xe,computerId:r.computerId,mediaDirectory:C,referenceImages:qe}),Ke===null?null:(0,$.jsx)(Jk,{notices:He,uploads:We,open:d,inset:p,onOpenChange:f,onDismiss:h.dismiss,onDismissAll:()=>{h.dismissAll(Ve)},onLoadMore:W.hasMore?W.loadMore:void 0})]}),(0,$.jsx)(Xk,{folder:r})]})}var Rj=document.getElementById(`media-root`);if(!Rj)throw Error(`Media root is missing`);vu(Rj,{name:`Prints`,queryClient:En()},({app:e})=>(0,Y.createElement)(Lj,{connection:e?{app:e}:null}));
|