@aperture-browser/session-element 0.0.0-nightly.100.78b4e7ef6edc → 0.0.0-nightly.101.c63f90ec6164
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.
|
@@ -19,11 +19,11 @@ Error generating stack: `+e.message+`
|
|
|
19
19
|
`)},yo=e=>uo(e).map(bo).join(`
|
|
20
20
|
`),bo=e=>e.cause?`${e.stack} {\n${xo(e.cause,` `)}\n}`:e.stack,xo=(e,t)=>{let n=e.stack.split(`
|
|
21
21
|
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${xo(e.cause,`${t} `)}\n${t}}`),r},So=`~effect/Fiber`,j={_A:x,_E:x},Co={id:0},wo=()=>globalThis[it],To=class{constructor(e,t=!0){this.setContext(e),this.id=++Co.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[So](){return j}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return Ur(this.context,e)}addObserver(e){return this._exit?(e(this._exit),ne):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=eo(e);this.cache.stackFrame&&(n=$t(n,Lr(ln,this.cache.stackFrame))),t&&(n=$t(n,t)),this._interruptedCause=this._interruptedCause?so(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(zo(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Ft)return;let n=ko.interruptChildren&&ko.interruptChildren(this);if(n!==void 0)return this.evaluate(Os(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=Fr()}runLoop(e){let t=globalThis[it];globalThis[it]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=zo(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Os(Ho,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[jt](this),i===Ft){let e=this._yielded;if(Ot in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Ft}}}catch(e){return D(i,jt)?this.runLoop(pn(e)):pn(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[it]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Do;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Pt];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&Oo-1))return cn(e);let t=this.getCont(Mt);return t?t[Mt](e,this):this.yieldWith(cn(e))}yieldWith(e){return this._yielded=e,Ft}children(){return this._children??=new Set}pipe(){return _(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Mr(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Eo(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Eo=e=>{let t=Vr(e,La);return{scheduler:Ur(e,ga),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:Ur(e,Ha),span:Vr(e,ja),logLevel:Ur(e,qa),minimumLogLevel:Ur(e,Ja),stackFrame:Ur(e,Va),runtimeMetrics:Vr(e,Ba),maxOpsBeforeYield:Ur(e,Ca),preventYield:Ur(e,wa)}},Do={[Mt](e,t){return zo(t._interruptedCause)},[Nt](e,t){return zo(t._interruptedCause)}},Oo=32,ko={interruptChildren:void 0},Ao=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(un.key,e.cache.stackFrame),Ar(t)},jo=e=>{if(!(e._children===void 0||e._children.size===0))return Lo(e._children)},Mo=e=>{let t=e;return t._exit?Ro(t._exit):es(n=>t._exit?n(Ro(t._exit)):Vo(e.addObserver(e=>n(Ro(e)))))},No=e=>es(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(Ro(r))}return a(),Vo(()=>i?.())}),Po=e=>{let t=e;return t._exit?t._exit:es(n=>t._exit?n(t._exit):Vo(e.addObserver(n)))},Fo=e=>mn(t=>Io(e,t.id)),Io=b(e=>D(e[0],So),(e,t,n)=>mn(r=>{let i=Ao(r);return i=i&&n?qr(i,n):i??n,e.interruptUnsafe(t,i),Ts(Mo(e))})),Lo=e=>mn(t=>{let n=Ao(t),r=ca();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Ts(No(r))}),Ro=cn,zo=dn,Bo=fn,Vo=on({op:`Sync`,[jt](e){let t=this[k](),n=e.getCont(Mt);return n?n[Mt](t,e):e.yieldWith(cn(t))}}),M=on({op:`Suspend`,[jt](e){return this[k]()}}),Ho=on({op:`Yield`,[jt](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Bs)},this[k]??0),e.yieldWith(()=>{t=!0})}})(0),Uo=Ro(or()),Wo=e=>M(()=>zo(e())),Go=e=>pn(e),Ko=e=>M(()=>Bo(e())),qo=Ro(void 0),Jo=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new uu(e,`An error occurred in Effect.try`):e.catch;return M(()=>{try{return Ro(t())}catch(e){return Bo(n(e))}})},Yo=e=>Qo(function(t,n){e(n).then(e=>t(Ro(e)),e=>t(Go(e)))},e.length!==0),Xo=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new uu(e,`An error occurred in Effect.tryPromise`):e.catch;return Qo(function(e,r){let i=t=>{try{e(Bo(wt(()=>n(t))))}catch(t){e(Go(t))}};try{t(r).then(t=>e(Ro(t)),i)}catch(e){i(e)}},t.length!==0)},Zo=e=>mn(t=>e(t.id)),Qo=function(){let e=an({op:`Async`,[jt](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e._yielded=()=>{t=!0},r===void 0&&i===void 0||e._stack.push($o(()=>(t=!0,r?.abort(),i??Bs))),Ft):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),$o=on({op:`AsyncFinalizer`,[Pt](e){e.interruptible&&(e.interruptible=!1,e._stack.push(ll))},[Nt](e,t){return ro(e)?Os(Pc(dn(e),this[k]()),()=>zo(e)):zo(e)}}),es=e=>Qo(e,e.length>=2),ts=es(ne),ns=(...e)=>{if(e.length===1){let t=e[0];return M(()=>us(t()))}let[t,n]=e;return M(()=>us(n.call(t.self)))},rs=(e,...t)=>{let n=t.length===0?function(){return M(()=>us(e.apply(this,arguments)))}:function(){let n=M(()=>us(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return is(e.length,n)},is=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),as=Za(2),os=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=xt(),i;return r!==0&&(St(2),i=new globalThis.Error,St(r)),e?(r,...a)=>ss(t,r,i,a,e,n):ss(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},ss=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self),s=`${e} (definition)`,c=n?as(()=>n.stack):te;return is(o.length,function(...t){let n=M(()=>{let e=o.apply(this,arguments);return Rt(e)?e:us(e)});for(let e=0;e<r.length;e++)n=r[e](n,...t);if(!Rt(n))return n;let l=xt(),u;return l!==0&&(St(2),u=new globalThis.Error,St(l)),qs(i?Zl(e,a,e=>Ql(n,e)):n,Va,t=>({name:e,stack:u?as(()=>u.stack):te,parent:{name:s,stack:c,parent:t}}))})},cs=(e,...t)=>is(e.length,t.length===0?function(){return ls(()=>e.apply(this,arguments))}:function(){let n=ls(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),ls=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return Ro(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}else if(i&&i._tag===`Failure`)return r.value;else{let n=!0;return M(()=>n?(n=!1,Os(r.value,e=>us(t,e))):M(()=>us(e())))}}}catch(e){return Go(e)}},us=function(){let e=an({op:`Iterator`,[Mt](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return Ro(r.value);if(!ks(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[jt](e){return this[Mt](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),ds=b(2,(e,t)=>new ms(e,hs,Ro(t))),fs=function(e){return e._stack.push(this),this[k]},ps=an({op:`OnSuccess`,[jt]:fs}),ms=function(e,t,n){this[k]=e,this[Mt]=t,this.payload=n};ms.prototype=ps;var hs=function(){return this.payload},gs=function(e,t){return t.succeedWith(this.payload)},_s=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as ~effect/Effect/stackProbe]`)===!0})(),vs=function(e,t){let n=this.payload;return t.succeedWith(_s?n(e):wt(()=>n(e)))},ys=function(e){let t=this.payload;return t(e)},bs=function(e){let t=this.payload;return new ms(t(e),gs,e)},xs=function(e){return new ms(this.payload,gs,e)},Ss=e=>Ms(e,sr),Cs=b(2,(e,t)=>new ms(e,Rt(t)?hs:ys,t)),ws=b(2,(e,t)=>new ms(e,Rt(t)?xs:bs,t)),Ts=e=>new ms(e,hs,Bs),Es=(e,t)=>mn(n=>{let r=new Set;return Zc(n,()=>r.size===0?void 0:Lo(r)),es(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=wl(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Ds=b(e=>Rt(e[1]),(e,t,n)=>Es([e,t],n)),Os=b(2,(e,t)=>new ms(e,ys,t)),ks=e=>e[Ot]!==void 0,As=b(2,(e,t)=>ks(e)?e._tag===`Success`?t(e.value):e:Os(e,t)),js=e=>Os(e,x),Ms=b(2,(e,t)=>new ms(e,vs,t)),Ns=b(2,(e,t)=>ks(e)?Vs(e,t):Ms(e,t)),Ps=b(2,(e,t)=>ks(e)?Hs(e,t):mc(e,t)),Fs=b(2,(e,t)=>ks(e)?Us(e,t):hc(e,t)),Is=e=>dn(eo(e)),Ls=e=>e._tag===`Success`,Rs=e=>e._tag===`Failure`,zs=e=>e._tag===`Failure`?Ni(e.cause):Pi(e),Bs=cn(void 0),Vs=b(2,(e,t)=>e._tag===`Success`?cn(t(e.value)):e),Hs=b(2,(e,t)=>{if(e._tag===`Success`)return e;let n=no(e.cause);return Ii(n)?e:fn(t(n.success))}),Us=b(2,(e,t)=>{if(e._tag===`Success`)return cn(t.onSuccess(e.value));let n=no(e.cause);return Ii(n)?e:fn(t.onFailure(n.success))}),Ws=b(2,(e,t)=>Ls(e)?t:e),Gs=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Bs:dn(Jt(t))},Ks=b(2,(e,t)=>mn(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Zc(n,()=>{n.setContext(r)}),e)})),qs=b(3,(e,t,n)=>Ks(e,e=>{let r=Hr(e,t),i=n(r);return r===i?e:Rr(e,t,i)})),Js=()=>Ys,Ys=mn(e=>Ro(e.context)),Xs=e=>mn(t=>e(t.context)),Zs=b(2,(e,t)=>ks(e)?e:Ks(e,qr(t))),Qs=function(){return arguments.length===1?b(2,(e,t)=>$s(e,arguments[0],t)):b(3,(e,t,n)=>$s(e,t,n)).apply(this,arguments)},$s=(e,t,n)=>Ks(e,Rr(t,n)),ec=b(2,(e,t)=>Os(t,t=>t?Ss(e):Uo)),tc=b(e=>Rt(e[0]),(e,t)=>hl({while:S,body:ee(t?.disableYield?e:Os(e,e=>Ho)),step:ne})),nc=b(2,(e,t)=>new ic(e,t.length===1?t:e=>t(e))),rc=an({op:`OnFailure`,[jt]:fs}),ic=function(e,t){this[k]=e,this[Nt]=t};ic.prototype=rc;var ac=b(3,(e,t,n)=>nc(e,e=>{let r=t(e);return Ii(r)?zo(r.failure):n(r.success,e)})),oc=b(2,(e,t)=>ac(e,no,e=>t(e))),sc=b(3,(e,t,n)=>nc(e,e=>{let r=t(e);return Ii(r)?zo(e):Cs(n(r.success,e),zo(e))})),cc=b(2,(e,t)=>sc(e,no,e=>t(e))),lc=b(e=>Rt(e[0]),(e,t,n,r)=>nc(e,e=>{let i=no(e);return Ii(i)?zo(i.failure):t(i.success)?n(i.success):r?r(i.success):zo(e)})),uc=b(e=>Rt(e[0]),(e,t,n,r)=>nc(e,e=>{let i=no(e);if(Ii(i))return zo(i.failure);let a=t(i.success);return Ii(a)?r?r(a.failure):zo(e):n(a.success)})),dc=b(e=>Rt(e[0]),(e,t,n,r)=>lc(e,Array.isArray(t)?e=>D(e,`_tag`)&&t.includes(e._tag):ve(t),n,r)),fc=b(e=>Rt(e[0]),(e,t,n)=>{let r;return uc(e,e=>(r??=Object.keys(t),D(e,`_tag`)&&ce(e._tag)&&r.includes(e._tag)?Ni(e):Pi(e)),e=>t[e._tag](e),n)}),pc=b(e=>Rt(e[0]),(e,t,n,r)=>{let i;return lc(e,e=>ve(e,t)&&D(e,`reason`)&&D(e.reason,`_tag`)&&ce(e.reason._tag)&&(r!==void 0||(i??=Object.keys(n)).includes(e.reason._tag)),e=>{let t=e.reason;return i??=Object.keys(n),i.includes(t._tag)?n[t._tag](t,e):r?r(t,e):Bo(e)})}),mc=b(2,(e,t)=>oc(e,e=>Ko(()=>t(e)))),hc=b(2,(e,t)=>Cc(e,{onFailure:e=>Ko(()=>t.onFailure(e)),onSuccess:e=>Vo(()=>t.onSuccess(e))})),gc=b(2,(e,t)=>oc(e,e=>Vo(()=>t(e)))),_c=b(e=>Rt(e[0]),(e,t)=>{if(!t?.log)return Cc(e,{onFailure:e=>qo,onSuccess:e=>qo});let n=yu(t.log===!0?void 0:t.log);return vc(e,{onFailure(e){let r=to(e);return Ii(r)?zo(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>qo})}),vc=b(2,(e,t)=>new bc(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),yc=an({op:`OnSuccessAndFailure`,[jt]:fs}),bc=function(e,t,n){this[k]=e,this[Mt]=t,this[Nt]=n};bc.prototype=yc;var xc=function(e,t){let n=this.payload;return t.succeedWith(_s?n.onSuccess(e):wt(()=>n.onSuccess(e)))},Sc=((e,t)=>{let n=an({op:e,[jt]:fs,[Mt]:xc,[Nt]:t}),r=function(e,t){this[k]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(en);if(n===void 0)return zo(e);let r=this.payload;return t.succeedWith(_s?r.onFailure(n.error):wt(()=>r.onFailure(n.error)))}),Cc=b(2,(e,t)=>vc(e,{onFailure:e=>{let n=e.reasons.find(en);return n?t.onFailure(n.error):zo(e)},onSuccess:t.onSuccess})),wc=b(2,(e,t)=>new Sc(e,t)),Tc=e=>ks(e)?cn(e):Ec(e),Ec=on({op:`Exit`,[jt](e){return e._stack.push(this),this[k]},[Mt](e,t,n){return t.succeedWith(n??cn(e))},[Nt](e,t,n){return t.succeedWith(n??dn(e))}}),Dc=b(2,(e,t)=>Cs(ou(t),e)),Oc=`~effect/Scope`,kc=`~effect/Scope/Closeable`,Ac=_r(`effect/Scope`),jc=(e,t)=>mn(n=>{let r=Mc(e,t);return r===void 0?qo:(fl(n),r)}),Mc=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Bc(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Nc(n.finalizer,t);let r=n.finalizers;return r.size===1?Nc(r.values().next().value,t):Fc(e,r,t)},Nc=(e,t)=>{try{return e(t)}catch(e){return pn(e)}},Pc=(e,t)=>Ls(e)?t:nc(t,t=>zo(so(e.cause,t))),Fc=rs(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=wo();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*Tc(Nc(s,n))):i.push(wl(o,Nc(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*No(i)),yield*Gs(r)}),Ic=(e,t)=>{let n=Hc(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(zc(e,n,e=>jc(n,e)),n)},Lc=(e,t)=>M(()=>e.state._tag===`Closed`?t(e.state.exit):(zc(e,{},t),qo)),Rc=(e,t)=>Lc(e,ee(t)),zc=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},Bc=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=Uc:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=Uc))},Vc=e=>Hc(e,void 0),Hc=(e=`sequential`,t)=>({[kc]:kc,[Oc]:Oc,strategy:e,parent:t,state:Uc}),Uc={_tag:`Empty`},Wc=Ac,Gc=Qs(Ac),Kc=e=>mn(t=>{let n=t.context,r=Vc();return t.setContext(Rr(t.context,Ac,r)),Zc(t,e=>(t.setContext(n),Mc(r,e))),e}),qc=(e,t,n)=>Xs(r=>ml(i=>Os(Wc,a=>ws(n?.interruptible?i(e):e,e=>Lc(a,n=>Zs(t(e,n),r)))))),Jc=e=>Os(Wc,t=>Xs(n=>Lc(t,t=>Zs(e(t),n)))),Yc=function(){let e=an({op:`OnExit`,[jt](e){return e._stack.push(this),this.effect},[Pt](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(ll),e.interruptible=!1)},[Mt](e,t,n){n??=cn(e);let r;try{r=this.onExit(n)}catch(e){r=pn(e)}return r?Os(r,e=>n):n},[Nt](e,t,n){n??=dn(e);let r;try{r=this.onExit(n)}catch(e){r=pn(e)}return r?Os(Pc(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Xc=(e,t,n)=>new Yc(e,t,n),Zc=(e,t)=>{e._stack.push(new Yc(void 0,t,void 0))},Qc=b(2,Xc),$c=b(2,(e,t)=>Qc(e,e=>t)),el=b(3,(e,t,n)=>Qc(e,e=>{let r=t(e);return Ii(r)?qo:n(r.success,e)})),tl=b(2,(e,t)=>el(e,zs,t)),nl=b(3,(e,t,n)=>Qc(e,e=>{if(e._tag!==`Failure`)return qo;let r=t(e.cause);return Ii(r)?qo:n(r.success,e.cause)})),rl=b(2,(e,t)=>nl(io,t)(e)),il=(e,t,n)=>ml(r=>Os(e,e=>Xc(M(()=>r(t(e))),t=>n(e,t),!0))),al=e=>Vo(()=>{let t=Hl(!1),n=!1,r,i=Os(t.await,()=>r);return mn(a=>r===void 0?n?i:(n=!0,Zc(a,e=>Vo(()=>{r=e,t.openUnsafe()})),e):r)}),ol=mn(e=>zo(eo(e.id))),sl=e=>mn(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ll),e):e),cl=on({op:`SetInterruptible`,[Pt](e){if(e.interruptible=this[k],e._interruptedCause&&e.interruptible)return()=>zo(e._interruptedCause)}}),ll=cl(!0),ul=cl(!1),dl=e=>{if(e.interruptible=!0,e._stack.push(ul),e._interruptedCause)return zo(e._interruptedCause)},fl=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(ll))},pl=e=>mn(t=>t.interruptible?e:dl(t)??e),ml=e=>mn(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ll),e(pl)):e(x)),hl=on({op:`While`,[Mt](e,t){return this[k].step(e),this[k].while()?(t._stack.push(this),this[k].body()):Bs},[jt](e){return this[k].while()?(e._stack.push(this),this[k].body()):Bs}}),gl=b(e=>typeof e[1]==`function`,(e,t,n)=>M(()=>{let r=vl(n?.concurrency);if(r===1)return _l(e,t,n);let i=Yi(e),a=i.length;if(a===0)return n?.discard?qo:Ro([]);let o=n?.discard?void 0:Array(a),s=Sl({f:t,out:o},i,{concurrency:r});return s?ds(s,o):Ro(o)})),_l=(e,t,n)=>M(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return ds(hl({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),vl=e=>e===`unbounded`?1/0:Math.max(1,e??1),yl=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Os(Tc(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??qo),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!ks(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},bl=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=pn(e);return f=t,c=!0,u&&u.size>0?Os(sl(Lo(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(ks(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=wl(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=Jt(e);f=dn(f._tag===`Failure`?so(f.cause,t):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??qo)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return es(e=>{l=wo(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):M(()=>(f??=Bs,Os(u?Lo(u):qo,()=>f?._tag===`Failure`?f:qo)))})}if(c=!0,f){if(u&&u.size>0){let e=Ao(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d)if(u)u.size===0&&d(qo);else return Bs};return h()}},xl=()=>e=>bl(e),Sl=bl({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Cl=b(e=>Rt(e[0]),(e,t)=>mn(n=>(wu(),Ro(wl(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),wl=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new To(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s._parent=a),s},Tl=b(e=>Rt(e[0]),(e,t,n)=>mn(r=>{let i=wl(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!i._exit)if(t.state._tag!==`Closed`){let e={};zc(t,e,()=>Zo(e=>e===i.id?qo:Fo(i))),i.addObserver(()=>Bc(t,e))}else i.interruptUnsafe(r.id,Ao(r));return Ro(i)})),El=e=>(t,n)=>{let r=new To(n?.scheduler?Rr(e,ga,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal)if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}return n?.onFiberStart&&n.onFiberStart(r),r},Dl=b(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return zc(t,n,()=>Fo(e)),e.addObserver(()=>Bc(t,n)),e}),Ol=El(Fr()),kl=e=>{let t=El(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},Al=kl(Fr()),jl=e=>{let t=El(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Ml=jl(Fr()),Nl=e=>{let t=jl(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw lo(e.cause);return e.value})},Pl=Nl(Fr()),Fl=e=>{let t=El(e);return e=>{if(ks(e))return e;let n=new xa(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??pn(new cu(r))}},Il=Fl(Fr()),Ll=e=>{let t=Fl(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw lo(n.cause);return n.value}},Rl=Ll(Fr()),zl=Ro(!0),Bl=Ro(!1),Vl=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return zl;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],zl}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Bs)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Bs)}open=mn(e=>this._isOpen?Bl:(this._isOpen=!0,this.scheduleUnsafe(e)));release=mn(e=>this._isOpen?Bl:this.scheduleUnsafe(e));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=es(e=>this._isOpen?e(qo):(this.waiters.push(e),Vo(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=Vo(()=>this.closeUnsafe());whenOpen=e=>Os(this.await,()=>e);isOpen(){return this._isOpen}},Hl=e=>new Vl(e??!1),Ul=e=>Vo(()=>Hl(e)),Wl=BigInt(0),Gl={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:Wl,endTime:Wl,exit:Bs},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},Kl=e=>Object.assign(Object.create(Gl),e),ql=e=>e?Ur(e.annotations,Pa)?e._tag===`Span`?ql(pr(e.parent)):or():sr(e):or(),Jl=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&Ur(n.annotations,Pa),i=n?.parent===void 0?n?.root?or():ql(e.cache.span):sr(n.parent),a;if(r)a=Kl({name:t,parent:i,annotations:Rr(n?.annotations??Fr(),Pa,!0)});else{let r=e.cache.tracer??Ra,o=e.getRef(N),s=e.getRef(Ua),c=e.getRef(Wa),l=e.getRef(Ga),u=n?.level??e.getRef(Fa),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??Fr(),links:d,startTime:s?o.currentTimeNanosUnsafe():Wl,kind:n?.kind??`internal`,root:n?.root??cr(i),sampled:n?.sampled??(lr(i)&&i.value.sampled===!1?!1:!fu(e.getRef(Ia),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},Yl=(e,t)=>(t=typeof t==`function`?t:te,qs(Va,n=>({name:e,stack:t,parent:n}))),Xl=(e,t,n,r)=>Vo(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():Wl,t)}),Zl=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return mn(t=>{let i=Jl(t,e,n),a=t.getRef(N),o=t.getRef(Ua);return Zc(t,e=>Xl(i,e,a,o)),r(i)})},Ql=Qs(Ma),$l=function(){let e=Rt(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=Xa(n),r=Yl(t.name,n?.captureStackTrace)),e?Ql(r(arguments[0]),t):e=>Ql(r(e),t)},N=Yr(`effect/Clock`,{defaultValue:()=>new tu}),eu=2**31-1,tu=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Vo(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iu()}currentTimeNanos=Vo(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return ru()}monotonicTimeNanos=Vo(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(wi(e))}sleepMillis(e){return e<=0?Ho:Number.isFinite(e)?es(t=>{let n=e>eu?this.sleepMillis(e-eu):qo,r=setTimeout(()=>t(n),Math.min(e,eu));return Vo(()=>clearTimeout(r))}):ts}},nu=BigInt(1e6),ru=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*nu;return e>t&&(t=e),t}}(),iu=function(){let e=BigInt(1e9),t;return()=>{let n=ru(),r=BigInt(Date.now())*nu;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),au=e=>mn(t=>e(t.getRef(N))),ou=e=>au(t=>t.sleep(oi(e)));_n(`TimeoutError`),_n(`IllegalArgumentError`),_n(`ExceededCapacityError`);var su=`~effect/Cause/AsyncFiberError`,cu=class extends _n(`AsyncFiberError`){[su]=su;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},lu=`~effect/Cause/UnknownError`,uu=class extends _n(`UnknownError`){[lu]=lu;constructor(e,t){super({message:t,cause:e})}},du=Yr(`effect/Console`,{defaultValue:()=>globalThis.console}),fu=rr(tr(er,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),pu=Yr(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([Su,Cu])}),mu=Yr(`effect/Logger/LogToStderr`,{defaultValue:C}),hu={"~effect/Logger":{_Message:x,_Output:x},pipe(){return _(this,arguments)}},gu=e=>{let t=Object.create(hu);return t.log=e,t},_u=e=>e.replace(/[\s="]/g,`_`),vu=(e,t)=>`${_u(e[0])}=${t-e[1]}ms`,yu=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];Ht(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?Jt(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=Yt),mn(r=>{let i=e??r.cache.logLevel;if(fu(r.cache.minimumLogLevel,i))return qo;let a=r.getRef(N),o=r.getRef(pu);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return qo})},bu={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};bu.gray,bu.blue,bu.green,bu.yellow,bu.red,bu.bgBrightRed,bu.black;var xu=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Su=gu(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(yo(e));let o=t.getTime(),s=n.getRef(Ya),c=``;for(let e of s)c+=` ${vu(e,o)}`;let l=n.getRef(Ka);Object.keys(l).length>0&&a.push(l);let u=n.getRef(du);(n.getRef(mu)?u.error:u.log)(`[${xu(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Cu=gu(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(N),a=t.getRef(Ka),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))Tt(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=yo(e)),o.event(_t(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)});function wu(){ko.interruptChildren??=jo}var Tu=cn,Eu=dn,Du=fn,Ou=Bs,ku=Ls,Au=Rs,ju={"~effect/Deferred":{_A:x,_E:x},pipe(){return _(this,arguments)}},Mu=function(){this.resumes=void 0,this.effect=void 0};Mu.prototype=ju;var Nu=()=>new Mu,Pu=e=>es(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Vo(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),Fu=b(2,(e,t)=>Vo(()=>Ru(e,t))),Iu=b(2,(e,t)=>Fu(e,dn(t))),Lu=b(2,(e,t)=>Iu(e,eo(t))),Ru=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},zu=b(2,(e,t)=>ml(n=>Os(Tc(n(e)),e=>Fu(t,e)))),Bu=Ac,Vu=Vc,Hu=Gc,Uu=Lc,Wu=Rc,Gu=Ic,Ku=jc,qu=`~effect/Layer`,Ju=`~effect/Layer/MemoMap`,Yu=(e,t)=>{let n={observers:0,deferred:Nu(),scope:Vu(),finalizer:r=>M(()=>--n.observers>0?qo:(e.map.delete(t),Ku(n.scope,r)))};return n},Xu=(e,t)=>t.state._tag===`Closed`?!1:(e.observers++,zc(t,{},e.finalizer),!0),Zu={[qu]:{_ROut:x,_E:x,_RIn:x},pipe(){return _(this,arguments)}},Qu=e=>{let t=Object.create(Zu);return t.build=e,t},$u=e=>Qu((t,n)=>{let r=Gu(n);return Qc(e(t,r),e=>e._tag===`Failure`?Ku(r,e):qo)}),ed=e=>{let t=$u((n,r)=>n.getOrElseMemoize(t,r,e));return t},td=class{get[Ju](){return Ju}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(Xu(n,t),n.deferred.effect??Pu(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return M(()=>{let r;return Xc(M(()=>{let i=this.get(e,t);if(i)return i;let a=Yu(this,e);return Xu(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&Ru(r,e)})})}},nd=()=>new td,rd=e=>new td(e),id=class e extends _r()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=Br(t,e);return n?rd(n):nd()}},ad=b(3,(e,t,n)=>Qs(Ms(e.build(t,n),Rr(id,t)),id,t)),od=function(){return arguments.length===1?e=>sd(Lr(arguments[0],e)):sd(Lr(arguments[0],arguments[1]))},sd=e=>Qu(ee(Ro(e))),cd=sd(Fr()),ld=function(){return arguments.length===1?e=>ud(arguments[0],e):ud(arguments[0],arguments[1])},ud=(e,t)=>dd(Ms(t,t=>Lr(e,t))),dd=e=>ed((t,n)=>Hu(e,n)),fd=(e,t,n)=>{let r=Gu(n,`parallel`);return gl(e,e=>e.build(t,Gu(r,`sequential`)),{concurrency:e.length}).pipe(Ms(e=>Jr(...e)))},pd=(...e)=>$u((t,n)=>fd(e,t,n)),md=(e,t,n)=>$u((r,i)=>Os(Array.isArray(t)?fd(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Zs(t),Ms(e=>n(e,t))))),hd=b(2,(e,t)=>md(e,t,x)),gd=b(2,(e,t)=>md(e,t,(e,t)=>qr(t,e))),_d=en,vd=Jt,yd=Qt,bd=ao,xd=co,Sd=lo,Cd=no,wd=ro,Td=io,Ed=yn,Dd=Cn;_r()(`effect/Cause/StackTrace`),_r()(`effect/Cause/InterruptorStackTrace`);var Od=`~effect/DateTime`,kd=`~effect/DateTime/TimeZone`,Ad={[Od]:Od,pipe(){return _(this,arguments)},[ht](){return this.toString()},toJSON(){return Md(this).toJSON()}};({...Ad}),{...Ad};var jd={[kd]:kd,[ht](){return this.toString()}};({...jd}),{...jd};var Md=e=>new Date(e.epochMilliseconds),Nd=Yr(`effect/Random`,{defaultValue:()=>({nextIntUnsafe(){return Math.floor(Math.random()*(2**53-1- -(2**53-1)+1))+-(2**53-1)},nextDoubleUnsafe(){return Math.random()}})}),Pd=b(2,(e,t)=>ac(e,Rd,e=>t(e))),Fd=e=>e.reasons.some(Id),Id=e=>e._tag===`Fail`&&Ed(e.error),Ld=e=>{let t,n=!1;for(let r of e.reasons)Id(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Pi(e):n?Pi(vd(e.reasons.filter(e=>!Id(e)))):Ni(t)},Rd=e=>{let t=Ld(e);return Ii(t)?t:Ni(t.success.value)},zd=e=>{let t=Ld(e);return Ii(t)?Eu(t.failure):Tu(t.success.value)},Bd=b(2,(e,t)=>vc(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=Ld(e);return Ii(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),Vd=`~effect/Schedule`,Hd=Yr(`effect/Schedule/CurrentMetadata`,{defaultValue:ee({input:void 0,output:void 0,duration:mi,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),Ud={[Vd]:{_Out:x,_In:x,_Env:x},pipe(){return _(this,arguments)}},Wd=e=>D(e,Vd),Gd=e=>{let t=Object.create(Ud);return t.step=e,t},Kd=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},qd=e=>Gd(Ms(e,e=>{let t=Kd();return(n,r)=>e(t(n,r))})),Jd=e=>nc(e.step,e=>Ro(()=>zo(e))),Yd=e=>au(t=>Ms(Jd(e),e=>{let n=Kd();return r=>M(()=>{let i=t.currentTimeMillisUnsafe();return Os(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,ds(ou(t),a)})})})),Xd=e=>Gd(Ms(Jd(e),e=>(t,n)=>Bd(e(t,n),{onSuccess:e=>Ro([n,e[1]]),onFailure:zo,onDone:()=>Dd(n)}))),Zd=e=>{let t=oi(e);return qd(Ro(e=>Ro([e.attempt-1,t])))},Qd=b(2,(e,t)=>Gd(Ms(Jd(e),e=>{let n=Kd();return(r,i)=>Os(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return Os(Rt(s)?s:Ro(s),t=>t?Ro(e):Dd(a))})}))),$d=Zd(mi),ef=b(3,(e,t,n)=>Os(Yd(t),t=>{let r=Hd.defaultValue();return oc(tc(ws(Os(M(()=>Qs(e,Hd,r)),t),e=>Vo(()=>{r=e})),{disableYield:!0}),e=>yn(e)?Ro(e.value):n(e,r.attempt===0?or():sr(r)))})),tf=b(2,(e,t)=>ef(e,typeof t==`function`?t(x):Wd(t)?t:rf(t),Bo)),nf=Xd($d),rf=e=>{let t=e.schedule?Xd(e.schedule):nf;return e.while&&(t=Qd(t,({input:t})=>{let n=e.while(t);return Rt(n)?n:Ro(n)})),e.until&&(t=Qd(t,({input:t})=>{let n=e.until(t);return Rt(n)?Ms(n,e=>!e):Ro(!n)})),e.times!==void 0&&(t=Qd(t,({attempt:t})=>Ro(t<=e.times))),t},af=gl,of=hl,sf=Yo,cf=Xo,P=Ro,lf=M,F=Vo,uf=qo,df=es,ff=ts,pf=ns,I=Bo,mf=zo,hf=Wo,gf=Go,_f=Jo,vf=Ho,yf=mn,L=Os,bf=js,xf=Cs,Sf=ws,Cf=Tc,R=Ms,wf=ds,Tf=Ss,Ef=Ts,Df=oc,Of=dc,kf=fc,Af=pc,jf=nc,Mf=cc,Nf=_c,Pf=gc,Ff=Dc,If=ou,Lf=Ds,Rf=ec,zf=wc,Bf=vc,Vf=Js,Hf=Xs,Uf=Zs,Wf=Ks,Gf=Qs,Kf=Kc,qf=qc,Jf=il,Yf=Jc,Xf=$c,Zf=tl,Qf=Qc,$f=al,ep=ol,tp=rl,np=sl,rp=ml,ip=tc,ap=tf,op=Zl,sp=$l,cp=Cl,lp=Tl,up=Ol,dp=El,fp=kl,pp=Al,mp=Pl,hp=Nl,gp=Ml,_p=jl,vp=Rl,yp=Ll,bp=Il,xp=Fl,Sp=rs,z=os;_r()(`effect/Effect/Transaction`);var Cp=Ns,wp=Ps,Tp=Fs,Ep=As,Dp=cs,Op=Mo,kp=Po,Ap=Fo,jp=Lo,Mp=Dl,Np=Hl,Pp=Ul,Fp=`~effect/MutableRef`,Ip={[Fp]:Fp,...It,toJSON(){return{_id:`MutableRef`,current:gt(this.current)}}},Lp=e=>{let t=Object.create(Ip);return t.current=e,t},Rp=b(2,(e,t)=>(e.current=t,e)),zp=Symbol.for(`effect/MutableList/Empty`),Bp=()=>({head:void 0,tail:void 0,length:0}),Vp=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},Hp=()=>({array:[],mutable:!0,offset:0,next:void 0}),Up=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=Hp(),e.tail=e.tail.next):e.head=e.tail=Hp(),e.tail.array.push(t),e.length++},Wp=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||=e.head,e.length++},Gp=e=>{e.head=e.tail=void 0,e.length=0},Kp=(e,t)=>{if(t=ji(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return Gp(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?Gp(e):Vp(e),n;i=i.next}return Gp(e),n},qp=e=>Kp(e,e.length),Jp=e=>{if(!e.head)return zp;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Gp(e):Vp(e),t},Yp=(e,t)=>{let n=[],r=e.head,i=0;for(;r;){for(let e=r.offset;e<r.array.length;e++)t(r.array[e],i++)&&n.push(r.array[e]);r=r.next}if(n.length===0){Gp(e);return}e.head=e.tail={array:n,mutable:!0,offset:0,next:void 0},e.length=n.length},Xp=(e,t)=>Yp(e,e=>e!==t),Zp=`~effect/PubSub`,Qp=`~effect/PubSub/Subscription`,$p=e=>F(()=>gm(e.atomicPubSub(),new Map,Vu(),Np(!1),Lp(!1),e.strategy(),Lp(or()))),em=e=>$p({atomicPubSub:()=>tm(e),strategy:()=>new _m}),tm=e=>{let t=e?.replay;return new fm(t&&t>0?new bm(Math.ceil(t)):void 0)},nm=b(2,(e,t)=>lf(()=>e.shutdownFlag.current||lr(e.ended.current)?P(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),P(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag))),rm=b(2,(e,t)=>e.shutdownFlag.current||lr(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),im=e=>np(Hf(t=>{let n=Ur(t,Bu),r=Gu(e.scope),i=dm(e.pubsub,e.subscribers,e.strategy,e.ended);return Wu(r,am(i)).pipe(xf(Uu(n,e=>Ku(r,e))),wf(i))})),am=e=>np(yf(t=>(Rp(e.shutdownFlag,!0),af(qp(e.pollers),e=>Lu(e,t.id),{discard:!0,concurrency:`unbounded`}).pipe(Sf(()=>F(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),Rf(e.shutdownHook.open),Ef)))),om=e=>lf(function t(n){if(e.shutdownFlag.current)return ep;let r=e.pollers.length===0?e.subscription.pollUpTo(1/0):[];return n&&(r=n.concat(r)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?P(e.replayWindow.takeAll().concat(r)):Qi(r)?P(r):L(sm(e),e=>t([e]))}),sm=e=>df(t=>{if(e.shutdownFlag.current)return t(ep);if(lr(e.ended.current))return t(P(e.ended.current.value));let n=Nu(),r=e.subscribers.get(e.subscription);return r||(r=new Set,e.subscribers.set(e.subscription,r)),r.add(e.pollers),Up(e.pollers,n),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),n.effect?t(n.effect):(n.resumes=[t],F(()=>Xp(e.pollers,n)))}),cm=Symbol.for(`effect/PubSub/AbsentValue`),lm=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)},um=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.delete(n),r.size===0&&e.delete(t)},dm=(e,t,n,r)=>new mm(e,t,e.subscribe(),Bp(),Np(!1),Lp(!1),n,e.replayWindow(),r),fm=class{publisherHead={value:cm,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=2**53-1;replayBuffer;constructor(e){this.replayBuffer=e}replayWindow(){return this.replayBuffer?new xm(this.replayBuffer):Sm}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(e){let t=this.replayBuffer?.offer(e),n=this.publisherTail.subscribers;if(n!==0){let r={value:e,replayIndex:t,subscribers:n,next:null};this.publisherTail.next=r,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(e){if(this.publisherTail.subscribers!==0)for(let t of e)this.publish(t);else this.replayBuffer&&this.replayBuffer.offerAll(e);return[]}slide(){if(this.publisherHead!==this.publisherTail){let e=this.publisherHead.next,t=e.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=cm,this.subscribersIndex+=1,this.replayBuffer?.slide(t,e.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new pm(this,this.publisherTail,this.publisherIndex,!1)}},pm=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(e,t,n,r){this.self=e,this.subscriberHead=t,this.subscriberIndex=n,this.unsubscribed=r}isEmpty(){if(this.unsubscribed)return!0;let e=!0,t=!0;for(;t;)this.subscriberHead===this.self.publisherTail?t=!1:this.subscriberHead.next.value===cm?(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1):(e=!1,t=!1);return e}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return zp;let e=!0,t=zp;for(;e;)if(this.subscriberHead===this.self.publisherTail)e=!1;else{let n=this.subscriberHead.next.value;n!==cm&&(t=n,--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=cm,this.self.subscribersIndex+=1),e=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return t}pollUpTo(e){e=ji(e);let t=[],n=0;for(;n!==e;){let r=this.poll();r===zp?n=e:(t.push(r),n+=1)}return t}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,--this.self.publisherTail.subscribers;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==cm&&(--this.subscriberHead.subscribers,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=cm,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},mm=class{[Qp]={_A:x};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(e,t,n,r,i,a,o,s,c){this.pubsub=e,this.subscribers=t,this.subscription=n,this.pollers=r,this.shutdownHook=i,this.shutdownFlag=a,this.strategy=o,this.replayWindow=s,this.ended=c}pipe(){return _(this,arguments)}},hm=class{[Zp]={_A:x};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(e,t,n,r,i,a,o){this.pubsub=e,this.subscribers=t,this.scope=n,this.shutdownHook=r,this.shutdownFlag=i,this.strategy=a,this.ended=o}pipe(){return _(this,arguments)}},gm=(e,t,n,r,i,a,o)=>new hm(e,t,n,r,i,a,o),_m=class{get shutdown(){return uf}handleSurplus(e,t,n,r){return P(!1)}onPubSubEmptySpaceUnsafe(e,t){}completePollersUnsafe(e,t,n,r){return vm(this,e,t,n,r)}completeSubscribersUnsafe(e,t){return ym(this,e,t)}},vm=(e,t,n,r,i)=>{let a=!0;for(;a&&!r.isEmpty();){let o=Jp(i);if(o===zp)um(n,r,i),i.length===0?a=!1:lm(n,r,i);else{let a=r.poll();a===zp?Wp(i,o):(Ru(o,Tu(a)),e.onPubSubEmptySpaceUnsafe(t,n))}}},ym=(e,t,n)=>{for(let[r,i]of n)for(let a of i)e.completePollersUnsafe(t,n,r,a)},bm=class{capacity;head={value:cm,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(e){this.capacity=e}slide(e,t){this.slideValues[this.index%this.capacity]={value:e,index:t},this.index++}offer(e){let t=this.publisherIndex++;return this.tail.value=e,this.tail.index=t,this.tail.next={value:cm,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,t}offerAll(e){for(let t of e)this.offer(t)}},xm=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(e){this.buffer=e,this.remaining=e.size,this.slideIndex=e.index,this.values=Array(this.remaining);let t=e.head;for(let e=0;e<this.remaining;e++)this.values[e]=t.value,this.newestIndex=t.index,t=t.next}close(){this.values.length=0,this.remaining=0}sync(){let e=this.buffer.index-this.slideIndex;if(e===0||this.remaining===0)return;let t=Math.min(e,this.buffer.capacity),n=this.buffer.index-t;for(let e=0;e<t;e++){let t=this.buffer.slideValues[(n+e)%this.buffer.capacity];t.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=t.value,this.newestIndex=t.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let e=this.values[this.index];return this.values[this.index]=cm,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),e}takeN(e){e=ji(e);let t=Math.min(e,this.remaining),n=Array(t);for(let e=0;e<t;e++)n[e]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},Sm={remaining:0,take:()=>void 0,takeN:()=>[],takeAll:()=>[],close:()=>void 0},Cm=`~effect/Queue`,wm=`~effect/Queue/Enqueue`,Tm=`~effect/Queue/Dequeue`,Em={_A:x,_E:x},Dm={[Cm]:Em,[wm]:Em,[Tm]:Em,...It,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:Rm(this)}}},Om=e=>mn(t=>{let n=Object.create(Dm);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=Bp(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},Ro(n)}),km=e=>Om({capacity:e}),Am=b(2,(e,t)=>M(()=>jm(e,t)?Bm:e.state._tag===`Open`&&e.strategy===`suspend`?qm(e,t):zm)),jm=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(Jp(e.messages),Up(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(Up(e.messages,t),Um(e),!0):!1:(Up(e.messages,t),Wm(e),!0):!1,Mm=b(2,(e,t)=>Vo(()=>Nm(e,t))),Nm=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=Ws(dn(t),Vm);return e.state.offers.size===0&&e.messages.length===0?(Qm(e,n),!0):(e.state={...e.state,_tag:`Closing`,exit:n},Wm(e),!0)},Pm=e=>Vo(()=>Fm(e)),Fm=e=>{if(e.state._tag===`Done`)return!1;Gp(e.messages);let t=e.state.offers;Qm(e,e.state._tag===`Open`?Hm:e.state.exit);for(let e of t)Ym(e);return!0},Im=e=>M(()=>Lm(e)??Cs(Km(e,()=>Gm(e,1)),Im(e))),Lm=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=Jp(e.messages);return Zm(e),cn(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=Xm(e.state.offers);return Zm(e),cn(t)}},Rm=e=>e.state._tag===`Done`?0:e.messages.length,zm=cn(!1),Bm=cn(!0),Vm=fn(xn()),Hm=Is(),Um=e=>{if(!(e.state._tag===`Done`||e.state.takers.size===0)){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(Bs),e.messages.length===0))break}},Wm=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,Um(e)},0))},Gm=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,Km=(e,t)=>es(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(Bs);let r={ready:t,resume:n};return e.state.takers.add(r),Vo(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),qm=(e,t)=>es(n=>jm(e,t)?n(Bm):Jm(e,{_tag:`Single`,message:t,resume:n})),Jm=(e,t)=>{if(e.state._tag!==`Open`)return Ym(t);let n=e.state.offers;return n.add(t),Vo(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&Qm(e,e.state.exit))})},Ym=e=>e._tag===`Single`?e.resume(zm):e.resume(cn(e.remaining.slice(e.offset))),Xm=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(Bm),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(cn([]))),n},Zm=e=>{if(e.state._tag===`Done`)return Fd(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0?(Qm(e,e.state.exit),Fd(e.state.exit.cause)):!1;for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)Up(e.messages,t.message),e.state.offers.delete(t),t.resume(Bm);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;Up(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(cn([]))}}return!1},Qm=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},$m=e=>new th(e),eh=(e,t,n)=>es(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),Vo(()=>{e.waiters.delete(i)})}),th=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=M(()=>this.free<e?eh(this,e,t):(this.taken+=e,Ro(e)));return t}takeIfAvailable(e){return M(()=>this.free<e?Ro(!1):(this.taken+=e,Ro(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return mn(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),qo))}release(e){return mn(t=>Ro(this.releaseUnsafe(t,e)))}get releaseAll(){return mn(e=>Ro(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>ml(n=>{let r=M(()=>this.free<e?Os(n(eh(this,e,qo)),()=>r):(this.taken+=e,Xc(n(t),()=>{this.releaseUnsafe(wo(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ml(n=>this.free<e?Uo:(this.taken+=e,Xc(n(Ss(t)),()=>{this.releaseUnsafe(wo(),e)},!0)))}},nh=`~effect/Channel`,rh=e=>D(e,nh),ih={[nh]:{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return _(this,arguments)}},ah=e=>{let t=Object.create(ih);return t.transform=(t,n)=>jf(e(t,n),e=>P(mf(e))),t},oh=(e,t)=>ah((n,r)=>L(lh(e)(n,r),e=>t(e,r))),sh=e=>ah((t,n)=>e),ch=e=>ah(Sp(function*(t,n){let r=Gu(n),i=e=>Ku(r,zd(e));return Zf(yield*Zf(e(t,n,r),i),i)})),lh=e=>e.transform,uh=4096,dh=e=>ah((t,n)=>lf(()=>lh(e())(t,n))),fh=e=>sh(F(()=>{let t=e();return lf(()=>{let e=t.next();return e.done?Dd(e.value):P(e.value)})})),ph=(e,t=uh)=>{let n=Mi(t);return sh(F(()=>{let t=e(),r=or();return lf(()=>{if(r._tag===`Some`)return Dd(r.value);let e=[];for(;e.length<n;){let n=t.next();if(n.done){if(e.length===0)return Dd(n.value);r=sr(n.value);break}e.push(n.value)}return P(e)})}))},mh=(e,t=uh)=>ph(()=>e[Symbol.iterator](),t),hh=e=>yh(P(e)),gh=sh(P(Dd())),_h=e=>sh(P(I(e))),vh=e=>sh(mf(e)),yh=e=>sh(F(()=>{let t=!1;return lf(()=>t?Dd():(t=!0,e))})),bh=e=>sh(P(tp(om(e),()=>Dd()))),xh=e=>Lh(R(im(e),bh)),Sh=e=>ah((t,n)=>Ch({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Ch=e=>{let t=e.readable.getReader(),n=e.exit??Lp(void 0),r=lf(()=>n.current?n.current:Bf(cf({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??mf(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Dd():P(la(t))}));return wf(Wu(e.scope,e.releaseLockOnEnd?F(()=>t.releaseLock()):sf(()=>t.cancel().catch(ne))),r)},wh=b(2,(e,t)=>oh(e,e=>F(()=>{let n=0;return R(e,e=>t(e,n++))}))),Th=e=>e===void 0||e!==`unbounded`&&e<=1,Eh=b(e=>rh(e[0]),(e,t,n)=>Th(n?.concurrency)?Dh(e,t):Oh(e,t,n)),Dh=(e,t)=>ah((n,r)=>R(lh(e)(n,r),e=>{let i,a,o=L(e,e=>(a??=Gu(r),Ep(lh(t(e))(n,a),e=>(i=s(e),i)))),s=Pd(e=>{if(i=void 0,a.state._tag===`Empty`)return o;let t=Ku(a,Ou);return a=void 0,L(t,()=>o)});return lf(()=>i??o)})),Oh=(e,t,n)=>e.pipe(wh(t),Ih(n)),kh=e=>Eh(e,x),Ah=e=>oh(e,e=>{let t,n=0;return P(lf(function r(){if(t===void 0)return L(e,e=>{switch(e.length){case 0:return r();case 1:return P(e[0]);default:return t=e,P(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),P(i)}))}),jh=b(2,(e,t)=>oh(e,e=>P(L(e,function n(r){let i=[];for(let e=0;e<r.length;e++)t(r[e])&&i.push(r[e]);return $i(i)?P(i):L(e,n)})))),Mh=b(2,(e,t)=>ah((n,r)=>{let i=Gu(r);return R(lh(e)(n,i),e=>{let a=e.pipe(jf(e=>{if(Fd(e))return mf(e);let o=i;return i=Gu(r),Ku(o,Eu(e)).pipe(xf(lh(t(e))(n,i)),L(e=>(a=e,e)))}));return lf(()=>a)})})),Nh=b(3,(e,t,n)=>Mh(e,e=>{let r=t(e);return Ii(r)?vh(r.failure):n(r.success,e)})),Ph=b(2,(e,t)=>Nh(e,Cd,e=>t(e))),Fh=b(e=>rh(e[0]),(e,t,n,r)=>Ph(e,e=>t(e)?n(e):r?r(e):_h(e))),Ih=b(2,(e,{bufferSize:t=16,concurrency:n,switch:r=!1})=>ch(Sp(function*(i,a,o){let s=n===`unbounded`?2**53-1:Math.max(1,n),c=r?void 0:$m(s),l=yield*Pp(!0),u=new Set,d=yield*km(t);yield*Wu(o,Pm(d));let f=yield*lh(e)(i,a);return yield*pf(function*(){for(;;){let e;c&&(u.size<s?yield*c.take(1):(e=yield*cp(f),yield*Lf(c.take(1),xf(kp(e),ff))));let t=e===void 0?yield*f:yield*kp(e),n=Gu(o),r=yield*lh(t)(i,n);for(;u.size>=s;){let e=zi(u);u.delete(e),u.size===0&&(yield*l.open),yield*Ap(e)}let a=yield*r.pipe(Sf(()=>vf),L(e=>Am(d,e)),ip({disableYield:!0}),Zf(Sp(function*(e){let t=Ld(e);if(yield*Cf(Ku(n,Ii(t)?Eu(t.failure):Tu(t.success.value))),u.has(a)&&(u.delete(a),c&&(yield*c.release(1)),u.size===0&&(yield*l.open),!Li(t)))return yield*Mm(d,e)})),cp);l.closeUnsafe(),u.add(a)}}).pipe(jf(e=>Li(Ld(e))?l.whenOpen(Mm(d,e)):Mm(d,e)),lp(o)),Im(d)}))),Lh=e=>ah((t,n)=>{let r;return P(lf(()=>r||e.pipe(Hu(n),L(e=>lh(e)(t,n)),L(e=>r=e))))}),Rh=b(2,(e,t)=>ch((n,r,i)=>Uu(i,t).pipe(xf(lh(e)(n,r))))),zh=b(2,(e,t)=>Rh(e,e=>t)),Bh=(e,t,n)=>lf(()=>{let r=Vu();return Pd(L(lh(e)(Dd(),r),t),n||P).pipe(Qf(e=>Ku(r,e)))}),Vh=b(2,(e,t)=>Bh(e,e=>ip(L(e,t),{disableYield:!0}))),Hh=e=>lf(()=>{let t=or();return Bh(e,e=>e.pipe(Tf,L(e=>(t=e,Dd()))),()=>P(t))}),Uh=b(3,(e,t,n)=>lf(()=>{let r=t();return Bh(e,e=>of({while:S,body:()=>e,step:e=>{r=n(r,e)}}),()=>P(r))})),Wh=`~effect/Stream`,Gh={_R:x,_E:x,_A:x},Kh=function(e){this.channel=e};Kh.prototype={[Wh]:Gh,pipe(){return _(this,arguments)}};var qh=e=>new Kh(e),Jh=`~effect/Stream`,Yh=e=>D(e,Jh),Xh=qh,Zh=e=>Xh(yh(R(e,la))),Qh=e=>Xh(sh(e)),$h=e=>e.channel,eg=Xh(gh),tg=e=>Xh(hh(la(e))),ng=e=>Xh(dh(()=>e().channel)),rg=e=>Xh(_h(e)),ig=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?ag(e):Xh(mh(e,t?.chunkSize)),ag=e=>$i(e)?Xh(hh(e)):eg,og=e=>Xh(xh(e)),sg=e=>Xh(Sh(e)),cg=(e,t)=>Qh(F(()=>{let n=e,r=!1;return lf(function e(){return r?Dd():L(t(n),([t,i])=>(cr(i)?r=!0:n=i.value,$i(t)?P(t):e()))})})),lg=e=>Xh(Lh(R(e,$h))),ug=b(e=>Yh(e[0]),(e,t,n)=>e.channel.pipe(Ah,Eh(e=>t(e).channel,n),Xh)),dg=b(e=>Yh(e[0]),(e,t)=>ug(e,x,t)),fg=b(2,(e,t)=>{let n=Xh(kh(fh(()=>mg(e,t))));return pg.set(n,[e,t]),n}),pg=new WeakMap;function*mg(e,t){let n=[t,e];for(;n.length>0;){let e=n.pop(),t=pg.get(e);t===void 0?yield e.channel:n.push(t[1],t[0])}}var hg=b(2,(e,t)=>Xh(jh($h(e),t))),gg=b(e=>Yh(e[0]),(e,t,n,r)=>Xh(Fh($h(e),t,e=>n(e).channel,r&&(e=>r(e).channel)))),_g=b(e=>Yh(e[0]),(e,t,n,r)=>gg(e,Array.isArray(t)?e=>D(e,`_tag`)&&t.includes(e._tag):ve(t),n,r)),vg=b(2,(e,t)=>Xh(zh(e.channel,t))),yg=e=>Uh(e.channel,()=>[],(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n]);return e}),bg=e=>R(Hh(e.channel),mr(ta(0))),xg=b(2,(e,t)=>Vh(e.channel,e=>{let n=0;return of({while:()=>n<e.length,body:()=>t(e[n++]),step:ne})})),Sg=b(2,(e,t)=>Vh(e.channel,t)),Cg=b(e=>Yh(e[0]),(e,t,n)=>{let r,i,a=Np(!1);return new ReadableStream({start(n){i=up(Uf(Sg(e,e=>a.whenOpen(F(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Sd(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return mp(Ef(Ap(i)))}},n?.strategy)}),wg=b(e=>Yh(e[0]),(e,t)=>R(Vf(),n=>Cg(e,n,t))),Tg={Escape:1,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,Minus:12,Equal:13,Backspace:14,Tab:15,KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,BracketLeft:26,BracketRight:27,Enter:28,ControlLeft:29,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,Semicolon:39,Quote:40,Backquote:41,ShiftLeft:42,Backslash:43,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Comma:51,Period:52,Slash:53,ShiftRight:54,NumpadMultiply:55,AltLeft:56,Space:57,CapsLock:58,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,NumLock:69,ScrollLock:70,Numpad7:71,Numpad8:72,Numpad9:73,NumpadSubtract:74,Numpad4:75,Numpad5:76,Numpad6:77,NumpadAdd:78,Numpad1:79,Numpad2:80,Numpad3:81,Numpad0:82,NumpadDecimal:83,IntlBackslash:86,F11:87,F12:88,NumpadEnter:96,ControlRight:97,NumpadDivide:98,PrintScreen:99,AltRight:100,Home:102,ArrowUp:103,PageUp:104,ArrowLeft:105,ArrowRight:106,End:107,ArrowDown:108,PageDown:109,Insert:110,Delete:111,Pause:119,MetaLeft:125,MetaRight:126,ContextMenu:127},Eg={Backspace:8,Tab:9,Enter:13,NumpadEnter:13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,MetaLeft:91,MetaRight:92,ContextMenu:93,Semicolon:186,Equal:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222},Dg={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,Pause:19,CapsLock:20,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,Meta:91,ContextMenu:93},Og=new Set(`KeyA.KeyC.KeyF.KeyG.KeyH.KeyJ.KeyK.KeyL.KeyN.KeyO.KeyP.KeyR.KeyS.KeyT.KeyW.KeyX.KeyV.KeyZ.KeyY.BracketLeft.BracketRight.ArrowLeft.ArrowRight.ArrowUp.ArrowDown.Backspace.Delete.Enter.Tab`.split(`.`));function kg(e){let t=0;return e.altKey&&(t|=1),e.ctrlKey&&(t|=2),e.metaKey&&(t|=4),e.shiftKey&&(t|=8),t}function Ag(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function jg(e,t){let n=Ng(e.code,e.key),r=kg(e),i=t===`down`&&Ag(e)?e.key:void 0,a=e.key.length===1?e.key:void 0;return{key:e.key,code:e.code,text:i,unmodifiedText:a,modifiers:r,windowsVirtualKeyCode:n,nativeVirtualKeyCode:n,location:e.location,autoRepeat:e.repeat,isKeypad:e.location===KeyboardEvent.DOM_KEY_LOCATION_NUMPAD}}function Mg(e){return e.key===`Escape`?!1:Pg(e.code)||!(e.metaKey||e.ctrlKey)?!0:Og.has(e.code)}function Ng(e,t){let n=e?Eg[e]:void 0;if(n!==void 0)return n;if(e?.startsWith(`Key`)&&e.length===4)return e.charCodeAt(3);if(e?.startsWith(`Digit`)&&e.length===6)return e.charCodeAt(5);if(e?.startsWith(`Numpad`)&&e.length===7){let t=Number(e.slice(6));if(Number.isInteger(t)&&t>=0&&t<=9)return 96+t}if(e?.startsWith(`F`)){let t=Number(e.slice(1));if(Number.isInteger(t)&&t>=1&&t<=24)return 111+t}let r=t?Dg[t]:void 0;return r===void 0?t?.length===1?t.toUpperCase().charCodeAt(0):0:r}function Pg(e){return e===`AltLeft`||e===`AltRight`||e===`ControlLeft`||e===`ControlRight`||e===`MetaLeft`||e===`MetaRight`||e===`ShiftLeft`||e===`ShiftRight`}var Fg=`~effect/BigDecimal`,Ig={[Fg]:Fg,[be](){let e=Wg(this);return Ce(De(String(e.value)),Ee(e.scale))},[Re](e){return Lg(e)&&Yg(this,e)===0},toString(){return`BigDecimal(${Zg(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[ht](){return this.toJSON()},pipe(){return _(this,arguments)}},Lg=e=>D(e,Fg),Rg=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(Ig);return n.value=e,n.scale=t,n},zg=(e,t)=>{let n=Rg(e,t);return n.normalized=n,n},Bg=BigInt(0),Vg=BigInt(1),Hg=BigInt(10),Ug=zg(Bg,0),Wg=e=>{if(e.normalized===void 0)if(e.value===Bg)e.normalized=Ug;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=zg(BigInt(t.slice(0,n)),e.scale-(t.length-n))}return e.normalized},Gg=100,Kg=[Vg],qg=(e,t)=>e===t?0:e<t?-1:1,Jg=(e,t)=>{let n=`${e.value<Bg?-e.value:e.value}`,r=`${t.value<Bg?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==Bg)return i<Bg?-1:1;let a=Math.max(n.length,r.length);return $n(n.padEnd(a,`0`),r.padEnd(a,`0`))},Yg=(e,t)=>{if(e.scale===t.scale)return qg(e.value,t.value);let n=Xg(e),r=Xg(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>Gg)return n===-1?Jg(t,e):Jg(e,t);let o=Kg[a]??=Hg**BigInt(a);return i>0?qg(e.value,t.value*o):qg(e.value*o,t.value)},Xg=e=>e.value===Bg?0:e.value<Bg?-1:1,Zg=e=>{let t=Wg(e);if(Math.abs(t.scale)>=16)return Qg(t);let n=t.value<Bg,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},Qg=e=>{if($g(e))return`0e+0`;let t=Wg(e),n=`${t.value}`,r=t.value<Bg?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},$g=e=>e.value===Bg;_r()(`effect/DateTime/CurrentTimeZone`);var e_=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,t_=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)t_[e_.charCodeAt(e)]=e;t_[61]=0;var n_=`~effect/http/Cookies`,r_=`~effect/http/Cookies/Cookie`;Ta(`CookiesError`);var i_={[n_]:n_,...vt,toJSON(){return{_id:`effect/Cookies`,cookies:Wi(this.cookies,e=>e.toJSON())}},pipe(){return _(this,arguments)}},a_=e=>{let t=Object.create(i_);return t.cookies=e,t},o_=e=>{let t={};for(let n of e)Tt(t,n.name,n);return a_(t)},s_=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=c_(e.trim());t&&n.push(t)}return o_(n)};function c_(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!l_.test(r))return;let i=t[0].slice(n+1),a=d_(i);if(t.length===1)return Object.assign(Object.create(u_),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=yi(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`;break}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`;break}break}}return Object.assign(Object.create(u_),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var l_=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,u_={[r_]:r_,...vt,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},d_=e=>{try{return decodeURIComponent(e)}catch{return e}},f_=new WeakMap,p_=e=>{if(f_.has(e))return f_.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},m_=e=>typeof e==`string`?e:p_(e),h_=`~effect/Redacted`,g_=e=>D(e,h_),__=(e,t)=>{let n=Object.create(v_);return t?.label&&(n.label=t.label),f_.set(n,e),n},v_={[h_]:{_A:e=>e},label:void 0,...It,toJSON(){return this.toString()},toString(){return`<redacted${ce(this.label)?`:`+this.label:``}>`},[be](){return O(f_.get(this))},[Re](e){return g_(e)&&ze(f_.get(this),f_.get(e))}},y_=p_,b_=e=>Tn((t,n)=>e(y_(t),y_(n))),x_=Symbol.for(`~effect/http/Headers`),S_=Object.defineProperties(Object.create(null),{[x_]:{value:x_},[et]:{value(e){return M_(this,Ur(e,P_))}},toJSON:{value(){return nt(this)}},[Re]:{value(e){return w_(this,e)}},[be]:{value(){return ke(this)}},toString:{value:vt.toString},[ht]:{value:vt[ht]}}),C_=e=>Object.assign(Object.create(S_),e),w_=qi(Dn()),T_=Object.create(S_),E_=e=>{if(e===void 0)return T_;if(Symbol.iterator in e){let t=Object.create(S_);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(S_);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},D_=e=>Object.setPrototypeOf(e,S_),O_=b(3,(e,t,n)=>{let r=C_(e);return r[t.toLowerCase()]=n,r}),k_=b(2,(e,t)=>C_({...e,...E_(t)})),A_=b(2,(e,t)=>{let n=C_(e);return Object.assign(n,t),n}),j_=b(2,(e,t)=>{let n=C_(e);return delete n[t.toLowerCase()],n}),M_=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=__(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=__(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),N_=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},P_=Yr(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),F_=`~effect/http/UrlParams`,I_=e=>D(e,F_),L_={...It,[F_]:F_,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Re](e){return V_(this,e)},[be](){return je(this.params.flat())}},R_=e=>{let t=Object.create(L_);return t.params=e,t},z_=e=>{if(I_(e))return e;let t=B_(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return R_(n)},B_=e=>{let t=typeof e[Symbol.iterator]==`function`?Yi(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`&&r){let t=B_(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},V_=Tn((e,t)=>H_(e.params,t.params)),H_=da(Ri([Dn(),Dn()])),U_=R_([]),W_=b(2,(e,t)=>{let n=z_(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return R_(n)});function G_(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var K_=`~structural`,q_=`~sentinels`,J_=`~constructor`,Y_=w(e=>{let t=G_(e)?.identifier;return typeof t==`string`?t:e.getExpected(Y_)}),X_=Symbol(),Z_=Tu,Q_=Z_(X_),$_=Z_(X_),ev=e=>e===X_?or():sr(e),tv=e=>e._tag===`None`?Q_:Z_(e.value),nv=`~effect/SchemaIssue/Issue`;function rv(e){return D(e,nv)&&e[nv]===nv}function iv(e){return Object.hasOwn(e,`input`)}var av=class{[nv]=nv;constructor(e,t){t?.reportInput===!0&&e!==X_&&(this.input=e)}},ov=class extends av{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},sv=class extends av{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},cv=class extends av{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},lv=class extends av{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},uv=class extends av{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},dv=class extends av{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},fv=class extends av{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},pv=class extends av{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},mv=class extends av{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},hv=class extends av{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},gv=class extends av{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function _v(e,t,n){if(rv(e))return e;if(typeof e==`string`)return new pv({message:e},t,n);let r=typeof e.issue==`string`?new pv({message:e.issue},t,n):e.issue;return new cv(e.path,r)}function vv(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new pv(void 0,t,n):_v(e,t,n)}function yv(e,t,n,r){return Array.isArray(t)?$i(t)?t.length===1?_v(t[0],n,r):new dv(e,ua(t,e=>_v(e,n,r)),n,r):void 0:vv(t,n,r)}var bv=e=>{let t=kv(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return wv(Y_(e.ast),e);case`InvalidValue`:{let t=Cv(e);if(t!==void 0)return wv(t,e);let n=Sv(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Sv(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Sv(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},xv=e=>kv(e.issue)??kv(e);function Sv(e){return iv(e)?st(e.input):void 0}function Cv(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function wv(e,t){let n=Sv(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Tv(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Tv(e)).join(` & `)}}function Ev(){return e=>Ov(e,``)}var Dv=Ev();function Ov(e,t){let n;switch(e._tag){case`Filter`:{let r=xv(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Ov(e.issue,t);let r=Cv(e.issue);n=r===void 0?wv(Tv(e.filter),e):wv(r,e.issue)}break}case`Encoding`:return Ov(e.issue,t);case`Pointer`:return Ov(e.issue,t+ut(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Ov(e,t)).join(`
|
|
22
|
-
`);n=kv(e)??wv(Y_(e.ast),e);break;default:n=bv(e);break}return t?`${n}\n at ${t}`:n}function kv(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return kv(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Av(e){let t;for(let n of e.reasons){if(!_d(n)||!rv(n.error))return;t??=n.error}return t}function jv(e,t){let n=Av(e);if(n===void 0)throw Error(t,{cause:e});return n}var Mv=e=>Object.assign(Object.create(v),e);function Nv(e){return Bv((t,n)=>I(e(t,n)))}function Pv(e){return Nv((t,n)=>{let r={message:e(t)};return lr(t)?new mv(r,t.value,n):new mv(r)})}var Fv=Mv({_tag:`Passthrough`});function Iv(){return Fv}function Lv(e){return Mv({_tag:`Transform`,transform:e})}function Rv(e){return Mv({_tag:`TransformEffect`,transform:e})}function zv(e){return Mv({_tag:`TransformOptional`,transform:e})}function Bv(e){return Mv({_tag:`TransformOptionalEffect`,transform:e})}function Vv(){return zv(()=>or())}function Hv(e){return Bv(t=>{let n=hr(t,pe);return lr(n)?P(n):Cp(e,sr)})}function Uv(){return Lv(globalThis.String)}function Wv(){return Lv(globalThis.Number)}function Gv(e){return Rv((t,n)=>_f({try:()=>JSON.parse(t,e?.reviver),catch:()=>new pv({expected:`a valid JSON string`},t,n)}))}function Kv(e){return Rv((t,n)=>_f({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new pv({expected:`a JSON-serializable value`},t,n)}))}var qv=class extends y{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new qv(this.encode,this.decode)}},Jv=`~effect/SchemaTransformation/Transformation`,Yv=class extends y{[Jv]=Jv;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Yv(this.encode,this.decode)}};function Xv(e){return D(e,Jv)&&e[Jv]===Jv}var Zv=e=>Xv(e)?e:new Yv(e.decode,e.encode);function Qv(e){return new Yv(Lv(e.decode),Lv(e.encode))}var $v=new Yv(Iv(),Iv());function ey(){return $v}var ty=new Yv(Wv(),Uv()),ny=e=>ge(e)&&typeof e.message==`string`,ry=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:sy(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},iy=e=>{try{let t=mt(e);return t===void 0?st(e):JSON.parse(t)}catch{return st(e)}},ay=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},oy=e=>{let t=new WeakSet,n=r=>{if(ye(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=ay(r,e,n);return t.delete(r),i}return iy(r)};return n},sy=e=>ny(e)?ry(e):e,cy=e=>Qv({decode:sy,encode:oy(e)});function ly(e){return new Yv(Gv(e??{}),Kv(e))}function uy(e){return t=>t._tag===e}var dy=uy(`Declaration`),fy=uy(`Never`),py=uy(`Literal`),my=uy(`UniqueSymbol`),hy=uy(`Arrays`),gy=uy(`Objects`),_y=uy(`Suspend`),vy=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},yy={},by=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},xy=`~effect/Schema`,Sy=class{[xy]=xy;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Cy=class extends Sy{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===X_?Q_:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Gb(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Cy(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},wy=new class extends Sy{_tag=`Null`;getParser(){return lx(this,null)}getExpected(){return`null`}},Ty=class extends Sy{_tag=`Undefined`;getParser(){return lx(this,void 0)}toCodecJson(){return Nb(this,[Ey])}getExpected(){return`undefined`}},Ey=new vy(wy,new Yv(Lv(()=>void 0),Lv(()=>null))),Dy=new Ty,Oy=new class extends Sy{_tag=`Unknown`;getParser(){return ux(this,he)}getExpected(){return`unknown`}},ky=class extends Sy{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${st(e)}`);this.literal=e}getParser(){return lx(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Ay(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Ay(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Ay(e){let t=globalThis.String(e.literal);return Nb(e,[new vy(new ky(t),new Yv(Lv(()=>e.literal),Lv(()=>t)))])}var jy=new class extends Sy{_tag=`String`;getParser(){return ux(this,ce)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&yx(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},My=class extends Sy{_tag=`Number`;getParser(){return ux(this,le)}matchKey(e,t){return this._match(mx,e,t)}matchPart(e,t){return this._match(px,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:yx(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Ny(this.checks,`effect/schema/isFinite`)||Ny(this.checks,`effect/schema/isInt`))?this:Nb(this,[Ob])}toCodecStringTree(){return this.toCodecJson()===this?Nb(this,[_x]):Nb(this,[vx])}getExpected(){return`number`}};function Ny(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Ny(e.checks,t))}var Py=new My,Fy=new class extends Sy{_tag=`Boolean`;getParser(){return ux(this,E)}getExpected(){return`boolean`}},Iy=class extends Sy{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(ex(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(ex(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new uv(n,t[o],i),a=new cv([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return I(new dv(n,[a],t,i))}return e.issues?I(new dv(n,e.issues,t,i)):Z_(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:vl(t.concurrency),f=d===1?zy(i,e,0,u):By(i,e,{concurrency:d,end:u});if(!f)return c(i);if(ks(f))return Ep(f,()=>c(i));let p=!0;return lf(()=>p?(p=!1,L(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===X_)return Q_;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):I(new fv(n,e,a))}catch(e){return gf(e)}}}_rebuild(e,t,n){let r=Gb(this.elements,e),i=Gb(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Iy(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ly(e,t,n,r){if(n._tag===`Failure`)return Vy(e,e.ast,r,n);let i=n===$_?t:n[k];if(i!==X_)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(ex(t.ast))return;let n=new cv([r],new lv(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Du(new dv(e.ast,[n],e.input,e.options))}}var Ry={onItem(e,t,n){let r=n<e.len?t:X_;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ly},zy=yl()(Ry),By=xl()(Ry),Vy=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Av(r.cause);if(i===void 0)return Eu(xd(r.cause,r=>new dv(t,[new cv([n],r)],e.input,e.options)));let a=new cv([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Du(new dv(t,[a],e.input,e.options))},Hy=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Uy(e,t,n=yy){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(dx(ax(t)))}var Wy=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Gy(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Gy);default:return!1}}function Ky(e){let t=Fb(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Ky);default:return!1}}function qy(e){return Gy(e)&&Ky(e)}var Jy=class{parameter;type;constructor(e,t){if(!qy(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,ex(t)&&!cx(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Yy=class extends Sy{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return ux(n,me);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(dx(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return Vy(t,n,i,s)??Ou;let c=s===$_?o:s[k];if(a!==X_&&c!==X_){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return Ou;Tt(t.out,a,c)}return Ou},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!ks(t))return L(Cf(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return Vy(e,n,r,a)??Ou;let o=a===$_?r:a[k],s=e.input[r],l=i.parserValue(s,e.options);return ks(l)?t(e,r,o,s,l):L(Cf(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return ks(a)?t(e,n,n,i,a):L(Cf(a),r=>t(e,n,n,i,r))},u=i?xl()({onItem:(e,[t,n])=>n.is.parameter===jy?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Dp(function*(t,d){if(t===X_)return X_;if(!(typeof t==`object`&&t&&!Array.isArray(t)))return yield*I(new fv(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:vl(d.concurrency),v=i&&g?n.indexSignatures.map(e=>Uy(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new uv(n,f[a],d),r=new cv([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}else return yield*I(new dv(n,[r],t,d))}}}if(r){let e=_===1?Qy(m,a):$y(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===jy?l:c,r=v?.[e]??(t.is.parameter===jy?Object.keys(f):Uy(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!ks(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ca();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===jy?Object.keys(f):Uy(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*I(new dv(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return L(Cf(n),n=>{let i=Xy(e,r,n);if(i)return i;let o=()=>Z_(e.out),s=Qy(e,a.slice(t+1));return s?Ep(s,o):o()})};return(e,t)=>{if(e===X_)return Q_;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&vl(t.concurrency)!==1)return(l??=c())(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return I(new fv(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=fb(i,s),l=c?i[s]:X_,d=n.parser(l,t);if(!ks(d))return u(o,e,d);if(d===$_){c&&Tt(a,s,l);continue}let f=Xy(o,n,d);if(f)return f}}catch(e){return gf(e)}return Z_(a)}}_rebuild(e,t,n,r){let i=Gb(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Wy(t.name,n)}),a=Gb(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Jy(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Yy(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Xy(e,t,n){if(n._tag===`Failure`)return Vy(e,e.ast,t.name,n);if(n===$_)return;let r=n[k];if(r!==X_){Tt(e.out,t.name,r);return}if(delete e.out[t.name],!ex(t.type)){let n=new cv([t.name],new lv(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}else return Du(new dv(e.ast,[n],e.input,e.options))}}var Zy={onItem(e,t){if(!fb(e.input,t.name))return t.parser(X_,e.options);let n=e.input[t.name];return Tt(e.out,t.name,n),t.parser(n,e.options)},step:Xy},Qy=yl()(Zy),$y=xl()(Zy);function eb(e,t){return e?t?[...e,...t]:e:t}function tb(e,t,n){return new Yy(Reflect.ownKeys(e).map(t=>new Wy(t,e[t].ast)),[],n,t)}function nb(e){return e.ast}function rb(e,t=void 0){return new Iy(!1,e.map(e=>e.ast),[],void 0,t)}function ib(e,t,n){return new mb(e.map(nb),t,void 0,n)}function ab(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new Iy(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var ob=T(e=>{for(;;){if(_y(e))return Oy;let t=e.encoding;if(!t)return e.recur?.(ob,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return Oy;e=t[t.length-1].to}});function sb(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(sb)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function cb(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[q_];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ex(t)){if(py(t))return[{key:e.name,literal:t.literal}];if(my(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!ex(e)){if(py(e))return[{key:t,literal:e.literal}];if(my(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>cb(ob(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return cb(e.thunk())}}var lb=new WeakMap,ub=Object.freeze([]),db=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,fb=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function pb(e){let t=lb.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=ob(c);if(fy(l))continue;if(py(l)||my(l)){a??=new Map;let e=py(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=cb(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=sb(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??ub);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??ub;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(_e(e)){let n=fb(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??ub;if(t)return o}return ub}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=db(t);if(!_e(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=fb(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=fb(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=fb(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(db(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return lb.set(e,t),t}var mb=class extends Sy{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===X_)return Q_;let i=(o??=pb(n.types))(e,r);if(i.length===0)return I(new hv(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:ks(r)?hb(n,r.cause,e,t):gb(n,r,e,t)}return _b(n,a,i,e,t)}}_rebuild(e,t,n){let r=Gb(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new mb(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=ax(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(py);if(t.length>0)return`${xb(n.isMutable)}[ ${t.map(t=>e(t)+Sb(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>py(e.type));if(t.length>0)return`{ ${t.map(t=>`${xb(t.type.context?.isMutable)}${lt(t.name)}${Sb(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function hb(e,t,n,r){let i=Av(t);return i?Du(new hv(e,[i],n,r)):Eu(t)}function gb(e,t,n,r){return jf(t,t=>hb(e,t,n,r))}function _b(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=yb(a,n);return o?vb(o,a):a.out?a.out:I(new hv(e,a.issues??[],r,i))}function vb(e,t){return Ep(e,e=>t.out===$_?P(t.input):t.out?t.out:I(new hv(t.ast,t.issues??[],t.input,t.options)))}var yb=yl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Av(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Du(new gv(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Ou}}}),bb=new mb([new ky(`Infinity`),new ky(`-Infinity`),new ky(`NaN`)]);function xb(e){return e?``:`readonly `}function Sb(e){return e?`?`:``}var Cb=class extends Sy{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Cb(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},wb=class extends y{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new wb(this.run,{...this.annotations,...e},this.aborted)}abort(){return new wb(this.run,this.annotations,!0)}and(e,t){return new Tb([this,e],t)}},Tb=class extends y{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Tb(this.checks,{...this.annotations,...e})}and(e,t){return new Tb([this,e],t)}};function Eb(e,t,n=!1){return new wb((t,n,r)=>yv(n,e(t,n,r),t,r),t,n)}function Db(e){return Eb(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Ob=new vy(new mb([Rb(Py,[Db()]),bb]),new Yv(Wv(),Lv(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function kb(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Eb(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Ab=new WeakMap;function jb(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Ab.set(n,Mb(e)),n}function Mb(e){let t=Ab.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Ab.set(e,n),n}function Nb(e,t){return e.encoding===t?e:jb(e,{encoding:t})}function Pb(e,t){if(e.context===t)return e;let n=Mb(e);return n.context===t&&n.encoding===e.encoding?n:jb(e,{context:t})}function Fb(e){return e.encoding?Fb(e.encoding[e.encoding.length-1].to):e}function Ib(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Lb(e,Zi(e.checks.slice(0,-1),n.annotate(t)))}return jb(e,{annotations:{...e.annotations,...t}})}function Lb(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:jb(e,{checks:t})}function Rb(e,t){return Lb(e,eb(e.checks,t))}function zb(e,t){let n=t(e.to);return n===e.to?e:new vy(n,e.transformation)}function Bb(e,t){let n=e,r=n[n.length-1],i=zb(r,t);return i===r?e:Zi(e.slice(0,e.length-1),i)}function Vb(e){return t=>t.encoding?Nb(t,Bb(t.encoding,e)):t}function Hb(e,t){return Vb(e=>Pb(e,t))(e)}function Ub(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Nb(r,Bb(r.encoding,n))}return e(r)}return T(n)}function Wb(e,t,n){let r=new vy(e,t);return Nb(n,n.encoding?[...n.encoding,r]:[r])}function Gb(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function Kb(e,t){return Pb(e,e.context?new by(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new by(!1,!1,void 0,t))}var qb=T(e=>Jb(Pb(e,e.context?e.context.isOptional===!1?new by(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new by(!0,!1)))),Jb=Vb(qb),Yb=w(e=>qb(new mb([e,Dy])));function Xb(e,t){return Pb(e,e.context?new by(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new by(!1,!1,t))}function Zb(e,t,n){return Wb(e,n,t)}function Qb(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:de(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function $b(e,t){let{literals:n,parameters:r}=Qb(e);return new Yy(n.map(e=>new Wy(e,t)),r.map(e=>new Jy(e,t)))}function ex(e){return e.context?.isOptional??!1}function tx(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(tx)}function nx(e){function t(e){return tx(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Qi(n)?n:void 0}function rx(e){let t=!0;function n(e){return t=t&&!e.encoding&&!_y(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var ix=T(e=>{let t=Mb(e);if(t!==e){let n=ix(t);return n===t&&e.encoding===void 0?e:Pb(n,e.context)}let n=`recur`in e?e.recur(ix):e;if(`encodingChecks`in n&&n.encodingChecks){let t=rx(e)?n.encodingChecks:hy(n)||gy(n)||dy(n)&&n.typeParameters.length>0?nx(n.encodingChecks):void 0;return jb(n,{encodingChecks:void 0,checks:eb(n.checks,t)})}return n}),ax=T(e=>ix(sx(e)));function ox(e,t){let n=t,r=n.length,i=n[r-1],a=[new vy(sx(Nb(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new vy(sx(n[e-1].to),n[e].transformation.flip()));let o=sx(i.to);return o.encoding?Nb(o,[...o.encoding,...a]):Nb(o,a)}var sx=w(e=>{if(e.encoding)return ox(e,e.encoding);let t=Mb(e);if(t!==e){let n=sx(t);return n===t?e:Pb(n,e.context)}return`flip`in e?e.flip(sx):`recur`in e?e.recur(sx):e});function cx(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(cx);default:return!1}}function lx(e,t){let n=t===0?$_:Z_(t);return(r,i)=>r===X_?Q_:r===t?n:I(new fv(e,r,i))}function ux(e,t){return(n,r)=>n===X_?Q_:t(n)?$_:I(new fv(e,n,r))}var dx=Ub(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(dx)}}),fx=Ub(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(fx)}}),px=new globalThis.RegExp(`^${Hy}$`),mx=new globalThis.RegExp(`^(?:${Hy}|Infinity|-Infinity|NaN)$`);function hx(e){return kb(px,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:px.source}),...e})}var gx=Rb(jy,[hx()]),_x=new vy(gx,ty),vx=new vy(new mb([gx,bb]),ty);function yx(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=yx(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new ov(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function bx(e){if(!dy(e))return;let t=e.annotations?.[J_];return fe(t)?t(e.typeParameters):void 0}function xx(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Sx(e){return e===void 0||typeof e==`string`}function Cx(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function wx(e){return Cx(e,xx)}var Tx=new Cy([],()=>(e,t,n)=>wx(e)?$_:I(new fv(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>kx}),Ex=new vy(Tx,ey()),Dx=new vy(new mb([new Iy(!1,[],[Tx]),new Yy([],[new Jy(jy,Tx)])]),ey());function Ox(e){return Cx(e,Sx)}var kx=new vy(new Cy([],()=>(e,t,n)=>Ox(e)?$_:I(new fv(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),ey()),Ax=(e,t,n)=>e===$_?n(t):Ep(e,n);function jx(e){if(e._tag===`Middleware`)return(t,n,r)=>Mx(t===$_?e.decode(Z_(ev(n)),r):e.decode(Cp(t,ev),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===$_?Z_(t):e;case`Transform`:{let e=e=>e===X_?Q_:Z_(t.transform(e));return(t,n)=>Ax(t,n,e)}case`TransformOptional`:{let e=e=>tv(t.transform(ev(e)));return(t,n)=>Ax(t,n,e)}case`TransformEffect`:return(e,n,r)=>Ax(e,n,e=>e===X_?Q_:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Ax(e,n,e=>Mx(t.transform(ev(e),r)))}}var Mx=e=>Ep(e,tv),Nx=(e,t,n,r)=>jf(r,r=>hf(()=>xd(r,r=>new sv(e,r,t,n))));function Px(e,t){let n=jx(e.link.transformation),r;return(i,a)=>{if(i===X_)return Q_;if(e.isConstructed(i))return $_;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Fx(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==X_&&r!==void 0)return t(r,i);let a=n;if(ks(a)&&a._tag===`Success`){let e=t(a[k],i);return e===$_?a:e}return Ep(Nx(e,r,i,a),e=>{let n=t(e,i);return n===$_?Z_(e):n})}}function Ix(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Fx(e,n)}function Lx(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?bx(e):void 0,o=a?Px(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>jx(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks)if(ks(r)){if(r._tag===`Success`){let i=r===$_?t:r[k];if(t!==X_&&i!==X_){let i=yx(u,t,void 0,e,n);i&&(r=I(new dv(e,i,t,n)))}}}else r=L(r,r=>{if(t!==X_&&r!==X_){let r=yx(u,t,void 0,e,n);if(r)return I(new dv(e,r,t,n))}return P(r)});if(s&&!n.disableChecks)if(ks(r)){if(r._tag===`Success`){let i=r===$_?t:r[k];if(i===X_)return r;let a=yx(s,i,void 0,e,n);a&&(r=I(new dv(e,a,i,n)))}}else r=L(r,t=>{if(t!==X_){let r=yx(s,t,void 0,e,n);if(r)return I(new dv(e,r,t,n))}return P(t)});return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[k],o=t(a,r)):o=Ep(o,e=>{let n=t(e,r);return n===$_?Z_(e):n})}if(o._tag===`Success`){let e=o[k],t=p(e,r);return t===$_?o:t}return o=Nx(e,n,r,o),Ep(o,e=>{let t=p(e,r);return t===$_?Z_(e):t})}:p}var Rx=Symbol(),zx=new WeakMap,Bx,Vx=e=>Jx(e).parser,Hx=e=>Jx(e).makeEffect,Ux=e=>Ix(e,Hx),Wx=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Lx(this.ast,Vx)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Lx(this.ast,Hx,Ux)}},Gx=class extends Wx{compiled;resolve;constructor(e,t,n){super(e),this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==`function`?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save(`is`,this.operation(`is`))}get decode(){return this.save(`decode`,this.operation(`decode`))}get make(){return this.save(`make`,this.operation(`make`))}get decodeEffect(){return this.save(`decodeEffect`,this.operation(`decodeEffect`)??Lx(this.ast,e=>qx(this.resolve,e,`parser`)))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save(`parser`,Kx(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation(`makeEffect`);if(e!==void 0)return this.save(`makeEffect`,e);let t=e=>qx(this.resolve,e,`makeEffect`);return this.save(`makeEffect`,Lx(this.ast,t,e=>Ix(e,t)))}};function Kx(e,t){let n;return(r,i)=>{if(r!==X_)try{let t=e(r,i);if(t!==Rx)return t===r?$_:Z_(t)}catch(e){return gf(e)}return(n??=t())(r,i)}}function qx(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let i;return(e,t)=>(i??=r[n])(e,t)}function Jx(e){let t=zx.get(e);if(t!==void 0)return t;let n=Bx===void 0?new Wx(e):new Gx(e,Bx(e,Jx),Jx);return zx.set(e,n),n}function Yx(e){let t=e.ast,n;return(e,r)=>(n??=aS(dS,ix(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Xx(e){let t=Yx(e);return(e,n)=>{let r=bp(t(e,n));return ku(r)?sr(r.value):(jv(r.cause,`Option adapter can only return none for schema issues`),or())}}function Zx(e){return lS(ix(e.ast))}function Qx(e,t){let n=rS(e.ast);return t===void 0?n:(e,r)=>n(e,tS(t,r))}function $x(e,t){return sS(Qx(e,t))}function eS(e,t){let n=rS(sx(e.ast));return t===void 0?n:(e,r)=>n(e,tS(t,r))}var tS=(e,t)=>t?{...e,...t}:e,nS=e=>e===X_?I(new pv):P(e);function rS(e){return aS(uS,e)}function iS(e,t){return e===$_?P(t):ks(e)?e[k]===X_?nS(X_):e:Ep(e,nS)}function aS(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??yy);return a===$_?P(r):ks(a)?a[k]===X_?nS(X_):a:Ep(a,nS)}}function oS(e){return(t,n)=>bp(e(t,n))}function sS(e){let t=oS(e);return(e,n)=>{let r=t(e,n);return ku(r)?sr(r.value):(jv(r.cause,`Option adapter can only return none for schema issues`),or())}}function cS(e,t){let n=bp(e);if(ku(n))return n.value;let r=jv(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function lS(e){let t,n;return(r,i)=>{t??=Jx(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??yy,o=t.make;if(o!==void 0&&r!==X_){let e;try{e=o(r,a)}catch(e){throw jv(yd(e),`Constructor adapter can only throw schema issues`),e}if(e!==Rx&&e!==X_)return e}return cS(iS((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var uS=e=>Jx(e).parser,dS=e=>Jx(e).makeEffect,fS=`~effect/Schema/Schema`,pS=Symbol(),mS={[fS]:fS,get make(){let e=Zx(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Yx(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Xx(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return _(this,arguments)},annotate(e){return this.rebuild(Ib(this.ast,e))},annotateKey(e){return this.rebuild(Kb(this.ast,e))},check(...e){return this.rebuild(Rb(this.ast,e))},rebuild(e){return hS(e,this[pS])}};function hS(e,t){function n(){}let r=Object.setPrototypeOf(n,mS);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[pS]=t,r.ast=e,r}function gS(e){return hS(_S(e.ast),{schema:e})}var _S=Ub(e=>{let t=SS(e,_S),n=e.context;return t===e||n===void 0?t:Hb(t,vS(n))});function vS(e){return e.constructorDefault===void 0?e:new by(e.isOptional,e.isMutable,void 0,e.annotations)}function yS(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function bS(e){return t=>{let n=[...t].sort((t,n)=>e(ax(t))-e(ax(n)));return n.some((e,n)=>e!==t[n])?n:t}}var xS=bS(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function SS(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!fe(n))return Nb(e,[Ex]);let r=n(e.typeParameters.map(e=>hS(ax(e))));return r===void 0?e:Nb(e,[zb(r,t)])}case`Unknown`:return Nb(e,[Ex]);case`ObjectKeyword`:return Nb(e,[Dx]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return yS(e),e.recur(t,fx);case`Union`:{let n=xS(e.types);return n===e.types?e.recur(t):new mb(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var CS=e=>e,wS=`~effect/Schema/SchemaError`;function TS(e){return D(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var ES=fS;function DS(){return(e,t,n)=>VS(new Cy(e.map(nb),e=>t(e.map(e=>VS(e))),n))}function OS(e,t){return DS()([],()=>(t,n,r)=>e(t)?P(t):I(new fv(n,t,r)),t)}var kS=class extends Ta(`SchemaError`){[wS]=wS;constructor(e){let t=xt();St(0);try{super({issue:e})}finally{St(t)}}get message(){return Dv(this.issue)}toString(){return`SchemaError(${this.message})`}};function AS(e){return TS(e)}function jS(e){return ks(e)?MS(e):jf(e,e=>hf(()=>xd(e,e=>new kS(e))))}function MS(e){return ku(e)?e:Eu(xd(e.cause,e=>new kS(e)))}function NS(e,t){let n;for(let r of e.reasons){if(!_d(r)||!AS(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function PS(e){let t=bp(e);if(ku(t))return t.value;throw NS(t.cause,`Sync adapter can only throw schema errors`)}function FS(e,t){let n=Qx(e,t);return(e,t)=>jS(n(e,t))}var IS=FS,LS=$x;function RS(e,t){let n=eS(e,t);return(e,t)=>jS(n(e,t))}function zS(e,t){let n=RS(e,t);return(e,t)=>PS(n(e,t))}var BS=zS,VS=hS;function HS(e){return D(e,ES)&&e[ES]===ES}var B=CS(e=>VS(qb(e.ast),{schema:e})),US=CS(e=>{let t=nC(e);return VS(Yb(e.ast),{schema:t})}),WS=CS(e=>VS(ix(e.ast),{schema:e})),GS=CS(e=>VS(ax(e.ast),{schema:e}));function V(e){let t=VS(new ky(e),{literal:e,transform(n){return t.pipe(iC(V(n),{decode:Lv(()=>n),encode:Lv(()=>e)}))}});return t}var KS=VS(Oy),qS=VS(wy),JS=VS(Dy),H=VS(jy),U=VS(Py),W=VS(Fy);function YS(e,t){return VS(e,{fields:t,mapFields(e,t){let n=e(this.fields);return YS(tb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function G(e){return YS(tb(e,void 0),e)}function XS(e,t){return VS($b(e.ast,t.ast),{key:e,value:t})}function ZS(e,t){return VS(e,{elements:t,mapElements(e,t){let n=e(this.elements);return ZS(rb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}var K=CS(e=>VS(new Iy(!1,[],[e.ast]),{value:e})),QS=CS(e=>VS(ab(e.ast),{schema:e}));function $S(e,t){return VS(e,{members:t,mapMembers(e,t){let n=e(this.members);return $S(ib(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function eC(e,t){return $S(ib(e,t,void 0),e)}function q(e){let t=e.map(V);return VS(ib(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return eC(e(this.members))},pick(e){return q(e)},transform(e){return eC(t.map((t,n)=>t.transform(e[n])))}})}var tC=CS(e=>eC([e,qS])),nC=CS(e=>eC([e,JS]));function rC(e){return VS(new Cb(()=>e().ast))}function iC(e,t){return n=>VS(Zb(n.ast,e.ast,t?Zv(t):ey()),{from:n,to:e})}function aC(e){return t=>VS(Xb(t.ast,e),{schema:t})}function oC(e){return jf(e,e=>hf(()=>xd(e,e=>e.issue)))}function sC(e,t){let n=t?.encodingStrategy===`omit`?Vv():Iv();return t=>B(GS(t)).pipe(iC(t,{decode:Hv(oC(e)),encode:n}))}function cC(e){return V(e).pipe(aC(P(e)))}function lC(e,t){return G({_tag:cC(e),...t})}function uC(e,t){return OS(t=>t instanceof e,t)}function dC(){return(e,t)=>new vy(e.ast,Zv(t))}var fC=Eb;function pC(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${st(n)})`:`new RegExp(${st(n)}, ${st(r)})`;return kb(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var mC=Db;function hC(e){let t=rr(e.order),n=e.formatter??st;return(r,i)=>fC(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function gC(e){let t=ar(e.order),n=e.formatter??st;return(r,i)=>fC(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function _C(e){let t=ir(e.order),n=e.formatter??st;return(r,i)=>fC(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function vC(e){let t=ar(e.order),n=rr(e.order),r=ir(e.order),i=nr(e.order),a=e.formatter??st;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return fC(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function yC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${st(e)}`);return e}var bC=hC({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:yC(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${st(e)})`})})}),J=gC({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:yC(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${st(e)})`})})}),xC=_C({order:er,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:yC(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${st(e)})`})})}),SC=vC({order:er,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:yC(e.minimum),maximum:yC(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${st(e.minimum)}, maximum: ${st(e.maximum)}, exclusiveMinimum: ${st(t)}, exclusiveMaximum: ${st(n)} })`})}}});function Y(e){return fC(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}function CC(e,t){return e=OC(e),wC(e,Math.ceil(e/2),t)}function wC(e,t,n){return fC(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[K_]:!0,arbitraryConstraint:{minLength:e},...n})}function TC(e,t){return e=OC(e),fC(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[K_]:!0,arbitraryConstraint:{maxLength:e},...t})}function EC(e,t){return e=OC(e),fC(t=>DC(t,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:`effect/schema/isMaxCodePoints`,payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function DC(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function OC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function kC(e){return fC(e=>fa(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var AC=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),jC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},MC=[];function NC(e){let t=AC(e),n=MC[t];if(n!==void 0)return n;let r=JC.pipe(iC(KS,cy(jC(t))));return MC[t]=r,r}globalThis.RegExp,globalThis.URL;var PC=H.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function FC(e,t){return PC.pipe(iC(e,ly(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;function IC(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:Qx(V(n));return VS(DS()([e],([e])=>(t,n,r)=>g_(t)?Ep(a===void 0?uf:wp(a(t.label,r),e=>new cv([`label`],e)),()=>Tp(Qx(e)(y_(t),r),{onSuccess:e=>__(e,{label:t.label}),onFailure:()=>new dv(n,[new cv([`value`],new pv(void 0,t,r))],t,r)})):I(new fv(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${st(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>dC()(e,{decode:Lv(e=>__(e,{label:n})),encode:r?Pv(e=>`Cannot serialize Redacted`+(lr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):Lv(y_)}),toEquivalence:([e])=>b_(e)}).ast,{value:e})}function LC(e,t){return iC(IC(WS(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Lv(e=>__(e,{label:t?.label})),encode:t?.disallowEncode?Pv(e=>`Cannot encode Redacted`+(lr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):Lv(y_)})(e)}var RC=globalThis.Symbol.for(`immer-draftable`),zC={};function BC(e,t,n,r,i){let a=UC(n,t,r),o=HC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===zC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:zC,value:i}})}static[ES]=ES;get[o](){return o}static[RC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return _(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Zx(a(this))(e??{},t)}static makeOption(e,t){return Xx(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Ib(this.ast,e))}static annotateKey(e){return this.rebuild(Kb(this.ast,e))}static check(...e){return this.rebuild(Rb(this.ast,e))}static extend(e){return(t,r)=>{let a=WC(t)?t:G(t),o={...n.fields,...a.fields},s=tb(o,n.ast.checks,{identifier:e});return BC(this,e,YS(Rb(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function VC(e){return new Yv(Lv(t=>new e(t,{"~payload":{token:zC,value:t}})),Iv())}function HC(e){return`~effect/Schema/Class/${e}`}function UC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=HC(t),o=e=>e instanceof i||D(e,a),s=VC(i);return r=iC(VS(new Cy([e.ast],()=>(e,t,n)=>o(e)?P(e):I(new fv(t,e,n)),{identifier:t,[J_]:([e])=>({isConstructed:o,link:new vy(e,s)}),toCodec:([e])=>new vy(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[q_]:cb(e.ast),...n})),s)(e)}}function WC(e){return HS(e)}var GC=e=>(t,n)=>BC(gn,e,WC(t)?t:G(t),n,e=>({name:e})),KC=e=>(t,n,r)=>{let i=WC(n)?n.mapFields(e=>({_tag:cC(t),...e}),{unsafePreserveChecks:!0}):lC(t,n);return GC(e??t)(i,r)},qC=gS,JC=VS(Ib(Tx,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),YC=`~effect/http/HttpBody`;Ta(`HttpBodyError`);var XC=class{[YC];constructor(){this[YC]=YC}[ht](){return this.toJSON()}toString(){return st(this,{ignoreToString:!0})}},ZC=new class extends XC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},QC=class extends XC{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=tw(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},$C=new TextEncoder,ew=globalThis.Buffer,tw=ew===void 0?e=>$C.encode(e):e=>ew.from(e,`utf8`),nw=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),ew!==void 0)return new QC(void 0,t??`text/plain`,ew.byteLength(e,`utf8`),e);let n=$C.encode(e);return new QC(n,t??`text/plain`,n.length,e)},rw=(e,t)=>nw(JSON.stringify(e),t??`application/json`),iw=class extends XC{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},aw=e=>new iw(e),ow=(e,t,n)=>{if(n!=null){if(typeof n==`object`){e.append(t,n);return}e.append(t,String(n))}},sw=e=>{let t=new globalThis.FormData;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)ow(t,n,e);else ow(t,n,r);return aw(t)},cw=class extends XC{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},lw=(e,t,n)=>new cw(e,t??`application/octet-stream`,n),uw=`~effect/http/HttpClientError`,dw=class extends Ta(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[uw]=uw;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},fw=e=>e.endsWith(`Error`)?e.slice(0,-5):e,pw=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,mw=class extends Ta(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return pw(fw(this._tag),this.description,this.methodAndUrl)}};Ta(`EncodeError`);var hw=class extends Ta(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return pw(fw(this._tag),this.description,this.methodAndUrl)}},gw=class extends Ta(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return pw(fw(this._tag),this.description,e)}},_w=class extends Ta(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return pw(fw(this._tag),this.description,e)}},vw=class extends Ta(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return pw(fw(this._tag),this.description,e)}};GC(uw)({_tag:cC(`HttpError`),kind:q([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:US(NC())});var yw=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],bw=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?j_(j_(e,`content-type`),`content-length`):(e=t.contentType===void 0?j_(e,`content-type`):O_(e,`content-type`,t.contentType),t.contentLength===void 0?j_(e,`content-length`):O_(e,`content-length`,t.contentLength.toString())),xw=class extends Ta(`UrlError`){},Sw=(e,t,n)=>Fi({try:()=>{let r=new URL(e,Cw());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new xw({cause:e})}),Cw=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},ww=`~effect/http/HttpClientRequest`,Tw={[ww]:ww,...vt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:nt(this.headers),body:this.body.toJSON()}},pipe(){return _(this,arguments)}};function Ew(e,t,n,r,i,a){let o=Object.create(Tw);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Dw=Ew(`GET`,``,U_,or(),T_,ZC),Ow=e=>(t,n)=>Pw(Dw,{method:e,url:t,...n??void 0}),kw=Ow(`GET`),Aw=Ow(`POST`),jw=Ow(`PATCH`),Mw=Ow(`PUT`),Nw=Ow(`DELETE`),Pw=b(2,(e,t)=>{let n=e;return t.method&&(n=Fw(n,t.method)),t.url&&(n=Hw(n,t.url)),t.headers&&(n=X(n,t.headers)),t.urlParams&&(n=Gw(n,t.urlParams)),t.hash&&(n=Kw(n,t.hash)),t.body&&(n=qw(n,t.body)),t.accept&&(n=Bw(n,t.accept)),t.acceptJson&&(n=Vw(n)),n}),Fw=b(2,(e,t)=>Ew(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Iw=b(3,(e,t,n)=>Ew(e.method,e.url,e.urlParams,e.hash,O_(e.headers,t,n),e.body)),X=b(2,(e,t)=>Ew(e.method,e.url,e.urlParams,e.hash,k_(e.headers,t),e.body)),Lw=b(2,(e,t)=>Ew(e.method,e.url,e.urlParams,e.hash,t(e.headers),e.body)),Rw=b(2,(e,t)=>Lw(e,j_(t))),zw=b(2,(e,t)=>Iw(e,`Authorization`,`Bearer ${m_(t)}`)),Bw=b(2,(e,t)=>Iw(e,`Accept`,t)),Vw=Bw(`application/json`),Hw=b(2,(e,t)=>{if(typeof t==`string`)return Ew(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=z_(n.searchParams),i=fr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ew(e.method,n.toString(),r,i,e.headers,e.body)}),Uw=b(2,(e,t)=>t===``?e:Ew(e.method,Ww(t,e.url),e.urlParams,e.hash,e.headers,e.body)),Ww=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},Gw=b(2,(e,t)=>Ew(e.method,e.url,W_(e.urlParams,t),e.hash,e.headers,e.body)),Kw=b(2,(e,t)=>Ew(e.method,e.url,e.urlParams,sr(t),e.headers,e.body)),qw=b(2,(e,t)=>Ew(e.method,e.url,e.urlParams,e.hash,bw(e.headers,t),t)),Jw=b(2,(e,t)=>qw(e,rw(t))),Yw=b(2,(e,t)=>qw(e,sw(t)));function Xw(e){let t=Sw(e.url,e.urlParams,pr(e.hash));return Li(t)?sr(t.success):or()}var Zw=`~effect/http/HttpIncomingMessage`,Qw=(e,t)=>{let n=IS(qC(e)),r=t?.reviver===void 0?void 0:IS(FC(qC(e),t));return e=>r===void 0?L(e.json,e=>n(e,t)):L(e.text,i=>i===``?L(e.json,e=>n(e,t)):r(i,t))},$w=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=vp(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=vp(e.text)}catch{}let i={...t,headers:nt(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},eT=`~effect/http/HttpClientResponse`,tT=(e,t)=>new rT(e,t),Z=b(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),nT=e=>e.status>=200&&e.status<300?P(e):I(new dw({reason:new gw({response:e,request:e.request,description:`non 2xx status code`})})),rT=class extends yt{[Zw];[eT];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Zw]=Zw,this[eT]=eT}toJSON(){return $w(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=Xw(this.request);return cr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return E_(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=s_(this.source.headers.getSetCookie())}get remoteAddress(){return or()}get stream(){return this.source.body?sg({evaluate:()=>this.source.body,onError:e=>new dw({reason:new _w({request:this.request,response:this,cause:e})})}):rg(new dw({reason:new vw({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return L(this.text,e=>_f({try:()=>e===``?null:JSON.parse(e),catch:e=>new dw({reason:new _w({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=R(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return L(this.text,e=>_f({try:()=>z_(new URLSearchParams(e)),catch:e=>new dw({reason:new _w({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=cf({try:()=>this.source.formData(),catch:e=>new dw({reason:new _w({request:this.request,response:this,cause:e})})}).pipe($f,vp)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=cf({try:()=>this.source.arrayBuffer(),catch:e=>new dw({reason:new _w({request:this.request,response:this,cause:e})})}).pipe($f,vp),this.arrayBufferBody}pipe(){return _(this,arguments)}},iT=e=>D_({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ur(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),aT=`~effect/http/HttpClient`,oT=_r(`effect/HttpClient`),sT=b(2,(e,t)=>lT(n=>t(e.postprocess(n)),e.preprocess)),cT=sT(L(nT)),lT=(e,t)=>{let n=Object.create(uT);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},uT={[aT]:aT,pipe(){return _(this,arguments)},...vt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(yw.map(([e,t])=>[t,function(t,n){return this.execute(Ow(e)(t,n))}]))},dT=e=>lT(t=>L(t,t=>yf(n=>{let r=bT.get(t),i=r??new AbortController,a=Sw(t.url,t.urlParams,pr(t.hash));if(Ii(a))return I(new dw({reason:new hw({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Pa)||n.getRef(mT)(t)){let a=e(t,o,i.signal,n);return r?a:rp(e=>Bf(e(a),{onSuccess(e){return yT.register(e,i),P(new xT(e,i))},onFailure(e){return wd(e)&&i.abort(),mf(e)}}))}return op(n.getRef(_T)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(P_),l=n.getRef(hT);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,N_(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(gT)?X(t,iT(a)):t,rp(s=>s(e(t,o,i.signal,n)).pipe(sp(a,{captureStackTrace:!1}),Bf({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,N_(t,c)?`<redacted>`:e.headers[t]);return r?P(e):(yT.register(e,i),P(new xT(e,i)))},onFailure(e){return!r&&wd(e)&&i.abort(),mf(e)}})))})})),P),fT=b(2,(e,t)=>lT(e.postprocess,n=>R(e.preprocess(n),t))),pT=b(2,(e,t)=>lT(e.postprocess,n=>L(e.preprocess(n),t))),mT=Yr(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>C}),hT=Yr(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>S}),gT=Yr(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:S}),_T=Yr(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),vT=e=>ld(oT)(Hf(t=>R(e,e=>sT(e,Wf(e=>qr(t,e)))))),yT=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),bT=new WeakMap,xT=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[eT]=eT;[Zw]=Zw;applyInterrupt(e){return lf(()=>(yT.unregister(this.original),tp(e,()=>F(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return ng(()=>(yT.unregister(this.original),vg(this.original.stream,F(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[ht](){return this.original[ht]()}pipe(){return _(this,arguments)}},ST=G({status:V(`ok`).annotate({description:"Process health. A successful response currently reports `ok`."}),color:q([`blue`,`green`]).annotate({description:`Deployment color of the process that handled the request.`}),role:q([`active`,`inactive`]).annotate({description:`Whether this deployment color currently serves active traffic.`}),version:H.annotate({description:`Build or release version embedded in the running binary.`,examples:[`1.4.0`]}),activeColor:q([`blue`,`green`]).annotate({description:`Deployment color currently selected as active.`})}).annotate({description:`Local deployment health and blue-green role information.`,examples:[{status:`ok`,color:`blue`,role:`active`,version:`1.4.0`,activeColor:`blue`}],identifier:`Health`}),Q=H.annotate({description:`Time-ordered UUID version 7 generated by Aperture.`,examples:[`019f6cf0-0000-7000-8000-000000000001`],format:`uuid`,identifier:`UUIDv7`}),CT=q([`api_token`,`user`,`system`]).annotate({description:`Stable category of the authenticated or audited actor.`,examples:[`api_token`],identifier:`PrincipalType`}),wT=q([`system_admin`,`tenant`]).annotate({description:"Authorization boundary. `system_admin` principals may administer the deployment and select tenants. `tenant` principals act within one effective tenant.\n",examples:[`tenant`],identifier:`AuthorityType`}),TT=q([`system:admin`,`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`,`tenants:write`]).annotate({description:"Permission granted to a principal. `system:admin` implies every scope. Tenant credentials and memberships cannot receive `system:admin` or `tenants:write`.\n",examples:[`sessions:write`],identifier:`Scope`}),ET=q([`all`,`allowlist`]).annotate({description:`Whether a tenant API token can access every tenant resource or only explicit grants.`,default:`all`,examples:[`allowlist`],identifier:`ResourceMode`}),DT=q([`session`,`snapshot`]).annotate({description:`Tenant resource category accepted by API token allowlists.`,examples:[`session`],identifier:`ResourceType`}),OT=G({code:H.annotate({description:`Stable code enumerated by each operation response.`,examples:[`insufficient_scope`]}),message:H.annotate({description:`Human-readable explanation. It may include resource or validation context.`,examples:[`insufficient scope`]})}).annotate({description:`Stable machine-readable error code with a human-readable explanation.`,identifier:`ErrorDetail`}),kT=G({name:H.annotate({description:`Configured browser channel name.`,examples:[`chromium`]})}).annotate({description:`Browser runtime selectable when creating a session.`,identifier:`BrowserChannel`}),AT=G({limit:U.annotate({description:`Effective page size after applying the default and maximum.`,examples:[50]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(xC(100).annotate({expected:`a value less than or equal to 100`})),nextCursor:B(H.annotate({description:`Opaque cursor for the next page. Omitted when there is no next page.`,examples:[`eyJjcmVhdGVkQXQiOiIyMDI2LTA3LTE3VDEyOjAwOjAwWiIsImlkIjoiMDE5ZjZjZjAtMDAwMC03MDAwLTgwMDAtMDAwMDAwMDAwMDAwIn0`]})),hasMore:W.annotate({description:`Whether another page is available.`,examples:[!0]})}).annotate({description:`Cursor pagination metadata for a newest-first result page.`,identifier:`PageMeta`});G({displayName:H.annotate({description:`Human-readable tenant name. Leading and trailing whitespace is removed and whitespace-only values are rejected.`,examples:[`Example engineering`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`}))}).annotate({description:`Tenant fields accepted by create and update operations.`,identifier:`TenantInput`}),G({email:B(eC([H,qS]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:H.check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:W.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`})}).annotate({identifier:`UserInput`});var jT=G({token:H.annotate({description:`Raw setup token. Store and transmit it as a secret.`}),expiresAt:H.annotate({format:`date-time`})}).annotate({description:`One-time account setup secret returned only when created.`,identifier:`UserInvitation`}),MT=q([`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`]).annotate({description:`Scope allowed on a tenant-bound API token.`,examples:[`sessions:write`],identifier:`TenantScope`}),NT=LC(H).annotate({identifier:`SensitiveString`}),PT=q([`creating`,`running`,`suspended`,`deleted`,`expired`,`failed`]).annotate({description:"Session lifecycle state:\n\n- `creating`: browser startup is in progress; the CDP endpoint does not answer yet.\n- `running`: browser and routing are available and the CDP endpoint answers.\n- `suspended`: browser is intentionally stopped while retained state remains available.\n- `deleted`: session is soft-deleted and may be reopened while retained.\n- `expired`: retention elapsed and the session can no longer be used.\n- `failed`: startup or reopen failed; retained state may still be reopenable.\n",examples:[`running`],identifier:`SessionStatus`}),FT=XS(H,H).annotate({description:`Arbitrary string key-value metadata. Tag-writing operations additionally reject blank keys and blank values.`,examples:[{environment:`production`,region:`eu-west-1`}],identifier:`StringMap`}),IT=G({url:H.annotate({examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})}).annotate({description:`A named upstream as stored. The secret is never returned and proxy URL passwords are masked.`,identifier:`SessionProxyUpstream`}),LT=G({match:H.annotate({description:"`host` or `host:port`, where the host is exact, `*.suffix` for subdomains, or `*` for any host. `*` never matches `localhost`, which only a rule naming it routes. Loopback IPs never reach the proxy, so local services are matched as `localhost`.",examples:[`*.example.test`]}),via:H.annotate({description:"`direct` dials from the session host, `refuse` fails the connection, `local` uses the attached local tunnel and fails while none is attached. Anything else names an upstream, or is an inline proxy URL without a secret.",examples:[`operator`]})}).annotate({description:`Routes the browser connections its match covers.`,identifier:`ProxyRule`}),RT=G({channel:H.annotate({description:"Channel returned by `GET /api/browser/channels`.",examples:[`chromium`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),args:B(K(H).annotate({description:`Additional Chromium command-line arguments. Aperture rejects arguments that conflict with supervisor-owned behavior or deployment policy.`,examples:[[`--lang=en-US`]]}))}).annotate({description:`Browser runtime configuration used to create or reopen the session.`,identifier:`BrowserConfig`}),zT=G({x:U.check(mC().annotate({expected:`a finite number`})),y:U.check(mC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserScrollPosition`}),BT=G({tag:H.check(pC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),index:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserElementPathStep`}),VT=G({start:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),end:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),direction:q([`forward`,`backward`,`none`])}).annotate({identifier:`InitialBrowserControlSelection`}),HT=q([`Strict`,`Lax`,`None`]).annotate({identifier:`BrowserCookieSameSite`}),UT=G({topLevelSite:H.annotate({format:`uri`}).check(pC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),hasCrossSiteAncestor:B(W)}).annotate({identifier:`InitialBrowserCookiePartitionKey`}),WT=G({kind:q([`none`,`string`,`array`]),value:B(K(H))}).annotate({description:`Object-store key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBKeyPath`}),GT=G({kind:q([`string`,`array`]),value:K(H).check(CC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Index key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBIndexKeyPath`}),KT=G({visible:W.annotate({description:`Whether to include the remote cursor in live streams and recordings.`})}).annotate({description:`Whether the remote browser cursor is composited into session media.`,identifier:`CursorVisibility`});G({origins:eC([V(`open-tabs`),K(H.check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(EC(2048).annotate({expected:`a string with at most 2048 code points`}))).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(TC(100).annotate({expected:`a value with a length of at most 100`}))],{mode:`oneOf`}).annotate({description:`Exact origins and/or * patterns, or open-tabs to select current pages and frames.`})}).annotate({examples:[{origins:[`*`]},{origins:[`https://example.com`,`https://*.example.org`]},{origins:`open-tabs`}],identifier:`ExportSessionStorageStateInput`});var qT=G({code:q([`ffmpeg_unavailable`,`open_failed`,`nothing_kept`,`analysis_failed`,`plan_failed`,`render_failed`,`timeout`,`cancelled`,`timeline_failed`]),message:H}).annotate({description:`Why a recording has no edit although one was due or a timeline could not be written. The raw video is published regardless.`,identifier:`RecordingEditError`});G({targetId:H.annotate({description:`Identifier of the ready top-level target to record.`}).check(CC(1).annotate({expected:`a value with a length of at least 1`})),fps:B(U.annotate({description:`Requested frames per second. Omit or use a non-positive value for the instance default.`,examples:[60]}).check(Y().annotate({expected:`an integer`}))),bitrateKbps:B(U.annotate({description:`Requested video bitrate in kilobits per second. Omit or use a non-positive value for the instance default.`,examples:[6e3]}).check(Y().annotate({expected:`an integer`}))),codec:B(q([`vp8`,`h264-va`]).annotate({description:`Video codec. Omit for the instance default.`,examples:[`vp8`]})),capture:B(q([`continuous`,`bursts`]).annotate({description:"With `bursts`, the edited video keeps only the stretches around browser tool calls, from `burst.leadMs` before a call to `burst.tailMs` after it, longer until the screen has stood still for `burst.settleMs` but at most `burst.maxTailMs`, and the recording follows the tab the automation acts on. The raw video is always the whole capture. Defaults to `continuous`. Cannot be combined with `idle`. Needs `recording_ffmpeg_executable` on the instance."})),presentation:B(W.annotate({description:`Run browser automation at presentation pace while the recording runs. Needs nothing of the instance.`})),idle:B(q([`cut`,`speed`]).annotate({description:"Remove (`cut`) or fast-forward (`speed`) the stretches of a continuous recording in which neither the picture nor the automation changes, in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),ripple:B(W.annotate({description:"Mark clicks with a ripple in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),burst:B(G({leadMs:B(U.annotate({description:`Kept before a tool call. Defaults to 500.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(xC(6e4).annotate({expected:`a value less than or equal to 60000`}))),tailMs:B(U.annotate({description:`Kept after a tool call. Defaults to 800.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(xC(6e4).annotate({expected:`a value less than or equal to 60000`}))),settleMs:B(U.annotate({description:`How long the screen must stand still to count as settled. Defaults to 400.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(xC(6e4).annotate({expected:`a value less than or equal to 60000`}))),maxTailMs:B(U.annotate({description:`Longest wait for the screen to settle after a call. Defaults to 3000.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(xC(6e4).annotate({expected:`a value less than or equal to 60000`})))}).annotate({description:"Burst sizes in milliseconds for `capture` `bursts`; rejected without it. Omitted or zero fields take the defaults. `tailMs` must not exceed `maxTailMs` (default 3000)."}))}).annotate({description:`Top-level target and optional recording settings.`,identifier:`CreateSessionRecordingInput`}),G({targetId:H.annotate({description:`Identifier of the ready destination top-level target.`}).check(CC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Destination for a running tab recording.`,identifier:`RetargetSessionRecordingInput`});var JT=G({type:V(`file`),name:H.annotate({description:`File name without directory components.`,examples:[`screencast-20260801T120000Z.webm`]}),relativePath:H.annotate({description:"Path below the session files root. Browser downloads are under `downloads/`, recordings under `recordings/`, uploads under `uploads/`, and Playwright MCP output under `outputs/`. Pass it to `browser_file_upload` or to create a signed download URL.",examples:[`recordings/screencast-20260801T120000Z.webm`]}),size:U.annotate({description:`File size in bytes.`,examples:[1048576],format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),modifiedAt:H.annotate({description:`Last file modification time.`,examples:[`2026-08-01T12:05:00Z`],format:`date-time`}),mimeType:H.annotate({description:`Detected media type.`,examples:[`video/webm`]}),sandboxPath:B(H.annotate({description:"Path of the file inside the session's browser sandbox, under the fixed `/session/files` root, for CDP `DOM.setFileInputFiles`. It is readable by the browser while the session runs. Absent for files of sessions created before session files moved under one root that are still in their old location.",examples:[`/session/files/recordings/screencast-20260801T120000Z.webm`]}))}).annotate({description:`Regular file retained with a browser session.`,identifier:`SessionFile`}),YT=G({type:V(`directory`),name:H.annotate({description:`Directory name without parent components.`,examples:[`invoices`]}),relativePath:H.annotate({description:`Path below the session files root.`,examples:[`uploads/invoices`]}),modifiedAt:H.annotate({format:`date-time`})}).annotate({description:`Directory below the session files root.`,identifier:`SessionDirectory`}),XT=uC(globalThis.Blob,{expected:`File | Blob`});G({from:H.annotate({description:"Current path from a `SessionFileEntry` result.",examples:[`downloads/invoice.pdf`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})),to:H.annotate({description:`New path below the session files root. Missing directories are created.`,examples:[`uploads/invoices/2026-08.pdf`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Current and new path of a session file.`,identifier:`MoveSessionFileInput`}),G({relativePath:H.annotate({description:`Path below the session files root. Missing parents are created.`,examples:[`uploads/invoices`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Directory to create.`,identifier:`CreateSessionDirectoryInput`}),G({relativePath:H.annotate({description:"Path from a `SessionFile` result.",examples:[`recordings/screencast-20260801T120000Z.webm`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})),ttlSeconds:B(U.annotate({description:"Requested lifetime in seconds. Omit it to use `signed_file_url_ttl`; values above `signed_file_url_max_ttl` are rejected.",examples:[900]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`}))),disposition:B(q([`attachment`,`inline`]).annotate({description:"How the URL presents the file. `inline` lets browsers display it, for example as an `<img>` source. Either way it is served with its detected `Content-Type`, `X-Content-Type-Options: nosniff`, and byte-range support. Content that can run scripts, such as HTML or SVG, also gets `Content-Security-Policy: sandbox`; images, audio, video, PDFs, and plain text do not, so browser viewers keep working.",default:`attachment`}))}).annotate({description:`Session file path and requested signed URL lifetime.`,identifier:`SessionFileDownloadURLInput`});var ZT=G({url:H.annotate({description:"URL containing a path-bound `apf_` token.",examples:[`https://aperture.example.com/sessions/019f6cf0-0000-7000-8000-000000000010/files/recordings/screencast-20260801T120000Z.webm?token=apf_REDACTED`],format:`uri`}),expiresAt:H.annotate({description:`Time after which the URL is rejected.`,examples:[`2026-08-01T12:20:00Z`],format:`date-time`})}).annotate({description:`Signed URL for one session file.`,identifier:`SessionFileDownloadURL`});G({description:B(eC([H,qS]).annotate({description:"New description. Send `null` to clear it; an empty string is stored as an empty description.",examples:[`Updated signed-in state`]}))}).annotate({description:`Replacement snapshot description.`,identifier:`UpdateSnapshotInput`});var QT=G({error:H.annotate({examples:[`file exceeds upload limit`]})}).annotate({description:`Error raised inside a running session. It carries a message but no stable code.`,identifier:`LiveSessionErrorBody`});G({targetId:H.annotate({description:`Identifier of the top-level target to resize.`}).check(CC(1).annotate({expected:`a value with a length of at least 1`})),width:U.annotate({description:`Logical width in CSS pixels. Widths below 500 are raised to 500.`,examples:[1280]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(xC(16384).annotate({expected:`a value less than or equal to 16384`})),height:U.annotate({description:`Logical height in CSS pixels.`,examples:[720]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(xC(16384).annotate({expected:`a value less than or equal to 16384`})),deviceScaleFactor:B(U.annotate({description:`Device pixel ratio, rounded to 1/120. Omit or use a non-positive value for 1. The scaled content size may not exceed 16384 pixels.`,examples:[1]}).check(mC().annotate({expected:`a finite number`})))}).annotate({description:`Requested logical viewport of one top-level target.`,identifier:`SetViewportInput`});var $T=G({width:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),height:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentWidth:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentHeight:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasWidth:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasHeight:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),deviceScaleFactor:U.annotate({description:`Effective device pixel ratio.`}).check(mC().annotate({expected:`a finite number`}))}).annotate({description:`Logical size, DPR-scaled content rectangle, and 64x64-bucketed media canvas of a target.`,identifier:`Viewport`}),eE=G({id:rC(()=>Q).annotate({description:`Tenant identifier.`}),displayName:H.annotate({description:`Human-readable tenant name.`,examples:[`Example engineering`]}),createdAt:H.annotate({description:`Time the tenant was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),deletedAt:B(eC([H,qS]).annotate({description:"Soft-deactivation time, or `null` for an active tenant.",examples:[null],format:`date-time`}))}).annotate({description:`Tenant account. Deletion is a reversible soft deactivation.`,identifier:`Tenant`}),tE=G({id:Q,email:B(eC([H,qS]).annotate({format:`email`})),displayName:H,isSystemAdmin:W,createdAt:H.annotate({format:`date-time`}),updatedAt:H.annotate({format:`date-time`}),disabledAt:B(eC([H,qS]).annotate({format:`date-time`})),passwordSetupStatus:B(q([`available`,`configured`,`email_required`,`user_disabled`,`login_disabled`]).annotate({description:`Password setup state included by the get-user operation.`}))}).annotate({identifier:`User`});G({ids:K(Q).annotate({description:`Up to 100 unique UUIDv7 values. An empty array is valid.`,examples:[[`019f6cf0-0000-7000-8000-000000000010`,`019f6cf0-0000-7000-8000-000000000011`]]}).check(TC(100).annotate({expected:`a value with a length of at most 100`})).check(kC().annotate({expected:`an array with unique items`}))}).annotate({description:`Ordered session IDs for a tenant-scoped bulk lookup. Missing, foreign, and deleted IDs are omitted from the result.`,identifier:`SessionBulkInput`});var nE=G({id:rC(()=>Q).annotate({description:`Event identifier.`}),tenantId:rC(()=>Q).annotate({description:`Tenant that owns the event.`}),resourceType:H.annotate({description:`Resource category associated with the event. Currently session events are the primary source; new categories may be added.`,examples:[`session`]}),resourceId:H.annotate({description:"Identifier of the associated resource. Its format depends on `resourceType`.",examples:[`019f6cf0-0000-7000-8000-000000000010`]}),type:H.annotate({description:`Extensible event type used for programmatic handling.`,examples:[`session.token_rotated`]}),message:H.annotate({description:`Human-readable event summary.`,examples:[`session token rotated`]}),data:XS(H,JC.annotate({expected:`JSON value`})).annotate({description:`Event-specific JSON payload, such as error details or upload metadata.`,examples:[{reason:`manual rotation`}]}),createdAt:H.annotate({description:`Time the event was recorded.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})}).annotate({description:`Immutable tenant-scoped audit or lifecycle event.`,identifier:`Event`}),rE=G({id:Q,actorType:CT,actorId:B(eC([H,qS])),tenantId:B(eC([Q,qS],{mode:`oneOf`})),action:H.annotate({examples:[`tenant_membership.upserted`]}),resourceType:H.annotate({examples:[`tenant_membership`]}),resourceId:B(eC([H,qS])),data:XS(H,JC.annotate({expected:`JSON value`})),createdAt:H.annotate({format:`date-time`})}).annotate({identifier:`AuditEvent`}),iE=G({resourceType:DT,resourceId:Q}).annotate({description:`Access to one existing tenant session or snapshot by its stable UUIDv7 identifier.`,identifier:`ResourceGrant`}),aE=G({error:OT}).annotate({description:`Standard error envelope returned by REST API operations.`,identifier:`Error`}),oE=G({channels:K(kT)}).annotate({description:`Browser channels enabled on this deployment.`,examples:[{channels:[{name:`chromium`}]}],identifier:`BrowserChannels`}),sE=G({tenantId:Q,userId:Q,scopes:K(MT).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`})),createdAt:H.annotate({format:`date-time`}),updatedAt:H.annotate({format:`date-time`})}).annotate({identifier:`TenantMembership`});G({scopes:K(MT).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`}))}).annotate({identifier:`TenantMembershipInput`});var cE=G({urls:K(H).annotate({description:`STUN or TURN server URLs.`,examples:[[`turn:turn.example.com:3478?transport=udp`]]}),username:B(H.annotate({description:`TURN username. Omitted when the server does not require authentication.`,examples:[`aperture-session`]})),credential:B(rC(()=>NT).annotate({description:`TURN credential. Treat it as a secret and do not persist it in logs.`,examples:[`REDACTED`]}))}).annotate({description:`ICE server configuration supplied to WebRTC consumers.`,identifier:`IceServer`}),lE=G({editorToken:rC(()=>NT).annotate({examples:[`ape_019f6cf0000070008000000000000010_REDACTED`]}),viewerToken:rC(()=>NT).annotate({examples:[`apv_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Owner-visible role-scoped secrets used to build collaboration links.`,identifier:`SessionCollaborationCapabilities`}),uE=G({url:rC(()=>NT).annotate({description:`Thumbnail of the tab most recently shown to a live-session client.`,format:`uri`}),targetUrlTemplate:rC(()=>NT).annotate({description:"Tab thumbnail URL with a literal `{targetId}` placeholder for a top-level target ID."}),expiresAt:H.annotate({format:`date-time`})}).annotate({description:`Signed thumbnail URLs for image elements. They need no other credentials and expire after the
|
|
22
|
+
`);n=kv(e)??wv(Y_(e.ast),e);break;default:n=bv(e);break}return t?`${n}\n at ${t}`:n}function kv(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return kv(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Av(e){let t;for(let n of e.reasons){if(!_d(n)||!rv(n.error))return;t??=n.error}return t}function jv(e,t){let n=Av(e);if(n===void 0)throw Error(t,{cause:e});return n}var Mv=e=>Object.assign(Object.create(v),e);function Nv(e){return Bv((t,n)=>I(e(t,n)))}function Pv(e){return Nv((t,n)=>{let r={message:e(t)};return lr(t)?new mv(r,t.value,n):new mv(r)})}var Fv=Mv({_tag:`Passthrough`});function Iv(){return Fv}function Lv(e){return Mv({_tag:`Transform`,transform:e})}function Rv(e){return Mv({_tag:`TransformEffect`,transform:e})}function zv(e){return Mv({_tag:`TransformOptional`,transform:e})}function Bv(e){return Mv({_tag:`TransformOptionalEffect`,transform:e})}function Vv(){return zv(()=>or())}function Hv(e){return Bv(t=>{let n=hr(t,pe);return lr(n)?P(n):Cp(e,sr)})}function Uv(){return Lv(globalThis.String)}function Wv(){return Lv(globalThis.Number)}function Gv(e){return Rv((t,n)=>_f({try:()=>JSON.parse(t,e?.reviver),catch:()=>new pv({expected:`a valid JSON string`},t,n)}))}function Kv(e){return Rv((t,n)=>_f({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new pv({expected:`a JSON-serializable value`},t,n)}))}var qv=class extends y{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new qv(this.encode,this.decode)}},Jv=`~effect/SchemaTransformation/Transformation`,Yv=class extends y{[Jv]=Jv;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Yv(this.encode,this.decode)}};function Xv(e){return D(e,Jv)&&e[Jv]===Jv}var Zv=e=>Xv(e)?e:new Yv(e.decode,e.encode);function Qv(e){return new Yv(Lv(e.decode),Lv(e.encode))}var $v=new Yv(Iv(),Iv());function ey(){return $v}var ty=new Yv(Wv(),Uv()),ny=e=>ge(e)&&typeof e.message==`string`,ry=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:sy(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},iy=e=>{try{let t=mt(e);return t===void 0?st(e):JSON.parse(t)}catch{return st(e)}},ay=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},oy=e=>{let t=new WeakSet,n=r=>{if(ye(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=ay(r,e,n);return t.delete(r),i}return iy(r)};return n},sy=e=>ny(e)?ry(e):e,cy=e=>Qv({decode:sy,encode:oy(e)});function ly(e){return new Yv(Gv(e??{}),Kv(e))}function uy(e){return t=>t._tag===e}var dy=uy(`Declaration`),fy=uy(`Never`),py=uy(`Literal`),my=uy(`UniqueSymbol`),hy=uy(`Arrays`),gy=uy(`Objects`),_y=uy(`Suspend`),vy=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},yy={},by=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},xy=`~effect/Schema`,Sy=class{[xy]=xy;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Cy=class extends Sy{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===X_?Q_:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Gb(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Cy(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},wy=new class extends Sy{_tag=`Null`;getParser(){return lx(this,null)}getExpected(){return`null`}},Ty=class extends Sy{_tag=`Undefined`;getParser(){return lx(this,void 0)}toCodecJson(){return Nb(this,[Ey])}getExpected(){return`undefined`}},Ey=new vy(wy,new Yv(Lv(()=>void 0),Lv(()=>null))),Dy=new Ty,Oy=new class extends Sy{_tag=`Unknown`;getParser(){return ux(this,he)}getExpected(){return`unknown`}},ky=class extends Sy{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${st(e)}`);this.literal=e}getParser(){return lx(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Ay(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Ay(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Ay(e){let t=globalThis.String(e.literal);return Nb(e,[new vy(new ky(t),new Yv(Lv(()=>e.literal),Lv(()=>t)))])}var jy=new class extends Sy{_tag=`String`;getParser(){return ux(this,ce)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&yx(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},My=class extends Sy{_tag=`Number`;getParser(){return ux(this,le)}matchKey(e,t){return this._match(mx,e,t)}matchPart(e,t){return this._match(px,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:yx(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Ny(this.checks,`effect/schema/isFinite`)||Ny(this.checks,`effect/schema/isInt`))?this:Nb(this,[Ob])}toCodecStringTree(){return this.toCodecJson()===this?Nb(this,[_x]):Nb(this,[vx])}getExpected(){return`number`}};function Ny(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Ny(e.checks,t))}var Py=new My,Fy=new class extends Sy{_tag=`Boolean`;getParser(){return ux(this,E)}getExpected(){return`boolean`}},Iy=class extends Sy{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(ex(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(ex(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new uv(n,t[o],i),a=new cv([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return I(new dv(n,[a],t,i))}return e.issues?I(new dv(n,e.issues,t,i)):Z_(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:vl(t.concurrency),f=d===1?zy(i,e,0,u):By(i,e,{concurrency:d,end:u});if(!f)return c(i);if(ks(f))return Ep(f,()=>c(i));let p=!0;return lf(()=>p?(p=!1,L(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===X_)return Q_;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):I(new fv(n,e,a))}catch(e){return gf(e)}}}_rebuild(e,t,n){let r=Gb(this.elements,e),i=Gb(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Iy(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ly(e,t,n,r){if(n._tag===`Failure`)return Vy(e,e.ast,r,n);let i=n===$_?t:n[k];if(i!==X_)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(ex(t.ast))return;let n=new cv([r],new lv(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Du(new dv(e.ast,[n],e.input,e.options))}}var Ry={onItem(e,t,n){let r=n<e.len?t:X_;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ly},zy=yl()(Ry),By=xl()(Ry),Vy=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Av(r.cause);if(i===void 0)return Eu(xd(r.cause,r=>new dv(t,[new cv([n],r)],e.input,e.options)));let a=new cv([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Du(new dv(t,[a],e.input,e.options))},Hy=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Uy(e,t,n=yy){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(dx(ax(t)))}var Wy=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Gy(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Gy);default:return!1}}function Ky(e){let t=Fb(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Ky);default:return!1}}function qy(e){return Gy(e)&&Ky(e)}var Jy=class{parameter;type;constructor(e,t){if(!qy(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,ex(t)&&!cx(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Yy=class extends Sy{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return ux(n,me);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(dx(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return Vy(t,n,i,s)??Ou;let c=s===$_?o:s[k];if(a!==X_&&c!==X_){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return Ou;Tt(t.out,a,c)}return Ou},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!ks(t))return L(Cf(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return Vy(e,n,r,a)??Ou;let o=a===$_?r:a[k],s=e.input[r],l=i.parserValue(s,e.options);return ks(l)?t(e,r,o,s,l):L(Cf(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return ks(a)?t(e,n,n,i,a):L(Cf(a),r=>t(e,n,n,i,r))},u=i?xl()({onItem:(e,[t,n])=>n.is.parameter===jy?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Dp(function*(t,d){if(t===X_)return X_;if(!(typeof t==`object`&&t&&!Array.isArray(t)))return yield*I(new fv(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:vl(d.concurrency),v=i&&g?n.indexSignatures.map(e=>Uy(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new uv(n,f[a],d),r=new cv([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}else return yield*I(new dv(n,[r],t,d))}}}if(r){let e=_===1?Qy(m,a):$y(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===jy?l:c,r=v?.[e]??(t.is.parameter===jy?Object.keys(f):Uy(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!ks(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=ca();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===jy?Object.keys(f):Uy(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*I(new dv(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return L(Cf(n),n=>{let i=Xy(e,r,n);if(i)return i;let o=()=>Z_(e.out),s=Qy(e,a.slice(t+1));return s?Ep(s,o):o()})};return(e,t)=>{if(e===X_)return Q_;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&vl(t.concurrency)!==1)return(l??=c())(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return I(new fv(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=fb(i,s),l=c?i[s]:X_,d=n.parser(l,t);if(!ks(d))return u(o,e,d);if(d===$_){c&&Tt(a,s,l);continue}let f=Xy(o,n,d);if(f)return f}}catch(e){return gf(e)}return Z_(a)}}_rebuild(e,t,n,r){let i=Gb(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Wy(t.name,n)}),a=Gb(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Jy(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Yy(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function Xy(e,t,n){if(n._tag===`Failure`)return Vy(e,e.ast,t.name,n);if(n===$_)return;let r=n[k];if(r!==X_){Tt(e.out,t.name,r);return}if(delete e.out[t.name],!ex(t.type)){let n=new cv([t.name],new lv(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}else return Du(new dv(e.ast,[n],e.input,e.options))}}var Zy={onItem(e,t){if(!fb(e.input,t.name))return t.parser(X_,e.options);let n=e.input[t.name];return Tt(e.out,t.name,n),t.parser(n,e.options)},step:Xy},Qy=yl()(Zy),$y=xl()(Zy);function eb(e,t){return e?t?[...e,...t]:e:t}function tb(e,t,n){return new Yy(Reflect.ownKeys(e).map(t=>new Wy(t,e[t].ast)),[],n,t)}function nb(e){return e.ast}function rb(e,t=void 0){return new Iy(!1,e.map(e=>e.ast),[],void 0,t)}function ib(e,t,n){return new mb(e.map(nb),t,void 0,n)}function ab(e){if(e.encoding)throw Error(`mutable does not support encodings`);return new Iy(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var ob=T(e=>{for(;;){if(_y(e))return Oy;let t=e.encoding;if(!t)return e.recur?.(ob,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return Oy;e=t[t.length-1].to}});function sb(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(sb)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function cb(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[q_];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ex(t)){if(py(t))return[{key:e.name,literal:t.literal}];if(my(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!ex(e)){if(py(e))return[{key:t,literal:e.literal}];if(my(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>cb(ob(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return cb(e.thunk())}}var lb=new WeakMap,ub=Object.freeze([]),db=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,fb=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function pb(e){let t=lb.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=ob(c);if(fy(l))continue;if(py(l)||my(l)){a??=new Map;let e=py(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=cb(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=sb(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??ub);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??ub;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(_e(e)){let n=fb(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??ub;if(t)return o}return ub}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=db(t);if(!_e(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=fb(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=fb(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=fb(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(db(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return lb.set(e,t),t}var mb=class extends Sy{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===X_)return Q_;let i=(o??=pb(n.types))(e,r);if(i.length===0)return I(new hv(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:ks(r)?hb(n,r.cause,e,t):gb(n,r,e,t)}return _b(n,a,i,e,t)}}_rebuild(e,t,n){let r=Gb(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new mb(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=ax(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(py);if(t.length>0)return`${xb(n.isMutable)}[ ${t.map(t=>e(t)+Sb(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>py(e.type));if(t.length>0)return`{ ${t.map(t=>`${xb(t.type.context?.isMutable)}${lt(t.name)}${Sb(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function hb(e,t,n,r){let i=Av(t);return i?Du(new hv(e,[i],n,r)):Eu(t)}function gb(e,t,n,r){return jf(t,t=>hb(e,t,n,r))}function _b(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=yb(a,n);return o?vb(o,a):a.out?a.out:I(new hv(e,a.issues??[],r,i))}function vb(e,t){return Ep(e,e=>t.out===$_?P(t.input):t.out?t.out:I(new hv(t.ast,t.issues??[],t.input,t.options)))}var yb=yl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Av(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Du(new gv(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Ou}}}),bb=new mb([new ky(`Infinity`),new ky(`-Infinity`),new ky(`NaN`)]);function xb(e){return e?``:`readonly `}function Sb(e){return e?`?`:``}var Cb=class extends Sy{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Cb(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},wb=class extends y{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new wb(this.run,{...this.annotations,...e},this.aborted)}abort(){return new wb(this.run,this.annotations,!0)}and(e,t){return new Tb([this,e],t)}},Tb=class extends y{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Tb(this.checks,{...this.annotations,...e})}and(e,t){return new Tb([this,e],t)}};function Eb(e,t,n=!1){return new wb((t,n,r)=>yv(n,e(t,n,r),t,r),t,n)}function Db(e){return Eb(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Ob=new vy(new mb([Rb(Py,[Db()]),bb]),new Yv(Wv(),Lv(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function kb(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Eb(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Ab=new WeakMap;function jb(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Ab.set(n,Mb(e)),n}function Mb(e){let t=Ab.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Ab.set(e,n),n}function Nb(e,t){return e.encoding===t?e:jb(e,{encoding:t})}function Pb(e,t){if(e.context===t)return e;let n=Mb(e);return n.context===t&&n.encoding===e.encoding?n:jb(e,{context:t})}function Fb(e){return e.encoding?Fb(e.encoding[e.encoding.length-1].to):e}function Ib(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Lb(e,Zi(e.checks.slice(0,-1),n.annotate(t)))}return jb(e,{annotations:{...e.annotations,...t}})}function Lb(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:jb(e,{checks:t})}function Rb(e,t){return Lb(e,eb(e.checks,t))}function zb(e,t){let n=t(e.to);return n===e.to?e:new vy(n,e.transformation)}function Bb(e,t){let n=e,r=n[n.length-1],i=zb(r,t);return i===r?e:Zi(e.slice(0,e.length-1),i)}function Vb(e){return t=>t.encoding?Nb(t,Bb(t.encoding,e)):t}function Hb(e,t){return Vb(e=>Pb(e,t))(e)}function Ub(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Nb(r,Bb(r.encoding,n))}return e(r)}return T(n)}function Wb(e,t,n){let r=new vy(e,t);return Nb(n,n.encoding?[...n.encoding,r]:[r])}function Gb(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function Kb(e,t){return Pb(e,e.context?new by(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new by(!1,!1,void 0,t))}var qb=T(e=>Jb(Pb(e,e.context?e.context.isOptional===!1?new by(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new by(!0,!1)))),Jb=Vb(qb),Yb=w(e=>qb(new mb([e,Dy])));function Xb(e,t){return Pb(e,e.context?new by(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new by(!1,!1,t))}function Zb(e,t,n){return Wb(e,n,t)}function Qb(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:de(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function $b(e,t){let{literals:n,parameters:r}=Qb(e);return new Yy(n.map(e=>new Wy(e,t)),r.map(e=>new Jy(e,t)))}function ex(e){return e.context?.isOptional??!1}function tx(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(tx)}function nx(e){function t(e){return tx(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Qi(n)?n:void 0}function rx(e){let t=!0;function n(e){return t=t&&!e.encoding&&!_y(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var ix=T(e=>{let t=Mb(e);if(t!==e){let n=ix(t);return n===t&&e.encoding===void 0?e:Pb(n,e.context)}let n=`recur`in e?e.recur(ix):e;if(`encodingChecks`in n&&n.encodingChecks){let t=rx(e)?n.encodingChecks:hy(n)||gy(n)||dy(n)&&n.typeParameters.length>0?nx(n.encodingChecks):void 0;return jb(n,{encodingChecks:void 0,checks:eb(n.checks,t)})}return n}),ax=T(e=>ix(sx(e)));function ox(e,t){let n=t,r=n.length,i=n[r-1],a=[new vy(sx(Nb(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new vy(sx(n[e-1].to),n[e].transformation.flip()));let o=sx(i.to);return o.encoding?Nb(o,[...o.encoding,...a]):Nb(o,a)}var sx=w(e=>{if(e.encoding)return ox(e,e.encoding);let t=Mb(e);if(t!==e){let n=sx(t);return n===t?e:Pb(n,e.context)}return`flip`in e?e.flip(sx):`recur`in e?e.recur(sx):e});function cx(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(cx);default:return!1}}function lx(e,t){let n=t===0?$_:Z_(t);return(r,i)=>r===X_?Q_:r===t?n:I(new fv(e,r,i))}function ux(e,t){return(n,r)=>n===X_?Q_:t(n)?$_:I(new fv(e,n,r))}var dx=Ub(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(dx)}}),fx=Ub(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(fx)}}),px=new globalThis.RegExp(`^${Hy}$`),mx=new globalThis.RegExp(`^(?:${Hy}|Infinity|-Infinity|NaN)$`);function hx(e){return kb(px,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:px.source}),...e})}var gx=Rb(jy,[hx()]),_x=new vy(gx,ty),vx=new vy(new mb([gx,bb]),ty);function yx(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=yx(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new ov(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function bx(e){if(!dy(e))return;let t=e.annotations?.[J_];return fe(t)?t(e.typeParameters):void 0}function xx(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Sx(e){return e===void 0||typeof e==`string`}function Cx(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function wx(e){return Cx(e,xx)}var Tx=new Cy([],()=>(e,t,n)=>wx(e)?$_:I(new fv(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>kx}),Ex=new vy(Tx,ey()),Dx=new vy(new mb([new Iy(!1,[],[Tx]),new Yy([],[new Jy(jy,Tx)])]),ey());function Ox(e){return Cx(e,Sx)}var kx=new vy(new Cy([],()=>(e,t,n)=>Ox(e)?$_:I(new fv(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),ey()),Ax=(e,t,n)=>e===$_?n(t):Ep(e,n);function jx(e){if(e._tag===`Middleware`)return(t,n,r)=>Mx(t===$_?e.decode(Z_(ev(n)),r):e.decode(Cp(t,ev),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===$_?Z_(t):e;case`Transform`:{let e=e=>e===X_?Q_:Z_(t.transform(e));return(t,n)=>Ax(t,n,e)}case`TransformOptional`:{let e=e=>tv(t.transform(ev(e)));return(t,n)=>Ax(t,n,e)}case`TransformEffect`:return(e,n,r)=>Ax(e,n,e=>e===X_?Q_:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Ax(e,n,e=>Mx(t.transform(ev(e),r)))}}var Mx=e=>Ep(e,tv),Nx=(e,t,n,r)=>jf(r,r=>hf(()=>xd(r,r=>new sv(e,r,t,n))));function Px(e,t){let n=jx(e.link.transformation),r;return(i,a)=>{if(i===X_)return Q_;if(e.isConstructed(i))return $_;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Fx(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==X_&&r!==void 0)return t(r,i);let a=n;if(ks(a)&&a._tag===`Success`){let e=t(a[k],i);return e===$_?a:e}return Ep(Nx(e,r,i,a),e=>{let n=t(e,i);return n===$_?Z_(e):n})}}function Ix(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Fx(e,n)}function Lx(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?bx(e):void 0,o=a?Px(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>jx(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks)if(ks(r)){if(r._tag===`Success`){let i=r===$_?t:r[k];if(t!==X_&&i!==X_){let i=yx(u,t,void 0,e,n);i&&(r=I(new dv(e,i,t,n)))}}}else r=L(r,r=>{if(t!==X_&&r!==X_){let r=yx(u,t,void 0,e,n);if(r)return I(new dv(e,r,t,n))}return P(r)});if(s&&!n.disableChecks)if(ks(r)){if(r._tag===`Success`){let i=r===$_?t:r[k];if(i===X_)return r;let a=yx(s,i,void 0,e,n);a&&(r=I(new dv(e,a,i,n)))}}else r=L(r,t=>{if(t!==X_){let r=yx(s,t,void 0,e,n);if(r)return I(new dv(e,r,t,n))}return P(t)});return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[k],o=t(a,r)):o=Ep(o,e=>{let n=t(e,r);return n===$_?Z_(e):n})}if(o._tag===`Success`){let e=o[k],t=p(e,r);return t===$_?o:t}return o=Nx(e,n,r,o),Ep(o,e=>{let t=p(e,r);return t===$_?Z_(e):t})}:p}var Rx=Symbol(),zx=new WeakMap,Bx,Vx=e=>Jx(e).parser,Hx=e=>Jx(e).makeEffect,Ux=e=>Ix(e,Hx),Wx=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Lx(this.ast,Vx)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Lx(this.ast,Hx,Ux)}},Gx=class extends Wx{compiled;resolve;constructor(e,t,n){super(e),this.compiled=t,this.resolve=n}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==`function`?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save(`is`,this.operation(`is`))}get decode(){return this.save(`decode`,this.operation(`decode`))}get make(){return this.save(`make`,this.operation(`make`))}get decodeEffect(){return this.save(`decodeEffect`,this.operation(`decodeEffect`)??Lx(this.ast,e=>qx(this.resolve,e,`parser`)))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save(`parser`,Kx(e,()=>this.decodeEffect))}get makeEffect(){let e=this.operation(`makeEffect`);if(e!==void 0)return this.save(`makeEffect`,e);let t=e=>qx(this.resolve,e,`makeEffect`);return this.save(`makeEffect`,Lx(this.ast,t,e=>Ix(e,t)))}};function Kx(e,t){let n;return(r,i)=>{if(r!==X_)try{let t=e(r,i);if(t!==Rx)return t===r?$_:Z_(t)}catch(e){return gf(e)}return(n??=t())(r,i)}}function qx(e,t,n){let r=e(t);if(r.compiled===void 0||Object.hasOwn(r,n))return r[n];let i;return(e,t)=>(i??=r[n])(e,t)}function Jx(e){let t=zx.get(e);if(t!==void 0)return t;let n=Bx===void 0?new Wx(e):new Gx(e,Bx(e,Jx),Jx);return zx.set(e,n),n}function Yx(e){let t=e.ast,n;return(e,r)=>(n??=aS(dS,ix(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Xx(e){let t=Yx(e);return(e,n)=>{let r=bp(t(e,n));return ku(r)?sr(r.value):(jv(r.cause,`Option adapter can only return none for schema issues`),or())}}function Zx(e){return lS(ix(e.ast))}function Qx(e,t){let n=rS(e.ast);return t===void 0?n:(e,r)=>n(e,tS(t,r))}function $x(e,t){return sS(Qx(e,t))}function eS(e,t){let n=rS(sx(e.ast));return t===void 0?n:(e,r)=>n(e,tS(t,r))}var tS=(e,t)=>t?{...e,...t}:e,nS=e=>e===X_?I(new pv):P(e);function rS(e){return aS(uS,e)}function iS(e,t){return e===$_?P(t):ks(e)?e[k]===X_?nS(X_):e:Ep(e,nS)}function aS(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??yy);return a===$_?P(r):ks(a)?a[k]===X_?nS(X_):a:Ep(a,nS)}}function oS(e){return(t,n)=>bp(e(t,n))}function sS(e){let t=oS(e);return(e,n)=>{let r=t(e,n);return ku(r)?sr(r.value):(jv(r.cause,`Option adapter can only return none for schema issues`),or())}}function cS(e,t){let n=bp(e);if(ku(n))return n.value;let r=jv(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function lS(e){let t,n;return(r,i)=>{t??=Jx(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??yy,o=t.make;if(o!==void 0&&r!==X_){let e;try{e=o(r,a)}catch(e){throw jv(yd(e),`Constructor adapter can only throw schema issues`),e}if(e!==Rx&&e!==X_)return e}return cS(iS((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var uS=e=>Jx(e).parser,dS=e=>Jx(e).makeEffect,fS=`~effect/Schema/Schema`,pS=Symbol(),mS={[fS]:fS,get make(){let e=Zx(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Yx(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Xx(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return _(this,arguments)},annotate(e){return this.rebuild(Ib(this.ast,e))},annotateKey(e){return this.rebuild(Kb(this.ast,e))},check(...e){return this.rebuild(Rb(this.ast,e))},rebuild(e){return hS(e,this[pS])}};function hS(e,t){function n(){}let r=Object.setPrototypeOf(n,mS);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[pS]=t,r.ast=e,r}function gS(e){return hS(_S(e.ast),{schema:e})}var _S=Ub(e=>{let t=SS(e,_S),n=e.context;return t===e||n===void 0?t:Hb(t,vS(n))});function vS(e){return e.constructorDefault===void 0?e:new by(e.isOptional,e.isMutable,void 0,e.annotations)}function yS(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function bS(e){return t=>{let n=[...t].sort((t,n)=>e(ax(t))-e(ax(n)));return n.some((e,n)=>e!==t[n])?n:t}}var xS=bS(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function SS(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!fe(n))return Nb(e,[Ex]);let r=n(e.typeParameters.map(e=>hS(ax(e))));return r===void 0?e:Nb(e,[zb(r,t)])}case`Unknown`:return Nb(e,[Ex]);case`ObjectKeyword`:return Nb(e,[Dx]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return yS(e),e.recur(t,fx);case`Union`:{let n=xS(e.types);return n===e.types?e.recur(t):new mb(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var CS=e=>e,wS=`~effect/Schema/SchemaError`;function TS(e){return D(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var ES=fS;function DS(){return(e,t,n)=>HS(new Cy(e.map(nb),e=>t(e.map(e=>HS(e))),n))}function OS(e,t){return DS()([],()=>(t,n,r)=>e(t)?P(t):I(new fv(n,t,r)),t)}var kS=class extends Ta(`SchemaError`){[wS]=wS;constructor(e){let t=xt();St(0);try{super({issue:e})}finally{St(t)}}get message(){return Dv(this.issue)}toString(){return`SchemaError(${this.message})`}};function AS(e){return TS(e)}function jS(e){return ks(e)?MS(e):jf(e,e=>hf(()=>xd(e,e=>new kS(e))))}function MS(e){return ku(e)?e:Eu(xd(e.cause,e=>new kS(e)))}function NS(e,t){let n;for(let r of e.reasons){if(!_d(r)||!AS(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function PS(e){let t=bp(e);if(ku(t))return t.value;throw NS(t.cause,`Sync adapter can only throw schema errors`)}function FS(e,t){let n=Qx(e,t);return(e,t)=>jS(n(e,t))}var IS=FS,LS=$x;function RS(e,t){let n=FS(e,t);return(e,t)=>PS(n(e,t))}function zS(e,t){let n=eS(e,t);return(e,t)=>jS(n(e,t))}function BS(e,t){let n=zS(e,t);return(e,t)=>PS(n(e,t))}var VS=BS,HS=hS;function US(e){return D(e,ES)&&e[ES]===ES}var B=CS(e=>HS(qb(e.ast),{schema:e})),WS=CS(e=>{let t=rC(e);return HS(Yb(e.ast),{schema:t})}),GS=CS(e=>HS(ix(e.ast),{schema:e})),KS=CS(e=>HS(ax(e.ast),{schema:e}));function V(e){let t=HS(new ky(e),{literal:e,transform(n){return t.pipe(aC(V(n),{decode:Lv(()=>n),encode:Lv(()=>e)}))}});return t}var qS=HS(Oy),JS=HS(wy),YS=HS(Dy),H=HS(jy),U=HS(Py),W=HS(Fy);function XS(e,t){return HS(e,{fields:t,mapFields(e,t){let n=e(this.fields);return XS(tb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function G(e){return XS(tb(e,void 0),e)}function ZS(e,t){return HS($b(e.ast,t.ast),{key:e,value:t})}function QS(e,t){return HS(e,{elements:t,mapElements(e,t){let n=e(this.elements);return QS(rb(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}var K=CS(e=>HS(new Iy(!1,[],[e.ast]),{value:e})),$S=CS(e=>HS(ab(e.ast),{schema:e}));function eC(e,t){return HS(e,{members:t,mapMembers(e,t){let n=e(this.members);return eC(ib(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function tC(e,t){return eC(ib(e,t,void 0),e)}function q(e){let t=e.map(V);return HS(ib(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return tC(e(this.members))},pick(e){return q(e)},transform(e){return tC(t.map((t,n)=>t.transform(e[n])))}})}var nC=CS(e=>tC([e,JS])),rC=CS(e=>tC([e,YS]));function iC(e){return HS(new Cb(()=>e().ast))}function aC(e,t){return n=>HS(Zb(n.ast,e.ast,t?Zv(t):ey()),{from:n,to:e})}function oC(e){return t=>HS(Xb(t.ast,e),{schema:t})}function sC(e){return jf(e,e=>hf(()=>xd(e,e=>e.issue)))}function cC(e,t){let n=t?.encodingStrategy===`omit`?Vv():Iv();return t=>B(KS(t)).pipe(aC(t,{decode:Hv(sC(e)),encode:n}))}function lC(e){return V(e).pipe(oC(P(e)))}function uC(e,t){return G({_tag:lC(e),...t})}function dC(e,t){return OS(t=>t instanceof e,t)}function fC(){return(e,t)=>new vy(e.ast,Zv(t))}var pC=Eb;function mC(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${st(n)})`:`new RegExp(${st(n)}, ${st(r)})`;return kb(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var hC=Db;function gC(e){let t=rr(e.order),n=e.formatter??st;return(r,i)=>pC(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function _C(e){let t=ar(e.order),n=e.formatter??st;return(r,i)=>pC(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function vC(e){let t=ir(e.order),n=e.formatter??st;return(r,i)=>pC(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function yC(e){let t=ar(e.order),n=rr(e.order),r=ir(e.order),i=nr(e.order),a=e.formatter??st;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return pC(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function bC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${st(e)}`);return e}var xC=gC({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:bC(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${st(e)})`})})}),J=_C({order:er,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:bC(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${st(e)})`})})}),SC=vC({order:er,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:bC(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${st(e)})`})})}),CC=yC({order:er,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:bC(e.minimum),maximum:bC(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${st(e.minimum)}, maximum: ${st(e.maximum)}, exclusiveMinimum: ${st(t)}, exclusiveMaximum: ${st(n)} })`})}}});function Y(e){return pC(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}function wC(e,t){return e=kC(e),TC(e,Math.ceil(e/2),t)}function TC(e,t,n){return pC(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[K_]:!0,arbitraryConstraint:{minLength:e},...n})}function EC(e,t){return e=kC(e),pC(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[K_]:!0,arbitraryConstraint:{maxLength:e},...t})}function DC(e,t){return e=kC(e),pC(t=>OC(t,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:`effect/schema/isMaxCodePoints`,payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function OC(e,t){if(t===0)return 0;let n=0;for(let r of e)if(++n>=t)break;return n}function kC(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function AC(e){return pC(e=>fa(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:x},...e})}var jC=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),MC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},NC=[];function PC(e){let t=jC(e),n=NC[t];if(n!==void 0)return n;let r=YC.pipe(aC(qS,cy(MC(t))));return NC[t]=r,r}globalThis.RegExp,globalThis.URL;var FC=H.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function IC(e,t){return FC.pipe(aC(e,ly(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;function LC(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:Qx(V(n));return HS(DS()([e],([e])=>(t,n,r)=>g_(t)?Ep(a===void 0?uf:wp(a(t.label,r),e=>new cv([`label`],e)),()=>Tp(Qx(e)(y_(t),r),{onSuccess:e=>__(e,{label:t.label}),onFailure:()=>new dv(n,[new cv([`value`],new pv(void 0,t,r))],t,r)})):I(new fv(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${st(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>fC()(e,{decode:Lv(e=>__(e,{label:n})),encode:r?Pv(e=>`Cannot serialize Redacted`+(lr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):Lv(y_)}),toEquivalence:([e])=>b_(e)}).ast,{value:e})}function RC(e,t){return aC(LC(GS(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Lv(e=>__(e,{label:t?.label})),encode:t?.disallowEncode?Pv(e=>`Cannot encode Redacted`+(lr(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):Lv(y_)})(e)}var zC=globalThis.Symbol.for(`immer-draftable`),BC={};function VC(e,t,n,r,i){let a=WC(n,t,r),o=UC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===BC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:BC,value:i}})}static[ES]=ES;get[o](){return o}static[zC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return _(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Zx(a(this))(e??{},t)}static makeOption(e,t){return Xx(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Ib(this.ast,e))}static annotateKey(e){return this.rebuild(Kb(this.ast,e))}static check(...e){return this.rebuild(Rb(this.ast,e))}static extend(e){return(t,r)=>{let a=GC(t)?t:G(t),o={...n.fields,...a.fields},s=tb(o,n.ast.checks,{identifier:e});return VC(this,e,XS(Rb(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function HC(e){return new Yv(Lv(t=>new e(t,{"~payload":{token:BC,value:t}})),Iv())}function UC(e){return`~effect/Schema/Class/${e}`}function WC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=UC(t),o=e=>e instanceof i||D(e,a),s=HC(i);return r=aC(HS(new Cy([e.ast],()=>(e,t,n)=>o(e)?P(e):I(new fv(t,e,n)),{identifier:t,[J_]:([e])=>({isConstructed:o,link:new vy(e,s)}),toCodec:([e])=>new vy(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[q_]:cb(e.ast),...n})),s)(e)}}function GC(e){return US(e)}var KC=e=>(t,n)=>VC(gn,e,GC(t)?t:G(t),n,e=>({name:e})),qC=e=>(t,n,r)=>{let i=GC(n)?n.mapFields(e=>({_tag:lC(t),...e}),{unsafePreserveChecks:!0}):uC(t,n);return KC(e??t)(i,r)},JC=gS,YC=HS(Ib(Tx,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),XC=`~effect/http/HttpBody`;Ta(`HttpBodyError`);var ZC=class{[XC];constructor(){this[XC]=XC}[ht](){return this.toJSON()}toString(){return st(this,{ignoreToString:!0})}},QC=new class extends ZC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},$C=class extends ZC{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=nw(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},ew=new TextEncoder,tw=globalThis.Buffer,nw=tw===void 0?e=>ew.encode(e):e=>tw.from(e,`utf8`),rw=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),tw!==void 0)return new $C(void 0,t??`text/plain`,tw.byteLength(e,`utf8`),e);let n=ew.encode(e);return new $C(n,t??`text/plain`,n.length,e)},iw=(e,t)=>rw(JSON.stringify(e),t??`application/json`),aw=class extends ZC{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},ow=e=>new aw(e),sw=(e,t,n)=>{if(n!=null){if(typeof n==`object`){e.append(t,n);return}e.append(t,String(n))}},cw=e=>{let t=new globalThis.FormData;for(let[n,r]of Object.entries(e))if(Array.isArray(r))for(let e of r)sw(t,n,e);else sw(t,n,r);return ow(t)},lw=class extends ZC{_tag=`Stream`;stream;contentType;contentLength;constructor(e,t,n){super(),this.stream=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Stream`,contentType:this.contentType,contentLength:this.contentLength}}},uw=(e,t,n)=>new lw(e,t??`application/octet-stream`,n),dw=`~effect/http/HttpClientError`,fw=class extends Ta(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[dw]=dw;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},pw=e=>e.endsWith(`Error`)?e.slice(0,-5):e,mw=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,hw=class extends Ta(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return mw(pw(this._tag),this.description,this.methodAndUrl)}};Ta(`EncodeError`);var gw=class extends Ta(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return mw(pw(this._tag),this.description,this.methodAndUrl)}},_w=class extends Ta(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return mw(pw(this._tag),this.description,e)}},vw=class extends Ta(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return mw(pw(this._tag),this.description,e)}},yw=class extends Ta(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return mw(pw(this._tag),this.description,e)}};KC(dw)({_tag:lC(`HttpError`),kind:q([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:WS(PC())});var bw=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],xw=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?j_(j_(e,`content-type`),`content-length`):(e=t.contentType===void 0?j_(e,`content-type`):O_(e,`content-type`,t.contentType),t.contentLength===void 0?j_(e,`content-length`):O_(e,`content-length`,t.contentLength.toString())),Sw=class extends Ta(`UrlError`){},Cw=(e,t,n)=>Fi({try:()=>{let r=new URL(e,ww());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new Sw({cause:e})}),ww=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Tw=`~effect/http/HttpClientRequest`,Ew={[Tw]:Tw,...vt,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:nt(this.headers),body:this.body.toJSON()}},pipe(){return _(this,arguments)}};function Dw(e,t,n,r,i,a){let o=Object.create(Ew);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var Ow=Dw(`GET`,``,U_,or(),T_,QC),kw=e=>(t,n)=>Fw(Ow,{method:e,url:t,...n??void 0}),Aw=kw(`GET`),jw=kw(`POST`),Mw=kw(`PATCH`),Nw=kw(`PUT`),Pw=kw(`DELETE`),Fw=b(2,(e,t)=>{let n=e;return t.method&&(n=Iw(n,t.method)),t.url&&(n=Uw(n,t.url)),t.headers&&(n=X(n,t.headers)),t.urlParams&&(n=Kw(n,t.urlParams)),t.hash&&(n=qw(n,t.hash)),t.body&&(n=Jw(n,t.body)),t.accept&&(n=Vw(n,t.accept)),t.acceptJson&&(n=Hw(n)),n}),Iw=b(2,(e,t)=>Dw(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Lw=b(3,(e,t,n)=>Dw(e.method,e.url,e.urlParams,e.hash,O_(e.headers,t,n),e.body)),X=b(2,(e,t)=>Dw(e.method,e.url,e.urlParams,e.hash,k_(e.headers,t),e.body)),Rw=b(2,(e,t)=>Dw(e.method,e.url,e.urlParams,e.hash,t(e.headers),e.body)),zw=b(2,(e,t)=>Rw(e,j_(t))),Bw=b(2,(e,t)=>Lw(e,`Authorization`,`Bearer ${m_(t)}`)),Vw=b(2,(e,t)=>Lw(e,`Accept`,t)),Hw=Vw(`application/json`),Uw=b(2,(e,t)=>{if(typeof t==`string`)return Dw(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=z_(n.searchParams),i=fr(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Dw(e.method,n.toString(),r,i,e.headers,e.body)}),Ww=b(2,(e,t)=>t===``?e:Dw(e.method,Gw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),Gw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},Kw=b(2,(e,t)=>Dw(e.method,e.url,W_(e.urlParams,t),e.hash,e.headers,e.body)),qw=b(2,(e,t)=>Dw(e.method,e.url,e.urlParams,sr(t),e.headers,e.body)),Jw=b(2,(e,t)=>Dw(e.method,e.url,e.urlParams,e.hash,xw(e.headers,t),t)),Yw=b(2,(e,t)=>Jw(e,iw(t))),Xw=b(2,(e,t)=>Jw(e,cw(t)));function Zw(e){let t=Cw(e.url,e.urlParams,pr(e.hash));return Li(t)?sr(t.success):or()}var Qw=`~effect/http/HttpIncomingMessage`,$w=(e,t)=>{let n=IS(JC(e)),r=t?.reviver===void 0?void 0:IS(IC(JC(e),t));return e=>r===void 0?L(e.json,e=>n(e,t)):L(e.text,i=>i===``?L(e.json,e=>n(e,t)):r(i,t))},eT=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=vp(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=vp(e.text)}catch{}let i={...t,headers:nt(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},tT=`~effect/http/HttpClientResponse`,nT=(e,t)=>new iT(e,t),Z=b(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),rT=e=>e.status>=200&&e.status<300?P(e):I(new fw({reason:new _w({response:e,request:e.request,description:`non 2xx status code`})})),iT=class extends yt{[Qw];[tT];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Qw]=Qw,this[tT]=tT}toJSON(){return eT(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=Zw(this.request);return cr(e)?``:(e.value.hash=``,e.value.href)}get headers(){return E_(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=s_(this.source.headers.getSetCookie())}get remoteAddress(){return or()}get stream(){return this.source.body?sg({evaluate:()=>this.source.body,onError:e=>new fw({reason:new vw({request:this.request,response:this,cause:e})})}):rg(new fw({reason:new yw({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return L(this.text,e=>_f({try:()=>e===``?null:JSON.parse(e),catch:e=>new fw({reason:new vw({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=R(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return L(this.text,e=>_f({try:()=>z_(new URLSearchParams(e)),catch:e=>new fw({reason:new vw({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=cf({try:()=>this.source.formData(),catch:e=>new fw({reason:new vw({request:this.request,response:this,cause:e})})}).pipe($f,vp)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=cf({try:()=>this.source.arrayBuffer(),catch:e=>new fw({reason:new vw({request:this.request,response:this,cause:e})})}).pipe($f,vp),this.arrayBufferBody}pipe(){return _(this,arguments)}},aT=e=>D_({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${ur(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),oT=`~effect/http/HttpClient`,sT=_r(`effect/HttpClient`),cT=b(2,(e,t)=>uT(n=>t(e.postprocess(n)),e.preprocess)),lT=cT(L(rT)),uT=(e,t)=>{let n=Object.create(dT);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},dT={[oT]:oT,pipe(){return _(this,arguments)},...vt,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(bw.map(([e,t])=>[t,function(t,n){return this.execute(kw(e)(t,n))}]))},fT=e=>uT(t=>L(t,t=>yf(n=>{let r=xT.get(t),i=r??new AbortController,a=Cw(t.url,t.urlParams,pr(t.hash));if(Ii(a))return I(new fw({reason:new gw({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Pa)||n.getRef(hT)(t)){let a=e(t,o,i.signal,n);return r?a:rp(e=>Bf(e(a),{onSuccess(e){return bT.register(e,i),P(new ST(e,i))},onFailure(e){return wd(e)&&i.abort(),mf(e)}}))}return op(n.getRef(vT)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(P_),l=n.getRef(gT);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,N_(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(_T)?X(t,aT(a)):t,rp(s=>s(e(t,o,i.signal,n)).pipe(sp(a,{captureStackTrace:!1}),Bf({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,N_(t,c)?`<redacted>`:e.headers[t]);return r?P(e):(bT.register(e,i),P(new ST(e,i)))},onFailure(e){return!r&&wd(e)&&i.abort(),mf(e)}})))})})),P),pT=b(2,(e,t)=>uT(e.postprocess,n=>R(e.preprocess(n),t))),mT=b(2,(e,t)=>uT(e.postprocess,n=>L(e.preprocess(n),t))),hT=Yr(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>C}),gT=Yr(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>S}),_T=Yr(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:S}),vT=Yr(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),yT=e=>ld(sT)(Hf(t=>R(e,e=>cT(e,Wf(e=>qr(t,e)))))),bT=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),xT=new WeakMap,ST=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[tT]=tT;[Qw]=Qw;applyInterrupt(e){return lf(()=>(bT.unregister(this.original),tp(e,()=>F(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return ng(()=>(bT.unregister(this.original),vg(this.original.stream,F(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[ht](){return this.original[ht]()}pipe(){return _(this,arguments)}},CT=G({status:V(`ok`).annotate({description:"Process health. A successful response currently reports `ok`."}),color:q([`blue`,`green`]).annotate({description:`Deployment color of the process that handled the request.`}),role:q([`active`,`inactive`]).annotate({description:`Whether this deployment color currently serves active traffic.`}),version:H.annotate({description:`Build or release version embedded in the running binary.`,examples:[`1.4.0`]}),activeColor:q([`blue`,`green`]).annotate({description:`Deployment color currently selected as active.`})}).annotate({description:`Local deployment health and blue-green role information.`,examples:[{status:`ok`,color:`blue`,role:`active`,version:`1.4.0`,activeColor:`blue`}],identifier:`Health`}),Q=H.annotate({description:`Time-ordered UUID version 7 generated by Aperture.`,examples:[`019f6cf0-0000-7000-8000-000000000001`],format:`uuid`,identifier:`UUIDv7`}),wT=q([`api_token`,`user`,`system`]).annotate({description:`Stable category of the authenticated or audited actor.`,examples:[`api_token`],identifier:`PrincipalType`}),TT=q([`system_admin`,`tenant`]).annotate({description:"Authorization boundary. `system_admin` principals may administer the deployment and select tenants. `tenant` principals act within one effective tenant.\n",examples:[`tenant`],identifier:`AuthorityType`}),ET=q([`system:admin`,`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`,`tenants:write`]).annotate({description:"Permission granted to a principal. `system:admin` implies every scope. Tenant credentials and memberships cannot receive `system:admin` or `tenants:write`.\n",examples:[`sessions:write`],identifier:`Scope`}),DT=q([`all`,`allowlist`]).annotate({description:`Whether a tenant API token can access every tenant resource or only explicit grants.`,default:`all`,examples:[`allowlist`],identifier:`ResourceMode`}),OT=q([`session`,`snapshot`]).annotate({description:`Tenant resource category accepted by API token allowlists.`,examples:[`session`],identifier:`ResourceType`}),kT=G({code:H.annotate({description:`Stable code enumerated by each operation response.`,examples:[`insufficient_scope`]}),message:H.annotate({description:`Human-readable explanation. It may include resource or validation context.`,examples:[`insufficient scope`]})}).annotate({description:`Stable machine-readable error code with a human-readable explanation.`,identifier:`ErrorDetail`}),AT=G({name:H.annotate({description:`Configured browser channel name.`,examples:[`chromium`]})}).annotate({description:`Browser runtime selectable when creating a session.`,identifier:`BrowserChannel`}),jT=G({limit:U.annotate({description:`Effective page size after applying the default and maximum.`,examples:[50]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(SC(100).annotate({expected:`a value less than or equal to 100`})),nextCursor:B(H.annotate({description:`Opaque cursor for the next page. Omitted when there is no next page.`,examples:[`eyJjcmVhdGVkQXQiOiIyMDI2LTA3LTE3VDEyOjAwOjAwWiIsImlkIjoiMDE5ZjZjZjAtMDAwMC03MDAwLTgwMDAtMDAwMDAwMDAwMDAwIn0`]})),hasMore:W.annotate({description:`Whether another page is available.`,examples:[!0]})}).annotate({description:`Cursor pagination metadata for a newest-first result page.`,identifier:`PageMeta`});G({displayName:H.annotate({description:`Human-readable tenant name. Leading and trailing whitespace is removed and whitespace-only values are rejected.`,examples:[`Example engineering`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`}))}).annotate({description:`Tenant fields accepted by create and update operations.`,identifier:`TenantInput`}),G({email:B(tC([H,JS]).annotate({description:`Optional normalized login and contact email.`,format:`email`})),displayName:H.check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),isSystemAdmin:W.annotate({description:`Grants deployment-wide administration independently of tenant memberships.`})}).annotate({identifier:`UserInput`});var MT=G({token:H.annotate({description:`Raw setup token. Store and transmit it as a secret.`}),expiresAt:H.annotate({format:`date-time`})}).annotate({description:`One-time account setup secret returned only when created.`,identifier:`UserInvitation`}),NT=q([`sessions:read`,`sessions:write`,`snapshots:read`,`snapshots:write`,`tenant:write`]).annotate({description:`Scope allowed on a tenant-bound API token.`,examples:[`sessions:write`],identifier:`TenantScope`}),PT=RC(H).annotate({identifier:`SensitiveString`}),FT=q([`creating`,`running`,`suspended`,`deleted`,`expired`,`failed`]).annotate({description:"Session lifecycle state:\n\n- `creating`: browser startup is in progress; the CDP endpoint does not answer yet.\n- `running`: browser and routing are available and the CDP endpoint answers.\n- `suspended`: browser is intentionally stopped while retained state remains available.\n- `deleted`: session is soft-deleted and may be reopened while retained.\n- `expired`: retention elapsed and the session can no longer be used.\n- `failed`: startup or reopen failed; retained state may still be reopenable.\n",examples:[`running`],identifier:`SessionStatus`}),IT=ZS(H,H).annotate({description:`Arbitrary string key-value metadata. Tag-writing operations additionally reject blank keys and blank values.`,examples:[{environment:`production`,region:`eu-west-1`}],identifier:`StringMap`}),LT=G({url:H.annotate({examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})}).annotate({description:`A named upstream as stored. The secret is never returned and proxy URL passwords are masked.`,identifier:`SessionProxyUpstream`}),RT=G({match:H.annotate({description:"`host` or `host:port`, where the host is exact, `*.suffix` for subdomains, or `*` for any host. `*` never matches `localhost`, which only a rule naming it routes. Loopback IPs never reach the proxy, so local services are matched as `localhost`.",examples:[`*.example.test`]}),via:H.annotate({description:"`direct` dials from the session host, `refuse` fails the connection, `local` uses the attached local tunnel and fails while none is attached. Anything else names an upstream, or is an inline proxy URL without a secret.",examples:[`operator`]})}).annotate({description:`Routes the browser connections its match covers.`,identifier:`ProxyRule`}),zT=G({channel:H.annotate({description:"Channel returned by `GET /api/browser/channels`.",examples:[`chromium`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),args:B(K(H).annotate({description:`Additional Chromium command-line arguments. Aperture rejects arguments that conflict with supervisor-owned behavior or deployment policy.`,examples:[[`--lang=en-US`]]}))}).annotate({description:`Browser runtime configuration used to create or reopen the session.`,identifier:`BrowserConfig`}),BT=G({x:U.check(hC().annotate({expected:`a finite number`})),y:U.check(hC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserScrollPosition`}),VT=G({tag:H.check(mC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),index:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserElementPathStep`}),HT=G({start:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),end:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),direction:q([`forward`,`backward`,`none`])}).annotate({identifier:`InitialBrowserControlSelection`}),UT=q([`Strict`,`Lax`,`None`]).annotate({identifier:`BrowserCookieSameSite`}),WT=G({topLevelSite:H.annotate({format:`uri`}).check(mC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),hasCrossSiteAncestor:B(W)}).annotate({identifier:`InitialBrowserCookiePartitionKey`}),GT=G({kind:q([`none`,`string`,`array`]),value:B(K(H))}).annotate({description:`Object-store key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBKeyPath`}),KT=G({kind:q([`string`,`array`]),value:K(H).check(wC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Index key path. String paths contain one value; array paths contain at least one.`,identifier:`InitialIndexedDBIndexKeyPath`}),qT=G({visible:W.annotate({description:`Whether to include the remote cursor in live streams and recordings.`})}).annotate({description:`Whether the remote browser cursor is composited into session media.`,identifier:`CursorVisibility`});G({origins:tC([V(`open-tabs`),K(H.check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(DC(2048).annotate({expected:`a string with at most 2048 code points`}))).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(EC(100).annotate({expected:`a value with a length of at most 100`}))],{mode:`oneOf`}).annotate({description:`Exact origins and/or * patterns, or open-tabs to select current pages and frames.`})}).annotate({examples:[{origins:[`*`]},{origins:[`https://example.com`,`https://*.example.org`]},{origins:`open-tabs`}],identifier:`ExportSessionStorageStateInput`});var JT=G({code:q([`ffmpeg_unavailable`,`open_failed`,`nothing_kept`,`analysis_failed`,`plan_failed`,`render_failed`,`timeout`,`cancelled`,`timeline_failed`]),message:H}).annotate({description:`Why a recording has no edit although one was due or a timeline could not be written. The raw video is published regardless.`,identifier:`RecordingEditError`}),YT=G({targetId:H.annotate({description:`Identifier of the ready top-level target to record.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`})),fps:B(U.annotate({description:`Requested frames per second. Omit or use a non-positive value for the instance default.`,examples:[60]}).check(Y().annotate({expected:`an integer`}))),bitrateKbps:B(U.annotate({description:`Requested video bitrate in kilobits per second. Omit or use a non-positive value for the instance default.`,examples:[6e3]}).check(Y().annotate({expected:`an integer`}))),codec:B(q([`vp8`,`h264-va`]).annotate({description:`Video codec. Omit for the instance default.`,examples:[`vp8`]})),capture:B(q([`continuous`,`bursts`]).annotate({description:"With `bursts`, the edited video keeps only the stretches around browser tool calls, from `burst.leadMs` before a call to `burst.tailMs` after it, longer until the screen has stood still for `burst.settleMs` but at most `burst.maxTailMs`, and the recording follows the tab the automation acts on. The raw video is always the whole capture. Defaults to `continuous`. Cannot be combined with `idle`. Needs `recording_ffmpeg_executable` on the instance."})),presentation:B(W.annotate({description:`Run browser automation at presentation pace while the recording runs. Needs nothing of the instance.`})),idle:B(q([`cut`,`speed`]).annotate({description:"Remove (`cut`) or fast-forward (`speed`) the stretches of a continuous recording in which neither the picture nor the automation changes, in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),ripple:B(W.annotate({description:"Mark clicks with a ripple in the edited video. Needs `recording_ffmpeg_executable` on the instance."})),burst:B(G({leadMs:B(U.annotate({description:`Kept before a tool call. Defaults to 500.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(6e4).annotate({expected:`a value less than or equal to 60000`}))),tailMs:B(U.annotate({description:`Kept after a tool call. Defaults to 800.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(6e4).annotate({expected:`a value less than or equal to 60000`}))),settleMs:B(U.annotate({description:`How long the screen must stand still to count as settled. Defaults to 400.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(6e4).annotate({expected:`a value less than or equal to 60000`}))),maxTailMs:B(U.annotate({description:`Longest wait for the screen to settle after a call. Defaults to 3000.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(6e4).annotate({expected:`a value less than or equal to 60000`})))}).annotate({description:"Burst sizes in milliseconds for `capture` `bursts`; rejected without it. Omitted or zero fields take the defaults. `tailMs` must not exceed `maxTailMs` (default 3000)."}))}).annotate({description:`Top-level target and optional recording settings.`,identifier:`CreateSessionRecordingInput`});G({targetId:H.annotate({description:`Identifier of the ready destination top-level target.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Destination for a running tab recording.`,identifier:`RetargetSessionRecordingInput`}),G({text:H.annotate({description:`Caption text. Whitespace is trimmed.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(DC(200).annotate({expected:`a string with at most 200 code points`})),durationMs:B(U.annotate({description:`Display duration in milliseconds. Zero or omitted means 3000; other values must be at least 200.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(3e4).annotate({expected:`a value less than or equal to 30000`})))}).annotate({identifier:`RecordingCaptionInput`});var XT=G({x:U.annotate({description:`Left edge in viewport CSS pixels.`}).check(hC().annotate({expected:`a finite number`})),y:U.annotate({description:`Top edge in viewport CSS pixels.`}).check(hC().annotate({expected:`a finite number`})),width:U.check(hC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),height:U.check(hC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`RecordingRect`}),ZT=G({x:U.annotate({description:`Horizontal position in viewport CSS pixels.`}).check(hC().annotate({expected:`a finite number`})),y:U.annotate({description:`Vertical position in viewport CSS pixels.`}).check(hC().annotate({expected:`a finite number`}))}).annotate({identifier:`RecordingPoint`}),QT=G({type:V(`file`),name:H.annotate({description:`File name without directory components.`,examples:[`screencast-20260801T120000Z.webm`]}),relativePath:H.annotate({description:"Path below the session files root. Browser downloads are under `downloads/`, recordings under `recordings/`, uploads under `uploads/`, and Playwright MCP output under `outputs/`. Pass it to `browser_file_upload` or to create a signed download URL.",examples:[`recordings/screencast-20260801T120000Z.webm`]}),size:U.annotate({description:`File size in bytes.`,examples:[1048576],format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),modifiedAt:H.annotate({description:`Last file modification time.`,examples:[`2026-08-01T12:05:00Z`],format:`date-time`}),mimeType:H.annotate({description:`Detected media type.`,examples:[`video/webm`]}),sandboxPath:B(H.annotate({description:"Path of the file inside the session's browser sandbox, under the fixed `/session/files` root, for CDP `DOM.setFileInputFiles`. It is readable by the browser while the session runs. Absent for files of sessions created before session files moved under one root that are still in their old location.",examples:[`/session/files/recordings/screencast-20260801T120000Z.webm`]}))}).annotate({description:`Regular file retained with a browser session.`,identifier:`SessionFile`}),$T=G({type:V(`directory`),name:H.annotate({description:`Directory name without parent components.`,examples:[`invoices`]}),relativePath:H.annotate({description:`Path below the session files root.`,examples:[`uploads/invoices`]}),modifiedAt:H.annotate({format:`date-time`})}).annotate({description:`Directory below the session files root.`,identifier:`SessionDirectory`}),eE=dC(globalThis.Blob,{expected:`File | Blob`});G({from:H.annotate({description:"Current path from a `SessionFileEntry` result.",examples:[`downloads/invoice.pdf`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})),to:H.annotate({description:`New path below the session files root. Missing directories are created.`,examples:[`uploads/invoices/2026-08.pdf`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Current and new path of a session file.`,identifier:`MoveSessionFileInput`}),G({relativePath:H.annotate({description:`Path below the session files root. Missing parents are created.`,examples:[`uploads/invoices`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`}))}).annotate({description:`Directory to create.`,identifier:`CreateSessionDirectoryInput`}),G({relativePath:H.annotate({description:"Path from a `SessionFile` result.",examples:[`recordings/screencast-20260801T120000Z.webm`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})),ttlSeconds:B(U.annotate({description:"Requested lifetime in seconds. Omit it to use `signed_file_url_ttl`; values above `signed_file_url_max_ttl` are rejected.",examples:[900]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`}))),disposition:B(q([`attachment`,`inline`]).annotate({description:"How the URL presents the file. `inline` lets browsers display it, for example as an `<img>` source. Either way it is served with its detected `Content-Type`, `X-Content-Type-Options: nosniff`, and byte-range support. Content that can run scripts, such as HTML or SVG, also gets `Content-Security-Policy: sandbox`; images, audio, video, PDFs, and plain text do not, so browser viewers keep working.",default:`attachment`}))}).annotate({description:`Session file path and requested signed URL lifetime.`,identifier:`SessionFileDownloadURLInput`});var tE=G({url:H.annotate({description:"URL containing a path-bound `apf_` token.",examples:[`https://aperture.example.com/sessions/019f6cf0-0000-7000-8000-000000000010/files/recordings/screencast-20260801T120000Z.webm?token=apf_REDACTED`],format:`uri`}),expiresAt:H.annotate({description:`Time after which the URL is rejected.`,examples:[`2026-08-01T12:20:00Z`],format:`date-time`})}).annotate({description:`Signed URL for one session file.`,identifier:`SessionFileDownloadURL`});G({description:B(tC([H,JS]).annotate({description:"New description. Send `null` to clear it; an empty string is stored as an empty description.",examples:[`Updated signed-in state`]}))}).annotate({description:`Replacement snapshot description.`,identifier:`UpdateSnapshotInput`});var nE=G({error:H.annotate({examples:[`file exceeds upload limit`]})}).annotate({description:`Error raised inside a running session. It carries a message but no stable code.`,identifier:`LiveSessionErrorBody`});G({targetId:H.annotate({description:`Identifier of the top-level target to resize.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`})),width:U.annotate({description:`Logical width in CSS pixels. Widths below 500 are raised to 500.`,examples:[1280]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(SC(16384).annotate({expected:`a value less than or equal to 16384`})),height:U.annotate({description:`Logical height in CSS pixels.`,examples:[720]}).check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(SC(16384).annotate({expected:`a value less than or equal to 16384`})),deviceScaleFactor:B(U.annotate({description:`Device pixel ratio, rounded to 1/120. Omit or use a non-positive value for 1. The scaled content size may not exceed 16384 pixels.`,examples:[1]}).check(hC().annotate({expected:`a finite number`})))}).annotate({description:`Requested logical viewport of one top-level target.`,identifier:`SetViewportInput`});var rE=G({width:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),height:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentWidth:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),contentHeight:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasWidth:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),canvasHeight:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),deviceScaleFactor:U.annotate({description:`Effective device pixel ratio.`}).check(hC().annotate({expected:`a finite number`}))}).annotate({description:`Logical size, DPR-scaled content rectangle, and 64x64-bucketed media canvas of a target.`,identifier:`Viewport`}),iE=G({id:iC(()=>Q).annotate({description:`Tenant identifier.`}),displayName:H.annotate({description:`Human-readable tenant name.`,examples:[`Example engineering`]}),createdAt:H.annotate({description:`Time the tenant was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),deletedAt:B(tC([H,JS]).annotate({description:"Soft-deactivation time, or `null` for an active tenant.",examples:[null],format:`date-time`}))}).annotate({description:`Tenant account. Deletion is a reversible soft deactivation.`,identifier:`Tenant`}),aE=G({id:Q,email:B(tC([H,JS]).annotate({format:`email`})),displayName:H,isSystemAdmin:W,createdAt:H.annotate({format:`date-time`}),updatedAt:H.annotate({format:`date-time`}),disabledAt:B(tC([H,JS]).annotate({format:`date-time`})),passwordSetupStatus:B(q([`available`,`configured`,`email_required`,`user_disabled`,`login_disabled`]).annotate({description:`Password setup state included by the get-user operation.`}))}).annotate({identifier:`User`});G({ids:K(Q).annotate({description:`Up to 100 unique UUIDv7 values. An empty array is valid.`,examples:[[`019f6cf0-0000-7000-8000-000000000010`,`019f6cf0-0000-7000-8000-000000000011`]]}).check(EC(100).annotate({expected:`a value with a length of at most 100`})).check(AC().annotate({expected:`an array with unique items`}))}).annotate({description:`Ordered session IDs for a tenant-scoped bulk lookup. Missing, foreign, and deleted IDs are omitted from the result.`,identifier:`SessionBulkInput`});var oE=G({id:iC(()=>Q).annotate({description:`Event identifier.`}),tenantId:iC(()=>Q).annotate({description:`Tenant that owns the event.`}),resourceType:H.annotate({description:`Resource category associated with the event. Currently session events are the primary source; new categories may be added.`,examples:[`session`]}),resourceId:H.annotate({description:"Identifier of the associated resource. Its format depends on `resourceType`.",examples:[`019f6cf0-0000-7000-8000-000000000010`]}),type:H.annotate({description:`Extensible event type used for programmatic handling.`,examples:[`session.token_rotated`]}),message:H.annotate({description:`Human-readable event summary.`,examples:[`session token rotated`]}),data:ZS(H,YC.annotate({expected:`JSON value`})).annotate({description:`Event-specific JSON payload, such as error details or upload metadata.`,examples:[{reason:`manual rotation`}]}),createdAt:H.annotate({description:`Time the event was recorded.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})}).annotate({description:`Immutable tenant-scoped audit or lifecycle event.`,identifier:`Event`}),sE=G({id:Q,actorType:wT,actorId:B(tC([H,JS])),tenantId:B(tC([Q,JS],{mode:`oneOf`})),action:H.annotate({examples:[`tenant_membership.upserted`]}),resourceType:H.annotate({examples:[`tenant_membership`]}),resourceId:B(tC([H,JS])),data:ZS(H,YC.annotate({expected:`JSON value`})),createdAt:H.annotate({format:`date-time`})}).annotate({identifier:`AuditEvent`}),cE=G({resourceType:OT,resourceId:Q}).annotate({description:`Access to one existing tenant session or snapshot by its stable UUIDv7 identifier.`,identifier:`ResourceGrant`}),lE=G({error:kT}).annotate({description:`Standard error envelope returned by REST API operations.`,identifier:`Error`}),uE=G({channels:K(AT)}).annotate({description:`Browser channels enabled on this deployment.`,examples:[{channels:[{name:`chromium`}]}],identifier:`BrowserChannels`}),dE=G({tenantId:Q,userId:Q,scopes:K(NT).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`})),createdAt:H.annotate({format:`date-time`}),updatedAt:H.annotate({format:`date-time`})}).annotate({identifier:`TenantMembership`});G({scopes:K(NT).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`}))}).annotate({identifier:`TenantMembershipInput`});var fE=G({urls:K(H).annotate({description:`STUN or TURN server URLs.`,examples:[[`turn:turn.example.com:3478?transport=udp`]]}),username:B(H.annotate({description:`TURN username. Omitted when the server does not require authentication.`,examples:[`aperture-session`]})),credential:B(iC(()=>PT).annotate({description:`TURN credential. Treat it as a secret and do not persist it in logs.`,examples:[`REDACTED`]}))}).annotate({description:`ICE server configuration supplied to WebRTC consumers.`,identifier:`IceServer`}),pE=G({editorToken:iC(()=>PT).annotate({examples:[`ape_019f6cf0000070008000000000000010_REDACTED`]}),viewerToken:iC(()=>PT).annotate({examples:[`apv_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Owner-visible role-scoped secrets used to build collaboration links.`,identifier:`SessionCollaborationCapabilities`}),mE=G({url:iC(()=>PT).annotate({description:`Thumbnail of the tab most recently shown to a live-session client.`,format:`uri`}),targetUrlTemplate:iC(()=>PT).annotate({description:"Tab thumbnail URL with a literal `{targetId}` placeholder for a top-level target ID."}),expiresAt:H.annotate({format:`date-time`})}).annotate({description:`Signed thumbnail URLs for image elements. They need no other credentials and expire after the
|
|
23
23
|
configured signed URL lifetime; every session response returns fresh ones. Present while the
|
|
24
24
|
session is running, or while suspended when thumbnails were saved.
|
|
25
|
-
`,identifier:`SessionThumbnail`}),dE=G({name:H,value:rC(()=>NT).annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),fE=G({key:rC(()=>NT).annotate({description:`JSON-encoded structured-clone key.`}),value:rC(()=>NT).annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),pE=G({path:H.check(CC(1).annotate({expected:`a value with a length of at least 1`})),body:rC(()=>NT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),mE=G({url:H.annotate({description:"A generic proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`) or a compound tunnel URL (`ws+yamux+socks5://`, `wss+yamux+socks5://`). Proxy credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}),auth:B(rC(()=>NT).annotate({description:`Bearer secret for a tunnel URL's handshake. Required for a tunnel URL and invalid for a proxy URL. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:`A named upstream that proxy rules route through.`,identifier:`ProxyUpstream`}),hE=G({url:B(H.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:B(rC(()=>NT).annotate({description:`Bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Legacy tunnel endpoint for `upstream` `tunnel`; both fields are required with it. Use a tunnel URL in `upstreams`.",identifier:`ProxyTunnelConfig`}),gE=G({url:H.annotate({format:`uri`}),requestHeaders:FT,responseHeaders:FT,responseStatus:U.check(Y().annotate({expected:`an integer`})).check(J(100).annotate({expected:`a value greater than or equal to 100`})).check(xC(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:H,responseBody:rC(()=>NT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});G({tags:rC(()=>FT).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),G({name:H.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:B(eC([H,qS]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:B(W.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:B(rC(()=>FT).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var _E=G({id:rC(()=>Q).annotate({description:`Snapshot identifier.`}),name:H.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:rC(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:B(eC([H,qS]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:B(rC(()=>Q).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`})),promotedFromSessionId:B(rC(()=>Q).annotate({description:`Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable.`})),createdAt:H.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:B(eC([H,qS]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:B(H.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:B(rC(()=>FT).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),vE=G({upstreams:XS(H,IT),rules:K(LT),upstream:q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream view of `rules`; read `upstreams` and `rules` instead. Exact when the rules are optional leading `direct` rules followed by one final `*` rule via an upstream proxy or tunnel, with no other upstreams, and `direct` when there are no rules. Otherwise it approximates the route of the last `*` rule (`local` reads as `tunnel`, `refuse` as `direct`), or `direct` without one, and `url`, `tunnel` and `bypass` are omitted.",examples:[`tunnel`]}),url:B(H.annotate({description:"Legacy upstream proxy URL with its password masked. Only present when `upstream` is exactly `proxy`.",examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})),tunnel:B(G({url:B(H.annotate({examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Legacy tunnel endpoint. Only present when `upstream` is exactly `tunnel`. The secret is never returned."})),bypass:B(H.annotate({description:"Legacy `;`-separated matches of the leading `direct` rules. Only present with an exact `proxy` or `tunnel` value.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy configuration. Secrets are write-only, so this value cannot be replayed as a write.`,identifier:`SessionProxy`}),yE=G({tag:H.check(pC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:B(H),name:B(H),inputType:B(H),autocomplete:B(H),ariaLabel:B(H),placeholder:B(H),path:K(BT).check(TC(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),bE=G({name:H.check(CC(1).annotate({expected:`a value with a length of at least 1`})),value:rC(()=>NT).annotate({description:`Cookie value. Never log this field.`}),domain:H.annotate({examples:[`.example.com`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:B(W.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:H.annotate({examples:[`/`]}).check(pC(RegExp(`^\\/`,`u`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:B(U.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(mC().annotate({expected:`a finite number`})).check(bC(0).annotate({expected:`a value greater than 0`}))),httpOnly:B(W.annotate({default:!1})),secure:B(W.annotate({default:!1})),sameSite:B(HT),partitionKey:B(UT)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),xE=G({name:H,keyPath:GT,unique:W,multiEntry:W}).annotate({identifier:`InitialIndexedDBIndex`}),SE=G({recordingId:H.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:q([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:H.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:U.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:B(H.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:H.annotate({description:`Session file path below the session files root; host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:H.annotate({format:`date-time`}),stoppedAt:B(H.annotate({format:`date-time`})),sizeBytes:B(U.annotate({format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),fps:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),codec:q([`vp8`,`h264-va`]),editing:W.annotate({description:"Whether the edit a requested stop makes is still running. The raw video is already published; `editedRelativePath`, `timelineRelativePath` and `editError` are filled once this is false."}),editedRelativePath:B(H.annotate({description:"The edited H.264 video, published next to the raw one as `<name>.edited.mp4`, once a stop made it."})),timelineRelativePath:B(H.annotate({description:"What the recording's automation did and when, in the raw and edited video's time, published as `<name>.timeline.json`."})),editError:B(qT)}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`}),CE=eC([JT,YT],{mode:`oneOf`}).annotate({description:"A session file or directory, told apart by `type`.",identifier:`SessionFileEntry`}),wE=G({targetId:H,generation:U.annotate({description:`Assignment generation of the target's media output.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),viewport:$T}).annotate({description:`Viewport applied to a top-level target.`,identifier:`TargetViewport`}),TE=G({data:K(eE),meta:AT}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),EE=G({data:K(tE),meta:AT}).annotate({identifier:`UserPage`}),DE=G({data:K(nE),meta:AT}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),OE=G({data:K(rE),meta:AT}).annotate({identifier:`AuditEventPage`}),kE=G({type:CT,id:H.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:q([`api_token`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:eC([Q,qS],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:B(eC([Q,qS],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:H.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:wT,tenantId:B(eC([Q,qS],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:K(TT).annotate({description:`Scopes granted to the authenticated principal.`}).check(kC().annotate({expected:`an array with unique items`})),resourceMode:ET,resourceGrants:K(iE).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(kC().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),AE=G({id:rC(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:wT,tenantId:B(eC([Q,qS],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token."})),name:H.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:K(TT).annotate({description:`Unique scopes granted to the token.`}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`})),createdAt:H.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:rC(()=>CT).annotate({description:`Principal category that created the token.`}),createdById:eC([Q,qS],{mode:`oneOf`}).annotate({description:"User or API token identifier that created the token, or `null` for trusted local system actions."}),parentTokenId:eC([Q,qS],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it."}),resourceMode:ET,resourceGrants:K(iE).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(kC().annotate({expected:`an array with unique items`})),expiresAt:B(eC([H,qS]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:B(eC([H,qS]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});eC([G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:V(`system_admin`),scopes:K(TT).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`})),expiresAt:B(eC([H,qS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(V(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:B(K(iE).annotate({description:`Must be empty for a system administrator token.`}).check(TC(0).annotate({expected:`a value with a length of at most 0`})))}),G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:V(`tenant`),tenantId:rC(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:K(MT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`})),expiresAt:B(eC([H,qS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(ET),resourceGrants:B(K(iE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(kC().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(pC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:K(MT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(CC(1).annotate({expected:`a value with a length of at least 1`})).check(kC().annotate({expected:`an array with unique items`})),expiresAt:B(eC([H,qS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(ET),resourceGrants:B(K(iE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(kC().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`}),eC([aE,QT],{mode:`oneOf`}).annotate({description:`Failure of a live-session route.`,identifier:`LiveSessionFailure`});var jE=G({mode:q([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:W.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:B(K(cE).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),ME=G({origin:H.annotate({format:`uri`}).check(pC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:K(dE)}).annotate({identifier:`InitialTargetStorageOrigin`}),NE=G({upstreams:B(XS(H,mE).annotate({description:"Upstreams by name. Names use lowercase letters, digits and dashes; `direct`, `refuse` and `local` are reserved."})),rules:B(K(LT).check(TC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:B(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`. Cannot be combined with them. `proxy` becomes a final `*` rule via `url`, `tunnel` a `tunnel` upstream and a final `*` rule via it, each preceded by `direct` rules for the `bypass` entries. `direct` or omitted means no rules.",examples:[`tunnel`]})),url:B(H.annotate({description:"Legacy upstream proxy URL, required with `upstream` `proxy`. Use `upstreams` and `rules`.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:B(hE),bypass:B(H.annotate({description:"Legacy hosts to send direct, separated by `;` or `,`. Each entry must be a valid rule `match`; a leading `.` means any subdomain. CIDR ranges, `<local>` and scheme prefixes are rejected. Use `upstreams` and `rules`.",examples:[`*.internal.example.com`]}))}).annotate({description:"Session egress proxy configuration. Rules are checked in order and the first match routes the connection; unmatched connections go direct, and unmatched `localhost` stays on the session host. Omitted for direct egress.",identifier:`ProxyConfig`}),PE=G({upstreams:B(XS(H,mE)),rules:B(K(LT).check(TC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:B(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`."})),url:B(H.annotate({description:"Legacy upstream proxy URL; use `upstreams` and `rules`."})),tunnel:B(hE),bypass:B(H.annotate({description:"Legacy hosts to send direct; use `upstreams` and `rules`."})),drain:B(W.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new rules either way.`,examples:[!1]}))}).annotate({description:"Replacement session egress proxy configuration. Fields other than `drain` are as in `ProxyConfig`.",identifier:`UpdateProxyConfig`}),FE=G({name:H,entries:K(gE)}).annotate({identifier:`InitialCacheStorageCache`}),IE=G({snapshot:_E}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),LE=G({data:K(_E),meta:AT}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),RE=G({locator:yE,value:NT,checked:B(W),selectedIndices:B(K(U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})))),selection:B(VT)}).annotate({identifier:`InitialBrowserControlState`}),zE=G({locator:yE,html:NT}).annotate({identifier:`InitialBrowserContentEditableState`}),BE=G({locator:yE,x:U.check(mC().annotate({expected:`a finite number`})),y:U.check(mC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),VE=G({locator:yE,nodePath:K(U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))).check(TC(256).annotate({expected:`a value with a length of at most 256`})),offset:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),HE=G({name:H,keyPath:WT,autoIncrement:W,indexes:K(xE),records:K(fE)}).annotate({identifier:`InitialIndexedDBObjectStore`}),UE=G({principal:kE,selectedTenant:eC([eE,qS],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:K(eE).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),WE=G({data:K(AE),meta:AT}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),GE=G({token:AE,rawToken:rC(()=>NT).annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),KE=G({id:rC(()=>Q).annotate({description:`Session identifier.`}),tenantId:rC(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:B(H.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:B(H.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:PT,browserChannel:B(H.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:jE,createdAt:H.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:B(H.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:B(H.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:B(eC([H,qS]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:H.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:B(H.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:B(H.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:B(rC(()=>FT).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:B(H.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:B(rC(()=>NT).annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:B(lE),thumbnail:B(uE),proxy:B(vE)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),qE=G({anchor:VE,focus:VE}).annotate({identifier:`InitialBrowserDocumentSelection`}),JE=G({name:H,version:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:K(HE)}).annotate({identifier:`InitialIndexedDBDatabase`}),YE=G({data:K(KE),meta:AT}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),XE=G({session:KE,cdpUrl:H.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:rC(()=>NT).annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),ZE=G({sessions:K(KE)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),QE=G({session:KE,cdpUrl:B(H.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:B(rC(()=>NT).annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),$E=G({version:V(1),windowName:B(NT),historyState:B(rC(()=>NT).annotate({description:`JSON-encoded structured-clone history state.`})),controls:K(RE).check(TC(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:K(zE).check(TC(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:K(BE).check(TC(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:B(yE),selection:B(qE)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),eD=G({origin:H.annotate({examples:[`https://example.com`],format:`uri`}).check(pC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:B(K(H.annotate({format:`uri`}).check(pC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(TC(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:K(dE),indexedDB:B(K(JE)),cacheStorage:B(K(FE)),opfs:B(K(pE))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),tD=G({url:H.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(pC(RegExp(`^https?:\\/\\/`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:B(K(ME).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:B(zT),documentState:B($E),openerTargetIndex:B(U.annotate({description:`Index of another initial target that opened this target.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),active:B(W.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),nD=G({cookies:K(bE).check(TC(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:K(eD).check(TC(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`}),rD=G({baseSnapshotName:B(eC([H,qS]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:B(eC([H,qS]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:RT,initialTargets:B(K(tD).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(TC(50).annotate({expected:`a value with a length of at most 50`}))),storageState:B(nD),tags:B(rC(()=>FT).annotate({description:`Initial session tags.`})),proxy:B(NE)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`}),iD=ST;G({"X-Aperture-Tenant-Id":B(Q)});var aD=UE,oD=oE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),deleted:B(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:B(W.annotate({default:!1})),query:B(H)});var sD=TE,cD=eE,lD=eE,uD=eE,dD=eE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),query:B(H),disabled:B(q([`active`,`disabled`,`all`]).annotate({default:`active`}))});var fD=EE,pD=tE,mD=tE,hD=tE,gD=tE,_D=tE,vD=jT,yD=K(sE),bD=K(sE),xD=sE,SD=aE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),tenantId:B(Q),actorType:B(CT),actorId:B(H),action:B(H),resourceType:B(H),resourceId:B(H)});var CD=OE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),authorityType:B(wT),tenantId:B(Q),name:B(H),scope:B(TT),revoked:B(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var wD=WE,TD=GE,ED=aE,DD=eE,OD=eE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),name:B(H),scope:B(TT),revoked:B(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var kD=WE,AD=GE,jD=aE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),includeDeleted:B(W.annotate({default:!1})),status:B(PT),query:B(H),tagKey:B(K(H.check(CC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:B(K(H.check(CC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:B(K(q([`eq`,`neq`,`in`,`not_in`])))});var MD=YE;G({"X-Aperture-Tenant-Id":B(Q),waitForReady:B(W.annotate({default:!0}))});var ND=rD,PD=XE;G({"X-Aperture-Tenant-Id":B(Q)});var FD=ZE;G({"X-Aperture-Tenant-Id":B(Q)});var ID=KE;G({"X-Aperture-Tenant-Id":B(Q)});var LD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var RD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var zD=PE,BD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var VD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var HD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var UD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var WD=QE;G({"X-Aperture-Tenant-Id":B(Q)});var GD=KT;G({"X-Aperture-Tenant-Id":B(Q)});var KD=KT;G({"X-Aperture-Tenant-Id":B(Q)});var qD=aE;G({"X-Aperture-Tenant-Id":B(Q)});var JD=aE;G({"X-Aperture-Tenant-Id":B(Q)});var YD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var XD=K(SE);G({"X-Aperture-Tenant-Id":B(Q)});var ZD=SE;G({"X-Aperture-Tenant-Id":B(Q)});var QD=SE;G({"X-Aperture-Tenant-Id":B(Q)});var $D=SE;G({"X-Aperture-Tenant-Id":B(Q)});var eO=SE;G({"X-Aperture-Tenant-Id":B(Q)});var tO=K(CE);G({"X-Aperture-Tenant-Id":B(Q),directory:B(H.annotate({default:`uploads`}))}),G({files:B(K(XT))});var nO=G({files:K(JT)}).annotate({description:`Files stored by this request, in request order.`});G({"X-Aperture-Tenant-Id":B(Q),relativePath:H.check(CC(1).annotate({expected:`a value with a length of at least 1`})),recursive:B(W.annotate({default:!1}))});var rO=aE;G({"X-Aperture-Tenant-Id":B(Q)});var iO=CE;G({"X-Aperture-Tenant-Id":B(Q)});var aO=YT;G({"X-Aperture-Tenant-Id":B(Q)});var oO=ZT;G({"X-Aperture-Tenant-Id":B(Q)});var sO=IE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),name:B(H),deleted:B(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:B(W.annotate({default:!1})),tagKey:B(K(H.check(CC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:B(K(H.check(CC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:B(K(q([`eq`,`neq`,`in`,`not_in`])))});var cO=LE;G({"X-Aperture-Tenant-Id":B(Q)});var lO=IE;G({"X-Aperture-Tenant-Id":B(Q)});var uO=IE;G({"X-Aperture-Tenant-Id":B(Q)});var dO=IE;G({"X-Aperture-Tenant-Id":B(Q)});var fO=IE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),resourceType:B(H),resourceId:B(H)});var pO=DE;G({"X-Aperture-Tenant-Id":B(Q)}),G({files:B(K(XT))});var mO=G({files:K(JT)}).annotate({description:`Files stored by this request, in request order.`});G({"X-Aperture-Tenant-Id":B(Q)});var hO=wE,gO=(e,t={})=>{let n=e=>L(Pf(e.json,()=>`Unexpected status code`),t=>I(new dw({reason:new gw({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>R(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>L(L(t.transformClient(e),e=>e.execute(n)),i):t=>L(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>lf(()=>{let r=(t,n)=>I(new dw({reason:new hw({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):P(e(i))}),o=n=>lf(()=>t.transformClient?L(t.transformClient(e),e=>cT(e).execute(n)):cT(e).execute(n)),s=e=>R(e.arrayBuffer,e=>new Uint8Array(e)),c=e=>o(e).pipe(R(e=>e.stream),lg),l=e=>t=>Qw(e)(t);return{httpClient:e,getHealth:e=>kw(`/api/health`).pipe(r(e?.config)(Z({"2xx":l(iD),orElse:n}))),getCurrentPrincipal:e=>kw(`/api/auth/me`).pipe(X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(aD),orElse:n}))),listBrowserChannels:e=>kw(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":l(oD),orElse:n}))),listTenants:e=>kw(`/api/admin/tenants`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,query:e?.params?.query}),r(e?.config)(Z({"2xx":l(sD),orElse:n}))),createTenant:e=>Aw(`/api/admin/tenants`).pipe(Jw(e.payload),r(e.config)(Z({"2xx":l(cD),orElse:n}))),deleteTenant:(e,t)=>a(Nw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(lD),orElse:n}))))),updateTenant:(e,t)=>a(jw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(Jw(t.payload),r(t.config)(Z({"2xx":l(uD),orElse:n}))))),restoreTenant:(e,t)=>a(Aw,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(dD),orElse:n}))))),listUsers:e=>kw(`/api/admin/users`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":l(fD),orElse:n}))),createUser:e=>Aw(`/api/admin/users`).pipe(Jw(e.payload),r(e.config)(Z({"2xx":l(pD),orElse:n}))),getUser:(e,t)=>a(kw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(mD),orElse:n}))))),disableUser:(e,t)=>a(Nw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(hD),orElse:n}))))),updateUser:(e,t)=>a(jw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(Jw(t.payload),r(t.config)(Z({"2xx":l(gD),orElse:n}))))),restoreUser:(e,t)=>a(Aw,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(_D),orElse:n}))))),createUserInvitation:(e,t)=>a(Aw,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(vD),orElse:n}))))),listUserMemberships:(e,t)=>a(kw,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(yD),orElse:n}))))),listTenantMemberships:(e,t)=>a(kw,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(bD),orElse:n}))))),upsertTenantMembership:(e,t,o)=>a(Mw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(Jw(o.payload),r(o.config)(Z({"2xx":l(xD),orElse:n}))))),deleteTenantMembership:(e,t,o)=>a(Nw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(r(o?.config)(Z({"2xx":l(SD),204:()=>uf,orElse:n}))))),listAuditEvents:e=>kw(`/api/admin/audit-events`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":l(CD),orElse:n}))),listAdminTokens:e=>kw(`/api/admin/tokens`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(wD),orElse:n}))),createAdminToken:e=>Aw(`/api/admin/tokens`).pipe(Jw(e.payload),r(e.config)(Z({"2xx":l(TD),orElse:n}))),revokeAdminToken:(e,t)=>a(Aw,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(ED),204:()=>uf,orElse:n}))))),getTenant:e=>kw(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":l(DD),orElse:n}))),updateSelectedTenant:e=>jw(`/api/tenant`).pipe(Jw(e.payload),r(e.config)(Z({"2xx":l(OD),orElse:n}))),listTenantTokens:e=>kw(`/api/tenant/tokens`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(kD),orElse:n}))),createTenantToken:e=>Aw(`/api/tenant/tokens`).pipe(Jw(e.payload),r(e.config)(Z({"2xx":l(AD),orElse:n}))),revokeTenantToken:(e,t)=>a(Aw,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(jD),204:()=>uf,orElse:n}))))),listSessions:e=>kw(`/api/sessions`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,query:e?.params?.query,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(MD),orElse:n}))),createSession:e=>Aw(`/api/sessions`).pipe(Gw({waitForReady:e.params?.waitForReady}),X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(e.payload),r(e.config)(Z({"2xx":l(PD),orElse:n}))),getSessionsBulk:e=>Aw(`/api/sessions/bulk`).pipe(X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(e.payload),r(e.config)(Z({"2xx":l(FD),orElse:n}))),getSession:(e,t)=>a(kw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(ID),orElse:n}))))),deleteSession:(e,t)=>a(Nw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(LD),orElse:n}))))),replaceSessionTags:(e,t)=>a(Mw,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(RD),orElse:n}))))),updateSessionProxy:(e,t)=>a(Mw,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(BD),orElse:n}))))),suspendSession:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(VD),orElse:n}))))),reopenSession:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(HD),orElse:n}))))),rotateSessionToken:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(UD),orElse:n}))))),rotateCollaborationCapability:(e,t,o)=>a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(WD),orElse:n}))))),getSessionCursor:(e,t)=>a(kw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(GD),orElse:n}))))),setSessionCursor:(e,t)=>a(Mw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(KD),orElse:n}))))),getSessionThumbnail:(e,t)=>a(kw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(qD),200:s,orElse:n}))))),getSessionThumbnailStream:(e,t)=>lg(a(kw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(R(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),getSessionTargetThumbnail:(e,t,o)=>a(kw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(JD),200:s,orElse:n}))))),getSessionTargetThumbnailStream:(e,t,n)=>lg(a(kw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(R(e=>e.pipe(X({"X-Aperture-Tenant-Id":n?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),exportSessionStorageState:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/storage-state`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(YD),orElse:n}))))),listSessionRecordings:(e,t)=>a(kw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(XD),orElse:n}))))),createSessionRecording:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(ZD),orElse:n}))))),getSessionRecording:(e,t,o)=>a(kw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(QD),orElse:n}))))),retargetSessionRecording:(e,t,o)=>a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(o.payload),r(o.config)(Z({"2xx":l($D),orElse:n}))))),stopSessionRecording:(e,t,o)=>a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(eO),orElse:n}))))),listSessionFiles:(e,t)=>a(kw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(tO),orElse:n}))))),uploadSessionFiles:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Gw({directory:t.params?.directory}),X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(nO),orElse:n}))))),deleteSessionFile:(e,t)=>a(Nw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Gw({relativePath:t.params.relativePath,recursive:t.params.recursive}),X({"X-Aperture-Tenant-Id":t.params[`X-Aperture-Tenant-Id`]??void 0}),r(t.config)(Z({"2xx":l(rO),204:()=>uf,orElse:n}))))),moveSessionFile:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/files/move`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(iO),orElse:n}))))),createSessionDirectory:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/files/directories`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(aO),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(oO),orElse:n}))))),promoteSession:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(sO),orElse:n}))))),listSnapshots:e=>kw(`/api/snapshots`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(cO),orElse:n}))),deleteSnapshot:(e,t)=>a(Nw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(lO),orElse:n}))))),updateSnapshot:(e,t)=>a(jw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(uO),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Mw,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(dO),orElse:n}))))),restoreSnapshot:(e,t)=>a(Aw,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(fO),orElse:n}))))),listEvents:e=>kw(`/api/events`).pipe(Gw({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(pO),orElse:n}))),uploadLiveSessionFiles:(e,t)=>a(Aw,[e],()=>`/sessions/`+i(e)+`/uploads`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(mO),orElse:n}))))),setSessionViewport:(e,t)=>a(Aw,[e],()=>`/sessions/`+i(e)+`/browser/viewport`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Jw(t.payload),r(t.config)(Z({"2xx":l(hO),orElse:n})))))}},_O=`X-Aperture-Tenant-Id`,vO={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function yO(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var bO={anonymous:{},webSession:{credentials:vO},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},xO=class extends _r()(`@aperture-browser/api-client/ApiAuthorization`){},SO=q([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),CO=G({id:H,type:V(`public-key`),transports:B(QS(K(SO)))}),wO=B(G({appid:B(H),credProps:B(W),hmacCreateSecret:B(W),minPinLength:B(W)})),TO=q([`hybrid`,`security-key`,`client-device`]),EO=q([`discouraged`,`preferred`,`required`]),DO=G({methods:K(eC([G({type:V(`password`)}),G({type:V(`api_token`)}),G({type:V(`passkey`)}),G({type:V(`oidc`),id:H,name:H,loginUrl:H})]))}),OO=G({publicKey:G({challenge:H,timeout:B(U),rpId:B(H),allowCredentials:B(QS(K(CO))),userVerification:B(EO),hints:B(QS(K(TO))),extensions:wO})}),kO=G({publicKey:G({rp:G({id:B(H),name:H}),user:G({id:H,name:H,displayName:H}),challenge:H,pubKeyCredParams:QS(K(G({alg:q([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:V(`public-key`)}))),timeout:B(U),excludeCredentials:B(QS(K(CO))),authenticatorSelection:B(G({authenticatorAttachment:B(q([`platform`,`cross-platform`])),requireResidentKey:B(W),residentKey:B(q([`discouraged`,`preferred`,`required`])),userVerification:B(EO)})),hints:B(QS(K(TO))),attestation:B(q([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:B(QS(K(q([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:wO})}),AO=G({id:H,name:H,createdAt:H,lastUsedAt:tC(H)}),jO=G({passkeys:K(AO)}),MO=G({passkey:AO}),NO=G({mfaRequired:W}),PO=G({hasPassword:W,totpEnabled:W,recoveryCodesRemaining:U.check(Y(),J(0))}),FO=G({secret:H,otpauthUrl:H,qrCodeDataUrl:H}),IO=G({recoveryCodes:K(H)}),LO=G({id:H,name:H,uri:tC(H),logoUri:tC(H),kind:q([`registered`,`metadata_document`])}),RO=G({client:LO,redirectUri:H,requestedScopes:K(H),user:G({id:H,displayName:H,isSystemAdmin:W}),tenants:K(G({id:H,displayName:H,scopes:K(MT)})),availableScopes:K(MT),canGrantSystemAdmin:W}),zO=G({redirectUrl:H}),BO=G({grants:K(G({id:H,client:LO,authorityType:wT,tenants:K(G({id:H,displayName:H})),scopes:K(H),resourceMode:ET,resourceGrants:K(G({resourceType:DT,resourceId:H})),createdAt:H,lastUsedAt:tC(H)}))}),VO=class extends _r()(`@aperture-browser/api-client/AuthApi`){},HO=e=>({body:rw(e)}),UO=ld(VO,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=cT(e),r=gO(e),i=t(bO.anonymous),a=t(bO.webSession),o=z(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(L(Qw(DO)),i)}),s=z(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,HO({email:e,password:t})).pipe(L(Qw(NO)),i)}),c=z(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,HO({code:e})).pipe(i)}),l=z(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,HO({token:e})).pipe(i)}),u=z(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(L(Qw(OO)),i)}),d=z(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,HO(e)).pipe(i)}),f=z(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,HO({token:e,password:t})).pipe(i)}),p=z(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=z(`AuthApi.getAuthMe`)(function*(e=null,n=vO){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=z(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(L(Qw(PO)),a)}),g=z(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,HO({currentPassword:e,newPassword:t})).pipe(a)}),_=z(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(L(Qw(jO)),a)}),v=z(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,HO({name:e})).pipe(L(Qw(kO)),a)}),y=z(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,HO(e)).pipe(L(Qw(MO)),a)}),b=z(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,HO({name:t})).pipe(L(Qw(MO)),a)}),x=z(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),ee=z(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(L(Qw(FO)),a)}),S=z(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,HO({code:e})).pipe(L(Qw(IO)),a)}),C=z(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,HO({code:e})).pipe(L(Qw(IO)),a)}),te=z(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,HO({code:e})).pipe(a)}),ne=z(`AuthApi.getOAuthAuthorization`)(function*(e){return yield*n.get(`/auth/oauth/authorization?${e}`).pipe(L(Qw(RO)),a)}),w=z(`AuthApi.approveOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/approve`,HO(e)).pipe(L(Qw(zO)),a)}),T=z(`AuthApi.denyOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/deny`,HO({query:e})).pipe(L(Qw(zO)),a)}),re=z(`AuthApi.listOAuthGrants`)(function*(){return yield*n.get(`/auth/oauth/grants`).pipe(L(Qw(BO)),a)}),ie=z(`AuthApi.revokeOAuthGrant`)(function*(e){yield*n.del(`/auth/oauth/grants/${encodeURIComponent(e)}`).pipe(a)});return VO.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getSecurityStatus:h,setPassword:g,listPasskeys:_,beginPasskeyRegistration:v,finishPasskeyRegistration:y,renamePasskey:b,deletePasskey:x,beginTOTPEnrollment:ee,completeTOTPEnrollment:S,regenerateRecoveryCodes:C,disableTOTP:te,getOAuthAuthorization:ne,approveOAuthAuthorization:w,denyOAuthAuthorization:T,listOAuthGrants:re,revokeOAuthGrant:ie})})),WO=eC([G({error:G({code:H,message:H})}),G({error:H})]),GO=class extends KC()(`ApiRequestError`,{code:H,message:H,status:U,cause:US(eC([uC(dw),uC(kS)]))}){},KO=(e,t)=>new GO({code:`internal_error`,message:`Invalid response`,status:e,cause:t}),qO=e=>e.pipe(Af(`HttpClientError`,{StatusCodeError:({response:e},t)=>Qw(WO)(e).pipe(R(({error:t})=>typeof t==`string`?new GO({code:`live_session_error`,message:t,status:e.status}):new GO({...t,status:e.status})),Pf(()=>new GO({code:`internal_error`,message:`Request failed`,status:e.status,cause:t})),L(I)),DecodeError:({response:e},t)=>I(KO(e.status,t))}),kf({HttpClientError:e=>I(new GO({code:`network_error`,message:`The server could not be reached`,status:0,cause:e})),SchemaError:e=>I(KO(0,e))})),JO=Yr(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),YO=e=>JO.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token:void 0),a=i===void 0?void 0:y_(i).trim(),o=t?yO(t,r):void 0;return e.pipe(Vw,a?zw(a):x,o?Iw(_O,o):Rw(_O))}),XO=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),ZO=ld(oT,R(oT,pT(YO))),QO=ld(xO,pf(function*(){let e=yield*em();return xO.of({authorize:t=>n=>n.pipe(qO,Mf(n=>t.credentials?.kind===`session`&&XO.has(n.code)?nm(e,void 0):uf),Gf(JO,t)),sessionAuthenticationFailures:og(e)})})),$O=class extends _r()(`@aperture-browser/api-client/EventsApi`){},ek=class extends _r()(`@aperture-browser/api-client/HealthApi`){};function tk(e){return e.meta.hasMore?e.meta.nextCursor:void 0}function nk(e){let t=(t,n)=>cg(void 0,r=>e(t,n===void 0?{cursor:r}:{...n,cursor:r}).pipe(R(e=>{let t=tk(e);return[e.data,t===void 0?or():sr(t)]})));return{list:e,stream:t,listAll:(e,n)=>yg(t(e,n))}}var rk=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),ik=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),ak=ld($O,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=z(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:ik({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(bO.tenantScoped(e)))}),i=z(`EventsApi.listAuditEvents`)(function*(e,r={}){return yield*n.listAuditEvents({params:ik({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,actorType:r.actorType,actorId:r.actorId,action:r.action,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(bO.of(e)))}),a=nk(r),o=nk(i);return $O.of({listEvents:r,streamEvents:a.stream,listAllEvents:a.listAll,listAuditEvents:i,streamAuditEvents:o.stream,listAllAuditEvents:o.listAll})})),ok=ld(ek,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=z(`HealthApi.getHealth`)(function*(){return yield*n.getHealth(void 0).pipe(t(bO.anonymous))});return ek.of({getHealth:r})})),sk=U.check(Y(),bC(0)),ck=P([]),lk={sessionId:H,cdpUrl:H,media:jE,thumbnailAvailable:W,pages:K(G({targetId:H,state:q([`pending`,`ready`,`unavailable`,`closed`]),title:H,url:H,viewport:B(G({width:sk,height:sk,deviceScaleFactor:U.check(bC(0)),contentWidth:sk,contentHeight:sk,canvasWidth:sk,canvasHeight:sk})),thumbnailAvailable:W})).pipe(sC(ck))},uk={...lk,capturedAt:H,representativeTargetId:B(H)},dk=eC([G({...uk,status:V(`running`),source:V(`live`)}),G({...uk,status:V(`suspended`),source:V(`persisted`)}),G({...lk,status:V(`suspended`),source:V(`unavailable`)})]),fk={recordingId:H,mode:q([`tab`,`viewer`]),targetId:H,captureGeneration:sk,status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:B(H),sandboxPath:B(H),path:B(H),startedAt:H,stoppedAt:B(H),sizeBytes:B(U.check(Y(),J(0))),fps:sk,bitrateKbps:sk,codec:H,editing:W,editedRelativePath:B(H),timelineRelativePath:B(H),editError:B(qT)},pk=G({...fk,relativePath:B(H)}).pipe(iC(G({...fk,relativePath:H}),Qv({decode:({relativePath:e,...t})=>({...t,relativePath:e??t.path??``}),encode:e=>e}))),mk=class extends _r()(`@aperture-browser/api-client/SessionsApi`){},hk=Nd,gk=e=>yf(t=>P(e(t.getRef(hk)))),_k=(e,t,n)=>{let r=n?.halfOpen===!0?0:1;return gk(n=>{let i=Math.ceil(e),a=Math.floor(t);return Math.floor(n.nextDoubleUnsafe()*(a-i+r))+i})},vk=new TextEncoder,yk=e=>e.replaceAll(`"`,`%22`).replaceAll(`\r`,`%0D`).replaceAll(`
|
|
26
|
-
`,`%0A`),
|
|
25
|
+
`,identifier:`SessionThumbnail`}),hE=G({name:H,value:iC(()=>PT).annotate({description:`Browser storage value. Never log this field.`})}).annotate({identifier:`BrowserStorageEntry`}),gE=G({key:iC(()=>PT).annotate({description:`JSON-encoded structured-clone key.`}),value:iC(()=>PT).annotate({description:`JSON-encoded structured-clone value.`})}).annotate({identifier:`InitialIndexedDBRecord`}),_E=G({path:H.check(wC(1).annotate({expected:`a value with a length of at least 1`})),body:iC(()=>PT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialOPFSFile`}),vE=G({url:H.annotate({description:"A generic proxy URL (`http`, `https`, `socks`, `socks5`, `socks5h`) or a compound tunnel URL (`ws+yamux+socks5://`, `wss+yamux+socks5://`). Proxy credentials go in the userinfo (`socks5://user:pass@host:1080`) and are sent as Basic `Proxy-Authorization` for `http`/`https` or RFC 1929 username/password for the socks schemes. An omitted port defaults to 1080 (socks), 80 (http) or 443 (https).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}),auth:B(iC(()=>PT).annotate({description:`Bearer secret for a tunnel URL's handshake. Required for a tunnel URL and invalid for a proxy URL. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:`A named upstream that proxy rules route through.`,identifier:`ProxyUpstream`}),yE=G({url:B(H.annotate({description:"Compound tunnel URL (`ws+yamux+socks5://` or `wss+yamux+socks5://`).",examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]})),auth:B(iC(()=>PT).annotate({description:`Bearer secret for the tunnel handshake. Write-only; never returned.`,examples:[`REDACTED`]}))}).annotate({description:"Legacy tunnel endpoint for `upstream` `tunnel`; both fields are required with it. Use a tunnel URL in `upstreams`.",identifier:`ProxyTunnelConfig`}),bE=G({url:H.annotate({format:`uri`}),requestHeaders:IT,responseHeaders:IT,responseStatus:U.check(Y().annotate({expected:`an integer`})).check(J(100).annotate({expected:`a value greater than or equal to 100`})).check(SC(599).annotate({expected:`a value less than or equal to 599`})),responseStatusText:H,responseBody:iC(()=>PT).annotate({contentEncoding:`base64`})}).annotate({identifier:`InitialCacheStorageEntry`});G({tags:iC(()=>IT).annotate({description:`Complete tag map. Keys and values must contain non-whitespace characters.`})}).annotate({description:`Complete replacement tag set. The map may be empty to clear all tags.`,examples:[{tags:{environment:`production`,region:`eu-west-1`}}],identifier:`ReplaceTagsInput`}),G({name:H.annotate({description:`Tenant-unique snapshot name. Leading and trailing whitespace is removed.`,examples:[`signed-in-base`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),description:B(tC([H,JS]).annotate({description:"Optional snapshot description. `null` creates the snapshot without a description.",examples:[`Signed-in storefront state for checkout tests`]})),force:B(W.annotate({description:"Deleted snapshot names are reused automatically. Set `true` to replace an active snapshot, which is renamed to its tombstone name and retained for the configured snapshot retention period.",default:!1})),tags:B(iC(()=>IT).annotate({description:`Initial complete tag map for the new snapshot.`}))}).annotate({description:`Snapshot metadata created from a stopped, retained session.`,examples:[{name:`signed-in-base`,description:`Signed-in storefront state for checkout tests`,force:!1,tags:{application:`storefront`,environment:`staging`}}],identifier:`PromoteSessionInput`});var xE=G({id:iC(()=>Q).annotate({description:`Snapshot identifier.`}),name:H.annotate({description:`Human-selected tenant-unique snapshot name.`,examples:[`signed-in-base`]}),tenantId:iC(()=>Q).annotate({description:`Tenant that owns the snapshot.`}),description:B(tC([H,JS]).annotate({description:"Operator-provided description, or `null` when none is set.",examples:[`Signed-in storefront state for checkout tests`]})),parentSnapshotId:B(iC(()=>Q).annotate({description:`Base snapshot from which the source session was created. Omitted for snapshots without a parent.`})),promotedFromSessionId:B(iC(()=>Q).annotate({description:`Session whose retained overlay produced this snapshot. Omitted when lineage is unavailable.`})),createdAt:H.annotate({description:`Time the snapshot was created.`,examples:[`2026-07-17T12:45:00Z`],format:`date-time`}),deletedAt:B(tC([H,JS]).annotate({description:"Soft-deletion time, or `null` for an active snapshot.",examples:[null],format:`date-time`})),expiresAt:B(H.annotate({description:`Purge eligibility time for a deleted snapshot. Omitted for active snapshots.`,examples:[`2026-08-16T12:45:00Z`],format:`date-time`})),tags:B(iC(()=>IT).annotate({description:`Snapshot metadata tags. Omitted when no tags are set.`}))}).annotate({description:`Reusable retained browser filesystem state. Deletion is soft until the retention deadline.`,identifier:`Snapshot`}),SE=G({upstreams:ZS(H,LT),rules:K(RT),upstream:q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream view of `rules`; read `upstreams` and `rules` instead. Exact when the rules are optional leading `direct` rules followed by one final `*` rule via an upstream proxy or tunnel, with no other upstreams, and `direct` when there are no rules. Otherwise it approximates the route of the last `*` rule (`local` reads as `tunnel`, `refuse` as `direct`), or `direct` without one, and `url`, `tunnel` and `bypass` are omitted.",examples:[`tunnel`]}),url:B(H.annotate({description:"Legacy upstream proxy URL with its password masked. Only present when `upstream` is exactly `proxy`.",examples:[`socks5://user:xxxxx@proxy.example.com:1080`]})),tunnel:B(G({url:B(H.annotate({examples:[`wss+yamux+socks5://tunnel.example.com/t/019f6cf0-0000-7000-8000-000000000010`]}))}).annotate({description:"Legacy tunnel endpoint. Only present when `upstream` is exactly `tunnel`. The secret is never returned."})),bypass:B(H.annotate({description:"Legacy `;`-separated matches of the leading `direct` rules. Only present with an exact `proxy` or `tunnel` value.",examples:[`*.internal.example.com`]}))}).annotate({description:`Stored session egress proxy configuration. Secrets are write-only, so this value cannot be replayed as a write.`,identifier:`SessionProxy`}),CE=G({tag:H.check(mC(RegExp(`^[a-z][a-z0-9-]*$`,`u`)).annotate({expected:`a string matching the RegExp ^[a-z][a-z0-9-]*$`})),id:B(H),name:B(H),inputType:B(H),autocomplete:B(H),ariaLabel:B(H),placeholder:B(H),path:K(VT).check(EC(256).annotate({expected:`a value with a length of at most 256`}))}).annotate({description:`Semantic element identity with a structural fallback. It is not a CSS selector.`,identifier:`InitialBrowserElementLocator`}),wE=G({name:H.check(wC(1).annotate({expected:`a value with a length of at least 1`})),value:iC(()=>PT).annotate({description:`Cookie value. Never log this field.`}),domain:H.annotate({examples:[`.example.com`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})),hostOnly:B(W.annotate({description:"Scope the cookie to exactly `domain`, without subdomains. `domain` must then be a plain hostname.",default:!1})),path:H.annotate({examples:[`/`]}).check(mC(RegExp(`^\\/`,`u`)).annotate({expected:`a string matching the RegExp ^\\/`})),expires:B(U.annotate({description:`Unix timestamp in seconds. Omit for a session cookie.`}).check(hC().annotate({expected:`a finite number`})).check(xC(0).annotate({expected:`a value greater than 0`}))),httpOnly:B(W.annotate({default:!1})),secure:B(W.annotate({default:!1})),sameSite:B(UT),partitionKey:B(WT)}).annotate({description:`Cookie imported into the new browser profile.`,identifier:`InitialBrowserCookie`}),TE=G({name:H,keyPath:KT,unique:W,multiEntry:W}).annotate({identifier:`InitialIndexedDBIndex`}),EE=G({recordingId:H.annotate({description:`Stable recording identifier retained across target changes.`,format:`uuid`}),mode:q([`tab`,`viewer`]).annotate({description:`Tab recordings stay on their specified top-level target; viewer recordings follow a live session client's selected top-level target and cannot be explicitly retargeted.`}),targetId:H.annotate({description:`Identifier of the top-level target currently recorded.`}),captureGeneration:U.annotate({description:`Assignment generation for the current top-level target.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:B(H.annotate({description:`Lifecycle reason recorded after the recording stops or fails.`})),relativePath:H.annotate({description:`Session file path below the session files root; host paths are never exposed.`,examples:[`recordings/recording-550e8400-e29b-41d4-a716-446655440000.webm`]}),startedAt:H.annotate({format:`date-time`}),stoppedAt:B(H.annotate({format:`date-time`})),sizeBytes:B(U.annotate({format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),fps:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),bitrateKbps:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),codec:q([`vp8`,`h264-va`]),editing:W.annotate({description:"Whether the edit a requested stop makes is still running. The raw video is already published; `editedRelativePath`, `timelineRelativePath` and `editError` are filled once this is false."}),editedRelativePath:B(H.annotate({description:"The edited H.264 video, published next to the raw one as `<name>.edited.mp4`, once a stop made it."})),timelineRelativePath:B(H.annotate({description:"What the recording's automation did and when, in the raw and edited video's time, published as `<name>.timeline.json`."})),editError:B(JT)}).annotate({description:`One logical recording of a top-level target.`,identifier:`Recording`});G({rect:B(XT),selector:B(H.annotate({description:`CSS selector in the top-level document; pass instead of rect.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`}))),zoom:U.check(hC().annotate({expected:`a finite number`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})).check(SC(4).annotate({expected:`a value less than or equal to 4`})),durationMs:B(U.annotate({description:`Hold duration in milliseconds. Zero or omitted means 2000; other values must be at least 200.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(1e4).annotate({expected:`a value less than or equal to 10000`})))}).annotate({identifier:`RecordingFocusInput`}),G({point:B(ZT),selector:B(H.annotate({description:`CSS selector in the top-level document; pass instead of point.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`}))),radius:B(U.annotate({description:`Circle radius in CSS pixels. Zero or omitted means 40; other values must be at least 8.`}).check(hC().annotate({expected:`a finite number`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(300).annotate({expected:`a value less than or equal to 300`}))),loops:B(U.annotate({description:`Number of circles. Zero or omitted means 2.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(5).annotate({expected:`a value less than or equal to 5`}))),durationMs:B(U.annotate({description:`Circle duration in milliseconds. Zero or omitted means 1200; other values must be at least 300.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})).check(SC(5e3).annotate({expected:`a value less than or equal to 5000`})))}).annotate({identifier:`RecordingAttentionInput`});var DE=tC([QT,$T],{mode:`oneOf`}).annotate({description:"A session file or directory, told apart by `type`.",identifier:`SessionFileEntry`}),OE=G({targetId:H,generation:U.annotate({description:`Assignment generation of the target's media output.`,format:`int64`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})),viewport:rE}).annotate({description:`Viewport applied to a top-level target.`,identifier:`TargetViewport`}),kE=G({data:K(iE),meta:jT}).annotate({description:`Cursor-paginated tenants.`,identifier:`TenantPage`}),AE=G({data:K(aE),meta:jT}).annotate({identifier:`UserPage`}),jE=G({data:K(oE),meta:jT}).annotate({description:`Cursor-paginated tenant events.`,identifier:`EventPage`}),ME=G({data:K(sE),meta:jT}).annotate({identifier:`AuditEventPage`}),NE=G({type:wT,id:H.annotate({description:`Stable identifier of the authenticated subject.`}),authMethod:q([`api_token`,`oidc`,`passkey`,`password`]).annotate({description:`Authentication mechanism used for this request.`}),tokenId:tC([Q,JS],{mode:`oneOf`}).annotate({description:"Identifier of the API token used for authentication, or `null` for account-backed sessions."}),userId:B(tC([Q,JS],{mode:`oneOf`}).annotate({description:"User identifier for account-backed authentication, or `null` for API tokens."})),name:H.annotate({description:`Display name of the authenticated credential or user.`,examples:[`deployment automation`]}),authorityType:TT,tenantId:B(tC([Q,JS],{mode:`oneOf`}).annotate({description:"Effective tenant for tenant authority, or `null` when no tenant is selected."})),scopes:K(ET).annotate({description:`Scopes granted to the authenticated principal.`}).check(AC().annotate({expected:`an array with unique items`})),resourceMode:DT,resourceGrants:K(cE).annotate({description:"Explicit grants when `resourceMode` is `allowlist`; empty when it is `all`."}).check(AC().annotate({expected:`an array with unique items`}))}).annotate({description:`Authenticated subject identity and authorization context.`,identifier:`Principal`}),PE=G({id:iC(()=>Q).annotate({description:`Token identifier. This is not the bearer secret.`}),authorityType:TT,tenantId:B(tC([Q,JS],{mode:`oneOf`}).annotate({description:"Bound tenant for a tenant token, or `null` for a system administrator token."})),name:H.annotate({description:`Operator-assigned token name, unique within its authority and tenant context.`,examples:[`ci automation`]}),scopes:K(ET).annotate({description:`Unique scopes granted to the token.`}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`})),createdAt:H.annotate({description:`Time the token was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),createdByType:iC(()=>wT).annotate({description:`Principal category that created the token.`}),createdById:tC([Q,JS],{mode:`oneOf`}).annotate({description:"User or API token identifier that created the token, or `null` for trusted local system actions."}),parentTokenId:tC([Q,JS],{mode:`oneOf`}).annotate({description:"API token used to delegate this token, or `null` when a user or trusted local system created it."}),resourceMode:DT,resourceGrants:K(cE).annotate({description:"Explicit session and snapshot grants when `resourceMode` is `allowlist`."}).check(AC().annotate({expected:`an array with unique items`})),expiresAt:B(tC([H,JS]).annotate({description:"Authentication expiry time, or `null` when the token does not expire automatically.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),revokedAt:B(tC([H,JS]).annotate({description:"Revocation time, or `null` while the token is active.",examples:[null],format:`date-time`}))}).annotate({description:`API token metadata. The raw bearer secret is never included in this schema.`,identifier:`Token`});tC([G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`platform admin`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:V(`system_admin`),scopes:K(ET).annotate({description:"Must include `system:admin`.",examples:[[`system:admin`]]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`})),expiresAt:B(tC([H,JS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(V(`all`).annotate({description:`System administrator tokens cannot use resource allowlists.`,default:`all`})),resourceGrants:B(K(cE).annotate({description:`Must be empty for a system administrator token.`}).check(EC(0).annotate({expected:`a value with a length of at most 0`})))}),G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`tenant automation`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),authorityType:V(`tenant`),tenantId:iC(()=>Q).annotate({description:`Active tenant to bind permanently to the token.`}),scopes:K(NT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`})),expiresAt:B(tC([H,JS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(DT),resourceGrants:B(K(cE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(AC().annotate({expected:`an array with unique items`})))})],{mode:`oneOf`}).annotate({description:`Token definition accepted by the system administrator token endpoint.`,identifier:`CreateAdminTokenInput`}),G({name:H.annotate({description:`Operator-assigned name. Leading and trailing whitespace is removed.`,examples:[`browser worker`]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(mC(RegExp(`.*\\S.*`,`u`)).annotate({expected:`a string matching the RegExp .*\\S.*`})),scopes:K(NT).annotate({description:"Tenant-compatible scopes. `system:admin` and `tenants:write` are rejected.",examples:[[`sessions:read`,`sessions:write`]]}).check(wC(1).annotate({expected:`a value with a length of at least 1`})).check(AC().annotate({expected:`an array with unique items`})),expiresAt:B(tC([H,JS]).annotate({description:"Optional RFC3339 timestamp. Omit or send `null` for no automatic expiry.",examples:[`2026-08-17T12:00:00Z`],format:`date-time`})),resourceMode:B(DT),resourceGrants:B(K(cE).annotate({description:"Existing tenant resources granted when `resourceMode` is `allowlist`; must be empty for `all`."}).check(AC().annotate({expected:`an array with unique items`})))}).annotate({description:`Token definition automatically bound to the authenticated tenant.`,identifier:`CreateTenantTokenInput`}),tC([lE,nE],{mode:`oneOf`}).annotate({description:`Failure of a live-session route.`,identifier:`LiveSessionFailure`});var FE=G({mode:q([`auto`,`cdp`]).annotate({description:"Configured media mode. `auto` enables deployment-selected media support; `cdp` exposes Chrome DevTools access only.",examples:[`auto`]}),webrtcProducer:W.annotate({description:`Whether the compositor WebRTC producer is available for this session.`,examples:[!0]}),iceServers:B(K(fE).annotate({description:`ICE configuration for WebRTC setup. Omitted when WebRTC is unavailable or does not need configured ICE servers.`}))}).annotate({description:`Media capabilities currently available for the session.`,identifier:`SessionMedia`}),IE=G({origin:H.annotate({format:`uri`}).check(mC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),entries:K(hE)}).annotate({identifier:`InitialTargetStorageOrigin`}),LE=G({upstreams:B(ZS(H,vE).annotate({description:"Upstreams by name. Names use lowercase letters, digits and dashes; `direct`, `refuse` and `local` are reserved."})),rules:B(K(RT).check(EC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:B(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`. Cannot be combined with them. `proxy` becomes a final `*` rule via `url`, `tunnel` a `tunnel` upstream and a final `*` rule via it, each preceded by `direct` rules for the `bypass` entries. `direct` or omitted means no rules.",examples:[`tunnel`]})),url:B(H.annotate({description:"Legacy upstream proxy URL, required with `upstream` `proxy`. Use `upstreams` and `rules`.",examples:[`socks5://user:pass@proxy.example.com:1080`]})),tunnel:B(yE),bypass:B(H.annotate({description:"Legacy hosts to send direct, separated by `;` or `,`. Each entry must be a valid rule `match`; a leading `.` means any subdomain. CIDR ranges, `<local>` and scheme prefixes are rejected. Use `upstreams` and `rules`.",examples:[`*.internal.example.com`]}))}).annotate({description:"Session egress proxy configuration. Rules are checked in order and the first match routes the connection; unmatched connections go direct, and unmatched `localhost` stays on the session host. Omitted for direct egress.",identifier:`ProxyConfig`}),RE=G({upstreams:B(ZS(H,vE)),rules:B(K(RT).check(EC(256).annotate({expected:`a value with a length of at most 256`}))),upstream:B(q([`direct`,`proxy`,`tunnel`]).annotate({description:"Legacy single-upstream shape; use `upstreams` and `rules`."})),url:B(H.annotate({description:"Legacy upstream proxy URL; use `upstreams` and `rules`."})),tunnel:B(yE),bypass:B(H.annotate({description:"Legacy hosts to send direct; use `upstreams` and `rules`."})),drain:B(W.annotate({description:`Reset live tunnel streams instead of letting them drain. New connections use the new rules either way.`,examples:[!1]}))}).annotate({description:"Replacement session egress proxy configuration. Fields other than `drain` are as in `ProxyConfig`.",identifier:`UpdateProxyConfig`}),zE=G({name:H,entries:K(bE)}).annotate({identifier:`InitialCacheStorageCache`}),BE=G({snapshot:xE}).annotate({description:`Snapshot returned after a mutation.`,identifier:`SnapshotMutation`}),VE=G({data:K(xE),meta:jT}).annotate({description:`Cursor-paginated snapshots.`,identifier:`SnapshotPage`}),HE=G({locator:CE,value:PT,checked:B(W),selectedIndices:B(K(U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`})))),selection:B(HT)}).annotate({identifier:`InitialBrowserControlState`}),UE=G({locator:CE,html:PT}).annotate({identifier:`InitialBrowserContentEditableState`}),WE=G({locator:CE,x:U.check(hC().annotate({expected:`a finite number`})),y:U.check(hC().annotate({expected:`a finite number`}))}).annotate({identifier:`InitialBrowserElementScrollPosition`}),GE=G({locator:CE,nodePath:K(U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))).check(EC(256).annotate({expected:`a value with a length of at most 256`})),offset:U.check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))}).annotate({identifier:`InitialBrowserSelectionEndpoint`}),KE=G({name:H,keyPath:GT,autoIncrement:W,indexes:K(TE),records:K(gE)}).annotate({identifier:`InitialIndexedDBObjectStore`}),qE=G({principal:NE,selectedTenant:tC([iE,JS],{mode:`oneOf`}).annotate({description:"Effective tenant, or `null` when the principal has not selected one."}),availableTenants:K(iE).annotate({description:`Active tenant memberships available to an account-backed principal. API-token principals return an empty array.`})}).annotate({description:`Current principal and its effective tenant selection.`,identifier:`AuthMe`}),JE=G({data:K(PE),meta:jT}).annotate({description:`Cursor-paginated API token metadata without bearer secrets.`,identifier:`TokenPage`}),YE=G({token:PE,rawToken:iC(()=>PT).annotate({description:`One-time Aperture API bearer token. Store it immediately; later reads return only token metadata.`,examples:[`apt_019f6cf0000070008000000000000002_REDACTED`]})}).annotate({description:`Created token metadata and its one-time bearer secret.`,identifier:`CreateTokenResponse`}),XE=G({id:iC(()=>Q).annotate({description:`Session identifier.`}),tenantId:iC(()=>Q).annotate({description:`Tenant that owns the session.`}),baseSnapshotName:B(H.annotate({description:`Snapshot name used as the session base. Omitted for a blank session.`,examples:[`signed-in-base`]})),label:B(H.annotate({description:`Optional operator-facing session label.`,examples:[`checkout smoke test`]})),status:FT,browserChannel:B(H.annotate({description:`Browser channel used to create and reopen the session.`,examples:[`chromium`]})),media:FE,createdAt:H.annotate({description:`Time the session record was created.`,examples:[`2026-07-17T12:00:00Z`],format:`date-time`}),startedAt:B(H.annotate({description:`Most recent successful browser start time. Omitted before startup succeeds.`,examples:[`2026-07-17T12:00:03Z`],format:`date-time`})),stoppedAt:B(H.annotate({description:`Most recent browser stop time. Omitted while no stop has occurred.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),deletedAt:B(tC([H,JS]).annotate({description:"Soft-deletion time, or `null` for a session that has not been deleted.",examples:[null],format:`date-time`})),expiresAt:H.annotate({description:`Retention deadline after which the session and its overlay may be purged. This is not token expiry.`,examples:[`2026-07-24T12:00:00Z`],format:`date-time`}),lastConnectedAt:B(H.annotate({description:`Most recent routed client activity time. Omitted until a client connects.`,examples:[`2026-07-17T12:30:00Z`],format:`date-time`})),suspendedAt:B(H.annotate({description:`Most recent suspension time. Omitted unless the session is suspended.`,examples:[`2026-07-17T13:00:00Z`],format:`date-time`})),tags:B(iC(()=>IT).annotate({description:`Session metadata tags. Omitted when no tags are set.`})),cdpUrl:B(H.annotate({description:"Authenticated Chrome DevTools endpoint. Omitted when the session is not currently routable. Use it with `sessionToken`.",examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:B(iC(()=>PT).annotate({description:`Session access secret returned when live access credentials are available. Rotation invalidates the previous token immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})),collaboration:B(pE),thumbnail:B(mE),proxy:B(SE)}).annotate({description:`Browser session state, retention metadata, tags, and currently available access credentials.`,identifier:`Session`}),ZE=G({anchor:GE,focus:GE}).annotate({identifier:`InitialBrowserDocumentSelection`}),QE=G({name:H,version:U.check(Y().annotate({expected:`an integer`})).check(J(1).annotate({expected:`a value greater than or equal to 1`})),objectStores:K(KE)}).annotate({identifier:`InitialIndexedDBDatabase`}),$E=G({data:K(XE),meta:jT}).annotate({description:`Cursor-paginated browser sessions.`,identifier:`SessionPage`}),eD=G({session:XE,cdpUrl:H.annotate({description:`Authenticated Chrome DevTools endpoint for the new session.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`}),sessionToken:iC(()=>PT).annotate({description:`Initial session access secret. Store it immediately.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]})}).annotate({description:`Newly created session and its one-time initial access credentials.`,identifier:`CreateSessionResult`}),tD=G({sessions:K(XE)}).annotate({description:`Sessions found for the requested IDs, preserving request order.`,identifier:`SessionBulkResponse`}),nD=G({session:XE,cdpUrl:B(H.annotate({description:`Current Chrome DevTools endpoint. Omitted by operations that do not expose live access.`,examples:[`https://aperture.example.com/cdp/019f6cf0-0000-7000-8000-000000000010`],format:`uri`})),sessionToken:B(iC(()=>PT).annotate({description:`Current raw session access secret. Omitted by operations that do not expose or replace credentials.`,examples:[`aps_019f6cf0000070008000000000000010_REDACTED`]}))}).annotate({description:`Updated session and operation-specific live access credentials when available.`,identifier:`SessionMutation`}),rD=G({version:V(1),windowName:B(PT),historyState:B(iC(()=>PT).annotate({description:`JSON-encoded structured-clone history state.`})),controls:K(HE).check(EC(1e4).annotate({expected:`a value with a length of at most 10000`})),contentEditables:K(UE).check(EC(1e4).annotate({expected:`a value with a length of at most 10000`})),scrollPositions:K(WE).check(EC(1e4).annotate({expected:`a value with a length of at most 10000`})),focus:B(CE),selection:B(ZE)}).annotate({description:`Sensitive top-document state replayed during initial navigation.`,identifier:`InitialBrowserDocumentState`}),iD=G({origin:H.annotate({examples:[`https://example.com`],format:`uri`}).check(mC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`})),ancestorOrigins:B(K(H.annotate({format:`uri`}).check(mC(RegExp(`^https?:\\/\\/[^/]+$`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/[^/]+$`}))).annotate({description:`Top-down HTTP origin chain for partitioned storage. Omitted for a top-level origin.`}).check(EC(32).annotate({expected:`a value with a length of at most 32`}))),localStorage:K(hE),indexedDB:B(K(QE)),cacheStorage:B(K(zE)),opfs:B(K(_E))}).annotate({description:`Profile-scoped browser storage imported for one exact HTTP origin and ancestor partition.`,identifier:`InitialStorageOrigin`}),aD=G({url:H.annotate({description:`Absolute HTTP or HTTPS URL without embedded credentials.`,examples:[`https://example.com/account`],format:`uri`}).check(mC(RegExp(`^https?:\\/\\/`,`u`)).annotate({expected:`a string matching the RegExp ^https?:\\/\\/`})),sessionStorage:B(K(IE).annotate({description:`Per-origin session storage installed in target frames before page scripts execute.`})),scroll:B(BT),documentState:B(rD),openerTargetIndex:B(U.annotate({description:`Index of another initial target that opened this target.`}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),active:B(W.annotate({description:`Select this target for the first connected session client. At most one target may be active.`,default:!1}))}).annotate({description:`HTTP page and target-scoped state opened during session creation.`,identifier:`InitialBrowserTarget`}),oD=G({cookies:K(wE).check(EC(1e4).annotate({expected:`a value with a length of at most 10000`})),origins:K(iD).check(EC(100).annotate({expected:`a value with a length of at most 100`}))}).annotate({description:`Profile-scoped browser storage imported before initial browser targets are opened.`,identifier:`InitialBrowserStorageState`}),sD=G({baseSnapshotName:B(tC([H,JS]).annotate({description:"Active snapshot used as the browser filesystem base. Omit, send `null`, or send an empty value for a blank session.",examples:[`signed-in-base`]})),label:B(tC([H,JS]).annotate({description:`Optional operator-facing label for the session.`,examples:[`checkout smoke test`]})),browser:zT,initialTargets:B(K(aD).annotate({description:`Browser targets that replace the browser's startup page after storage import. Result order follows input order; opener dependencies may be created first.`}).check(EC(50).annotate({expected:`a value with a length of at most 50`}))),storageState:B(oD),tags:B(iC(()=>IT).annotate({description:`Initial session tags.`})),proxy:B(LE)}).annotate({description:`Configuration for a new retained browser session.`,examples:[{baseSnapshotName:`signed-in-base`,label:`checkout smoke test`,browser:{channel:`chromium`,args:[`--lang=en-US`]},initialTargets:[{url:`https://example.com/account`}],storageState:{cookies:[],origins:[{origin:`https://example.com`,localStorage:[{name:`access-token`,value:`REDACTED`}]}]},tags:{environment:`staging`,suite:`checkout`}}],identifier:`CreateSessionInput`}),cD=CT;G({"X-Aperture-Tenant-Id":B(Q)});var lD=qE,uD=uE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),deleted:B(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:B(W.annotate({default:!1})),query:B(H)});var dD=kE,fD=iE,pD=iE,mD=iE,hD=iE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),query:B(H),disabled:B(q([`active`,`disabled`,`all`]).annotate({default:`active`}))});var gD=AE,_D=aE,vD=aE,yD=aE,bD=aE,xD=aE,SD=MT,CD=K(dE),wD=K(dE),TD=dE,ED=lE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),tenantId:B(Q),actorType:B(wT),actorId:B(H),action:B(H),resourceType:B(H),resourceId:B(H)});var DD=ME;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),authorityType:B(TT),tenantId:B(Q),name:B(H),scope:B(ET),revoked:B(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var OD=JE,kD=YE,AD=lE,jD=iE,MD=iE;G({limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),name:B(H),scope:B(ET),revoked:B(q([`active`,`revoked`,`all`]).annotate({default:`all`}))});var ND=JE,PD=YE,FD=lE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),includeDeleted:B(W.annotate({default:!1})),status:B(FT),query:B(H),tagKey:B(K(H.check(wC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:B(K(H.check(wC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:B(K(q([`eq`,`neq`,`in`,`not_in`])))});var ID=$E;G({"X-Aperture-Tenant-Id":B(Q),waitForReady:B(W.annotate({default:!0}))});var LD=sD,RD=eD;G({"X-Aperture-Tenant-Id":B(Q)});var zD=tD;G({"X-Aperture-Tenant-Id":B(Q)});var BD=XE;G({"X-Aperture-Tenant-Id":B(Q)});var VD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var HD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var UD=RE,WD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var GD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var KD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var qD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var JD=nD;G({"X-Aperture-Tenant-Id":B(Q)});var YD=qT;G({"X-Aperture-Tenant-Id":B(Q)});var XD=qT;G({"X-Aperture-Tenant-Id":B(Q)});var ZD=lE;G({"X-Aperture-Tenant-Id":B(Q)});var QD=lE;G({"X-Aperture-Tenant-Id":B(Q)});var $D=oD;G({"X-Aperture-Tenant-Id":B(Q)});var eO=K(EE);G({"X-Aperture-Tenant-Id":B(Q)});var tO=EE;G({"X-Aperture-Tenant-Id":B(Q)});var nO=EE;G({"X-Aperture-Tenant-Id":B(Q)});var rO=EE;G({"X-Aperture-Tenant-Id":B(Q)});var iO=lE;G({"X-Aperture-Tenant-Id":B(Q)});var aO=lE;G({"X-Aperture-Tenant-Id":B(Q)});var oO=lE;G({"X-Aperture-Tenant-Id":B(Q)});var sO=EE;G({"X-Aperture-Tenant-Id":B(Q)});var cO=K(DE);G({"X-Aperture-Tenant-Id":B(Q),directory:B(H.annotate({default:`uploads`}))}),G({files:B(K(eE))});var lO=G({files:K(QT)}).annotate({description:`Files stored by this request, in request order.`});G({"X-Aperture-Tenant-Id":B(Q),relativePath:H.check(wC(1).annotate({expected:`a value with a length of at least 1`})),recursive:B(W.annotate({default:!1}))});var uO=lE;G({"X-Aperture-Tenant-Id":B(Q)});var dO=DE;G({"X-Aperture-Tenant-Id":B(Q)});var fO=$T;G({"X-Aperture-Tenant-Id":B(Q)});var pO=tE;G({"X-Aperture-Tenant-Id":B(Q)});var mO=BE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),name:B(H),deleted:B(q([`active`,`deleted`,`all`]).annotate({default:`active`})),includeDeleted:B(W.annotate({default:!1})),tagKey:B(K(H.check(wC(1).annotate({expected:`a value with a length of at least 1`})))),tagValue:B(K(H.check(wC(1).annotate({expected:`a value with a length of at least 1`})))),tagOperator:B(K(q([`eq`,`neq`,`in`,`not_in`])))});var hO=VE;G({"X-Aperture-Tenant-Id":B(Q)});var gO=BE;G({"X-Aperture-Tenant-Id":B(Q)});var _O=BE;G({"X-Aperture-Tenant-Id":B(Q)});var vO=BE;G({"X-Aperture-Tenant-Id":B(Q)});var yO=BE;G({"X-Aperture-Tenant-Id":B(Q),limit:B(U.annotate({default:50}).check(Y().annotate({expected:`an integer`})).check(J(0).annotate({expected:`a value greater than or equal to 0`}))),cursor:B(H),resourceType:B(H),resourceId:B(H)});var bO=jE;G({"X-Aperture-Tenant-Id":B(Q)}),G({files:B(K(eE))});var xO=G({files:K(QT)}).annotate({description:`Files stored by this request, in request order.`});G({"X-Aperture-Tenant-Id":B(Q)});var SO=OE,CO=(e,t={})=>{let n=e=>L(Pf(e.json,()=>`Unexpected status code`),t=>I(new fw({reason:new _w({request:e.request,response:e,description:typeof t==`string`?t:JSON.stringify(t)})}))),r=n=>r=>{let i=n?.includeResponse?e=>R(r(e),t=>[t,e]):e=>r(e);return t?.transformClient?n=>L(L(t.transformClient(e),e=>e.execute(n)),i):t=>L(e.execute(t),i)},i=encodeURIComponent,a=(e,t,n)=>lf(()=>{let r=(t,n)=>I(new fw({reason:new gw({request:e(``),cause:n,description:t})}));if(t.some(e=>e===``||/^(?:\.|%2e){1,2}$/i.test(e)))return r(`Path parameters must be non-empty and cannot be dot segments`);let i;try{i=n()}catch(e){return r(`Failed to encode path parameter`,e)}return i.split(`/`).some(e=>/^(?:\.|%2e){1,2}$/i.test(e))?r(`Request paths cannot contain dot segments`):P(e(i))}),o=n=>lf(()=>t.transformClient?L(t.transformClient(e),e=>lT(e).execute(n)):lT(e).execute(n)),s=e=>R(e.arrayBuffer,e=>new Uint8Array(e)),c=e=>o(e).pipe(R(e=>e.stream),lg),l=e=>t=>$w(e)(t);return{httpClient:e,getHealth:e=>Aw(`/api/health`).pipe(r(e?.config)(Z({"2xx":l(cD),orElse:n}))),getCurrentPrincipal:e=>Aw(`/api/auth/me`).pipe(X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(lD),orElse:n}))),listBrowserChannels:e=>Aw(`/api/browser/channels`).pipe(r(e?.config)(Z({"2xx":l(uD),orElse:n}))),listTenants:e=>Aw(`/api/admin/tenants`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,query:e?.params?.query}),r(e?.config)(Z({"2xx":l(dD),orElse:n}))),createTenant:e=>jw(`/api/admin/tenants`).pipe(Yw(e.payload),r(e.config)(Z({"2xx":l(fD),orElse:n}))),deleteTenant:(e,t)=>a(Pw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(pD),orElse:n}))))),updateTenant:(e,t)=>a(Mw,[e],()=>`/api/admin/tenants/`+i(e)).pipe(L(e=>e.pipe(Yw(t.payload),r(t.config)(Z({"2xx":l(mD),orElse:n}))))),restoreTenant:(e,t)=>a(jw,[e],()=>`/api/admin/tenants/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(hD),orElse:n}))))),listUsers:e=>Aw(`/api/admin/users`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,query:e?.params?.query,disabled:e?.params?.disabled}),r(e?.config)(Z({"2xx":l(gD),orElse:n}))),createUser:e=>jw(`/api/admin/users`).pipe(Yw(e.payload),r(e.config)(Z({"2xx":l(_D),orElse:n}))),getUser:(e,t)=>a(Aw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(vD),orElse:n}))))),disableUser:(e,t)=>a(Pw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(yD),orElse:n}))))),updateUser:(e,t)=>a(Mw,[e],()=>`/api/admin/users/`+i(e)).pipe(L(e=>e.pipe(Yw(t.payload),r(t.config)(Z({"2xx":l(bD),orElse:n}))))),restoreUser:(e,t)=>a(jw,[e],()=>`/api/admin/users/`+i(e)+`/restore`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(xD),orElse:n}))))),createUserInvitation:(e,t)=>a(jw,[e],()=>`/api/admin/users/`+i(e)+`/invitation`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(SD),orElse:n}))))),listUserMemberships:(e,t)=>a(Aw,[e],()=>`/api/admin/users/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(CD),orElse:n}))))),listTenantMemberships:(e,t)=>a(Aw,[e],()=>`/api/admin/tenants/`+i(e)+`/memberships`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(wD),orElse:n}))))),upsertTenantMembership:(e,t,o)=>a(Nw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(Yw(o.payload),r(o.config)(Z({"2xx":l(TD),orElse:n}))))),deleteTenantMembership:(e,t,o)=>a(Pw,[e,t],()=>`/api/admin/tenants/`+i(e)+`/memberships/`+i(t)).pipe(L(e=>e.pipe(r(o?.config)(Z({"2xx":l(ED),204:()=>uf,orElse:n}))))),listAuditEvents:e=>Aw(`/api/admin/audit-events`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,tenantId:e?.params?.tenantId,actorType:e?.params?.actorType,actorId:e?.params?.actorId,action:e?.params?.action,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),r(e?.config)(Z({"2xx":l(DD),orElse:n}))),listAdminTokens:e=>Aw(`/api/admin/tokens`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,authorityType:e?.params?.authorityType,tenantId:e?.params?.tenantId,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(OD),orElse:n}))),createAdminToken:e=>jw(`/api/admin/tokens`).pipe(Yw(e.payload),r(e.config)(Z({"2xx":l(kD),orElse:n}))),revokeAdminToken:(e,t)=>a(jw,[e],()=>`/api/admin/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(AD),204:()=>uf,orElse:n}))))),getTenant:e=>Aw(`/api/tenant`).pipe(r(e?.config)(Z({"2xx":l(jD),orElse:n}))),updateSelectedTenant:e=>Mw(`/api/tenant`).pipe(Yw(e.payload),r(e.config)(Z({"2xx":l(MD),orElse:n}))),listTenantTokens:e=>Aw(`/api/tenant/tokens`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,scope:e?.params?.scope,revoked:e?.params?.revoked}),r(e?.config)(Z({"2xx":l(ND),orElse:n}))),createTenantToken:e=>jw(`/api/tenant/tokens`).pipe(Yw(e.payload),r(e.config)(Z({"2xx":l(PD),orElse:n}))),revokeTenantToken:(e,t)=>a(jw,[e],()=>`/api/tenant/tokens/`+i(e)+`/revoke`).pipe(L(e=>e.pipe(r(t?.config)(Z({"2xx":l(FD),204:()=>uf,orElse:n}))))),listSessions:e=>Aw(`/api/sessions`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,includeDeleted:e?.params?.includeDeleted,status:e?.params?.status,query:e?.params?.query,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(ID),orElse:n}))),createSession:e=>jw(`/api/sessions`).pipe(Kw({waitForReady:e.params?.waitForReady}),X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(e.payload),r(e.config)(Z({"2xx":l(RD),orElse:n}))),getSessionsBulk:e=>jw(`/api/sessions/bulk`).pipe(X({"X-Aperture-Tenant-Id":e.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(e.payload),r(e.config)(Z({"2xx":l(zD),orElse:n}))),getSession:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(BD),orElse:n}))))),deleteSession:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(VD),orElse:n}))))),replaceSessionTags:(e,t)=>a(Nw,[e],()=>`/api/sessions/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(HD),orElse:n}))))),updateSessionProxy:(e,t)=>a(Nw,[e],()=>`/api/sessions/`+i(e)+`/proxy`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(WD),orElse:n}))))),suspendSession:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/suspend`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(GD),orElse:n}))))),reopenSession:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/reopen`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(KD),orElse:n}))))),rotateSessionToken:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/session-token/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(qD),orElse:n}))))),rotateCollaborationCapability:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/collaboration-capabilities/`+i(t)+`/rotate`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(JD),orElse:n}))))),getSessionCursor:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(YD),orElse:n}))))),setSessionCursor:(e,t)=>a(Nw,[e],()=>`/api/sessions/`+i(e)+`/cursor`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(XD),orElse:n}))))),getSessionThumbnail:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(ZD),200:s,orElse:n}))))),getSessionThumbnailStream:(e,t)=>lg(a(Aw,[e],()=>`/api/sessions/`+i(e)+`/thumbnail`).pipe(R(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),getSessionTargetThumbnail:(e,t,o)=>a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(QD),200:s,orElse:n}))))),getSessionTargetThumbnailStream:(e,t,n)=>lg(a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/targets/`+i(t)+`/thumbnail`).pipe(R(e=>e.pipe(X({"X-Aperture-Tenant-Id":n?.params?.[`X-Aperture-Tenant-Id`]??void 0}),c)))),exportSessionStorageState:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/storage-state`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l($D),orElse:n}))))),listSessionRecordings:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(eO),orElse:n}))))),createSessionRecording:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/recordings`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(tO),orElse:n}))))),getSessionRecording:(e,t,o)=>a(Aw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(nO),orElse:n}))))),retargetSessionRecording:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/retarget`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(o.payload),r(o.config)(Z({"2xx":l(rO),orElse:n}))))),captionSessionRecording:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/caption`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(o.payload),r(o.config)(Z({"2xx":l(iO),204:()=>uf,orElse:n}))))),focusSessionRecording:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/focus`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(o.payload),r(o.config)(Z({"2xx":l(aO),204:()=>uf,orElse:n}))))),attentionSessionRecording:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/attention`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(o.payload),r(o.config)(Z({"2xx":l(oO),204:()=>uf,orElse:n}))))),stopSessionRecording:(e,t,o)=>a(jw,[e,t],()=>`/api/sessions/`+i(e)+`/recordings/`+i(t)+`/stop`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":o?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(o?.config)(Z({"2xx":l(sO),orElse:n}))))),listSessionFiles:(e,t)=>a(Aw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(cO),orElse:n}))))),uploadSessionFiles:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Kw({directory:t.params?.directory}),X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Xw(t.payload),r(t.config)(Z({"2xx":l(lO),orElse:n}))))),deleteSessionFile:(e,t)=>a(Pw,[e],()=>`/api/sessions/`+i(e)+`/files`).pipe(L(e=>e.pipe(Kw({relativePath:t.params.relativePath,recursive:t.params.recursive}),X({"X-Aperture-Tenant-Id":t.params[`X-Aperture-Tenant-Id`]??void 0}),r(t.config)(Z({"2xx":l(uO),204:()=>uf,orElse:n}))))),moveSessionFile:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/files/move`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(dO),orElse:n}))))),createSessionDirectory:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/files/directories`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(fO),orElse:n}))))),createSessionFileDownloadURL:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/files/download-url`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(pO),orElse:n}))))),promoteSession:(e,t)=>a(jw,[e],()=>`/api/sessions/`+i(e)+`/promote`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(mO),orElse:n}))))),listSnapshots:e=>Aw(`/api/snapshots`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,name:e?.params?.name,deleted:e?.params?.deleted,includeDeleted:e?.params?.includeDeleted,tagKey:e?.params?.tagKey,tagValue:e?.params?.tagValue,tagOperator:e?.params?.tagOperator}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(hO),orElse:n}))),deleteSnapshot:(e,t)=>a(Pw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(gO),orElse:n}))))),updateSnapshot:(e,t)=>a(Mw,[e],()=>`/api/snapshots/`+i(e)).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(_O),orElse:n}))))),replaceSnapshotTags:(e,t)=>a(Nw,[e],()=>`/api/snapshots/`+i(e)+`/tags`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(vO),orElse:n}))))),restoreSnapshot:(e,t)=>a(jw,[e],()=>`/api/snapshots/`+i(e)+`/restore`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(t?.config)(Z({"2xx":l(yO),orElse:n}))))),listEvents:e=>Aw(`/api/events`).pipe(Kw({limit:e?.params?.limit,cursor:e?.params?.cursor,resourceType:e?.params?.resourceType,resourceId:e?.params?.resourceId}),X({"X-Aperture-Tenant-Id":e?.params?.[`X-Aperture-Tenant-Id`]??void 0}),r(e?.config)(Z({"2xx":l(bO),orElse:n}))),uploadLiveSessionFiles:(e,t)=>a(jw,[e],()=>`/sessions/`+i(e)+`/uploads`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Xw(t.payload),r(t.config)(Z({"2xx":l(xO),orElse:n}))))),setSessionViewport:(e,t)=>a(jw,[e],()=>`/sessions/`+i(e)+`/browser/viewport`).pipe(L(e=>e.pipe(X({"X-Aperture-Tenant-Id":t.params?.[`X-Aperture-Tenant-Id`]??void 0}),Yw(t.payload),r(t.config)(Z({"2xx":l(SO),orElse:n})))))}},wO=`X-Aperture-Tenant-Id`,TO={kind:`session`,authorityType:null,tenantId:null,selectedTenantId:null};function EO(e,t){if(t!==`none`){if(t===`optional`)return e.selectedTenantId??void 0;if(e.authorityType===`tenant`)return e.kind===`bearer`?void 0:e.tenantId??void 0;if(e.authorityType===`system_admin`)return e.selectedTenantId??void 0}}var DO={anonymous:{},webSession:{credentials:TO},of:e=>({credentials:e}),tenantScoped:e=>({credentials:e,tenantHeader:`tenant-scoped`})},OO=class extends _r()(`@aperture-browser/api-client/ApiAuthorization`){},kO=q([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),AO=G({id:H,type:V(`public-key`),transports:B($S(K(kO)))}),jO=B(G({appid:B(H),credProps:B(W),hmacCreateSecret:B(W),minPinLength:B(W)})),MO=q([`hybrid`,`security-key`,`client-device`]),NO=q([`discouraged`,`preferred`,`required`]),PO=G({methods:K(tC([G({type:V(`password`)}),G({type:V(`api_token`)}),G({type:V(`passkey`)}),G({type:V(`oidc`),id:H,name:H,loginUrl:H})]))}),FO=G({publicKey:G({challenge:H,timeout:B(U),rpId:B(H),allowCredentials:B($S(K(AO))),userVerification:B(NO),hints:B($S(K(MO))),extensions:jO})}),IO=G({publicKey:G({rp:G({id:B(H),name:H}),user:G({id:H,name:H,displayName:H}),challenge:H,pubKeyCredParams:$S(K(G({alg:q([-7,-8,-35,-36,-37,-38,-39,-257,-258,-259]),type:V(`public-key`)}))),timeout:B(U),excludeCredentials:B($S(K(AO))),authenticatorSelection:B(G({authenticatorAttachment:B(q([`platform`,`cross-platform`])),requireResidentKey:B(W),residentKey:B(q([`discouraged`,`preferred`,`required`])),userVerification:B(NO)})),hints:B($S(K(MO))),attestation:B(q([`direct`,`enterprise`,`indirect`,`none`])),attestationFormats:B($S(K(q([`fido-u2f`,`packed`,`android-safetynet`,`android-key`,`tpm`,`apple`,`none`])))),extensions:jO})}),LO=G({id:H,name:H,createdAt:H,lastUsedAt:nC(H)}),RO=G({passkeys:K(LO)}),zO=G({passkey:LO}),BO=G({mfaRequired:W}),VO=G({hasPassword:W,totpEnabled:W,recoveryCodesRemaining:U.check(Y(),J(0))}),HO=G({secret:H,otpauthUrl:H,qrCodeDataUrl:H}),UO=G({recoveryCodes:K(H)}),WO=G({id:H,name:H,uri:nC(H),logoUri:nC(H),kind:q([`registered`,`metadata_document`])}),GO=G({client:WO,redirectUri:H,requestedScopes:K(H),user:G({id:H,displayName:H,isSystemAdmin:W}),tenants:K(G({id:H,displayName:H,scopes:K(NT)})),availableScopes:K(NT),canGrantSystemAdmin:W}),KO=G({redirectUrl:H}),qO=G({grants:K(G({id:H,client:WO,authorityType:TT,tenants:K(G({id:H,displayName:H})),scopes:K(H),resourceMode:DT,resourceGrants:K(G({resourceType:OT,resourceId:H})),createdAt:H,lastUsedAt:nC(H)}))}),JO=class extends _r()(`@aperture-browser/api-client/AuthApi`){},YO=e=>({body:iw(e)}),XO=ld(JO,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=lT(e),r=CO(e),i=t(DO.anonymous),a=t(DO.webSession),o=z(`AuthApi.listLoginMethods`)(function*(){return yield*n.get(`/auth/login-methods`).pipe(L($w(PO)),i)}),s=z(`AuthApi.loginWithPassword`)(function*(e,t){return yield*n.post(`/auth/password/login`,YO({email:e,password:t})).pipe(L($w(BO)),i)}),c=z(`AuthApi.completePasswordMFA`)(function*(e){yield*n.post(`/auth/password/login/mfa`,YO({code:e})).pipe(i)}),l=z(`AuthApi.loginWithAPIToken`)(function*(e){yield*n.post(`/auth/token/login`,YO({token:e})).pipe(i)}),u=z(`AuthApi.beginPasskeyLogin`)(function*(){return yield*n.post(`/auth/passkeys/login/options`).pipe(L($w(FO)),i)}),d=z(`AuthApi.finishPasskeyLogin`)(function*(e){yield*n.post(`/auth/passkeys/login/finish`,YO(e)).pipe(i)}),f=z(`AuthApi.acceptUserInvitation`)(function*(e,t){yield*n.post(`/auth/invitations/accept`,YO({token:e,password:t})).pipe(i)}),p=z(`AuthApi.logoutWebSession`)(function*(){yield*n.post(`/auth/logout`).pipe(a)}),m=z(`AuthApi.getAuthMe`)(function*(e=null,n=TO){return yield*r.getCurrentPrincipal(void 0).pipe(t({credentials:{...n,selectedTenantId:e},tenantHeader:`optional`}))}),h=z(`AuthApi.getSecurityStatus`)(function*(){return yield*n.get(`/auth/security`).pipe(L($w(VO)),a)}),g=z(`AuthApi.setPassword`)(function*(e,t){yield*n.put(`/auth/password`,YO({currentPassword:e,newPassword:t})).pipe(a)}),_=z(`AuthApi.listPasskeys`)(function*(){return yield*n.get(`/auth/passkeys`).pipe(L($w(RO)),a)}),v=z(`AuthApi.beginPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/options`,YO({name:e})).pipe(L($w(IO)),a)}),y=z(`AuthApi.finishPasskeyRegistration`)(function*(e){return yield*n.post(`/auth/passkeys/registration/finish`,YO(e)).pipe(L($w(zO)),a)}),b=z(`AuthApi.renamePasskey`)(function*(e,t){return yield*n.patch(`/auth/passkeys/${encodeURIComponent(e)}`,YO({name:t})).pipe(L($w(zO)),a)}),x=z(`AuthApi.deletePasskey`)(function*(e){yield*n.del(`/auth/passkeys/${encodeURIComponent(e)}`).pipe(a)}),ee=z(`AuthApi.beginTOTPEnrollment`)(function*(){return yield*n.post(`/auth/totp/enrollment/options`).pipe(L($w(HO)),a)}),S=z(`AuthApi.completeTOTPEnrollment`)(function*(e){return yield*n.post(`/auth/totp/enrollment/finish`,YO({code:e})).pipe(L($w(UO)),a)}),C=z(`AuthApi.regenerateRecoveryCodes`)(function*(e){return yield*n.post(`/auth/totp/recovery-codes`,YO({code:e})).pipe(L($w(UO)),a)}),te=z(`AuthApi.disableTOTP`)(function*(e){yield*n.post(`/auth/totp/disable`,YO({code:e})).pipe(a)}),ne=z(`AuthApi.getOAuthAuthorization`)(function*(e){return yield*n.get(`/auth/oauth/authorization?${e}`).pipe(L($w(GO)),a)}),w=z(`AuthApi.approveOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/approve`,YO(e)).pipe(L($w(KO)),a)}),T=z(`AuthApi.denyOAuthAuthorization`)(function*(e){return yield*n.post(`/auth/oauth/authorization/deny`,YO({query:e})).pipe(L($w(KO)),a)}),re=z(`AuthApi.listOAuthGrants`)(function*(){return yield*n.get(`/auth/oauth/grants`).pipe(L($w(qO)),a)}),ie=z(`AuthApi.revokeOAuthGrant`)(function*(e){yield*n.del(`/auth/oauth/grants/${encodeURIComponent(e)}`).pipe(a)});return JO.of({listLoginMethods:o,loginWithPassword:s,completePasswordMFA:c,loginWithAPIToken:l,beginPasskeyLogin:u,finishPasskeyLogin:d,acceptUserInvitation:f,logoutWebSession:p,getAuthMe:m,getSecurityStatus:h,setPassword:g,listPasskeys:_,beginPasskeyRegistration:v,finishPasskeyRegistration:y,renamePasskey:b,deletePasskey:x,beginTOTPEnrollment:ee,completeTOTPEnrollment:S,regenerateRecoveryCodes:C,disableTOTP:te,getOAuthAuthorization:ne,approveOAuthAuthorization:w,denyOAuthAuthorization:T,listOAuthGrants:re,revokeOAuthGrant:ie})})),ZO=tC([G({error:G({code:H,message:H})}),G({error:H})]),QO=class extends qC()(`ApiRequestError`,{code:H,message:H,status:U,cause:WS(tC([dC(fw),dC(kS)]))}){},$O=(e,t)=>new QO({code:`internal_error`,message:`Invalid response`,status:e,cause:t}),ek=e=>e.pipe(Af(`HttpClientError`,{StatusCodeError:({response:e},t)=>$w(ZO)(e).pipe(R(({error:t})=>typeof t==`string`?new QO({code:`live_session_error`,message:t,status:e.status}):new QO({...t,status:e.status})),Pf(()=>new QO({code:`internal_error`,message:`Request failed`,status:e.status,cause:t})),L(I)),DecodeError:({response:e},t)=>I($O(e.status,t))}),kf({HttpClientError:e=>I(new QO({code:`network_error`,message:`The server could not be reached`,status:0,cause:e})),SchemaError:e=>I($O(0,e))})),tk=Yr(`@aperture-browser/api-client/CurrentAuthorization`,{defaultValue:()=>({})}),nk=e=>tk.useSync(({credentials:t,bearerToken:n,tenantHeader:r=`none`})=>{let i=n??(t?.kind===`bearer`?t.token:void 0),a=i===void 0?void 0:y_(i).trim(),o=t?EO(t,r):void 0;return e.pipe(Hw,a?Bw(a):x,o?Lw(wO,o):zw(wO))}),rk=new Set([`authentication_required`,`invalid_authentication_token`,`authentication_token_expired`,`authentication_token_revoked`,`user_disabled`]),ik=ld(sT,R(sT,mT(nk))),ak=ld(OO,pf(function*(){let e=yield*em();return OO.of({authorize:t=>n=>n.pipe(ek,Mf(n=>t.credentials?.kind===`session`&&rk.has(n.code)?nm(e,void 0):uf),Gf(tk,t)),sessionAuthenticationFailures:og(e)})})),ok=class extends _r()(`@aperture-browser/api-client/EventsApi`){},sk=class extends _r()(`@aperture-browser/api-client/HealthApi`){};function ck(e){return e.meta.hasMore?e.meta.nextCursor:void 0}function lk(e){let t=(t,n)=>cg(void 0,r=>e(t,n===void 0?{cursor:r}:{...n,cursor:r}).pipe(R(e=>{let t=ck(e);return[e.data,t===void 0?or():sr(t)]})));return{list:e,stream:t,listAll:(e,n)=>yg(t(e,n))}}var uk=e=>({tagKey:e?.map(e=>e.key),tagOperator:e?.map(e=>e.operator),tagValue:e?.map(e=>e.values.join(`,`))}),dk=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t==null||t===``)return[];if(!Array.isArray(t))return[[e,t]];let n=t.filter(e=>e!==``);return n.length>0?[[e,n]]:[]})),fk=ld(ok,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=z(`EventsApi.listEvents`)(function*(e,r={}){return yield*n.listEvents({params:dk({limit:r.limit,cursor:r.cursor,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(DO.tenantScoped(e)))}),i=z(`EventsApi.listAuditEvents`)(function*(e,r={}){return yield*n.listAuditEvents({params:dk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,actorType:r.actorType,actorId:r.actorId,action:r.action,resourceType:r.resourceType,resourceId:r.resourceId})}).pipe(t(DO.of(e)))}),a=lk(r),o=lk(i);return ok.of({listEvents:r,streamEvents:a.stream,listAllEvents:a.listAll,listAuditEvents:i,streamAuditEvents:o.stream,listAllAuditEvents:o.listAll})})),pk=ld(sk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=z(`HealthApi.getHealth`)(function*(){return yield*n.getHealth(void 0).pipe(t(DO.anonymous))});return sk.of({getHealth:r})})),mk=U.check(Y(),xC(0)),hk=P([]),gk=G({capture:YT.fields.capture,presentation:YT.fields.presentation,idle:YT.fields.idle,ripple:YT.fields.ripple,burst:YT.fields.burst}),_k={sessionId:H,cdpUrl:H,media:FE,thumbnailAvailable:W,pages:K(G({targetId:H,state:q([`pending`,`ready`,`unavailable`,`closed`]),title:H,url:H,viewport:B(G({width:mk,height:mk,deviceScaleFactor:U.check(xC(0)),contentWidth:mk,contentHeight:mk,canvasWidth:mk,canvasHeight:mk})),thumbnailAvailable:W})).pipe(cC(hk))},vk={..._k,capturedAt:H,representativeTargetId:B(H)},yk=tC([G({...vk,status:V(`running`),source:V(`live`)}),G({...vk,status:V(`suspended`),source:V(`persisted`)}),G({..._k,status:V(`suspended`),source:V(`unavailable`)})]),bk={recordingId:H,mode:q([`tab`,`viewer`]),targetId:H,captureGeneration:mk,status:q([`starting`,`running`,`stopped`,`failed`]),stopReason:B(H),sandboxPath:B(H),path:B(H),startedAt:H,stoppedAt:B(H),sizeBytes:B(U.check(Y(),J(0))),fps:mk,bitrateKbps:mk,codec:H,editing:W,editedRelativePath:B(H),timelineRelativePath:B(H),editError:B(JT)},xk=G({...bk,relativePath:B(H)}).pipe(aC(G({...bk,relativePath:H}),Qv({decode:({relativePath:e,...t})=>({...t,relativePath:e??t.path??``}),encode:e=>e}))),Sk=class extends _r()(`@aperture-browser/api-client/SessionsApi`){},Ck=Nd,wk=e=>yf(t=>P(e(t.getRef(Ck)))),Tk=(e,t,n)=>{let r=n?.halfOpen===!0?0:1;return wk(n=>{let i=Math.ceil(e),a=Math.floor(t);return Math.floor(n.nextDoubleUnsafe()*(a-i+r))+i})},Ek=new TextEncoder,Dk=e=>e.replaceAll(`"`,`%22`).replaceAll(`\r`,`%0D`).replaceAll(`
|
|
26
|
+
`,`%0A`),Ok=e=>e instanceof Blob?sg({evaluate:()=>e.stream(),onError:e=>e}):e instanceof Uint8Array?tg(e):e,kk=z(`SessionsApi.streamedMultipart`)(function*(e){let t=`aperture-upload-${(yield*Tk(0,2**53-1)).toString(36)}`;return uw(ig(e.map(e=>{let n=`--${t}\r\nContent-Disposition: form-data; name="files"; filename="${Dk(e.name)}"\r\nContent-Type: application/octet-stream\r
|
|
27
27
|
\r
|
|
28
|
-
`;return tg(
|
|
29
|
-
`))))})).pipe(dg(),fg(tg(vk.encode(`--${t}--\r\n`)))),`multipart/form-data; boundary=${t}`)}),Sk=z(`SessionsApi.uploadBody`)(function*(e){let t=new FormData;for(let n of e)if(n.content instanceof Blob)t.append(`files`,n.content,n.name);else if(n.content instanceof Uint8Array)t.append(`files`,new Blob([new Uint8Array(n.content)]),n.name);else return yield*xk(e);return aw(t)}),Ck=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,wk=(e,t)=>`/sessions/${encodeURIComponent(e)}/recordings/${encodeURIComponent(t)}/content`,Tk=100,Ek=ld(mk,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=cT(e),r=gO(e),i=e=>t(bO.tenantScoped(e)),a=z(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:ik({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,query:t.query,...rk(t.tags)})}).pipe(i(e))}),o=nk(a),s=z(`SessionsApi.exportSessionStorageState`)(function*(e,t,n){return yield*r.exportSessionStorageState(t,{payload:n}).pipe(i(e))}),c=z(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),l=z(`SessionsApi.getSessionsBulk`)(function*(e,t){return{sessions:(yield*af(oa(t,Tk),t=>r.getSessionsBulk({payload:{ids:t}}).pipe(i(e)))).flatMap(e=>e.sessions)}}),u=z(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:ik({waitForReady:n.waitForReady}),payload:BS(ND)({baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{},...t.proxy===void 0?{}:{proxy:t.proxy}})}).pipe(i(e))}),d=z(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),f=z(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),p=z(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),m=z(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),h=z(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),g=z(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),_=z(`SessionsApi.updateSessionProxy`)(function*(e,t,n){return yield*r.updateSessionProxy(t,{payload:BS(zD)(n)}).pipe(i(e))}),v=z(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),y=z(`SessionsApi.getSessionCursor`)(function*(e,t){return yield*r.getSessionCursor(t,void 0).pipe(i(e))}),b=z(`SessionsApi.setSessionCursor`)(function*(e,t,n){return yield*r.setSessionCursor(t,{payload:{visible:n}}).pipe(i(e))}),x=z(`SessionsApi.listSessionRecordings`)(function*(e,t){return yield*r.listSessionRecordings(t,void 0).pipe(i(e))}),ee=z(`SessionsApi.createSessionRecording`)(function*(e,t,n){return yield*r.createSessionRecording(t,{payload:n}).pipe(i(e))}),S=z(`SessionsApi.getSessionRecording`)(function*(e,t,n){return yield*r.getSessionRecording(t,n,void 0).pipe(i(e))}),C=z(`SessionsApi.retargetSessionRecording`)(function*(e,t,n,a){return yield*r.retargetSessionRecording(t,n,{payload:{targetId:a}}).pipe(i(e))}),te=z(`SessionsApi.stopSessionRecording`)(function*(e,t,n){return yield*r.stopSessionRecording(t,n,void 0).pipe(i(e))}),ne=z(`SessionsApi.listSessionFiles`)(function*(e,t){return yield*r.listSessionFiles(t,void 0).pipe(i(e))}),w=z(`SessionsApi.createSessionFileDownloadURL`)(function*(e,t,n){return yield*r.createSessionFileDownloadURL(t,{payload:n}).pipe(i(e))}),T=z(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),re=z(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(L(Qw(dk)),t({credentials:e,bearerToken:i,tenantHeader:`tenant-scoped`}))}),ie=z(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(wk(r,i)).pipe(L(e=>R(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:Ck(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))}),ae=z(`SessionsApi.getSessionThumbnail`)(function*(e,r,i){let a=`/api/sessions/${encodeURIComponent(r)}`,o=i===void 0?`${a}/thumbnail`:`${a}/targets/${encodeURIComponent(i)}/thumbnail`;return yield*n.get(o).pipe(L(e=>R(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),t({credentials:e,tenantHeader:`tenant-scoped`}))}),oe=(e,r,i,a)=>n.get(wk(r,i)).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}),R(e=>e.stream.pipe(_g(`HttpClientError`,e=>Zh(qO(I(e)))))),lg),se=z(`SessionsApi.uploadSessionFiles`)(function*(e,t,r,a={}){let o=yield*Sk(r);return(yield*n.post(`/api/sessions/${encodeURIComponent(t)}/files`,{body:o,urlParams:ik({directory:a.directory})}).pipe(L(Qw(nO)),i(e))).files}),ce=z(`SessionsApi.deleteSessionFile`)(function*(e,t,n,a={}){yield*r.deleteSessionFile(t,{params:ik({relativePath:n,recursive:a.recursive})}).pipe(i(e))}),le=z(`SessionsApi.createSessionDirectory`)(function*(e,t,n){return yield*r.createSessionDirectory(t,{payload:{relativePath:n}}).pipe(i(e))}),E=z(`SessionsApi.moveSessionFile`)(function*(e,t,n){return yield*r.moveSessionFile(t,{payload:n}).pipe(i(e))}),ue=z(`SessionsApi.uploadLiveSessionFiles`)(function*(e,r,i,a){let o=yield*Sk(i);return(yield*n.post(`/sessions/${encodeURIComponent(r)}/uploads`,{body:o}).pipe(L(Qw(mO)),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))).files}),de=z(`SessionsApi.setSessionViewport`)(function*(e,n,i,a){return yield*r.setSessionViewport(n,{payload:i}).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return mk.of({listSessions:a,streamSessions:o.stream,listAllSessions:o.listAll,getSession:c,exportSessionStorageState:s,getSessionsBulk:l,createSession:u,deleteSession:d,reopenSession:f,suspendSession:p,rotateSessionToken:m,rotateCollaborationCapability:h,replaceSessionTags:g,updateSessionProxy:_,promoteSession:v,getSessionCursor:y,setSessionCursor:b,listSessionRecordings:x,createSessionRecording:ee,getSessionRecording:S,retargetSessionRecording:C,stopSessionRecording:te,listSessionFiles:ne,createSessionFileDownloadURL:w,getBrowserChannels:T,getBrowserStatus:re,downloadSessionRecording:ie,getSessionThumbnail:ae,streamSessionRecording:oe,uploadSessionFiles:se,uploadLiveSessionFiles:ue,deleteSessionFile:ce,moveSessionFile:E,createSessionDirectory:le,setSessionViewport:de})})),Dk=class extends _r()(`@aperture-browser/api-client/SnapshotsApi`){},Ok=ld(Dk,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=e=>t(bO.tenantScoped(e)),i=z(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:ik({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...rk(t.tags)})}).pipe(r(e))}),a=nk(i),o=z(`SnapshotsApi.getSnapshotByName`)(function*(e,t){return yield*a.stream(e,{name:t,limit:100}).pipe(hg(e=>e.name===t),bg)}),s=z(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),c=z(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),l=z(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),u=z(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return Dk.of({listSnapshots:i,streamSnapshots:a.stream,listAllSnapshots:a.listAll,getSnapshotByName:o,updateSnapshot:s,replaceSnapshotTags:c,deleteSnapshot:l,restoreSnapshot:u})})),kk=class extends _r()(`@aperture-browser/api-client/TenantsApi`){},Ak=ld(kk,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=z(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:ik({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted,query:r.query})}).pipe(t(bO.of(e)))}),i=nk(r),a=z(`TenantsApi.getCurrentTenant`)(function*(e){return yield*n.getTenant(void 0).pipe(t(bO.of(e)))}),o=z(`TenantsApi.updateCurrentTenant`)(function*(e,r){return yield*n.updateSelectedTenant({payload:r}).pipe(t(bO.of(e)))}),s=z(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t(bO.of(e)))}),c=z(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t(bO.of(e)))}),l=z(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t(bO.of(e)))}),u=z(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t(bO.of(e)))});return kk.of({listTenants:r,streamTenants:i.stream,listAllTenants:i.listAll,createTenant:s,updateTenant:c,deleteTenant:l,restoreTenant:u,getCurrentTenant:a,updateCurrentTenant:o})})),jk=class extends _r()(`@aperture-browser/api-client/TokensApi`){},Mk=ld(jk,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=z(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:ik({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t(bO.of(e)))}),i=nk(r),a=z(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(bO.of(e)))}),o=z(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t(bO.of(e)))}),s=z(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:ik({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t(bO.of(e)))}),c=nk(s),l=z(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(bO.of(e)))}),u=z(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t(bO.of(e)))});return jk.of({listAdminTokens:r,streamAdminTokens:i.stream,listAllAdminTokens:i.listAll,createAdminToken:a,revokeAdminToken:o,listTenantTokens:s,streamTenantTokens:c.stream,listAllTenantTokens:c.listAll,createTenantToken:l,revokeTenantToken:u})})),Nk=class extends _r()(`@aperture-browser/api-client/UsersApi`){},Pk=pd(UO,Ak,ld(Nk,pf(function*(){let e=yield*oT,{authorize:t}=yield*xO,n=gO(e),r=z(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:ik({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t(bO.of(e)))}),i=nk(r),a=z(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t(bO.of(e)))}),o=z(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t(bO.of(e)))}),s=z(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t(bO.of(e)))}),c=z(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t(bO.of(e)))}),l=z(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t(bO.of(e)))}),u=z(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t(bO.of(e)))}),d=z(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t(bO.of(e)))}),f=z(`UsersApi.listTenantMemberships`)(function*(e,r){return yield*n.listTenantMemberships(r,void 0).pipe(t(bO.of(e)))}),p=z(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t(bO.of(e)))}),m=z(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t(bO.of(e)))});return Nk.of({listUsers:r,streamUsers:i.stream,listAllUsers:i.listAll,createUser:a,getUser:o,updateUser:s,createUserInvitation:c,disableUser:l,restoreUser:u,listUserMemberships:d,listTenantMemberships:f,upsertTenantMembership:p,deleteTenantMembership:m})})),Ek,Ok,Mk,ak,ok).pipe(hd(ZO),gd(QO)),Fk=e=>ld(oT,R(oT,fT(Uw(e)))),Ik=`aperture-session.v1`,Lk={onExcessProperty:`error`},Rk=U.check(Y()),zk=U.check(bC(0)),Bk=Rk.check(bC(0)),Vk=U.check(SC({minimum:0,maximum:1})),Hk=P([]);function Uk(e){return K(e).pipe(sC(Hk))}var Wk=q([`implicit`,`explicit`]),Gk=G({profile:H,fps:Rk.check(SC({minimum:1,maximum:120})),bitrateKbps:Rk.check(J(100)),keyframeInterval:Bk}),Kk=G({id:H,label:H,codec:H,mimeType:H,sdpFmtpLine:H}),qk=G({quality:B(Gk),profiles:K(Kk),cursorVisible:W}),Jk=G({id:H,type:H,title:H,url:H,loading:W,canGoBack:B(W),canGoForward:B(W),viewport:B(G({width:zk,height:zk,contentWidth:zk,contentHeight:zk,canvasWidth:zk,canvasHeight:zk,deviceScaleFactor:zk}))}),Yk=G({clientId:H,name:H,avatarHash:H,role:q([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:B(H),followingClientId:B(H),holdingInput:W,leaseMode:B(Wk),recovering:B(W)}),Xk=LS(FC(eC([G({type:V(`session.snapshot`),clientId:H,resumeSecret:H,role:q([`owner`,`editor`,`viewer`]),transport:q([`webrtc`,`websocket`]),holderClientId:B(H),mode:B(Wk),activeTargetId:B(H),targets:Uk(Jk),participants:Uk(Yk),recordings:Uk(pk),presentation:qk,viewportOwnerClientId:B(H),autoSize:B(W)}),G({type:V(`presence.state`),participants:Uk(Yk)}),G({type:V(`input.state`),holderClientId:B(H),mode:B(Wk)}),G({type:V(`viewport.state`),viewportOwnerClientId:B(H),autoSize:W}),G({type:V(`presence.cursor`),clientId:H,targetId:H,x:Vk,y:Vk,realtimeCounter:Bk}),G({type:V(`presence.cursor.clear`),clientId:H,realtimeCounter:Bk}),G({type:V(`paint.point`),clientId:H,targetId:H,strokeId:H,color:H.check(pC(/^#[0-9a-fA-F]{6}$/)),width:U.check(SC({minimum:1,maximum:16})),phase:q([`start`,`move`,`end`]),x:Vk,y:Vk,realtimeCounter:B(Bk)}),G({type:V(`targets.state`),activeTargetId:B(H),targets:Uk(Jk)}),G({type:V(`recordings.state`),recordings:Uk(pk)}),G({type:V(`presentation.state`),presentation:qk}),G({type:V(`error`),code:H,message:H}),G({type:q([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`viewport.auto-size.set.result`,`viewport.owner.claim.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`automation.pacing.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:H,ok:W,code:B(H),message:B(H),targetId:B(H),recording:B(pk),presentation:B(qk)})])),Lk),Zk=G({type:V(`presentation.frame`),targetId:H,width:zk,height:zk}),Qk=[tA(1280,720,1),tA(1440,900,1),tA(1920,1080,1),tA(2560,1440,1),tA(768,1024,1),tA(390,844,1)],$k=Qk[0],eA=[1,1.5,2,3];function tA(e,t,n){return{id:`${e}x${t}@${nA(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function nA(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function rA(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var iA=`~effect/FiberSet`,aA=e=>D(e,iA),oA={[iA]:iA,[Symbol.iterator](){return this.state._tag===`Closed`?Hi():this.state.backing[Symbol.iterator]()},...It,toJSON(){return{_id:`FiberSet`,state:this.state}}},sA=(e,t)=>{let n=Object.create(oA);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},cA=()=>qf(F(()=>sA(new Set,Nu())),e=>lf(()=>{let t=e.state;if(t._tag===`Closed`)return uf;e.state={_tag:`Closed`};let n=t.backing;return jp(n).pipe(zu(e.deferred))})),lA=()=>L(cA(),e=>mA(e)()),uA=-1,dA=pa(ha(Td,ma(uA))),fA=b(e=>aA(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(uA);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Au(r)&&(n?.propagateInterruption===!0?!dA(r.cause):!bd(r.cause))&&Ru(e.deferred,r))})}),pA=function(){let e;return()=>(e===void 0&&(e=up(ep)),e)}(),mA=e=>()=>R(Vf(),t=>{let n=dp(t);return(t,r)=>{if(e.state._tag===`Closed`)return pA();let i=n(t,r);return fA(e,i,r),i}}),hA=Yr(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),gA=class extends _r()(`effect/http/FetchHttpClient/RequestInit`){},_A=vT(P(dT((e,t,n,r)=>{let i=r.getRef(hA),a=Br(r.context,gA)??{},o=a.headers?A_(E_(a.headers),e.headers):e.headers;o[`content-length`]&&(o=j_(o,`content-length`));let s=r=>R(cf({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new dw({reason:new mw({request:e,cause:t})})}),t=>tT(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return L(wg(e.body.stream),s)}return s(void 0)})));function vA(e,t){let n=new URL(e.baseUrl??`/`,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`session base URL must use HTTP or HTTPS`);if(e.kind===`relay`&&n.origin!==window.location.origin)throw Error(`session relay must use the page's origin`);return n.pathname=`${n.pathname.replace(/\/$/,``)}/${t}`,n.search=``,n.hash=``,n}function yA(e,t){return vA(e,`sessions/${encodeURIComponent(e.sessionId)}/${t}`)}function bA(e,t){let n=yA(e,t);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function xA(e){if(e.kind!==`direct`)return{token:void 0,tenantId:void 0};let{credentials:t}=e;return{token:t.kind===`bearer`?y_(t.token):void 0,tenantId:yO(t,`tenant-scoped`)}}function SA(e){let{token:t,tenantId:n}=xA(e),r=[Ik];return t!==void 0&&r.push(`authorization.bearer.${t}`),n!==void 0&&r.push(`x-aperture-tenant-id.${n}`),r}function CA(e,t){let{token:n,tenantId:r}=xA(e),i={};return n!==void 0&&(i.Authorization=`Bearer ${n}`),r!==void 0&&(i[`X-Aperture-Tenant-Id`]=r),L(oT,e=>cT(e).get(t.toString(),{headers:i})).pipe(Gf(gA,{credentials:n===void 0?`same-origin`:`omit`,redirect:`error`,cache:`no-store`}))}var wA=z(`getSessionStatus`)(function*(e){return yield*CA(e,yA(e,`browser/status`)).pipe(L(Qw(dk)),qO)}),TA=z(`downloadSessionRecording`)(function*(e,t){return yield*CA(e,yA(e,`recordings/${encodeURIComponent(t)}/content`)).pipe(L(e=>R(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:Ck(e.headers[`content-disposition`])}))),qO)}),EA=z(`getTargetThumbnail`)(function*(e,t){let n=`targets/${encodeURIComponent(t)}/thumbnail`,r=xA(e).token;return yield*CA(e,e.kind===`relay`||r!==void 0&&(r.startsWith(`aps_`)||r.startsWith(`ape_`)||r.startsWith(`apv_`))?yA(e,n):vA(e,`api/sessions/${encodeURIComponent(e.sessionId)}/${n}`)).pipe(L(e=>R(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),qO)}),DA=class extends Ta(`LiveSessionError`){},OA=LS(FC(eC([G({version:V(1),type:V(`answer`),sdp:H}),G({version:V(1),type:V(`ice-candidate`),candidate:G({candidate:H,sdpMid:B(tC(H)),sdpMLineIndex:B(tC(U.check(Y()))),usernameFragment:B(tC(H))})}),G({version:V(1),type:V(`error`),error:G({code:H,message:H})})])),Lk),kA=LS(FC(Zk),Lk),AA=5e3,jA=500,MA=15e3,NA=Sp(function*(e){let{callbacks:t}=e,n=yield*lA(),r=e=>n(e),i=(e,t)=>r(If(e).pipe(xf(F(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=null,p=1e3,m=0,h=0,g=0,_=[],v=null,y=new Map,b={hello:()=>({type:`session.hello`,...s??e.identity,...e.autoSize===void 0?{}:{autoSize:e.autoSize()}}),message:(e,t)=>oe(e,t),ready:e=>re(e),failed:(e,t)=>ae(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(v=n)}},x=()=>{o?.close(),o=null,_=[],v=null},ee=()=>{f?.interruptUnsafe(),f=null},S=e=>{let t=new DA({message:e});for(let e of y.values())Ru(e,I(t));y.clear()},C=e=>{if(!l)return;let t=l;l=null,Ru(t.deferred,I(new DA({message:e})))},te=()=>{c===`webrtc`&&e.webrtcSupported?ne():w()},ne=()=>{if(u||d!==null||o)return;let t;try{t=new IA({access:e.access,iceServers:e.iceServers,callbacks:b,fork:r})}catch(e){le(`webrtc`,PA(e,`WebRTC setup failed`));return}o=t,_=[],v=null,t.connect(),i(AA,()=>{o===t&&(x(),le(`webrtc`,new DA({message:`WebRTC presentation timed out`})))})},w=()=>{if(u||d!==null||o)return;let t;try{t=new FA({access:e.access,callbacks:b,fork:r})}catch(e){le(`websocket`,PA(e,`WebSocket setup failed`));return}o=t,_=[],v=null,t.connect()},T=e=>i(e,()=>{!u&&a===null&&o===null&&w()}),re=n=>{if(u||o!==n){n.close();return}let r=a,i=_,s=v;if(r&&r!==n&&S(`live session transport replaced`),o=null,_=[],v=null,a=n,h=0,g=0,p=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,Ru(e.deferred,uf)}n instanceof IA?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)se(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&ce(),r&&r!==n&&r.close()},ie=e=>{ee(),x(),a?.close(),a=null,C(e),S(e),t.onFrame(null),t.onStream(null),t.onTransport(null)},ae=(e,n)=>{if(!u){if(n.terminalReason!==void 0&&(o===e||a===e)){d=n,ie(n.message),t.onPhase(`error`),t.onError(n.message);return}if(o===e){x(),le(e.kind,n);return}a===e&&(a=null,e.close(),S(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),T(e.kind===`webrtc`?0:jA))}},oe=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;_.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&re(e);return}se(t)},se=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=g)return;g=e.realtimeCounter}if(`requestId`in e){let t=y.get(e.requestId);t&&(y.delete(e.requestId),Ru(t,e.ok?P(e):I(new DA({message:e.message??`live session command failed`}))))}t.onMessage(e)},ce=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||f!==null)return;let t=p;p=Math.min(MA,p*2),f=i(t,()=>{f=null,ne()})},le=(e,n)=>{if(l?.kind===e&&(C(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&ce();return}if(e===`webrtc`){w();return}t.onPhase(`disconnected`),t.onError(n.message),T(jA)},E=e=>a?.sendReliable(e)??!1,ue=e=>(h+=1,a?.sendRealtime({realtimeCounter:h,...e})??!1),de=()=>{u=!0,ie(`live session connection closed`)};return yield*Yf(()=>F(de)),t.onPhase(`connecting`),te(),{reconnect:F(()=>{d=null,ee(),x(),a?.close(),a=null,C(`live session transport replaced`),S(`live session transport replaced`),t.onPhase(`connecting`),w()}),selectTransport:t=>lf(()=>{if(d!==null)return I(d);if(t===`webrtc`&&!e.webrtcSupported)return I(new DA({message:`WebRTC presentation is unavailable`}));if(c=t,ee(),o&&o.kind!==t&&x(),C(`presentation selection was replaced`),a?.kind===t)return uf;let n=Nu();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?ne():w()),Pu(n)}),sendReliable:E,sendRealtime:ue,command:(e,t={})=>lf(()=>{m+=1;let n=`request-${m}`,r=Nu();return y.set(n,r),E({type:e,requestId:n,...t})?Pu(r).pipe(tp(()=>F(()=>y.delete(n)))):(y.delete(n),I(new DA({message:`live session transport is unavailable`})))})}});function PA(e,t){return new DA({message:e instanceof Error&&e.message?e.message:t})}var FA=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(bA(e.access,`session`),SA(e.access)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=Xk(e.data);lr(t)&&this.callbacks.message(this,t.value);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,e=>{this.closed||this.callbacks.failed(this,LA(`WebSocket session transport closed`,e.code))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new DA({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return pf({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*RA(e);lr(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},IA=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({urls:[...e.urls],username:e.username,credential:e.credential===void 0?void 0:y_(e.credential)}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(bA(e.access,`webrtc/signal`),SA(e.access))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Of(`LiveSessionError`,e=>F(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,e=>this.fail(`WebRTC signaling closed`,e.code)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=Xk(e.data);if(cr(t)){this.fail(`WebRTC session message is invalid`);return}this.callbacks.message(this,t.value),t.value.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?OA(e.data):or();if(cr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(cf(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(xf(lf(()=>af(this.pendingCandidates.splice(0),e=>cf(()=>this.connection.addIceCandidate(e)),{discard:!0}))),Df(()=>F(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(cf(()=>this.connection.addIceCandidate(n.candidate)).pipe(Df(()=>F(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return pf({self:this},function*(){let e=e=>PA(e,`WebRTC negotiation failed`),t=yield*cf({try:()=>this.connection.createOffer(),catch:e});yield*cf({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new DA({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e,t=0){this.closed||this.callbacks.failed(this,LA(e,t))}};function LA(e,t){return t===4401||t===4403?new DA({message:`Session access denied. Sign in or request access before reconnecting.`,terminalReason:`access_denied`}):t===4404||t===4410?new DA({message:`Session is no longer available.`,terminalReason:`session_unavailable`}):new DA({message:e})}function RA(e){return pf(function*(){if(e.size<4)return or();let t=yield*cf(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?or():mr(kA(yield*cf(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(Pf(()=>or()))}var $=c(f(),1),zA=`~effect/SubscriptionRef`,BA={...It,[zA]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},VA=e=>R(em({replay:1}),t=>{let n=Object.create(BA);return n.semaphore=$m(1),n.value=e,n.pubsub=t,rm(n.pubsub,e),n}),HA=e=>og(e.pubsub),UA=(e,t)=>{e.value=t,rm(e.pubsub,t)},WA=b(2,(e,t)=>e.semaphore.withPermit(F(()=>UA(e,t)))),GA=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),KA=o(((e,t)=>{t.exports=GA()})),qA=KA(),JA=(0,$.createContext)(null),YA=class extends Ta(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function XA({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,qA.jsx)(JA.Provider,{value:r,children:n})}function ZA(){let e=(0,$.useContext)(JA);if(!e)throw new YA;return e}function QA(){return ZA().runtime}function $A(e,t){let n=QA();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function ej(e,t){let n=QA(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var tj=2e3,nj=()=>new DA({message:`live session transport is unavailable`}),rj=40,ij=7e3,aj={left:272,right:273,middle:274};function oj({access:e,displayName:t=null,enabled:n,webrtcSupported:r,iceServers:i,autoSize:a}){let o=(0,$.useMemo)(()=>cj(t),[t]),[s,c]=(0,$.useState)(`viewer`),l=QA(),u=(0,$.useMemo)(()=>l.runSync(VA(null)),[l]),d=(0,$.useMemo)(()=>l.runSync(em()),[l]),f=(0,$.useMemo)(()=>HA(u),[u]),p=(0,$.useMemo)(()=>og(d),[d]),m=(0,$.useCallback)(e=>l.runSync(WA(u,e)),[u,l]),h=(0,$.useCallback)(e=>rm(d,e),[d]),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(``),y=(0,$.useRef)(!1),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(0),S=(0,$.useRef)([]),C=(0,$.useRef)(null),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),w=(0,$.useRef)(null),T=(0,$.useRef)(!1),[re,ie]=(0,$.useState)(`idle`),[ae,oe]=(0,$.useState)([]),[se,ce]=(0,$.useState)(null),[le,E]=(0,$.useState)(null),[ue,de]=(0,$.useState)(null),[fe,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(!1),[ge,_e]=(0,$.useState)(!1),[D,ve]=(0,$.useState)(null),[ye,be]=(0,$.useState)([]),[O,xe]=(0,$.useState)(null),[Se,Ce]=(0,$.useState)(``),[we,Te]=(0,$.useState)(null),[Ee,De]=(0,$.useState)(null),[Oe,ke]=(0,$.useState)([]),[Ae,je]=(0,$.useState)(()=>new Map),[Me,Ne]=(0,$.useState)(null);te.current=ue,ne.current=fe,w.current=D;let Pe=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:c(e.role),v.current=e.clientId,Ce(e.clientId),_.current=e.holderClientId??null,Te(e.holderClientId??null),De(e.mode??null),S.current=e.participants,ke(e.participants),C.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,oe(e.targets),ce(e.activeTargetId??null),de(dj(e.targets,e.activeTargetId)),be(e.recordings),ve(e.presentation??null),xe(e.autoSize===void 0?null:{ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize}),Ne(null);return;case`targets.state`:oe(e.targets),ce(e.activeTargetId??null),de(dj(e.targets,e.activeTargetId)),he(!1);return;case`presence.state`:S.current=e.participants,ke(e.participants),C.current=e.participants.find(e=>e.clientId===v.current)?.followingClientId??null,je(e=>{let t=C.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:_.current=e.holderClientId??null,Te(e.holderClientId??null),De(e.mode??null),y.current=!1,b.current=!1,Ne(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`viewport.state`:xe({ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize});return;case`presence.cursor`:if(e.clientId!==C.current)return;je(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:je(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:S.current.some(t=>t.clientId===e.clientId)&&h({type:`point`,message:e});return;case`recordings.state`:be(e.recordings);return;case`presentation.state`:ve(e.presentation);return;case`error`:y.current=!1,b.current=!1,Ne({code:e.code,message:e.message});return;default:e.presentation&&ve(e.presentation),e.ok||Ne({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[h]);$A(()=>{if(!n||e===null){g.current=null,ie(`idle`),c(`viewer`),oe([]),ce(null),E(null),de(null),pe(null),ve(null),he(!1),_e(!1),ke([]),je(new Map),be([]),xe(null),m(null),h({type:`clear`});return}return c(`viewer`),pf(function*(){let t=yield*NA({access:e,identity:o,autoSize:a,iceServers:i,webrtcSupported:r,callbacks:{onPhase:ie,onMessage:Pe,onFrame:m,onStream:E,onTransport:pe,onError:e=>Ne({code:`connection_failed`,message:e})}});return g.current=t,yield*Yf(()=>F(()=>{g.current===t&&(g.current=null)})),yield*ff}).pipe(Kf,Xf(F(()=>{m(null),h({type:`clear`})})))},[a,e,n,Pe,i,o,m,h,r]);let Fe=(0,$.useCallback)(e=>g.current?.sendReliable(e)??!1,[]),Ie=(0,$.useCallback)(e=>g.current?.sendRealtime(e)??!1,[]),Le=ej((e,t,n)=>e.command(t,n).pipe(Df(e=>F(()=>{he(!1),Ne({code:`request_rejected`,message:e.message})}))),[]),Re=(0,$.useCallback)((e,t={})=>{let n=g.current;return n?(Le(n,e,t),!0):!1},[Le]),ze=(0,$.useCallback)((e,t={})=>lf(()=>g.current?g.current.command(e,t):I(nj())),[]),Be=ej((e,t)=>e.command(`target.select`,{targetId:t}).pipe(zf({onSuccess:()=>ce(t),onFailure:e=>Ne({code:`request_rejected`,message:e.message})}),Xf(F(()=>he(!1)))),[]),Ve=(0,$.useCallback)(e=>lf(()=>{let t=g.current;return t?(he(!0),t.command(`target.select`,{targetId:e}).pipe(Sf(()=>F(()=>ce(e))),Mf(e=>F(()=>Ne({code:`request_rejected`,message:e.message}))),Xf(F(()=>he(!1))),Ef)):I(nj())}),[]),He=(0,$.useCallback)(e=>{let t=g.current;return t?(he(!0),Be(t,e),!0):!1},[Be]),Ue=(0,$.useCallback)(e=>lf(()=>{let t=g.current;return t?T.current?I(new DA({message:`another presentation update is already in progress`})):(T.current=!0,_e(!0),pf(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=te.current;if(!n)return yield*new DA({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&ne.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Mf(()=>r?Nf(t.selectTransport(`webrtc`)):uf));return i.presentation&&ve(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Mf(e=>F(()=>Ne({code:`presentation_update_failed`,message:e.message}))),Xf(F(()=>{T.current=!1,_e(!1)})))):I(nj())}),[]),We=(0,$.useCallback)((e,t)=>s===`viewer`||!Fe({type:`input.claim`,targetId:e,mode:t})?!1:(y.current=!0,b.current=!1,!0),[s,Fe]),Ge=(0,$.useCallback)(()=>b.current||_.current!==v.current||!Fe({type:`input.release`})?!1:(b.current=!0,y.current=!1,!0),[Fe]),Ke=(0,$.useCallback)(e=>e?He(e):!1,[He]),qe=(0,$.useCallback)(e=>Fe({type:`follow.set`,followingClientId:e??``}),[Fe]),Je=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-ee.current<rj)return!1;ee.current=i;let a=Ie({type:`presence.cursor`,targetId:e,x:fj(t,r.width),y:fj(n,r.height)});return a&&(x.current=!0),a},[Ie]),Ye=(0,$.useCallback)(e=>e.phase===`move`?Ie({type:`paint.point`,...e}):Fe({type:`paint.point`,...e}),[Ie,Fe]),Xe=(0,$.useCallback)(()=>!x.current||!Fe({type:`presence.cursor.clear`})?!1:(x.current=!1,!0),[Fe]),Ze=(0,$.useCallback)((e,t=!1)=>t?Ie(e):Fe(e),[Ie,Fe]),Qe=(0,$.useCallback)((e,t)=>{if(s===`viewer`||_.current!==v.current&&!y.current)return!1;switch(e.type){case`input.mouse`:{let n=fj(e.x,t.width),r=fj(e.y,t.height);if(e.action===`move`)return Ze({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=aj[e.button??`left`],a=(a,o)=>Ze({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=fj(e.x,t.width),r=fj(e.y,t.height);return Ze({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Ze({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Ze({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=Tg[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??Ng(e.code,e.key);return Ze({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return pj(Ze,e.targetId,`KeyC`);case`clipboard.cut`:return pj(Ze,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Ze({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[s,Ze]),$e=we===Se&&Se!==``,et=Oe.find(e=>e.clientId===Se)?.followingClientId??null;return $A(()=>$e?If(tj).pipe(xf(F(()=>{_.current===v.current&&Fe({type:`input.heartbeat`})})),ip):void 0,[$e,Fe]),{phase:re,targets:ae,activeTargetId:se,frames:f,mediaStream:le,mediaSize:ue,transport:fe,presentation:D,mediaSwitching:me||ge,recordings:ye,viewportOwnership:O,sendBrowserInput:Qe,selectTarget:He,requestSelectTarget:Ve,command:Re,request:ze,selectPresentation:Ue,reconnect:()=>{let e=g.current;e&&l.runSync(e.reconnect)},collaboration:{phase:re===`error`?`disconnected`:re,role:s,clientId:Se,holderClientId:we,leaseMode:Ee,hasControl:$e,canRequestControl:s!==`viewer`&&re===`connected`,lastError:Me,participants:Oe,cursors:Ae,paintEvents:p,followingClientId:et,claim:We,release:Ge,setActiveTarget:Ke,follow:qe,sendCursor:Je,sendPaintPoint:Ye,clearCursor:Xe,sendInput:Qe}}}var sj=LS(FC(G({name:H.check(CC(1),TC(48)),avatarHash:H.check(pC(/^[0-9a-f]{32}$/))})),Lk);function cj(e){let t=lj();return e?.trim()?{...t,name:Array.from(e.trim()).slice(0,48).join(``)}:t}function lj(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=sj(t);if(lr(e))return e.value}let n=uj();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return uj()}}function uj(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function dj(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function fj(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function pj(e,t,n){let r=Tg.ControlLeft,i=Tg[n];if(!r||!i)return!1;let a=Ng(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=Ng(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var mj=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],hj=4,gj=24,_j=2048,vj=512;function yj({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=Sj(e.clientId);$A(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/ij:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>_j&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=vj){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),xg(e.paintEvents,e=>F(()=>m(e))).pipe(Xf(F(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=bj(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:hj,phase:r,x:a.x,y:a.y})}function h(n){if(xj(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=bj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(xj(n),u.current!==null&&n.pointerId!==u.current)return;let r=bj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<gj)&&(d.current=performance.now(),m(n,`move`))}function _(e){xj(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,qA.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:xj,onContextMenu:xj})}function bj(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function xj(e){e.preventDefault(),e.stopPropagation()}function Sj(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return mj[t%mj.length]??`#f43f5e`}var Cj=500,wj=5;function Tj({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),w=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,T=w&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),re=r&&(w||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!T,ie=r||e.mediaSwitching||T||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,ae=T&&te?te.size:e.mediaSize,oe=w?ae?.width??t.width:S?.width??t.width,se=w?ae?.height??t.height:S?.height??t.height,ce=w?oe:t.width,le=w?se:t.height,E=w?Math.min(ae?.canvasWidth??oe,Math.round(oe*(ae?.deviceScaleFactor??1))):oe,ue=w?Math.min(ae?.canvasHeight??se,Math.round(se*(ae?.deviceScaleFactor??1))):se,de=rA(e.browserViewportSize?.width??oe,e.browserViewportSize?.height??se,oe,se),fe=Ej(e.phase),pe=Dj(e.collaboration),me=fe??pe,he=me?y.current??x:null,ge=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,_e=ge?e.collaboration.cursors.get(ge.clientId):null,D=_e?.targetId===e.activeTargetId?{x:de.offsetX+_e.x*de.renderedWidth,y:de.offsetY+_e.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:ce,height:le})},[e.setInputDimensions,le,ce]);let ve=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);$A(()=>{let t=t=>{if(!t){u.current?Mj(u.current,f.current):Nj(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!w?kj(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return xg(e.frames,e=>F(()=>t(e))).pipe(Xf(F(()=>{u.current?Mj(u.current,f.current):Nj(f.current)})))},[e.activeTargetId,e.frames,w]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?Mj(i,t):Nj(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&Aj(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;w||!e||Aj(e,f.current)},[S,w]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=w?e.mediaStream:null)},[e.mediaStream,w]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!w||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,w]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),ve()},[ve]),(0,$.useEffect)(()=>{let e=()=>{ve(),xe()},t=()=>{document.visibilityState===`hidden`&&(ve(),xe())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[ve,e.collaboration]),(0,$.useEffect)(()=>{ie&&(_.current?.(),ve(),xe())},[ie,ve]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function ye(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=rA(n.width,n.height,oe,se),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(ce/oe),s=a/r.scale*(le/se);return t?{x:Math.round(zj(o,0,Math.max(ce-1,0))),y:Math.round(zj(s,0,Math.max(le-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function be(){return e.phase!==`connected`||!e.activeTargetId||ie?null:(e.captured||e.setCaptured(!0),O(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function O(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function xe(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function Se(e){e.preventDefault(),e.stopPropagation()}function Ce(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function we(){e.phase!==`connected`||ie||(e.setCaptured(!0),e.activeTargetId&&O(e.activeTargetId),l.current?.focus())}function Te(t){Le(t),!(ie||!e.activeTargetId)&&(e.setCaptured(!0),O(e.activeTargetId))}function Ee(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(ve(),xe(),e.setCaptured(!1))}function De(){e.captured||we()}function Oe(t){Le(t);let n=ye(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:ce,height:le}):n||e.collaboration.clearCursor(),ie||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(Se(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:kg(t.nativeEvent)}))}function ke(t){Le(t);let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=Ij(t.button),o=Date.now(),s=Lj(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},Se(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Me({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:kg(t.nativeEvent)})}function Ae(t){if(ie)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=ye(t,n?.pointerId===t.pointerId);i&&(Se(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??Ij(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:kg(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function je(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=ye(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ie)&&(Se(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:kg(t.nativeEvent)}))}function Me({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=ye(a,!0);Ce(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:ce,height:le}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||Rj(r),clickCount:i,modifiers:kg(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=ye(a,!0);ye(a,!1)||e.collaboration.clearCursor(),Ce(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:kg(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Ne(t){let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;Se(t);let i=Bj(t.deltaMode,le);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:kg(t.nativeEvent)})}function Pe(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),xe());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ie||!o||!e.captured&&Uj(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=Fj(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){Vj(e,a);return}if(!Mg(t.nativeEvent))return;let c=jg(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Fe(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ie&&(e.captured||Uj(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&Fj(t.nativeEvent))&&(!r&&!Mg(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...jg(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Ie(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(ve(),xe(),e.setCaptured(!1))}function Le(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let Re=Hj(e.phase,S!==null,e.mediaPhase,e.mediaPath,w),ze=Pj(e.phase,e.mediaPhase,e.mediaSwitching),Be=pe||Oj(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,qA.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Pe,onKeyUp:Fe,onBlur:Ie,onClick:De,onPointerMove:Oe,onFocus:()=>{!ie&&e.activeTargetId&&O(e.activeTargetId)},onPointerEnter:Te,onPointerLeave:Ee,onPointerDown:ke,onPointerUp:Ae,onPointerCancel:je,onWheel:Ne,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":T,"aria-disabled":ie,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[w?(0,qA.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:T?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,qA.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":oe,"data-viewport-height":se,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((ae?.canvasWidth??E)/E),height:de.renderedHeight*((ae?.canvasHeight??ue)/ue)}})}):S?(0,qA.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,qA.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,qA.jsx)(yj,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:re,visible:!e.mediaSwitching&&!T&&(w||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:Re,placeholder:w||S?null:ze,cursorHint:me&&he?{text:me,...he}:null,followedCursor:D&&ge?{name:ge.name,...D}:null,collaborationError:Be?.message??null})]})}function Ej(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function Dj(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function Oj(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function kj(e,t,n){t.pending=n,Aj(e,t)}function Aj(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,jj(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,Aj(e,t))})}async function jj(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function Mj(e,t){Nj(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function Nj(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function Pj(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function Fj(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function Ij(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function Lj(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=Cj&&Math.abs(i.point.x-n.x)<=wj&&Math.abs(i.point.y-n.y)<=wj?Math.min(i.clickCount+1,3):1}function Rj(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function zj(e,t,n){return Math.min(Math.max(e,t),n)}function Bj(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function Vj(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function Hj(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function Uj(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var Wj=[],Gj=`aperture.viewport.auto-size-default`;function Kj({access:e,displayName:t,enabled:n=!0,webrtcProducerSupported:r=!1,webrtcIceServers:i=Wj,onNotice:a}){let o=QA(),s=(0,$.useRef)(a);s.current=a;let c=(e,t)=>F(()=>s.current?.({level:e,message:t})),[l,u]=(0,$.useState)(Jj),[d,f]=(0,$.useState)(()=>l),p=(0,$.useRef)(d);p.current=d;let m=(0,$.useCallback)(()=>p.current,[]),h=oj({access:e,displayName:t,enabled:n&&e!==null,webrtcSupported:r,iceServers:i,autoSize:m}),g=h.collaboration.role,[_,v]=(0,$.useState)([]),y=(0,$.useMemo)(()=>qj(_,h.targets),[h.targets,_]),b=(0,$.useRef)(h.targets);b.current=h.targets;let x=(0,$.useRef)(h.phase);x.current=h.phase;let[ee,S]=(0,$.useState)($k),[C,te]=(0,$.useState)(null),[ne,w]=(0,$.useState)(!1),[T,re]=(0,$.useState)(!1),ie=g===`owner`||g===`editor`,ae=(0,$.useMemo)(()=>e===null?null:t=>EA(e,t),[e]),oe=(0,$.useRef)(null),se=(0,$.useRef)(ee),ce=(0,$.useRef)($k),le=(0,$.useRef)(null);oe.current=h.activeTargetId,se.current=ee,le.current=C,(0,$.useEffect)(()=>{h.phase!==`connected`&&w(!1)},[h.phase]),(0,$.useEffect)(()=>{if(!h.mediaSize)return;let e=se.current;e.width===h.mediaSize.width&&e.height===h.mediaSize.height&&e.deviceScaleFactor===h.mediaSize.deviceScaleFactor||S(Yj(h.mediaSize,h.mediaSize.deviceScaleFactor))},[h.mediaSize]);let E=(0,$.useCallback)(t=>!n||e===null?!1:h.sendBrowserInput(t,ce.current),[e,n,h]),ue=(0,$.useCallback)(e=>{h.selectTarget(e)},[h]),de=(0,$.useCallback)((e,t,n)=>{e!==t&&v(r=>{let i=qj(r,b.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),fe=(0,$.useCallback)(e=>o.runPromise(h.request(`target.create`,{url:e}).pipe(R(e=>e.targetId??null),Df(e=>c(`error`,Zj(e,`Tab could not be created`)).pipe(wf(null))))),[h,o]),pe=(0,$.useCallback)((e=`about:blank`)=>{fe(e)},[fe]),me=(0,$.useCallback)(e=>{fe(e.url||`about:blank`).then(t=>{t&&de(t,e.id,`after`)})},[fe,de]),he=(0,$.useCallback)(e=>{h.command(`target.close`,{targetId:e})},[h]),ge=(0,$.useCallback)(e=>{let t=oe.current;t&&h.command(`page.navigate`,{targetId:t,url:e})},[h]),_e=(0,$.useCallback)(e=>{h.command(`page.reload`,{targetId:e})},[h]),D=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.stop-loading`,{targetId:e})},[h]),ve=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-back`,{targetId:e})},[h]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-forward`,{targetId:e})},[h]),be=h.viewportOwnership,O=(0,$.useRef)(be);O.current=be;let xe=d&&(be===null||be.ownerClientId===h.collaboration.clientId),Se=(0,$.useRef)(xe);Se.current=xe,(0,$.useEffect)(()=>{be!==null&&(p.current=be.autoSize,f(be.autoSize))},[be]);let Ce=ej(e=>h.request(`viewport.set`,e).pipe(Nf),[h.request]),we=(0,$.useCallback)((e,t)=>{S(e);let n=oe.current;if(n===null)return;let r={targetId:n,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor};t&&O.current!==null?Ce({...r,autoSize:!0}):h.command(`viewport.set`,r)},[h.command,Ce]),Te=(0,$.useCallback)(e=>{p.current!==e&&(p.current=e,f(e),O.current!==null&&h.command(`viewport.auto-size.set`,{enabled:e}))},[h.command]);(0,$.useEffect)(()=>{let e=le.current;xe&&h.phase===`connected`&&h.activeTargetId!==null&&e!==null&&we(Yj(e,se.current.deviceScaleFactor),!0)},[we,h.activeTargetId,h.phase,xe]);let Ee=(0,$.useCallback)(e=>{Te(!1),we(e,!1)},[we,Te]),De=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=le.current;n?.width===t.width&&n.height===t.height||(le.current=t,te(t),Se.current&&we(Yj(t,se.current.deviceScaleFactor),!0))},[we]),Oe=(0,$.useCallback)(()=>{let e=le.current;e&&(Te(!1),we(Yj(e,se.current.deviceScaleFactor),!1))},[we,Te]),ke=(0,$.useCallback)(()=>{p.current=!0,f(!0),h.command(`viewport.owner.claim`)},[h.command]),Ae=(0,$.useCallback)(e=>{u(e);try{window.localStorage.setItem(Gj,String(e))}catch{}},[]),je=(e,t)=>e.pipe(Df(e=>c(`error`,Zj(e,t))),Xf(F(()=>re(!1)))),Me=ej((e,t)=>je(h.request(`recording.start`,{mode:e,targetId:t}),`Recording failed to start`),[h]),Ne=(0,$.useCallback)(e=>{let t=oe.current;!t||!ie||T||(re(!0),Me(e,t))},[ie,T,Me]),Pe=ej((e,t)=>je(h.request(`recording.stop`,{recordingId:t}).pipe(xf(TA(e,t)),L(({blob:n,filename:r})=>{let i=h.recordings.find(e=>e.recordingId===t);return Xj(n,r??`${e.sessionId}-${i?.targetId??`target`}-${t}.webm`)}),xf(c(`success`,`Recording saved`))),`Recording failed to stop`),[h]),Fe=(0,$.useCallback)(t=>{e===null||T||(re(!0),Pe(e,t))},[e,T,Pe]),Ie=ej(e=>je(h.request(`recording.cancel`,{recordingId:e}).pipe(xf(c(`success`,`Recording stopped`))),`Recording failed to stop`),[h]),Le=(0,$.useCallback)(e=>{T||(re(!0),Ie(e))},[T,Ie]),Re=ej(e=>h.request(`presentation.cursor.set`,{visible:e}).pipe(Df(e=>c(`error`,Zj(e,`Remote cursor could not be updated`)))),[h]),ze=(0,$.useCallback)(t=>{e!==null&&Re(t)},[e,Re]),[Be,Ve]=(0,$.useState)(!1),He=(0,$.useRef)(h.command);He.current=h.command,(0,$.useEffect)(()=>{h.phase===`connected`&&ie&&He.current(`automation.pacing.set`,{pacing:Be?`watchable`:`normal`})},[h.phase,ie,Be]);let Ue=ej(e=>h.selectPresentation(e).pipe(Df(e=>c(`error`,Zj(e,`Presentation could not be updated`)))),[h]),We=(0,$.useCallback)(t=>!n||e===null||h.mediaSwitching?!1:(Ue(t),!0),[e,n,h.mediaSwitching,Ue]),Ge=(0,$.useCallback)(e=>We({kind:`webrtc`,quality:e}),[We]),Ke=(0,$.useMemo)(()=>{let e=e=>lf(()=>x.current===`connected`?e:I(new DA({message:`the session is not connected`}))),t=(t,n)=>e(h.request(t,n)),n=(t,n={})=>e(lf(()=>{let e=oe.current;return e?h.request(t,{targetId:e,...n}):I(new DA({message:`no tab is active`}))})).pipe(Ef);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Ef):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(R(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Ef),activateTarget:t=>e(h.requestSelectTarget(t))}},[h.request,h.requestSelectTarget]),qe=(0,$.useMemo)(()=>y.find(e=>e.id===h.activeTargetId)??null,[h.activeTargetId,y]),Je=h.transport===`webrtc`?`webrtc-live`:`websocket-live`,Ye=h.phase===`connected`?`live`:h.phase===`connecting`?`connecting`:h.phase===`error`?`failed`:`idle`;return{phase:h.phase,targets:y,activeTargetId:h.activeTargetId,activeTarget:qe,frames:h.frames,mediaPhase:Ye,mediaStream:h.mediaStream,mediaStreamSettings:h.presentation?.quality??null,mediaVideoProfiles:h.presentation?.profiles??[],mediaSize:h.mediaSize,mediaPath:Je,mediaTargetId:h.activeTargetId,mediaSwitching:h.mediaSwitching,viewport:ee,browserViewportSize:C,viewportAutoSync:d,viewportAutoSizeActive:xe,viewportOwnership:be,viewportAutoSizeDefault:l,captured:ne,recordings:h.recordings,canRecord:ie,loadTargetThumbnail:ae,recordingBusy:T,remoteCursorEnabled:h.presentation?.cursorVisible??!0,watchableAutomation:Be,collaboration:h.collaboration,commands:Ke,setCaptured:w,setInputDimensions:e=>{ce.current=e},setViewport:Ee,setBrowserViewportSize:De,setViewportAutoSync:Te,setViewportToBrowserSize:Oe,setViewportAutoSizeDefault:Ae,takeOverViewport:ke,setWebRTCStreamSettings:Ge,selectMediaStream:We,sendInput:E,activateTarget:ue,reorderTargets:de,createTarget:pe,duplicateTarget:me,closeTarget:he,navigate:ge,reload:_e,stopLoading:D,historyBack:ve,historyForward:ye,startRecording:Ne,stopRecording:Fe,cancelRecording:Le,setRemoteCursorEnabled:ze,setWatchableAutomation:Ve,reconnect:h.reconnect}}function qj(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function Jj(){try{return window.localStorage.getItem(Gj)===`true`}catch{return!1}}function Yj(e,t){return tA(e.width,e.height,t)}var Xj=(e,t)=>Jf(F(()=>URL.createObjectURL(e)),e=>F(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>F(()=>URL.revokeObjectURL(e)).pipe(Ff(0)));function Zj(e,t){return e instanceof Error&&e.message?e.message:t}var Qj=`~effect/ManagedRuntime`,$j=(e,t)=>{let n=t?.memoMap??nd(),r=Vu(`sequential`),i=Gu(r,`sequential`),a={onFiberStart:Mp(Gu(r,`parallel`))},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=yf(t=>(s||=up(Sf(ad(e,n,i),e=>F(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),bf(Op(s)))),l={[Qj]:Qj,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?mp(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return mp(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:lf(()=>(l.contextEffect=gf(`ManagedRuntime disposed`),l.cachedContext=void 0,Ku(l.scope,Ou))),runFork(e,t){return l.cachedContext===void 0?up(eM(l,e),o(t)):dp(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?pp(eM(l,e),o(t)):fp(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?bp(eM(l,e)):xp(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?vp(eM(l,e)):yp(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?gp(eM(l,e),o(t)):_p(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?mp(eM(l,e),o(t)):hp(l.cachedContext)(e,o(t))}};return l};function eM(e,t){return L(e.contextEffect,e=>Uf(t,e))}var tM=(e={})=>$j(pd(_A,Pk.pipe(hd(e.baseUrl?Fk(e.baseUrl):cd),hd(_A)),od(gT,!1)));function nM({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=tM({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,qA.jsx)(XA,{runtime:n,baseUrl:e,children:t}):null}function rM(e,t){let n=e.slice(4,40);return!(e.startsWith(`ape_`)||e.startsWith(`apv_`))||e[40]!==`_`||e.length<=41?null:{kind:`direct`,baseUrl:t,sessionId:n,credentials:{kind:`bearer`,token:__(e),authorityType:null,tenantId:null,selectedTenantId:null}}}var iM=[];function aM(e){return e===401||e===403?`denied`:e===410?`expired`:`unavailable`}function oM({access:e,displayName:t,onNotice:n}){let[r,i]=(0,$.useState)({access:null,status:`loading`,browser:null});$A(()=>{if(e!==null)return i({access:e,status:`loading`,browser:null}),wA(e).pipe(zf({onFailure:t=>i({access:e,status:aM(t.status),browser:null}),onSuccess:t=>i(e.kind===`direct`&&t.sessionId!==e.sessionId?{access:e,status:`unavailable`,browser:null}:{access:e,status:`ready`,browser:t})}))},[e]);let a=r.access===e?r.browser:null,o=Kj({access:a===null?null:e,displayName:t,webrtcProducerSupported:a?.media.mode===`auto`&&a.media.webrtcProducer,webrtcIceServers:a?.media.iceServers??iM,onNotice:n});return{status:e===null?`invalid`:r.access===e?r.status:`loading`,browser:a,control:o}}function sM(){let e=null;return t=>{let n=t.getAttribute(`token`),r=t.getAttribute(`base-url`);return(e===null||e.token!==n||e.baseUrl!==r)&&(e={token:n,baseUrl:r,access:n===null?null:rM(n,r??void 0)}),e.access}}export{m as A,lf as C,Zd as D,uf as E,o as M,c as N,Ta as O,Kf as S,cf as T,I as _,ej as a,ap as b,DA as c,tA as d,nA as f,Df as g,Of as h,Tj as i,f as j,g as k,eA as l,xf as m,oM as n,$A as o,Yf as p,nM as r,KA as s,sM as t,Qk as u,pf as v,F as w,mp as x,ff as y};
|
|
28
|
+
`;return tg(Ek.encode(n)).pipe(fg(Ok(e.content)),fg(tg(Ek.encode(`\r
|
|
29
|
+
`))))})).pipe(dg(),fg(tg(Ek.encode(`--${t}--\r\n`)))),`multipart/form-data; boundary=${t}`)}),Ak=z(`SessionsApi.uploadBody`)(function*(e){let t=new FormData;for(let n of e)if(n.content instanceof Blob)t.append(`files`,n.content,n.name);else if(n.content instanceof Uint8Array)t.append(`files`,new Blob([new Uint8Array(n.content)]),n.name);else return yield*kk(e);return ow(t)}),jk=e=>e?.match(/filename="([^"]+)"/)?.[1]??null,Mk=(e,t)=>`/sessions/${encodeURIComponent(e)}/recordings/${encodeURIComponent(t)}/content`,Nk=100,Pk=ld(Sk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=lT(e),r=CO(e),i=e=>t(DO.tenantScoped(e)),a=z(`SessionsApi.listSessions`)(function*(e,t={}){return yield*r.listSessions({params:dk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,status:t.status,query:t.query,...uk(t.tags)})}).pipe(i(e))}),o=lk(a),s=z(`SessionsApi.exportSessionStorageState`)(function*(e,t,n){return yield*r.exportSessionStorageState(t,{payload:n}).pipe(i(e))}),c=z(`SessionsApi.getSession`)(function*(e,t){return yield*r.getSession(t,void 0).pipe(i(e))}),l=z(`SessionsApi.getSessionsBulk`)(function*(e,t){return{sessions:(yield*af(oa(t,Nk),t=>r.getSessionsBulk({payload:{ids:t}}).pipe(i(e)))).flatMap(e=>e.sessions)}}),u=z(`SessionsApi.createSession`)(function*(e,t,n={}){return yield*r.createSession({params:dk({waitForReady:n.waitForReady}),payload:VS(LD)({baseSnapshotName:t.baseSnapshotName??null,label:t.label??null,browser:{channel:t.browser.channel,args:t.browser.args??[]},initialTargets:t.initialTargets??[],...t.storageState===void 0?{}:{storageState:t.storageState},tags:t.tags??{},...t.proxy===void 0?{}:{proxy:t.proxy}})}).pipe(i(e))}),d=z(`SessionsApi.deleteSession`)(function*(e,t){return yield*r.deleteSession(t,void 0).pipe(i(e))}),f=z(`SessionsApi.reopenSession`)(function*(e,t){return yield*r.reopenSession(t,void 0).pipe(i(e))}),p=z(`SessionsApi.suspendSession`)(function*(e,t){return yield*r.suspendSession(t,void 0).pipe(i(e))}),m=z(`SessionsApi.rotateSessionToken`)(function*(e,t){return yield*r.rotateSessionToken(t,void 0).pipe(i(e))}),h=z(`SessionsApi.rotateCollaborationCapability`)(function*(e,t,n){return yield*r.rotateCollaborationCapability(t,n,void 0).pipe(i(e))}),g=z(`SessionsApi.replaceSessionTags`)(function*(e,t,n){return yield*r.replaceSessionTags(t,{payload:{tags:n}}).pipe(i(e))}),_=z(`SessionsApi.updateSessionProxy`)(function*(e,t,n){return yield*r.updateSessionProxy(t,{payload:VS(UD)(n)}).pipe(i(e))}),v=z(`SessionsApi.promoteSession`)(function*(e,t,n){return yield*r.promoteSession(t,{payload:{name:n.name,description:n.description??null,force:n.force??!1,tags:n.tags??{}}}).pipe(i(e))}),y=z(`SessionsApi.getSessionCursor`)(function*(e,t){return yield*r.getSessionCursor(t,void 0).pipe(i(e))}),b=z(`SessionsApi.setSessionCursor`)(function*(e,t,n){return yield*r.setSessionCursor(t,{payload:{visible:n}}).pipe(i(e))}),x=z(`SessionsApi.listSessionRecordings`)(function*(e,t){return yield*r.listSessionRecordings(t,void 0).pipe(i(e))}),ee=z(`SessionsApi.createSessionRecording`)(function*(e,t,n){return yield*r.createSessionRecording(t,{payload:n}).pipe(i(e))}),S=z(`SessionsApi.getSessionRecording`)(function*(e,t,n){return yield*r.getSessionRecording(t,n,void 0).pipe(i(e))}),C=z(`SessionsApi.retargetSessionRecording`)(function*(e,t,n,a){return yield*r.retargetSessionRecording(t,n,{payload:{targetId:a}}).pipe(i(e))}),te=z(`SessionsApi.stopSessionRecording`)(function*(e,t,n){return yield*r.stopSessionRecording(t,n,void 0).pipe(i(e))}),ne=z(`SessionsApi.listSessionFiles`)(function*(e,t){return yield*r.listSessionFiles(t,void 0).pipe(i(e))}),w=z(`SessionsApi.captionSessionRecording`)(function*(e,t,n,a){yield*r.captionSessionRecording(t,n,{payload:a}).pipe(i(e))}),T=z(`SessionsApi.focusSessionRecording`)(function*(e,t,n,a){yield*r.focusSessionRecording(t,n,{payload:a}).pipe(i(e))}),re=z(`SessionsApi.attentionSessionRecording`)(function*(e,t,n,a){yield*r.attentionSessionRecording(t,n,{payload:a}).pipe(i(e))}),ie=z(`SessionsApi.createSessionFileDownloadURL`)(function*(e,t,n){return yield*r.createSessionFileDownloadURL(t,{payload:n}).pipe(i(e))}),ae=z(`SessionsApi.getBrowserChannels`)(function*(e){return yield*r.listBrowserChannels(void 0).pipe(i(e))}),oe=z(`SessionsApi.getBrowserStatus`)(function*(e,r,i){return yield*n.get(`/sessions/${encodeURIComponent(r)}/browser/status`).pipe(L($w(yk)),t({credentials:e,bearerToken:i,tenantHeader:`tenant-scoped`}))}),se=z(`SessionsApi.downloadSessionRecording`)(function*(e,r,i,a){return yield*n.get(Mk(r,i)).pipe(L(e=>R(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:jk(e.headers[`content-disposition`])}))),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))}),ce=z(`SessionsApi.getSessionThumbnail`)(function*(e,r,i){let a=`/api/sessions/${encodeURIComponent(r)}`,o=i===void 0?`${a}/thumbnail`:`${a}/targets/${encodeURIComponent(i)}/thumbnail`;return yield*n.get(o).pipe(L(e=>R(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),t({credentials:e,tenantHeader:`tenant-scoped`}))}),le=(e,r,i,a)=>n.get(Mk(r,i)).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}),R(e=>e.stream.pipe(_g(`HttpClientError`,e=>Zh(ek(I(e)))))),lg),E=z(`SessionsApi.uploadSessionFiles`)(function*(e,t,r,a={}){let o=yield*Ak(r);return(yield*n.post(`/api/sessions/${encodeURIComponent(t)}/files`,{body:o,urlParams:dk({directory:a.directory})}).pipe(L($w(lO)),i(e))).files}),ue=z(`SessionsApi.deleteSessionFile`)(function*(e,t,n,a={}){yield*r.deleteSessionFile(t,{params:dk({relativePath:n,recursive:a.recursive})}).pipe(i(e))}),de=z(`SessionsApi.createSessionDirectory`)(function*(e,t,n){return yield*r.createSessionDirectory(t,{payload:{relativePath:n}}).pipe(i(e))}),fe=z(`SessionsApi.moveSessionFile`)(function*(e,t,n){return yield*r.moveSessionFile(t,{payload:n}).pipe(i(e))}),pe=z(`SessionsApi.uploadLiveSessionFiles`)(function*(e,r,i,a){let o=yield*Ak(i);return(yield*n.post(`/sessions/${encodeURIComponent(r)}/uploads`,{body:o}).pipe(L($w(xO)),t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))).files}),me=z(`SessionsApi.setSessionViewport`)(function*(e,n,i,a){return yield*r.setSessionViewport(n,{payload:i}).pipe(t({credentials:e,bearerToken:a,tenantHeader:`tenant-scoped`}))});return Sk.of({listSessions:a,streamSessions:o.stream,listAllSessions:o.listAll,getSession:c,exportSessionStorageState:s,getSessionsBulk:l,createSession:u,deleteSession:d,reopenSession:f,suspendSession:p,rotateSessionToken:m,rotateCollaborationCapability:h,replaceSessionTags:g,updateSessionProxy:_,promoteSession:v,getSessionCursor:y,setSessionCursor:b,listSessionRecordings:x,createSessionRecording:ee,getSessionRecording:S,retargetSessionRecording:C,stopSessionRecording:te,captionSessionRecording:w,focusSessionRecording:T,attentionSessionRecording:re,listSessionFiles:ne,createSessionFileDownloadURL:ie,getBrowserChannels:ae,getBrowserStatus:oe,downloadSessionRecording:se,getSessionThumbnail:ce,streamSessionRecording:le,uploadSessionFiles:E,uploadLiveSessionFiles:pe,deleteSessionFile:ue,moveSessionFile:fe,createSessionDirectory:de,setSessionViewport:me})})),Fk=class extends _r()(`@aperture-browser/api-client/SnapshotsApi`){},Ik=ld(Fk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=e=>t(DO.tenantScoped(e)),i=z(`SnapshotsApi.listSnapshots`)(function*(e,t={}){return yield*n.listSnapshots({params:dk({limit:t.limit,cursor:t.cursor,includeDeleted:t.includeDeleted||void 0,deleted:t.deleted,name:t.name,...uk(t.tags)})}).pipe(r(e))}),a=lk(i),o=z(`SnapshotsApi.getSnapshotByName`)(function*(e,t){return yield*a.stream(e,{name:t,limit:100}).pipe(hg(e=>e.name===t),bg)}),s=z(`SnapshotsApi.updateSnapshot`)(function*(e,t,i){return yield*n.updateSnapshot(t,{payload:i}).pipe(r(e))}),c=z(`SnapshotsApi.replaceSnapshotTags`)(function*(e,t,i){return yield*n.replaceSnapshotTags(t,{payload:{tags:i}}).pipe(r(e))}),l=z(`SnapshotsApi.deleteSnapshot`)(function*(e,t){return yield*n.deleteSnapshot(t,void 0).pipe(r(e))}),u=z(`SnapshotsApi.restoreSnapshot`)(function*(e,t){return yield*n.restoreSnapshot(t,void 0).pipe(r(e))});return Fk.of({listSnapshots:i,streamSnapshots:a.stream,listAllSnapshots:a.listAll,getSnapshotByName:o,updateSnapshot:s,replaceSnapshotTags:c,deleteSnapshot:l,restoreSnapshot:u})})),Lk=class extends _r()(`@aperture-browser/api-client/TenantsApi`){},Rk=ld(Lk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=z(`TenantsApi.listTenants`)(function*(e,r={}){return yield*n.listTenants({params:dk({limit:r.limit,cursor:r.cursor,includeDeleted:r.includeDeleted||void 0,deleted:r.deleted,query:r.query})}).pipe(t(DO.of(e)))}),i=lk(r),a=z(`TenantsApi.getCurrentTenant`)(function*(e){return yield*n.getTenant(void 0).pipe(t(DO.of(e)))}),o=z(`TenantsApi.updateCurrentTenant`)(function*(e,r){return yield*n.updateSelectedTenant({payload:r}).pipe(t(DO.of(e)))}),s=z(`TenantsApi.createTenant`)(function*(e,r){return yield*n.createTenant({payload:r}).pipe(t(DO.of(e)))}),c=z(`TenantsApi.updateTenant`)(function*(e,r,i){return yield*n.updateTenant(r,{payload:i}).pipe(t(DO.of(e)))}),l=z(`TenantsApi.deleteTenant`)(function*(e,r){return yield*n.deleteTenant(r,void 0).pipe(t(DO.of(e)))}),u=z(`TenantsApi.restoreTenant`)(function*(e,r){return yield*n.restoreTenant(r,void 0).pipe(t(DO.of(e)))});return Lk.of({listTenants:r,streamTenants:i.stream,listAllTenants:i.listAll,createTenant:s,updateTenant:c,deleteTenant:l,restoreTenant:u,getCurrentTenant:a,updateCurrentTenant:o})})),zk=class extends _r()(`@aperture-browser/api-client/TokensApi`){},Bk=ld(zk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=z(`TokensApi.listAdminTokens`)(function*(e,r={}){return yield*n.listAdminTokens({params:dk({limit:r.limit,cursor:r.cursor,tenantId:r.tenantId,name:r.name,authorityType:r.authorityType,revoked:r.revoked,scope:r.scope})}).pipe(t(DO.of(e)))}),i=lk(r),a=z(`TokensApi.createAdminToken`)(function*(e,r){let i=r.authorityType===`system_admin`;return yield*n.createAdminToken({payload:{name:r.name,authorityType:r.authorityType,tenantId:r.tenantId??null,scopes:r.scopes,resourceMode:i?`all`:r.resourceMode,resourceGrants:i?[]:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(DO.of(e)))}),o=z(`TokensApi.revokeAdminToken`)(function*(e,r){yield*n.revokeAdminToken(r,void 0).pipe(t(DO.of(e)))}),s=z(`TokensApi.listTenantTokens`)(function*(e,r={}){return yield*n.listTenantTokens({params:dk({limit:r.limit,cursor:r.cursor,name:r.name,revoked:r.revoked,scope:r.scope})}).pipe(t(DO.of(e)))}),c=lk(s),l=z(`TokensApi.createTenantToken`)(function*(e,r){return yield*n.createTenantToken({payload:{name:r.name,scopes:r.scopes,resourceMode:r.resourceMode,resourceGrants:r.resourceGrants,expiresAt:r.expiresAt??null}}).pipe(t(DO.of(e)))}),u=z(`TokensApi.revokeTenantToken`)(function*(e,r){yield*n.revokeTenantToken(r,void 0).pipe(t(DO.of(e)))});return zk.of({listAdminTokens:r,streamAdminTokens:i.stream,listAllAdminTokens:i.listAll,createAdminToken:a,revokeAdminToken:o,listTenantTokens:s,streamTenantTokens:c.stream,listAllTenantTokens:c.listAll,createTenantToken:l,revokeTenantToken:u})})),Vk=class extends _r()(`@aperture-browser/api-client/UsersApi`){},Hk=pd(XO,Rk,ld(Vk,pf(function*(){let e=yield*sT,{authorize:t}=yield*OO,n=CO(e),r=z(`UsersApi.listUsers`)(function*(e,r={}){return yield*n.listUsers({params:dk({limit:r.limit,cursor:r.cursor,query:r.query,disabled:r.disabled})}).pipe(t(DO.of(e)))}),i=lk(r),a=z(`UsersApi.createUser`)(function*(e,r){return yield*n.createUser({payload:r}).pipe(t(DO.of(e)))}),o=z(`UsersApi.getUser`)(function*(e,r){return yield*n.getUser(r,void 0).pipe(t(DO.of(e)))}),s=z(`UsersApi.updateUser`)(function*(e,r,i){return yield*n.updateUser(r,{payload:i}).pipe(t(DO.of(e)))}),c=z(`UsersApi.createUserInvitation`)(function*(e,r){return yield*n.createUserInvitation(r,void 0).pipe(t(DO.of(e)))}),l=z(`UsersApi.disableUser`)(function*(e,r){return yield*n.disableUser(r,void 0).pipe(t(DO.of(e)))}),u=z(`UsersApi.restoreUser`)(function*(e,r){return yield*n.restoreUser(r,void 0).pipe(t(DO.of(e)))}),d=z(`UsersApi.listUserMemberships`)(function*(e,r){return yield*n.listUserMemberships(r,void 0).pipe(t(DO.of(e)))}),f=z(`UsersApi.listTenantMemberships`)(function*(e,r){return yield*n.listTenantMemberships(r,void 0).pipe(t(DO.of(e)))}),p=z(`UsersApi.upsertTenantMembership`)(function*(e,r,i,a){let o={scopes:a};return yield*n.upsertTenantMembership(r,i,{payload:o}).pipe(t(DO.of(e)))}),m=z(`UsersApi.deleteTenantMembership`)(function*(e,r,i){yield*n.deleteTenantMembership(r,i,void 0).pipe(t(DO.of(e)))});return Vk.of({listUsers:r,streamUsers:i.stream,listAllUsers:i.listAll,createUser:a,getUser:o,updateUser:s,createUserInvitation:c,disableUser:l,restoreUser:u,listUserMemberships:d,listTenantMemberships:f,upsertTenantMembership:p,deleteTenantMembership:m})})),Pk,Ik,Bk,fk,pk).pipe(hd(ik),gd(ak)),Uk=e=>ld(sT,R(sT,pT(Ww(e)))),Wk=`aperture-session.v1`,Gk={onExcessProperty:`error`},Kk=U.check(Y()),qk=U.check(xC(0)),Jk=Kk.check(xC(0)),Yk=U.check(CC({minimum:0,maximum:1})),Xk=P([]);function Zk(e){return K(e).pipe(cC(Xk))}var Qk=q([`implicit`,`explicit`]),$k=G({profile:H,fps:Kk.check(CC({minimum:1,maximum:120})),bitrateKbps:Kk.check(J(100)),keyframeInterval:Jk}),eA=G({id:H,label:H,codec:H,mimeType:H,sdpFmtpLine:H}),tA=G({quality:B($k),profiles:K(eA),cursorVisible:W}),nA=G({id:H,type:H,title:H,url:H,loading:W,canGoBack:B(W),canGoForward:B(W),viewport:B(G({width:qk,height:qk,contentWidth:qk,contentHeight:qk,canvasWidth:qk,canvasHeight:qk,deviceScaleFactor:qk}))}),rA=G({clientId:H,name:H,avatarHash:H,role:q([`owner`,`editor`,`viewer`,`automation`]),activeTargetId:B(H),followingClientId:B(H),holdingInput:W,leaseMode:B(Qk),recovering:B(W)}),iA=LS(IC(tC([G({type:V(`session.snapshot`),clientId:H,resumeSecret:H,role:q([`owner`,`editor`,`viewer`]),transport:q([`webrtc`,`websocket`]),holderClientId:B(H),mode:B(Qk),activeTargetId:B(H),targets:Zk(nA),participants:Zk(rA),recordings:Zk(xk),presentation:tA,viewportOwnerClientId:B(H),autoSize:B(W)}),G({type:V(`presence.state`),participants:Zk(rA)}),G({type:V(`input.state`),holderClientId:B(H),mode:B(Qk)}),G({type:V(`viewport.state`),viewportOwnerClientId:B(H),autoSize:W}),G({type:V(`presence.cursor`),clientId:H,targetId:H,x:Yk,y:Yk,realtimeCounter:Jk}),G({type:V(`presence.cursor.clear`),clientId:H,realtimeCounter:Jk}),G({type:V(`paint.point`),clientId:H,targetId:H,strokeId:H,color:H.check(mC(/^#[0-9a-fA-F]{6}$/)),width:U.check(CC({minimum:1,maximum:16})),phase:q([`start`,`move`,`end`]),x:Yk,y:Yk,realtimeCounter:B(Jk)}),G({type:V(`targets.state`),activeTargetId:B(H),targets:Zk(nA)}),G({type:V(`recordings.state`),recordings:Zk(xk)}),G({type:V(`presentation.state`),presentation:tA}),G({type:V(`error`),code:H,message:H}),G({type:q([`target.select.result`,`target.create.result`,`target.close.result`,`page.navigate.result`,`page.history-back.result`,`page.history-forward.result`,`page.reload.result`,`page.stop-loading.result`,`viewport.set.result`,`viewport.auto-size.set.result`,`viewport.owner.claim.result`,`presentation.quality.set.result`,`presentation.cursor.set.result`,`automation.pacing.set.result`,`recording.start.result`,`recording.stop.result`,`recording.cancel.result`]),requestId:H,ok:W,code:B(H),message:B(H),targetId:B(H),recording:B(xk),presentation:B(tA)})])),Gk),aA=G({type:V(`presentation.frame`),targetId:H,width:qk,height:qk}),oA=[lA(1280,720,1),lA(1440,900,1),lA(1920,1080,1),lA(2560,1440,1),lA(768,1024,1),lA(390,844,1)],sA=oA[0],cA=[1,1.5,2,3];function lA(e,t,n){return{id:`${e}x${t}@${uA(n)}`,label:`${e}×${t}`,width:e,height:t,deviceScaleFactor:n}}function uA(e){return Number.isInteger(e)?String(e):String(e).replace(/0+$/,``).replace(/\.$/,``)}function dA(e,t,n,r){if(n<=0||r<=0||e<=0||t<=0)return{scale:1,offsetX:0,offsetY:0,renderedWidth:e,renderedHeight:t};let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{scale:i,offsetX:(e-a)/2,offsetY:(t-o)/2,renderedWidth:a,renderedHeight:o}}var fA=`~effect/FiberSet`,pA=e=>D(e,fA),mA={[fA]:fA,[Symbol.iterator](){return this.state._tag===`Closed`?Hi():this.state.backing[Symbol.iterator]()},...It,toJSON(){return{_id:`FiberSet`,state:this.state}}},hA=(e,t)=>{let n=Object.create(mA);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},gA=()=>qf(F(()=>hA(new Set,Nu())),e=>lf(()=>{let t=e.state;if(t._tag===`Closed`)return uf;e.state={_tag:`Closed`};let n=t.backing;return jp(n).pipe(zu(e.deferred))})),_A=()=>L(gA(),e=>SA(e)()),vA=-1,yA=pa(ha(Td,ma(vA))),bA=b(e=>pA(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(vA);return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),Au(r)&&(n?.propagateInterruption===!0?!yA(r.cause):!bd(r.cause))&&Ru(e.deferred,r))})}),xA=function(){let e;return()=>(e===void 0&&(e=up(ep)),e)}(),SA=e=>()=>R(Vf(),t=>{let n=dp(t);return(t,r)=>{if(e.state._tag===`Closed`)return xA();let i=n(t,r);return bA(e,i,r),i}}),CA=Yr(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),wA=class extends _r()(`effect/http/FetchHttpClient/RequestInit`){},TA=yT(P(fT((e,t,n,r)=>{let i=r.getRef(CA),a=Br(r.context,wA)??{},o=a.headers?A_(E_(a.headers),e.headers):e.headers;o[`content-length`]&&(o=j_(o,`content-length`));let s=r=>R(cf({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new fw({reason:new hw({request:e,cause:t})})}),t=>nT(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return L(wg(e.body.stream),s)}return s(void 0)})));function EA(e,t){let n=new URL(e.baseUrl??`/`,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`session base URL must use HTTP or HTTPS`);if(e.kind===`relay`&&n.origin!==window.location.origin)throw Error(`session relay must use the page's origin`);return n.pathname=`${n.pathname.replace(/\/$/,``)}/${t}`,n.search=``,n.hash=``,n}function DA(e,t){return EA(e,`sessions/${encodeURIComponent(e.sessionId)}/${t}`)}function OA(e,t){let n=DA(e,t);return n.protocol=n.protocol===`https:`?`wss:`:`ws:`,n.toString()}function kA(e){if(e.kind!==`direct`)return{token:void 0,tenantId:void 0};let{credentials:t}=e;return{token:t.kind===`bearer`?y_(t.token):void 0,tenantId:EO(t,`tenant-scoped`)}}function AA(e){let{token:t,tenantId:n}=kA(e),r=[Wk];return t!==void 0&&r.push(`authorization.bearer.${t}`),n!==void 0&&r.push(`x-aperture-tenant-id.${n}`),r}function jA(e,t){let{token:n,tenantId:r}=kA(e),i={};return n!==void 0&&(i.Authorization=`Bearer ${n}`),r!==void 0&&(i[`X-Aperture-Tenant-Id`]=r),L(sT,e=>lT(e).get(t.toString(),{headers:i})).pipe(Gf(wA,{credentials:n===void 0?`same-origin`:`omit`,redirect:`error`,cache:`no-store`}))}var MA=z(`getSessionStatus`)(function*(e){return yield*jA(e,DA(e,`browser/status`)).pipe(L($w(yk)),ek)}),NA=z(`downloadSessionRecording`)(function*(e,t){return yield*jA(e,DA(e,`recordings/${encodeURIComponent(t)}/content`)).pipe(L(e=>R(e.arrayBuffer,t=>({blob:new Blob([t],{type:e.headers[`content-type`]??``}),filename:jk(e.headers[`content-disposition`])}))),ek)}),PA=z(`getTargetThumbnail`)(function*(e,t){let n=`targets/${encodeURIComponent(t)}/thumbnail`,r=kA(e).token;return yield*jA(e,e.kind===`relay`||r!==void 0&&(r.startsWith(`aps_`)||r.startsWith(`ape_`)||r.startsWith(`apv_`))?DA(e,n):EA(e,`api/sessions/${encodeURIComponent(e.sessionId)}/${n}`)).pipe(L(e=>R(e.arrayBuffer,e=>new Blob([e],{type:`image/jpeg`}))),ek)}),FA=class extends Ta(`LiveSessionError`){},IA=LS(IC(tC([G({version:V(1),type:V(`answer`),sdp:H}),G({version:V(1),type:V(`ice-candidate`),candidate:G({candidate:H,sdpMid:B(nC(H)),sdpMLineIndex:B(nC(U.check(Y()))),usernameFragment:B(nC(H))})}),G({version:V(1),type:V(`error`),error:G({code:H,message:H})})])),Gk),LA=LS(IC(aA),Gk),RA=5e3,zA=500,BA=15e3,VA=Sp(function*(e){let{callbacks:t}=e,n=yield*_A(),r=e=>n(e),i=(e,t)=>r(If(e).pipe(xf(F(t)))),a=null,o=null,s=null,c=e.webrtcSupported?`webrtc`:`websocket`,l=null,u=!1,d=null,f=null,p=1e3,m=0,h=0,g=0,_=[],v=null,y=new Map,b={hello:()=>({type:`session.hello`,...s??e.identity,...e.autoSize===void 0?{}:{autoSize:e.autoSize()}}),message:(e,t)=>oe(e,t),ready:e=>re(e),failed:(e,t)=>ae(e,t),frame:(e,n)=>{a===e?t.onFrame(n):o===e&&(v=n)}},x=()=>{o?.close(),o=null,_=[],v=null},ee=()=>{f?.interruptUnsafe(),f=null},S=e=>{let t=new FA({message:e});for(let e of y.values())Ru(e,I(t));y.clear()},C=e=>{if(!l)return;let t=l;l=null,Ru(t.deferred,I(new FA({message:e})))},te=()=>{c===`webrtc`&&e.webrtcSupported?ne():w()},ne=()=>{if(u||d!==null||o)return;let t;try{t=new WA({access:e.access,iceServers:e.iceServers,callbacks:b,fork:r})}catch(e){le(`webrtc`,HA(e,`WebRTC setup failed`));return}o=t,_=[],v=null,t.connect(),i(RA,()=>{o===t&&(x(),le(`webrtc`,new FA({message:`WebRTC presentation timed out`})))})},w=()=>{if(u||d!==null||o)return;let t;try{t=new UA({access:e.access,callbacks:b,fork:r})}catch(e){le(`websocket`,HA(e,`WebSocket setup failed`));return}o=t,_=[],v=null,t.connect()},T=e=>i(e,()=>{!u&&a===null&&o===null&&w()}),re=n=>{if(u||o!==n){n.close();return}let r=a,i=_,s=v;if(r&&r!==n&&S(`live session transport replaced`),o=null,_=[],v=null,a=n,h=0,g=0,p=1e3,t.onPhase(`connected`),t.onTransport(n.kind),l?.kind===n.kind){let e=l;l=null,Ru(e.deferred,uf)}n instanceof WA?(t.onFrame(null),t.onStream(n.mediaStream())):(t.onStream(null),s&&t.onFrame(s));for(let e of i)se(e);n.kind===`websocket`&&c===`webrtc`&&e.webrtcSupported&&ce(),r&&r!==n&&r.close()},ie=e=>{ee(),x(),a?.close(),a=null,C(e),S(e),t.onFrame(null),t.onStream(null),t.onTransport(null)},ae=(e,n)=>{if(!u){if(n.terminalReason!==void 0&&(o===e||a===e)){d=n,ie(n.message),t.onPhase(`error`),t.onError(n.message);return}if(o===e){x(),le(e.kind,n);return}a===e&&(a=null,e.close(),S(`live session transport was lost`),t.onPhase(`disconnected`),t.onError(n.message),t.onFrame(null),t.onStream(null),t.onTransport(null),T(e.kind===`webrtc`?0:zA))}},oe=(e,t)=>{if(t.type===`error`&&t.code===`resume_rejected`&&o===e&&a===null&&(s=null),t.type===`session.snapshot`&&(s={clientId:t.clientId,resumeSecret:t.resumeSecret}),a!==e){if(o!==e)return;_.push(t),t.type===`session.snapshot`&&e.kind===`websocket`&&re(e);return}se(t)},se=e=>{if(`realtimeCounter`in e&&e.realtimeCounter!==void 0){if(e.realtimeCounter<=g)return;g=e.realtimeCounter}if(`requestId`in e){let t=y.get(e.requestId);t&&(y.delete(e.requestId),Ru(t,e.ok?P(e):I(new FA({message:e.message??`live session command failed`}))))}t.onMessage(e)},ce=()=>{if(u||c!==`webrtc`||!e.webrtcSupported||a?.kind===`webrtc`||f!==null)return;let t=p;p=Math.min(BA,p*2),f=i(t,()=>{f=null,ne()})},le=(e,n)=>{if(l?.kind===e&&(C(n.message),a&&(c=a.kind)),a){a.kind===`websocket`&&ce();return}if(e===`webrtc`){w();return}t.onPhase(`disconnected`),t.onError(n.message),T(zA)},E=e=>a?.sendReliable(e)??!1,ue=e=>(h+=1,a?.sendRealtime({realtimeCounter:h,...e})??!1),de=()=>{u=!0,ie(`live session connection closed`)};return yield*Yf(()=>F(de)),t.onPhase(`connecting`),te(),{reconnect:F(()=>{d=null,ee(),x(),a?.close(),a=null,C(`live session transport replaced`),S(`live session transport replaced`),t.onPhase(`connecting`),w()}),selectTransport:t=>lf(()=>{if(d!==null)return I(d);if(t===`webrtc`&&!e.webrtcSupported)return I(new FA({message:`WebRTC presentation is unavailable`}));if(c=t,ee(),o&&o.kind!==t&&x(),C(`presentation selection was replaced`),a?.kind===t)return uf;let n=Nu();return l={kind:t,deferred:n},o===null&&(t===`webrtc`?ne():w()),Pu(n)}),sendReliable:E,sendRealtime:ue,command:(e,t={})=>lf(()=>{m+=1;let n=`request-${m}`,r=Nu();return y.set(n,r),E({type:e,requestId:n,...t})?Pu(r).pipe(tp(()=>F(()=>y.delete(n)))):(y.delete(n),I(new FA({message:`live session transport is unavailable`})))})}});function HA(e,t){return new FA({message:e instanceof Error&&e.message?e.message:t})}var UA=class{kind=`websocket`;socket;callbacks;fork;pendingRealtime=new Map;pendingRasterPacket=null;rasterDecoder=null;decodingRaster=!1;realtimeFrame=null;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.socket=new WebSocket(OA(e.access,`session`),AA(e.access)),this.socket.binaryType=`blob`}connect(){this.socket.addEventListener(`open`,()=>{this.sendReliable(this.callbacks.hello())}),this.socket.addEventListener(`message`,e=>{if(typeof e.data==`string`){let t=iA(e.data);lr(t)&&this.callbacks.message(this,t.value);return}e.data instanceof Blob&&(this.pendingRasterPacket=e.data,this.decodingRaster||(this.decodingRaster=!0,this.rasterDecoder=this.fork(this.decodeRasterPackets())))}),this.socket.addEventListener(`close`,e=>{this.closed||this.callbacks.failed(this,GA(`WebSocket session transport closed`,e.code))}),this.socket.addEventListener(`error`,()=>{this.closed||this.callbacks.failed(this,new FA({message:`WebSocket session transport failed`}))})}sendReliable(e){return this.flushRealtime(),this.sendNow(e)}sendRealtime(e){return this.socket.readyState===WebSocket.OPEN?(this.pendingRealtime.delete(e.type),this.pendingRealtime.set(e.type,e),this.realtimeFrame===null&&(this.realtimeFrame=window.requestAnimationFrame(()=>{this.realtimeFrame=null,this.flushRealtime()})),!0):!1}close(){this.closed=!0,this.pendingRasterPacket=null,this.rasterDecoder?.interruptUnsafe(),this.rasterDecoder=null,this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null),this.pendingRealtime.clear(),this.socket.close()}decodeRasterPackets(){return pf({self:this},function*(){for(;;){let e=this.pendingRasterPacket;if(e===null||this.closed){this.decodingRaster=!1;return}this.pendingRasterPacket=null;let t=yield*KA(e);lr(t)&&!this.closed&&this.callbacks.frame(this,t.value)}})}flushRealtime(){this.realtimeFrame!==null&&(window.cancelAnimationFrame(this.realtimeFrame),this.realtimeFrame=null);for(let e of this.pendingRealtime.values())this.sendNow(e);this.pendingRealtime.clear()}sendNow(e){return this.socket.readyState===WebSocket.OPEN?(this.socket.send(JSON.stringify(e)),!0):!1}},WA=class{kind=`webrtc`;connection;reliable;realtime;signal;callbacks;fork;pendingCandidates=[];reliableOpen=!1;realtimeOpen=!1;helloSent=!1;snapshotReceived=!1;stream=null;streamReady=!1;closed=!1;constructor(e){this.callbacks=e.callbacks,this.fork=e.fork,this.connection=new RTCPeerConnection({iceServers:e.iceServers.map(e=>({urls:[...e.urls],username:e.username,credential:e.credential===void 0?void 0:y_(e.credential)}))}),this.reliable=this.connection.createDataChannel(`application`,{ordered:!0}),this.realtime=this.connection.createDataChannel(`application-realtime`,{ordered:!1,maxRetransmits:0}),this.connection.addTransceiver(`video`,{direction:`recvonly`}),this.signal=new WebSocket(OA(e.access,`webrtc/signal`),AA(e.access))}connect(){this.reliable.addEventListener(`open`,()=>{this.reliableOpen=!0,this.sendHello()}),this.realtime.addEventListener(`open`,()=>{this.realtimeOpen=!0,this.sendHello()}),this.reliable.addEventListener(`message`,e=>this.handleApplicationMessage(e)),this.realtime.addEventListener(`message`,e=>this.handleApplicationMessage(e));for(let e of[this.reliable,this.realtime])e.addEventListener(`close`,()=>this.fail(`WebRTC session channel closed`)),e.addEventListener(`error`,()=>this.fail(`WebRTC session channel failed`));this.connection.addEventListener(`track`,e=>{this.stream=e.streams[0]??new MediaStream([e.track]);let t=()=>{this.stream&&(this.streamReady=!0,this.maybeReady())};e.track.muted?e.track.addEventListener(`unmute`,t,{once:!0}):t()}),this.connection.addEventListener(`icecandidate`,e=>{e.candidate&&this.signal.readyState===WebSocket.OPEN&&this.signal.send(JSON.stringify({version:1,type:`ice-candidate`,candidate:e.candidate.toJSON()}))}),this.connection.addEventListener(`connectionstatechange`,()=>{(this.connection.connectionState===`failed`||this.connection.connectionState===`closed`)&&this.fail(`WebRTC ${this.connection.connectionState}`)}),this.signal.addEventListener(`open`,()=>{this.fork(this.sendOffer().pipe(Of(`LiveSessionError`,e=>F(()=>this.fail(e.message)))))}),this.signal.addEventListener(`message`,e=>this.handleSignal(e)),this.signal.addEventListener(`close`,e=>this.fail(`WebRTC signaling closed`,e.code)),this.signal.addEventListener(`error`,()=>this.fail(`WebRTC signaling failed`))}sendReliable(e){return this.reliable.readyState===`open`?(this.reliable.send(JSON.stringify(e)),!0):!1}sendRealtime(e){return this.realtime.readyState===`open`?(this.realtime.send(JSON.stringify(e)),!0):!1}close(){this.closed=!0,this.reliable.close(),this.realtime.close(),this.connection.close(),this.signal.close()}mediaStream(){return this.stream}sendHello(){this.helloSent||!this.reliableOpen||!this.realtimeOpen||(this.helloSent=this.sendReliable(this.callbacks.hello()))}handleApplicationMessage(e){if(typeof e.data!=`string`)return;let t=iA(e.data);if(cr(t)){this.fail(`WebRTC session message is invalid`);return}this.callbacks.message(this,t.value),t.value.type===`session.snapshot`&&(this.snapshotReceived=!0,this.maybeReady())}handleSignal(e){let t=typeof e.data==`string`?IA(e.data):or();if(cr(t)){this.fail(`WebRTC signaling message is invalid`);return}let n=t.value;if(n.type===`error`){this.fail(n.error.message);return}if(n.type===`answer`){this.fork(cf(()=>this.connection.setRemoteDescription({type:`answer`,sdp:n.sdp})).pipe(xf(lf(()=>af(this.pendingCandidates.splice(0),e=>cf(()=>this.connection.addIceCandidate(e)),{discard:!0}))),Df(()=>F(()=>this.fail(`WebRTC answer is invalid`)))));return}if(!this.connection.remoteDescription){this.pendingCandidates.push(n.candidate);return}this.fork(cf(()=>this.connection.addIceCandidate(n.candidate)).pipe(Df(()=>F(()=>this.fail(`WebRTC ICE candidate is invalid`)))))}sendOffer(){return pf({self:this},function*(){let e=e=>HA(e,`WebRTC negotiation failed`),t=yield*cf({try:()=>this.connection.createOffer(),catch:e});yield*cf({try:()=>this.connection.setLocalDescription(t),catch:e});let n=this.connection.localDescription?.sdp;if(!n)return yield*new FA({message:`WebRTC offer is unavailable`});this.signal.send(JSON.stringify({version:1,type:`offer`,sdp:n}))})}maybeReady(){this.snapshotReceived&&this.stream&&this.streamReady&&this.callbacks.ready(this)}fail(e,t=0){this.closed||this.callbacks.failed(this,GA(e,t))}};function GA(e,t){return t===4401||t===4403?new FA({message:`Session access denied. Sign in or request access before reconnecting.`,terminalReason:`access_denied`}):t===4404||t===4410?new FA({message:`Session is no longer available.`,terminalReason:`session_unavailable`}):new FA({message:e})}function KA(e){return pf(function*(){if(e.size<4)return or();let t=yield*cf(()=>e.slice(0,4).arrayBuffer()),n=new DataView(t).getUint32(0);return n===0||n>e.size-4?or():mr(LA(yield*cf(()=>e.slice(4,4+n).text())),t=>({targetId:t.targetId,data:e.slice(4+n,e.size,`image/jpeg`),width:t.width,height:t.height}))}).pipe(Pf(()=>or()))}var $=c(f(),1),qA=`~effect/SubscriptionRef`,JA={...It,[qA]:{_A:x},toJSON(){return{_id:`SubscriptionRef`,value:this.value}}},YA=e=>R(em({replay:1}),t=>{let n=Object.create(JA);return n.semaphore=$m(1),n.value=e,n.pubsub=t,rm(n.pubsub,e),n}),XA=e=>og(e.pubsub),ZA=(e,t)=>{e.value=t,rm(e.pubsub,t)},QA=b(2,(e,t)=>e.semaphore.withPermit(F(()=>ZA(e,t)))),$A=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),ej=o(((e,t)=>{t.exports=$A()})),tj=ej(),nj=(0,$.createContext)(null),rj=class extends Ta(`RuntimeProviderMissingError`){message=`useRuntime must be used inside RuntimeProvider`};function ij({runtime:e,baseUrl:t,children:n}){let r=(0,$.useMemo)(()=>({runtime:e,baseUrl:t}),[e,t]);return(0,tj.jsx)(nj.Provider,{value:r,children:n})}function aj(){let e=(0,$.useContext)(nj);if(!e)throw new rj;return e}function oj(){return aj().runtime}function sj(e,t){let n=oj();(0,$.useEffect)(()=>{let t=e();if(!t)return;let r=n.runFork(t);return()=>r.interruptUnsafe()},[n,...t])}function cj(e,t){let n=oj(),r=(0,$.useRef)(new Set);return(0,$.useEffect)(()=>{let e=r.current;return()=>{for(let t of e)t.interruptUnsafe();e.clear()}},[]),(0,$.useCallback)((...t)=>{let i=n.runFork(e(...t));i.pollUnsafe()||(r.current.add(i),i.addObserver(()=>r.current.delete(i)))},[n,...t])}var lj=2e3,uj=()=>new FA({message:`live session transport is unavailable`}),dj=40,fj=7e3,pj={left:272,right:273,middle:274};function mj({access:e,displayName:t=null,enabled:n,webrtcSupported:r,iceServers:i,autoSize:a}){let o=(0,$.useMemo)(()=>gj(t),[t]),[s,c]=(0,$.useState)(`viewer`),l=oj(),u=(0,$.useMemo)(()=>l.runSync(YA(null)),[l]),d=(0,$.useMemo)(()=>l.runSync(em()),[l]),f=(0,$.useMemo)(()=>XA(u),[u]),p=(0,$.useMemo)(()=>og(d),[d]),m=(0,$.useCallback)(e=>l.runSync(QA(u,e)),[u,l]),h=(0,$.useCallback)(e=>rm(d,e),[d]),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(``),y=(0,$.useRef)(!1),b=(0,$.useRef)(!1),x=(0,$.useRef)(!1),ee=(0,$.useRef)(0),S=(0,$.useRef)([]),C=(0,$.useRef)(null),te=(0,$.useRef)(null),ne=(0,$.useRef)(null),w=(0,$.useRef)(null),T=(0,$.useRef)(!1),[re,ie]=(0,$.useState)(`idle`),[ae,oe]=(0,$.useState)([]),[se,ce]=(0,$.useState)(null),[le,E]=(0,$.useState)(null),[ue,de]=(0,$.useState)(null),[fe,pe]=(0,$.useState)(null),[me,he]=(0,$.useState)(!1),[ge,_e]=(0,$.useState)(!1),[D,ve]=(0,$.useState)(null),[ye,be]=(0,$.useState)([]),[O,xe]=(0,$.useState)(null),[Se,Ce]=(0,$.useState)(``),[we,Te]=(0,$.useState)(null),[Ee,De]=(0,$.useState)(null),[Oe,ke]=(0,$.useState)([]),[Ae,je]=(0,$.useState)(()=>new Map),[Me,Ne]=(0,$.useState)(null);te.current=ue,ne.current=fe,w.current=D;let Pe=(0,$.useCallback)(e=>{switch(e.type){case`session.snapshot`:c(e.role),v.current=e.clientId,Ce(e.clientId),_.current=e.holderClientId??null,Te(e.holderClientId??null),De(e.mode??null),S.current=e.participants,ke(e.participants),C.current=e.participants.find(t=>t.clientId===e.clientId)?.followingClientId??null,oe(e.targets),ce(e.activeTargetId??null),de(yj(e.targets,e.activeTargetId)),be(e.recordings),ve(e.presentation??null),xe(e.autoSize===void 0?null:{ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize}),Ne(null);return;case`targets.state`:oe(e.targets),ce(e.activeTargetId??null),de(yj(e.targets,e.activeTargetId)),he(!1);return;case`presence.state`:S.current=e.participants,ke(e.participants),C.current=e.participants.find(e=>e.clientId===v.current)?.followingClientId??null,je(e=>{let t=C.current;if(!t)return e.size===0?e:new Map;let n=e.get(t);return n?new Map([[t,n]]):new Map});return;case`input.state`:_.current=e.holderClientId??null,Te(e.holderClientId??null),De(e.mode??null),y.current=!1,b.current=!1,Ne(e=>e?.code===`input_busy`||e?.code===`input_not_owned`?null:e);return;case`viewport.state`:xe({ownerClientId:e.viewportOwnerClientId??null,autoSize:e.autoSize});return;case`presence.cursor`:if(e.clientId!==C.current)return;je(t=>new Map(t).set(e.clientId,e));return;case`presence.cursor.clear`:je(t=>{if(!t.has(e.clientId))return t;let n=new Map(t);return n.delete(e.clientId),n});return;case`paint.point`:S.current.some(t=>t.clientId===e.clientId)&&h({type:`point`,message:e});return;case`recordings.state`:be(e.recordings);return;case`presentation.state`:ve(e.presentation);return;case`error`:y.current=!1,b.current=!1,Ne({code:e.code,message:e.message});return;default:e.presentation&&ve(e.presentation),e.ok||Ne({code:e.code??`request_rejected`,message:e.message??`Live session command failed.`})}},[h]);sj(()=>{if(!n||e===null){g.current=null,ie(`idle`),c(`viewer`),oe([]),ce(null),E(null),de(null),pe(null),ve(null),he(!1),_e(!1),ke([]),je(new Map),be([]),xe(null),m(null),h({type:`clear`});return}return c(`viewer`),pf(function*(){let t=yield*VA({access:e,identity:o,autoSize:a,iceServers:i,webrtcSupported:r,callbacks:{onPhase:ie,onMessage:Pe,onFrame:m,onStream:E,onTransport:pe,onError:e=>Ne({code:`connection_failed`,message:e})}});return g.current=t,yield*Yf(()=>F(()=>{g.current===t&&(g.current=null)})),yield*ff}).pipe(Kf,Xf(F(()=>{m(null),h({type:`clear`})})))},[a,e,n,Pe,i,o,m,h,r]);let Fe=(0,$.useCallback)(e=>g.current?.sendReliable(e)??!1,[]),Ie=(0,$.useCallback)(e=>g.current?.sendRealtime(e)??!1,[]),Le=cj((e,t,n)=>e.command(t,n).pipe(Df(e=>F(()=>{he(!1),Ne({code:`request_rejected`,message:e.message})}))),[]),Re=(0,$.useCallback)((e,t={})=>{let n=g.current;return n?(Le(n,e,t),!0):!1},[Le]),ze=(0,$.useCallback)((e,t={})=>lf(()=>g.current?g.current.command(e,t):I(uj())),[]),Be=cj((e,t)=>e.command(`target.select`,{targetId:t}).pipe(zf({onSuccess:()=>ce(t),onFailure:e=>Ne({code:`request_rejected`,message:e.message})}),Xf(F(()=>he(!1)))),[]),Ve=(0,$.useCallback)(e=>lf(()=>{let t=g.current;return t?(he(!0),t.command(`target.select`,{targetId:e}).pipe(Sf(()=>F(()=>ce(e))),Mf(e=>F(()=>Ne({code:`request_rejected`,message:e.message}))),Xf(F(()=>he(!1))),Ef)):I(uj())}),[]),He=(0,$.useCallback)(e=>{let t=g.current;return t?(he(!0),Be(t,e),!0):!1},[Be]),Ue=(0,$.useCallback)(e=>lf(()=>{let t=g.current;return t?T.current?I(new FA({message:`another presentation update is already in progress`})):(T.current=!0,_e(!0),pf(function*(){switch(e.kind){case`jpeg`:return yield*t.selectTransport(`websocket`);case`webrtc-retry`:return yield*t.selectTransport(`webrtc`);case`webrtc`:{let n=te.current;if(!n)return yield*new FA({message:`presentation size is unavailable`});let r=w.current?.quality?.profile!==e.quality.profile&&ne.current===`webrtc`;r&&(yield*t.selectTransport(`websocket`));let i=yield*t.command(`presentation.quality.set`,{profile:e.quality.profile,width:n.canvasWidth,height:n.canvasHeight,fps:e.quality.fps,bitrateKbps:e.quality.bitrateKbps}).pipe(Mf(()=>r?Nf(t.selectTransport(`webrtc`)):uf));return i.presentation&&ve(i.presentation),yield*t.selectTransport(`webrtc`)}default:return e}}).pipe(Mf(e=>F(()=>Ne({code:`presentation_update_failed`,message:e.message}))),Xf(F(()=>{T.current=!1,_e(!1)})))):I(uj())}),[]),We=(0,$.useCallback)((e,t)=>s===`viewer`||!Fe({type:`input.claim`,targetId:e,mode:t})?!1:(y.current=!0,b.current=!1,!0),[s,Fe]),Ge=(0,$.useCallback)(()=>b.current||_.current!==v.current||!Fe({type:`input.release`})?!1:(b.current=!0,y.current=!1,!0),[Fe]),Ke=(0,$.useCallback)(e=>e?He(e):!1,[He]),qe=(0,$.useCallback)(e=>Fe({type:`follow.set`,followingClientId:e??``}),[Fe]),Je=(0,$.useCallback)((e,t,n,r)=>{let i=performance.now();if(i-ee.current<dj)return!1;ee.current=i;let a=Ie({type:`presence.cursor`,targetId:e,x:bj(t,r.width),y:bj(n,r.height)});return a&&(x.current=!0),a},[Ie]),Ye=(0,$.useCallback)(e=>e.phase===`move`?Ie({type:`paint.point`,...e}):Fe({type:`paint.point`,...e}),[Ie,Fe]),Xe=(0,$.useCallback)(()=>!x.current||!Fe({type:`presence.cursor.clear`})?!1:(x.current=!1,!0),[Fe]),Ze=(0,$.useCallback)((e,t=!1)=>t?Ie(e):Fe(e),[Ie,Fe]),Qe=(0,$.useCallback)((e,t)=>{if(s===`viewer`||_.current!==v.current&&!y.current)return!1;switch(e.type){case`input.mouse`:{let n=bj(e.x,t.width),r=bj(e.y,t.height);if(e.action===`move`)return Ze({type:`input.pointer.motion.absolute`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,modifiers:e.modifiers??0},!0);if(e.button===`none`)return!0;let i=pj[e.button??`left`],a=(a,o)=>Ze({type:`input.pointer.button`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,buttonCode:i,pressed:a,clickCount:o,modifiers:e.modifiers??0});if(e.action===`down`||e.action===`up`)return a(e.action===`down`,e.clickCount??1);let o=e.action===`doubleClick`?2:1;for(let t=0;t<o;t+=1){let n=e.action===`doubleClick`?t+1:1;a(!0,n),a(!1,n)}return!0}case`input.wheel`:{let n=bj(e.x,t.width),r=bj(e.y,t.height);return Ze({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:e.deltaX,vertical:e.deltaY,stopHorizontal:!1,stopVertical:!1,modifiers:e.modifiers??0}),Ze({type:`input.pointer.scroll`,targetId:e.targetId,x:n,y:r,width:t.width,height:t.height,horizontal:0,vertical:0,stopHorizontal:e.deltaX!==0,stopVertical:e.deltaY!==0,modifiers:e.modifiers??0})}case`input.key`:{if(e.action===`char`)return e.text?Ze({type:`input.keyboard.text`,targetId:e.targetId,text:e.text}):!1;let t=Tg[e.code??``];if(!t)return!1;let n=e.windowsVirtualKeyCode??Ng(e.code,e.key);return Ze({type:`input.keyboard.key`,targetId:e.targetId,keycode:t,pressed:e.action===`down`,key:e.key,code:e.code,text:e.text,unmodifiedText:e.unmodifiedText,modifiers:e.modifiers??0,windowsVirtualKeyCode:n,nativeVirtualKeyCode:e.nativeVirtualKeyCode??n,location:e.location??0,autoRepeat:e.autoRepeat??!1,isKeypad:e.isKeypad??!1})}case`clipboard.copy`:return xj(Ze,e.targetId,`KeyC`);case`clipboard.cut`:return xj(Ze,e.targetId,`KeyX`);case`clipboard.paste`:{let t=e.items.find(e=>e.mimeType===`text/plain`);return t?Ze({type:`input.keyboard.text`,targetId:e.targetId,text:t.data}):!1}default:return e}},[s,Ze]),$e=we===Se&&Se!==``,et=Oe.find(e=>e.clientId===Se)?.followingClientId??null;return sj(()=>$e?If(lj).pipe(xf(F(()=>{_.current===v.current&&Fe({type:`input.heartbeat`})})),ip):void 0,[$e,Fe]),{phase:re,targets:ae,activeTargetId:se,frames:f,mediaStream:le,mediaSize:ue,transport:fe,presentation:D,mediaSwitching:me||ge,recordings:ye,viewportOwnership:O,sendBrowserInput:Qe,selectTarget:He,requestSelectTarget:Ve,command:Re,request:ze,selectPresentation:Ue,reconnect:()=>{let e=g.current;e&&l.runSync(e.reconnect)},collaboration:{phase:re===`error`?`disconnected`:re,role:s,clientId:Se,holderClientId:we,leaseMode:Ee,hasControl:$e,canRequestControl:s!==`viewer`&&re===`connected`,lastError:Me,participants:Oe,cursors:Ae,paintEvents:p,followingClientId:et,claim:We,release:Ge,setActiveTarget:Ke,follow:qe,sendCursor:Je,sendPaintPoint:Ye,clearCursor:Xe,sendInput:Qe}}}var hj=LS(IC(G({name:H.check(wC(1),EC(48)),avatarHash:H.check(mC(/^[0-9a-f]{32}$/))})),Gk);function gj(e){let t=_j();return e?.trim()?{...t,name:Array.from(e.trim()).slice(0,48).join(``)}:t}function _j(){let e=`aperture.collaboration.identity`;try{let t=window.localStorage.getItem(e);if(t){let e=hj(t);if(lr(e))return e.value}let n=vj();return window.localStorage.setItem(e,JSON.stringify(n)),n}catch{return vj()}}function vj(){let e=[`Amber`,`Brisk`,`Calm`,`Clever`,`Misty`,`Quiet`,`Swift`,`Warm`],t=[`Badger`,`Falcon`,`Fox`,`Koala`,`Otter`,`Panda`,`Raven`,`Tiger`],n=new Uint8Array(18);return crypto.getRandomValues(n),{name:`${e[(n.at(0)??0)%e.length]??`Quiet`} ${t[(n.at(1)??0)%t.length]??`Otter`}`,avatarHash:Array.from(n.slice(2),e=>e.toString(16).padStart(2,`0`)).join(``)}}function yj(e,t){let n=e.find(e=>e.id===t)?.viewport;return n?{width:n.width,height:n.height,canvasWidth:n.canvasWidth,canvasHeight:n.canvasHeight,deviceScaleFactor:n.deviceScaleFactor}:null}function bj(e,t){return t<=1?0:Math.min(1,Math.max(0,e/t))}function xj(e,t,n){let r=Tg.ControlLeft,i=Tg[n];if(!r||!i)return!1;let a=Ng(`ControlLeft`,`Control`),o=n===`KeyC`?`c`:`x`,s=Ng(n,o);return e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!0,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!0,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:i,pressed:!1,key:o,code:n,windowsVirtualKeyCode:s,nativeVirtualKeyCode:s,modifiers:2}),e({type:`input.keyboard.key`,targetId:t,keycode:r,pressed:!1,key:`Control`,code:`ControlLeft`,windowsVirtualKeyCode:a,nativeVirtualKeyCode:a,modifiers:0})}var Sj=[`#f43f5e`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#8b5cf6`],Cj=4,wj=24,Tj=2048,Ej=512;function Dj({collaboration:e,targetId:t,enabled:n,visible:r,left:i,top:a,width:o,height:s}){let c=(0,$.useRef)(null),l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(0),f=(0,$.useRef)(new Map),p=Aj(e.clientId);sj(()=>{let n=c.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=Math.max(1,Math.round(o*r)),n.height=Math.max(1,Math.round(s*r));let i=n.getContext(`2d`);if(!i)return;let a=null,l=new Set(e.participants.map(e=>e.clientId)),u=Date.now();for(let[e,t]of f.current)!t.ended&&!l.has(t.clientId)&&f.current.set(e,{...t,updatedAt:u,ended:!0});let d=()=>{a=null,i.setTransform(r,0,0,r,0,0),i.clearRect(0,0,o,s);let e=Date.now(),n=0;for(let[r,a]of f.current){let c=e-a.updatedAt;if(a.ended&&c>=7e3){f.current.delete(r);continue}if(a.ended&&(n+=1),a.targetId!==t||a.points.length===0)continue;let l=a.ended?1-c/fj:1;i.globalAlpha=l,i.strokeStyle=a.color,i.fillStyle=a.color,i.lineWidth=a.width,i.lineCap=`round`,i.lineJoin=`round`;let u=a.points[0];if(!u)continue;if(a.points.length===1){i.beginPath(),i.arc(u.x*o,u.y*s,a.width/2,0,Math.PI*2),i.fill();continue}i.beginPath(),i.moveTo(u.x*o,u.y*s);for(let e=1;e<a.points.length-1;e+=1){let t=a.points[e],n=a.points[e+1];!t||!n||i.quadraticCurveTo(t.x*o,t.y*s,(t.x+n.x)/2*o,(t.y+n.y)/2*s)}let d=a.points[a.points.length-1];d&&i.lineTo(d.x*o,d.y*s),i.stroke()}i.globalAlpha=1,n>0&&(a=window.requestAnimationFrame(d))},p=()=>{a===null&&(a=window.requestAnimationFrame(d))},m=e=>{if(e.type===`clear`){f.current.clear(),p();return}let t=e.message,n=`${t.clientId}:${t.targetId}:${t.strokeId}`,r=f.current.get(n);if(t.phase!==`start`&&!r||r?.ended&&t.phase!==`start`)return;let i=Date.now();if(t.phase===`start`)for(let[e,n]of f.current)!n.ended&&n.clientId===t.clientId&&f.current.set(e,{...n,updatedAt:i,ended:!0});let a=t.phase===`start`||!r?[{x:t.x,y:t.y}]:[...r.points,{x:t.x,y:t.y}];if(a.length>Tj&&(a=a.filter((e,t)=>t%2==0)),!r&&f.current.size>=Ej){let e=null,t=1/0;for(let[n,r]of f.current)r.ended&&r.updatedAt<t&&(e=n,t=r.updatedAt);e&&f.current.delete(e)}f.current.set(n,{clientId:t.clientId,targetId:t.targetId,color:t.color,width:t.width,points:a,updatedAt:i,ended:t.phase===`end`}),p()};return d(),xg(e.paintEvents,e=>F(()=>m(e))).pipe(Xf(F(()=>{a!==null&&window.cancelAnimationFrame(a)})))},[e.paintEvents,e.participants,s,t,o]),(0,$.useEffect)(()=>{l.current=null,u.current=null},[n,t]);function m(n,r){let i=l.current,a=Oj(n);!i||!a||e.sendPaintPoint({targetId:t,strokeId:i,color:p,width:Cj,phase:r,x:a.x,y:a.y})}function h(n){if(kj(n),!n.isPrimary||n.button!==0||u.current!==null)return;n.currentTarget.focus(),l.current=crypto.randomUUID(),u.current=n.pointerId,d.current=performance.now();try{n.currentTarget.setPointerCapture(n.pointerId)}catch{}let r=Oj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),m(n,`start`)}function g(n){if(kj(n),u.current!==null&&n.pointerId!==u.current)return;let r=Oj(n);r&&e.sendCursor(t,r.x*o,r.y*s,{width:o,height:s}),!(!l.current||performance.now()-d.current<wj)&&(d.current=performance.now(),m(n,`move`))}function _(e){kj(e),!(!l.current||u.current!==e.pointerId)&&(m(e,`end`),l.current=null,u.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))}return(0,tj.jsx)(`canvas`,{ref:c,tabIndex:-1,style:{position:`absolute`,zIndex:20,touchAction:`none`,cursor:n?`crosshair`:void 0,pointerEvents:n?void 0:`none`,visibility:r?void 0:`hidden`,left:i,top:a,width:o,height:s},"aria-label":`Shared drawing overlay`,onPointerDown:h,onPointerMove:g,onPointerUp:_,onPointerCancel:_,onWheel:kj,onContextMenu:kj})}function Oj(e){let t=e.currentTarget.getBoundingClientRect();return t.width===0||t.height===0?null:{x:Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)),y:Math.max(0,Math.min(1,(e.clientY-t.top)/t.height))}}function kj(e){e.preventDefault(),e.stopPropagation()}function Aj(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)>>>0;return Sj[t%Sj.length]??`#f43f5e`}var jj=500,Mj=5;function Nj({control:e,viewport:t=e.viewport,localCursorEnabled:n=!0,paintingEnabled:r=!1,onPaintingEnabledChange:i,onNotice:a,className:o,style:s,renderOverlay:c}){let l=(0,$.useRef)(null),u=(0,$.useRef)(null),d=(0,$.useRef)(null),f=(0,$.useRef)({decodingFrame:null,generation:0,pending:null}),p=(0,$.useRef)(null),m=(0,$.useRef)(new Map),h=(0,$.useRef)(new Set),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(!1),y=(0,$.useRef)(null),b=(0,$.useRef)(null),[x,ee]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[te,ne]=(0,$.useState)(null),w=e.mediaPath===`webrtc-live`&&e.mediaPhase===`live`&&!!e.mediaStream&&!!e.activeTargetId,T=w&&(e.mediaSwitching||e.mediaTargetId!==e.activeTargetId||te?.stream!==e.mediaStream||te?.targetId!==e.activeTargetId),re=r&&(w||S!==null)&&e.collaboration.phase===`connected`&&!e.mediaSwitching&&!T,ie=r||e.mediaSwitching||T||e.collaboration.phase!==`connected`||e.collaboration.role===`viewer`,ae=T&&te?te.size:e.mediaSize,oe=w?ae?.width??t.width:S?.width??t.width,se=w?ae?.height??t.height:S?.height??t.height,ce=w?oe:t.width,le=w?se:t.height,E=w?Math.min(ae?.canvasWidth??oe,Math.round(oe*(ae?.deviceScaleFactor??1))):oe,ue=w?Math.min(ae?.canvasHeight??se,Math.round(se*(ae?.deviceScaleFactor??1))):se,de=dA(e.browserViewportSize?.width??oe,e.browserViewportSize?.height??se,oe,se),fe=Pj(e.phase),pe=Fj(e.collaboration),me=fe??pe,he=me?y.current??x:null,ge=e.collaboration.followingClientId?e.collaboration.participants.find(t=>t.clientId===e.collaboration.followingClientId):null,_e=ge?e.collaboration.cursors.get(ge.clientId):null,D=_e?.targetId===e.activeTargetId?{x:de.offsetX+_e.x*de.renderedWidth,y:de.offsetY+_e.y*de.renderedHeight}:null;(0,$.useEffect)(()=>{e.setInputDimensions({width:ce,height:le})},[e.setInputDimensions,le,ce]);let ve=(0,$.useCallback)(()=>{let t=[...m.current.entries()].reverse();m.current.clear();for(let[n,r]of t)e.sendInput({type:`input.key`,targetId:r.targetId,action:`up`,...r.input,text:void 0,modifiers:0,autoRepeat:!1})&&h.current.add(n)},[e.sendInput]);sj(()=>{let t=t=>{if(!t){u.current?Bj(u.current,f.current):Vj(f.current),p.current!==null&&(p.current=null,C(null));return}if(t.targetId!==e.activeTargetId)return;u.current&&!w?Lj(u.current,f.current,t):f.current.pending=t;let n=p.current;if(n?.width!==t.width||n?.height!==t.height){let e={width:t.width,height:t.height};p.current=e,C(e)}};return xg(e.frames,e=>F(()=>t(e))).pipe(Xf(F(()=>{u.current?Bj(u.current,f.current):Vj(f.current)})))},[e.activeTargetId,e.frames,w]),(0,$.useLayoutEffect)(()=>{let t=f.current,n=e.activeTargetId,r=t.pending?.targetId===n?t.pending:t.decodingFrame?.targetId===n?t.decodingFrame:null,i=u.current;if(i?Bj(i,t):Vj(t),r){t.pending=r;let e={width:r.width,height:r.height};p.current=e,C(e),i&&Rj(i,t)}else p.current!==null&&(p.current=null,C(null))},[e.activeTargetId]),(0,$.useEffect)(()=>{let e=u.current;w||!e||Rj(e,f.current)},[S,w]),(0,$.useEffect)(()=>{d.current&&(d.current.srcObject=w?e.mediaStream:null)},[e.mediaStream,w]),(0,$.useEffect)(()=>{let t=d.current,n=e.mediaStream,r=e.activeTargetId,i=e.mediaSize;if(!w||!t||!n||!r||!i||e.mediaSwitching||e.mediaTargetId!==r||te?.stream===n&&te.targetId===r)return;let a=t.requestVideoFrameCallback(()=>{ne({stream:n,targetId:r,size:i})});return()=>t.cancelVideoFrameCallback(a)},[e.activeTargetId,e.mediaSize,e.mediaStream,e.mediaSwitching,e.mediaTargetId,te,w]),(0,$.useEffect)(()=>{let t=l.current;if(!t)return;let n=(t,n)=>{e.setBrowserViewportSize({width:t,height:n})},r=t.getBoundingClientRect();n(r.width,r.height);let i=new ResizeObserver(e=>{let t=e[0];t&&n(t.contentRect.width,t.contentRect.height)});return i.observe(t),()=>i.disconnect()},[e.setBrowserViewportSize]),(0,$.useEffect)(()=>()=>{_.current?.(),ve()},[ve]),(0,$.useEffect)(()=>{let e=()=>{ve(),xe()},t=()=>{document.visibilityState===`hidden`&&(ve(),xe())};return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,t)}},[ve,e.collaboration]),(0,$.useEffect)(()=>{ie&&(_.current?.(),ve(),xe())},[ie,ve]),(0,$.useEffect)(()=>{r&&(e.setCaptured(!1),v.current=!1),e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&!v.current&&e.collaboration.release()},[e.collaboration.hasControl,e.collaboration.leaseMode,e.collaboration.release,e.setCaptured,r]);function ye(e,t){let n=l.current?.getBoundingClientRect();if(!n)return null;let r=dA(n.width,n.height,oe,se),i=e.clientX-n.left-r.offsetX,a=e.clientY-n.top-r.offsetY;if(!t&&(i<0||a<0||i>r.renderedWidth||a>r.renderedHeight))return null;let o=i/r.scale*(ce/oe),s=a/r.scale*(le/se);return t?{x:Math.round(qj(o,0,Math.max(ce-1,0))),y:Math.round(qj(s,0,Math.max(le-1,0)))}:{x:Math.round(o),y:Math.round(s)}}function be(){return e.phase!==`connected`||!e.activeTargetId||ie?null:(e.captured||e.setCaptured(!0),O(e.activeTargetId),l.current?.focus(),e.activeTargetId)}function O(t){v.current=!0,e.collaboration.hasControl||e.collaboration.claim(t,`implicit`)}function xe(){v.current=!1,e.collaboration.hasControl&&e.collaboration.leaseMode===`implicit`&&e.collaboration.release()}function Se(e){e.preventDefault(),e.stopPropagation()}function Ce(e){e.cancelable&&e.preventDefault(),e.stopPropagation()}function we(){e.phase!==`connected`||ie||(e.setCaptured(!0),e.activeTargetId&&O(e.activeTargetId),l.current?.focus())}function Te(t){Le(t),!(ie||!e.activeTargetId)&&(e.setCaptured(!0),O(e.activeTargetId))}function Ee(){y.current=null,ee(null),e.collaboration.clearCursor(),g.current||(ve(),xe(),e.setCaptured(!1))}function De(){e.captured||we()}function Oe(t){Le(t);let n=ye(t,!1);if(e.activeTargetId&&n?e.collaboration.sendCursor(e.activeTargetId,n.x,n.y,{width:ce,height:le}):n||e.collaboration.clearCursor(),ie||g.current?.pointerId===t.pointerId)return;let r=e.captured&&t.buttons===0?e.activeTargetId:null;r&&n&&(Se(t),e.sendInput({type:`input.mouse`,targetId:r,action:`move`,x:n.x,y:n.y,button:`none`,buttons:0,clickCount:0,modifiers:kg(t.nativeEvent)}))}function ke(t){Le(t);let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;let i=l.current;if(!i)return;let a=Wj(t.button),o=Date.now(),s=Gj(n,a,r,o,b.current);b.current={targetId:n,button:a,point:r,time:o,clickCount:s},Se(t),g.current={pointerId:t.pointerId,targetId:n,button:a,clickCount:s},_.current?.();try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}Me({pointerId:t.pointerId,targetId:n,button:a,clickCount:s,element:i}),e.sendInput({type:`input.mouse`,targetId:n,action:`down`,x:r.x,y:r.y,button:a,buttons:t.buttons,clickCount:s,modifiers:kg(t.nativeEvent)})}function Ae(t){if(ie)return;let n=g.current,r=n?.pointerId===t.pointerId?n.targetId:e.activeTargetId;if(!r)return;let i=ye(t,n?.pointerId===t.pointerId);i&&(Se(t),e.sendInput({type:`input.mouse`,targetId:r,action:`up`,x:i.x,y:i.y,button:n?.button??Wj(t.button),buttons:t.buttons,clickCount:n?.clickCount??1,modifiers:kg(t.nativeEvent)}),n?.pointerId===t.pointerId&&(g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)))}function je(t){let n=g.current;if(n?.pointerId!==t.pointerId)return;let r=ye(t,!0);g.current=null,t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),!(!r||ie)&&(Se(t),e.sendInput({type:`input.mouse`,targetId:n.targetId,action:`up`,x:r.x,y:r.y,button:n.button,buttons:0,clickCount:n.clickCount,modifiers:kg(t.nativeEvent)}))}function Me({pointerId:t,targetId:n,button:r,clickCount:i,element:a}){let o=a=>{if(a.pointerId!==t)return;let o=ye(a,!0);Ce(a),o&&(e.collaboration.sendCursor(n,o.x,o.y,{width:ce,height:le}),e.sendInput({type:`input.mouse`,targetId:n,action:`move`,x:o.x,y:o.y,button:r,buttons:a.buttons||Kj(r),clickCount:i,modifiers:kg(a)}))},s=(a,o)=>{if(a.pointerId!==t)return;let s=ye(a,!0);ye(a,!1)||e.collaboration.clearCursor(),Ce(a),s&&(e.sendInput({type:`input.mouse`,targetId:n,action:`up`,x:s.x,y:s.y,button:r,buttons:0,clickCount:i,modifiers:kg(a)}),o||(b.current={targetId:n,button:r,point:s,time:Date.now(),clickCount:i})),u()},c=e=>s(e,!1),l=e=>s(e,!0),u=()=>{window.removeEventListener(`pointermove`,o,!0),window.removeEventListener(`pointerup`,c,!0),window.removeEventListener(`pointercancel`,l,!0);try{a.hasPointerCapture(t)&&a.releasePointerCapture(t)}catch{}g.current?.pointerId===t&&(g.current=null),_.current===u&&(_.current=null)};_.current=u,window.addEventListener(`pointermove`,o,!0),window.addEventListener(`pointerup`,c,!0),window.addEventListener(`pointercancel`,l,!0)}function Ne(t){let n=be();if(!n)return;let r=ye(t,!1);if(!r)return;Se(t);let i=Jj(t.deltaMode,le);e.sendInput({type:`input.wheel`,targetId:n,x:r.x,y:r.y,deltaX:t.deltaX*i,deltaY:t.deltaY*i,modifiers:kg(t.nativeEvent)})}function Pe(t){if(t.key===`Escape`&&r){t.preventDefault(),t.stopPropagation(),i?.(!1);return}if(t.key===`Escape`){e.captured&&(t.preventDefault(),t.stopPropagation(),e.setCaptured(!1),xe());return}let n=t.code||t.key;if(t.repeat&&h.current.has(n)){t.preventDefault(),t.stopPropagation();return}let o=e.activeTargetId;if(ie||!o||!e.captured&&Zj(l.current)!==l.current&&!l.current?.contains(t.target))return;t.preventDefault(),t.stopPropagation();let s=Uj(t.nativeEvent);if(s===`copy`){e.sendInput({type:`clipboard.copy`,targetId:o});return}if(s===`cut`){e.sendInput({type:`clipboard.cut`,targetId:o});return}if(s===`paste`){Yj(e,a);return}if(!Mg(t.nativeEvent))return;let c=jg(t.nativeEvent,`down`);e.sendInput({type:`input.key`,targetId:o,action:`down`,...c})&&(h.current.delete(n),m.current.set(n,{targetId:o,input:c}))}function Fe(t){let n=t.code||t.key;if(h.current.delete(n)){t.preventDefault(),t.stopPropagation();return}let r=m.current.get(n),i=r?.targetId??e.activeTargetId,a=!ie&&(e.captured||Zj(l.current)===l.current||!!l.current?.contains(t.target));!i||!r&&!a||t.key!==`Escape`&&(t.preventDefault(),t.stopPropagation(),!(!r&&Uj(t.nativeEvent))&&(!r&&!Mg(t.nativeEvent)||e.sendInput({type:`input.key`,targetId:i,action:`up`,...jg(t.nativeEvent,`up`)})&&m.current.delete(n)))}function Ie(t){t.relatedTarget instanceof Node&&t.currentTarget.contains(t.relatedTarget)||(ve(),xe(),e.setCaptured(!1))}function Le(e){let t=l.current?.getBoundingClientRect();if(!t)return;let n={x:e.clientX-t.left,y:e.clientY-t.top};y.current=n,me&&ee(n)}let Re=Xj(e.phase,S!==null,e.mediaPhase,e.mediaPath,w),ze=Hj(e.phase,e.mediaPhase,e.mediaSwitching),Be=pe||Ij(e.collaboration.lastError)?null:e.collaboration.lastError;return(0,tj.jsxs)(`div`,{ref:l,tabIndex:0,onKeyDown:Pe,onKeyUp:Fe,onBlur:Ie,onClick:De,onPointerMove:Oe,onFocus:()=>{!ie&&e.activeTargetId&&O(e.activeTargetId)},onPointerEnter:Te,onPointerLeave:Ee,onPointerDown:ke,onPointerUp:Ae,onPointerCancel:je,onWheel:Ne,onContextMenu:t=>{e.captured&&t.preventDefault()},"aria-busy":T,"aria-disabled":ie,className:o,style:{position:`relative`,display:`flex`,flex:`1 1 0%`,minHeight:0,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,outline:`none`,touchAction:`none`,cursor:n?void 0:`none`,...s},children:[w?(0,tj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,transition:`opacity 150ms`,opacity:T?.75:1,width:de.renderedWidth,height:de.renderedHeight},children:(0,tj.jsx)(`video`,{ref:d,autoPlay:!0,muted:!0,playsInline:!0,"data-viewport-width":oe,"data-viewport-height":se,style:{position:`absolute`,top:0,left:0,maxWidth:`none`,objectFit:`fill`,width:de.renderedWidth*((ae?.canvasWidth??E)/E),height:de.renderedHeight*((ae?.canvasHeight??ue)/ue)}})}):S?(0,tj.jsx)(`div`,{style:{position:`relative`,overflow:`hidden`,background:`black`,width:de.renderedWidth,height:de.renderedHeight},children:(0,tj.jsx)(`img`,{ref:u,alt:``,draggable:!1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`contain`}})}):null,e.activeTargetId?(0,tj.jsx)(Dj,{collaboration:e.collaboration,targetId:e.activeTargetId,enabled:re,visible:!e.mediaSwitching&&!T&&(w||S!==null),left:de.offsetX,top:de.offsetY,width:de.renderedWidth,height:de.renderedHeight}):null,c?.({status:Re,placeholder:w||S?null:ze,cursorHint:me&&he?{text:me,...he}:null,followedCursor:D&&ge?{name:ge.name,...D}:null,collaborationError:Be?.message??null})]})}function Pj(e){return e===`disconnected`||e===`error`?`Session disconnected`:null}function Fj(e){return e.holderClientId!==null&&e.holderClientId!==e.clientId?`Input in use`:e.hasControl?null:e.lastError?.code===`input_busy`||e.lastError?.code===`input_not_owned`?`Input in use`:e.lastError?.code===`input_unavailable`?`Input unavailable`:null}function Ij(e){return e?.code===`input_busy`||e?.code===`input_not_owned`}function Lj(e,t,n){t.pending=n,Rj(e,t)}function Rj(e,t){if(t.decodingFrame!==null||t.pending===null)return;let n=t.pending,r=t.generation;t.pending=null,t.decodingFrame=n,zj(e,n).then(()=>{t.generation===r&&(t.decodingFrame=null,Rj(e,t))})}async function zj(e,t){let n=e.src,r=URL.createObjectURL(t.data);e.src=r;try{await e.decode()}catch{}finally{n.startsWith(`blob:`)&&URL.revokeObjectURL(n),e.src!==r&&URL.revokeObjectURL(r)}}function Bj(e,t){Vj(t);let n=e.src;e.removeAttribute(`src`),n.startsWith(`blob:`)&&URL.revokeObjectURL(n)}function Vj(e){e.generation+=1,e.decodingFrame=null,e.pending=null}function Hj(e,t,n){return e===`connecting`?`connecting`:e===`connected`&&t===`connecting`?`connecting-media`:e===`connected`&&n?`switching`:e===`disconnected`||e===`error`?`disconnected`:`waiting`}function Uj(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.code){case`KeyC`:return`copy`;case`KeyX`:return`cut`;case`KeyV`:return`paste`;default:return null}}function Wj(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function Gj(e,t,n,r,i){return i&&i.targetId===e&&i.button===t&&r-i.time<=jj&&Math.abs(i.point.x-n.x)<=Mj&&Math.abs(i.point.y-n.y)<=Mj?Math.min(i.clickCount+1,3):1}function Kj(e){switch(e){case`left`:return 1;case`right`:return 2;case`middle`:return 4;case`none`:return 0;default:return e}}function qj(e,t,n){return Math.min(Math.max(e,t),n)}function Jj(e,t){return e===WheelEvent.DOM_DELTA_LINE?16:e===WheelEvent.DOM_DELTA_PAGE?t:1}async function Yj(e,t){if(!e.activeTargetId)return;let n=``;try{n=await navigator.clipboard.readText()}catch(e){console.warn(`Clipboard read failed`,e),t?.({level:`error`,message:`Clipboard read failed`});return}n&&e.sendInput({type:`clipboard.paste`,targetId:e.activeTargetId,items:[{mimeType:`text/plain`,data:n}]})}function Xj(e,t,n,r,i){return e===`connected`?n===`live`&&i?`webrtc`:t?r===`websocket-live`?`websocket`:`webrtc`:`offline`:`offline`}function Zj(e){let t=e?.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t.activeElement:null}var Qj=[],$j=`aperture.viewport.auto-size-default`;function eM({access:e,displayName:t,enabled:n=!0,webrtcProducerSupported:r=!1,webrtcIceServers:i=Qj,onNotice:a}){let o=oj(),s=(0,$.useRef)(a);s.current=a;let c=(e,t)=>F(()=>s.current?.({level:e,message:t})),[l,u]=(0,$.useState)(nM),[d,f]=(0,$.useState)(()=>l),p=(0,$.useRef)(d);p.current=d;let m=(0,$.useCallback)(()=>p.current,[]),h=mj({access:e,displayName:t,enabled:n&&e!==null,webrtcSupported:r,iceServers:i,autoSize:m}),g=h.collaboration.role,[_,v]=(0,$.useState)([]),y=(0,$.useMemo)(()=>tM(_,h.targets),[h.targets,_]),b=(0,$.useRef)(h.targets);b.current=h.targets;let x=(0,$.useRef)(h.phase);x.current=h.phase;let[ee,S]=(0,$.useState)(sA),[C,te]=(0,$.useState)(null),[ne,w]=(0,$.useState)(!1),[T,re]=(0,$.useState)(!1),ie=g===`owner`||g===`editor`,ae=(0,$.useMemo)(()=>e===null?null:t=>PA(e,t),[e]),oe=(0,$.useRef)(null),se=(0,$.useRef)(ee),ce=(0,$.useRef)(sA),le=(0,$.useRef)(null);oe.current=h.activeTargetId,se.current=ee,le.current=C,(0,$.useEffect)(()=>{h.phase!==`connected`&&w(!1)},[h.phase]),(0,$.useEffect)(()=>{if(!h.mediaSize)return;let e=se.current;e.width===h.mediaSize.width&&e.height===h.mediaSize.height&&e.deviceScaleFactor===h.mediaSize.deviceScaleFactor||S(rM(h.mediaSize,h.mediaSize.deviceScaleFactor))},[h.mediaSize]);let E=(0,$.useCallback)(t=>!n||e===null?!1:h.sendBrowserInput(t,ce.current),[e,n,h]),ue=(0,$.useCallback)(e=>{h.selectTarget(e)},[h]),de=(0,$.useCallback)((e,t,n)=>{e!==t&&v(r=>{let i=tM(r,b.current).map(e=>e.id),a=i.indexOf(e),o=i.indexOf(t),s=i[a];if(a===-1||o===-1||!s)return r;let c=[...i];c.splice(a,1);let l=n===`after`?o+1:o,u=a<l?l-1:l;return u===a?r:(c.splice(u,0,s),c)})},[]),fe=(0,$.useCallback)(e=>o.runPromise(h.request(`target.create`,{url:e}).pipe(R(e=>e.targetId??null),Df(e=>c(`error`,aM(e,`Tab could not be created`)).pipe(wf(null))))),[h,o]),pe=(0,$.useCallback)((e=`about:blank`)=>{fe(e)},[fe]),me=(0,$.useCallback)(e=>{fe(e.url||`about:blank`).then(t=>{t&&de(t,e.id,`after`)})},[fe,de]),he=(0,$.useCallback)(e=>{h.command(`target.close`,{targetId:e})},[h]),ge=(0,$.useCallback)(e=>{let t=oe.current;t&&h.command(`page.navigate`,{targetId:t,url:e})},[h]),_e=(0,$.useCallback)(e=>{h.command(`page.reload`,{targetId:e})},[h]),D=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.stop-loading`,{targetId:e})},[h]),ve=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-back`,{targetId:e})},[h]),ye=(0,$.useCallback)(()=>{let e=oe.current;e&&h.command(`page.history-forward`,{targetId:e})},[h]),be=h.viewportOwnership,O=(0,$.useRef)(be);O.current=be;let xe=d&&(be===null||be.ownerClientId===h.collaboration.clientId),Se=(0,$.useRef)(xe);Se.current=xe,(0,$.useEffect)(()=>{be!==null&&(p.current=be.autoSize,f(be.autoSize))},[be]);let Ce=cj(e=>h.request(`viewport.set`,e).pipe(Nf),[h.request]),we=(0,$.useCallback)((e,t)=>{S(e);let n=oe.current;if(n===null)return;let r={targetId:n,width:e.width,height:e.height,deviceScaleFactor:e.deviceScaleFactor};t&&O.current!==null?Ce({...r,autoSize:!0}):h.command(`viewport.set`,r)},[h.command,Ce]),Te=(0,$.useCallback)(e=>{p.current!==e&&(p.current=e,f(e),O.current!==null&&h.command(`viewport.auto-size.set`,{enabled:e}))},[h.command]);(0,$.useEffect)(()=>{let e=le.current;xe&&h.phase===`connected`&&h.activeTargetId!==null&&e!==null&&we(rM(e,se.current.deviceScaleFactor),!0)},[we,h.activeTargetId,h.phase,xe]);let Ee=(0,$.useCallback)(e=>{Te(!1),we(e,!1)},[we,Te]),De=(0,$.useCallback)(e=>{let t={width:Math.round(e.width),height:Math.round(e.height)};if(t.width<1||t.height<1)return;let n=le.current;n?.width===t.width&&n.height===t.height||(le.current=t,te(t),Se.current&&we(rM(t,se.current.deviceScaleFactor),!0))},[we]),Oe=(0,$.useCallback)(()=>{let e=le.current;e&&(Te(!1),we(rM(e,se.current.deviceScaleFactor),!1))},[we,Te]),ke=(0,$.useCallback)(()=>{p.current=!0,f(!0),h.command(`viewport.owner.claim`)},[h.command]),Ae=(0,$.useCallback)(e=>{u(e);try{window.localStorage.setItem($j,String(e))}catch{}},[]),je=(e,t)=>e.pipe(Df(e=>c(`error`,aM(e,t))),Xf(F(()=>re(!1)))),Me=cj((e,t,n)=>je(h.request(`recording.start`,{mode:e,targetId:t,...n}),`Recording failed to start`),[h]),Ne=(0,$.useCallback)((e,t)=>{let n=oe.current;!n||!ie||T||(re(!0),Me(e,n,t))},[ie,T,Me]),Pe=cj((e,t)=>je(h.request(`recording.stop`,{recordingId:t}).pipe(xf(NA(e,t)),L(({blob:n,filename:r})=>{let i=h.recordings.find(e=>e.recordingId===t);return iM(n,r??`${e.sessionId}-${i?.targetId??`target`}-${t}.webm`)}),xf(c(`success`,`Recording saved`))),`Recording failed to stop`),[h]),Fe=(0,$.useCallback)(t=>{e===null||T||(re(!0),Pe(e,t))},[e,T,Pe]),Ie=cj(e=>je(h.request(`recording.cancel`,{recordingId:e}).pipe(xf(c(`success`,`Recording stopped`))),`Recording failed to stop`),[h]),Le=(0,$.useCallback)(e=>{T||(re(!0),Ie(e))},[T,Ie]),Re=cj(e=>h.request(`presentation.cursor.set`,{visible:e}).pipe(Df(e=>c(`error`,aM(e,`Remote cursor could not be updated`)))),[h]),ze=(0,$.useCallback)(t=>{e!==null&&Re(t)},[e,Re]),[Be,Ve]=(0,$.useState)(!1),He=(0,$.useRef)(h.command);He.current=h.command,(0,$.useEffect)(()=>{h.phase===`connected`&&ie&&He.current(`automation.pacing.set`,{pacing:Be?`watchable`:`normal`})},[h.phase,ie,Be]);let Ue=cj(e=>h.selectPresentation(e).pipe(Df(e=>c(`error`,aM(e,`Presentation could not be updated`)))),[h]),We=(0,$.useCallback)(t=>!n||e===null||h.mediaSwitching?!1:(Ue(t),!0),[e,n,h.mediaSwitching,Ue]),Ge=(0,$.useCallback)(e=>We({kind:`webrtc`,quality:e}),[We]),Ke=(0,$.useMemo)(()=>{let e=e=>lf(()=>x.current===`connected`?e:I(new FA({message:`the session is not connected`}))),t=(t,n)=>e(h.request(t,n)),n=(t,n={})=>e(lf(()=>{let e=oe.current;return e?h.request(t,{targetId:e,...n}):I(new FA({message:`no tab is active`}))})).pipe(Ef);return{navigate:e=>n(`page.navigate`,{url:e}),historyBack:()=>n(`page.history-back`),historyForward:()=>n(`page.history-forward`),reload:e=>e?t(`page.reload`,{targetId:e}).pipe(Ef):n(`page.reload`),stopLoading:()=>n(`page.stop-loading`),createTarget:(e=`about:blank`)=>t(`target.create`,{url:e}).pipe(R(e=>e.targetId??null)),closeTarget:e=>t(`target.close`,{targetId:e}).pipe(Ef),activateTarget:t=>e(h.requestSelectTarget(t))}},[h.request,h.requestSelectTarget]),qe=(0,$.useMemo)(()=>y.find(e=>e.id===h.activeTargetId)??null,[h.activeTargetId,y]),Je=h.transport===`webrtc`?`webrtc-live`:`websocket-live`,Ye=h.phase===`connected`?`live`:h.phase===`connecting`?`connecting`:h.phase===`error`?`failed`:`idle`;return{phase:h.phase,targets:y,activeTargetId:h.activeTargetId,activeTarget:qe,frames:h.frames,mediaPhase:Ye,mediaStream:h.mediaStream,mediaStreamSettings:h.presentation?.quality??null,mediaVideoProfiles:h.presentation?.profiles??[],mediaSize:h.mediaSize,mediaPath:Je,mediaTargetId:h.activeTargetId,mediaSwitching:h.mediaSwitching,viewport:ee,browserViewportSize:C,viewportAutoSync:d,viewportAutoSizeActive:xe,viewportOwnership:be,viewportAutoSizeDefault:l,captured:ne,recordings:h.recordings,canRecord:ie,loadTargetThumbnail:ae,recordingBusy:T,remoteCursorEnabled:h.presentation?.cursorVisible??!0,watchableAutomation:Be,collaboration:h.collaboration,commands:Ke,setCaptured:w,setInputDimensions:e=>{ce.current=e},setViewport:Ee,setBrowserViewportSize:De,setViewportAutoSync:Te,setViewportToBrowserSize:Oe,setViewportAutoSizeDefault:Ae,takeOverViewport:ke,setWebRTCStreamSettings:Ge,selectMediaStream:We,sendInput:E,activateTarget:ue,reorderTargets:de,createTarget:pe,duplicateTarget:me,closeTarget:he,navigate:ge,reload:_e,stopLoading:D,historyBack:ve,historyForward:ye,startRecording:Ne,stopRecording:Fe,cancelRecording:Le,setRemoteCursorEnabled:ze,setWatchableAutomation:Ve,reconnect:h.reconnect}}function tM(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set,i=[];for(let t of e){let e=n.get(t);e&&(i.push(e),r.add(e.id))}for(let e of t)r.has(e.id)||i.push(e);return i}function nM(){try{return window.localStorage.getItem($j)===`true`}catch{return!1}}function rM(e,t){return lA(e.width,e.height,t)}var iM=(e,t)=>Jf(F(()=>URL.createObjectURL(e)),e=>F(()=>{let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}),e=>F(()=>URL.revokeObjectURL(e)).pipe(Ff(0)));function aM(e,t){return e instanceof Error&&e.message?e.message:t}var oM=`~effect/ManagedRuntime`,sM=(e,t)=>{let n=t?.memoMap??nd(),r=Vu(`sequential`),i=Gu(r,`sequential`),a={onFiberStart:Mp(Gu(r,`parallel`))},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=yf(t=>(s||=up(Sf(ad(e,n,i),e=>F(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),bf(Op(s)))),l={[oM]:oM,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?mp(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return mp(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:lf(()=>(l.contextEffect=gf(`ManagedRuntime disposed`),l.cachedContext=void 0,Ku(l.scope,Ou))),runFork(e,t){return l.cachedContext===void 0?up(cM(l,e),o(t)):dp(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?pp(cM(l,e),o(t)):fp(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?bp(cM(l,e)):xp(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?vp(cM(l,e)):yp(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?gp(cM(l,e),o(t)):_p(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?mp(cM(l,e),o(t)):hp(l.cachedContext)(e,o(t))}};return l};function cM(e,t){return L(e.contextEffect,e=>Uf(t,e))}var lM=(e={})=>sM(pd(TA,Hk.pipe(hd(e.baseUrl?Uk(e.baseUrl):cd),hd(TA)),od(_T,!1)));function uM({baseUrl:e,children:t}){let[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let t=lM({baseUrl:e});return r(t),()=>{r(null),t.dispose()}},[e]),n?(0,tj.jsx)(ij,{runtime:n,baseUrl:e,children:t}):null}function dM(e,t){let n=e.slice(4,40);return!(e.startsWith(`ape_`)||e.startsWith(`apv_`))||e[40]!==`_`||e.length<=41?null:{kind:`direct`,baseUrl:t,sessionId:n,credentials:{kind:`bearer`,token:__(e),authorityType:null,tenantId:null,selectedTenantId:null}}}var fM=[];function pM(e){return e===401||e===403?`denied`:e===410?`expired`:`unavailable`}function mM({access:e,displayName:t,onNotice:n}){let[r,i]=(0,$.useState)({access:null,status:`loading`,browser:null});sj(()=>{if(e!==null)return i({access:e,status:`loading`,browser:null}),MA(e).pipe(zf({onFailure:t=>i({access:e,status:pM(t.status),browser:null}),onSuccess:t=>i(e.kind===`direct`&&t.sessionId!==e.sessionId?{access:e,status:`unavailable`,browser:null}:{access:e,status:`ready`,browser:t})}))},[e]);let a=r.access===e?r.browser:null,o=eM({access:a===null?null:e,displayName:t,webrtcProducerSupported:a?.media.mode===`auto`&&a.media.webrtcProducer,webrtcIceServers:a?.media.iceServers??fM,onNotice:n});return{status:e===null?`invalid`:r.access===e?r.status:`loading`,browser:a,control:o}}function hM(){let e=null;return t=>{let n=t.getAttribute(`token`),r=t.getAttribute(`base-url`);return(e===null||e.token!==n||e.baseUrl!==r)&&(e={token:n,baseUrl:r,access:n===null?null:dM(n,r??void 0)}),e.access}}export{cf as A,pf as C,Kf as D,mp as E,g as F,m as I,f as L,Zd as M,Ta as N,lf as O,lr as P,o as R,I as S,ap as T,IC as _,cj as a,Of as b,FA as c,lA as d,uA as f,VS as g,RS as h,Nj as i,uf as j,F as k,cA as l,LS as m,mM as n,sj as o,gk as p,uM as r,ej as s,hM as t,oA as u,Yf as v,ff as w,Df as x,xf as y,c as z};
|