@wheatley-ai/cli 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -3
- package/dist/cli/chat-state.js +95 -0
- package/dist/cli/chat.js +32 -95
- package/dist/cli/io.js +22 -2
- package/dist/cli/main.js +8 -2
- package/dist/cli/personality.js +81 -0
- package/dist/cli/tui/app.js +159 -0
- package/dist/cli/tui/commands.js +98 -0
- package/dist/cli/tui/controller.js +504 -0
- package/dist/cli/tui/editor.js +125 -0
- package/dist/cli/tui/format.js +32 -0
- package/dist/cli/tui/markdown.js +147 -0
- package/dist/cli/tui/prompt.js +275 -0
- package/dist/cli/tui/run.js +63 -0
- package/dist/cli/tui/transcript.js +89 -0
- package/dist/dashboard/assets/{index-DXzGGAxQ.js → index-DThc2x_d.js} +2 -2
- package/dist/dashboard/assets/{sheet-presentation-DMljN0LW.js → sheet-presentation-CkgiDsTg.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/node_modules/@wheatley-ai/sdk/package.json +1 -1
- package/dist/ops/cli.js +41 -22
- package/dist/ops/command-runner.js +1 -0
- package/dist/ops/install-method.js +189 -0
- package/dist/ops/registry.js +35 -0
- package/dist/ops/update.js +95 -61
- package/package.json +8 -2
package/dist/dashboard/assets/{sheet-presentation-DMljN0LW.js → sheet-presentation-CkgiDsTg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./index-DXzGGAxQ.js";var c=new WeakSet,l=e=>c.has(e);function u(e,t=!1,n){let r=e.defaultView??window,i=e=>n===void 0||!(`pointerId`in e)||e.pointerId===n,a=t=>{i(t)&&(t.preventDefault(),t.stopPropagation(),e.removeEventListener(`click`,a,!0))},o=()=>{e.removeEventListener(`click`,a,!0),e.removeEventListener(`pointerdown`,s,!0),e.removeEventListener(`pointerup`,c,!0),e.removeEventListener(`pointercancel`,c,!0)},s=e=>i(e)&&o(),c=e=>i(e)&&r.setTimeout(o);if(e.addEventListener(`click`,a,!0),e.addEventListener(`pointerdown`,s,!0),!t)return r.setTimeout(o);e.addEventListener(`pointerup`,c,!0),e.addEventListener(`pointercancel`,c,!0)}function d(e){return e.towardMore?!e.atLargest&&e.expandOnScroll?`sheet`:`scroll`:e.scrollAtStart?`sheet`:`scroll`}function f(e,t){return e*t/(1-t)}function p(e){let{extent:t,velocity:n,candidates:r}=e;if(Math.abs(n)<e.minFlingVelocity)return m(r,t);let i=t+f(n,e.rate),a=h(r,t,Math.sign(n)),o=m(r,i);return(n>0?r[o]<=t+.5:r[o]>=t-.5)&&a!==-1&&(o=a),!e.skipSnapPoints&&a!==-1&&(o=n>0?Math.min(o,a):Math.max(o,a)),o}function m(e,t){let n=0;for(let r=1;r<e.length;r++)Math.abs(e[r]-t)<Math.abs(e[n]-t)&&(n=r);return n}function h(e,t,n){if(n>0)return e.findIndex(e=>e>t+.5);for(let n=e.length-1;n>=0;n--)if(e[n]<t-.5)return n;return-1}var g=.55;function _(e,t,n=g){return e<=0?0:(1-1/(e*n/t+1))*t}function v(e,t,n=g){return e<=0?0:(1/(1-Math.min(e/t,.999999))-1)*t/n}function y(e,t,n=g){if(e<=0)return 1;let r=e*n/t+1;return n/(r*r)}function b(e,t,n,r){let i=2*Math.PI/(e*1e3),a=t;return Math.abs(a-1)<1e-6?S(i,n,r):a<1?x(i,a,n,r):C(i,a,n,r)}function x(e,t,n,r){let i=t*e,a=e*Math.sqrt(1-t*t),o=(r+i*n)/a;return{position:e=>Math.exp(-i*e)*(n*Math.cos(a*e)+o*Math.sin(a*e)),velocity:e=>{let t=Math.cos(a*e),r=Math.sin(a*e);return Math.exp(-i*e)*((o*a-i*n)*t-(n*a+i*o)*r)}}}function S(e,t,n){let r=n+e*t;return{position:n=>Math.exp(-e*n)*(t+r*n),velocity:n=>Math.exp(-e*n)*(r-e*(t+r*n))}}function C(e,t,n,r){let i=Math.sqrt(t*t-1),a=-e*(t+i),o=-e*(t-i),s=(r-a*n)/(o-a),c=n-s;return{position:e=>s*Math.exp(o*e)+c*Math.exp(a*e),velocity:e=>s*o*Math.exp(o*e)+c*a*Math.exp(a*e)}}function ee(e,{positionTolerance:t=.5,velocityTolerance:n=.02,step:r=1,limit:i=1e4}={}){for(let a=0;a<=i;a+=r)if(Math.abs(e.position(a))<=t&&Math.abs(e.velocity(a))<=n)return a;return i}function w(e,t,n,r,i=1e3/120){let a=n-t;if(Math.abs(a)<1e-6)return`linear`;let o=[];for(let t=0;t<r;t+=i)o.push(T(1+e.position(t)/a));return o.push(`1`),`linear(${o.join(`, `)})`}function T(e){return String(Math.round(e*1e4)/1e4)}var E=[],D=1;function O(e,t){return{phase:`idle`,extent:e,restingIndex:t}}function k(e,t,n){switch(t.type){case`down`:return j(e,t,n);case`move`:return M(e,t,n);case`up`:return I(e,t,n);case`settled`:return L(e);case`rest`:return R(e,t,n);case`snap-to`:return z(e,t,n);case`nudge`:return B(e,t,n);case`close`:return V(e,n,{targetIndex:-1,motion:A(e,t.time),time:t.time,reason:`imperative`,outcome:{type:`dismiss`,reason:`imperative`}})}}function A(e,t){if(e.phase!==`settling`)return{extent:e.extent,velocity:0};let n=b(e.response,e.dampingRatio,e.from-e.to,e.velocity),r=Math.max(0,t-e.startTime);return{extent:e.to+n.position(r),velocity:n.velocity(r)}}function j(e,t,n){let r=t.pointer===`mouse`?n.physics.mouseSlop:n.physics.touchSlop;if(e.phase===`idle`&&e.restingIndex>=0)return{state:{...e,phase:`pending`,originX:t.x,originY:t.y,slop:r},effects:E};if(e.phase!==`settling`)return{state:e,effects:E};let{extent:i}=A(e,t.time);return{state:{phase:`dragging`,extent:i,restingIndex:e.restingIndex,anchorY:t.y,anchorExtent:U(i,n),lastY:t.y,isScrollingContent:!1},effects:[{type:`move`,extent:i}]}}function M(e,t,n){return e.phase===`pending`?N(e,t,n):e.phase===`scrolling`&&n.contentScroll?n.contentScroll.move(e,t):e.phase===`dragging`?F(e,t,n):{state:e,effects:E}}function N(e,t,n){let r=t.x-e.originX,i=t.y-e.originY;if(Math.max(Math.abs(r),Math.abs(i))<e.slop)return{state:e,effects:E};if(Math.abs(r)>Math.abs(i))return{state:O(e.extent,e.restingIndex),effects:E};let a=n.contentScroll?.claim(e,t,i<0,n);if(a)return{state:a,effects:E};let o={...P(e,e.originY+Math.sign(i)*e.slop),lastY:t.y},s=H(o.anchorExtent+(o.anchorY-t.y),n);return{state:{...o,extent:s},effects:[{type:`move`,extent:s}]}}function P(e,t){return{phase:`dragging`,extent:e.extent,restingIndex:e.restingIndex,anchorY:t,anchorExtent:e.extent,lastY:t,isScrollingContent:!1}}function F(e,t,n){let r=e.lastY-t.y,i=e.isScrollingContent?{anchorY:e.lastY,anchorExtent:e.extent}:e,a=i.anchorExtent+(i.anchorY-t.y),o=n.contentScroll?.drag(e,t,r,a,n);if(o)return o;let s=H(a,n);return{state:{...e,anchorY:i.anchorY,anchorExtent:i.anchorExtent,extent:s,lastY:t.y,isScrollingContent:!1},effects:[{type:`move`,extent:s}]}}function I(e,t,n){if(e.phase===`pending`||e.phase===`scrolling`)return{state:O(e.extent,e.restingIndex),effects:E};if(e.phase!==`dragging`)return{state:e,effects:E};let r=n.contentScroll?.release(e,t,n);if(r)return r;let i=-t.velocity*G(e.extent,n),a=[0,...q(n)],o=n.physics,s={candidates:a,rate:o.projectionRate,minFlingVelocity:o.minFlingVelocity,skipSnapPoints:o.skipSnapPoints},c=p({...s,extent:e.extent,velocity:i}),l={motion:{extent:e.extent,velocity:i},time:t.time,reason:`swipe`};if(n.dismissible)return c>0?V(e,n,{...l,targetIndex:c-1}):V(e,n,{...l,targetIndex:-1,outcome:{type:`dismiss`,reason:`swipe`}});let u=e.anchorExtent+(e.anchorY-e.lastY),d=p({...s,extent:u,velocity:-t.velocity})===0,f=Math.max(0,c-1);return d?V(e,n,{...l,targetIndex:0,outcome:{type:`attempt-dismiss`,reason:`swipe`}}):V(e,n,{...l,targetIndex:f})}function L(e){return e.phase===`settling`?{state:O(e.to,e.targetIndex),effects:E}:{state:e,effects:E}}function R(e,t,n){if(t.extent<1&&n.dismissible)return{state:O(0,-1),effects:[{type:`dismiss`,reason:`swipe`}]};let r=m(q(n),t.extent),i=r===e.restingIndex?[]:[{type:`snap`,id:n.snapPoints[r].id,reason:`swipe`}];return{state:O(t.extent,r),effects:i}}function z(e,t,n){let r=n.snapPoints.findIndex(e=>e.id===t.id);return r===-1||e.phase===`dragging`?{state:e,effects:E}:V(e,n,{targetIndex:r,motion:A(e,t.time),time:t.time,reason:t.reason})}function B(e,t,n){return e.phase!==`idle`||e.restingIndex<0?{state:e,effects:E}:V(e,n,{targetIndex:e.restingIndex,motion:{extent:e.extent,velocity:-D},time:t.time,reason:`imperative`})}function V(e,t,n){let{targetIndex:r,motion:i,time:a,reason:o}=n,s=t.physics,c=r<0?0:t.snapPoints[r].extent,l=Math.abs(i.velocity)>=s.minFlingVelocity?s.momentumDampingRatio:s.dampingRatio,u={phase:`settling`,extent:i.extent,restingIndex:e.restingIndex,targetIndex:r,from:i.extent,to:c,velocity:i.velocity,response:s.response,dampingRatio:l,startTime:a},d=[{type:`settle`,from:i.extent,to:c,velocity:i.velocity,response:s.response,dampingRatio:l}];return r>=0&&r!==e.restingIndex&&d.push({type:`snap`,id:t.snapPoints[r].id,reason:o}),n.outcome&&d.push(n.outcome),{state:u,effects:d}}function H(e,t){let n=K(t),{coefficient:r,dimension:i}=W(t);if(e>n)return n+_(e-n,i,r);if(t.dismissible)return Math.max(0,e);let a=t.snapPoints[0].extent;return e<a?a-_(a-e,i,r):e}function U(e,t){let n=K(t),{coefficient:r,dimension:i}=W(t);if(e>n)return n+v(e-n,i,r);let a=t.snapPoints[0].extent;return!t.dismissible&&e<a?a-v(a-e,i,r):e}function W(e){return{coefficient:e.physics.rubberBand,dimension:e.physics.rubberBandDimension??e.dimension}}function G(e,t){let{coefficient:n,dimension:r}=W(t),i=K(t),a=t.snapPoints[0].extent,o=e>i?e-i:!t.dismissible&&e<a?a-e:0;return o<=0?1:y(v(o,r,n),r,n)}function K(e){return e.snapPoints[e.snapPoints.length-1].extent}function q(e){return e.snapPoints.map(e=>e.extent)}var J=[],te={claim(e,t,n,r){if(t.scroll&&d({towardMore:n,scrollAtStart:t.scroll.atStart,atLargest:e.extent>=K(r)-.5,expandOnScroll:r.expandOnScroll})===`scroll`)return{phase:`scrolling`,extent:e.extent,restingIndex:e.restingIndex,lastY:t.y}},move(e,t){return t.y>e.lastY&&t.scroll?.atStart?{state:P(e,t.y),effects:J}:{state:{...e,lastY:t.y},effects:J}},drag(e,t,n,r,i){let a=t.scroll;if(!a)return;if(e.isScrollingContent&&(n>0?!a.atEnd:!a.atStart)){let r=[{type:`scroll`,delta:n}];return{state:{...e,lastY:t.y},effects:r}}let o=K(i);if(!(n>0&&r>o&&e.extent<=o&&!a.atEnd))return;let s=[{type:`scroll`,delta:r-o}];return e.extent!==o&&s.unshift({type:`move`,extent:o}),{state:{...e,extent:o,anchorY:t.y,anchorExtent:o,lastY:t.y,isScrollingContent:!0},effects:s}},release(e,t,n){if(!e.isScrollingContent)return;let r=n.snapPoints.length-1,i=[{type:`fling-scroll`,velocity:-t.velocity}];return e.restingIndex!==r&&i.push({type:`snap`,id:n.snapPoints[r].id,reason:`swipe`}),{state:O(e.extent,r),effects:i}}},Y={ios:{response:.34,dampingRatio:1,momentumDampingRatio:.88,projectionRate:.99,minFlingVelocity:.5,skipSnapPoints:!0,rubberBand:1.9,rubberBandDimension:24,touchSlop:8,mouseSlop:4,dim:.2,velocityHorizon:70}};function ne(e){return String(e)}function re(e,t){if(typeof e==`number`)return e<=1?e*t.container:e;if(e===`content`)return t.content;let n=parseFloat(e);return e.endsWith(`rem`)?n*t.rootFontSize:e.endsWith(`%`)?n/100*t.container:e.endsWith(`px`)?n:NaN}function X(e,t){let n=e.map((e,n)=>({value:e,index:n,extent:Math.min(re(e,t),t.content)})).filter(e=>e.extent>0).sort((e,t)=>e.extent-t.extent||e.index-t.index),r=[];for(let e of n){let t=ne(e.value),n=r[r.length-1];n&&e.extent-n.extent<1?(n.ids.push(t),e.index>n.index&&Object.assign(n,{id:t,value:e.value,index:e.index}),n.extent=Math.max(n.extent,e.extent)):r.push({id:t,value:e.value,extent:Math.round(e.extent*100)/100,ids:[t],index:e.index})}return r.map(({index:e,...t})=>t)}function Z(e,t){if(t==null)return-1;let n=String(t);return e.findIndex(e=>e.ids.includes(n))}function ie(e,t,n){let r=Z(e,n),i=Z(e,t);return r>=0&&i>=0&&i<=r}function ae(e,t){return r(e,e===`start`||e===`end`?o(t):!1)}var Q=e=>e===`bottom`||e===`top`,oe=e=>e===`bottom`||e===`right`?1:-1;function $(e,t,n,r){let i=Q(e);return r.y=(i?n:t)*oe(e),r.x=i?t:n,r}function se(e,t){let n=`${Math.round(t*oe(e)*100)/100}px`;return Q(e)?`0 ${n}`:`${n} 0`}function ce(e,t){return Q(t)?e.offsetHeight:e.offsetWidth}function le(e,t,n){let r=ue(e,t,n);if(!r)return null;let{start:i,end:a}=fe(r,n);return{atStart:i,atEnd:a,area:r}}function ue(e,t,n){let r=t.ownerDocument.defaultView;if(!r||!(e instanceof Element)||!t.contains(e))return null;let i=Q(n);for(let n=e;n&&n!==t.parentElement;n=n.parentElement){if(!(i?n.scrollHeight>n.clientHeight+1:n.scrollWidth>n.clientWidth+1)||!(n instanceof HTMLElement))continue;let e=i?r.getComputedStyle(n).overflowY:r.getComputedStyle(n).overflowX;if(/auto|scroll/.test(e))return n}return null}function de(e,t){if(Q(t)){let n=e.scrollHeight-e.clientHeight;return{position:t===`bottom`?e.scrollTop:n-e.scrollTop,max:n}}let n=e.scrollWidth-e.clientWidth,r=Math.abs(e.scrollLeft),i=o(e)?n-r:r;return{position:t===`right`?i:n-i,max:n}}function fe(e,t){let{position:n,max:r}=de(e,t);return{start:n<=.5,end:n>=r-1}}function pe(e,t,n){if(Q(t))e.scrollTop+=t===`bottom`?n:-n;else{let r=t===`right`?n:-n;e.scrollLeft+=o(e)?-r:r}}var me=1e3;function he(e,t){e.requestAnimationFrame(()=>e.requestAnimationFrame(t))}function ge(e){return e===`bottom`?-120:-32}function _e(e,t){let n=[];for(let r=0;r<e.duration;r+=1e3/60)n.push(t(e.extentAt(r)));return n.push(t(e.extentAt(e.duration))),n}function ve(e,t){let r=Object.entries(t).map(([t,r])=>n(e,t,r));return()=>r.forEach(e=>e())}var ye=e=>Math.max(0,Math.min(1,e));function be(e,t,n=-1){let r=n<0?0:t[n],i=n<0?t[0]:t[n+1];return i===void 0||i<=r?+(e>r):ye((e-r)/(i-r))}function xe(e,t){let n=t[t.length-1],r=t.length>1?t[t.length-2]:0;return n<=r?+(e>=n):ye((e-r)/(n-r))}function Se(e,t){let n=t[t.length-1];return n>0?ye(e/n):0}var Ce=1e3/60,we=[`--drawer-progress`,`--drawer-dim`,`--drawer-expand`,`--drawer-stack`],Te=new WeakSet;function Ee(e){let t=e.defaultView?.CSS;if(!Te.has(e)&&t?.registerProperty){Te.add(e);for(let e of we)try{t.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:`0`})}catch{}}}function De(){typeof document<`u`&&!Te.has(document)&&a(()=>Ee(document))}var Oe=()=>typeof CSS<`u`&&CSS.supports(`animation-timing-function`,`linear(0, 1)`),ke=e=>Math.round(e*1e4)/1e4;function Ae(e){Ee(e.sheet.ownerDocument);let t=[1],n=-1,r=[],i=new Map,a={dim:0,progress:0,expand:0},o;function s(e){t=e.snapExtents.length?e.snapExtents:[1],n=e.undimmedIndex}function c(e,r=a){return r.dim=ke(be(e,t,n)),r.progress=ke(Se(e,t)),r.expand=ke(xe(e,t)),r}let l=!1;function u(t,{rest:n=!1}={}){if(!l){x(),c(t),d(a.dim),m(e.sheet,a),p(a.progress);for(let t of e.outlets())m(t.el,a),t.keyframes&&h(t,a.expand,n);n&&e.themeColor?.(a.dim)}}function d(t){let n=e.backdrop();n&&(n.style.opacity=String(t));let r=f();r&&(r.currentTime=t*1e3)}function f(){return!e.dimmed||o||(o=e.dimmed.animate({opacity:[0,1]},{...je,duration:1e3,fill:`both`}),o.pause(),o.currentTime=0),o}function p(t){let n=e.ancestors();for(let e=0;e<n.length;e++)n[e].style.setProperty(`--drawer-stack`,String(e+t))}function m(e,{dim:t,progress:n,expand:r}){e.style.setProperty(`--drawer-progress`,String(n)),e.style.setProperty(`--drawer-dim`,String(t)),e.style.setProperty(`--drawer-expand`,String(r))}function h(e,t,n){let r=i.get(e.el);r||(r=e.el.animate(Ne(e.keyframes),{duration:1e3,fill:`both`}),r.pause(),i.set(e.el,r)),r.currentTime=t*1e3,n&&(r.commitStyles?.(),r.cancel(),i.delete(e.el))}function g(t){if(l)return;if(x(),S(),!Oe())return u(t.type===`settle`?t.extentAt(t.duration):0,{rest:!0});let n=y(t);f();let i=t.type===`settle`?{duration:Math.max(1,t.duration),fill:`both`}:{timeline:t.timeline,fill:`both`},a=(e,n,a,o)=>{let s=e.animate(n,{...i,...o,easing:Me(a)});t.type===`settle`&&(s.startTime=t.startTime),r.push(s)},o=e.backdrop();o&&a(o,{opacity:[0,1]},n.dim),e.dimmed&&a(e.dimmed,{opacity:[0,1]},n.dim,je),_(e.sheet,n,a),e.ancestors().forEach((e,t)=>a(e,{"--drawer-stack":[t,t+1]},n.progress));for(let t of e.outlets())_(t.el,n,a),t.keyframes&&a(t.el,Ne(t.keyframes),n.expand);if(t.type!==`settle`)return;v(t.extentAt(t.duration));let s=r;s[0]&&(s[0].onfinish=()=>r===s&&x())}function _(e,t,n){n(e,{"--drawer-progress":[0,1]},t.progress),n(e,{"--drawer-dim":[0,1]},t.dim),n(e,{"--drawer-expand":[0,1]},t.expand)}function v(t){let n=c(t,{dim:0,progress:0,expand:0});d(n.dim),m(e.sheet,n),p(n.progress);for(let t of e.outlets())if(m(t.el,n),t.keyframes)for(let[e,r]of Object.entries(t.keyframes)){let i=r[n.expand>=.5?r.length-1:0];t.el.style.setProperty(Pe(e),String(i))}e.themeColor?.(n.dim)}function y(e){let t={dim:[],progress:[],expand:[]},n={dim:0,progress:0,expand:0},r=e.type===`settle`?Math.max(2,Math.ceil(e.duration/Ce)+1):61;for(let i=0;i<r;i++){let a=i/(r-1);c(e.type===`settle`?e.extentAt(Math.min(e.duration,i*Ce)):e.extentAt(a),n),t.dim.push(n.dim),t.progress.push(n.progress),t.expand.push(n.expand)}return t}function b(e){for(let t of r)t.startTime=e}function x(){if(r.length){for(let e of r)e.cancel();r=[]}}function S(){for(let e of i.values())e.cancel();i.clear()}function C(){l=!0,x(),S(),e.backdrop()?.style.removeProperty(`opacity`),o?.cancel();for(let t of we.slice(0,3))e.sheet.style.removeProperty(t);for(let t of e.outlets()){for(let e of we.slice(0,3))t.el.style.removeProperty(e);for(let e of Object.keys(t.keyframes??{}))t.el.style.removeProperty(Pe(e))}}return{configure:s,compute:c,apply:u,play:g,sync:b,follow:g,stop:x,destroy:C}}var je={pseudoElement:`::backdrop`};function Me(e){return`linear(${e.map(ke).join(`, `)})`}var Ne=e=>e;function Pe(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}var Fe={horizon:70,staleAfter:40,maxSpeed:8,capacity:20};function Ie(e,t,n=0,r=e.length){let i=r-n;if(i<2)return 0;let a=e[r-1];if(i<4)return Le(e,t,n,r);let o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;for(let i=n;i<r;i++){let n=e[i]-a,r=t[i],m=n*n;o+=1,s+=n,c+=m,l+=m*n,u+=m*m,d+=r,f+=r*n,p+=r*m}let m=o*(c*u-l*l)-s*(s*u-l*c)+c*(s*l-c*c);return Math.abs(m)<1e-9?Le(e,t,n,r):(o*(f*u-l*p)-d*(s*u-l*c)+c*(s*p-f*c))/m}function Le(e,t,n,r){let i=0,a=0,o=r-n;for(let s=n;s<r;s++)i+=e[s]/o,a+=t[s]/o;let s=0,c=0;for(let o=n;o<r;o++){let n=e[o]-i;s+=n*(t[o]-a),c+=n*n}return c>0?s/c:0}function Re(e={}){let{horizon:t,staleAfter:n,maxSpeed:r,capacity:i}={...Fe,...e},a=new Float64Array(i),o=new Float64Array(i),s=new Float64Array(i),c=new Float64Array(i),l=0,u=-1;function d(e,t){l>0&&e<=a[u]||(u=(u+1)%i,a[u]=e,o[u]=t,l=Math.min(l+1,i))}function f(e){if(l<2)return 0;let d=a[u];if(e-d>n)return 0;let f=0;for(let e=l-1;e>=0;e--){let n=(u-e+i)%i;d-a[n]>t||(s[f]=a[n],c[f]=o[n],f++)}let p=Ie(s,c,0,f);return Math.max(-r,Math.min(r,p))}function p(){l=0,u=-1}return{add:d,velocity:f,reset:p}}var ze=.998,Be=`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-drawer-no-drag]`;function Ve(e){let{sheet:n}=e,r=n.ownerDocument,i=r.defaultView??window,a=O(0,-1),o=0,s=null,c=0,f=0,p=null,h=null,g=null,_=null,v=null,y=null,x=null,S=!1,C=!1,T=null,E=null,D=null,A={x:0,y:0},j=Re({horizon:e.config().physics.velocityHorizon}),M=[t(r,`touchstart`,q,{capture:!0,passive:!0}),t(r,`touchmove`,J,{capture:!0,passive:!1}),t(r,`touchend`,Y,{capture:!0,passive:!0}),t(r,`touchcancel`,Y,{capture:!0,passive:!0}),t(n,`pointerdown`,re)],N=!1;function P(t){N||(n.style.translate=se(e.side(),e.size()-t),o=t)}function F(t,n){if(N)return;let r=k(a,t,e.config());a=r.state;let i=`time`in t?t.time:performance.now();for(let e of r.effects)I(e,i,n);let o=a.phase===`dragging`;o!==S&&(S=o,e.onDragChange(S))}function I(t,n,r){switch(t.type){case`move`:p?(B(),P(t.extent),e.onFrame(t.extent)):(s=t.extent,H());return;case`settle`:return L(t,n);case`scroll`:return c+=t.delta,H();case`fling-scroll`:return v&&(_={velocity:t.velocity,startTime:n,startScroll:0,area:v}),H();case`snap`:return E=t.id,e.onSnap(t.id,t.reason,r);case`dismiss`:return t.reason===`swipe`?(g=`swipe`,e.onDismiss(r)):void 0;case`attempt-dismiss`:return e.onDismissAttempt(r)}}function L(t,r){B(),s=null;let i=e.closedExtent(),a=t.from<=0?i:t.from,o=t.to<=0?i:t.to,c=e.reducedMotion()&&(a===i||o===i),l=e.reducedMotion()?z(a,o,c):R(a,o,t);if(P(c?Math.max(o,0):o),Math.abs(o-a)<.5&&t.velocity===0||l.duration===0)return V();let u=e.size(),d=e.side();p=c?n.animate({opacity:a===i?[0,1]:[1,0]},{duration:l.duration,fill:`both`}):Math.abs(o-a)<1||!Oe()?n.animate({translate:_e(l,e=>se(d,u-e))},{duration:l.duration,fill:`backwards`}):n.animate({translate:[se(d,u-a),se(d,u-o)]},{duration:l.duration,easing:l.easing,fill:`backwards`}),c&&(h=p);let f=p;p.onfinish=()=>{p===f&&V()},p.startTime=r,e.onMotion({type:`settle`,extentAt:l.extentAt,startTime:r,duration:l.duration})}function R(e,t,n){let r=b(n.response,n.dampingRatio,e-t,n.velocity),i=ee(r);return{duration:i,easing:w(r,e,t,i),extentAt:e=>t+r.position(e)}}function z(e,t,n){let r=n?150:200,i=e=>1-(1-e)**3;return{duration:r,easing:`cubic-bezier(0.33, 1, 0.68, 1)`,extentAt:n=>e+(t-e)*i(Math.min(1,n/r))}}function B(){p?.cancel(),p=null,h&&=(h.cancel(),null)}function V(){if(B(),F({type:`settled`}),a.phase===`idle`){if(a.restingIndex<0)return g=null,E=null,e.onRest(null);E=e.config().snapPoints[a.restingIndex].id,e.onRest(E)}}function H(){f||=i.requestAnimationFrame(U)}function U(t){f=0,c&&v&&(pe(v,e.side(),c),c=0),_&&W(t),s!==null&&(P(s),s=null,e.onFrame(o))}function W(t){if(!_)return;let n=Math.max(0,t-_.startTime),r=_.velocity*(ze**n-1)/Math.log(ze);pe(_.area,e.side(),r-_.startScroll),_.startScroll=r,Math.abs(_.velocity*ze**n)<.01?_=null:H()}function G(e){return e instanceof Element&&e.closest(Be)!==null}function K(t){let r=le(t,n,e.side());return v=r?.area??null,r&&{atStart:r.atStart,atEnd:r.atEnd}}function q(t){let n=T!==null&&l(T);if(T=null,y||t.touches.length>1||g||n||!e.owns(t.target)||G(t.target))return;let r=t.changedTouches[0];y={id:r.identifier,originX:r.clientX,originY:r.clientY},_=null,j.reset(),$(e.side(),r.clientX,r.clientY,A),j.add(t.timeStamp,A.y),F({type:`down`,time:t.timeStamp,x:A.x,y:A.y,pointer:`touch`},t)}function J(t){let n=ne(t.changedTouches);if(!n)return;$(e.side(),n.clientX,n.clientY,A),j.add(t.timeStamp,A.y);let r=a.phase===`dragging`,i=K(t.target);if(F({type:`move`,time:t.timeStamp,x:A.x,y:A.y,scroll:i},t),a.phase===`pending`)return te(t,n,i);a.phase===`dragging`&&(t.cancelable?t.preventDefault():!r&&v&&(v.style.overscrollBehavior=`none`))}function te(t,n,r){if(!t.cancelable||!y)return;let i=$(e.side(),y.originX,y.originY,{x:0,y:0});if(Math.abs(A.y-i.y)<Math.abs(A.x-i.x))return;let a=e.config().snapPoints.at(-1)?.extent??0;(r?d({towardMore:A.y<i.y,scrollAtStart:r.atStart,atLargest:o>=a-.5,expandOnScroll:e.config().expandOnScroll}):`sheet`)===`sheet`&&t.preventDefault()}function Y(e){if(!ne(e.changedTouches))return;y=null,v&&v.style.removeProperty(`overscroll-behavior`);let t=e.type===`touchcancel`?0:j.velocity(e.timeStamp);F({type:`up`,time:e.timeStamp,velocity:t},e)}function ne(e){if(!y)return null;for(let t=0;t<e.length;t++)if(e[t].identifier===y.id)return e[t];return null}function re(n){if(T=n,n.pointerType===`touch`||n.button!==0||x!==null||g)return;let i=n.target;if(!e.owns(i)||G(i)||!(i instanceof Element)||!e.canMouseDrag(i))return;x=n.pointerId,C=!1,D=a.phase===`settling`&&a.targetIndex>=0?E:null,_=null,j.reset(),$(e.side(),n.clientX,n.clientY,A),j.add(n.timeStamp,A.y),X=[t(r,`pointermove`,Z,{capture:!0}),t(r,`pointerup`,ie,{capture:!0}),t(r,`pointercancel`,ie,{capture:!0})];let o=n.pointerType===`pen`?`pen`:`mouse`;F({type:`down`,time:n.timeStamp,x:A.x,y:A.y,pointer:o},n)}let X=[];function Z(t){if(t.pointerId!==x)return;if(T&&l(T))return ae(t,0,D);let i=t.getCoalescedEvents?.();for(let n of i?.length?i:[t])j.add(n.timeStamp,$(e.side(),n.clientX,n.clientY,A).y);if($(e.side(),t.clientX,t.clientY,A),F({type:`move`,time:t.timeStamp,x:A.x,y:A.y,scroll:K(t.target)},t),!(a.phase!==`dragging`||C)){C=!0,r.getSelection()?.removeAllRanges(),n.style.userSelect=`none`;try{n.setPointerCapture(t.pointerId)}catch{}}}function ie(e){if(e.pointerId===x){if(T&&l(T))return ae(e,0,D);ae(e,e.type===`pointercancel`?0:j.velocity(e.timeStamp))}}function ae(t,i,o=null){x=null,T=null,X.forEach(e=>e()),X=[],n.style.removeProperty(`user-select`);let s=t.timeStamp,c=e.config().snapPoints.findIndex(e=>e.id===o);o!==null&&c>=0?(a=O(a.extent,c),F({type:`snap-to`,time:s,id:o,reason:`imperative`})):F({type:`up`,time:s,velocity:i},t),C&&u(r)}return{open(t,n){g=null,E=t,B();let r=e.config().snapPoints.findIndex(e=>e.id===t);if(!n&&r>=0)return a=O(e.config().snapPoints[r].extent,r),P(a.extent),e.onRest(t);a=O(0,-1),P(e.closedExtent()),F({type:`snap-to`,time:performance.now()+me,id:t,reason:`imperative`});let o=p;o&&he(i,t=>{p===o&&a.phase===`settling`&&(o.startTime=t,a={...a,startTime:t},e.onMotionStart(t))})},close(){let e=g;g=`close`,e||F({type:`close`,time:performance.now()})},snapTo(e,t){g!==`close`&&(g=null,F({type:`snap-to`,time:performance.now(),id:e,reason:t}))},nudge(){!g&&!e.reducedMotion()&&F({type:`nudge`,time:performance.now()})},relayout(t,n){let r=e.config().snapPoints;if(g||E===null||a.phase===`dragging`||a.phase===`pending`)return P(o);let i=r.findIndex(e=>e.id===E),s=r.findIndex(e=>e.id===n),c=i>=0?i:s>=0?s:m(r.map(e=>e.extent),o),{id:l,extent:u}=r[c];if(a.phase===`idle`&&(a=O(o,i),t||Math.abs(u-o)<.5))return a=O(u,c),P(u),t?(l!==E&&I({type:`snap`,id:l,reason:`content-resize`},performance.now()),e.onRest(l)):void 0;F({type:`snap-to`,time:performance.now(),id:l,reason:`content-resize`})},target:()=>g?null:E,isMoving:()=>a.phase!==`idle`,destroy(){N=!0,B(),f&&i.cancelAnimationFrame(f),M.forEach(e=>e()),X.forEach(e=>e()),S&&e.onDragChange(!1);for(let e of[`translate`,`user-select`,`opacity`])n.style.removeProperty(e)}}}var He=120,Ue=24;function We(e){let{sheet:n,host:r}=e,a=n.ownerDocument,o=a.defaultView??window,s=O(0,-1),c=0,l=[],u=null,d=!1,f=!1,p=!1,h=null,g=0,_=0,v=null,y=new Map,x=null,S=ve(r,{inset:`0 0 calc(var(--keyboard-inset, 0px) - 120px) 0`,display:`block`,"overflow-y":`scroll`,"overflow-x":`hidden`,"scroll-snap-type":`y mandatory`,"scrollbar-width":`none`,"overscroll-behavior":`contain`,"pointer-events":`auto`}),C=ve(n,{position:`absolute`,left:`0`,right:`0`}),T=`onscrollend`in r,E=o.ScrollTimeline,D=[t(r,`scroll`,R,{passive:!0}),...T?[t(r,`scrollend`,H)]:[],t(r,`touchstart`,()=>{d=!0,f=!1,u&&!h&&W()},{passive:!0}),t(r,`touchend`,B,{passive:!0}),t(r,`touchcancel`,B,{passive:!0})],A=i()?1:121,j=new IntersectionObserver(U,{root:r,rootMargin:`0px 0px -${A}px 0px`,threshold:0});j.observe(n);let M=()=>e.config().dimension,N=()=>e.config().snapPoints.at(-1)?.extent??0,P=()=>N()+Ue-c,F=()=>Math.min(r.scrollTop+c,N());function I(){let t=e.config();c=t.dismissible?-120:t.snapPoints[0].extent,n.style.top=`${M()-c}px`;for(let e of l)e.remove();let i=t.snapPoints.map(e=>e.extent);l=(t.dismissible?[c,...i]:i).map(e=>L(e-c,`start`)),l.push(L(P()+r.clientHeight-1,`none`)),r.append(...l);for(let e of y.keys())n.contains(e)||y.delete(e);for(let e of Ge(n))y.has(e)||y.set(e,[e.style.getPropertyValue(`overflow-y`),e.style.getPropertyPriority(`overflow-y`)])}function L(e,t){let n=a.createElement(`div`);return n.setAttribute(`aria-hidden`,`true`),n.style.cssText=`position:absolute;left:0;width:1px;height:1px;top:${e}px;scroll-snap-align:${t};pointer-events:none`,n}function R(){u||h||(x&&d&&Math.abs(r.scrollTop-x.offsetTop)>1&&G(),d&&!p&&V(!0),E||(_||=o.requestAnimationFrame(z)),o.clearTimeout(g),!T&&!d&&(g=o.setTimeout(H,He)))}function z(){_=0,e.onFrame(F())}function B(){if(d=!1,V(!1),x){G();let t=e.config().snapPoints;return Y(t[m(t.map(e=>e.extent),F())].id,`swipe`)}!e.config().dismissible&&r.scrollTop<-2&&e.onDismissAttempt(),(f||!T)&&(g=o.setTimeout(H,He)),f=!1}function V(t){p!==t&&(p=t,e.onDragChange(t))}function H(){if(d){f=!0;return}if(u||h)return;let t=e.config(),n=k(s,{type:`rest`,extent:F()},t);s=n.state;for(let t of n.effects)t.type===`snap`&&(v=t.id,e.onSnap(t.id,t.reason));s.restingIndex>=0&&J(t.snapPoints[s.restingIndex].id)}function U(t){t[t.length-1].isIntersecting||u||h||v===null||!e.config().dismissible||(h=`swipe`,v=null,e.onDismiss())}function W(){if(!u)return;let e=Math.max(0,u.extentAt(performance.now()-u.startTime)-c);q(),x=L(e,`start`),r.append(x),r.scrollTop=e,z(),te()}function G(){x?.remove(),x=null}function K(t,i,a,o){q();let s=e.config().physics,l=b(s.response,s.dampingRatio,i-t,0),d=Math.max(1,ee(l)),f=Math.max(c,t);r.scrollTop=f-c;let p=e=>t+l.position(Math.max(0,e)),m=Math.abs(t-i)<.5,h=!m&&!Oe(),g=n.animate({translate:h?_e({duration:d,extentAt:p},e=>`0 ${f-e}px`):[`0 ${f-i}px`,`0 ${f-t}px`]},{duration:d,easing:m||h?`linear`:w(l,i,t,d),fill:`both`});g.startTime=a,u={animation:g,to:t,extentAt:p,startTime:a},e.onMotion({type:`settle`,extentAt:p,startTime:a,duration:d}),g.onfinish=()=>{u?.animation===g&&(u=null,o(),g.cancel())}}function q(){u?.animation.cancel(),u=null}function J(t){let n=e.config(),i=n.snapPoints.findIndex(e=>e.id===t);s=O(n.snapPoints[i].extent,i),v=t,r.style.pointerEvents=e.isInteractive(t)?`none`:`auto`;let a=i===n.snapPoints.length-1;for(let[e,[t,n]]of y)a?e.style.setProperty(`overflow-y`,t,n):e.style.overflowY=`hidden`;e.onRest(t),te()}function te(){if(!E)return;let t=P(),n=new E({source:r,axis:`block`});e.onMotion({type:`timeline`,timeline:n,extentAt:e=>Math.min(N(),e*t+c)})}function Y(t,n){let r=e.config().snapPoints.find(e=>e.id===t);if(!r||h===`close`)return;h=null,t!==v&&(v=t,e.onSnap(t,n));let i=u?u.extentAt(performance.now()-u.startTime):F();K(r.extent,i,performance.now(),()=>J(t))}return{open(t,n){h=null,v=t,I();let i=e.config().snapPoints.find(e=>e.id===t);if(!i)return;if(!n)return r.scrollTop=i.extent-c,J(t);K(i.extent,-120,performance.now()+me,()=>J(t));let a=u;he(o,t=>{a&&u===a&&(a.animation.startTime=t,a.startTime=t,e.onMotionStart(t))})},close(){let t=h;h=`close`,t||(v=null,K(-120,u?u.extentAt(performance.now()-u.startTime):F(),performance.now(),()=>e.onRest(null)))},snapTo:Y,nudge(){if(h||e.reducedMotion()||v===null)return;let t=e.config().snapPoints.find(e=>e.id===v);t&&K(t.extent,t.extent-20,performance.now(),()=>J(t.id))},relayout(t,n){if(h||d)return;let i=e.config().snapPoints,a=i.findIndex(e=>e.id===v),o=i.findIndex(e=>e.id===n),s=a>=0?a:o>=0?o:m(i.map(e=>e.extent),F()),l=c;I();let f=i[s];if(f.id!==v&&(v=f.id,e.onSnap(f.id,`content-resize`)),u){let e=u,t=performance.now();(e.to!==f.extent||c!==l)&&(K(f.extent,e.extentAt(t-e.startTime),Math.max(t,e.startTime),()=>J(f.id)),u=Object.assign(e,u))}else r.scrollTop=f.extent-c,J(f.id)},target:()=>h?null:v,isMoving:()=>!!u||p,destroy(){q(),G(),o.clearTimeout(g),_&&o.cancelAnimationFrame(_),j.disconnect(),D.forEach(e=>e());for(let e of l)e.remove();for(let[e,[t,n]]of y)e.style.setProperty(`overflow-y`,t,n);p&&e.onDragChange(!1),n.style.removeProperty(`top`),C(),S()}}}function Ge(e){let t=e.ownerDocument.defaultView??window;return Array.from(e.querySelectorAll(`*`)).filter(e=>/auto|scroll/.test(t.getComputedStyle(e).overflowY))}function Ke(e){let t=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e);return t?[t[1],t[2],t[3]].map(Number):null}function qe(e,t){let n=Array.from(e.querySelectorAll(`meta[name="theme-color"]`)),r=n.map(e=>e.content),i=r.map(t=>Ke(Je(e,t))),a=-1;function o(e){let o=Math.round(e*t*100)/100;o!==a&&(a=o,n.forEach((e,t)=>{let n=i[t];n&&(e.content=o?`rgb(${n.map(e=>Math.round(e*(1-o))).join(` `)})`:r[t])}))}function s(){n.forEach((e,t)=>e.content=r[t]),a=-1}return{write:o,restore:s}}function Je(e,t){let n=e.createElement(`span`);n.style.color=t,n.style.display=`none`,e.body.append(n);let r=e.defaultView?.getComputedStyle(n).color??t;return n.remove(),r}var Ye=`a[href], button, label, summary, [role="button"], [role="link"], [role="slider"], [tabindex]:not([tabindex="-1"])`,Xe=e=>!e.closest(Ye),Ze=()=>{};function Qe(e){return{side:()=>`bottom`,snapPoints:()=>[`content`],snapPoint:()=>null,dismissible:()=>!0,modalAbove:()=>void 0,driver:()=>`auto`,expandOnScroll:()=>!0,physics:()=>void 0,backdrop:()=>void 0,hostBackdrop:!1,outlets:()=>[],parent:()=>void 0,themeColor:()=>!1,preventEdgeSwipe:()=>!1,canMouseDrag:Xe,onSnap:Ze,onRest:Ze,onDismissAttempt:Ze,onDragChange:Ze,onLayout:Ze,...$e(e)}}function $e(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var et=new WeakSet,tt=new WeakMap;function nt(e){for(let t=e.parent;t;t=t.parent){let e=tt.get(t);if(e)return e}}function rt(e){for(let t=e instanceof Element?e:null;t;){if(et.has(t))return t;let e=t.getRootNode();t=t.parentElement??(e instanceof ShadowRoot?e.host:null)}return null}function it(e,t){let n=e.closest(`[popover]`);return!!n&&n!==t&&t.contains(n)}var at=24;function ot(e,t){let n=t.driver();return n===`auto`?t.modalAbove()===void 0&&t.expandOnScroll()&&!!e.matchMedia?.(`(hover: none) and (pointer: coarse)`).matches:n===`scroll-snap`}var st={duration:250,easing:`cubic-bezier(0.38, 0.7, 0.125, 1)`};function ct(e,n){let r=Qe(n),{host:a}=r,o=e.ownerDocument,c=o.defaultView??window,l=c.matchMedia?.(`(prefers-reduced-motion: reduce)`),u=ae(r.side(),e),d=[],f=0,p,m=Y.ios,h,g,_={snapPoints:[],dimension:0,dismissible:!0,expandOnScroll:!0,physics:m,contentScroll:te},v=u===`bottom`&&ot(c,r);et.add(e);let y=[lt(a,u,e),ut(e)],b=[],x=Ae({sheet:e,backdrop:r.backdrop,dimmed:r.hostBackdrop?a:void 0,outlets:r.outlets,ancestors:()=>b,themeColor:e=>h?.write(e)});function S(){let e=r.physics();return e!==p&&(p=e,m=e?{...Y.ios,...e}:Y.ios),_.physics=m,_.dismissible=r.dismissible(),_.expandOnScroll=r.expandOnScroll(),_}let C=!1;function ee(){C=!0;let t=ae(r.side(),e);t!==u&&(u=t,y[0](),y[0]=lt(a,u,e));let n=(Q(u)?a.clientHeight:a.clientWidth)-(v?120:0);M??=c.visualViewport?.height,f=ce(e,u);let i=parseFloat(c.getComputedStyle(o.documentElement).fontSize)||16,s=X(r.snapPoints(),{container:n,content:f,rootFontSize:i});s.length||s.push({id:`content`,value:`content`,extent:f,ids:[`content`]});let l=n!==_.dimension||s.length!==d.length||s.some((e,t)=>e.id!==d[t].id||Math.abs(e.extent-d[t].extent)>=.5);return d=s,_.dimension=n,_.snapPoints=d.map(({id:e,extent:t})=>({id:e,extent:t})),x.configure({snapExtents:_.snapPoints.map(e=>e.extent),undimmedIndex:Z(d,r.modalAbove())}),l&&O(),l}let w=!1,T=e=>e===null?null:d.find(t=>t.id===e)?.value??null,E={sheet:e,host:a,side:()=>u,config:S,size:()=>f,closedExtent:()=>ge(u),reducedMotion:()=>!!l?.matches,owns:t=>rt(t)===e,canMouseDrag:r.canMouseDrag,onSnap:(e,t,n)=>{let i=T(e);i!==null&&r.onSnap(i,t,n)},onRest(e){if(w)return;let t=d.find(t=>t.id===e);x.apply(t?.extent??ge(u),{rest:!0}),r.onRest(T(e)),R&&e!==null&&B(),R=!1},onDismiss:r.onDismiss,onDismissAttempt:r.onDismissAttempt,onDragChange:r.onDragChange,isInteractive:e=>U.isInteractiveAt(T(e)),onFrame:e=>w||x.apply(e),onMotion:e=>w||x.play(e),onMotionStart:e=>w||x.sync(e)},D=!0;function O(){if(!D)return r.onLayout({side:u,snapPoints:d});queueMicrotask(()=>w||r.onLayout({side:u,snapPoints:d}))}S();let k=v?We(E):Ve(E);e.setAttribute(`data-driver`,v?`scroll-snap`:`pointer`),D=!1;let A=new ResizeObserver(()=>{V(!1)});A.observe(e),A.observe(a);let j=0,M,N=null,P=[s(a,{before:()=>j=e.getBoundingClientRect().top,after:F}),...r.preventEdgeSwipe()?[t(o,`touchstart`,I,{capture:!0,passive:!1})]:[],...i()?[t(o,`touchend`,L,{capture:!0,passive:!1})]:[],t(e,`focusin`,z)];function F(){V(!0),B();let t=c.visualViewport?.height;if(t===M)return;M=t,N?.cancel(),N=null;let n=j-e.getBoundingClientRect().top;Math.abs(n)<1||l?.matches||(N=a.animate({translate:[`0 ${n}px`,`0 0`]},st))}function I(e){if(!e.cancelable)return;let t=e.touches[0];if(!t||t.clientX>at&&t.clientX<c.innerWidth-at)return;let n=e.target;n&&(a.contains(n)||r.backdrop()?.contains(n))&&e.preventDefault()}function L(t){let n=t.target;(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&e.contains(n)&&n!==o.activeElement&&!k.isMoving()&&t.cancelable&&(t.preventDefault(),n.focus({preventScroll:!0}))}let R=!1;function z(){k.isMoving()?R=!0:B()}function B(){let t=o.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t)||t===e||it(t,e))return;let n=ue(t,e,`bottom`);if(!n)return;let r=c.visualViewport,i=Math.min(n.getBoundingClientRect().bottom,r?r.offsetTop+r.height:c.innerHeight),{top:a,bottom:s}=t.getBoundingClientRect(),u=n.getBoundingClientRect().top,d=s+16>i?s+16-i:a-16<u?a-16-u:0;d&&n.scrollBy({top:d,behavior:l?.matches?`instant`:`smooth`})}function V(e){let t=!C;ee()&&!t&&k.relayout(e,d[Z(d,r.snapPoint())]?.id)}function H(e){let t=Z(d,e);return d[t>=0?t:0]?.id}let U={element:e,parent:r.parent,open(e){if(w)return;b=[];for(let e=r.parent();e;e=e.parent())b.push(e.element);ee(),S(),r.themeColor()&&(h??=qe(o,m.dim)),e&&x.apply(ge(u)),g?.();let t=r.backdrop();g=t&&ve(t,{"will-change":`opacity`}),k.open(H(r.snapPoint()),e)},close:()=>w||k.close(),snapTo(e,t){let n=Z(d,e);n>=0&&d[n].id!==k.target()&&k.snapTo(d[n].id,t)},nudge:()=>k.nudge(),snapPoints:()=>d,target:()=>T(k.target()),isInteractiveAt:e=>ie(d,e,r.modalAbove()),refresh(){V(!1)},destroy(){w=!0,A.disconnect(),N?.cancel(),P.forEach(e=>e()),k.destroy(),x.destroy(),g?.(),h?.restore(),y.forEach(e=>e()),e.removeAttribute(`data-driver`),et.delete(e)}};return U}function lt(e,t,n){let r=Q(t),i=r?t===`bottom`:t===`right`!=(n.ownerDocument.defaultView?.getComputedStyle(e).direction===`rtl`);return ve(e,{position:`fixed`,inset:`0 0 var(--keyboard-inset, 0px) 0`,width:`auto`,height:`auto`,"max-width":`none`,"max-height":`none`,margin:`0`,padding:`0`,border:`0`,background:`transparent`,color:`inherit`,overflow:`visible`,display:`flex`,"flex-direction":r?`column`:`row`,"justify-content":i?`flex-end`:`flex-start`,"pointer-events":`none`})}function ut(e){return ve(e,{"pointer-events":`auto`,"overscroll-behavior":`contain`,"will-change":`translate`})}function dt(t){let n=t.getAttribute(`data-slot`);n&&e(t.ownerDocument,`ui-sdk-sheet-${n}`,`@layer ui-sdk { :where([data-slot="${n}"])::backdrop { background: var(--sheet-backdrop, rgb(0 0 0 / 0.2)); pointer-events: auto } }`)}function ft(e,t){let r=[],i=e=>{for(let a of Array.from(e.children))t.includes(a)||(t.some(e=>e&&a.contains(e))?i(a):a instanceof HTMLElement&&r.push(n(a,`display`,`none`)))};return i(e),()=>r.forEach(e=>e())}function pt(e,t,r){let i,a=t.bind(e,{...r,position:void 0,inline:!0,onShow(){let[t,n]=r.drillIn();return t&&(i=ft(t,[e,n])),()=>i?.()},onClose(){i?.(),i=n(e,`display`,`none`)}});return()=>{a(),i?.()}}function mt(e,t,n){if(n.drillIn)return pt(e,t,n);let r=e.parentElement;if(!r)return;dt(r);let i;return t.bind(e,{...n,position:void 0,host:()=>r,onShow(a){let o=ht(e,r,t,n,a);return i=o.sheet,()=>{o.hide(),i=void 0}},onClose:()=>i?.close()})}function ht(e,n,r,i,a){let o=null,s=nt(a),c=!i.backdrop?.(),l=ct(e,{host:n,snapPoints:()=>i.snapPoints??[`content`],snapPoint:()=>o,backdrop:i.backdrop,hostBackdrop:c,dismissible:i.dismissible,onDismissAttempt:i.onDismissAttempt,parent:()=>s?.(),onSnap:e=>o=e,onDismiss(e){r.requestClose(`swipe`,e),requestAnimationFrame(()=>{let e=o??l.snapPoints()[0]?.value;a.active()&&e!==void 0&&l.snapTo(e,`imperative`)})}});tt.set(a,()=>l),i.onSheet?.(l);let u=t(e,`focusin`,e=>{let t=l.snapPoints().at(-1);t&&l.snapPoints().length>1&&e.target.matches(`input, textarea`)&&l.snapTo(t.value,`imperative`)}),d=c?getComputedStyle(e).getPropertyValue(`--sheet-backdrop`):`transparent`;return d&&n.style.setProperty(`--sheet-backdrop`,d),a.active()&&l.open(r.opener()!==`initial`),{sheet:l,hide(){u(),tt.delete(a),l.destroy(),i.onSheet?.(void 0),n.style.removeProperty(`--sheet-backdrop`)}}}export{De as prepareVariables,mt as presentSheet};
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./index-DThc2x_d.js";var c=new WeakSet,l=e=>c.has(e);function u(e,t=!1,n){let r=e.defaultView??window,i=e=>n===void 0||!(`pointerId`in e)||e.pointerId===n,a=t=>{i(t)&&(t.preventDefault(),t.stopPropagation(),e.removeEventListener(`click`,a,!0))},o=()=>{e.removeEventListener(`click`,a,!0),e.removeEventListener(`pointerdown`,s,!0),e.removeEventListener(`pointerup`,c,!0),e.removeEventListener(`pointercancel`,c,!0)},s=e=>i(e)&&o(),c=e=>i(e)&&r.setTimeout(o);if(e.addEventListener(`click`,a,!0),e.addEventListener(`pointerdown`,s,!0),!t)return r.setTimeout(o);e.addEventListener(`pointerup`,c,!0),e.addEventListener(`pointercancel`,c,!0)}function d(e){return e.towardMore?!e.atLargest&&e.expandOnScroll?`sheet`:`scroll`:e.scrollAtStart?`sheet`:`scroll`}function f(e,t){return e*t/(1-t)}function p(e){let{extent:t,velocity:n,candidates:r}=e;if(Math.abs(n)<e.minFlingVelocity)return m(r,t);let i=t+f(n,e.rate),a=h(r,t,Math.sign(n)),o=m(r,i);return(n>0?r[o]<=t+.5:r[o]>=t-.5)&&a!==-1&&(o=a),!e.skipSnapPoints&&a!==-1&&(o=n>0?Math.min(o,a):Math.max(o,a)),o}function m(e,t){let n=0;for(let r=1;r<e.length;r++)Math.abs(e[r]-t)<Math.abs(e[n]-t)&&(n=r);return n}function h(e,t,n){if(n>0)return e.findIndex(e=>e>t+.5);for(let n=e.length-1;n>=0;n--)if(e[n]<t-.5)return n;return-1}var g=.55;function _(e,t,n=g){return e<=0?0:(1-1/(e*n/t+1))*t}function v(e,t,n=g){return e<=0?0:(1/(1-Math.min(e/t,.999999))-1)*t/n}function y(e,t,n=g){if(e<=0)return 1;let r=e*n/t+1;return n/(r*r)}function b(e,t,n,r){let i=2*Math.PI/(e*1e3),a=t;return Math.abs(a-1)<1e-6?S(i,n,r):a<1?x(i,a,n,r):C(i,a,n,r)}function x(e,t,n,r){let i=t*e,a=e*Math.sqrt(1-t*t),o=(r+i*n)/a;return{position:e=>Math.exp(-i*e)*(n*Math.cos(a*e)+o*Math.sin(a*e)),velocity:e=>{let t=Math.cos(a*e),r=Math.sin(a*e);return Math.exp(-i*e)*((o*a-i*n)*t-(n*a+i*o)*r)}}}function S(e,t,n){let r=n+e*t;return{position:n=>Math.exp(-e*n)*(t+r*n),velocity:n=>Math.exp(-e*n)*(r-e*(t+r*n))}}function C(e,t,n,r){let i=Math.sqrt(t*t-1),a=-e*(t+i),o=-e*(t-i),s=(r-a*n)/(o-a),c=n-s;return{position:e=>s*Math.exp(o*e)+c*Math.exp(a*e),velocity:e=>s*o*Math.exp(o*e)+c*a*Math.exp(a*e)}}function ee(e,{positionTolerance:t=.5,velocityTolerance:n=.02,step:r=1,limit:i=1e4}={}){for(let a=0;a<=i;a+=r)if(Math.abs(e.position(a))<=t&&Math.abs(e.velocity(a))<=n)return a;return i}function w(e,t,n,r,i=1e3/120){let a=n-t;if(Math.abs(a)<1e-6)return`linear`;let o=[];for(let t=0;t<r;t+=i)o.push(T(1+e.position(t)/a));return o.push(`1`),`linear(${o.join(`, `)})`}function T(e){return String(Math.round(e*1e4)/1e4)}var E=[],D=1;function O(e,t){return{phase:`idle`,extent:e,restingIndex:t}}function k(e,t,n){switch(t.type){case`down`:return j(e,t,n);case`move`:return M(e,t,n);case`up`:return I(e,t,n);case`settled`:return L(e);case`rest`:return R(e,t,n);case`snap-to`:return z(e,t,n);case`nudge`:return B(e,t,n);case`close`:return V(e,n,{targetIndex:-1,motion:A(e,t.time),time:t.time,reason:`imperative`,outcome:{type:`dismiss`,reason:`imperative`}})}}function A(e,t){if(e.phase!==`settling`)return{extent:e.extent,velocity:0};let n=b(e.response,e.dampingRatio,e.from-e.to,e.velocity),r=Math.max(0,t-e.startTime);return{extent:e.to+n.position(r),velocity:n.velocity(r)}}function j(e,t,n){let r=t.pointer===`mouse`?n.physics.mouseSlop:n.physics.touchSlop;if(e.phase===`idle`&&e.restingIndex>=0)return{state:{...e,phase:`pending`,originX:t.x,originY:t.y,slop:r},effects:E};if(e.phase!==`settling`)return{state:e,effects:E};let{extent:i}=A(e,t.time);return{state:{phase:`dragging`,extent:i,restingIndex:e.restingIndex,anchorY:t.y,anchorExtent:U(i,n),lastY:t.y,isScrollingContent:!1},effects:[{type:`move`,extent:i}]}}function M(e,t,n){return e.phase===`pending`?N(e,t,n):e.phase===`scrolling`&&n.contentScroll?n.contentScroll.move(e,t):e.phase===`dragging`?F(e,t,n):{state:e,effects:E}}function N(e,t,n){let r=t.x-e.originX,i=t.y-e.originY;if(Math.max(Math.abs(r),Math.abs(i))<e.slop)return{state:e,effects:E};if(Math.abs(r)>Math.abs(i))return{state:O(e.extent,e.restingIndex),effects:E};let a=n.contentScroll?.claim(e,t,i<0,n);if(a)return{state:a,effects:E};let o={...P(e,e.originY+Math.sign(i)*e.slop),lastY:t.y},s=H(o.anchorExtent+(o.anchorY-t.y),n);return{state:{...o,extent:s},effects:[{type:`move`,extent:s}]}}function P(e,t){return{phase:`dragging`,extent:e.extent,restingIndex:e.restingIndex,anchorY:t,anchorExtent:e.extent,lastY:t,isScrollingContent:!1}}function F(e,t,n){let r=e.lastY-t.y,i=e.isScrollingContent?{anchorY:e.lastY,anchorExtent:e.extent}:e,a=i.anchorExtent+(i.anchorY-t.y),o=n.contentScroll?.drag(e,t,r,a,n);if(o)return o;let s=H(a,n);return{state:{...e,anchorY:i.anchorY,anchorExtent:i.anchorExtent,extent:s,lastY:t.y,isScrollingContent:!1},effects:[{type:`move`,extent:s}]}}function I(e,t,n){if(e.phase===`pending`||e.phase===`scrolling`)return{state:O(e.extent,e.restingIndex),effects:E};if(e.phase!==`dragging`)return{state:e,effects:E};let r=n.contentScroll?.release(e,t,n);if(r)return r;let i=-t.velocity*G(e.extent,n),a=[0,...q(n)],o=n.physics,s={candidates:a,rate:o.projectionRate,minFlingVelocity:o.minFlingVelocity,skipSnapPoints:o.skipSnapPoints},c=p({...s,extent:e.extent,velocity:i}),l={motion:{extent:e.extent,velocity:i},time:t.time,reason:`swipe`};if(n.dismissible)return c>0?V(e,n,{...l,targetIndex:c-1}):V(e,n,{...l,targetIndex:-1,outcome:{type:`dismiss`,reason:`swipe`}});let u=e.anchorExtent+(e.anchorY-e.lastY),d=p({...s,extent:u,velocity:-t.velocity})===0,f=Math.max(0,c-1);return d?V(e,n,{...l,targetIndex:0,outcome:{type:`attempt-dismiss`,reason:`swipe`}}):V(e,n,{...l,targetIndex:f})}function L(e){return e.phase===`settling`?{state:O(e.to,e.targetIndex),effects:E}:{state:e,effects:E}}function R(e,t,n){if(t.extent<1&&n.dismissible)return{state:O(0,-1),effects:[{type:`dismiss`,reason:`swipe`}]};let r=m(q(n),t.extent),i=r===e.restingIndex?[]:[{type:`snap`,id:n.snapPoints[r].id,reason:`swipe`}];return{state:O(t.extent,r),effects:i}}function z(e,t,n){let r=n.snapPoints.findIndex(e=>e.id===t.id);return r===-1||e.phase===`dragging`?{state:e,effects:E}:V(e,n,{targetIndex:r,motion:A(e,t.time),time:t.time,reason:t.reason})}function B(e,t,n){return e.phase!==`idle`||e.restingIndex<0?{state:e,effects:E}:V(e,n,{targetIndex:e.restingIndex,motion:{extent:e.extent,velocity:-D},time:t.time,reason:`imperative`})}function V(e,t,n){let{targetIndex:r,motion:i,time:a,reason:o}=n,s=t.physics,c=r<0?0:t.snapPoints[r].extent,l=Math.abs(i.velocity)>=s.minFlingVelocity?s.momentumDampingRatio:s.dampingRatio,u={phase:`settling`,extent:i.extent,restingIndex:e.restingIndex,targetIndex:r,from:i.extent,to:c,velocity:i.velocity,response:s.response,dampingRatio:l,startTime:a},d=[{type:`settle`,from:i.extent,to:c,velocity:i.velocity,response:s.response,dampingRatio:l}];return r>=0&&r!==e.restingIndex&&d.push({type:`snap`,id:t.snapPoints[r].id,reason:o}),n.outcome&&d.push(n.outcome),{state:u,effects:d}}function H(e,t){let n=K(t),{coefficient:r,dimension:i}=W(t);if(e>n)return n+_(e-n,i,r);if(t.dismissible)return Math.max(0,e);let a=t.snapPoints[0].extent;return e<a?a-_(a-e,i,r):e}function U(e,t){let n=K(t),{coefficient:r,dimension:i}=W(t);if(e>n)return n+v(e-n,i,r);let a=t.snapPoints[0].extent;return!t.dismissible&&e<a?a-v(a-e,i,r):e}function W(e){return{coefficient:e.physics.rubberBand,dimension:e.physics.rubberBandDimension??e.dimension}}function G(e,t){let{coefficient:n,dimension:r}=W(t),i=K(t),a=t.snapPoints[0].extent,o=e>i?e-i:!t.dismissible&&e<a?a-e:0;return o<=0?1:y(v(o,r,n),r,n)}function K(e){return e.snapPoints[e.snapPoints.length-1].extent}function q(e){return e.snapPoints.map(e=>e.extent)}var J=[],te={claim(e,t,n,r){if(t.scroll&&d({towardMore:n,scrollAtStart:t.scroll.atStart,atLargest:e.extent>=K(r)-.5,expandOnScroll:r.expandOnScroll})===`scroll`)return{phase:`scrolling`,extent:e.extent,restingIndex:e.restingIndex,lastY:t.y}},move(e,t){return t.y>e.lastY&&t.scroll?.atStart?{state:P(e,t.y),effects:J}:{state:{...e,lastY:t.y},effects:J}},drag(e,t,n,r,i){let a=t.scroll;if(!a)return;if(e.isScrollingContent&&(n>0?!a.atEnd:!a.atStart)){let r=[{type:`scroll`,delta:n}];return{state:{...e,lastY:t.y},effects:r}}let o=K(i);if(!(n>0&&r>o&&e.extent<=o&&!a.atEnd))return;let s=[{type:`scroll`,delta:r-o}];return e.extent!==o&&s.unshift({type:`move`,extent:o}),{state:{...e,extent:o,anchorY:t.y,anchorExtent:o,lastY:t.y,isScrollingContent:!0},effects:s}},release(e,t,n){if(!e.isScrollingContent)return;let r=n.snapPoints.length-1,i=[{type:`fling-scroll`,velocity:-t.velocity}];return e.restingIndex!==r&&i.push({type:`snap`,id:n.snapPoints[r].id,reason:`swipe`}),{state:O(e.extent,r),effects:i}}},Y={ios:{response:.34,dampingRatio:1,momentumDampingRatio:.88,projectionRate:.99,minFlingVelocity:.5,skipSnapPoints:!0,rubberBand:1.9,rubberBandDimension:24,touchSlop:8,mouseSlop:4,dim:.2,velocityHorizon:70}};function ne(e){return String(e)}function re(e,t){if(typeof e==`number`)return e<=1?e*t.container:e;if(e===`content`)return t.content;let n=parseFloat(e);return e.endsWith(`rem`)?n*t.rootFontSize:e.endsWith(`%`)?n/100*t.container:e.endsWith(`px`)?n:NaN}function X(e,t){let n=e.map((e,n)=>({value:e,index:n,extent:Math.min(re(e,t),t.content)})).filter(e=>e.extent>0).sort((e,t)=>e.extent-t.extent||e.index-t.index),r=[];for(let e of n){let t=ne(e.value),n=r[r.length-1];n&&e.extent-n.extent<1?(n.ids.push(t),e.index>n.index&&Object.assign(n,{id:t,value:e.value,index:e.index}),n.extent=Math.max(n.extent,e.extent)):r.push({id:t,value:e.value,extent:Math.round(e.extent*100)/100,ids:[t],index:e.index})}return r.map(({index:e,...t})=>t)}function Z(e,t){if(t==null)return-1;let n=String(t);return e.findIndex(e=>e.ids.includes(n))}function ie(e,t,n){let r=Z(e,n),i=Z(e,t);return r>=0&&i>=0&&i<=r}function ae(e,t){return r(e,e===`start`||e===`end`?o(t):!1)}var Q=e=>e===`bottom`||e===`top`,oe=e=>e===`bottom`||e===`right`?1:-1;function $(e,t,n,r){let i=Q(e);return r.y=(i?n:t)*oe(e),r.x=i?t:n,r}function se(e,t){let n=`${Math.round(t*oe(e)*100)/100}px`;return Q(e)?`0 ${n}`:`${n} 0`}function ce(e,t){return Q(t)?e.offsetHeight:e.offsetWidth}function le(e,t,n){let r=ue(e,t,n);if(!r)return null;let{start:i,end:a}=fe(r,n);return{atStart:i,atEnd:a,area:r}}function ue(e,t,n){let r=t.ownerDocument.defaultView;if(!r||!(e instanceof Element)||!t.contains(e))return null;let i=Q(n);for(let n=e;n&&n!==t.parentElement;n=n.parentElement){if(!(i?n.scrollHeight>n.clientHeight+1:n.scrollWidth>n.clientWidth+1)||!(n instanceof HTMLElement))continue;let e=i?r.getComputedStyle(n).overflowY:r.getComputedStyle(n).overflowX;if(/auto|scroll/.test(e))return n}return null}function de(e,t){if(Q(t)){let n=e.scrollHeight-e.clientHeight;return{position:t===`bottom`?e.scrollTop:n-e.scrollTop,max:n}}let n=e.scrollWidth-e.clientWidth,r=Math.abs(e.scrollLeft),i=o(e)?n-r:r;return{position:t===`right`?i:n-i,max:n}}function fe(e,t){let{position:n,max:r}=de(e,t);return{start:n<=.5,end:n>=r-1}}function pe(e,t,n){if(Q(t))e.scrollTop+=t===`bottom`?n:-n;else{let r=t===`right`?n:-n;e.scrollLeft+=o(e)?-r:r}}var me=1e3;function he(e,t){e.requestAnimationFrame(()=>e.requestAnimationFrame(t))}function ge(e){return e===`bottom`?-120:-32}function _e(e,t){let n=[];for(let r=0;r<e.duration;r+=1e3/60)n.push(t(e.extentAt(r)));return n.push(t(e.extentAt(e.duration))),n}function ve(e,t){let r=Object.entries(t).map(([t,r])=>n(e,t,r));return()=>r.forEach(e=>e())}var ye=e=>Math.max(0,Math.min(1,e));function be(e,t,n=-1){let r=n<0?0:t[n],i=n<0?t[0]:t[n+1];return i===void 0||i<=r?+(e>r):ye((e-r)/(i-r))}function xe(e,t){let n=t[t.length-1],r=t.length>1?t[t.length-2]:0;return n<=r?+(e>=n):ye((e-r)/(n-r))}function Se(e,t){let n=t[t.length-1];return n>0?ye(e/n):0}var Ce=1e3/60,we=[`--drawer-progress`,`--drawer-dim`,`--drawer-expand`,`--drawer-stack`],Te=new WeakSet;function Ee(e){let t=e.defaultView?.CSS;if(!Te.has(e)&&t?.registerProperty){Te.add(e);for(let e of we)try{t.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:`0`})}catch{}}}function De(){typeof document<`u`&&!Te.has(document)&&a(()=>Ee(document))}var Oe=()=>typeof CSS<`u`&&CSS.supports(`animation-timing-function`,`linear(0, 1)`),ke=e=>Math.round(e*1e4)/1e4;function Ae(e){Ee(e.sheet.ownerDocument);let t=[1],n=-1,r=[],i=new Map,a={dim:0,progress:0,expand:0},o;function s(e){t=e.snapExtents.length?e.snapExtents:[1],n=e.undimmedIndex}function c(e,r=a){return r.dim=ke(be(e,t,n)),r.progress=ke(Se(e,t)),r.expand=ke(xe(e,t)),r}let l=!1;function u(t,{rest:n=!1}={}){if(!l){x(),c(t),d(a.dim),m(e.sheet,a),p(a.progress);for(let t of e.outlets())m(t.el,a),t.keyframes&&h(t,a.expand,n);n&&e.themeColor?.(a.dim)}}function d(t){let n=e.backdrop();n&&(n.style.opacity=String(t));let r=f();r&&(r.currentTime=t*1e3)}function f(){return!e.dimmed||o||(o=e.dimmed.animate({opacity:[0,1]},{...je,duration:1e3,fill:`both`}),o.pause(),o.currentTime=0),o}function p(t){let n=e.ancestors();for(let e=0;e<n.length;e++)n[e].style.setProperty(`--drawer-stack`,String(e+t))}function m(e,{dim:t,progress:n,expand:r}){e.style.setProperty(`--drawer-progress`,String(n)),e.style.setProperty(`--drawer-dim`,String(t)),e.style.setProperty(`--drawer-expand`,String(r))}function h(e,t,n){let r=i.get(e.el);r||(r=e.el.animate(Ne(e.keyframes),{duration:1e3,fill:`both`}),r.pause(),i.set(e.el,r)),r.currentTime=t*1e3,n&&(r.commitStyles?.(),r.cancel(),i.delete(e.el))}function g(t){if(l)return;if(x(),S(),!Oe())return u(t.type===`settle`?t.extentAt(t.duration):0,{rest:!0});let n=y(t);f();let i=t.type===`settle`?{duration:Math.max(1,t.duration),fill:`both`}:{timeline:t.timeline,fill:`both`},a=(e,n,a,o)=>{let s=e.animate(n,{...i,...o,easing:Me(a)});t.type===`settle`&&(s.startTime=t.startTime),r.push(s)},o=e.backdrop();o&&a(o,{opacity:[0,1]},n.dim),e.dimmed&&a(e.dimmed,{opacity:[0,1]},n.dim,je),_(e.sheet,n,a),e.ancestors().forEach((e,t)=>a(e,{"--drawer-stack":[t,t+1]},n.progress));for(let t of e.outlets())_(t.el,n,a),t.keyframes&&a(t.el,Ne(t.keyframes),n.expand);if(t.type!==`settle`)return;v(t.extentAt(t.duration));let s=r;s[0]&&(s[0].onfinish=()=>r===s&&x())}function _(e,t,n){n(e,{"--drawer-progress":[0,1]},t.progress),n(e,{"--drawer-dim":[0,1]},t.dim),n(e,{"--drawer-expand":[0,1]},t.expand)}function v(t){let n=c(t,{dim:0,progress:0,expand:0});d(n.dim),m(e.sheet,n),p(n.progress);for(let t of e.outlets())if(m(t.el,n),t.keyframes)for(let[e,r]of Object.entries(t.keyframes)){let i=r[n.expand>=.5?r.length-1:0];t.el.style.setProperty(Pe(e),String(i))}e.themeColor?.(n.dim)}function y(e){let t={dim:[],progress:[],expand:[]},n={dim:0,progress:0,expand:0},r=e.type===`settle`?Math.max(2,Math.ceil(e.duration/Ce)+1):61;for(let i=0;i<r;i++){let a=i/(r-1);c(e.type===`settle`?e.extentAt(Math.min(e.duration,i*Ce)):e.extentAt(a),n),t.dim.push(n.dim),t.progress.push(n.progress),t.expand.push(n.expand)}return t}function b(e){for(let t of r)t.startTime=e}function x(){if(r.length){for(let e of r)e.cancel();r=[]}}function S(){for(let e of i.values())e.cancel();i.clear()}function C(){l=!0,x(),S(),e.backdrop()?.style.removeProperty(`opacity`),o?.cancel();for(let t of we.slice(0,3))e.sheet.style.removeProperty(t);for(let t of e.outlets()){for(let e of we.slice(0,3))t.el.style.removeProperty(e);for(let e of Object.keys(t.keyframes??{}))t.el.style.removeProperty(Pe(e))}}return{configure:s,compute:c,apply:u,play:g,sync:b,follow:g,stop:x,destroy:C}}var je={pseudoElement:`::backdrop`};function Me(e){return`linear(${e.map(ke).join(`, `)})`}var Ne=e=>e;function Pe(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}var Fe={horizon:70,staleAfter:40,maxSpeed:8,capacity:20};function Ie(e,t,n=0,r=e.length){let i=r-n;if(i<2)return 0;let a=e[r-1];if(i<4)return Le(e,t,n,r);let o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0;for(let i=n;i<r;i++){let n=e[i]-a,r=t[i],m=n*n;o+=1,s+=n,c+=m,l+=m*n,u+=m*m,d+=r,f+=r*n,p+=r*m}let m=o*(c*u-l*l)-s*(s*u-l*c)+c*(s*l-c*c);return Math.abs(m)<1e-9?Le(e,t,n,r):(o*(f*u-l*p)-d*(s*u-l*c)+c*(s*p-f*c))/m}function Le(e,t,n,r){let i=0,a=0,o=r-n;for(let s=n;s<r;s++)i+=e[s]/o,a+=t[s]/o;let s=0,c=0;for(let o=n;o<r;o++){let n=e[o]-i;s+=n*(t[o]-a),c+=n*n}return c>0?s/c:0}function Re(e={}){let{horizon:t,staleAfter:n,maxSpeed:r,capacity:i}={...Fe,...e},a=new Float64Array(i),o=new Float64Array(i),s=new Float64Array(i),c=new Float64Array(i),l=0,u=-1;function d(e,t){l>0&&e<=a[u]||(u=(u+1)%i,a[u]=e,o[u]=t,l=Math.min(l+1,i))}function f(e){if(l<2)return 0;let d=a[u];if(e-d>n)return 0;let f=0;for(let e=l-1;e>=0;e--){let n=(u-e+i)%i;d-a[n]>t||(s[f]=a[n],c[f]=o[n],f++)}let p=Ie(s,c,0,f);return Math.max(-r,Math.min(r,p))}function p(){l=0,u=-1}return{add:d,velocity:f,reset:p}}var ze=.998,Be=`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-drawer-no-drag]`;function Ve(e){let{sheet:n}=e,r=n.ownerDocument,i=r.defaultView??window,a=O(0,-1),o=0,s=null,c=0,f=0,p=null,h=null,g=null,_=null,v=null,y=null,x=null,S=!1,C=!1,T=null,E=null,D=null,A={x:0,y:0},j=Re({horizon:e.config().physics.velocityHorizon}),M=[t(r,`touchstart`,q,{capture:!0,passive:!0}),t(r,`touchmove`,J,{capture:!0,passive:!1}),t(r,`touchend`,Y,{capture:!0,passive:!0}),t(r,`touchcancel`,Y,{capture:!0,passive:!0}),t(n,`pointerdown`,re)],N=!1;function P(t){N||(n.style.translate=se(e.side(),e.size()-t),o=t)}function F(t,n){if(N)return;let r=k(a,t,e.config());a=r.state;let i=`time`in t?t.time:performance.now();for(let e of r.effects)I(e,i,n);let o=a.phase===`dragging`;o!==S&&(S=o,e.onDragChange(S))}function I(t,n,r){switch(t.type){case`move`:p?(B(),P(t.extent),e.onFrame(t.extent)):(s=t.extent,H());return;case`settle`:return L(t,n);case`scroll`:return c+=t.delta,H();case`fling-scroll`:return v&&(_={velocity:t.velocity,startTime:n,startScroll:0,area:v}),H();case`snap`:return E=t.id,e.onSnap(t.id,t.reason,r);case`dismiss`:return t.reason===`swipe`?(g=`swipe`,e.onDismiss(r)):void 0;case`attempt-dismiss`:return e.onDismissAttempt(r)}}function L(t,r){B(),s=null;let i=e.closedExtent(),a=t.from<=0?i:t.from,o=t.to<=0?i:t.to,c=e.reducedMotion()&&(a===i||o===i),l=e.reducedMotion()?z(a,o,c):R(a,o,t);if(P(c?Math.max(o,0):o),Math.abs(o-a)<.5&&t.velocity===0||l.duration===0)return V();let u=e.size(),d=e.side();p=c?n.animate({opacity:a===i?[0,1]:[1,0]},{duration:l.duration,fill:`both`}):Math.abs(o-a)<1||!Oe()?n.animate({translate:_e(l,e=>se(d,u-e))},{duration:l.duration,fill:`backwards`}):n.animate({translate:[se(d,u-a),se(d,u-o)]},{duration:l.duration,easing:l.easing,fill:`backwards`}),c&&(h=p);let f=p;p.onfinish=()=>{p===f&&V()},p.startTime=r,e.onMotion({type:`settle`,extentAt:l.extentAt,startTime:r,duration:l.duration})}function R(e,t,n){let r=b(n.response,n.dampingRatio,e-t,n.velocity),i=ee(r);return{duration:i,easing:w(r,e,t,i),extentAt:e=>t+r.position(e)}}function z(e,t,n){let r=n?150:200,i=e=>1-(1-e)**3;return{duration:r,easing:`cubic-bezier(0.33, 1, 0.68, 1)`,extentAt:n=>e+(t-e)*i(Math.min(1,n/r))}}function B(){p?.cancel(),p=null,h&&=(h.cancel(),null)}function V(){if(B(),F({type:`settled`}),a.phase===`idle`){if(a.restingIndex<0)return g=null,E=null,e.onRest(null);E=e.config().snapPoints[a.restingIndex].id,e.onRest(E)}}function H(){f||=i.requestAnimationFrame(U)}function U(t){f=0,c&&v&&(pe(v,e.side(),c),c=0),_&&W(t),s!==null&&(P(s),s=null,e.onFrame(o))}function W(t){if(!_)return;let n=Math.max(0,t-_.startTime),r=_.velocity*(ze**n-1)/Math.log(ze);pe(_.area,e.side(),r-_.startScroll),_.startScroll=r,Math.abs(_.velocity*ze**n)<.01?_=null:H()}function G(e){return e instanceof Element&&e.closest(Be)!==null}function K(t){let r=le(t,n,e.side());return v=r?.area??null,r&&{atStart:r.atStart,atEnd:r.atEnd}}function q(t){let n=T!==null&&l(T);if(T=null,y||t.touches.length>1||g||n||!e.owns(t.target)||G(t.target))return;let r=t.changedTouches[0];y={id:r.identifier,originX:r.clientX,originY:r.clientY},_=null,j.reset(),$(e.side(),r.clientX,r.clientY,A),j.add(t.timeStamp,A.y),F({type:`down`,time:t.timeStamp,x:A.x,y:A.y,pointer:`touch`},t)}function J(t){let n=ne(t.changedTouches);if(!n)return;$(e.side(),n.clientX,n.clientY,A),j.add(t.timeStamp,A.y);let r=a.phase===`dragging`,i=K(t.target);if(F({type:`move`,time:t.timeStamp,x:A.x,y:A.y,scroll:i},t),a.phase===`pending`)return te(t,n,i);a.phase===`dragging`&&(t.cancelable?t.preventDefault():!r&&v&&(v.style.overscrollBehavior=`none`))}function te(t,n,r){if(!t.cancelable||!y)return;let i=$(e.side(),y.originX,y.originY,{x:0,y:0});if(Math.abs(A.y-i.y)<Math.abs(A.x-i.x))return;let a=e.config().snapPoints.at(-1)?.extent??0;(r?d({towardMore:A.y<i.y,scrollAtStart:r.atStart,atLargest:o>=a-.5,expandOnScroll:e.config().expandOnScroll}):`sheet`)===`sheet`&&t.preventDefault()}function Y(e){if(!ne(e.changedTouches))return;y=null,v&&v.style.removeProperty(`overscroll-behavior`);let t=e.type===`touchcancel`?0:j.velocity(e.timeStamp);F({type:`up`,time:e.timeStamp,velocity:t},e)}function ne(e){if(!y)return null;for(let t=0;t<e.length;t++)if(e[t].identifier===y.id)return e[t];return null}function re(n){if(T=n,n.pointerType===`touch`||n.button!==0||x!==null||g)return;let i=n.target;if(!e.owns(i)||G(i)||!(i instanceof Element)||!e.canMouseDrag(i))return;x=n.pointerId,C=!1,D=a.phase===`settling`&&a.targetIndex>=0?E:null,_=null,j.reset(),$(e.side(),n.clientX,n.clientY,A),j.add(n.timeStamp,A.y),X=[t(r,`pointermove`,Z,{capture:!0}),t(r,`pointerup`,ie,{capture:!0}),t(r,`pointercancel`,ie,{capture:!0})];let o=n.pointerType===`pen`?`pen`:`mouse`;F({type:`down`,time:n.timeStamp,x:A.x,y:A.y,pointer:o},n)}let X=[];function Z(t){if(t.pointerId!==x)return;if(T&&l(T))return ae(t,0,D);let i=t.getCoalescedEvents?.();for(let n of i?.length?i:[t])j.add(n.timeStamp,$(e.side(),n.clientX,n.clientY,A).y);if($(e.side(),t.clientX,t.clientY,A),F({type:`move`,time:t.timeStamp,x:A.x,y:A.y,scroll:K(t.target)},t),!(a.phase!==`dragging`||C)){C=!0,r.getSelection()?.removeAllRanges(),n.style.userSelect=`none`;try{n.setPointerCapture(t.pointerId)}catch{}}}function ie(e){if(e.pointerId===x){if(T&&l(T))return ae(e,0,D);ae(e,e.type===`pointercancel`?0:j.velocity(e.timeStamp))}}function ae(t,i,o=null){x=null,T=null,X.forEach(e=>e()),X=[],n.style.removeProperty(`user-select`);let s=t.timeStamp,c=e.config().snapPoints.findIndex(e=>e.id===o);o!==null&&c>=0?(a=O(a.extent,c),F({type:`snap-to`,time:s,id:o,reason:`imperative`})):F({type:`up`,time:s,velocity:i},t),C&&u(r)}return{open(t,n){g=null,E=t,B();let r=e.config().snapPoints.findIndex(e=>e.id===t);if(!n&&r>=0)return a=O(e.config().snapPoints[r].extent,r),P(a.extent),e.onRest(t);a=O(0,-1),P(e.closedExtent()),F({type:`snap-to`,time:performance.now()+me,id:t,reason:`imperative`});let o=p;o&&he(i,t=>{p===o&&a.phase===`settling`&&(o.startTime=t,a={...a,startTime:t},e.onMotionStart(t))})},close(){let e=g;g=`close`,e||F({type:`close`,time:performance.now()})},snapTo(e,t){g!==`close`&&(g=null,F({type:`snap-to`,time:performance.now(),id:e,reason:t}))},nudge(){!g&&!e.reducedMotion()&&F({type:`nudge`,time:performance.now()})},relayout(t,n){let r=e.config().snapPoints;if(g||E===null||a.phase===`dragging`||a.phase===`pending`)return P(o);let i=r.findIndex(e=>e.id===E),s=r.findIndex(e=>e.id===n),c=i>=0?i:s>=0?s:m(r.map(e=>e.extent),o),{id:l,extent:u}=r[c];if(a.phase===`idle`&&(a=O(o,i),t||Math.abs(u-o)<.5))return a=O(u,c),P(u),t?(l!==E&&I({type:`snap`,id:l,reason:`content-resize`},performance.now()),e.onRest(l)):void 0;F({type:`snap-to`,time:performance.now(),id:l,reason:`content-resize`})},target:()=>g?null:E,isMoving:()=>a.phase!==`idle`,destroy(){N=!0,B(),f&&i.cancelAnimationFrame(f),M.forEach(e=>e()),X.forEach(e=>e()),S&&e.onDragChange(!1);for(let e of[`translate`,`user-select`,`opacity`])n.style.removeProperty(e)}}}var He=120,Ue=24;function We(e){let{sheet:n,host:r}=e,a=n.ownerDocument,o=a.defaultView??window,s=O(0,-1),c=0,l=[],u=null,d=!1,f=!1,p=!1,h=null,g=0,_=0,v=null,y=new Map,x=null,S=ve(r,{inset:`0 0 calc(var(--keyboard-inset, 0px) - 120px) 0`,display:`block`,"overflow-y":`scroll`,"overflow-x":`hidden`,"scroll-snap-type":`y mandatory`,"scrollbar-width":`none`,"overscroll-behavior":`contain`,"pointer-events":`auto`}),C=ve(n,{position:`absolute`,left:`0`,right:`0`}),T=`onscrollend`in r,E=o.ScrollTimeline,D=[t(r,`scroll`,R,{passive:!0}),...T?[t(r,`scrollend`,H)]:[],t(r,`touchstart`,()=>{d=!0,f=!1,u&&!h&&W()},{passive:!0}),t(r,`touchend`,B,{passive:!0}),t(r,`touchcancel`,B,{passive:!0})],A=i()?1:121,j=new IntersectionObserver(U,{root:r,rootMargin:`0px 0px -${A}px 0px`,threshold:0});j.observe(n);let M=()=>e.config().dimension,N=()=>e.config().snapPoints.at(-1)?.extent??0,P=()=>N()+Ue-c,F=()=>Math.min(r.scrollTop+c,N());function I(){let t=e.config();c=t.dismissible?-120:t.snapPoints[0].extent,n.style.top=`${M()-c}px`;for(let e of l)e.remove();let i=t.snapPoints.map(e=>e.extent);l=(t.dismissible?[c,...i]:i).map(e=>L(e-c,`start`)),l.push(L(P()+r.clientHeight-1,`none`)),r.append(...l);for(let e of y.keys())n.contains(e)||y.delete(e);for(let e of Ge(n))y.has(e)||y.set(e,[e.style.getPropertyValue(`overflow-y`),e.style.getPropertyPriority(`overflow-y`)])}function L(e,t){let n=a.createElement(`div`);return n.setAttribute(`aria-hidden`,`true`),n.style.cssText=`position:absolute;left:0;width:1px;height:1px;top:${e}px;scroll-snap-align:${t};pointer-events:none`,n}function R(){u||h||(x&&d&&Math.abs(r.scrollTop-x.offsetTop)>1&&G(),d&&!p&&V(!0),E||(_||=o.requestAnimationFrame(z)),o.clearTimeout(g),!T&&!d&&(g=o.setTimeout(H,He)))}function z(){_=0,e.onFrame(F())}function B(){if(d=!1,V(!1),x){G();let t=e.config().snapPoints;return Y(t[m(t.map(e=>e.extent),F())].id,`swipe`)}!e.config().dismissible&&r.scrollTop<-2&&e.onDismissAttempt(),(f||!T)&&(g=o.setTimeout(H,He)),f=!1}function V(t){p!==t&&(p=t,e.onDragChange(t))}function H(){if(d){f=!0;return}if(u||h)return;let t=e.config(),n=k(s,{type:`rest`,extent:F()},t);s=n.state;for(let t of n.effects)t.type===`snap`&&(v=t.id,e.onSnap(t.id,t.reason));s.restingIndex>=0&&J(t.snapPoints[s.restingIndex].id)}function U(t){t[t.length-1].isIntersecting||u||h||v===null||!e.config().dismissible||(h=`swipe`,v=null,e.onDismiss())}function W(){if(!u)return;let e=Math.max(0,u.extentAt(performance.now()-u.startTime)-c);q(),x=L(e,`start`),r.append(x),r.scrollTop=e,z(),te()}function G(){x?.remove(),x=null}function K(t,i,a,o){q();let s=e.config().physics,l=b(s.response,s.dampingRatio,i-t,0),d=Math.max(1,ee(l)),f=Math.max(c,t);r.scrollTop=f-c;let p=e=>t+l.position(Math.max(0,e)),m=Math.abs(t-i)<.5,h=!m&&!Oe(),g=n.animate({translate:h?_e({duration:d,extentAt:p},e=>`0 ${f-e}px`):[`0 ${f-i}px`,`0 ${f-t}px`]},{duration:d,easing:m||h?`linear`:w(l,i,t,d),fill:`both`});g.startTime=a,u={animation:g,to:t,extentAt:p,startTime:a},e.onMotion({type:`settle`,extentAt:p,startTime:a,duration:d}),g.onfinish=()=>{u?.animation===g&&(u=null,o(),g.cancel())}}function q(){u?.animation.cancel(),u=null}function J(t){let n=e.config(),i=n.snapPoints.findIndex(e=>e.id===t);s=O(n.snapPoints[i].extent,i),v=t,r.style.pointerEvents=e.isInteractive(t)?`none`:`auto`;let a=i===n.snapPoints.length-1;for(let[e,[t,n]]of y)a?e.style.setProperty(`overflow-y`,t,n):e.style.overflowY=`hidden`;e.onRest(t),te()}function te(){if(!E)return;let t=P(),n=new E({source:r,axis:`block`});e.onMotion({type:`timeline`,timeline:n,extentAt:e=>Math.min(N(),e*t+c)})}function Y(t,n){let r=e.config().snapPoints.find(e=>e.id===t);if(!r||h===`close`)return;h=null,t!==v&&(v=t,e.onSnap(t,n));let i=u?u.extentAt(performance.now()-u.startTime):F();K(r.extent,i,performance.now(),()=>J(t))}return{open(t,n){h=null,v=t,I();let i=e.config().snapPoints.find(e=>e.id===t);if(!i)return;if(!n)return r.scrollTop=i.extent-c,J(t);K(i.extent,-120,performance.now()+me,()=>J(t));let a=u;he(o,t=>{a&&u===a&&(a.animation.startTime=t,a.startTime=t,e.onMotionStart(t))})},close(){let t=h;h=`close`,t||(v=null,K(-120,u?u.extentAt(performance.now()-u.startTime):F(),performance.now(),()=>e.onRest(null)))},snapTo:Y,nudge(){if(h||e.reducedMotion()||v===null)return;let t=e.config().snapPoints.find(e=>e.id===v);t&&K(t.extent,t.extent-20,performance.now(),()=>J(t.id))},relayout(t,n){if(h||d)return;let i=e.config().snapPoints,a=i.findIndex(e=>e.id===v),o=i.findIndex(e=>e.id===n),s=a>=0?a:o>=0?o:m(i.map(e=>e.extent),F()),l=c;I();let f=i[s];if(f.id!==v&&(v=f.id,e.onSnap(f.id,`content-resize`)),u){let e=u,t=performance.now();(e.to!==f.extent||c!==l)&&(K(f.extent,e.extentAt(t-e.startTime),Math.max(t,e.startTime),()=>J(f.id)),u=Object.assign(e,u))}else r.scrollTop=f.extent-c,J(f.id)},target:()=>h?null:v,isMoving:()=>!!u||p,destroy(){q(),G(),o.clearTimeout(g),_&&o.cancelAnimationFrame(_),j.disconnect(),D.forEach(e=>e());for(let e of l)e.remove();for(let[e,[t,n]]of y)e.style.setProperty(`overflow-y`,t,n);p&&e.onDragChange(!1),n.style.removeProperty(`top`),C(),S()}}}function Ge(e){let t=e.ownerDocument.defaultView??window;return Array.from(e.querySelectorAll(`*`)).filter(e=>/auto|scroll/.test(t.getComputedStyle(e).overflowY))}function Ke(e){let t=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e);return t?[t[1],t[2],t[3]].map(Number):null}function qe(e,t){let n=Array.from(e.querySelectorAll(`meta[name="theme-color"]`)),r=n.map(e=>e.content),i=r.map(t=>Ke(Je(e,t))),a=-1;function o(e){let o=Math.round(e*t*100)/100;o!==a&&(a=o,n.forEach((e,t)=>{let n=i[t];n&&(e.content=o?`rgb(${n.map(e=>Math.round(e*(1-o))).join(` `)})`:r[t])}))}function s(){n.forEach((e,t)=>e.content=r[t]),a=-1}return{write:o,restore:s}}function Je(e,t){let n=e.createElement(`span`);n.style.color=t,n.style.display=`none`,e.body.append(n);let r=e.defaultView?.getComputedStyle(n).color??t;return n.remove(),r}var Ye=`a[href], button, label, summary, [role="button"], [role="link"], [role="slider"], [tabindex]:not([tabindex="-1"])`,Xe=e=>!e.closest(Ye),Ze=()=>{};function Qe(e){return{side:()=>`bottom`,snapPoints:()=>[`content`],snapPoint:()=>null,dismissible:()=>!0,modalAbove:()=>void 0,driver:()=>`auto`,expandOnScroll:()=>!0,physics:()=>void 0,backdrop:()=>void 0,hostBackdrop:!1,outlets:()=>[],parent:()=>void 0,themeColor:()=>!1,preventEdgeSwipe:()=>!1,canMouseDrag:Xe,onSnap:Ze,onRest:Ze,onDismissAttempt:Ze,onDragChange:Ze,onLayout:Ze,...$e(e)}}function $e(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var et=new WeakSet,tt=new WeakMap;function nt(e){for(let t=e.parent;t;t=t.parent){let e=tt.get(t);if(e)return e}}function rt(e){for(let t=e instanceof Element?e:null;t;){if(et.has(t))return t;let e=t.getRootNode();t=t.parentElement??(e instanceof ShadowRoot?e.host:null)}return null}function it(e,t){let n=e.closest(`[popover]`);return!!n&&n!==t&&t.contains(n)}var at=24;function ot(e,t){let n=t.driver();return n===`auto`?t.modalAbove()===void 0&&t.expandOnScroll()&&!!e.matchMedia?.(`(hover: none) and (pointer: coarse)`).matches:n===`scroll-snap`}var st={duration:250,easing:`cubic-bezier(0.38, 0.7, 0.125, 1)`};function ct(e,n){let r=Qe(n),{host:a}=r,o=e.ownerDocument,c=o.defaultView??window,l=c.matchMedia?.(`(prefers-reduced-motion: reduce)`),u=ae(r.side(),e),d=[],f=0,p,m=Y.ios,h,g,_={snapPoints:[],dimension:0,dismissible:!0,expandOnScroll:!0,physics:m,contentScroll:te},v=u===`bottom`&&ot(c,r);et.add(e);let y=[lt(a,u,e),ut(e)],b=[],x=Ae({sheet:e,backdrop:r.backdrop,dimmed:r.hostBackdrop?a:void 0,outlets:r.outlets,ancestors:()=>b,themeColor:e=>h?.write(e)});function S(){let e=r.physics();return e!==p&&(p=e,m=e?{...Y.ios,...e}:Y.ios),_.physics=m,_.dismissible=r.dismissible(),_.expandOnScroll=r.expandOnScroll(),_}let C=!1;function ee(){C=!0;let t=ae(r.side(),e);t!==u&&(u=t,y[0](),y[0]=lt(a,u,e));let n=(Q(u)?a.clientHeight:a.clientWidth)-(v?120:0);M??=c.visualViewport?.height,f=ce(e,u);let i=parseFloat(c.getComputedStyle(o.documentElement).fontSize)||16,s=X(r.snapPoints(),{container:n,content:f,rootFontSize:i});s.length||s.push({id:`content`,value:`content`,extent:f,ids:[`content`]});let l=n!==_.dimension||s.length!==d.length||s.some((e,t)=>e.id!==d[t].id||Math.abs(e.extent-d[t].extent)>=.5);return d=s,_.dimension=n,_.snapPoints=d.map(({id:e,extent:t})=>({id:e,extent:t})),x.configure({snapExtents:_.snapPoints.map(e=>e.extent),undimmedIndex:Z(d,r.modalAbove())}),l&&O(),l}let w=!1,T=e=>e===null?null:d.find(t=>t.id===e)?.value??null,E={sheet:e,host:a,side:()=>u,config:S,size:()=>f,closedExtent:()=>ge(u),reducedMotion:()=>!!l?.matches,owns:t=>rt(t)===e,canMouseDrag:r.canMouseDrag,onSnap:(e,t,n)=>{let i=T(e);i!==null&&r.onSnap(i,t,n)},onRest(e){if(w)return;let t=d.find(t=>t.id===e);x.apply(t?.extent??ge(u),{rest:!0}),r.onRest(T(e)),R&&e!==null&&B(),R=!1},onDismiss:r.onDismiss,onDismissAttempt:r.onDismissAttempt,onDragChange:r.onDragChange,isInteractive:e=>U.isInteractiveAt(T(e)),onFrame:e=>w||x.apply(e),onMotion:e=>w||x.play(e),onMotionStart:e=>w||x.sync(e)},D=!0;function O(){if(!D)return r.onLayout({side:u,snapPoints:d});queueMicrotask(()=>w||r.onLayout({side:u,snapPoints:d}))}S();let k=v?We(E):Ve(E);e.setAttribute(`data-driver`,v?`scroll-snap`:`pointer`),D=!1;let A=new ResizeObserver(()=>{V(!1)});A.observe(e),A.observe(a);let j=0,M,N=null,P=[s(a,{before:()=>j=e.getBoundingClientRect().top,after:F}),...r.preventEdgeSwipe()?[t(o,`touchstart`,I,{capture:!0,passive:!1})]:[],...i()?[t(o,`touchend`,L,{capture:!0,passive:!1})]:[],t(e,`focusin`,z)];function F(){V(!0),B();let t=c.visualViewport?.height;if(t===M)return;M=t,N?.cancel(),N=null;let n=j-e.getBoundingClientRect().top;Math.abs(n)<1||l?.matches||(N=a.animate({translate:[`0 ${n}px`,`0 0`]},st))}function I(e){if(!e.cancelable)return;let t=e.touches[0];if(!t||t.clientX>at&&t.clientX<c.innerWidth-at)return;let n=e.target;n&&(a.contains(n)||r.backdrop()?.contains(n))&&e.preventDefault()}function L(t){let n=t.target;(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)&&e.contains(n)&&n!==o.activeElement&&!k.isMoving()&&t.cancelable&&(t.preventDefault(),n.focus({preventScroll:!0}))}let R=!1;function z(){k.isMoving()?R=!0:B()}function B(){let t=o.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t)||t===e||it(t,e))return;let n=ue(t,e,`bottom`);if(!n)return;let r=c.visualViewport,i=Math.min(n.getBoundingClientRect().bottom,r?r.offsetTop+r.height:c.innerHeight),{top:a,bottom:s}=t.getBoundingClientRect(),u=n.getBoundingClientRect().top,d=s+16>i?s+16-i:a-16<u?a-16-u:0;d&&n.scrollBy({top:d,behavior:l?.matches?`instant`:`smooth`})}function V(e){let t=!C;ee()&&!t&&k.relayout(e,d[Z(d,r.snapPoint())]?.id)}function H(e){let t=Z(d,e);return d[t>=0?t:0]?.id}let U={element:e,parent:r.parent,open(e){if(w)return;b=[];for(let e=r.parent();e;e=e.parent())b.push(e.element);ee(),S(),r.themeColor()&&(h??=qe(o,m.dim)),e&&x.apply(ge(u)),g?.();let t=r.backdrop();g=t&&ve(t,{"will-change":`opacity`}),k.open(H(r.snapPoint()),e)},close:()=>w||k.close(),snapTo(e,t){let n=Z(d,e);n>=0&&d[n].id!==k.target()&&k.snapTo(d[n].id,t)},nudge:()=>k.nudge(),snapPoints:()=>d,target:()=>T(k.target()),isInteractiveAt:e=>ie(d,e,r.modalAbove()),refresh(){V(!1)},destroy(){w=!0,A.disconnect(),N?.cancel(),P.forEach(e=>e()),k.destroy(),x.destroy(),g?.(),h?.restore(),y.forEach(e=>e()),e.removeAttribute(`data-driver`),et.delete(e)}};return U}function lt(e,t,n){let r=Q(t),i=r?t===`bottom`:t===`right`!=(n.ownerDocument.defaultView?.getComputedStyle(e).direction===`rtl`);return ve(e,{position:`fixed`,inset:`0 0 var(--keyboard-inset, 0px) 0`,width:`auto`,height:`auto`,"max-width":`none`,"max-height":`none`,margin:`0`,padding:`0`,border:`0`,background:`transparent`,color:`inherit`,overflow:`visible`,display:`flex`,"flex-direction":r?`column`:`row`,"justify-content":i?`flex-end`:`flex-start`,"pointer-events":`none`})}function ut(e){return ve(e,{"pointer-events":`auto`,"overscroll-behavior":`contain`,"will-change":`translate`})}function dt(t){let n=t.getAttribute(`data-slot`);n&&e(t.ownerDocument,`ui-sdk-sheet-${n}`,`@layer ui-sdk { :where([data-slot="${n}"])::backdrop { background: var(--sheet-backdrop, rgb(0 0 0 / 0.2)); pointer-events: auto } }`)}function ft(e,t){let r=[],i=e=>{for(let a of Array.from(e.children))t.includes(a)||(t.some(e=>e&&a.contains(e))?i(a):a instanceof HTMLElement&&r.push(n(a,`display`,`none`)))};return i(e),()=>r.forEach(e=>e())}function pt(e,t,r){let i,a=t.bind(e,{...r,position:void 0,inline:!0,onShow(){let[t,n]=r.drillIn();return t&&(i=ft(t,[e,n])),()=>i?.()},onClose(){i?.(),i=n(e,`display`,`none`)}});return()=>{a(),i?.()}}function mt(e,t,n){if(n.drillIn)return pt(e,t,n);let r=e.parentElement;if(!r)return;dt(r);let i;return t.bind(e,{...n,position:void 0,host:()=>r,onShow(a){let o=ht(e,r,t,n,a);return i=o.sheet,()=>{o.hide(),i=void 0}},onClose:()=>i?.close()})}function ht(e,n,r,i,a){let o=null,s=nt(a),c=!i.backdrop?.(),l=ct(e,{host:n,snapPoints:()=>i.snapPoints??[`content`],snapPoint:()=>o,backdrop:i.backdrop,hostBackdrop:c,dismissible:i.dismissible,onDismissAttempt:i.onDismissAttempt,parent:()=>s?.(),onSnap:e=>o=e,onDismiss(e){r.requestClose(`swipe`,e),requestAnimationFrame(()=>{let e=o??l.snapPoints()[0]?.value;a.active()&&e!==void 0&&l.snapTo(e,`imperative`)})}});tt.set(a,()=>l),i.onSheet?.(l);let u=t(e,`focusin`,e=>{let t=l.snapPoints().at(-1);t&&l.snapPoints().length>1&&e.target.matches(`input, textarea`)&&l.snapTo(t.value,`imperative`)}),d=c?getComputedStyle(e).getPropertyValue(`--sheet-backdrop`):`transparent`;return d&&n.style.setProperty(`--sheet-backdrop`,d),a.active()&&l.open(r.opener()!==`initial`),{sheet:l,hide(){u(),tt.delete(a),l.destroy(),i.onSheet?.(void 0),n.style.removeProperty(`--sheet-backdrop`)}}}export{De as prepareVariables,mt as presentSheet};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='15' fill='%234f46e5'/%3E%3Ccircle cx='16' cy='16' r='6' fill='%23a5f3fc'/%3E%3C/svg%3E"
|
|
10
10
|
/>
|
|
11
11
|
<title>Wheatley</title>
|
|
12
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/assets/index-DThc2x_d.js"></script>
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-C9Rul5vE.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/dist/ops/cli.js
CHANGED
|
@@ -3,16 +3,19 @@ import { parseArgs } from "node:util";
|
|
|
3
3
|
import { systemClock } from "../contracts/module.js";
|
|
4
4
|
import { listBackups, restoreAgentBackup } from "./backup.js";
|
|
5
5
|
import { processRunner } from "./command-runner.js";
|
|
6
|
+
import { resolveInstallation, UPDATE_METHODS } from "./install-method.js";
|
|
6
7
|
import { agentDirFor, resolveHomeDir } from "./paths.js";
|
|
7
8
|
import { createServiceManager, packageBinScript, resolveServiceSpec, } from "./service.js";
|
|
8
|
-
import {
|
|
9
|
+
import { applyUpgrade, packageDir, planUpdate, readPackageVersion, } from "./update.js";
|
|
9
10
|
/** The ops CLI dependencies of this process. */
|
|
10
11
|
export const hostCliDeps = (isDaemonRunning, drainTimeoutMs) => ({
|
|
11
12
|
clock: systemClock,
|
|
12
13
|
env: process.env,
|
|
13
14
|
execPath: process.execPath,
|
|
15
|
+
fetch: globalThis.fetch,
|
|
14
16
|
homeDir: resolveHomeDir(),
|
|
15
17
|
isDaemonRunning,
|
|
18
|
+
packageDir: packageDir(),
|
|
16
19
|
platform: process.platform,
|
|
17
20
|
runner: processRunner,
|
|
18
21
|
uid: process.getuid?.() ?? 0,
|
|
@@ -23,7 +26,7 @@ const EXIT_OK = 0;
|
|
|
23
26
|
const EXIT_FAILURE = 1;
|
|
24
27
|
const EXIT_USAGE = 2;
|
|
25
28
|
const SERVICE_USAGE = "Usage: wheatley service <install|start|stop|restart|status>";
|
|
26
|
-
const UPDATE_USAGE =
|
|
29
|
+
const UPDATE_USAGE = `Usage: wheatley update [--check] [--method ${UPDATE_METHODS.join("|")}]`;
|
|
27
30
|
const RESTORE_USAGE = "Usage: wheatley restore <agent> [backup]";
|
|
28
31
|
class UsageError extends Error {
|
|
29
32
|
name = "UsageError";
|
|
@@ -99,26 +102,38 @@ const serviceCommand = (deps) => async (args, io) => {
|
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
};
|
|
102
|
-
const
|
|
103
|
-
const
|
|
105
|
+
const isUpdateMethod = (value) => UPDATE_METHODS.some((method) => method === value);
|
|
106
|
+
const newerMajorLines = (major) => {
|
|
107
|
+
const intro = `Wheatley ${major.version} is a new major version. wheatley update stays within the current major version. Read the release notes, then`;
|
|
108
|
+
return major.action.kind === "command"
|
|
109
|
+
? [`${intro} run: ${major.action.command.join(" ")}`]
|
|
110
|
+
: [`${intro}:`, ...major.action.lines];
|
|
111
|
+
};
|
|
104
112
|
const updateCommand = (deps) => async (args, io) => {
|
|
105
113
|
const { values } = parseArgs({
|
|
106
114
|
args: [...args],
|
|
107
115
|
options: {
|
|
108
116
|
check: { type: "boolean" },
|
|
109
|
-
|
|
117
|
+
method: { type: "string" },
|
|
110
118
|
},
|
|
111
119
|
});
|
|
112
|
-
if (values.
|
|
113
|
-
throw new UsageError(`Unknown
|
|
120
|
+
if (values.method !== undefined && !isUpdateMethod(values.method)) {
|
|
121
|
+
throw new UsageError(`Unknown install method: ${values.method}`);
|
|
114
122
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
const installation = await resolveInstallation({
|
|
124
|
+
env: deps.env,
|
|
125
|
+
execPath: deps.execPath,
|
|
126
|
+
method: values.method,
|
|
127
|
+
packageDir: deps.packageDir,
|
|
128
|
+
platform: deps.platform,
|
|
120
129
|
runner: deps.runner,
|
|
121
|
-
|
|
130
|
+
userHome: deps.userHome,
|
|
131
|
+
});
|
|
132
|
+
const plan = await planUpdate({
|
|
133
|
+
current: await readPackageVersion(installation.packageDir),
|
|
134
|
+
env: deps.env,
|
|
135
|
+
fetch: deps.fetch,
|
|
136
|
+
installation,
|
|
122
137
|
});
|
|
123
138
|
if (plan.kind === "docker") {
|
|
124
139
|
io.out("This Wheatley runs in Docker. In the folder of docker-compose.yml, run:");
|
|
@@ -127,23 +142,27 @@ const updateCommand = (deps) => async (args, io) => {
|
|
|
127
142
|
}
|
|
128
143
|
return EXIT_OK;
|
|
129
144
|
}
|
|
130
|
-
const
|
|
131
|
-
const newerMajor = plan.newerMajor === undefined
|
|
132
|
-
? []
|
|
133
|
-
: [newerMajorNote(plan.newerMajor, manager)];
|
|
145
|
+
const newerMajor = plan.newerMajor === undefined ? [] : newerMajorLines(plan.newerMajor);
|
|
134
146
|
if (plan.kind === "up_to_date") {
|
|
135
147
|
io.out(`Wheatley ${plan.current} is the newest release of its major version.`);
|
|
136
|
-
|
|
148
|
+
}
|
|
149
|
+
else if (plan.action.kind === "notice") {
|
|
150
|
+
io.out(`Wheatley ${plan.target} is available. This Wheatley runs ${plan.current}.`);
|
|
151
|
+
for (const line of plan.action.lines) {
|
|
137
152
|
io.out(line);
|
|
138
153
|
}
|
|
139
|
-
return EXIT_OK;
|
|
140
154
|
}
|
|
141
|
-
if (values.check === true) {
|
|
155
|
+
else if (values.check === true) {
|
|
142
156
|
io.out(`Update available: ${plan.current} -> ${plan.target}. Run: wheatley update`);
|
|
143
157
|
}
|
|
144
158
|
else {
|
|
145
|
-
io.out(`Updating Wheatley ${plan.current} -> ${plan.target}: ${plan.command.join(" ")}`);
|
|
146
|
-
await
|
|
159
|
+
io.out(`Updating Wheatley ${plan.current} -> ${plan.target}: ${plan.action.command.join(" ")}`);
|
|
160
|
+
await applyUpgrade(plan.action, {
|
|
161
|
+
packageDir: installation.packageDir,
|
|
162
|
+
runner: deps.runner,
|
|
163
|
+
target: plan.target,
|
|
164
|
+
workDir: deps.userHome,
|
|
165
|
+
});
|
|
147
166
|
io.out(`Updated Wheatley to ${plan.target}. If the daemon runs as a service, run: wheatley service restart`);
|
|
148
167
|
}
|
|
149
168
|
for (const line of newerMajor) {
|
|
@@ -4,6 +4,7 @@ import { once } from "node:events";
|
|
|
4
4
|
export const processRunner = {
|
|
5
5
|
run: async (command, args, options) => {
|
|
6
6
|
const child = spawn(command, args, {
|
|
7
|
+
cwd: options?.cwd,
|
|
7
8
|
stdio: options?.inheritStdio === true ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
8
9
|
});
|
|
9
10
|
let stdout = "";
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Type } from "typebox";
|
|
4
|
+
import { Value } from "typebox/value";
|
|
5
|
+
import { envValue, isDocker, pathExists } from "./paths.js";
|
|
6
|
+
import { PACKAGE_NAME } from "./registry.js";
|
|
7
|
+
/** The Node.js package managers that can own a global install of Wheatley. */
|
|
8
|
+
export const NODE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
|
|
9
|
+
/** The install methods that `wheatley update` updates itself. `wheatley update --method` takes these values. */
|
|
10
|
+
export const UPDATE_METHODS = [...NODE_MANAGERS, "brew", "curl"];
|
|
11
|
+
const TAP_FORMULA = "sphericalkat/tap/wheatley";
|
|
12
|
+
const CORE_TAP = "homebrew/core";
|
|
13
|
+
const segment = (...names) => `${path.sep}${names.join(path.sep)}${path.sep}`;
|
|
14
|
+
const PACKAGE_SUFFIX = segment("lib", "node_modules", ...PACKAGE_NAME.split("/"));
|
|
15
|
+
const ReceiptSchema = Type.Object({
|
|
16
|
+
source: Type.Object({ tap: Type.String() }),
|
|
17
|
+
});
|
|
18
|
+
/** Returns `true` if `dir` is `parent` or inside it. Both paths must be real paths. */
|
|
19
|
+
const isInside = (dir, parent) => `${dir}${path.sep}`.startsWith(`${parent}${path.sep}`);
|
|
20
|
+
/** Returns the real path of `target`, or `target` itself if it does not exist. */
|
|
21
|
+
const realOrSelf = async (target) => {
|
|
22
|
+
try {
|
|
23
|
+
return await realpath(target);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return target;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const curlAppDirs = (env, userHome) => {
|
|
30
|
+
const fallback = path.join(userHome, ".local", "share");
|
|
31
|
+
const xdg = envValue(env, "XDG_DATA_HOME");
|
|
32
|
+
return [...new Set([xdg ?? fallback, fallback])].map((dataHome) => path.join(dataHome, "wheatley", "app"));
|
|
33
|
+
};
|
|
34
|
+
const isCurlInstall = async (dir, input) => {
|
|
35
|
+
const appDirs = await Promise.all(curlAppDirs(input.env, input.userHome).map(realOrSelf));
|
|
36
|
+
return appDirs.some((appDir) => isInside(dir, appDir));
|
|
37
|
+
};
|
|
38
|
+
/** The npm prefix of `<prefix>/lib/node_modules/@wheatley-ai/cli`, which npm uses on POSIX systems. */
|
|
39
|
+
const npmPrefix = (dir, platform) => platform !== "win32" && `${dir}${path.sep}`.endsWith(PACKAGE_SUFFIX)
|
|
40
|
+
? dir.slice(0, -(PACKAGE_SUFFIX.length - 1))
|
|
41
|
+
: undefined;
|
|
42
|
+
/** Reads the tap of the Homebrew keg that holds `dir`, from its `INSTALL_RECEIPT.json`. */
|
|
43
|
+
const brewFormula = async (dir) => {
|
|
44
|
+
const cellar = segment("Cellar", "wheatley");
|
|
45
|
+
const start = dir.indexOf(cellar) + cellar.length;
|
|
46
|
+
const keg = dir.slice(0, dir.indexOf(path.sep, start));
|
|
47
|
+
try {
|
|
48
|
+
const receipt = JSON.parse(await readFile(path.join(keg, "INSTALL_RECEIPT.json"), "utf-8"));
|
|
49
|
+
return Value.Check(ReceiptSchema, receipt) &&
|
|
50
|
+
receipt.source.tap === CORE_TAP
|
|
51
|
+
? "wheatley"
|
|
52
|
+
: TAP_FORMULA;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return TAP_FORMULA;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** Returns `true` if `pacman` reports an owner package for `dir`. */
|
|
59
|
+
const isPacmanPackage = async (dir, runner) => {
|
|
60
|
+
try {
|
|
61
|
+
const result = await runner.run("pacman", ["-Qqo", dir]);
|
|
62
|
+
return result.exitCode === 0;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const AUR_DIR = segment("usr", "lib", "node_modules", ...PACKAGE_NAME.split("/"));
|
|
69
|
+
/** Detects the installs that a dedicated tool or another package system owns, from the real package path. */
|
|
70
|
+
const detectManaged = async (dir, input) => {
|
|
71
|
+
if (await isCurlInstall(dir, input)) {
|
|
72
|
+
return "curl";
|
|
73
|
+
}
|
|
74
|
+
const hints = [
|
|
75
|
+
["brew", segment("Cellar", "wheatley")],
|
|
76
|
+
["volta", segment("tools", "image", "packages")],
|
|
77
|
+
["mise", `${path.sep}installs${path.sep}npm-`],
|
|
78
|
+
];
|
|
79
|
+
const marked = `${dir}${path.sep}`;
|
|
80
|
+
const hinted = hints.find(([, hint]) => marked.includes(hint))?.[0];
|
|
81
|
+
if (hinted !== undefined) {
|
|
82
|
+
return hinted;
|
|
83
|
+
}
|
|
84
|
+
const isSystemPackage = input.platform === "linux" &&
|
|
85
|
+
marked.endsWith(AUR_DIR) &&
|
|
86
|
+
(await isPacmanPackage(dir, input.runner));
|
|
87
|
+
if (isSystemPackage) {
|
|
88
|
+
return "aur";
|
|
89
|
+
}
|
|
90
|
+
return marked.includes(segment("node_modules")) ? undefined : "source";
|
|
91
|
+
};
|
|
92
|
+
/** The global package folders of each manager, as path fragments. */
|
|
93
|
+
const MANAGER_HINTS = {
|
|
94
|
+
bun: [segment(".bun", "install", "global")],
|
|
95
|
+
npm: [PACKAGE_SUFFIX],
|
|
96
|
+
pnpm: [segment("pnpm", "global"), segment(".pnpm")],
|
|
97
|
+
yarn: [segment("yarn", "global"), segment("Yarn", "Data", "global")],
|
|
98
|
+
};
|
|
99
|
+
const PROBES = {
|
|
100
|
+
bun: ["pm", "ls", "-g"],
|
|
101
|
+
npm: ["list", "-g", "--depth=0", PACKAGE_NAME],
|
|
102
|
+
pnpm: ["list", "-g", "--depth=0", PACKAGE_NAME],
|
|
103
|
+
yarn: ["global", "list"],
|
|
104
|
+
};
|
|
105
|
+
/** Resolves `true` if the global package list of `manager` contains Wheatley. A missing manager counts as `false`. */
|
|
106
|
+
const listsWheatley = async (manager, { runner, userHome }) => {
|
|
107
|
+
try {
|
|
108
|
+
// Corepack shims of pnpm and yarn refuse to run inside a project whose `packageManager` names another manager.
|
|
109
|
+
const result = await runner.run(manager, PROBES[manager], {
|
|
110
|
+
cwd: userHome,
|
|
111
|
+
});
|
|
112
|
+
return result.exitCode === 0 && result.stdout.includes(PACKAGE_NAME);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Picks the Node.js package manager that owns the install. It ranks the managers by the path of the package, then
|
|
120
|
+
* confirms the ranking with their global package lists, which it queries in parallel. A path hint wins over a list
|
|
121
|
+
* that only another manager confirms, because that list can belong to a second copy of Wheatley.
|
|
122
|
+
*/
|
|
123
|
+
const detectNodeManager = async (dir, input) => {
|
|
124
|
+
const marked = `${dir}${path.sep}`;
|
|
125
|
+
const pnpmHome = envValue(input.env, "PNPM_HOME");
|
|
126
|
+
const hinted = NODE_MANAGERS.filter((manager) => MANAGER_HINTS[manager].some((hint) => marked.includes(hint)) ||
|
|
127
|
+
(manager === "pnpm" &&
|
|
128
|
+
pnpmHome !== undefined &&
|
|
129
|
+
isInside(dir, path.resolve(pnpmHome))));
|
|
130
|
+
const confirmed = await Promise.all(NODE_MANAGERS.map(async (manager) => (await listsWheatley(manager, input)) ? manager : []));
|
|
131
|
+
const owners = confirmed.flat();
|
|
132
|
+
return (hinted.find((manager) => owners.includes(manager)) ??
|
|
133
|
+
hinted[0] ??
|
|
134
|
+
owners[0] ??
|
|
135
|
+
"npm");
|
|
136
|
+
};
|
|
137
|
+
/** The npm that belongs to `prefix`, started with the Node.js of the prefix or else the running Node.js. */
|
|
138
|
+
const npmFor = async (prefix, execPath) => {
|
|
139
|
+
if (prefix === undefined) {
|
|
140
|
+
return ["npm"];
|
|
141
|
+
}
|
|
142
|
+
const npm = path.join(prefix, "bin", "npm");
|
|
143
|
+
if (!(await pathExists(npm))) {
|
|
144
|
+
return ["npm"];
|
|
145
|
+
}
|
|
146
|
+
const node = path.join(prefix, "bin", "node");
|
|
147
|
+
return [(await pathExists(node)) ? node : await realOrSelf(execPath), npm];
|
|
148
|
+
};
|
|
149
|
+
const installationFor = async (method, dir, input) => {
|
|
150
|
+
if (method === "npm") {
|
|
151
|
+
const prefix = npmPrefix(dir, input.platform);
|
|
152
|
+
return {
|
|
153
|
+
method,
|
|
154
|
+
npm: await npmFor(prefix, input.execPath),
|
|
155
|
+
packageDir: dir,
|
|
156
|
+
prefix,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (method === "brew") {
|
|
160
|
+
return { formula: await brewFormula(dir), method, packageDir: dir };
|
|
161
|
+
}
|
|
162
|
+
return { method, packageDir: dir };
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Finds out how this Wheatley was installed and what updates it.
|
|
166
|
+
*
|
|
167
|
+
* It resolves the real package path first, so that a symlink such as `/opt/homebrew/opt/wheatley` or a `pnpm` link
|
|
168
|
+
* cannot hide the owner. It checks in this order:
|
|
169
|
+
*
|
|
170
|
+
* 1. Docker, from `WHEATLEY_DOCKER`.
|
|
171
|
+
* 2. The `curl` installer app folder, `${XDG_DATA_HOME:-~/.local/share}/wheatley/app`.
|
|
172
|
+
* 3. Homebrew, Volta, and mise, from their folders.
|
|
173
|
+
* 4. An AUR package, if `pacman` owns `/usr/lib/node_modules/@wheatley-ai/cli`.
|
|
174
|
+
* 5. A source checkout, if the package is outside `node_modules`.
|
|
175
|
+
* 6. npm, pnpm, yarn, or bun, from the package path and their global package lists.
|
|
176
|
+
*
|
|
177
|
+
* Errors: does not reject. A failed or missing `pacman` or package manager counts as "does not own Wheatley".
|
|
178
|
+
*/
|
|
179
|
+
export const resolveInstallation = async (input) => {
|
|
180
|
+
const dir = await realOrSelf(input.packageDir);
|
|
181
|
+
if (input.method !== undefined) {
|
|
182
|
+
return await installationFor(input.method, dir, input);
|
|
183
|
+
}
|
|
184
|
+
if (isDocker(input.env)) {
|
|
185
|
+
return { method: "docker", packageDir: dir };
|
|
186
|
+
}
|
|
187
|
+
const method = (await detectManaged(dir, input)) ?? (await detectNodeManager(dir, input));
|
|
188
|
+
return await installationFor(method, dir, input);
|
|
189
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
import { envValue } from "./paths.js";
|
|
4
|
+
/** The npm package name of the daemon and CLI. */
|
|
5
|
+
export const PACKAGE_NAME = "@wheatley-ai/cli";
|
|
6
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
7
|
+
/** The abbreviated packument has only the fields that installs need, which keeps the response small. */
|
|
8
|
+
const ABBREVIATED_PACKUMENT = "application/vnd.npm.install-v1+json";
|
|
9
|
+
const REGISTRY_TIMEOUT_MS = 10_000;
|
|
10
|
+
const TRAILING_SLASHES = /\/+$/u;
|
|
11
|
+
const PackumentSchema = Type.Object({
|
|
12
|
+
versions: Type.Record(Type.String(), Type.Unknown()),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Lists the published versions of `@wheatley-ai/cli` with one HTTP request to the npm registry. It does not start a
|
|
16
|
+
* package manager, so the `devEngines` field of a `package.json` in the working folder cannot make it fail.
|
|
17
|
+
*
|
|
18
|
+
* Errors: rejects on a network error, a timeout after 10 seconds, an HTTP error status, or an unexpected response.
|
|
19
|
+
*/
|
|
20
|
+
export const fetchPublishedVersions = async (options) => {
|
|
21
|
+
const registry = (envValue(options.env, "npm_config_registry") ?? DEFAULT_REGISTRY).replace(TRAILING_SLASHES, "");
|
|
22
|
+
const url = `${registry}/${PACKAGE_NAME.replace("/", "%2F")}`;
|
|
23
|
+
const response = await options.fetch(url, {
|
|
24
|
+
headers: { Accept: ABBREVIATED_PACKUMENT },
|
|
25
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS),
|
|
26
|
+
});
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new Error(`GET ${url} failed with HTTP ${response.status}`);
|
|
29
|
+
}
|
|
30
|
+
const parsed = await response.json();
|
|
31
|
+
if (!Value.Check(PackumentSchema, parsed)) {
|
|
32
|
+
throw new Error(`GET ${url} returned an unexpected response`);
|
|
33
|
+
}
|
|
34
|
+
return Object.keys(parsed.versions);
|
|
35
|
+
};
|