@fungi.computer/prints 0.20.17 → 0.20.19
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/{audio-waveform-8Le2_ags.js → audio-waveform-DcMy9xl2.js} +1 -1
- package/dist/assets/{audio-waveform-view-eHGxeEHT.js → audio-waveform-view-Bt66rIpF.js} +1 -1
- package/dist/assets/computer-Drn9XugY.js +1 -0
- package/dist/assets/dist-ujdia29J.js +1 -0
- package/dist/assets/{dropdown-menu-Bjq0vUfs.js → dropdown-menu-Dz4r7a9R.js} +1 -1
- package/dist/assets/{generation-quote-B6EfnJ9h.js → generation-quote-BstUB0PG.js} +1 -1
- package/dist/assets/index-DVyRYFHn.js +2 -0
- package/dist/assets/{library-rail-BxRfGzyI.js → library-rail-DPiYJWxN.js} +1 -1
- package/dist/assets/{library-view-BBAeJjj6.js → library-view-C71Cv37D.js} +1 -1
- package/dist/assets/{log-event-BfZxbz9a.js → log-event-IU820pK9.js} +1 -1
- package/dist/assets/{print-download-button-swuL0spO.js → print-download-button-ebYCmtQ8.js} +1 -1
- package/dist/assets/{print-info-drawer-BdtrIbGt.js → print-info-drawer-LxcR4Myk.js} +2 -2
- package/dist/assets/{print-viewer-Dn7RLr8D.js → print-viewer-B1_RBET9.js} +2 -2
- package/dist/assets/{query-CYqgVHJ7.js → query-DKNLqHPu.js} +1 -1
- package/dist/assets/{useMutation-DH-cbXIA.js → useMutation-DAlc59rA.js} +1 -1
- package/dist/index.html +11 -11
- package/package.json +5 -5
- package/dist/assets/computer-BugY64UO.js +0 -1
- package/dist/assets/dist-DAokFn5x.js +0 -1
- package/dist/assets/index-DwGyASrI.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,C as n,Cn as r,Dn as i,En as a,Et as o,F as s,Gt as c,H as l,Ht as u,I as d,J as ee,K as te,Lt as ne,M as re,Mt as f,N as p,O as m,Ot as ie,Q as ae,R as oe,Rt as se,S as h,Sn as g,T as _,Tn as v,V as y,Vn as ce,Vt as le,W as b,X as ue,_n as x,at as de,bn as S,cn as fe,ct as C,dn as w,et as pe,fn as me,gn as T,hn as he,it as E,j as ge,jt as _e,k as D,ln as O,lt as k,mn as ve,nt as A,ot as ye,q as be,qt as xe,sn as Se,st as j,tt as Ce,un as we,w as M,wn as N,xn as Te,yn as Ee,z as De,zt as Oe}from"./button-oE2Hrd5D.js";var P=e(ce(),1),ke=he(),Ae=T(()=>ve(`status`,[S({status:x(`available`)}).strict(),S({status:x(`unavailable`),reason:N()}).strict()])),F=ke,je=T(()=>g(N(),F)),Me=e=>F.parse(e),I=T(()=>S({code:N().min(1).max(160),message:N().min(1).max(512),details:F.optional()}).strict()),Ne=e=>I.parse(e),Pe=je,L=T(()=>N().refine(e=>e.trim().length>0)),Fe=Ae,Ie=T(()=>v([S({type:x(`action`)}).strict(),S({type:x(`custom`),data:je}).strict(),S({type:x(`choice`),options:w(S({value:F,label:L,description:L.optional()}))}).strict(),S({type:x(`form`),submitLabel:L.optional()}).strict(),S({type:x(`confirmation`),message:L,confirmLabel:L.optional(),cancelLabel:L.optional()}).strict()])),Le=T(()=>S({inputSchema:Pe.optional(),outputSchema:Pe.optional(),presentation:Ie.optional()}).strict()),Re=T(()=>Ee().int().refine(e=>Number.isSafeInteger(e))),ze=T(()=>S({hint:L.pipe(N().max(120)),words:w(S({word:N().regex(/^\S{1,64}$/u),description:L.pipe(N().max(512)).optional(),arguments:je}).strict()).max(32).optional(),text:S({field:L.pipe(N().max(120)),arguments:je,requestIdField:L.pipe(N().max(120)).optional()}).strict().optional()}).strict().refine(e=>e.words!==void 0||e.text!==void 0,`slash arguments need words or text`)),Be=T(()=>S({order:Re.optional()}).strict()),Ve=T(()=>S({bindings:S({order:Re.optional(),values:w(L).max(16)}).strict().optional(),agent:S({keybind:L.optional(),order:Re.optional()}).strict().optional(),help:Be.optional(),menu:Be.optional(),palette:Be.optional(),slash:S({aliases:w(L).max(16),consumesDraft:me().optional(),order:Re.optional(),arguments:ze.optional()}).strict().optional()}).strict()),He=T(()=>S({id:L.refine(e=>!e.includes(`:`)),title:L,category:L,description:L.optional(),projections:Ve.optional(),action:Le.optional(),availability:Fe.optional()}).strict()),Ue=e=>He.parse(e),We=T(()=>S({inputSchema:Pe.optional(),outputSchema:Pe.optional()}).strict()),Ge=N().min(1).brand(),Ke=T(()=>S({commandId:Ge,command:S({namespace:N(),id:N()}).strict(),sourceId:N(),scope:N().optional(),title:N(),category:N(),description:N().optional(),order:Ee(),availability:Ae,action:We.optional(),keybind:N().optional()}).strict());w(Ke);var qe=8192,R=L.pipe(N().max(qe)),Je=L.pipe(N().max(60)),Ye=i({protocol:/^https?$/u}),Xe=S({label:R,value:R}).strict(),Ze={summary:R.optional(),facts:w(Xe).max(4).optional(),body:R.optional(),bodyLabel:R.optional(),details:w(Xe).max(24).optional()};ve(`type`,[S({type:x(`choice`),message:Je,...Ze,current:R.optional(),collapsedGroup:R.optional(),options:w(S({value:R,label:R,description:R.optional(),group:R.optional(),destructive:x(!0).optional()}).strict()).min(1).max(256)}).strict(),S({type:x(`text`),message:Je,...Ze,placeholder:R.optional(),secret:me().optional()}).strict(),S({type:x(`confirmation`),message:Je,...Ze,confirmLabel:R.optional(),cancelLabel:R.optional(),destructive:x(!0).optional()}).strict(),S({type:x(`decision`),message:Je,...Ze,options:w(S({value:R,label:R,description:R.optional(),destructive:x(!0).optional()}).strict()).min(1).max(8).refine(e=>new Set(e.map(e=>e.value)).size===e.length,`Decision option values must be unique`),multiple:me().optional(),other:S({label:R,placeholder:R.optional(),maxLength:Ee().int().min(1).max(qe),blank:R.optional()}).strict().optional(),escape:R.optional()}).strict().refine(e=>[e.escape,e.other?.blank].every(t=>t===void 0||e.options.some(e=>e.value===t)),`A decision's escape and blank answers must be offered options`)]),T(()=>ve(`type`,[S({type:x(`info`),message:R,links:w(S({url:Ye,label:R.optional()}).strict()).max(16).optional()}).strict(),S({type:x(`progress`),message:R}).strict(),S({type:x(`handoff`),url:Ye,code:R.optional(),message:R.optional()}).strict(),S({type:x(`success`),message:R}).strict()]));var Qe=new WeakMap,$e=`~effect/Redacted`,et=e=>u(e,$e),tt=(e,t)=>{let n=Object.create(nt);return t?.label&&(n.label=t.label),Qe.set(n,e),n},nt={[$e]:{_A:e=>e},label:void 0,...ne,toJSON(){return this.toString()},toString(){return`<redacted${c(this.label)?`:`+this.label:``}>`},[le](){return t(Qe.get(this))},[Oe](e){return et(e)&&se(Qe.get(this),Qe.get(e))}},rt=s.pipe(b(de(1)),b(E(80))),it=[`exec_isolation_required`,`execution_not_admitted`,`artifact_unavailable`,`disabled`,`timed_out`,`permission_changed`,`binding_reply_invalid`,`backend_error`,`cancelled`,`request_too_large`,`not_offered`,`internal`],at=r({binding:N().min(1).max(64),method:N().min(1).max(128),path:N().max(256)});r({error:x(`App execution unavailable`),reason:Se(it),ref:N().min(1).max(64).optional(),where:at.optional()});var ot=[`CANCELLED`,`CAPABILITY_DENIED`,`CAPABILITY_REVOKED`,`COMMAND_NOT_DECLARED`,`CONFLICT`,`DAILY_LIMIT_REACHED`,`DELIVERY_PENDING`,`DISCONNECTED`,`FILE_TOO_LARGE`,`HOST_FAILURE`,`IDENTITY`,`INSUFFICIENT_CREDIT`,`INVALID_ARGUMENT`,`MEDIA_PROVIDER_FAILURE`,`MEDIA_PROVIDER_FAILURE_UNCHARGED`,`PROTOCOL`,`SAFETY_FILTER_REFUSED`,`SELECTION_CHANGED`,`SETUP_REQUIRED`,`TIMEOUT`],st=d({name:m(`AppError`),code:D(ot),retryable:_,need:C(s),reason:C(s),ref:C(s),where:C(l)}),ct=D(it),lt=d({binding:s,method:s,path:s}),z=class extends Error{code;retryable;need;reason;ref;where;constructor(e,t){super(e,{cause:t.cause}),this.name=`AppError`,this.code=t.code,this.retryable=t.retryable,this.need=t.need,this.reason=t.reason,this.ref=t.ref,this.where=t.where}};function ut(e){return _e(te(rt)(e))}function dt(e){return`This needs ${e??`setup`} first.`}var ft={CANCELLED:{title:`Request cancelled`,message:`It stopped before it finished. Start it again if you still want it.`},CAPABILITY_DENIED:{title:`Access needed`,message:`This App needs permission to do that.`,action:`grant`},CAPABILITY_REVOKED:{title:`Access changed`,message:`This App no longer has permission to do that.`,action:`grant`},COMMAND_NOT_DECLARED:{title:`Action unavailable`,message:`This App doesn't include that action. It may need an update.`},CONFLICT:{title:`File changed`,message:`This file changed elsewhere. Review it before saving again.`},DAILY_LIMIT_REACHED:{title:`Daily limit reached`,message:`Today's spending limit for this Oyster is used up. It resets at 00:00 UTC.`},DELIVERY_PENDING:{title:`App delivery pending`,message:`The App hasn't finished getting ready. Try opening it again.`},DISCONNECTED:{title:`Connection lost`,message:`Reopen the App to connect again.`,action:`reconnect`},HOST_FAILURE:{title:`Couldn't complete the request`,message:`The host stopped answering. Reopen the App or reload the workspace.`},FILE_TOO_LARGE:{title:`File too large`,message:`Choose a file within the supported size limit.`},IDENTITY:{title:`Couldn't connect`,message:`Reopen the App to connect again.`,action:`reconnect`},INSUFFICIENT_CREDIT:{title:`Something went wrong`,message:`The App couldn't complete this request.`,action:`billing`},INVALID_ARGUMENT:{title:`Request not accepted`,message:`Some of the details weren't usable. Check them and try again.`},MEDIA_PROVIDER_FAILURE:{title:`Generation failed`,message:`The model couldn't complete this generation. Change the prompt or model and send again.`},MEDIA_PROVIDER_FAILURE_UNCHARGED:{title:`Generation failed`,message:`The model couldn't complete this generation. You weren't charged. Change the prompt or model and send again.`},PROTOCOL:{title:`Couldn't read the response`,message:`The host sent something this App doesn't understand. Reload the workspace; if it keeps happening, the App may need an update.`},SAFETY_FILTER_REFUSED:{title:`Generation refused`,message:`The model refused this generation. Change the prompt or reference image and send again.`},SELECTION_CHANGED:{title:`Selection changed`,message:`The selection changed during this request. Reopen the App to continue.`,action:`reconnect`},SETUP_REQUIRED:{title:`Setup needed`,message:dt(void 0),action:`setup`},TIMEOUT:{title:`Still waiting`,message:`The request didn't respond in time. Its outcome isn't known yet.`},UNKNOWN:{title:`Something went wrong`,message:`The App couldn't complete this request.`}};function pt(e){return e===void 0||e===``?``:` (ref ${e})`}var mt={exec_isolation_required:()=>({title:`App can't run here`,message:`This App needs a runtime this host doesn't have.`}),execution_not_admitted:()=>({title:`App not allowed to run`,message:`This App isn't allowed to run right now. A Team owner can check its access.`}),artifact_unavailable:()=>({title:`App files missing`,message:`This App's files couldn't be loaded. Update or reinstall it.`}),disabled:()=>({title:`App turned off`,message:`This App is turned off.`}),timed_out:()=>({title:`Still waiting`,message:`The App took too long to answer. Its result isn't known; check before you retry.`}),permission_changed:()=>({title:`Access changed`,message:`This App's access changed while it was working. Review its permissions.`,action:`grant`}),binding_reply_invalid:(e,t)=>({title:`Internal error`,message:t===void 0?`One of the App's connections returned an answer we couldn't read. That's our bug${pt(e)}.`:`The App's ${t.binding.toLowerCase()} connection answered ${t.method} with something we couldn't read${t.path===``?``:` (${t.path})`}. That's our bug${pt(e)}.`}),cancelled:()=>({title:`Request cancelled`,message:`This request was cancelled before it finished. Start it again if you still want it.`}),request_too_large:()=>({title:`Request too large`,message:`This request is too large for the App to accept. Try something smaller.`}),not_offered:()=>({title:`App can't do that`,message:`This App doesn't offer that.`}),backend_error:e=>({title:`The App failed`,message:`The App's own code failed on this request${pt(e)}.`}),internal:e=>({title:`Internal error`,message:`An internal error stopped the App from running this request${pt(e)}.`})};function ht(e,t){let n=te(st)(e);if(f(n))return{...ft.UNKNOWN,retryable:!1};let r=n.value,i=ft[r.code],a=_e(te(ct)(r.reason));if(a!==void 0){let e=_e(te(lt)(r.where)),t=mt[a](r.ref,e),n=t.action??(r.retryable?`retry`:void 0),i={title:t.title,message:t.message,retryable:r.retryable};return n?{...i,action:n}:i}let o=t?.[r.code]??(r.code===`SETUP_REQUIRED`?{title:i.title,message:dt(ut(r.need))}:i),s=i.action??(r.retryable?`retry`:void 0),c={title:o.title,message:o.message,retryable:r.retryable};return s?{...c,action:s}:c}var gt=n(),_t=P.createContext(void 0),vt=e=>{let t=P.useContext(_t);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},yt=({client:e,children:t})=>(P.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,gt.jsx)(_t.Provider,{value:e,children:t})),bt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},xt=new class{#e=bt;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function St(e){setTimeout(e,0)}var Ct=typeof window>`u`||`Deno`in globalThis;function wt(){}function Tt(e,t){return typeof e==`function`?e(t):e}function Et(e){return typeof e==`number`&&e>=0&&e!==1/0}function Dt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ot(e,t){return typeof e==`function`?e(t):e}function kt(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==jt(o,t.options))return!1}else if(!Nt(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function At(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Mt(t.options.mutationKey)!==Mt(a))return!1}else if(!Nt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function jt(e,t){return(t?.queryKeyHashFn||Mt)(e)}function Mt(e){return JSON.stringify(e,(e,t)=>Rt(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Nt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Nt(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Nt(e[r],t[r]))return!1;return!0}return!1}var Pt=Object.prototype.hasOwnProperty;function Ft(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Lt(e)&&Lt(t);if(!r&&!(Rt(e)&&Rt(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Pt.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let ee=Ft(u,d,n+1);s[o]=ee,ee===u&&c++}return i===o&&c===i?e:s}function It(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Lt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Rt(e){if(!zt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!zt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function zt(e){return Object.prototype.toString.call(e)===`[object Object]`}function Bt(e){return new Promise(t=>{xt.setTimeout(t,e)})}function Vt(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Ft(e,t)}function Ht(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ut(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Wt=Symbol();function Gt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Wt?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Kt(e,t){return typeof e==`function`?e(...t):!!e}function qt(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Jt=()=>Ct,Yt=()=>Jt(),Xt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Zt=new class extends Xt{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Qt=St;function $t(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Qt,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var en=$t(),tn=new class extends Xt{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function nn(e){return Math.min(1e3*2**e,3e4)}function rn(e){return(e??`online`)!==`online`||tn.isOnline()}var an=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function on(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(wt);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new an(t);re(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},ee=()=>Zt.isFocused()&&(e.networkMode===`always`||tn.isOnline())&&e.canRun(),te=()=>rn(e.networkMode)&&e.canRun(),ne=e=>{c()||(r?.(),i=`resolved`,a(e))},re=e=>{c()||(r?.(),i=`rejected`,o(e))},f=()=>new Promise(t=>{r=e=>{(c()||ee())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),p=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(ne).catch(r=>{if(c())return;let i=e.retry??(Yt()?0:3),a=e.retryDelay??nn,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){re(r);return}n++,e.onFail?.(n,r),Bt(o).then(()=>ee()?void 0:f()).then(()=>{t?re(r):p()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:te,start:()=>(te()?p():f().then(p),s)}}var sn=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Et(this.gcTime)&&(this.#e=xt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Yt()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(xt.clearTimeout(this.#e),this.#e=void 0)}},cn=class extends sn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||ln(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=on({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),en.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function ln(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var un=Symbol(`workers-module`);Symbol.dispose||(Symbol.dispose=Symbol.for(`dispose`)),Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for(`asyncDispose`)),Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}});var dn=globalThis[un],fn=dn?dn.RpcTarget:class{},pn=async function(){}.constructor,mn=typeof Buffer<`u`?Buffer.prototype:void 0;function hn(e){switch(typeof e){case`boolean`:case`number`:case`string`:return`primitive`;case`undefined`:return`undefined`;case`object`:case`function`:break;case`bigint`:return`bigint`;default:return`unsupported`}if(e===null)return`primitive`;let t=Object.getPrototypeOf(e);switch(t){case Object.prototype:return`object`;case Function.prototype:case pn.prototype:return`function`;case Array.prototype:return`array`;case Date.prototype:return`date`;case Uint8Array.prototype:case mn:case ArrayBuffer.prototype:case DataView.prototype:case Int8Array.prototype:case Uint8ClampedArray.prototype:case Int16Array.prototype:case Uint16Array.prototype:case Int32Array.prototype:case Uint32Array.prototype:case BigInt64Array.prototype:case BigUint64Array.prototype:case Float32Array.prototype:case Float64Array.prototype:return`bytes`;case WritableStream.prototype:return`writable`;case ReadableStream.prototype:return`readable`;case URL.prototype:return`url`;case Headers.prototype:return`headers`;case Request.prototype:return`request`;case Response.prototype:return`response`;case Blob.prototype:return`blob`;case U.prototype:return`stub`;case W.prototype:return`rpc-promise`;default:if(dn){if(t==dn.RpcStub.prototype||e instanceof dn.ServiceStub)return`rpc-target`;if(t==dn.RpcPromise.prototype||t==dn.RpcProperty.prototype)return`rpc-thenable`}return e instanceof fn?`rpc-target`:e instanceof Error?`error`:`unsupported`}}function gn(){throw Error(`RPC map() implementation was not loaded.`)}var _n={applyMap:gn,sendMap:gn};function vn(){throw Error(`Stream implementation was not loaded.`)}var B={createWritableStreamHook:vn,createWritableStreamFromHook:vn,createReadableStreamHook:vn},yn=class{stream(e,t){let n=this.call(e,t),r;try{r=n.pull()}catch(e){throw n.dispose(),e}let i;return r instanceof Promise?i=r.then(e=>{e.dispose()}):(r.dispose(),i=Promise.resolve()),{promise:i}}},V=class extends yn{error;constructor(e){super(),this.error=e}call(e,t){return t.dispose(),this}map(e,t,n){for(let e of t)e.dispose();return this}get(e){return this}dup(){return this}pull(){return Promise.reject(this.error)}ignoreUnhandledRejections(){}dispose(){}onBroken(e){try{e(this.error)}catch(e){Promise.resolve(e)}}},bn=new V(Error(`Attempted to use RPC stub after it has been disposed.`)),xn=(e,t,n)=>e.call(t,n);function Sn(e,t){let n=xn;xn=e;try{return t()}finally{xn=n}}var H=Symbol(`realStub`),Cn={apply(e,t,n){let r=e.raw;return new W(xn(r.hook,r.pathIfPromise||[],G.fromAppParams(n)),[])},get(e,t,n){let r=e.raw;if(t===H)return r;if(t in W.prototype)return r[t];if(typeof t==`string`)return new W(r.hook,r.pathIfPromise?[...r.pathIfPromise,t]:[t]);if(t===Symbol.dispose&&(!r.pathIfPromise||r.pathIfPromise.length==0))return()=>{r.hook.dispose(),r.hook=bn}},has(e,t){let n=e.raw;return t===H?!0:t in W.prototype?t in n:typeof t==`string`||t===Symbol.dispose&&(!n.pathIfPromise||n.pathIfPromise.length==0)},construct(e,t){throw Error(`An RPC stub cannot be used as a constructor.`)},defineProperty(e,t,n){throw Error(`Can't define properties on RPC stubs.`)},deleteProperty(e,t){throw Error(`Can't delete properties on RPC stubs.`)},getOwnPropertyDescriptor(e,t){},getPrototypeOf(e){return Object.getPrototypeOf(e.raw)},isExtensible(e){return!1},ownKeys(e){return[]},preventExtensions(e){return!0},set(e,t,n,r){throw Error(`Can't assign properties on RPC stubs.`)},setPrototypeOf(e,t){throw Error(`Can't override prototype of RPC stubs.`)}},U=class e extends fn{constructor(e,t){if(super(),!(e instanceof yn)){let n=e;if(e=n instanceof fn||n instanceof Function?Nn.create(n,void 0):new K(G.fromAppReturn(n)),t)throw TypeError(`RpcStub constructor expected one argument, received two.`)}this.hook=e,this.pathIfPromise=t;let n=()=>{};return n.raw=this,new Proxy(n,Cn)}hook;pathIfPromise;dup(){let t=this[H];return t.pathIfPromise?new e(t.hook.get(t.pathIfPromise)):new e(t.hook.dup())}onRpcBroken(e){this[H].hook.onBroken(e)}map(e){let{hook:t,pathIfPromise:n}=this[H];return _n.sendMap(t,n||[],e)}toString(){return`[object RpcStub]`}},W=class extends U{constructor(e,t){if(e instanceof yn)super(e,t??[]);else{if(t!==void 0)throw TypeError(`RpcPromise constructor expected one argument, received two.`);let n=hn(e);if(n===`rpc-promise`){let t=On(e);if(t.pathIfPromise.length>0)super(t.hook,t.pathIfPromise);else{let e=t.hook;t.hook=bn,super(e,[])}}else if(n===`rpc-thenable`)super(Nn.create(e,void 0),[]);else{let t=new Pn(Promise.resolve(e).then(e=>new K(G.fromAppReturn(e))));t.ignoreUnhandledRejections(),super(t,[])}}}then(e,t){return kn(this).then(...arguments)}catch(e){return kn(this).catch(...arguments)}finally(e){return kn(this).finally(...arguments)}toString(){return`[object RpcPromise]`}};function wn(e){let{hook:t,pathIfPromise:n}=e[H];return n&&n.length>0?t.get(n):t}function Tn(e){let{hook:t,pathIfPromise:n}=e[H];return n?t.get(n):t.dup()}function En(e){let{hook:t,pathIfPromise:n}=e[H];if(!(n&&n.length>0))return t}function Dn(e){return e[H].hook}function On(e){return e[H]}async function kn(e){let{hook:t,pathIfPromise:n}=e[H];return n.length>0&&(t=t.get(n)),(await t.pull()).deliverResolve()}var G=class e{value;source;hooks;promises;static fromAppParams(t){return new e(t,`params`)}static fromAppReturn(t){return new e(t,`return`)}static fromArray(t){let n=[],r=[],i=[];for(let e of t){e.ensureDeepCopied();for(let t of e.hooks)n.push(t);for(let t of e.promises)t.parent===e&&(t={parent:i,property:i.length,promise:t.promise}),r.push(t);i.push(e.value)}return new e(i,`owned`,n,r)}static forEvaluate(t,n){return new e(null,`owned`,t,n)}static deepCopyFrom(t,n,r){let i=new e(null,`owned`,[],[]);return i.value=i.deepCopy(t,n,`value`,i,!0,r),i}constructor(e,t,n,r){this.value=e,this.source=t,this.hooks=n,this.promises=r}rpcTargets;getHookForRpcTarget(e,t,n=!0){if(this.source===`params`){if(n){let t=e;typeof t.dup==`function`&&(e=t.dup())}return Nn.create(e,t)}if(this.source===`return`){let r=this.rpcTargets?.get(e);return r?n?r.dup():(this.rpcTargets?.delete(e),r):(r=Nn.create(e,t),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,r),r.dup()):r)}throw Error(`owned payload shouldn't contain raw RpcTargets`)}getHookForWritableStream(e,t,n=!0){if(this.source===`params`)return B.createWritableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=B.createWritableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw WritableStreams`)}getHookForReadableStream(e,t,n=!0){if(this.source===`params`)return B.createReadableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=B.createReadableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw ReadableStreams`)}deepCopy(e,t,n,r,i,a){switch(hn(e)){case`unsupported`:return e;case`primitive`:case`bigint`:case`date`:case`bytes`:case`blob`:case`url`:case`error`:case`undefined`:return e;case`array`:{let t=e,n=t.length,r=Array(n);for(let e=0;e<n;e++)r[e]=this.deepCopy(t[e],t,e,r,i,a);return r}case`object`:{let t={},n=e;for(let e in n)t[e]=this.deepCopy(n[e],n,e,t,i,a);return t}case`stub`:case`rpc-promise`:{let t=e,a;if(a=i?Tn(t):wn(t),t instanceof W){let e=new W(a,[]);return this.promises.push({parent:r,property:n,promise:e}),e}return this.hooks.push(a),new U(a)}case`function`:case`rpc-target`:{let n=e,r;return r=a?a.getHookForRpcTarget(n,t,i):Nn.create(n,t),this.hooks.push(r),new U(r)}case`rpc-thenable`:{let o=e,s;return s=a?new W(a.getHookForRpcTarget(o,t,i),[]):new W(Nn.create(o,t),[]),this.promises.push({parent:r,property:n,promise:s}),s}case`writable`:{let n=e,r;return r=a?a.getHookForWritableStream(n,t,i):B.createWritableStreamHook(n),this.hooks.push(r),n}case`readable`:{let n=e,r;return r=a?a.getHookForReadableStream(n,t,i):B.createReadableStreamHook(n),this.hooks.push(r),n}case`headers`:return new Headers(e);case`request`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Request(t)}case`response`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Response(t.body,t)}default:throw Error(`unreachable`)}}ensureDeepCopied(){if(this.source!==`owned`){let e=this.source===`params`;this.hooks=[],this.promises=[];try{this.value=this.deepCopy(this.value,void 0,`value`,this,e,this)}catch(e){throw this.hooks=void 0,this.promises=void 0,e}if(this.source=`owned`,this.rpcTargets&&this.rpcTargets.size>0)throw Error(`Not all rpcTargets were accounted for in deep-copy?`);this.rpcTargets=void 0}}deliverTo(t,n,r){if(this.ensureDeepCopied(),this.value instanceof W)e.deliverRpcPromiseTo(this.value,t,n,r);else{t[n]=this.value;for(let t of this.promises)e.deliverRpcPromiseTo(t.promise,t.parent,t.property,r)}}static deliverRpcPromiseTo(t,n,r,i){let a=En(t);if(!a)throw Error(`property promises should have been resolved earlier`);let o=a.pull();o instanceof e?o.deliverTo(n,r,i):i.push(o.then(e=>{let t=[];if(e.deliverTo(n,r,t),t.length>0)return Promise.all(t)}))}async deliverCall(t,n){try{let r=[];this.deliverTo(this,`value`,r),r.length>0&&await Promise.all(r);let i=Function.prototype.apply.call(t,n,this.value);return i instanceof W?e.fromAppReturn(i):e.fromAppReturn(await i)}finally{this.dispose()}}async deliverStreamWrite(t){try{let n=[];this.deliverTo(this,`value`,n),n.length>0&&await Promise.all(n);let r=this.value[0];return(this.hooks.length>0||this.promises.length>0)&&r instanceof Object?(Symbol.dispose in r||Object.defineProperty(r,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0}),await t.write(r),e.fromAppReturn(void 0)):(await t.write(r),this.dispose(),e.fromAppReturn(void 0))}catch(e){throw this.dispose(),e}}async deliverResolve(){try{let e=[];this.deliverTo(this,`value`,e),e.length>0&&await Promise.all(e);let t=this.value;return t instanceof Object&&(Symbol.dispose in t||Object.defineProperty(t,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0})),t}catch(e){throw this.dispose(),e}}dispose(){if(this.source===`owned`)this.hooks.forEach(e=>e.dispose()),this.promises.forEach(e=>e.promise[Symbol.dispose]());else if(this.source===`return`&&(this.disposeImpl(this.value,void 0),this.rpcTargets&&this.rpcTargets.size>0))throw Error(`Not all rpcTargets were accounted for in disposeImpl()?`);this.source=`owned`,this.hooks=[],this.promises=[]}disposeImpl(e,t){switch(hn(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`url`:case`error`:case`undefined`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.disposeImpl(t[e],t);return}case`object`:{let t=e;for(let e in t)this.disposeImpl(t[e],t);return}case`stub`:case`rpc-promise`:{let t=En(e);t&&t.dispose();return}case`function`:case`rpc-target`:{let t=e,n=this.rpcTargets?.get(t);n?(n.dispose(),this.rpcTargets.delete(t)):Mn(t);return}case`rpc-thenable`:return;case`headers`:return;case`request`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`response`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`writable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=B.createWritableStreamHook(t),n.dispose();return}case`readable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=B.createReadableStreamHook(t),n.dispose();return}default:return}}ignoreUnhandledRejections(){this.hooks?(this.hooks.forEach(e=>{e.ignoreUnhandledRejections()}),this.promises.forEach(e=>Dn(e.promise).ignoreUnhandledRejections())):this.ignoreUnhandledRejectionsImpl(this.value)}ignoreUnhandledRejectionsImpl(e){switch(hn(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`undefined`:case`function`:case`rpc-target`:case`writable`:case`readable`:case`url`:case`headers`:case`request`:case`response`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`object`:{let t=e;for(let e in t)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`stub`:case`rpc-promise`:Dn(e).ignoreUnhandledRejections();return;case`rpc-thenable`:e.then(e=>{},e=>{});return;default:return}}};function An(e,t,n,r){for(let i=0;i<n.length;i++){t=e;let a=n[i];if(a in Object.prototype){e=void 0;continue}switch(hn(e)){case`object`:case`function`:e=Object.hasOwn(e,a)?e[a]:void 0;break;case`array`:e=Number.isInteger(a)&&a>=0?e[a]:void 0;break;case`rpc-target`:case`rpc-thenable`:if(Object.hasOwn(e,a))throw TypeError(`Attempted to access property '${a}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);e=e[a],r=null;break;case`stub`:case`rpc-promise`:{let{hook:t,pathIfPromise:r}=On(e);return{hook:t,remainingPath:r?r.concat(n.slice(i)):n.slice(i)}}case`writable`:e=void 0;break;case`readable`:e=void 0;break;case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`url`:case`headers`:case`request`:case`response`:e=void 0;break;case`undefined`:e=e[a];break;case`unsupported`:if(i===0)throw TypeError(`RPC stub points at a non-serializable type.`);{let e=n.slice(0,i).join(`.`),t=n.slice(0,i).join(`.`);throw TypeError(`'${e}' is not a serializable type, so property ${t} cannot be accessed.`)}default:throw TypeError(`unreachable`)}}if(e instanceof W){let{hook:t,pathIfPromise:n}=On(e);return{hook:t,remainingPath:n||[]}}return{value:e,parent:t,owner:r}}var jn=class extends yn{call(e,t){let n;try{let{value:t,owner:r}=this.getValue();n=An(t,void 0,e,r)}catch(e){return t.dispose(),new V(e)}return n.hook?n.hook.call(n.remainingPath,t):typeof n.value==`function`?new Pn(t.deliverCall(n.value,n.parent).then(e=>new K(e))):(t.dispose(),new V(TypeError(`'${e.join(`.`)}' is not a function.`)))}map(e,t,n){try{let r;try{let{value:t,owner:n}=this.getValue();r=An(t,void 0,e,n)}catch(e){for(let e of t)e.dispose();throw e}return r.hook?r.hook.map(r.remainingPath,t,n):_n.applyMap(r.value,r.parent,r.owner,t,n)}catch(e){return new V(e)}}get(e){try{let{value:t,owner:n}=this.getValue();if(e.length===0&&n===null){if(t instanceof Object&&`then`in t)return this.dup();throw Error(`Can't dup an RpcTarget stub as a promise.`)}let r=An(t,void 0,e,n);return r.hook?r.hook.get(r.remainingPath):new K(G.deepCopyFrom(r.value,r.parent,r.owner))}catch(e){return new V(e)}}},K=class e extends jn{constructor(e){super(),this.payload=e}payload;getPayload(){if(this.payload)return this.payload;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){let e=this.getPayload();return{value:e.value,owner:e}}dup(){let t=this.getPayload();return new e(G.deepCopyFrom(t.value,void 0,t))}pull(){return this.getPayload()}ignoreUnhandledRejections(){this.payload&&this.payload.ignoreUnhandledRejections()}dispose(){this.payload&&=(this.payload.dispose(),void 0)}onBroken(e){this.payload&&this.payload.value instanceof U&&this.payload.value.onRpcBroken(e)}};function Mn(e){if(Symbol.dispose in e)try{e[Symbol.dispose]()}catch(e){Promise.reject(e)}}var Nn=class e extends jn{static create(t,n){return typeof t!=`function`&&(n=void 0),new e(t,n)}constructor(e,t,n){super(),this.target=e,this.parent=t,n?n.refcount&&(this.refcount=n.refcount,++this.refcount.count):Symbol.dispose in e&&(this.refcount={count:1})}target;parent;refcount;getTarget(){if(this.target)return this.target;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){return{value:this.getTarget(),owner:null}}dup(){return new e(this.getTarget(),this.parent,this)}pull(){let e=this.getTarget();return`then`in e?Promise.resolve(e).then(e=>G.fromAppReturn(e)):Promise.reject(Error(`Tried to resolve a non-promise stub.`))}ignoreUnhandledRejections(){}dispose(){this.target&&=(this.refcount&&--this.refcount.count==0&&Mn(this.target),void 0)}onBroken(e){let t=this.target;t&&`then`in t&&Promise.resolve(t).then(()=>{},e)}},Pn=class e extends yn{promise;resolution;constructor(e){super(),this.promise=e.then(e=>(this.resolution=e,e))}call(t,n){return n.ensureDeepCopied(),new e(this.promise.then(e=>e.call(t,n),e=>{throw n.dispose(),e}))}stream(e,t){return t.ensureDeepCopied(),{promise:this.promise.then(n=>n.stream(e,t).promise,e=>{throw t.dispose(),e})}}map(t,n,r){return new e(this.promise.then(e=>e.map(t,n,r),e=>{for(let e of n)e.dispose();throw e}))}get(t){return new e(this.promise.then(e=>e.get(t)))}dup(){return this.resolution?this.resolution.dup():new e(this.promise.then(e=>e.dup()))}pull(){return this.resolution?this.resolution.pull():this.promise.then(e=>e.pull())}ignoreUnhandledRejections(){this.resolution?this.resolution.ignoreUnhandledRejections():this.promise.then(e=>{e.ignoreUnhandledRejections()},e=>{})}dispose(){this.promise.then(e=>e.dispose(),()=>{})}onBroken(e){this.resolution?this.resolution.onBroken(e):this.promise.then(t=>{t.onBroken(e)},e)}},Fn={maxBigIntDigits:16384,maxDepth:256,maxMessageSize:33554432},In=new Uint8Array(new Uint16Array([1]).buffer)[0]===1,Ln=[`ArrayBuffer`,`DataView`,`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`,`Float32Array`,`Float64Array`];function Rn(e){return Ln.includes(e)}var zn={ArrayBuffer:void 0,DataView:void 0,Int8Array:void 0,Uint8Array:void 0,Uint8ClampedArray:void 0,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,BigInt64Array:8,BigUint64Array:8,Float32Array:4,Float64Array:8},Bn={ArrayBuffer:ArrayBuffer.prototype,DataView:DataView.prototype,Int8Array:Int8Array.prototype,Uint8ClampedArray:Uint8ClampedArray.prototype,Int16Array:Int16Array.prototype,Uint16Array:Uint16Array.prototype,Int32Array:Int32Array.prototype,Uint32Array:Uint32Array.prototype,BigInt64Array:BigInt64Array.prototype,BigUint64Array:BigUint64Array.prototype,Float32Array:Float32Array.prototype,Float64Array:Float64Array.prototype},Vn=new Map;for(let e of Object.keys(Bn))Vn.set(Bn[e],e);function Hn(e,t){if(t!==2&&t!==4&&t!==8)throw RangeError(`Unsupported element size: ${t}`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<e.byteLength;r+=t)switch(t){case 2:n.setUint16(r,n.getUint16(r,!1),!0);break;case 4:n.setUint32(r,n.getUint32(r,!1),!0);break;case 8:n.setBigUint64(r,n.getBigUint64(r,!1),!0)}}var Un=new class{exportStub(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}exportPromise(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}getImport(e){}unexport(e){}createPipe(e){throw Error(`Cannot create pipes without an RPC session.`)}onSendError(e){}};async function Wn(e,t){let n=await new Response(e).blob();return n.type===t?n:n.slice(0,n.size,t)}var Gn={__proto__:null,Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError},q=class e{exporter;source;encodingLevel;constructor(e,t,n){this.exporter=e,this.source=t,this.encodingLevel=n}static devaluate(t,n,r=Un,i,a=`string`){let o=new e(r,i,a);try{return o.devaluateImpl(t,n,0)}catch(e){if(o.exports)try{r.unexport(o.exports)}catch{}throw e}}exports;devaluateImpl(e,t,n){if(n>=256)throw Error(`Serialization exceeded maximum allowed depth. (Does the message contain cycles?)`);switch(hn(e)){case`unsupported`:{let t;try{t=`Cannot serialize value: ${e}`}catch{t=`Cannot serialize value: (couldn't stringify value)`}throw TypeError(t)}case`primitive`:return typeof e==`number`&&!isFinite(e)?this.encodingLevel===`structuredClonable`?e:e===1/0?[`inf`]:e===-1/0?[`-inf`]:[`nan`]:e;case`object`:{let t=e,r={};for(let e in t)r[e]=this.devaluateImpl(t[e],t,n+1);return r}case`array`:{let t=e,r=t.length,i=Array(r);for(let e=0;e<r;e++)i[e]=this.devaluateImpl(t[e],t,n+1);return[i]}case`bigint`:return this.encodingLevel===`structuredClonable`?e:[`bigint`,e.toString()];case`date`:{if(this.encodingLevel===`structuredClonable`)return e;let t=e.getTime();return[`date`,Number.isNaN(t)?null:t]}case`bytes`:{let t=Vn.get(Object.getPrototypeOf(e)),n;if(t===`ArrayBuffer`)n=new Uint8Array(e);else if(t===void 0)n=e;else{let r=e;n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);let i=zn[t];!In&&i&&(n=n.slice(),Hn(n,i))}if(this.encodingLevel===`structuredClonable`||this.encodingLevel===`jsonCompatibleWithBytes`)return t===void 0?[`bytes`,n]:[`bytes`,n,t];let r;if(n.toBase64)r=n.toBase64({omitPadding:!0});else if(typeof Buffer<`u`)r=(n instanceof Buffer?n:Buffer.from(n.buffer,n.byteOffset,n.byteLength)).toString(`base64`);else{let e=``;for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);r=btoa(e)}return r=r.replace(/=+$/,``),t===void 0?[`bytes`,r]:[`bytes`,r,t]}case`url`:return[`url`,e.href];case`headers`:return[`headers`,[...e]];case`request`:{let t=e,r={};t.method!==`GET`&&(r.method=t.method);let i=[...t.headers];if(i.length>0&&(r.headers=i),t.body)r.body=this.devaluateImpl(t.body,t,n+1),r.duplex=t.duplex||`half`;else if(t.body===void 0&&![`GET`,`HEAD`,`OPTIONS`,`TRACE`,`DELETE`].includes(t.method)){let e=t.arrayBuffer(),n=new ReadableStream({async start(t){try{t.enqueue(new Uint8Array(await e)),t.close()}catch(e){t.error(e)}}}),i=B.createReadableStreamHook(n);r.body=[`readable`,this.exporter.createPipe(n,i)],r.duplex=t.duplex||`half`}t.cache&&t.cache!=="default"&&(r.cache=t.cache),t.redirect!==`follow`&&(r.redirect=t.redirect),t.integrity&&(r.integrity=t.integrity),t.mode&&t.mode!==`cors`&&(r.mode=t.mode),t.credentials&&t.credentials!==`same-origin`&&(r.credentials=t.credentials),t.referrer&&t.referrer!==`about:client`&&(r.referrer=t.referrer),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.keepalive&&(r.keepalive=t.keepalive);let a=t;return a.cf&&(r.cf=a.cf),a.encodeResponseBody&&a.encodeResponseBody!==`automatic`&&(r.encodeResponseBody=a.encodeResponseBody),[`request`,t.url,r]}case`response`:{let t=e,r=this.devaluateImpl(t.body,t,n+1),i={};t.status!==200&&(i.status=t.status),t.statusText&&(i.statusText=t.statusText);let a=[...t.headers];a.length>0&&(i.headers=a);let o=t;if(o.cf&&(i.cf=o.cf),o.encodeBody&&o.encodeBody!==`automatic`&&(i.encodeBody=o.encodeBody),o.webSocket)throw TypeError(`Can't serialize a Response containing a webSocket.`);return[`response`,r,i]}case`blob`:{let t=e,n=t.stream(),r=B.createReadableStreamHook(n),i=this.exporter.createPipe(n,r);return[`blob`,t.type,[`readable`,i]]}case`error`:{let t=e,r=this.exporter.onSendError(t);r&&(t=r);let i=t,a,o=(e,r)=>{let i=this.exports?.length??0;try{let i=this.devaluateImpl(r,t,n+1);a||={},a[e]=i}catch{if(this.exports&&this.exports.length>i){let e=this.exports.splice(i);try{this.exporter.unexport(e)}catch{}}}};for(let e of Object.keys(t))e!==`name`&&e!==`message`&&e!==`stack`&&o(e,i[e]);`cause`in t&&o(`cause`,i.cause),t instanceof AggregateError&&o(`errors`,t.errors);let s=[`error`,t.name,t.message];return a?(s.push(r&&r.stack?r.stack:null),s.push(a)):r&&r.stack&&s.push(r.stack),s}case`undefined`:return this.encodingLevel===`structuredClonable`?void 0:[`undefined`];case`stub`:case`rpc-promise`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let{hook:t,pathIfPromise:n}=On(e),r=this.exporter.getImport(t);return r===void 0?(t=n?t.get(n):t.dup(),this.devaluateHook(n?`promise`:`export`,t)):n?n.length>0?[`pipeline`,r,n]:[`pipeline`,r]:[`import`,r]}case`function`:case`rpc-target`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`export`,n)}case`rpc-thenable`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`promise`,n)}case`writable`:{if(!this.source)throw Error(`Can't serialize WritableStream in this context.`);let n=this.source.getHookForWritableStream(e,t);return this.devaluateHook(`writable`,n)}case`readable`:{if(!this.source)throw Error(`Can't serialize ReadableStream in this context.`);let n=e,r=this.source.getHookForReadableStream(n,t);return[`readable`,this.exporter.createPipe(n,r)]}default:throw Error(`unreachable`)}}devaluateHook(e,t){this.exports||=[];let n=e===`promise`?this.exporter.exportPromise(t):this.exporter.exportStub(t);return this.exports.push(n),[e,n]}};new class{importStub(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}importPromise(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}getExport(e){}getPipeReadable(e){throw Error(`Cannot retrieve pipe readable without an RPC session.`)}getLimits(){return Fn}};function Kn(e,t){return new W(new Pn(new Response(t).arrayBuffer().then(t=>{let n=new Uint8Array(t),r=new Request(e,{body:n});return new K(G.fromAppReturn(r))})),[])}function qn(e,t){return new W(new Pn(Wn(e,t).then(e=>new K(G.fromAppReturn(e)))),[])}var Jn=class e{importer;encodingLevel;limits;constructor(e,t=`string`){this.importer=e,this.encodingLevel=t,this.limits=e.getLimits()}hooks=[];promises=[];evaluate(e){return this.evaluateWithDepth(e,0)}evaluateWithDepth(e,t){let n=G.forEvaluate(this.hooks,this.promises);try{return n.value=this.evaluateImpl(e,n,`value`,t),n}catch(e){throw n.dispose(),e}}evaluateCopy(e){return this.evaluate(structuredClone(e))}evaluateImpl(t,n,r,i){let a=this.limits.maxDepth;if(i>=a)throw TypeError(`Deserialization exceeded maximum allowed message depth of ${a}.`);if(this.encodingLevel===`structuredClonable`&&(t instanceof Date||typeof t==`bigint`))return t;if(t instanceof Array){if(t.length==1&&t[0]instanceof Array){let e=t[0];for(let t=0;t<e.length;t++)e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}switch(t[0]){case`bigint`:if(typeof t[1]==`string`){let e=t[1],n=this.limits.maxBigIntDigits;if(e.length>n)throw TypeError(`Deserialized bigint exceeds maximum length of ${n} digits.`);return BigInt(e)}break;case`date`:if(t[1]===null)return new Date(NaN);if(typeof t[1]==`number`)return new Date(t[1]);break;case`bytes`:{let e;if(t[1]instanceof Uint8Array)e=t[1];else if(typeof t[1]==`string`){if(typeof Buffer<`u`)e=Buffer.from(t[1],`base64`);else if(Uint8Array.fromBase64)e=Uint8Array.fromBase64(t[1]);else{let n=atob(t[1]),r=n.length;e=new Uint8Array(r);for(let t=0;t<r;t++)e[t]=n.charCodeAt(t)}}else break;if(t.length===2)return e;if(typeof t[2]!=`string`)throw TypeError(`Unknown bytes type marker type: ${typeof t[2]}`);if(!Rn(t[2])){let e=t[2].slice(0,64);throw TypeError(`Unknown bytes type marker: ${e}`)}let n=t[2],r=zn[n];if(r!==void 0&&e.byteLength%r!==0)throw TypeError(`Invalid byte length ${e.byteLength} for ${n}; expected a multiple of ${r}`);let i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);switch(!In&&r!==void 0&&Hn(new Uint8Array(i),r),n){case`ArrayBuffer`:return i;case`DataView`:return new DataView(i);case`Int8Array`:return new Int8Array(i);case`Uint8Array`:return new Uint8Array(i);case`Uint8ClampedArray`:return new Uint8ClampedArray(i);case`Int16Array`:return new Int16Array(i);case`Uint16Array`:return new Uint16Array(i);case`Int32Array`:return new Int32Array(i);case`Uint32Array`:return new Uint32Array(i);case`BigInt64Array`:return new BigInt64Array(i);case`BigUint64Array`:return new BigUint64Array(i);case`Float32Array`:return new Float32Array(i);case`Float64Array`:return new Float64Array(i)}}case`error`:if(t.length>=3&&typeof t[1]==`string`&&typeof t[2]==`string`){let e=Gn[t[1]]||Error,n=e===AggregateError?new e([],t[2]):new e(t[2]);if(typeof t[3]==`string`&&(n.stack=t[3]),t.length>=5){let e=t[4];if(!e||typeof e!=`object`||Array.isArray(e))break;let r=n,a=e;for(let e of Object.keys(a))if(e!==`name`&&e!==`message`&&e!==`stack`){if(e in Object.prototype||e===`toJSON`){this.evaluateImpl(a[e],n,e,i+1);continue}r[e]=this.evaluateImpl(a[e],n,e,i+1)}}return n}break;case`undefined`:if(t.length===1)return;break;case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;case`url`:if(t.length===2&&typeof t[1]==`string`)return new URL(t[1]);break;case`headers`:if(t.length===2&&t[1]instanceof Array)return new Headers(t[1]);break;case`request`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=t[2];if(typeof a!=`object`||!a)break;if(a.body&&(a.body=this.evaluateImpl(a.body,a,`body`,i+1),!(a.body===null||typeof a.body==`string`||a.body instanceof Uint8Array||a.body instanceof ReadableStream)))throw TypeError(`Request body must be of type ReadableStream.`);if(a.signal&&(a.signal=this.evaluateImpl(a.signal,a,`signal`,i+1),!(a.signal instanceof AbortSignal)))throw TypeError(`Request siganl must be of type AbortSignal.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);let o=new Request(e,a);if(a.body instanceof ReadableStream&&o.body===void 0){let e=Kn(o,a.body);return this.promises.push({promise:e,parent:n,property:r}),e}return o}case`response`:{if(t.length!==3)break;let e=this.evaluateImpl(t[1],n,r,i+1);if(!(e===null||typeof e==`string`||e instanceof Uint8Array||e instanceof ReadableStream))throw TypeError(`Response body must be of type ReadableStream.`);let a=t[2];if(typeof a!=`object`||!a)break;if(a.webSocket)throw TypeError(`Can't deserialize a Response containing a webSocket.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);return new Response(e,a)}case`blob`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=this.evaluateImpl(t[2],n,r,i+1);if(!(a instanceof ReadableStream))throw TypeError(`Blob content must be serialized as a ReadableStream.`);let o=qn(a,e);return this.promises.push({promise:o,parent:n,property:r}),o}case`import`:case`pipeline`:{if(t.length<2||t.length>4||typeof t[1]!=`number`)break;let a=this.importer.getExport(t[1]);if(!a)throw Error(`no such entry on exports table: ${t[1]}`);let o=t[0]==`pipeline`,s=e=>{if(o){let t=new W(e,[]);return this.promises.push({promise:t,parent:n,property:r}),t}return this.hooks.push(e),new W(e,[])};if(t.length==2)return s(o?a.get([]):a.dup());let c=t[2];if(!(c instanceof Array)||!c.every(e=>typeof e==`string`||typeof e==`number`))break;if(t.length==3)return s(a.get(c));let l=t[3];if(!(l instanceof Array))break;return l=new e(this.importer).evaluateWithDepth([l],i),s(a.call(c,l))}case`remap`:{if(t.length!==5||typeof t[1]!=`number`||!(t[2]instanceof Array)||!(t[3]instanceof Array)||!(t[4]instanceof Array))break;let e=this.importer.getExport(t[1]);if(!e)throw Error(`no such entry on exports table: ${t[1]}`);let i=t[2];if(!i.every(e=>typeof e==`string`||typeof e==`number`))break;let a=t[3].map(e=>{if(!(e instanceof Array)||e.length!==2||e[0]!==`import`&&e[0]!==`export`||typeof e[1]!=`number`)throw TypeError(`unknown map capture: ${JSON.stringify(e)}`);if(e[0]===`export`)return this.importer.importStub(e[1]);{let t=this.importer.getExport(e[1]);if(!t)throw Error(`no such entry on exports table: ${e[1]}`);return t.dup()}}),o=t[4],s=new W(e.map(i,a,o),[]);return this.promises.push({promise:s,parent:n,property:r}),s}case`export`:case`promise`:if(typeof t[1]==`number`){if(t[0]==`promise`){let e=new W(this.importer.importPromise(t[1]),[]);return this.promises.push({parent:n,property:r,promise:e}),e}{let e=this.importer.importStub(t[1]);return this.hooks.push(e),new U(e)}}break;case`writable`:if(typeof t[1]==`number`){let e=this.importer.importStub(t[1]),n=B.createWritableStreamFromHook(e);return this.hooks.push(e),n}break;case`readable`:if(typeof t[1]==`number`){let e=this.importer.getPipeReadable(t[1]),n=B.createReadableStreamHook(e);return this.hooks.push(n),e}}throw TypeError(`unknown special value: ${JSON.stringify(t)}`)}if(t instanceof Object){let e=t;for(let t in e)t in Object.prototype||t===`toJSON`?(this.evaluateImpl(e[t],e,t,i+1),delete e[t]):e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}return t}},Yn=16,Xn=8,Zn=16,Qn=64;function $n(e){return 2+e.length*3}function er(e,t,n=0){if(n>=Qn)return Xn;switch(typeof e){case`string`:return $n(e);case`number`:return 16;case`bigint`:return 16;case`boolean`:return 8;case`undefined`:return 16;case`object`:{if(e===null)return 8;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return Zn+e.byteLength;if(typeof Blob<`u`&&e instanceof Blob)return Zn+e.size;if(e instanceof Date)return 16;if(t??=new WeakSet,t.has(e))return Xn;if(t.add(e),e instanceof Array){let r=Yn;for(let i of e)r+=Xn+er(i,t,n+1);return r}if(e instanceof Error){let r=Yn+$n(e.name)+$n(e.message)+$n(e.stack??``);for(let i of Object.keys(e))r+=Xn+$n(i)+er(e[i],t,n+1);return r}let r=Yn;for(let i of Object.keys(e))r+=Xn+$n(i)+er(e[i],t,n+1);return r}default:return 16}}var tr=class{session;importId;constructor(e,t,n){this.session=e,this.importId=t,n&&(this.activePull=Promise.withResolvers())}localRefcount=0;remoteRefcount=1;activePull;resolution;onBrokenRegistrations;resolve(e){if(this.localRefcount==0){e.dispose();return}if(this.resolution=e,this.sendRelease(),this.onBrokenRegistrations){for(let t of this.onBrokenRegistrations){let n=this.session.onBrokenCallbacks[t],r=this.session.onBrokenCallbacks.length;e.onBroken(n),this.session.onBrokenCallbacks[r]===n?delete this.session.onBrokenCallbacks[r]:delete this.session.onBrokenCallbacks[t]}this.onBrokenRegistrations=void 0}this.activePull&&=(this.activePull.resolve(),void 0)}async awaitResolution(){return this.activePull||=(this.session.sendPull(this.importId),Promise.withResolvers()),await this.activePull.promise,this.resolution.pull()}dispose(){this.resolution?this.resolution.dispose():(this.abort(Error(`RPC was canceled because the RpcPromise was disposed.`)),this.sendRelease())}abort(e){if(!this.resolution){if(this.resolution=new V(e),this.activePull&&=(this.activePull.reject(e),void 0),this.onBrokenRegistrations)for(let e of this.onBrokenRegistrations)delete this.session.onBrokenCallbacks[e];this.onBrokenRegistrations=void 0}}onBroken(e){if(this.resolution)this.resolution.onBroken(e);else{let t=this.session.onBrokenCallbacks.length;this.session.onBrokenCallbacks.push(e),this.onBrokenRegistrations||=[],this.onBrokenRegistrations.push(t)}}sendRelease(){this.remoteRefcount>0&&(this.session.sendRelease(this.importId,this.remoteRefcount),this.remoteRefcount=0)}},nr=class e extends yn{isPromise;entry;constructor(e,t){super(),this.isPromise=e,++t.localRefcount,this.entry=t}collectPath(e){return this}getEntry(){if(this.entry)return this.entry;throw Error(`This RpcImportHook was already disposed.`)}getEntryTakingOwnership(e){try{return this.getEntry()}catch(t){throw e(),t}}call(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.call(e,t):n.session.sendCall(n.importId,e,t)}stream(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.stream(e,t):n.session.sendStream(n.importId,e,t)}map(e,t,n){let r=this.getEntryTakingOwnership(()=>{for(let e of t)e.dispose()});return r.resolution?r.resolution.map(e,t,n):r.session.sendMap(r.importId,e,t,n)}get(e){let t=this.getEntry();return t.resolution?t.resolution.get(e):t.session.sendCall(t.importId,e)}dup(){return new e(!1,this.getEntry())}pull(){let e=this.getEntry();if(!this.isPromise)throw Error(`Can't pull this hook because it's not a promise hook.`);return e.resolution?e.resolution.pull():e.awaitResolution()}ignoreUnhandledRejections(){}dispose(){let e=this.entry;this.entry=void 0,e&&--e.localRefcount===0&&e.dispose()}onBroken(e){this.entry&&this.entry.onBroken(e)}},rr=class extends nr{session;constructor(e){super(!1,e),this.session=e.session}dispose(){if(this.session){let e=this.session;this.session=void 0,e.shutdown()}}},ir=class{transport;options;exports=[];reverseExports=new Map;imports=[];abortReason;cancelReadLoop;nextExportId=-1;onBatchDone;pullCount=0;onBrokenCallbacks=[];encodingLevel;limits;constructor(e,t,n){this.transport=e,this.options=n;let r=`string`;if(`encodingLevel`in e){let t=e.encodingLevel;if(t!==void 0){if(t!==`string`&&t!==`jsonCompatible`&&t!==`jsonCompatibleWithBytes`&&t!==`structuredClonable`)throw TypeError(`Unknown transport encodingLevel: ${String(t)}`);r=t}}this.encodingLevel=r,this.limits={...Fn,...n.limits},this.exports.push({hook:t,refcount:1}),this.imports.push(new tr(this,0,!1)),this.readLoop().catch(e=>this.abort(e))}getMainImport(){return new rr(this.imports[0])}shutdown(){this.abort(Error(`RPC session was shut down by disposing the main stub`),!1)}exportStub(e){if(this.abortReason)throw this.abortReason;let t=this.reverseExports.get(e);if(t!==void 0)return++this.exports[t].refcount,t;{let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.watchExport(t,e),t}}exportPromise(e){if(this.abortReason)throw this.abortReason;let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.ensureResolvingExport(t),t}unexport(e){for(let t of e)this.releaseExport(t,1)}watchExport(e,t){t.onBroken(n=>{queueMicrotask(()=>{if(this.abortReason===void 0&&this.exports[e]?.hook===t)try{this.send([`reject`,e,q.devaluate(n,void 0,this,void 0,this.encodingLevel)])}catch(e){this.abort(e)}})})}releaseExport(e,t){let n=this.exports[e];if(!n)throw Error(`no such export ID: ${e}`);if(n.refcount<t)throw Error(`refcount would go negative: ${n.refcount} < ${t}`);n.refcount-=t,n.refcount===0&&(delete this.exports[e],this.reverseExports.delete(n.hook),n.hook.dispose())}onSendError(e){if(this.options.onSendError)return this.options.onSendError(e)}ensureResolvingExport(e){let t=this.exports[e];if(!t)throw Error(`no such export ID: ${e}`);if(!t.pull){let n=async()=>{let e=t.hook;for(;;){let t=await e.pull();if(t.value instanceof U){let{hook:n,pathIfPromise:r}=On(t.value);if(r&&r.length==0&&this.getImport(e)===void 0){e=n;continue}}return t}},r=t.autoRelease;++this.pullCount,t.pull=n().then(t=>{let n=q.devaluate(t.value,void 0,this,t,this.encodingLevel);this.send([`resolve`,e,n]),r&&this.releaseExport(e,1)},t=>{this.send([`reject`,e,q.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}).catch(t=>{try{this.send([`reject`,e,q.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}catch(e){this.abort(e)}}).finally(()=>{--this.pullCount===0&&this.onBatchDone&&this.onBatchDone.resolve()})}}getImport(e){if(e instanceof nr&&e.entry&&e.entry.session===this)return e.entry.importId}importStub(e){if(this.abortReason)throw this.abortReason;let t=this.imports[e];return t||(t=new tr(this,e,!1),this.imports[e]=t),new nr(!1,t)}importPromise(e){if(this.abortReason)throw this.abortReason;if(this.imports[e])return new V(Error(`Bug in RPC system: The peer sent a promise reusing an existing export ID.`));let t=new tr(this,e,!0);return this.imports[e]=t,new nr(!0,t)}getExport(e){return this.exports[e]?.hook}getPipeReadable(e){let t=this.exports[e];if(!t||!t.pipeReadable)throw Error(`Export ${e} is not a pipe or its readable end was already consumed.`);let n=t.pipeReadable;return t.pipeReadable=void 0,n}getLimits(){return this.limits}createPipe(e,t){if(this.abortReason)throw this.abortReason;this.send([`pipe`]);let n=this.imports.length,r=new tr(this,n,!1);this.imports.push(r);let i=new nr(!1,r),a=B.createWritableStreamFromHook(i);return e.pipeTo(a).catch(()=>{}).finally(()=>t.dispose()),n}send(e){if(this.abortReason!==void 0)return 0;if(this.encodingLevel===`string`){let t;try{t=JSON.stringify(e)}catch(e){try{this.abort(e)}catch{}throw e}try{let e=this.transport.send(t);e!==void 0&&typeof e.catch==`function`&&e.catch(e=>this.abort(e,!1))}catch(e){queueMicrotask(()=>this.abort(e,!1))}return t.length}try{let t=this.transport.send(e);if(typeof t==`number`)return t;let n=t;n&&typeof n.then==`function`&&Promise.resolve(n).catch(e=>this.abort(e,!1));return}catch(e){queueMicrotask(()=>this.abort(e,!1));return}}sendCall(e,t,n){if(this.abortReason)throw n?.dispose(),this.abortReason;let r=[`pipeline`,e,t];if(n){let e;try{e=q.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(e[0])}this.send([`push`,r]);let i=new tr(this,this.imports.length,!1);return this.imports.push(i),new nr(!0,i)}sendStream(e,t,n){if(this.abortReason)throw n.dispose(),this.abortReason;let r=[`pipeline`,e,t],i;try{i=q.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(i[0]);let a=[`stream`,r],o=this.send(a);o===void 0&&(o=er(a));let s=this.imports.length,c=new tr(this,s,!0);return c.remoteRefcount=0,c.localRefcount=1,this.imports.push(c),{promise:c.awaitResolution().then(e=>{e.dispose(),delete this.imports[s]},e=>{throw delete this.imports[s],e}),size:o}}sendMap(e,t,n,r){if(this.abortReason){for(let e of n)e.dispose();throw this.abortReason}let i=[`remap`,e,t,n.map(e=>{let t=this.getImport(e);return t===void 0?[`export`,this.exportStub(e)]:[`import`,t]}),r];this.send([`push`,i]);let a=new tr(this,this.imports.length,!1);return this.imports.push(a),new nr(!0,a)}sendPull(e){if(this.abortReason)throw this.abortReason;this.send([`pull`,e])}sendRelease(e,t){this.abortReason||(this.send([`release`,e,t]),delete this.imports[e])}abort(e,t=!0){if(this.abortReason===void 0){if(this.cancelReadLoop?.(e),this.cancelReadLoop=void 0,t)try{let t=[`abort`,q.devaluate(e,void 0,this,void 0,this.encodingLevel)];if(this.encodingLevel===`string`){let e=this.transport.send(JSON.stringify(t));e!==void 0&&typeof e.catch==`function`&&e.catch(e=>{})}else{let e=this.transport.send(t);e&&typeof e.then==`function`&&Promise.resolve(e).catch(e=>{})}}catch{}if(e===void 0&&(e=`undefined`),this.abortReason=e,this.onBatchDone&&this.onBatchDone.reject(e),this.transport.abort)try{this.transport.abort(e)}catch(e){Promise.resolve(e)}for(let t of Object.values(this.onBrokenCallbacks))try{t(e)}catch(e){Promise.resolve(e)}for(let t in this.imports)this.imports[t].abort(e);for(let e in this.exports)this.exports[e].hook.dispose()}}async readLoop(){for(;!this.abortReason;){let e=Promise.withResolvers();this.cancelReadLoop=e.reject;let t;try{t=await Promise.race([this.transport.receive(),e.promise])}finally{this.cancelReadLoop===e.reject&&(this.cancelReadLoop=void 0)}if(this.encodingLevel===`string`&&t.length>this.limits.maxMessageSize)throw TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);if(this.abortReason)break;let n=this.encodingLevel===`string`?JSON.parse(t):t;if(n instanceof Array)switch(n[0]){case`push`:if(n.length>1){let e=new K(new Jn(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections(),this.exports.push({hook:e,refcount:1});continue}break;case`stream`:if(n.length>1){let e=new K(new Jn(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections();let t=this.exports.length;this.exports.push({hook:e,refcount:1,autoRelease:!0}),this.ensureResolvingExport(t);continue}break;case`pipe`:{let{readable:e,writable:t}=new TransformStream,n=B.createWritableStreamHook(t),r=this.exports.length;this.exports.push({hook:n,refcount:1,pipeReadable:e}),this.watchExport(r,n);continue}case`pull`:{let e=n[1];if(typeof e==`number`){this.ensureResolvingExport(e);continue}break}case`resolve`:case`reject`:{let e=n[1];if(typeof e==`number`&&n.length>2){let t=this.imports[e];if(t){if(n[0]==`resolve`)t.resolve(new K(new Jn(this,this.encodingLevel).evaluate(n[2])));else{let e=new Jn(this,this.encodingLevel).evaluate(n[2]);e.dispose(),t.resolve(new V(e.value))}}else n[0]==`resolve`&&new Jn(this,this.encodingLevel).evaluate(n[2]).dispose();continue}break}case`release`:{let e=n[1],t=n[2];if(typeof e==`number`&&typeof t==`number`){this.releaseExport(e,t);continue}break}case`abort`:{let e=new Jn(this,this.encodingLevel).evaluate(n[1]);e.dispose(),this.abort(e.value,!1);break}}throw Error(`bad RPC message: ${JSON.stringify(n)}`)}}async drain(){if(this.abortReason)throw this.abortReason;if(this.pullCount>0){let{promise:e,resolve:t,reject:n}=Promise.withResolvers();this.onBatchDone={resolve:t,reject:n},await e}}getStats(){let e={imports:0,exports:0};for(let t in this.imports)++e.imports;for(let t in this.exports)++e.exports;return e}},ar=class{#e;#t;constructor(e,t,n={}){let r;r=t?new K(G.fromAppReturn(t)):new V(Error(`This connection has no main object.`)),this.#e=new ir(e,r,n),this.#t=new U(this.#e.getMainImport())}getRemoteMain(){return this.#t}getStats(){return this.#e.getStats()}drain(){return this.#e.drain()}};function or(e,t,n){return new ar(new sr(e),t,n).getRemoteMain()}var sr=class{encodingLevel=`structuredClonable`;constructor(e){this.#e=e,e.start(),e.addEventListener(`message`,e=>{this.#i||(e.data===null?this.#a(Error(`Peer closed MessagePort connection.`)):this.#t?(this.#t(e.data),this.#t=void 0,this.#n=void 0):this.#r.push(e.data))}),e.addEventListener(`messageerror`,e=>{this.#a(Error(`MessagePort message error.`))})}#e;#t;#n;#r=[];#i;send(e){if(this.#i)throw this.#i;this.#e.postMessage(e)}async receive(){if(this.#r.length>0)return this.#r.shift();if(this.#i)throw this.#i;return new Promise((e,t)=>{this.#t=e,this.#n=t})}abort(e){try{this.#e.postMessage(null)}catch{}this.#e.close(),this.#i||=e}#a(e){this.#i||(this.#i=e,this.#n&&=(this.#n(e),this.#t=void 0,void 0))}},cr,lr=class{context;captureMap=new Map;instructions=[];constructor(e,t){this.context=cr?{parent:cr,captures:[],subject:cr.capture(e),path:t}:{parent:void 0,captures:[],subject:e,path:t},cr=this}unregister(){cr=this.context.parent}makeInput(){return new dr(this,0)}makeOutput(e){let t;try{t=q.devaluate(e.value,void 0,this,e)}finally{e.dispose()}return this.instructions.push(t),this.context.parent?(this.context.parent.instructions.push([`remap`,this.context.subject,this.context.path,this.context.captures.map(e=>[`import`,e]),this.instructions]),new dr(this.context.parent,this.context.parent.instructions.length)):this.context.subject.map(this.context.path,this.context.captures,this.instructions)}pushCall(e,t,n){let r=q.devaluate(n.value,void 0,this,n);r=r[0];let i=this.capture(e.dup());return this.instructions.push([`pipeline`,i,t,r]),new dr(this,this.instructions.length)}pushGet(e,t){let n=this.capture(e.dup());return this.instructions.push([`pipeline`,n,t]),new dr(this,this.instructions.length)}capture(e){if(e instanceof dr&&e.mapper===this)return e.idx;let t=this.captureMap.get(e);if(t===void 0){if(this.context.parent){let t=this.context.parent.capture(e);this.context.captures.push(t)}else this.context.captures.push(e);t=-this.context.captures.length,this.captureMap.set(e,t)}return t}exportStub(e){throw Error(`Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.`)}exportPromise(e){return this.exportStub(e)}getImport(e){return this.capture(e)}unexport(e){}createPipe(e){throw Error(`Cannot send ReadableStream inside a mapper function.`)}onSendError(e){}};_n.sendMap=(e,t,n)=>{let r=new lr(e,t),i;try{i=G.fromAppReturn(Sn(r.pushCall.bind(r),()=>n(new W(r.makeInput(),[]))))}finally{r.unregister()}if(i instanceof Promise)throw i.catch(e=>{}),Error(`RPC map() callbacks cannot be async.`);return new W(r.makeOutput(i),[])};function ur(){throw Error(`Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.`)}var dr=class extends yn{mapper;idx;constructor(e,t){super(),this.mapper=e,this.idx=t}dup(){return this}dispose(){}get(e){if(e.length==0)return this;if(cr)return cr.pushGet(this,e);ur()}call(e,t){t.dispose(),ur()}map(e,t,n){for(let e of t)e.dispose();ur()}pull(){ur()}ignoreUnhandledRejections(){}onBroken(e){ur()}},fr=class{captures;variables;constructor(e,t){this.captures=e,this.variables=[t]}dispose(){for(let e of this.variables)e.dispose()}apply(e){try{if(e.length<1)throw Error(`Invalid empty mapper function.`);for(let t of e.slice(0,-1)){let e=new Jn(this).evaluateCopy(t);if(e.value instanceof U){let t=En(e.value);if(t){this.variables.push(t);continue}}this.variables.push(new K(e))}return new Jn(this).evaluateCopy(e[e.length-1])}finally{for(let e of this.variables)e.dispose()}}importStub(e){throw Error(`A mapper function cannot refer to exports.`)}importPromise(e){return this.importStub(e)}getExport(e){return e<0?this.captures[-e-1]:this.variables[e]}getPipeReadable(e){throw Error(`A mapper function cannot use pipe readables.`)}getLimits(){return Fn}};function pr(e,t,n,r,i){let a=new fr(r,new K(G.deepCopyFrom(e,t,n)));try{return a.apply(i)}finally{a.dispose()}}_n.applyMap=(e,t,n,r,i)=>{try{let a;if(e instanceof W)throw Error(`applyMap() can't be called on RpcPromise`);if(e instanceof Array){let t=[];try{for(let a of e)t.push(pr(a,e,n,r,i))}catch(e){for(let e of t)e.dispose();throw e}a=G.fromArray(t)}else a=e==null?G.fromAppReturn(e):pr(e,t,n,r,i);return new K(a)}finally{for(let e of r)e.dispose()}};var mr=class e extends yn{state;static create(t){let n=t.getWriter();return new e({refcount:1,writer:n,closed:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}getState(){if(this.state)return this.state;throw Error(`Attempted to use a WritableStreamStubHook after it was disposed.`)}call(e,t){try{let n=this.getState();if(e.length!==1||typeof e[0]!=`string`)throw Error(`WritableStream stub only supports direct method calls`);let r=e[0];if(r!==`write`&&r!==`close`&&r!==`abort`)throw Error(`Unknown WritableStream method: ${r}`);return(r===`close`||r===`abort`)&&(n.closed=!0),new Pn((r===`write`?t.deliverStreamWrite(n.writer):t.deliverCall(n.writer[r],n.writer)).then(e=>new K(e)))}catch(e){return t.dispose(),new V(e)}}map(e,t,n){for(let e of t)e.dispose();return new V(Error(`Cannot use map() on a WritableStream`))}get(e){return new V(Error(`Cannot access properties on a WritableStream stub`))}dup(){let t=this.getState();return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a WritableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.closed||e.writer.abort(Error(`WritableStream RPC stub was disposed without calling close()`)).catch(()=>{}),e.writer.releaseLock())}onBroken(e){this.getState().writer.closed.then(void 0,e)}},hr=262144,gr=1073741824,_r=65536,vr=2,yr=1.25,br=.9,xr=3,Sr=class{now;window=hr;bytesInFlight=0;inStartupPhase=!0;delivered=0;deliveredTime=0;firstAckTime=0;firstAckDelivered=0;minRtt=1/0;roundsWithoutIncrease=0;lastRoundWindow=0;roundStartTime=0;constructor(e){this.now=e}onSend(e){this.bytesInFlight+=e;let t={sentTime:this.now(),size:e,deliveredAtSend:this.delivered,deliveredTimeAtSend:this.deliveredTime,windowAtSend:this.window,windowFullAtSend:this.bytesInFlight>=this.window};return{token:t,shouldBlock:t.windowFullAtSend}}onError(e){this.bytesInFlight-=e.size}onAck(e){let t=this.now();this.delivered+=e.size,this.deliveredTime=t,this.bytesInFlight-=e.size;let n=t-e.sentTime;if(this.minRtt=Math.min(this.minRtt,n),this.firstAckTime===0)this.firstAckTime=t,this.firstAckDelivered=this.delivered;else{let n,r;e.deliveredTimeAtSend===0?(n=this.firstAckTime,r=this.firstAckDelivered):(n=e.deliveredTimeAtSend,r=e.deliveredAtSend);let i=t-n,a=(this.delivered-r)/i,o=this.inStartupPhase?vr:yr,s=a*this.minRtt*o;s=Math.min(s,e.windowAtSend*o),s=e.windowFullAtSend?Math.max(s,e.windowAtSend*br):Math.max(s,this.window),this.window=Math.max(Math.min(s,gr),_r),this.inStartupPhase&&e.sentTime>=this.roundStartTime&&(this.window>this.lastRoundWindow*yr?this.roundsWithoutIncrease=0:++this.roundsWithoutIncrease>=xr&&(this.inStartupPhase=!1),this.roundStartTime=t,this.lastRoundWindow=this.window)}return this.bytesInFlight<this.window}};function Cr(e){let t,n=!1,r=new Sr(()=>performance.now()),i,a,o=()=>{n||(n=!0,e.dispose())};return new WritableStream({start(n){e.onBroken(e=>{t===void 0&&(t=e,n.error(e),o()),a&&=(a(e),i=void 0,void 0)})},write(n,s){if(t!==void 0)throw t;let c=G.fromAppParams([n]),{promise:l,size:u}=e.stream([`write`],c);if(u===void 0)return l.catch(e=>{throw t===void 0&&(t=e),e});{let{token:e,shouldBlock:n}=r.onSend(u);if(l.then(()=>{r.onAck(e)&&i&&(i(),i=void 0,a=void 0)},n=>{r.onError(e),t===void 0&&(t=n,s.error(n),o()),a&&=(a(n),i=void 0,void 0)}),n)return new Promise((e,t)=>{i=e,a=t})}},async close(){if(t!==void 0)throw o(),t;let{promise:n}=e.stream([`close`],G.fromAppParams([]));try{await n}catch(e){throw t??e}finally{o()}},abort(n){if(t!==void 0)return;t=n??Error(`WritableStream was aborted`),a&&=(a(t),i=void 0,void 0);let{promise:r}=e.stream([`abort`],G.fromAppParams([n]));r.then(()=>o(),()=>o())}})}var wr=class e extends yn{state;static create(t){return new e({refcount:1,stream:t,canceled:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}call(e,t){return t.dispose(),new V(Error(`Cannot call methods on a ReadableStream stub`))}map(e,t,n){for(let e of t)e.dispose();return new V(Error(`Cannot use map() on a ReadableStream`))}get(e){return new V(Error(`Cannot access properties on a ReadableStream stub`))}dup(){let t=this.state;if(!t)throw Error(`Attempted to dup a ReadableStreamStubHook after it was disposed.`);return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a ReadableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.canceled||(e.canceled=!0,e.stream.locked||e.stream.cancel(Error(`ReadableStream RPC stub was disposed without being consumed`)).catch(()=>{})))}onBroken(e){}};B.createWritableStreamHook=mr.create,B.createWritableStreamFromHook=Cr,B.createReadableStreamHook=wr.create;var Tr=U,Er=fn,Dr=or;function Or(e){return e<32||e>=127&&e<=159||e===1564||e>=8203&&e<=8207||e===8232||e===8233||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function kr(e,t=80){let n=``;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);n+=Or(r)?` `:e.charAt(t)}return n=n.replace(/\s+/gu,` `).trim(),n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ar(e,t){let n=e.find(e=>e.id===t.itemId);if(n===void 0||n.kind===`text`)return!1;if(n.kind===`menu`){let e=n.options.find(e=>e.id===t.optionId);return e!==void 0&&e.disabled!==!0}return t.optionId===void 0?n.kind!==`button`||n.disabled!==!0:!1}Object.freeze({publish:()=>Promise.resolve(),onBack:()=>()=>void 0,onForward:()=>()=>void 0,onActivate:()=>()=>void 0});function jr(e,t){if(t.kind===`action`){let n=[...e.primary??[],...e.menu??[]].find(e=>e.id===t.actionId);return n!==void 0&&n.disabled!==!0}let n=e.crumbs?.find(e=>e.id===t.crumbId);return n===void 0?!1:t.siblingId===void 0||n.siblings?.some(e=>e.id===t.siblingId)===!0}var Mr=[2,3],Nr=`fungi.app.ready.v3`,Pr=`fungi.app.ready`,Fr=`fungi.app.connect`,J=e=>s.pipe(b(de(1)),b(E(e))),Ir=e=>C(J(e)),Lr=p.pipe(b(A()),b(j(Number.isSafeInteger,{message:`Expected a safe integer`}))),Rr=Lr.pipe(b(Ce(0))),zr=Lr.pipe(b(pe(0))),Br=d({appId:J(160),releaseId:J(160),surfaceId:J(160)}),Vr=d({editing:_,surface:y([J(160),ge])}),Hr=y([d({kind:m(`compose`),requestId:J(160),text:J(2e3)}),d({kind:m(`navigate`),requestId:J(160),params:M(d({key:J(64),value:J(4096)})).pipe(b(E(16)))})]),Y=k(D([`granted`,`missing`])),Ur=d({"agent.list":Y,"agent.manage":Y,"agent.read":Y,"agent.send":Y,"computer.list":Y,"computer.readFile":Y,"computer.writeFile":Y,"computer.execute":Y,"git.repository":Y,"workflow.publish":Y,"workflow.arm":Y,"workflow.run":Y,"app.events.emit":Y,"llm.generation":Y,"media.generation":Y,"media.share":Y}),Wr=D([`ready`,`missing`,`unknown`]),Gr=d({models:Wr,media:Wr,git:Wr,terminal:D([`ready`,`exec-only`,`missing`,`unknown`]),terminalReason:C(s)}),Kr=D([`model`,`media`,`git`,`computer`]),qr=D([`opened`,`unavailable`]),Jr=d({computerId:y([J(256),ge]),computerName:C(re(s)),teamHasComputers:C(re(_)),computerAccessGranted:C(_),setup:C(Gr),permissions:C(Ur),focus:Vr,openRequest:y([ge,Hr]),visibility:D([`visible`,`hidden`])}),Yr=D([`connecting`,`connected`,`suspended`,`disconnected`,`disposing`,`disposed`]),Xr=d({altKey:_,ctrlKey:_,id:J(160),key:J(64),metaKey:_,shiftKey:_}),Zr=d({action:C(l),availability:C(l),category:J(160),description:Ir(512),id:J(160),projections:C(l),title:J(160)}),Qr=d({arguments:C(l),commandId:J(321),origin:D([`agent`,`browser`,`keyboard`,`menu`,`palette`,`programmatic`,`slash`,`terminal`]),requestId:J(160)}),$r=y([d({result:C(l),status:m(`handled`)}),d({error:l,status:m(`failed`)})]),ei=e=>J(e).pipe(b(j(e=>{for(let t=0;t<e.length;t+=1)if(Or(e.charCodeAt(t)))return!1;return!0},{message:`Expected one line of plain text`}))),ti={id:J(64),text:ei(80),end:k(_),priority:k(m(`low`))},ni=k(p.pipe(b(A()),b(ae({minimum:0,maximum:9999})))),ri=M(y([d({...ti,kind:m(`text`),tone:k(D([`neutral`,`success`,`warning`,`error`]))}),d({...ti,kind:m(`button`),icon:k(D([`folder`,`ports`,`processes`,`access`])),count:ni,tone:k(D([`neutral`,`success`,`warning`,`error`])),busy:k(_),title:k(ei(1024)),disabled:k(_),opens:k(m(`dialog`)),expanded:k(_)}),d({...ti,kind:m(`toggle`),pressed:_}),d({...ti,kind:m(`menu`),count:ni,title:k(ei(1024)),options:M(d({id:J(64),text:ei(80),checked:k(_),disabled:k(_)})).pipe(b(E(16)),b(j(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status option ids`})))})])).pipe(b(E(6)),b(j(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status item ids`}))),ii=d({computerId:J(256),path:J(1024)}),ai=J(80).pipe(b(j(e=>e.trim()===e,{message:`Expected a trimmed title`}))),oi=J(64),si=J(80),ci=e=>new Set(e.map(e=>e.id)).size===e.length,li=d({id:oi,label:si,siblings:C(M(d({id:oi,label:si})).pipe(b(E(16)),b(j(ci,{message:`Expected unique crumb sibling ids`}))))}),ui=d({id:oi,label:si,icon:C(m(`play`)),variant:C(D([`primary`,`outline`,`ghost`])),tone:C(m(`destructive`)),disabled:C(_)}),di=e=>M(ui).pipe(b(E(e)),b(j(ci,{message:`Expected unique header command ids`}))),fi=d({id:oi,label:si,presentation:C(m(`bead`)),tone:C(D([`neutral`,`info`,`warning`,`success`,`error`]))}),pi={status:C(M(fi).pipe(b(E(4)),b(j(ci,{message:`Expected unique header status ids`})))),crumbs:C(M(li).pipe(b(E(8)),b(j(ci,{message:`Expected unique crumb ids`})))),primary:C(di(3)),menu:C(di(12))},mi=d({contractVersion:m(2),canGoBack:_,canGoForward:_,title:C(ai),...pi}),hi=d({canGoBack:_,canGoForward:_,title:C(s),...pi}),gi=y([d({kind:m(`crumb`),crumbId:oi,siblingId:C(oi)}),d({kind:m(`action`),actionId:oi})]),_i=re(d({agentId:J(256),sessionId:J(256)})),vi=e=>C(M(D(e)).pipe(b(E(e.length)))),yi=d({agents:C(M(D([`agent.list`,`agent.manage`,`agent.read`,`agent.send`])).pipe(b(E(4)))),computers:C(M(D([`computer.list`,`computer.readFile`,`computer.writeFile`,`computer.execute`])).pipe(b(E(4)))),git:vi([`git.repository`]),workflows:vi([`workflow.publish`,`workflow.arm`,`workflow.run`]),events:vi([`app.events.emit`]),generation:vi([`llm.generation`,`media.generation`,`media.share`])}),bi=D([`granted`,`declined`,`customize`]),xi=d({message:J(512),tone:C(D([`info`,`success`,`warning`,`error`]))}),Si=D(ot);d({code:Si.pick([`DELIVERY_PENDING`])});var Ci=d({code:Si,message:J(512),retryable:_,need:k(rt)}),wi=y([d({protocolVersion:m(3),type:m(Nr)}),d({protocolVersion:m(2),type:m(Pr)})]),Ti=d({epoch:J(160),protocolVersion:D(Mr),type:m(Fr)}),Ei=d({epoch:J(160),protocolVersion:D(Mr)}),Di={[Symbol.dispose]:C(l)},Oi=y([d({...Di,ok:m(!0),value:l}),d({...Di,error:Ci,ok:m(!1)})]);function X(e,t,n=`PROTOCOL`){return xe(be(e,{onExcessProperty:`error`}),ie({onFailure:e=>{throw new z(`The peer sent malformed protocol data`,{cause:e,code:n,retryable:!1})},onSuccess:t}))}function Z(e){return Object.freeze(e)}function ki(e,t){let n=e.arguments===void 0?void 0:Me(e.arguments),r={origin:e.origin,signal:t};return n!==void 0&&Object.assign(r,{arguments:n}),Z(r)}var Ai=X(Zr,e=>{let t={category:e.category,id:e.id,title:e.title};return e.action!==void 0&&Object.assign(t,{action:e.action}),e.availability!==void 0&&Object.assign(t,{availability:e.availability}),e.description!==void 0&&Object.assign(t,{description:e.description}),e.projections!==void 0&&Object.assign(t,{projections:e.projections}),Z(xa(()=>Ue(t)))},`INVALID_ARGUMENT`),ji=X(J(321),e=>e),Mi=X(Qr,e=>{let t=e.arguments===void 0?void 0:Me(e.arguments),n={commandId:e.commandId,origin:e.origin,requestId:e.requestId};return t!==void 0&&Object.assign(n,{arguments:t}),Z(n)}),Ni=X(y([De,l]),e=>e===void 0?void 0:Me(e)),Pi=X(Ti,e=>Z(e));X(Ei,e=>Z(e));var Fi=X(Jr,e=>{let t={computerId:e.computerId,focus:Z({...e.focus}),openRequest:e.openRequest===null?null:Z({...e.openRequest}),visibility:e.visibility};return e.teamHasComputers!==void 0&&(t.teamHasComputers=e.teamHasComputers),e.computerName!==void 0&&(t.computerName=e.computerName),e.computerAccessGranted!==void 0&&(t.computerAccessGranted=e.computerAccessGranted),e.setup!==void 0&&(t.setup=Z({...e.setup})),e.permissions!==void 0&&(t.permissions=Z({...e.permissions})),Z(t)}),Ii=X(Ci,e=>Z({...e})),Li=X(Vr,e=>Z({...e}),`INVALID_ARGUMENT`),Ri=X(Br,e=>Z({...e})),zi=X(Yr,e=>e),Bi=X(ri,e=>Z(e.map(e=>e.kind===`menu`?Z({...e,options:Z(e.options.map(e=>Z(e)))}):Z(e))),`INVALID_ARGUMENT`),Vi=X(d({itemId:J(64),optionId:k(J(64)),anchor:k(d({start:p.pipe(b(ae({minimum:0,maximum:1e5}))),width:p.pipe(b(ae({minimum:0,maximum:1e5})))}))}),e=>Z(e.anchor===void 0?{...e}:{...e,anchor:Z({...e.anchor})}),`INVALID_ARGUMENT`),Hi=X(ii,e=>Z({...e}),`INVALID_ARGUMENT`);function Ui(e){let t={id:e.id,label:e.label};return e.presentation!==void 0&&(t={...t,presentation:e.presentation}),e.tone!==void 0&&(t={...t,tone:e.tone}),Z(t)}function Wi(e){let t={id:e.id,label:e.label};return e.siblings===void 0?Z(t):Z({...t,siblings:Z(e.siblings.map(e=>Z({...e})))})}function Gi(e){let t={id:e.id,label:e.label};return e.icon!==void 0&&(t={...t,icon:e.icon}),e.variant!==void 0&&(t={...t,variant:e.variant}),e.tone!==void 0&&(t={...t,tone:e.tone}),e.disabled!==void 0&&(t={...t,disabled:e.disabled}),Z(t)}function Ki(e){let t={canGoBack:e.canGoBack,canGoForward:e.canGoForward};return e.title!==void 0&&(t={...t,title:e.title}),e.crumbs!==void 0&&(t={...t,crumbs:Z(e.crumbs.map(Wi))}),e.primary!==void 0&&(t={...t,primary:Z(e.primary.map(Gi))}),e.menu!==void 0&&(t={...t,menu:Z(e.menu.map(Gi))}),e.status!==void 0&&(t={...t,status:Z(e.status.map(Ui))}),Z(t)}var qi=X(mi,Ki,`INVALID_ARGUMENT`),Ji=X(hi,e=>{let t=e.title?.trim();return Yi({...Ki({...e,title:t===void 0||t.length===0?void 0:t}),contractVersion:2})},`INVALID_ARGUMENT`),Yi=X(mi,e=>Z({...Ki(e),contractVersion:2}),`INVALID_ARGUMENT`),Xi=X(gi,e=>e.kind===`action`?Z({...e}):Z(e.siblingId===void 0?{kind:e.kind,crumbId:e.crumbId}:e),`INVALID_ARGUMENT`),Zi=X(_i,e=>e===null?null:Z({...e}),`INVALID_ARGUMENT`),Qi=X(yi,e=>Z({agents:Z([...new Set(e.agents??[])]),computers:Z([...new Set(e.computers??[])]),...e.git&&{git:Z([...new Set(e.git)])},...e.workflows&&{workflows:Z([...new Set(e.workflows)])},...e.events&&{events:Z([...new Set(e.events)])},...e.generation&&{generation:Z([...new Set(e.generation)])}}),`INVALID_ARGUMENT`),$i=X(Kr,e=>e,`INVALID_ARGUMENT`);X(wi,e=>Z(e));var ea=X(J(512),e=>e),ta=X(xi,e=>Z({...e}),`INVALID_ARGUMENT`);X(d({id:J(160),repeat:_}),e=>Z(e));var na=X(M(Xr).pipe(b(E(64))),e=>{if(new Set(e.map(e=>e.id)).size!==e.length)throw new z(`Reserved chords are invalid`,{code:`PROTOCOL`,retryable:!1});return Z(e.map(e=>Z({...e})))});function ra(e){return X(d({value:l,version:Rr}),t=>Z({value:e(t.value),version:t.version}))}var ia=ra(Fi),aa=X(d({capabilities:M(l).pipe(b(E(128))),context:l}),e=>Z({capabilities:Z(e.capabilities.map(e=>da(e))),context:ia(e.context)})),oa=ra(zi),sa=ra(na),ca=ra(ea),la=xe(oa,e=>{if(e.value!==`connected`&&e.value!==`suspended`)throw new z(`The host lifecycle is invalid`,{code:`PROTOCOL`,retryable:!1});return Z({value:e.value,version:e.version})});function ua(e){return X(d({handle:l,id:J(160),version:zr}),t=>{if(!(t.handle instanceof Tr)&&!(e&&t.handle instanceof Er))throw new z(`A capability handle is invalid`,{code:`PROTOCOL`,retryable:!1});return Z({handle:t.handle,id:t.id,version:t.version})})}var da=ua(!1),fa=ua(!0);function pa(e){let t=e?fa:da;return X(d({capabilities:M(l).pipe(b(E(128))),context:l,identity:l,lifecycle:l,reservedChords:l,theme:l}),e=>Z({capabilities:Z(e.capabilities.map(e=>t(e))),context:ia(e.context),identity:Ri(e.identity),lifecycle:la(e.lifecycle),reservedChords:sa(e.reservedChords),theme:ca(e.theme)}))}var ma=pa(!1);pa(!0);function ha(e){return X(Oi,t=>t.ok?Z({ok:!0,value:e(t.value)}):Z({ok:!1,error:Ii(t.error)}))}var ga=ha(ma),_a=ha(X(d({commandId:J(321)}),e=>Z(e)));ha(X($r,e=>{if(e.status===`failed`)return Z({status:`failed`,error:xa(()=>Ne(e.error))});let t=e.result===void 0?void 0:Me(e.result);return Z(t===void 0?{status:`handled`}:{status:`handled`,result:t})}));var va=ha(X(De,()=>void 0)),ya=ha(X(bi,e=>e)),ba=ha(X(qr,e=>e));ha(X(_,e=>e)),ha(X(_,e=>e));function xa(e){try{return e()}catch(e){throw new z(`The command metadata is invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}}var Sa=y([d({kind:m(`saveFile`),name:J(255).pipe(b(ye(/^[^\p{Cc}/\\]+$/u))),mime:J(255),bytes:oe}),d({kind:m(`copyText`),text:s})]);function Ca(e){let t=be(Sa,{onExcessProperty:`error`})(e);if(o(t))return{kind:`refused`,reason:`invalid-request`};let n=t.success;return n.kind===`saveFile`?n.name===`.`||n.name===`..`?{kind:`refused`,reason:`invalid-request`}:n.bytes.byteLength>33554432?{kind:`refused`,reason:`too-large`}:{...n,bytes:new Uint8Array(n.bytes)}:n.text.length>1048576||new TextEncoder().encode(n.text).byteLength>1048576?{kind:`refused`,reason:`too-large`}:n}var wa=ha(X(y([d({kind:m(`saved`)}),d({kind:m(`copied`)}),d({kind:m(`refused`),reason:D([`no-user-gesture`,`too-large`,`invalid-request`,`unavailable`,`denied`,`busy`])})]),e=>Z(e)));function Ta(e){let t=e,n=new Set;return{get:()=>t,subscribe(e){n.add(e);let t=!0;return()=>{t&&(t=!1,n.delete(e))}},update(e){if(!Object.is(t,e)){t=e;for(let e of Array.from(n))try{e(t)}catch(e){console.warn(`App store subscriber failed`,e)}}}}}function Ea(e){let t=new Map,n=Ta(0),r=!1,i=e=>{let t=new Map;try{for(let n of e){let e=da(n),r=ja(e.id,e.version);if(t.has(r))throw Oa(e.handle),new z(`Duplicate capability grant`,{code:`PROTOCOL`,retryable:!1});t.set(r,e.handle)}}catch(e){for(let e of t.values())Oa(e);throw e}return t};for(let[n,r]of i(e))t.set(n,r);let a=e=>{for(let t of e)Oa(t)},o=e=>{if(r)throw new z(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let n=ja(e.id,e.version);return t.get(n)};return{directory:Object.freeze({get version(){return n.get()},subscribe:e=>n.subscribe(e),has(e){return!!o(e)},require(e){let t=o(e);if(!t)throw new z(`The capability is not granted`,{code:`CAPABILITY_DENIED`,retryable:!1});try{return e.schema.parse(t)}catch(e){throw new z(`The capability interface is malformed`,{cause:e,code:`PROTOCOL`,retryable:!1})}}}),replace(e){if(r)throw new z(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let o=i(e),s=[...t.values()];t.clear();for(let[e,n]of o)t.set(e,n);a(s.filter(e=>![...o.values()].includes(e))),n.update(n.get()+1)},disconnect(){r||(r=!0,a(t.values()),t.clear(),n.update(n.get()+1))}}}var Da=a().transform(e=>{let t=O(Object).safeParse(e);if(!t.success)return;let n=Object.create(t.data),r=ee(d({[Symbol.dispose]:C(ue(Function))}))(n);return{owner:t.data,dispose:r[Symbol.dispose]}});function Oa(e){try{let t=Da.parse(e);if(t===void 0||Aa.has(t.owner))return;Aa.add(t.owner),t.dispose?.call(t.owner)}catch(e){console.warn(`RPC value disposal failed`,e)}}function ka(e){return{value:e,[Symbol.dispose](){Oa(e)}}}var Aa=new WeakSet;function ja(e,t){return`${e}@${String(t)}`}var Ma=class{id;version;#e;constructor(e,t,n){this.id=e,this.version=t,this.#e=n,Object.freeze(this)}get schema(){return this.#e}};function Na(e,t,n){return new Ma(e,t,n)}function Pa(e){let t=S(e),n=O(Object),r=S(Object.fromEntries(Object.keys(e).map(e=>[e,a().optional()])));return a().transform(e=>{let i=n.parse(e),a=Object.create(i),o=r.parse(a),s=Object.fromEntries(Object.entries(o).flatMap(([e,t])=>t===void 0?[]:[[e,fe().parse(t).bind(i)]]));return{...t.parse(s),[Symbol.dispose](){Oa(e)}}})}function Fa(e){return a().transform(t=>{try{return e.parse(t)}catch(e){throw e instanceof z?e:new z(`The capability returned malformed data`,{cause:e,code:`PROTOCOL`,retryable:!1})}finally{Oa(t)}})}function Ia(e){return fe({output:Te(a().transform(t=>{try{return e.parse(t)}catch(e){throw Oa(t),e instanceof z?e:new z(`The capability returned a malformed result`,{cause:e,code:`PROTOCOL`,retryable:!1})}}))})}var La=Ia(Fa(we()));Pa({fetch:Ia(O(Response)),close:La});var Ra=e(h(),1);function za(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 Ba=e=>{switch(e){case`success`:return Ua;case`info`:return Ga;case`warning`:return Wa;case`error`:return Ka;default:return null}},Va=Array(12).fill(0),Ha=({visible:e,className:t})=>P.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},P.createElement(`div`,{className:`sonner-spinner`},Va.map((e,t)=>P.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),Ua=P.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},P.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`})),Wa=P.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},P.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`})),Ga=P.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},P.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`})),Ka=P.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},P.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`})),qa=P.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`},P.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),P.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),Ja=()=>{let[e,t]=P.useState(document.hidden);return P.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},Ya=1,Xa=100,Za=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:Ya++,Q=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-Xa;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=Za(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],P.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if($a(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`&&!P.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`&&!P.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`&&!P.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`&&!P.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=Za(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}},Qa=(e,t)=>Q.message(e,t),$a=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,eo=Object.assign(Qa,{success:Q.success,info:Q.info,warning:Q.warning,error:Q.error,custom:Q.custom,message:Q.message,promise:Q.promise,dismiss:Q.dismiss,loading:Q.loading},{getHistory:()=>Q.toasts,getToasts:()=>Q.getActiveToasts()});za(`[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 to(e){return e.label!==void 0}var no=3,ro=`24px`,io=`16px`,ao=4e3,oo=356,so=14,co=45,lo=200;function $(...e){return e.filter(Boolean).join(` `)}function uo(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var fo=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:ee,closeButton:te,style:ne,cancelButtonStyle:re,actionButtonStyle:f,className:p=``,descriptionClassName:m=``,duration:ie,position:ae,gap:oe,expandByDefault:se,classNames:h,icons:g,closeButtonAriaLabel:_=`Close toast`}=e,[v,y]=P.useState(null),[ce,le]=P.useState(null),[b,ue]=P.useState(!1),[x,de]=P.useState(!1),[S,fe]=P.useState(!1),[C,w]=P.useState(!1),[pe,me]=P.useState(!1),[T,he]=P.useState(0),[E,ge]=P.useState(0),_e=P.useRef(n.duration||ie||ao),D=P.useRef(null),O=P.useRef(null),k=c===0,ve=c+1<=o,A=n.type,ye=A??`default`,be=n.dismissible!==!1,xe=n.className||``,Se=n.descriptionClassName||``,j=P.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),Ce=P.useMemo(()=>n.closeButton??te,[n.closeButton,te]),we=P.useMemo(()=>n.duration||ie||ao,[n.duration,ie]),M=P.useRef(0),N=P.useRef(0),Te=P.useRef(0),Ee=P.useRef(null),[De,Oe]=ae.split(`-`),ke=P.useMemo(()=>s.reduce((e,t,n)=>n>=j?e:e+t.height,0),[s,j]),Ae=Ja(),F=P.useMemo(()=>e.swipeDirections??uo(ae),[e.swipeDirections,ae]),je=n.invert||t,Me=A===`loading`;N.current=P.useMemo(()=>j*oe+ke,[j,ke]),P.useEffect(()=>{_e.current=we},[we]),P.useEffect(()=>{ue(!0)},[]),P.useEffect(()=>{let e=O.current;if(e){let t=e.getBoundingClientRect().height;return ge(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),P.useLayoutEffect(()=>{if(!b)return;let e=O.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ge(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])},[b,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let I=P.useCallback(()=>{de(!0),he(N.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},lo)},[n,d,a,N]);P.useEffect(()=>{if(n.promise&&A===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||Ae?(()=>{if(Te.current<M.current){let e=new Date().getTime()-M.current;_e.current-=e}Te.current=new Date().getTime()})():_e.current!==1/0&&(M.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),I()},_e.current)),()=>clearTimeout(e)},[u,i,n,A,Ae,I]),P.useEffect(()=>{n.delete&&(I(),n.onDismiss==null||n.onDismiss.call(n,n))},[I,n.delete]);function Ne(){return g?.loading?P.createElement(`div`,{className:$(h?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":A===`loading`},g.loading):P.createElement(Ha,{className:$(h?.loader,n?.classNames?.loader),visible:A===`loading`})}let Pe=n.icon||g?.[A]||Ba(A);return P.createElement(`li`,{tabIndex:0,ref:O,className:$(p,xe,h?.toast,n?.classNames?.toast,h?.[ye],n?.classNames?.[ye]),"data-sonner-toast":``,"data-rich-colors":n.richColors??ee,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":b,"data-promise":!!n.promise,"data-swiped":pe,"data-removed":x,"data-visible":ve,"data-y-position":De,"data-x-position":Oe,"data-index":c,"data-front":k,"data-swiping":S,"data-dismissible":be,"data-type":A,"data-invert":je,"data-swipe-out":C,"data-swipe-direction":ce,"data-expanded":!!(u||se&&b),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${x?T:N.current}px`,"--initial-height":se?`auto`:`${E}px`,...ne,...n.style},onDragEnd:()=>{fe(!1),y(null),Ee.current=null},onPointerDown:e=>{e.button!==2&&(Me||!be||(D.current=new Date,he(N.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(fe(!0),Ee.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(C||!be)return;Ee.current=null;let e=Number(O.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(O.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-D.current?.getTime(),i=v===`x`?e:t,a=Math.abs(i)/r;if((v===`x`?F.includes(e>0?`right`:`left`):F.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=co||a>.11)){he(N.current),n.onDismiss==null||n.onDismiss.call(n,n),le(v===`x`?e>0?`right`:`left`:t>0?`down`:`up`),I(),w(!0);return}var o,s;(o=O.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=O.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),me(!1),fe(!1),y(null)},onPointerMove:e=>{var t,n;if(!Ee.current||!be||window.getSelection()?.toString().length>0)return;let r=e.clientY-Ee.current.y,i=e.clientX-Ee.current.x;!v&&(Math.abs(i)>1||Math.abs(r)>1)&&y(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(v===`y`){if(F.includes(`top`)||F.includes(`bottom`)){if(F.includes(`top`)&&r<0||F.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(v===`x`&&(F.includes(`left`)||F.includes(`right`))){if(F.includes(`left`)&&i<0||F.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)&&me(!0),(t=O.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=O.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},Ce&&!n.jsx&&A!==`loading`?P.createElement(`button`,{"aria-label":_,"data-disabled":Me,"data-close-button":!0,onClick:Me||!be?()=>{}:()=>{I(),n.onDismiss==null||n.onDismiss.call(n,n)},className:$(h?.closeButton,n?.classNames?.closeButton)},g?.close??qa):null,(A||n.icon||n.promise)&&n.icon!==null&&(g?.[A]!==null||n.icon)?P.createElement(`div`,{"data-icon":``,className:$(h?.icon,n?.classNames?.icon)},A===`loading`?n.icon||Ne():n.promise?Ne():null,A===`loading`?null:Pe):null,P.createElement(`div`,{"data-content":``,className:$(h?.content,n?.classNames?.content)},P.createElement(`div`,{"data-title":``,className:$(h?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?P.createElement(`div`,{"data-description":``,className:$(m,Se,h?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),P.isValidElement(n.cancel)?n.cancel:n.cancel&&to(n.cancel)?P.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||re,onClick:e=>{to(n.cancel)&&be&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),I())},className:$(h?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,P.isValidElement(n.action)?n.action:n.action&&to(n.action)?P.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||f,onClick:e=>{to(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&I())},className:$(h?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function po(){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 mo(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?io:ro;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 ho=P.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:ee,duration:te,style:ne,visibleToasts:re=no,toastOptions:f,dir:p=po(),gap:m=so,icons:ie,customAriaLabel:ae,containerAriaLabel:oe=`Notifications`}=e,[se,h]=P.useState([]),g=P.useMemo(()=>n?se.filter(e=>e.toasterId===n):se.filter(e=>!e.toasterId),[se,n]),_=P.useMemo(()=>Array.from(new Set([i].concat(g.filter(e=>e.position).map(e=>e.position)))),[g,i]),[v,y]=P.useState([]),[ce,le]=P.useState(!1),[b,ue]=P.useState(!1),[x,de]=P.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),S=P.useRef(null),fe=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),C=P.useRef(null),w=P.useRef(!1),pe=P.useCallback(e=>{h(t=>(t.find(t=>t.id===e.id)?.delete||Q.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return P.useEffect(()=>Q.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{h(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{Ra.flushSync(()=>{h(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)]})})})}),[]),P.useEffect(()=>{if(d!==`system`){de(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?de(`dark`):de(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{de(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{de(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),P.useEffect(()=>{se.length<=1&&le(!1)},[se]),P.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;le(!0),(t=S.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===S.current||S.current?.contains(document.activeElement))&&le(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),P.useEffect(()=>{if(S.current)return()=>{C.current&&(C.current.focus({preventScroll:!0}),C.current=null,w.current=!1)}},[S.current]),P.createElement(`section`,{ref:t,"aria-label":ae??`${oe} ${fe}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},_.map((t,n)=>{let[i,a]=t.split(`-`);return g.length?P.createElement(`ol`,{key:t,dir:p===`auto`?po():p,tabIndex:-1,ref:S,className:c,"data-sonner-toaster":!0,"data-sonner-theme":x,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${v[0]?.height||0}px`,"--width":`${oo}px`,"--gap":`${m}px`,...ne,...mo(l,u)},onBlur:e=>{w.current&&!e.currentTarget.contains(e.relatedTarget)&&(w.current=!1,C.current&&=(C.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||w.current||(w.current=!0,C.current=e.relatedTarget)},onMouseEnter:()=>le(!0),onMouseMove:()=>le(!0),onMouseLeave:()=>{b||le(!1)},onDragEnd:()=>le(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||ue(!0)},onPointerUp:()=>ue(!1)},g.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>P.createElement(fo,{key:n.id,icons:ie,index:i,toast:n,defaultRichColors:ee,duration:f?.duration??te,className:f?.className,descriptionClassName:f?.descriptionClassName,invert:r,visibleToasts:re,closeButton:f?.closeButton??s,interacting:b,position:t,style:f?.style,unstyled:f?.unstyled,classNames:f?.classNames,cancelButtonStyle:f?.cancelButtonStyle,actionButtonStyle:f?.actionButtonStyle,closeButtonAriaLabel:f?.closeButtonAriaLabel,removeToast:pe,toasts:g.filter(e=>e.position==n.position),heights:v.filter(e=>e.position==n.position),setHeights:y,expandByDefault:o,gap:m,expanded:ce,swipeDirections:e.swipeDirections}))):null}))});export{cn as $,Xi as A,yt as At,Bi as B,Ii as C,Ft as Ct,Ri as D,Wt as Dt,aa as E,Kt as Et,_a as F,rt as Ft,Nr as G,ta as H,na as I,tt as It,Ar as J,Pr as K,$i as L,Ge as Lt,Ji as M,z as Mt,ya as N,ot as Nt,zi as O,Dt as Ot,Qi as P,ht as Pt,Dr as Q,ba as R,Ne as Rt,Fi as S,Vt as St,Li as T,It as Tt,va as U,ea as V,Fr as W,Tr as X,kr as Y,Er as Z,Ai as _,Et as _t,Ia as a,tn as at,Ni as b,wt as bt,Ea as c,Xt as ct,Ta as d,Ht as dt,ln as et,ki as f,Ut as ft,wa as g,jt as gt,Ca as h,Mt as ht,Pa as i,on as it,qi as j,vt as jt,Hi as k,xt as kt,Oa as l,Yt as lt,ga as m,Tt as mt,eo as n,an as nt,La as o,en as ot,Zi as p,Gt as pt,jr as q,Fa as r,rn as rt,Na as s,Zt as st,ho as t,sn as tt,ka as u,qt as ut,ji as v,At as vt,ra as w,Ot as wt,Pi as x,Nt as xt,Mi as y,kt as yt,Vi as z,Me as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,v as r,y as i}from"./button-oE2Hrd5D.js";import{l as a,u as o}from"./log-event-BfZxbz9a.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Cn as m,Ct as h,D as g,Dt as _,E as v,En as y,F as b,Ft as x,G as ee,Gt as S,H as C,Ht as w,I as T,It as E,J as te,K as ne,Kt as D,L as O,Lt as re,M as ie,Mt as ae,Nt as oe,On as k,Ot as A,Pt as se,Q as j,Qt as M,R as N,Rt as P,S as F,Sn as I,St as L,T as R,Tn as z,Tt as B,U as V,Ut as H,V as ce,Vt as U,W,Y as le,Z as ue,_ as G,_n as de,_t as K,a as fe,an as pe,at as me,b as he,bt as q,c as J,cn as ge,ct as _e,dn as ve,dt as ye,en as be,et as xe,f as Se,fn as Ce,ft as we,g as Te,gn as Y,gt as Ee,h as De,hn as Oe,ht as ke,i as Ae,in as X,it as je,j as Me,jt as Ne,k as Pe,kn as Fe,kt as Ie,l as Le,ln as Re,lt as ze,m as Be,mn as Ve,n as Z,nn as He,nt as Ue,o as We,on as Ge,p as Ke,pn as qe,pt as Je,q as Ye,r as Xe,rn as Ze,rt as Qe,s as $e,sn as et,t as tt,tn as nt,tt as rt,un as it,ut as at,v as ot,vn as st,w as ct,wn as lt,wt as ut,x as dt,xn as ft,xt as pt,y as mt,yn as ht,z as gt,zt as _t}from"./useTriggerFocusGuards-Bddw7Qdn.js";function vt(e){return/\.mp4$/iu.test(e)}async function yt(e,t){if(vt(e.name)){let n=document.createElement(`video`);return n.preload=`metadata`,n.muted=!0,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP4 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,width:n.videoWidth,height:n.videoHeight}}if(o(e.name)){let n=new Audio;return n.preload=`metadata`,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP3 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,...a}}let n=new Image;return n.src=t,await n.decode(),{file:e,url:t,width:n.naturalWidth,height:n.naturalHeight}}var Q=e(n(),1),bt=ge&&et;function xt(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Q.useRef(!1),s=Q.useRef(null),c=Q.useRef(!0),l=ft();Q.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=it(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Ce(t)&&t===Ze(Ie(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return je(B(r,`blur`,i),bt&&B(r,`keydown`,a,!0),bt&&B(r,`pointerdown`,l,!0))},[e,n]),Q.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);ve(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Q.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=pe(n.nativeEvent);if(ve(a)){if(bt&&!n.relatedTarget){if(!c.current&&!w(a))return}else if(!H(a))return}let u=f(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:p}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,q(K,d,p));return}l.start(r,()=>{o.current||e.setOpen(!0,q(K,d,p))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=ve(r)&&r.hasAttribute(xe(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ze(Ie(t));!r&&n===t||X(a.current.floatingContext?.refs.floating.current,n)||X(t,n)||o||f(r??n,e.context.triggerElements)||e.setOpen(!1,q(K,i))})}}},[a,r,e,l]);return Q.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}function St(e){return et&&e.movementX===0&&e.movementY===0}function Ct(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function wt(e,t){return Ct(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Tt(e,t,n){return Ct(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Et(e,t,n){return Ct(t,n?e===be:e===nt,e===c)}function Dt(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Ct(t,n?e===nt:e===be,e===He)}function Ot(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:c=!1,loopFocus:l=!1,nested:d=!1,rtl:f=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:ee=!0,externalTree:S,nestedReturnFocusRef:C,grid:T}=t,te=T!=null,D=e.useState(`open`),O=e.useState(`floatingElement`),ie=e.useState(`domReferenceElement`),oe=e.context.dataRef,k=_t(O),j=U(ie),M=Qe(k),N=ne(),F=Ye(S),I=Q.useRef(m),L=Q.useRef(o??-1),R=Q.useRef(null),B=Q.useRef(!0),V=z(e=>{i(L.current===-1?null:L.current,e)}),H=Q.useRef(!!O),ce=Q.useRef(D),W=Q.useRef(!1),le=Q.useRef(!1),ue=Q.useRef(null),G=Qe(_),de=Qe(D),K=Qe(o),fe=Qe(ee),me=Ue(),he=Ue(),J=z(()=>{me.cancel();function e(e){p||(ue.current=s(e,{sync:W.current,preventScroll:!0}))}let t=n.current[L.current],r=le.current;t&&e(t),(W.current?e=>e():e=>me.request(e))(()=>{let i=n.current[L.current]||t;i&&(t||e(i),Se&&(r||!B.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});A(()=>{oe.current.orientation=v},[oe,v]),A(()=>{D||(R.current=null),(!D||m!==`auto`)&&(I.current=m)},[D,m]),A(()=>{a&&(D&&O?(L.current=o??-1,I.current&&o!=null&&(le.current=!0,V())):H.current&&(L.current=-1,V()))},[a,D,O,o,V]),A(()=>{if(a){if(!D){W.current=!1;return}if(O){if(r==null){if(W.current=!1,K.current!=null)return;if(H.current&&(L.current=-1,J()),(!ce.current||!H.current)&&I.current&&(R.current!=null||I.current===!0&&R.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>he.request(e):queueMicrotask)(t),e+=1):(L.current=R.current==null||Tt(R.current,y,f)||d?Ne(n):u(n),R.current=null,V())};t()}}else se(n.current,r)||(L.current=r,J(),le.current=!1)}}},[a,D,O,r,K,d,n,y,f,V,J,he]),A(()=>{if(!a||O||!F||p||!H.current)return;let e=F.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ze(Ie(ie??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&B.current&&t.focus({preventScroll:!0})},[a,O,ie,F,N,p]),A(()=>{ce.current=D,H.current=!!O});let ge=r!=null,ve=z(e=>{if(!de.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(L.current!==t||r!==t)&&(L.current=t,V(e))}),ye=z(()=>b??F?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),be=z(()=>Ne(n,G.current)),xe=z(t=>{if(B.current=!1,W.current=!0,t.which===229||!de.current&&t.currentTarget===M.current)return;if(d&&Dt(t.key,v,f,te)){wt(t.key,ye())||P(t),e.setOpen(!1,q(we,t.nativeEvent));let n=C?.current??ie;Ce(n)&&n.focus();return}r!=null&&r!==L.current&&!se(n.current,r)&&(L.current=r);let i=L.current,a=Ne(n,_),o=u(n,_);if(j||(t.key===`Home`&&(P(t),L.current=a,V(t)),t.key===`End`&&(P(t),L.current=o,V(t))),T!=null){let e=T(t,L.current,n,v,l,f,_,a,o);if(e!=null&&e!==L.current&&(L.current=e,V(t)),v===`both`)return}if(wt(t.key,v)){P(t);let e=Ze(t.currentTarget.ownerDocument);if(D&&!p&&X(t.currentTarget,e)&&!n.current.some(t=>t!=null&&X(t,e))){L.current=Tt(t.key,v,f)?a:o,V(t),r===L.current&&J();return}let{index:s,wrapped:u}=ae(n.current,i,{decrement:!Tt(t.key,v,f),loopFocus:l,allowEscape:c,disabledIndices:_,minIndex:a,maxIndex:o});u&&(W.current=!1),L.current=s,V(t)}}),Se=Q.useMemo(()=>({onFocus(e){W.current=!0,ve(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){St(e)||(W.current=!0,le.current=!1,h&&ve(e))},onPointerLeave(e){if(!de.current||!B.current||e.pointerType===`touch`)return;W.current=!0;let t=e.relatedTarget;if(!(!h||n.current.includes(t))&&fe.current&&(ue.current?.(),ue.current=null,L.current=-1,V(e),!p)){let e=M.current,t=Ze(Ie(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ve,de,M,h,n,V,fe,p]),Te=Q.useMemo(()=>p&&D&&ge&&{"aria-activedescendant":`${x}-${r}`},[p,D,ge,x,r]),Y=Q.useMemo(()=>({...j?{}:Te,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&D&&!p){let n=pe(t.nativeEvent);if(n&&!X(M.current,n))return;P(t);let r=q(_e,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??ie;!r.isCanceled&&Ce(i)&&i.focus();return}xe(t)},onPointerMove(e){St(e)||(B.current=!0)}}),[Te,xe,M,j,e,D,p,ie,C]),Ee=Q.useMemo(()=>{function t(t){e.setOpen(!0,q(we,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&E(e.nativeEvent)&&(I.current=!p)}function r(e){I.current=m,m===`auto`&&re(e.nativeEvent)&&(I.current=!0)}return{onKeyDown(n){let r=e.select(`open`);B.current=!1;let i=n.key.startsWith(`Arrow`),a=Et(n.key,ye(),f),o=wt(n.key,r?v:y),s=(d?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!d||w(n.currentTarget)))return xe(n);if(!(!r&&!g&&i)){if(s){let e=wt(n.key,ye());R.current=d&&e?null:n.key}if(d){a&&(P(n),r?(L.current=be(),V(n),p&&M.current?.focus()):t(n));return}o&&(K.current!=null&&(L.current=K.current),P(n),!r&&g?t(n):xe(n),r&&V(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(L.current=-1,V(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[xe,m,be,d,V,e,g,v,y,ye,f,K,p,M]),De=Q.useMemo(()=>({...Te,...Ee}),[Te,Ee]);return Q.useMemo(()=>a?{reference:De,floating:Y,item:Se,trigger:Ee}:{},[a,De,Y,Ee,Se])}function kt(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=ft(),m=Q.useRef(``),h=Q.useRef(u??i??-1),g=Q.useRef(null),_=z(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!oe(n)||n?.matches(`:disabled`)?!1:o==null||!x(I,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===` `&&(P(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!==` `&&(P(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`);X(r,n)||X(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});A(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Q.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Q.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}function At({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Q.useRef(e!==void 0),[a,o]=Q.useState(()=>t);return[i&&e!==void 0?e:a,Q.useCallback(e=>{i||o(e)},[])]}var $=t(),jt=Q.createContext(void 0);function Mt(e){let t=Q.useContext(jt);if(t===void 0&&!e)throw Error(ht(33));return t}var Nt=Q.createContext(void 0);function Pt(e){let t=Q.useContext(Nt);if(t===void 0&&!e)throw Error(ht(36));return t}var Ft=Q.createContext(void 0);function It(e=!0){let t=Q.useContext(Ft);if(t===void 0&&!e)throw Error(ht(25));return t}var Lt=Q.createContext(null);function Rt(e=`root`){let t=Q.useContext(Lt),n=Q.useContext(Nt);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var zt={visible:!0,ref:null};function Bt(){return zt}function Vt(e,t,n=`root`){let r=Rt(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Bt)({label:e.label,children:e.children,render:e.render}),a=st(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var Ht=Q.createContext(void 0);function Ut(){let e=Q.useContext(Ht);if(e===void 0)throw Error(ht(30));return e}function Wt(e){e.preventDefault()}function Gt(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Pt(),u=It(!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`),g=a.useState(`open`),_=u!==void 0,v=!f&&g&&n?0:-1;return Q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:v,"aria-selected":p,onMouseDown:f?Wt: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:at})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,_&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||_&&!ge&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!_||e.button===2)&&c.type===`regular-item`&&h(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,v,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,_,c.type,p,f])}var Kt={type:`regular-item`};function qt(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=Q.useRef(null),{getButtonProps:d,buttonRef:f}=L({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Gt({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Q.useCallback(e=>de(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=st(u,f);return Q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Jt=Q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Yt(){return Q.useContext(Jt)}function Xt(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Yt(),u=Q.useRef(-1),[d,f]=Q.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=Q.useRef(null),h=Q.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 A(()=>{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 Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},...M},en=Q.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}=Pt(),m=Xt({guess:!0,label:a}),h=Ve(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:ee}=qt({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:Kt}),S=Q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function C(e){let t=q(at,e.nativeEvent,void 0,{preventUnmountOnClose:lt});u?.(!l,t)}let w=Y(`div`,e,{state:S,stateAttributesMapping:$t,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:C},f,x],ref:[ee,t,m.ref]});return(0,$.jsx)(Ht.Provider,{value:S,children:w})}),tn=Q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=At({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Vt(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(en,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),nn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Ut(),c=Q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=N(s.checked);T({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}});let f={checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l};return Y(`span`,e,{state:f,ref:[t,c],stateAttributesMapping:$t,props:{"aria-hidden":!0,...o},enabled:a||u})}),rn=Q.createContext(void 0);function an(){let e=Q.useContext(rn);if(e===void 0)throw Error(ht(31));return e}var on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Q.useState(void 0),c=Y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,$.jsx)(rn.Provider,{value:s,children:c})}),sn=Q.forwardRef(function(e,t){let n=Rt()?.Group??on;return(0,$.jsx)(n,{...e,ref:t})}),cn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ve(a),c=an();return A(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),ln=Q.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}=Pt(),f=Xt({guess:!0,label:a}),p=Ve(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}=qt({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Kt});return Y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),un=Q.forwardRef(function(e,t){let n=Vt(e,t);return n.visible?(0,$.jsx)(ln,{...e,ref:n.ref}):null}),dn=Q.createContext(void 0);function fn(){return Q.useContext(dn)}function pn(e,t){let n=Oe(e.render);if(Q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function mn(e,t,n){let r=pn(e,t),i=r===t?void 0:r;return[r,Q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function hn(e,t,n){let r=Oe(e.render),i=Q.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 gn=Q.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}=Pt(),m=fn(),{side:h,align:g}=Mt(),_=$e(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),ee=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),E=l.useState(`parent`),te=l.useState(`lastOpenChangeReason`),ne=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),re=l.useState(`closeDelay`),ie=l.useState(`hoverEnabled`),ae=l.useState(`disabled`),oe=l.useState(`openMethod`),k=l.useState(`activeTriggerId`),A=l.useState(`listElement`),[se,j]=mn(e,u,d),M=hn(e,w,k),N=E.type===`menu`?m:void 0,P=E.type===`context-menu`,F=s??E.type!==`menu`;s===void 0&&A&&E.type!==`menu`&&(F=()=>l.state.activeIndex===null&&A),T({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Q.useEffect(()=>{function e(e){l.setOpen(!1,q(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),G(D,{enabled:ie&&!ae&&!P&&E.type!==`menubar`,closeDelay:re});let I=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:L,handleFocus:R}=(Q.useContext(Lt)?.useParentHandoff??vn)(l,E,v,f),z={transitionStatus:y,side:h,align:g,open:v,nested:E.type===`menu`,instant:ee},B=Y(`div`,e,{state:z,ref:[t,l.context.popupRef,I,j],stateAttributesMapping:S,props:[b,{id:se,...A?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":M},onKeyDown(e){N?.onPopupKeyDown?.(e),_&&Be.has(e.key)&&e.stopPropagation()},onFocus:R},We(y),c,{"data-rootownerid":ne}]}),V=E.type===void 0||P;(w||E.type===`menubar`&&te!==`outside-press`)&&(V=!0);let H=N?.getReturnElement??L;return(0,$.jsx)(C,{context:D,openInteractionType:oe,modal:P,disabled:!x,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:F,restoreFocus:!0,getInsideElements:E.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:E.type===`menubar`?void 0:O,previousFocusableElement:w,nextFocusableElement:E.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:B})}),_n={parentVirtualFocusRef:void 0,handleFocus:void 0};function vn(){return _n}var yn=Q.forwardRef(function(e,t){let n=Rt()?.Popup??gn;return(0,$.jsx)(n,{...e,ref:t})}),bn=Q.createContext(void 0);function xn(){let e=Q.useContext(bn);if(e===void 0)throw Error(ht(32));return e}var Sn=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Pt();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(bn.Provider,{value:n,children:(0,$.jsx)(le,{ref:t,...r,portalOwnerRole:o})})});function Cn(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=z(i),[,o]=Q.useState(0),s=y(Tn).current,c=y(wn).current,l=Q.useRef(0),u=Q.useRef(!0),d=Q.useRef(null),f=Q.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(!On(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&kn(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=Dn(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=z(()=>{let[e,t]=En(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))});A(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),A(()=>{u.current&&v()}),A(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=z(e=>(s.add(e),()=>{s.delete(e)})),x=Q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,$.jsx)(Jt.Provider,{value:x,children:t})}function wn(){return new Map}function Tn(){return new Set}function En(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)=>kn(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 Dn(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function On(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 kn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var An=Q.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=ue,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Pt(),x=xn(),ee=It(!0),S=v.useState(`parent`),C=v.useState(`floatingRootContext`),w=v.useState(`floatingTreeRoot`),T=v.useState(`mounted`),E=v.useState(`open`),te=v.useState(`modal`),ne=v.useState(`openMethod`),D=v.useState(`activeTriggerElement`),O=v.useState(`transitionStatus`),re=v.useState(`positionerElement`),ie=v.useState(`instantType`),ae=v.useState(`adaptiveOrigin`),oe=v.useState(`lastOpenChangeReason`),k=v.useState(`floatingNodeId`),A=v.useState(`floatingParentNodeId`),se=C.useState(`domReferenceElement`),M=n,N=c,P=l,F=s,I=h;S.type===`context-menu`&&(M=n??S.context?.anchor,F??=`start`,!o&&F!==`center`&&(P=e.alignOffset??2,N=e.sideOffset??-5));let L=o,R=F;S.type===`menu`?(L??=`inline-end`,R??=`start`,I=e.collisionAvoidance??j):S.type===`menubar`&&(L??=S.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=S.type===`context-menu`,B=fe({anchor:M,floatingRootContext:C,positionMethod:ee?`fixed`:r,mounted:T,side:L,sideOffset:N,align:R,alignOffset:P,arrowPadding:z?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:k,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:I,shift:z?{crossAxis:!(`side`in I&&I.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:ae,lazyFlip:y?`placement`:!1});Q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===k&&v.set(`hoverEnabled`,!1),e.nodeId!==k&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,q(Ee)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[v,w.events,k]),Q.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,q(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,v]);let H=ft();Q.useEffect(()=>{E||H.clear()},[E,H]),Q.useEffect(()=>{function e(e){if(!(!E||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&D&&D!==e.target){let e=v.select(`closeDelay`);e>0?H.isStarted()||H.start(e,()=>{v.setOpen(!1,q(Ee))}):v.setOpen(!1,q(Ee))}else H.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,D,v,H]),Q.useEffect(()=>{let e={open:E,nodeId:k,parentNodeId:A,reason:v.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,v,k,A]),Ae({store:v,domReference:se,positionerElement:re,open:E});let ce={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:S.type===`menu`,instant:ie},U=S.type===`menubar`&&S.context.modal;Z(E&&(U||te&&oe!==`trigger-hover`),ne===`touch`,re,D);let W=Xe(e,ce,{styles:B.positionerStyles,transitionStatus:O,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&te&&oe!==`trigger-hover`||S.type===`menubar`&&S.context.modal),G=null;return S.type===`menubar`?G=S.context.contentElement:S.type===void 0&&(G=D),(0,$.jsxs)(jt.Provider,{value:B,children:[le&&(0,$.jsx)(Se,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Ke(!E),cutout:G}),(0,$.jsx)(V,{id:k,children:(0,$.jsx)(Cn,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),jn=Q.createContext(null);function Mn(e){let t=Q.useContext(jn);if(t===null&&!e)throw Error(ht(5));return t}function Nn(e){return e==null?Je:e.type.startsWith(`key`)?ye:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?ke:Je}var Pn={...he,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=he.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>et&&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`&&!he.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`)}},Fn=class extends dt{constructor(e,t,n=!1){let r=new ct,i=Ln(r,t,n,e);super(i,In(r),Pn),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 In(e){return{positionerRef:Q.createRef(),popupRef:Q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Q.createRef(),beforeTriggerFocusGuardRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Ln(e,t,n=!1,r){return{...mt(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:m,inputProps:m,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new te,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:m,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Rn=Q.createContext(null);function zn(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Bn(e,t){return e===`list-navigation`||zn(e,t)}var Vn=F(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:u=!0,orientation:f=`vertical`,actionsRef:p,closeParentOnEsc:h=!1,handle:b,triggerId:x,defaultTriggerId:S=null,highlightItemOnHover:C=!0,isSubmenu:w=!1,virtualFocus:T=!1,virtualFocusRef:E,allowEscape:te=!0,resetOnPointerLeave:D=!0}=e,re=It(!0),ae=Pt(!0),oe=Mn(!0),k=ae?.store,se=ae?.virtualFocus??!1,j=Q.useMemo(()=>w&&k?{type:`menu`,store:k}:oe?{type:`menubar`,context:oe}:re&&!k?{type:`context-menu`,context:re}:{type:void 0},[re,k,oe,w]),M=Ve(),N=Ve(),[P,F]=Q.useState(void 0),L=(P??N)||void 0,B=ne(),V=j.type===`menu`?j.store:void 0,H=(n??o)&&V?.state.transitionStatus===`starting`,ce=y(()=>H?V?.state.instantType:void 0).current,U=y(()=>{let e=new Fn({open:o,openProp:n,activeTriggerId:S,triggerIdProp:x,parent:j,disabled:s,highlightItemOnHover:C,modal:j.type===void 0?c:void 0,rootId:M,instantType:ce},L,B!=null);return e.context.virtualFocusRef=E,e}).current;U.useControlledProp(`openProp`,n),U.useControlledProp(`triggerIdProp`,x),U.useContextCallback(`onOpenChangeComplete`,i);let le=U.useState(`floatingTreeRoot`),ue=ee(le),G=U.useState(`open`),K=U.useState(`activeTriggerElement`),fe=U.useState(`positionerElement`),pe=U.useState(`hoverEnabled`),me=U.useState(`disabled`),he=U.useState(`lastOpenChangeReason`),J=U.useState(`parent`),ge=U.useState(`activeIndex`),_e=U.useState(`keyboardOpen`),ve=U.useState(`payload`),be=U.useState(`floatingParentNodeId`),xe=Q.useRef(null),Se=Q.useRef(J.type!==`context-menu`),Ce=ft(),we=Q.useRef(!0),Te=ft(),Y=be!=null,{openMethod:Ee,triggerProps:De}=Le(G);U.useSyncedValues({disabled:s,highlightItemOnHover:C,modal:J.type===void 0?c:void 0,openMethod:Ee,rootId:M}),l(U);let{forceUnmount:Oe,transitionStatus:ke}=Me(G,U,()=>{U.set(`allowMouseEnter`,!1)},H),Ae=O(U.context.popupRef);Q.useEffect(()=>{if(ce===void 0)return;let e=()=>{U.state.instantType===ce&&U.set(`instantType`,void 0)};if(!G){e();return}if(ke!==void 0)return;if(U.context.popupRef.current==null){e();return}let t=new AbortController;return Ae(e,t.signal),()=>{t.abort()}},[ce,G,ke,Ae,U]),A(()=>{re&&!ae?U.update({parent:{type:`context-menu`,context:re},floatingNodeId:ue,floatingParentNodeId:B}):(ae||!U.select(`activeTriggerElement`))&&U.update({floatingNodeId:ue,floatingParentNodeId:B})},[re,ae,ue,B,K,U]),Q.useEffect(()=>{if(G||(xe.current=null),J.type===`context-menu`){if(!G){Ce.clear(),Se.current=!1;return}Ce.start(500,()=>{Se.current=!0})}},[Ce,G,J.type]),A(()=>{!G&&!pe&&U.set(`hoverEnabled`,!0)},[G,pe,U]);let X=z((e,t)=>{let n=t.reason;if(!e&&!U.select(`open`)||G===e&&t.trigger===K&&he===n)return;let i=g(t);if(!e&&t.trigger==null&&(t.trigger=K??void 0),r?.(e,t),t.isCanceled)return;U.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!we.current)return;e&&n===`trigger-focus`?(we.current=!1,Te.start(300,()=>{we.current=!0})):(we.current=!0,Te.clear());let o=!e&&(n===`escape-key`||n==null);xe.current=t.event;let s=Pe(U.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Bn(n,a),s.instantType=J.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:zn(n,a)?`click`:o?`dismiss`:void 0,U.update(s)}),je=gt({popupStore:U,floatingRootContext:U.state.floatingRootContext,floatingId:L,nested:B!=null,onOpenChange:X}),Ne=je.context.events;A(()=>{let e=({open:e,eventDetails:t})=>X(e,t);return Ne.on(`setOpen`,e),()=>{Ne?.off(`setOpen`,e)}},[Ne,X]),A(()=>U.subscribeToParentMenu(),[U]);let Fe=Q.useCallback(()=>{U.setOpen(!1,q(ze))},[U]);Q.useImperativeHandle(p,()=>({unmount:Oe,close:Fe}),[Oe,Fe]);let Ie;J.type===`context-menu`&&(Ie=J.context),Q.useImperativeHandle(Ie?.positionerRef,()=>fe,[fe]),Q.useImperativeHandle(Ie?.actionsRef,()=>({setOpen:X}),[X]);let Re=d(je,{enabled:!me,bubbles:{escapeKey:h&&J.type===`menu`},outsidePress(){return J.type!==`context-menu`||xe.current?.type===`contextmenu`||Se.current},externalTree:Y?le:void 0}),Be=_(),Z=Ot(je,{enabled:!me,listRef:U.context.itemDomElements,activeIndex:ge,virtual:T,nested:J.type===`menubar`||!T&&J.type!==void 0,parentOrientation:J.type===`menubar`?J.context.orientation:void 0,loopFocus:u,focusItemOnOpen:T?_e:void 0,allowEscape:T&&u&&te,orientation:f,triggerOrientation:T?`vertical`:f,rtl:Be===`rtl`,disabledIndices:I,onNavigate(e,t){U.setActiveIndex(e,Nn(t),t?.nativeEvent)},openOnArrowKeyDown:J.type!==`context-menu`&&!(T&&w),externalTree:!T&&Y?le:void 0,nestedReturnFocusRef:V?.context.virtualFocusRef,focusItemOnHover:C,resetOnPointerLeave:D}),He=Q.useCallback(e=>{U.context.typingRef.current=e},[U]),Ue=kt(je,{enabled:!me&&!T,listRef:U.context.itemLabels,elementsRef:U.context.itemDomElements,activeIndex:ge,resetMs:500,onMatch:(e,t)=>{G&&e!==ge&&U.setActiveIndex(e,ye,t.nativeEvent)},onTyping:He}),We=z(a),Ge=Q.useRef(-1),Ke=z(()=>{let e=U.state.activeIndex,t=e===null?void 0:U.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ge.current===n&&U.context.reportedItem===t)return;Ge.current=n,U.context.reportedItem=t,T&&U.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=U.context;U.context.highlightReason=Je,U.context.highlightEvent=void 0,a&&We(t,pt(r,i,{label:t===void 0?void 0:U.context.itemLabels.current[n]??void 0}))});A(()=>{Ke()},[ge,Ke]);let qe=Q.useMemo(()=>{if(!T)return Z.reference;if(!Z.trigger)return m;let{onFocus:e,...t}=Z.trigger;return t},[T,Z.reference,Z.trigger]);U.useSyncedValue(`inputProps`,T?Z.reference??m:m);let Ye=Q.useMemo(()=>{let e=de(Ue.reference,qe,Re.reference,{onMouseMove(){U.set(`allowMouseEnter`,!0)}},De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=G,e},[U,Ue.reference,qe,Re.reference,De,G]),Xe=Q.useMemo(()=>{let e=de(Z.trigger,Re.trigger,De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Z.trigger,Re.trigger,De]);y(()=>(U.update({inactiveTriggerProps:Xe}),null));let Ze=Q.useMemo(()=>de(R,{onMouseMove(){U.set(`allowMouseEnter`,!0),J.type===`menu`&&U.set(`hoverEnabled`,!1)},onClick(){U.select(`hoverEnabled`)&&U.set(`hoverEnabled`,!1)},onKeyDown(e){let t=U.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ue.floating,Z.floating,Re.floating),[J.type,U,Ue.floating,Z.floating,Re.floating]),Qe=Z.item??m;ie(U,{floatingRootContext:je,activeTriggerProps:Ye,inactiveTriggerProps:Xe,popupProps:Ze,itemProps:Qe});let $e=Q.useMemo(()=>({store:U,parent:j,orientation:f,loopFocus:u,allowEscape:te,defaultFloatingId:N,setRenderedFloatingId:F,virtualFocus:T,parentVirtualFocus:se,syncHighlightedItem:Ke}),[U,j,f,u,te,N,T,se,Ke]),et=typeof t==`function`?t({payload:ve}):t,tt=(0,$.jsxs)(Nt.Provider,{value:$e,children:[b&&(0,$.jsx)(v,{handle:b,store:U}),et]});return(J.type===void 0||J.type===`context-menu`)&&(tt=(0,$.jsx)(W,{externalTree:le,children:tt})),tt});function Hn(e){let t=Q.useContext(Rn);if(t===null)return(0,$.jsx)(Vn,{...e});let n=t.Root;return(0,$.jsx)(Rn.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var Un=5;function Wn(e,t){let n=Gn(t);return e.clientX>=n.left-Un&&e.clientX<=n.right+Un&&e.clientY>=n.top-Un&&e.clientY<=n.bottom+Un}function Gn(e){let t=e.getBoundingClientRect(),n=it(e);if(Ge)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 Kn(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ut(),{ref:i,index:a}=Xt(e),o=n===a,s=Q.useRef(null),c=st(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 qn(e){let{render:t,className:n,style:r,state:i=m,props:a=I,refs:o=I,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Kn({metadata:s});return Y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Jn(e){if(Ce(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!qe(e))return Jn(Re(e))}function Yn(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Q.useRef(!1);return Q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Ie(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:m,[t,n,r])}var Xn=p(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,h=Pt(!0),g=ot(d)??h?.store;if(!g)throw Error(ht(85));let _=Ve(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Q.useRef(null),w=Qn(),T=ut(!0),E=Ye(),O=Q.useMemo(()=>E??new te,[E]),re=ee(O),ie=ne(),{registerTrigger:ae,isMountedByThisTrigger:oe}=b(_,C,g,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:re,floatingParentNodeId:ie,keyboardEventRelay:T?.relayKeyboardEvent}),k=w.type===`menubar`,A=g.useState(`disabled`),se=a||A||k&&w.context.disabled,{getButtonProps:j,buttonRef:M}=L({disabled:se,native:o});Q.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let N=Q.useRef(null),P=ft(),F=z(e=>{if(!N.current)return;P.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(N.current,t)||X(g.select(`positionerElement`),t)||t===N.current||(t==null||Jn(t)!==g.select(`rootId`))&&(Wn(e,N.current)||O.events.emit(`close`,{domEvent:e,reason:me}))});Q.useEffect(()=>{let e=Ie(N.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[x,F,g]);let I=k&&w.context.hasSubmenuOpen,R=Te(y,{enabled:(c??I)&&!se&&(!k||I&&!oe),handleClose:De({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),B=Zn(x,g.select(`lastOpenChangeReason`)),V=ce(y,{enabled:!se,event:x&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&B}),H=xt(y,{enabled:!se&&I}),U=Yn({open:x,enabled:k,mouseDownAction:`open`}),W=Q.useMemo(()=>de(H.reference,V.reference),[H.reference,V.reference]),le=g.useState(`triggerProps`,oe),ue=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:G,handleFocusTargetFocus:K}=tt(g,C),fe={disabled:se,open:x},pe=[N,t,M,ae,C],he=[W,R??m,le,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(P.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),Ie(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ue,k?{role:`menuitem`}:{},U,p,j],q=Y(`button`,e,{enabled:!k,stateAttributesMapping:D,state:fe,ref:pe,props:he});return k?(0,$.jsx)(qn,{tag:`button`,render:n,className:r,style:i,state:fe,refs:pe,props:he,stateAttributesMapping:D}):x?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(rt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:G},`${_}-pre-focus-guard`),(0,$.jsx)(Q.Fragment,{children:q},_),(0,$.jsx)(rt,{ref:g.context.triggerFocusTargetRef,onFocus:K},`${_}-post-focus-guard`)]}):(0,$.jsx)(Q.Fragment,{children:q},_)});function Zn(e,t){let n=ft(),[r,i]=Q.useState(!1);return A(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Qn(){let e=Mn(!0);return Q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var $n=Q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),er=(0,Q.createContext)(null);function tr({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Q.useRef)(null),o=e??a;return k(()=>o.current?.close()),(0,$.jsx)(er.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(Hn,{...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 nr(){let e=(0,Q.useContext)(er);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var rr=(0,Q.forwardRef)(function({className:e,render:t,type:n=`button`,...a},o){return(0,$.jsx)(Xn,{...a,className:t=>r(`btn caps-dropdown-trigger`,i(e,t)),ref:o,render:t,type:n})}),ir=(0,Q.forwardRef)(function({container:e,...t},n){let r=Fe(`popover`);return e==null&&r===null?null:(0,$.jsx)(Sn,{...t,container:e??r,ref:n})}),ar=(0,Q.forwardRef)(function({collisionBoundary:e,...t},n){let r=Fe(`popover`);return(0,$.jsx)(An,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),or=(0,Q.forwardRef)(function({className:e,finalFocus:t,...n},a){let{interactionOwner:o}=nr(),s=(0,Q.useRef)(null);(0,Q.useImperativeHandle)(a,()=>s.current);let c=J(`.caps-dropdown-item[data-highlighted]`),l=(0,Q.useCallback)(e=>{s.current=e,c(e)},[c]);return(0,$.jsx)(yn,{...n,className:t=>r(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,i(e,t)),finalFocus:o===`host`?!1:t??!0,ref:l})}),sr=(0,Q.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(ir,{container:r,keepMounted:i,children:(0,$.jsx)(ar,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(or,{...s,ref:c,children:n})})})}),cr=`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`,lr=(0,Q.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:a=`default`,...o},s){return(0,$.jsx)(un,{...o,className:t=>r(cr,a===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,i(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:s})}),ur=(0,Q.forwardRef)(function({children:e,className:t,onClick:n,onSelect:a,...o},s){return(0,$.jsxs)(tn,{...o,className:e=>r(cr,i(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||a?.(e)},ref:s,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(nn,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})}),dr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)($n,{...t,className:t=>r(`my-xs h-px bg-base-300`,i(e,t)),ref:n})}),fr=sn,pr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(cn,{...t,className:t=>r(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,i(e,t)),ref:n})});export{lr as a,rr as c,fr as i,yt as l,ur as n,pr as o,sr as r,dr as s,tr as t,vt as u};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,v as r,y as i}from"./button-oE2Hrd5D.js";import{l as a,u as o}from"./log-event-IU820pK9.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Cn as m,Ct as h,D as g,Dt as _,E as v,En as y,F as b,Ft as x,G as ee,Gt as S,H as C,Ht as w,I as T,It as E,J as te,K as ne,Kt as D,L as O,Lt as re,M as ie,Mt as ae,Nt as oe,On as k,Ot as A,Pt as se,Q as j,Qt as M,R as N,Rt as P,S as F,Sn as I,St as L,T as R,Tn as z,Tt as B,U as V,Ut as H,V as ce,Vt as U,W,Y as le,Z as ue,_ as G,_n as de,_t as K,a as fe,an as pe,at as me,b as he,bt as q,c as J,cn as ge,ct as _e,dn as ve,dt as ye,en as be,et as xe,f as Se,fn as Ce,ft as we,g as Te,gn as Y,gt as Ee,h as De,hn as Oe,ht as ke,i as Ae,in as X,it as je,j as Me,jt as Ne,k as Pe,kn as Fe,kt as Ie,l as Le,ln as Re,lt as ze,m as Be,mn as Ve,n as Z,nn as He,nt as Ue,o as We,on as Ge,p as Ke,pn as qe,pt as Je,q as Ye,r as Xe,rn as Ze,rt as Qe,s as $e,sn as et,t as tt,tn as nt,tt as rt,un as it,ut as at,v as ot,vn as st,w as ct,wn as lt,wt as ut,x as dt,xn as ft,xt as pt,y as mt,yn as ht,z as gt,zt as _t}from"./useTriggerFocusGuards-Bddw7Qdn.js";function vt(e){return/\.mp4$/iu.test(e)}async function yt(e,t){if(vt(e.name)){let n=document.createElement(`video`);return n.preload=`metadata`,n.muted=!0,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP4 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,width:n.videoWidth,height:n.videoHeight}}if(o(e.name)){let n=new Audio;return n.preload=`metadata`,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP3 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,...a}}let n=new Image;return n.src=t,await n.decode(),{file:e,url:t,width:n.naturalWidth,height:n.naturalHeight}}var Q=e(n(),1),bt=ge&&et;function xt(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Q.useRef(!1),s=Q.useRef(null),c=Q.useRef(!0),l=ft();Q.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=it(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Ce(t)&&t===Ze(Ie(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return je(B(r,`blur`,i),bt&&B(r,`keydown`,a,!0),bt&&B(r,`pointerdown`,l,!0))},[e,n]),Q.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);ve(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Q.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=pe(n.nativeEvent);if(ve(a)){if(bt&&!n.relatedTarget){if(!c.current&&!w(a))return}else if(!H(a))return}let u=f(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:p}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,q(K,d,p));return}l.start(r,()=>{o.current||e.setOpen(!0,q(K,d,p))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=ve(r)&&r.hasAttribute(xe(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ze(Ie(t));!r&&n===t||X(a.current.floatingContext?.refs.floating.current,n)||X(t,n)||o||f(r??n,e.context.triggerElements)||e.setOpen(!1,q(K,i))})}}},[a,r,e,l]);return Q.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}function St(e){return et&&e.movementX===0&&e.movementY===0}function Ct(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function wt(e,t){return Ct(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Tt(e,t,n){return Ct(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Et(e,t,n){return Ct(t,n?e===be:e===nt,e===c)}function Dt(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Ct(t,n?e===nt:e===be,e===He)}function Ot(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:c=!1,loopFocus:l=!1,nested:d=!1,rtl:f=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:ee=!0,externalTree:S,nestedReturnFocusRef:C,grid:T}=t,te=T!=null,D=e.useState(`open`),O=e.useState(`floatingElement`),ie=e.useState(`domReferenceElement`),oe=e.context.dataRef,k=_t(O),j=U(ie),M=Qe(k),N=ne(),F=Ye(S),I=Q.useRef(m),L=Q.useRef(o??-1),R=Q.useRef(null),B=Q.useRef(!0),V=z(e=>{i(L.current===-1?null:L.current,e)}),H=Q.useRef(!!O),ce=Q.useRef(D),W=Q.useRef(!1),le=Q.useRef(!1),ue=Q.useRef(null),G=Qe(_),de=Qe(D),K=Qe(o),fe=Qe(ee),me=Ue(),he=Ue(),J=z(()=>{me.cancel();function e(e){p||(ue.current=s(e,{sync:W.current,preventScroll:!0}))}let t=n.current[L.current],r=le.current;t&&e(t),(W.current?e=>e():e=>me.request(e))(()=>{let i=n.current[L.current]||t;i&&(t||e(i),Se&&(r||!B.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});A(()=>{oe.current.orientation=v},[oe,v]),A(()=>{D||(R.current=null),(!D||m!==`auto`)&&(I.current=m)},[D,m]),A(()=>{a&&(D&&O?(L.current=o??-1,I.current&&o!=null&&(le.current=!0,V())):H.current&&(L.current=-1,V()))},[a,D,O,o,V]),A(()=>{if(a){if(!D){W.current=!1;return}if(O){if(r==null){if(W.current=!1,K.current!=null)return;if(H.current&&(L.current=-1,J()),(!ce.current||!H.current)&&I.current&&(R.current!=null||I.current===!0&&R.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>he.request(e):queueMicrotask)(t),e+=1):(L.current=R.current==null||Tt(R.current,y,f)||d?Ne(n):u(n),R.current=null,V())};t()}}else se(n.current,r)||(L.current=r,J(),le.current=!1)}}},[a,D,O,r,K,d,n,y,f,V,J,he]),A(()=>{if(!a||O||!F||p||!H.current)return;let e=F.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ze(Ie(ie??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&B.current&&t.focus({preventScroll:!0})},[a,O,ie,F,N,p]),A(()=>{ce.current=D,H.current=!!O});let ge=r!=null,ve=z(e=>{if(!de.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(L.current!==t||r!==t)&&(L.current=t,V(e))}),ye=z(()=>b??F?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),be=z(()=>Ne(n,G.current)),xe=z(t=>{if(B.current=!1,W.current=!0,t.which===229||!de.current&&t.currentTarget===M.current)return;if(d&&Dt(t.key,v,f,te)){wt(t.key,ye())||P(t),e.setOpen(!1,q(we,t.nativeEvent));let n=C?.current??ie;Ce(n)&&n.focus();return}r!=null&&r!==L.current&&!se(n.current,r)&&(L.current=r);let i=L.current,a=Ne(n,_),o=u(n,_);if(j||(t.key===`Home`&&(P(t),L.current=a,V(t)),t.key===`End`&&(P(t),L.current=o,V(t))),T!=null){let e=T(t,L.current,n,v,l,f,_,a,o);if(e!=null&&e!==L.current&&(L.current=e,V(t)),v===`both`)return}if(wt(t.key,v)){P(t);let e=Ze(t.currentTarget.ownerDocument);if(D&&!p&&X(t.currentTarget,e)&&!n.current.some(t=>t!=null&&X(t,e))){L.current=Tt(t.key,v,f)?a:o,V(t),r===L.current&&J();return}let{index:s,wrapped:u}=ae(n.current,i,{decrement:!Tt(t.key,v,f),loopFocus:l,allowEscape:c,disabledIndices:_,minIndex:a,maxIndex:o});u&&(W.current=!1),L.current=s,V(t)}}),Se=Q.useMemo(()=>({onFocus(e){W.current=!0,ve(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){St(e)||(W.current=!0,le.current=!1,h&&ve(e))},onPointerLeave(e){if(!de.current||!B.current||e.pointerType===`touch`)return;W.current=!0;let t=e.relatedTarget;if(!(!h||n.current.includes(t))&&fe.current&&(ue.current?.(),ue.current=null,L.current=-1,V(e),!p)){let e=M.current,t=Ze(Ie(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ve,de,M,h,n,V,fe,p]),Te=Q.useMemo(()=>p&&D&&ge&&{"aria-activedescendant":`${x}-${r}`},[p,D,ge,x,r]),Y=Q.useMemo(()=>({...j?{}:Te,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&D&&!p){let n=pe(t.nativeEvent);if(n&&!X(M.current,n))return;P(t);let r=q(_e,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??ie;!r.isCanceled&&Ce(i)&&i.focus();return}xe(t)},onPointerMove(e){St(e)||(B.current=!0)}}),[Te,xe,M,j,e,D,p,ie,C]),Ee=Q.useMemo(()=>{function t(t){e.setOpen(!0,q(we,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&E(e.nativeEvent)&&(I.current=!p)}function r(e){I.current=m,m===`auto`&&re(e.nativeEvent)&&(I.current=!0)}return{onKeyDown(n){let r=e.select(`open`);B.current=!1;let i=n.key.startsWith(`Arrow`),a=Et(n.key,ye(),f),o=wt(n.key,r?v:y),s=(d?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!d||w(n.currentTarget)))return xe(n);if(!(!r&&!g&&i)){if(s){let e=wt(n.key,ye());R.current=d&&e?null:n.key}if(d){a&&(P(n),r?(L.current=be(),V(n),p&&M.current?.focus()):t(n));return}o&&(K.current!=null&&(L.current=K.current),P(n),!r&&g?t(n):xe(n),r&&V(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(L.current=-1,V(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[xe,m,be,d,V,e,g,v,y,ye,f,K,p,M]),De=Q.useMemo(()=>({...Te,...Ee}),[Te,Ee]);return Q.useMemo(()=>a?{reference:De,floating:Y,item:Se,trigger:Ee}:{},[a,De,Y,Ee,Se])}function kt(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=ft(),m=Q.useRef(``),h=Q.useRef(u??i??-1),g=Q.useRef(null),_=z(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!oe(n)||n?.matches(`:disabled`)?!1:o==null||!x(I,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===` `&&(P(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!==` `&&(P(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`);X(r,n)||X(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});A(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Q.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Q.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}function At({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Q.useRef(e!==void 0),[a,o]=Q.useState(()=>t);return[i&&e!==void 0?e:a,Q.useCallback(e=>{i||o(e)},[])]}var $=t(),jt=Q.createContext(void 0);function Mt(e){let t=Q.useContext(jt);if(t===void 0&&!e)throw Error(ht(33));return t}var Nt=Q.createContext(void 0);function Pt(e){let t=Q.useContext(Nt);if(t===void 0&&!e)throw Error(ht(36));return t}var Ft=Q.createContext(void 0);function It(e=!0){let t=Q.useContext(Ft);if(t===void 0&&!e)throw Error(ht(25));return t}var Lt=Q.createContext(null);function Rt(e=`root`){let t=Q.useContext(Lt),n=Q.useContext(Nt);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var zt={visible:!0,ref:null};function Bt(){return zt}function Vt(e,t,n=`root`){let r=Rt(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Bt)({label:e.label,children:e.children,render:e.render}),a=st(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var Ht=Q.createContext(void 0);function Ut(){let e=Q.useContext(Ht);if(e===void 0)throw Error(ht(30));return e}function Wt(e){e.preventDefault()}function Gt(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Pt(),u=It(!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`),g=a.useState(`open`),_=u!==void 0,v=!f&&g&&n?0:-1;return Q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:v,"aria-selected":p,onMouseDown:f?Wt: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:at})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,_&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||_&&!ge&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!_||e.button===2)&&c.type===`regular-item`&&h(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,v,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,_,c.type,p,f])}var Kt={type:`regular-item`};function qt(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=Q.useRef(null),{getButtonProps:d,buttonRef:f}=L({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Gt({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Q.useCallback(e=>de(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=st(u,f);return Q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Jt=Q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Yt(){return Q.useContext(Jt)}function Xt(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Yt(),u=Q.useRef(-1),[d,f]=Q.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=Q.useRef(null),h=Q.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 A(()=>{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 Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},...M},en=Q.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}=Pt(),m=Xt({guess:!0,label:a}),h=Ve(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:ee}=qt({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:Kt}),S=Q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function C(e){let t=q(at,e.nativeEvent,void 0,{preventUnmountOnClose:lt});u?.(!l,t)}let w=Y(`div`,e,{state:S,stateAttributesMapping:$t,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:C},f,x],ref:[ee,t,m.ref]});return(0,$.jsx)(Ht.Provider,{value:S,children:w})}),tn=Q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=At({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Vt(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(en,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),nn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Ut(),c=Q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=N(s.checked);T({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}});let f={checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l};return Y(`span`,e,{state:f,ref:[t,c],stateAttributesMapping:$t,props:{"aria-hidden":!0,...o},enabled:a||u})}),rn=Q.createContext(void 0);function an(){let e=Q.useContext(rn);if(e===void 0)throw Error(ht(31));return e}var on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Q.useState(void 0),c=Y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,$.jsx)(rn.Provider,{value:s,children:c})}),sn=Q.forwardRef(function(e,t){let n=Rt()?.Group??on;return(0,$.jsx)(n,{...e,ref:t})}),cn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ve(a),c=an();return A(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),ln=Q.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}=Pt(),f=Xt({guess:!0,label:a}),p=Ve(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}=qt({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Kt});return Y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),un=Q.forwardRef(function(e,t){let n=Vt(e,t);return n.visible?(0,$.jsx)(ln,{...e,ref:n.ref}):null}),dn=Q.createContext(void 0);function fn(){return Q.useContext(dn)}function pn(e,t){let n=Oe(e.render);if(Q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function mn(e,t,n){let r=pn(e,t),i=r===t?void 0:r;return[r,Q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function hn(e,t,n){let r=Oe(e.render),i=Q.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 gn=Q.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}=Pt(),m=fn(),{side:h,align:g}=Mt(),_=$e(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),ee=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),E=l.useState(`parent`),te=l.useState(`lastOpenChangeReason`),ne=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),re=l.useState(`closeDelay`),ie=l.useState(`hoverEnabled`),ae=l.useState(`disabled`),oe=l.useState(`openMethod`),k=l.useState(`activeTriggerId`),A=l.useState(`listElement`),[se,j]=mn(e,u,d),M=hn(e,w,k),N=E.type===`menu`?m:void 0,P=E.type===`context-menu`,F=s??E.type!==`menu`;s===void 0&&A&&E.type!==`menu`&&(F=()=>l.state.activeIndex===null&&A),T({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Q.useEffect(()=>{function e(e){l.setOpen(!1,q(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),G(D,{enabled:ie&&!ae&&!P&&E.type!==`menubar`,closeDelay:re});let I=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:L,handleFocus:R}=(Q.useContext(Lt)?.useParentHandoff??vn)(l,E,v,f),z={transitionStatus:y,side:h,align:g,open:v,nested:E.type===`menu`,instant:ee},B=Y(`div`,e,{state:z,ref:[t,l.context.popupRef,I,j],stateAttributesMapping:S,props:[b,{id:se,...A?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":M},onKeyDown(e){N?.onPopupKeyDown?.(e),_&&Be.has(e.key)&&e.stopPropagation()},onFocus:R},We(y),c,{"data-rootownerid":ne}]}),V=E.type===void 0||P;(w||E.type===`menubar`&&te!==`outside-press`)&&(V=!0);let H=N?.getReturnElement??L;return(0,$.jsx)(C,{context:D,openInteractionType:oe,modal:P,disabled:!x,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:F,restoreFocus:!0,getInsideElements:E.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:E.type===`menubar`?void 0:O,previousFocusableElement:w,nextFocusableElement:E.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:B})}),_n={parentVirtualFocusRef:void 0,handleFocus:void 0};function vn(){return _n}var yn=Q.forwardRef(function(e,t){let n=Rt()?.Popup??gn;return(0,$.jsx)(n,{...e,ref:t})}),bn=Q.createContext(void 0);function xn(){let e=Q.useContext(bn);if(e===void 0)throw Error(ht(32));return e}var Sn=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Pt();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(bn.Provider,{value:n,children:(0,$.jsx)(le,{ref:t,...r,portalOwnerRole:o})})});function Cn(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=z(i),[,o]=Q.useState(0),s=y(Tn).current,c=y(wn).current,l=Q.useRef(0),u=Q.useRef(!0),d=Q.useRef(null),f=Q.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(!On(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&kn(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=Dn(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=z(()=>{let[e,t]=En(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))});A(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),A(()=>{u.current&&v()}),A(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=z(e=>(s.add(e),()=>{s.delete(e)})),x=Q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,$.jsx)(Jt.Provider,{value:x,children:t})}function wn(){return new Map}function Tn(){return new Set}function En(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)=>kn(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 Dn(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function On(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 kn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var An=Q.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=ue,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Pt(),x=xn(),ee=It(!0),S=v.useState(`parent`),C=v.useState(`floatingRootContext`),w=v.useState(`floatingTreeRoot`),T=v.useState(`mounted`),E=v.useState(`open`),te=v.useState(`modal`),ne=v.useState(`openMethod`),D=v.useState(`activeTriggerElement`),O=v.useState(`transitionStatus`),re=v.useState(`positionerElement`),ie=v.useState(`instantType`),ae=v.useState(`adaptiveOrigin`),oe=v.useState(`lastOpenChangeReason`),k=v.useState(`floatingNodeId`),A=v.useState(`floatingParentNodeId`),se=C.useState(`domReferenceElement`),M=n,N=c,P=l,F=s,I=h;S.type===`context-menu`&&(M=n??S.context?.anchor,F??=`start`,!o&&F!==`center`&&(P=e.alignOffset??2,N=e.sideOffset??-5));let L=o,R=F;S.type===`menu`?(L??=`inline-end`,R??=`start`,I=e.collisionAvoidance??j):S.type===`menubar`&&(L??=S.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=S.type===`context-menu`,B=fe({anchor:M,floatingRootContext:C,positionMethod:ee?`fixed`:r,mounted:T,side:L,sideOffset:N,align:R,alignOffset:P,arrowPadding:z?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:k,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:I,shift:z?{crossAxis:!(`side`in I&&I.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:ae,lazyFlip:y?`placement`:!1});Q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===k&&v.set(`hoverEnabled`,!1),e.nodeId!==k&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,q(Ee)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[v,w.events,k]),Q.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,q(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,v]);let H=ft();Q.useEffect(()=>{E||H.clear()},[E,H]),Q.useEffect(()=>{function e(e){if(!(!E||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&D&&D!==e.target){let e=v.select(`closeDelay`);e>0?H.isStarted()||H.start(e,()=>{v.setOpen(!1,q(Ee))}):v.setOpen(!1,q(Ee))}else H.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,D,v,H]),Q.useEffect(()=>{let e={open:E,nodeId:k,parentNodeId:A,reason:v.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,v,k,A]),Ae({store:v,domReference:se,positionerElement:re,open:E});let ce={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:S.type===`menu`,instant:ie},U=S.type===`menubar`&&S.context.modal;Z(E&&(U||te&&oe!==`trigger-hover`),ne===`touch`,re,D);let W=Xe(e,ce,{styles:B.positionerStyles,transitionStatus:O,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&te&&oe!==`trigger-hover`||S.type===`menubar`&&S.context.modal),G=null;return S.type===`menubar`?G=S.context.contentElement:S.type===void 0&&(G=D),(0,$.jsxs)(jt.Provider,{value:B,children:[le&&(0,$.jsx)(Se,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Ke(!E),cutout:G}),(0,$.jsx)(V,{id:k,children:(0,$.jsx)(Cn,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),jn=Q.createContext(null);function Mn(e){let t=Q.useContext(jn);if(t===null&&!e)throw Error(ht(5));return t}function Nn(e){return e==null?Je:e.type.startsWith(`key`)?ye:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?ke:Je}var Pn={...he,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=he.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>et&&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`&&!he.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`)}},Fn=class extends dt{constructor(e,t,n=!1){let r=new ct,i=Ln(r,t,n,e);super(i,In(r),Pn),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 In(e){return{positionerRef:Q.createRef(),popupRef:Q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Q.createRef(),beforeTriggerFocusGuardRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Ln(e,t,n=!1,r){return{...mt(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:m,inputProps:m,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new te,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:m,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Rn=Q.createContext(null);function zn(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Bn(e,t){return e===`list-navigation`||zn(e,t)}var Vn=F(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:u=!0,orientation:f=`vertical`,actionsRef:p,closeParentOnEsc:h=!1,handle:b,triggerId:x,defaultTriggerId:S=null,highlightItemOnHover:C=!0,isSubmenu:w=!1,virtualFocus:T=!1,virtualFocusRef:E,allowEscape:te=!0,resetOnPointerLeave:D=!0}=e,re=It(!0),ae=Pt(!0),oe=Mn(!0),k=ae?.store,se=ae?.virtualFocus??!1,j=Q.useMemo(()=>w&&k?{type:`menu`,store:k}:oe?{type:`menubar`,context:oe}:re&&!k?{type:`context-menu`,context:re}:{type:void 0},[re,k,oe,w]),M=Ve(),N=Ve(),[P,F]=Q.useState(void 0),L=(P??N)||void 0,B=ne(),V=j.type===`menu`?j.store:void 0,H=(n??o)&&V?.state.transitionStatus===`starting`,ce=y(()=>H?V?.state.instantType:void 0).current,U=y(()=>{let e=new Fn({open:o,openProp:n,activeTriggerId:S,triggerIdProp:x,parent:j,disabled:s,highlightItemOnHover:C,modal:j.type===void 0?c:void 0,rootId:M,instantType:ce},L,B!=null);return e.context.virtualFocusRef=E,e}).current;U.useControlledProp(`openProp`,n),U.useControlledProp(`triggerIdProp`,x),U.useContextCallback(`onOpenChangeComplete`,i);let le=U.useState(`floatingTreeRoot`),ue=ee(le),G=U.useState(`open`),K=U.useState(`activeTriggerElement`),fe=U.useState(`positionerElement`),pe=U.useState(`hoverEnabled`),me=U.useState(`disabled`),he=U.useState(`lastOpenChangeReason`),J=U.useState(`parent`),ge=U.useState(`activeIndex`),_e=U.useState(`keyboardOpen`),ve=U.useState(`payload`),be=U.useState(`floatingParentNodeId`),xe=Q.useRef(null),Se=Q.useRef(J.type!==`context-menu`),Ce=ft(),we=Q.useRef(!0),Te=ft(),Y=be!=null,{openMethod:Ee,triggerProps:De}=Le(G);U.useSyncedValues({disabled:s,highlightItemOnHover:C,modal:J.type===void 0?c:void 0,openMethod:Ee,rootId:M}),l(U);let{forceUnmount:Oe,transitionStatus:ke}=Me(G,U,()=>{U.set(`allowMouseEnter`,!1)},H),Ae=O(U.context.popupRef);Q.useEffect(()=>{if(ce===void 0)return;let e=()=>{U.state.instantType===ce&&U.set(`instantType`,void 0)};if(!G){e();return}if(ke!==void 0)return;if(U.context.popupRef.current==null){e();return}let t=new AbortController;return Ae(e,t.signal),()=>{t.abort()}},[ce,G,ke,Ae,U]),A(()=>{re&&!ae?U.update({parent:{type:`context-menu`,context:re},floatingNodeId:ue,floatingParentNodeId:B}):(ae||!U.select(`activeTriggerElement`))&&U.update({floatingNodeId:ue,floatingParentNodeId:B})},[re,ae,ue,B,K,U]),Q.useEffect(()=>{if(G||(xe.current=null),J.type===`context-menu`){if(!G){Ce.clear(),Se.current=!1;return}Ce.start(500,()=>{Se.current=!0})}},[Ce,G,J.type]),A(()=>{!G&&!pe&&U.set(`hoverEnabled`,!0)},[G,pe,U]);let X=z((e,t)=>{let n=t.reason;if(!e&&!U.select(`open`)||G===e&&t.trigger===K&&he===n)return;let i=g(t);if(!e&&t.trigger==null&&(t.trigger=K??void 0),r?.(e,t),t.isCanceled)return;U.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!we.current)return;e&&n===`trigger-focus`?(we.current=!1,Te.start(300,()=>{we.current=!0})):(we.current=!0,Te.clear());let o=!e&&(n===`escape-key`||n==null);xe.current=t.event;let s=Pe(U.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Bn(n,a),s.instantType=J.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:zn(n,a)?`click`:o?`dismiss`:void 0,U.update(s)}),je=gt({popupStore:U,floatingRootContext:U.state.floatingRootContext,floatingId:L,nested:B!=null,onOpenChange:X}),Ne=je.context.events;A(()=>{let e=({open:e,eventDetails:t})=>X(e,t);return Ne.on(`setOpen`,e),()=>{Ne?.off(`setOpen`,e)}},[Ne,X]),A(()=>U.subscribeToParentMenu(),[U]);let Fe=Q.useCallback(()=>{U.setOpen(!1,q(ze))},[U]);Q.useImperativeHandle(p,()=>({unmount:Oe,close:Fe}),[Oe,Fe]);let Ie;J.type===`context-menu`&&(Ie=J.context),Q.useImperativeHandle(Ie?.positionerRef,()=>fe,[fe]),Q.useImperativeHandle(Ie?.actionsRef,()=>({setOpen:X}),[X]);let Re=d(je,{enabled:!me,bubbles:{escapeKey:h&&J.type===`menu`},outsidePress(){return J.type!==`context-menu`||xe.current?.type===`contextmenu`||Se.current},externalTree:Y?le:void 0}),Be=_(),Z=Ot(je,{enabled:!me,listRef:U.context.itemDomElements,activeIndex:ge,virtual:T,nested:J.type===`menubar`||!T&&J.type!==void 0,parentOrientation:J.type===`menubar`?J.context.orientation:void 0,loopFocus:u,focusItemOnOpen:T?_e:void 0,allowEscape:T&&u&&te,orientation:f,triggerOrientation:T?`vertical`:f,rtl:Be===`rtl`,disabledIndices:I,onNavigate(e,t){U.setActiveIndex(e,Nn(t),t?.nativeEvent)},openOnArrowKeyDown:J.type!==`context-menu`&&!(T&&w),externalTree:!T&&Y?le:void 0,nestedReturnFocusRef:V?.context.virtualFocusRef,focusItemOnHover:C,resetOnPointerLeave:D}),He=Q.useCallback(e=>{U.context.typingRef.current=e},[U]),Ue=kt(je,{enabled:!me&&!T,listRef:U.context.itemLabels,elementsRef:U.context.itemDomElements,activeIndex:ge,resetMs:500,onMatch:(e,t)=>{G&&e!==ge&&U.setActiveIndex(e,ye,t.nativeEvent)},onTyping:He}),We=z(a),Ge=Q.useRef(-1),Ke=z(()=>{let e=U.state.activeIndex,t=e===null?void 0:U.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ge.current===n&&U.context.reportedItem===t)return;Ge.current=n,U.context.reportedItem=t,T&&U.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=U.context;U.context.highlightReason=Je,U.context.highlightEvent=void 0,a&&We(t,pt(r,i,{label:t===void 0?void 0:U.context.itemLabels.current[n]??void 0}))});A(()=>{Ke()},[ge,Ke]);let qe=Q.useMemo(()=>{if(!T)return Z.reference;if(!Z.trigger)return m;let{onFocus:e,...t}=Z.trigger;return t},[T,Z.reference,Z.trigger]);U.useSyncedValue(`inputProps`,T?Z.reference??m:m);let Ye=Q.useMemo(()=>{let e=de(Ue.reference,qe,Re.reference,{onMouseMove(){U.set(`allowMouseEnter`,!0)}},De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=G,e},[U,Ue.reference,qe,Re.reference,De,G]),Xe=Q.useMemo(()=>{let e=de(Z.trigger,Re.trigger,De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Z.trigger,Re.trigger,De]);y(()=>(U.update({inactiveTriggerProps:Xe}),null));let Ze=Q.useMemo(()=>de(R,{onMouseMove(){U.set(`allowMouseEnter`,!0),J.type===`menu`&&U.set(`hoverEnabled`,!1)},onClick(){U.select(`hoverEnabled`)&&U.set(`hoverEnabled`,!1)},onKeyDown(e){let t=U.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ue.floating,Z.floating,Re.floating),[J.type,U,Ue.floating,Z.floating,Re.floating]),Qe=Z.item??m;ie(U,{floatingRootContext:je,activeTriggerProps:Ye,inactiveTriggerProps:Xe,popupProps:Ze,itemProps:Qe});let $e=Q.useMemo(()=>({store:U,parent:j,orientation:f,loopFocus:u,allowEscape:te,defaultFloatingId:N,setRenderedFloatingId:F,virtualFocus:T,parentVirtualFocus:se,syncHighlightedItem:Ke}),[U,j,f,u,te,N,T,se,Ke]),et=typeof t==`function`?t({payload:ve}):t,tt=(0,$.jsxs)(Nt.Provider,{value:$e,children:[b&&(0,$.jsx)(v,{handle:b,store:U}),et]});return(J.type===void 0||J.type===`context-menu`)&&(tt=(0,$.jsx)(W,{externalTree:le,children:tt})),tt});function Hn(e){let t=Q.useContext(Rn);if(t===null)return(0,$.jsx)(Vn,{...e});let n=t.Root;return(0,$.jsx)(Rn.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var Un=5;function Wn(e,t){let n=Gn(t);return e.clientX>=n.left-Un&&e.clientX<=n.right+Un&&e.clientY>=n.top-Un&&e.clientY<=n.bottom+Un}function Gn(e){let t=e.getBoundingClientRect(),n=it(e);if(Ge)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 Kn(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ut(),{ref:i,index:a}=Xt(e),o=n===a,s=Q.useRef(null),c=st(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 qn(e){let{render:t,className:n,style:r,state:i=m,props:a=I,refs:o=I,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Kn({metadata:s});return Y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Jn(e){if(Ce(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!qe(e))return Jn(Re(e))}function Yn(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Q.useRef(!1);return Q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Ie(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:m,[t,n,r])}var Xn=p(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,h=Pt(!0),g=ot(d)??h?.store;if(!g)throw Error(ht(85));let _=Ve(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Q.useRef(null),w=Qn(),T=ut(!0),E=Ye(),O=Q.useMemo(()=>E??new te,[E]),re=ee(O),ie=ne(),{registerTrigger:ae,isMountedByThisTrigger:oe}=b(_,C,g,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:re,floatingParentNodeId:ie,keyboardEventRelay:T?.relayKeyboardEvent}),k=w.type===`menubar`,A=g.useState(`disabled`),se=a||A||k&&w.context.disabled,{getButtonProps:j,buttonRef:M}=L({disabled:se,native:o});Q.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let N=Q.useRef(null),P=ft(),F=z(e=>{if(!N.current)return;P.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(N.current,t)||X(g.select(`positionerElement`),t)||t===N.current||(t==null||Jn(t)!==g.select(`rootId`))&&(Wn(e,N.current)||O.events.emit(`close`,{domEvent:e,reason:me}))});Q.useEffect(()=>{let e=Ie(N.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[x,F,g]);let I=k&&w.context.hasSubmenuOpen,R=Te(y,{enabled:(c??I)&&!se&&(!k||I&&!oe),handleClose:De({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),B=Zn(x,g.select(`lastOpenChangeReason`)),V=ce(y,{enabled:!se,event:x&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&B}),H=xt(y,{enabled:!se&&I}),U=Yn({open:x,enabled:k,mouseDownAction:`open`}),W=Q.useMemo(()=>de(H.reference,V.reference),[H.reference,V.reference]),le=g.useState(`triggerProps`,oe),ue=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:G,handleFocusTargetFocus:K}=tt(g,C),fe={disabled:se,open:x},pe=[N,t,M,ae,C],he=[W,R??m,le,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(P.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),Ie(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ue,k?{role:`menuitem`}:{},U,p,j],q=Y(`button`,e,{enabled:!k,stateAttributesMapping:D,state:fe,ref:pe,props:he});return k?(0,$.jsx)(qn,{tag:`button`,render:n,className:r,style:i,state:fe,refs:pe,props:he,stateAttributesMapping:D}):x?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(rt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:G},`${_}-pre-focus-guard`),(0,$.jsx)(Q.Fragment,{children:q},_),(0,$.jsx)(rt,{ref:g.context.triggerFocusTargetRef,onFocus:K},`${_}-post-focus-guard`)]}):(0,$.jsx)(Q.Fragment,{children:q},_)});function Zn(e,t){let n=ft(),[r,i]=Q.useState(!1);return A(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Qn(){let e=Mn(!0);return Q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var $n=Q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),er=(0,Q.createContext)(null);function tr({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Q.useRef)(null),o=e??a;return k(()=>o.current?.close()),(0,$.jsx)(er.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(Hn,{...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 nr(){let e=(0,Q.useContext)(er);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var rr=(0,Q.forwardRef)(function({className:e,render:t,type:n=`button`,...a},o){return(0,$.jsx)(Xn,{...a,className:t=>r(`btn caps-dropdown-trigger`,i(e,t)),ref:o,render:t,type:n})}),ir=(0,Q.forwardRef)(function({container:e,...t},n){let r=Fe(`popover`);return e==null&&r===null?null:(0,$.jsx)(Sn,{...t,container:e??r,ref:n})}),ar=(0,Q.forwardRef)(function({collisionBoundary:e,...t},n){let r=Fe(`popover`);return(0,$.jsx)(An,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),or=(0,Q.forwardRef)(function({className:e,finalFocus:t,...n},a){let{interactionOwner:o}=nr(),s=(0,Q.useRef)(null);(0,Q.useImperativeHandle)(a,()=>s.current);let c=J(`.caps-dropdown-item[data-highlighted]`),l=(0,Q.useCallback)(e=>{s.current=e,c(e)},[c]);return(0,$.jsx)(yn,{...n,className:t=>r(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,i(e,t)),finalFocus:o===`host`?!1:t??!0,ref:l})}),sr=(0,Q.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(ir,{container:r,keepMounted:i,children:(0,$.jsx)(ar,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(or,{...s,ref:c,children:n})})})}),cr=`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`,lr=(0,Q.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:a=`default`,...o},s){return(0,$.jsx)(un,{...o,className:t=>r(cr,a===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,i(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:s})}),ur=(0,Q.forwardRef)(function({children:e,className:t,onClick:n,onSelect:a,...o},s){return(0,$.jsxs)(tn,{...o,className:e=>r(cr,i(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||a?.(e)},ref:s,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(nn,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})}),dr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)($n,{...t,className:t=>r(`my-xs h-px bg-base-300`,i(e,t)),ref:n})}),fr=sn,pr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(cn,{...t,className:t=>r(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,i(e,t)),ref:n})});export{lr as a,rr as c,fr as i,yt as l,ur as n,pr as o,sr as r,dr as s,tr as t,vt as u};
|