@hot-updater/console 0.25.7 → 0.25.9

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.
@@ -24,4 +24,4 @@ var vg=Object.defineProperty;var su=e=>{throw TypeError(e)};var yg=(e,t,n)=>t in
24
24
  * LICENSE.md file in the root directory of this source tree.
25
25
  *
26
26
  * @license MIT
27
- */function wc(e,t){return e?typeof e=="function"?w(e,t):e:null}function w0(e){const t=F({state:{},onStateChange:()=>{},renderFallbackValue:null,mergeOptions:(i,s)=>F(i,s)},e),n=h0(t),[r,o]=vo(n.initialState);return pt(()=>{n.setOptions(i=>F(i,e,{state:F(r,e.state||{}),onStateChange:s=>{o(s),e.onStateChange==null||e.onStateChange(s)}}))}),n}function b0(e){const[t,n]=z(0),[r,o]=z(0);j(()=>{const a=e();if(!a)return;s(a);const l=new ResizeObserver(i);l.observe(a),Y(()=>{l.disconnect()})});const i=a=>{for(const l of a)l.target===e()&&s(l.target)},s=a=>{o(a.offsetWidth),n(a.offsetHeight)};return{width:r,height:t}}function lh(e){let t=e.startIndex??0;const n=e.startLevel??0,r=[],o=l=>{if(l==null)return"";const c=e.getKey??"key",u=Jn(c)?l[c]:c(l);return u!=null?String(u):""},i=l=>{if(l==null)return"";const c=e.getTextValue??"textValue",u=Jn(c)?l[c]:c(l);return u!=null?String(u):""},s=l=>{if(l==null)return!1;const c=e.getDisabled??"disabled";return(Jn(c)?l[c]:c(l))??!1},a=l=>{var c;if(l!=null)return Jn(e.getSectionChildren)?l[e.getSectionChildren]:(c=e.getSectionChildren)==null?void 0:c.call(e,l)};for(const l of e.dataSource){if(Jn(l)||Fm(l)){r.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:s(l),level:n,index:t}),t++;continue}if(a(l)!=null){r.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:t}),t++;const c=a(l)??[];if(c.length>0){const u=lh({dataSource:c,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:t,startLevel:n+1});r.push(...u),t+=u.length}}else r.push({type:"item",rawValue:l,key:o(l),textValue:i(l),disabled:s(l),level:n,index:t}),t++}return r}function S0(e,t=[]){return L(()=>{const n=lh({dataSource:T(e.dataSource),getKey:T(e.getKey),getTextValue:T(e.getTextValue),getDisabled:T(e.getDisabled),getSectionChildren:T(e.getSectionChildren)});for(let r=0;r<t.length;r++)t[r]();return e.factory(n)})}var Rt=class uh extends Set{constructor(n,r,o){super(n);Re(this,"anchorKey");Re(this,"currentKey");n instanceof uh?(this.anchorKey=r||n.anchorKey,this.currentKey=o||n.currentKey):(this.anchorKey=r,this.currentKey=o)}};function x0(e){const[t,n]=wt(e);return[()=>t()??new Rt,n]}function ch(e){return ti()?e.altKey:e.ctrlKey}function Zn(e){return wo()?e.metaKey:e.ctrlKey}function bc(e){return new Rt(e)}function dh(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function C0(e){const t=Z({selectionMode:"none",selectionBehavior:"toggle"},e),[n,r]=z(!1),[o,i]=z(),s=L(()=>{const g=T(t.selectedKeys);return g!=null?bc(g):g}),a=L(()=>{const g=T(t.defaultSelectedKeys);return g!=null?bc(g):new Rt}),[l,c]=x0({value:s,defaultValue:a,onChange:g=>{var v;return(v=t.onSelectionChange)==null?void 0:v.call(t,g)}}),[u,f]=z(T(t.selectionBehavior)),d=()=>T(t.selectionMode),h=()=>T(t.disallowEmptySelection)??!1,p=g=>{(T(t.allowDuplicateSelectionEvents)||!dh(g,l()))&&c(g)};return j(()=>{const g=l();T(t.selectionBehavior)==="replace"&&u()==="toggle"&&typeof g=="object"&&g.size===0&&f("replace")}),j(()=>{f(T(t.selectionBehavior)??"toggle")}),{selectionMode:d,disallowEmptySelection:h,selectionBehavior:u,setSelectionBehavior:f,isFocused:n,setFocused:r,focusedKey:o,setFocusedKey:i,selectedKeys:l,setSelectedKeys:p}}function E0(e){const[t,n]=z(""),[r,o]=z(-1);return{typeSelectHandlers:{onKeyDown:s=>{var d;if(T(e.isDisabled))return;const a=T(e.keyboardDelegate),l=T(e.selectionManager);if(!a.getKeyForSearch)return;const c=M0(s.key);if(!c||s.ctrlKey||s.metaKey)return;c===" "&&t().trim().length>0&&(s.preventDefault(),s.stopPropagation());let u=n(h=>h+c),f=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u);f==null&&I0(u)&&(u=u[0],f=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u)),f!=null&&(l.setFocusedKey(f),(d=e.onTypeSelect)==null||d.call(e,f)),clearTimeout(r()),o(window.setTimeout(()=>n(""),500))}}}}function M0(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function I0(e){return e.split("").every(t=>t===e[0])}function fh(e,t,n){const o=F({selectOnFocus:()=>T(e.selectionManager).selectionBehavior()==="replace"},e),i=()=>(n==null?void 0:n())??t(),{direction:s}=xn();let a={top:0,left:0};Mm(()=>T(o.isVirtualized)?void 0:i(),"scroll",()=>{const v=i();v&&(a={top:v.scrollTop,left:v.scrollLeft})});const{typeSelectHandlers:l}=E0({isDisabled:()=>T(o.disallowTypeAhead),keyboardDelegate:()=>T(o.keyboardDelegate),selectionManager:()=>T(o.selectionManager)}),c=()=>T(o.orientation)??"vertical",u=v=>{var V,$,k,N,B,ne,I,M;ee(v,l.onKeyDown),v.altKey&&v.key==="Tab"&&v.preventDefault();const m=t();if(!(m!=null&&m.contains(v.target)))return;const y=T(o.selectionManager),b=T(o.selectOnFocus),S=x=>{x!=null&&(y.setFocusedKey(x),v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&!ch(v)&&y.replaceSelection(x))},C=T(o.keyboardDelegate),R=T(o.shouldFocusWrap),D=y.focusedKey();switch(v.key){case(c()==="vertical"?"ArrowDown":"ArrowRight"):{if(C.getKeyBelow){v.preventDefault();let x;D!=null?x=C.getKeyBelow(D):x=(V=C.getFirstKey)==null?void 0:V.call(C),x==null&&R&&(x=($=C.getFirstKey)==null?void 0:$.call(C,D)),S(x)}break}case(c()==="vertical"?"ArrowUp":"ArrowLeft"):{if(C.getKeyAbove){v.preventDefault();let x;D!=null?x=C.getKeyAbove(D):x=(k=C.getLastKey)==null?void 0:k.call(C),x==null&&R&&(x=(N=C.getLastKey)==null?void 0:N.call(C,D)),S(x)}break}case(c()==="vertical"?"ArrowLeft":"ArrowUp"):{if(C.getKeyLeftOf){v.preventDefault();const x=s()==="rtl";let O;D!=null?O=C.getKeyLeftOf(D):O=x?(B=C.getFirstKey)==null?void 0:B.call(C):(ne=C.getLastKey)==null?void 0:ne.call(C),S(O)}break}case(c()==="vertical"?"ArrowRight":"ArrowDown"):{if(C.getKeyRightOf){v.preventDefault();const x=s()==="rtl";let O;D!=null?O=C.getKeyRightOf(D):O=x?(I=C.getLastKey)==null?void 0:I.call(C):(M=C.getFirstKey)==null?void 0:M.call(C),S(O)}break}case"Home":if(C.getFirstKey){v.preventDefault();const x=C.getFirstKey(D,Zn(v));x!=null&&(y.setFocusedKey(x),Zn(v)&&v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&y.replaceSelection(x))}break;case"End":if(C.getLastKey){v.preventDefault();const x=C.getLastKey(D,Zn(v));x!=null&&(y.setFocusedKey(x),Zn(v)&&v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&y.replaceSelection(x))}break;case"PageDown":if(C.getKeyPageBelow&&D!=null){v.preventDefault();const x=C.getKeyPageBelow(D);S(x)}break;case"PageUp":if(C.getKeyPageAbove&&D!=null){v.preventDefault();const x=C.getKeyPageAbove(D);S(x)}break;case"a":Zn(v)&&y.selectionMode()==="multiple"&&T(o.disallowSelectAll)!==!0&&(v.preventDefault(),y.selectAll());break;case"Escape":v.defaultPrevented||(v.preventDefault(),T(o.disallowEmptySelection)||y.clearSelection());break;case"Tab":if(!T(o.allowsTabNavigation)){if(v.shiftKey)m.focus();else{const x=Hm(m,{tabbable:!0});let O,P;do P=x.lastChild(),P&&(O=P);while(P);O&&!O.contains(document.activeElement)&&Fe(O)}break}}},f=v=>{var S,C;const m=T(o.selectionManager),y=T(o.keyboardDelegate),b=T(o.selectOnFocus);if(m.isFocused()){v.currentTarget.contains(v.target)||m.setFocused(!1);return}if(v.currentTarget.contains(v.target)){if(m.setFocused(!0),m.focusedKey()==null){const R=V=>{V!=null&&(m.setFocusedKey(V),b&&m.replaceSelection(V))},D=v.relatedTarget;D&&v.currentTarget.compareDocumentPosition(D)&Node.DOCUMENT_POSITION_FOLLOWING?R(m.lastSelectedKey()??((S=y.getLastKey)==null?void 0:S.call(y))):R(m.firstSelectedKey()??((C=y.getFirstKey)==null?void 0:C.call(y)))}else if(!T(o.isVirtualized)){const R=i();if(R){R.scrollTop=a.top,R.scrollLeft=a.left;const D=R.querySelector(`[data-key="${m.focusedKey()}"]`);D&&(Fe(D),Qs(R,D))}}}},d=v=>{const m=T(o.selectionManager);v.currentTarget.contains(v.relatedTarget)||m.setFocused(!1)},h=v=>{i()===v.target&&v.preventDefault()},p=()=>{var R,D;const v=T(o.autoFocus);if(!v)return;const m=T(o.selectionManager),y=T(o.keyboardDelegate);let b;v==="first"&&(b=(R=y.getFirstKey)==null?void 0:R.call(y)),v==="last"&&(b=(D=y.getLastKey)==null?void 0:D.call(y));const S=m.selectedKeys();S.size&&(b=S.values().next().value),m.setFocused(!0),m.setFocusedKey(b);const C=t();C&&b==null&&!T(o.shouldUseVirtualFocus)&&Fe(C)};return Sr(()=>{o.deferAutoFocus?setTimeout(p,0):p()}),j(Ee([i,()=>T(o.isVirtualized),()=>T(o.selectionManager).focusedKey()],v=>{var S;const[m,y,b]=v;if(y)b&&((S=o.scrollToKey)==null||S.call(o,b));else if(b&&m){const C=m.querySelector(`[data-key="${b}"]`);C&&Qs(m,C)}})),{tabIndex:L(()=>{if(!T(o.shouldUseVirtualFocus))return T(o.selectionManager).focusedKey()==null?0:-1}),onKeyDown:u,onMouseDown:h,onFocusIn:f,onFocusOut:d}}function ul(e,t){const n=()=>T(e.selectionManager),r=()=>T(e.key),o=()=>T(e.shouldUseVirtualFocus),i=y=>{n().selectionMode()!=="none"&&(n().selectionMode()==="single"?n().isSelected(r())&&!n().disallowEmptySelection()?n().toggleSelection(r()):n().replaceSelection(r()):y!=null&&y.shiftKey?n().extendSelection(r()):n().selectionBehavior()==="toggle"||Zn(y)||"pointerType"in y&&y.pointerType==="touch"?n().toggleSelection(r()):n().replaceSelection(r()))},s=()=>n().isSelected(r()),a=()=>T(e.disabled)||n().isDisabled(r()),l=()=>!a()&&n().canSelectItem(r());let c=null;const u=y=>{l()&&(c=y.pointerType,y.pointerType==="mouse"&&y.button===0&&!T(e.shouldSelectOnPressUp)&&i(y))},f=y=>{l()&&y.pointerType==="mouse"&&y.button===0&&T(e.shouldSelectOnPressUp)&&T(e.allowsDifferentPressOrigin)&&i(y)},d=y=>{l()&&(T(e.shouldSelectOnPressUp)&&!T(e.allowsDifferentPressOrigin)||c!=="mouse")&&i(y)},h=y=>{!l()||!["Enter"," "].includes(y.key)||(ch(y)?n().toggleSelection(r()):i(y))},p=y=>{a()&&y.preventDefault()},g=y=>{const b=t();o()||a()||!b||y.target===b&&n().setFocusedKey(r())},v=L(()=>{if(!(o()||a()))return r()===n().focusedKey()?0:-1}),m=L(()=>T(e.virtualized)?void 0:r());return j(Ee([t,r,o,()=>n().focusedKey(),()=>n().isFocused()],([y,b,S,C,R])=>{y&&b===C&&R&&!S&&document.activeElement!==y&&(e.focus?e.focus():Fe(y))})),{isSelected:s,isDisabled:a,allowsSelection:l,tabIndex:v,dataKey:m,onPointerDown:u,onPointerUp:f,onClick:d,onKeyDown:h,onMouseDown:p,onFocus:g}}var P0=class{constructor(e,t){Re(this,"collection");Re(this,"state");this.collection=e,this.state=t}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(e==null||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if(this.state.selectionMode()==="none")return!1;const t=this.getKey(e);return t==null?!1:this.state.selectedKeys().has(t)}isEmpty(){return this.state.selectedKeys().size===0}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every(t=>e.has(t))}firstSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),r=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index<e.index;(!e||r)&&(e=n)}return e==null?void 0:e.key}lastSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),r=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index>e.index;(!e||r)&&(e=n)}return e==null?void 0:e.key}extendSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=this.state.selectedKeys(),r=n.anchorKey||t,o=new Rt(n,r,t);for(const i of this.getKeyRange(r,n.currentKey||t))o.delete(i);for(const i of this.getKeyRange(t,r))this.canSelectItem(i)&&o.add(i);this.state.setSelectedKeys(o)}getKeyRange(e,t){const n=this.collection().getItem(e),r=this.collection().getItem(t);return n&&r?n.index!=null&&r.index!=null&&n.index<=r.index?this.getKeyRangeInternal(e,t):this.getKeyRangeInternal(t,e):[]}getKeyRangeInternal(e,t){const n=[];let r=e;for(;r!=null;){const o=this.collection().getItem(r);if(o&&o.type==="item"&&n.push(r),r===t)return n;r=this.collection().getKeyAfter(r)}return[]}getKey(e){const t=this.collection().getItem(e);return t?!t||t.type!=="item"?null:t.key:e}toggleSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=new Rt(this.state.selectedKeys());n.has(t)?n.delete(t):this.canSelectItem(t)&&(n.add(t),n.anchorKey=t,n.currentKey=t),!(this.disallowEmptySelection()&&n.size===0)&&this.state.setSelectedKeys(n)}replaceSelection(e){if(this.selectionMode()==="none")return;const t=this.getKey(e);if(t==null)return;const n=this.canSelectItem(t)?new Rt([t],t,t):new Rt;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new Rt;for(const n of e){const r=this.getKey(n);if(r!=null&&(t.add(r),this.selectionMode()==="single"))break}this.state.setSelectedKeys(t)}selectAll(){this.selectionMode()==="multiple"&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new Rt)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,t){this.selectionMode()!=="none"&&(this.selectionMode()==="single"?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior()==="toggle"||t&&t.pointerType==="touch"?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const t=this.selectedKeys();if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;for(const n of t)if(!e.has(n))return!1;return!0}canSelectItem(e){if(this.state.selectionMode()==="none")return!1;const t=this.collection().getItem(e);return t!=null&&!t.disabled}isDisabled(e){const t=this.collection().getItem(e);return!t||t.disabled}getAllSelectableKeys(){const e=[];return(n=>{for(;n!=null;){if(this.canSelectItem(n)){const r=this.collection().getItem(n);if(!r)continue;r.type==="item"&&e.push(n)}n=this.collection().getKeyAfter(n)}})(this.collection().getFirstKey()),e}},Sc=class{constructor(e){Re(this,"keyMap",new Map);Re(this,"iterable");Re(this,"firstKey");Re(this,"lastKey");this.iterable=e;for(const r of e)this.keyMap.set(r.key,r);if(this.keyMap.size===0)return;let t,n=0;for(const[r,o]of this.keyMap)t?(t.nextKey=r,o.prevKey=t.key):(this.firstKey=r,o.prevKey=void 0),o.type==="item"&&(o.index=n++),t=o,t.nextKey=void 0;this.lastKey=t.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.prevKey}getKeyAfter(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const t=[...this.getKeys()];return this.getItem(t[e])}};function cl(e){const t=C0(e),r=S0({dataSource:()=>T(e.dataSource),getKey:()=>T(e.getKey),getTextValue:()=>T(e.getTextValue),getDisabled:()=>T(e.getDisabled),getSectionChildren:()=>T(e.getSectionChildren),factory:i=>e.filter?new Sc(e.filter(i)):new Sc(i)},[()=>e.filter]),o=new P0(r,t);return pt(()=>{const i=t.focusedKey();i!=null&&!r().getItem(i)&&t.setFocusedKey(void 0)}),{collection:r,selectionManager:()=>o}}var hh=class{constructor(e,t,n){Re(this,"collection");Re(this,"ref");Re(this,"collator");this.collection=e,this.ref=t,this.collator=n}getKeyBelow(e){let t=this.collection().getKeyAfter(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyAfter(t)}}getKeyAbove(e){let t=this.collection().getKeyBefore(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyBefore(t)}}getFirstKey(){let e=this.collection().getFirstKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){var t,n;return((n=(t=this.ref)==null?void 0:t.call(this))==null?void 0:n.querySelector(`[data-key="${e}"]`))??null}getKeyPageAbove(e){var i;const t=(i=this.ref)==null?void 0:i.call(this);let n=this.getItem(e);if(!t||!n)return;const r=Math.max(0,n.offsetTop+n.offsetHeight-t.offsetHeight);let o=e;for(;o&&n&&n.offsetTop>r;)o=this.getKeyAbove(o),n=o!=null?this.getItem(o):null;return o}getKeyPageBelow(e){var i;const t=(i=this.ref)==null?void 0:i.call(this);let n=this.getItem(e);if(!t||!n)return;const r=Math.min(t.scrollHeight,n.offsetTop-n.offsetHeight+t.offsetHeight);let o=e;for(;o&&n&&n.offsetTop<r;)o=this.getKeyBelow(o),n=o!=null?this.getItem(o):null;return o}getKeyForSearch(e,t){var o;const n=(o=this.collator)==null?void 0:o.call(this);if(!n)return;let r=t!=null?this.getKeyBelow(t):this.getFirstKey();for(;r!=null;){const i=this.collection().getItem(r);if(i){const s=i.textValue.slice(0,e.length);if(i.textValue&&n.compare(s,e)===0)return r}r=this.getKeyBelow(r)}}};function gh(e,t,n){const r=zf({usage:"search",sensitivity:"base"}),o=L(()=>{const i=T(e.keyboardDelegate);return i||new hh(e.collection,t,r)});return fh({selectionManager:()=>T(e.selectionManager),keyboardDelegate:o,autoFocus:()=>T(e.autoFocus),deferAutoFocus:()=>T(e.deferAutoFocus),shouldFocusWrap:()=>T(e.shouldFocusWrap),disallowEmptySelection:()=>T(e.disallowEmptySelection),selectOnFocus:()=>T(e.selectOnFocus),disallowTypeAhead:()=>T(e.disallowTypeAhead),shouldUseVirtualFocus:()=>T(e.shouldUseVirtualFocus),allowsTabNavigation:()=>T(e.allowsTabNavigation),isVirtualized:()=>T(e.isVirtualized),scrollToKey:i=>{var s;return(s=T(e.scrollToKey))==null?void 0:s(i)},orientation:()=>T(e.orientation)},t,n)}var ph=Ce();function mh(){return xe(ph)}function R0(){const e=mh();if(e===void 0)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}function vh(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function O0(e,t){var o;const n=t.ref();if(!n)return-1;let r=e.length;if(!r)return-1;for(;r--;){const i=(o=e[r])==null?void 0:o.ref();if(i&&vh(i,n))return r+1}return 0}function F0(e){const t=e.map((r,o)=>[o,r]);let n=!1;return t.sort(([r,o],[i,s])=>{const a=o.ref(),l=s.ref();return a===l||!a||!l?0:vh(a,l)?(r>i&&(n=!0),-1):(r<i&&(n=!0),1)}),n?t.map(([r,o])=>o):e}function yh(e,t){const n=F0(e);e!==n&&t(n)}function $0(e){var o,i;const t=e[0],n=(o=e[e.length-1])==null?void 0:o.ref();let r=(i=t==null?void 0:t.ref())==null?void 0:i.parentElement;for(;r;){if(n&&r.contains(n))return r;r=r.parentElement}return We(r).body}function A0(e,t){j(()=>{const n=setTimeout(()=>{yh(e(),t)});Y(()=>clearTimeout(n))})}function T0(e,t){if(typeof IntersectionObserver!="function"){A0(e,t);return}let n=[];j(()=>{const r=()=>{const s=!!n.length;n=e(),s&&yh(e(),t)},o=$0(e()),i=new IntersectionObserver(r,{root:o});for(const s of e()){const a=s.ref();a&&i.observe(a)}Y(()=>i.disconnect())})}function D0(e={}){const[t,n]=xy({value:()=>T(e.items),onChange:i=>{var s;return(s=e.onItemsChange)==null?void 0:s.call(e,i)}});T0(t,n);const r=i=>(n(s=>{const a=O0(s,i);return Om(s,i,a)}),()=>{n(s=>{const a=s.filter(l=>l.ref()!==i.ref());return s.length===a.length?s:a})});return{DomCollectionProvider:i=>w(ph.Provider,{value:{registerItem:r},get children(){return i.children}})}}function L0(e){const t=R0(),n=Z({shouldRegisterItem:!0},e);j(()=>{if(!n.shouldRegisterItem)return;const r=t.registerItem(n.getItem());Y(r)})}function wh(e={}){const[t,n]=Af({value:()=>T(e.isSelected),defaultValue:()=>!!T(e.defaultIsSelected),onChange:i=>{var s;return(s=e.onSelectedChange)==null?void 0:s.call(e,i)}});return{isSelected:t,setIsSelected:i=>{!T(e.isReadOnly)&&!T(e.isDisabled)&&n(i)},toggle:()=>{!T(e.isReadOnly)&&!T(e.isDisabled)&&n(!t())}}}var bh=Ce();function Io(){return xe(bh)}function Lr(){const e=Io();if(e===void 0)throw new Error("[kobalte]: `useMenubarContext` must be used within a `Menubar` component");return e}var Sh=Ce();function dl(){return xe(Sh)}function Po(){const e=dl();if(e===void 0)throw new Error("[kobalte]: `useNavigationMenuContext` must be used within a `NavigationMenu` component");return e}var xh=Ce();function $i(){return xe(xh)}function Ut(){const e=$i();if(e===void 0)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var Ch=Ce();function fl(){const e=xe(Ch);if(e===void 0)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var Eh=Ce();function At(){const e=xe(Eh);if(e===void 0)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function hl(e){let t;const n=At(),r=Ut(),o=Z({id:n.generateId(`item-${Ie()}`)},e),[i,s]=_(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=z(),[c,u]=z(),[f,d]=z(),h=()=>r.listState().selectionManager(),p=()=>s.id,g=()=>h().focusedKey()===p(),v=()=>{var $;($=i.onSelect)==null||$.call(i),i.closeOnSelect&&setTimeout(()=>{r.close(!0)})};L0({getItem:()=>{var $;return{ref:()=>t,type:"item",key:p(),textValue:i.textValue??(($=f())==null?void 0:$.textContent)??(t==null?void 0:t.textContent)??"",disabled:i.disabled??!1}}});const m=ul({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),y=$=>{ee($,i.onPointerMove),$.pointerType==="mouse"&&(i.disabled?r.onItemLeave($):(r.onItemEnter($),$.defaultPrevented||(Fe($.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(p()))))},b=$=>{ee($,i.onPointerLeave),$.pointerType==="mouse"&&r.onItemLeave($)},S=$=>{ee($,i.onPointerUp),!i.disabled&&$.button===0&&v()},C=$=>{if(ee($,i.onKeyDown),!$.repeat&&!i.disabled)switch($.key){case"Enter":case" ":v();break}},R=L(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),D=L(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":g()?"":void 0})),V={isChecked:()=>i.checked,dataset:D,setLabelRef:d,generateId:Ye(()=>s.id),registerLabel:_e(l),registerDescription:_e(u)};return w(Ch.Provider,{value:V,get children(){return w(le,F({as:"div",ref($){var k=me(N=>t=N,i.ref);typeof k=="function"&&k($)},get tabIndex(){return m.tabIndex()},get"aria-checked"(){return R()},get"aria-disabled"(){return i.disabled},get"aria-labelledby"(){return a()},get"aria-describedby"(){return c()},get"data-key"(){return m.dataKey()},get onPointerDown(){return ye([i.onPointerDown,m.onPointerDown])},get onPointerUp(){return ye([S,m.onPointerUp])},get onClick(){return ye([i.onClick,m.onClick])},get onKeyDown(){return ye([C,m.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,m.onMouseDown])},get onFocus(){return ye([i.onFocus,m.onFocus])},onPointerMove:y,onPointerLeave:b},D,s))}})}function _0(e){const t=Z({closeOnSelect:!1},e),[n,r]=_(t,["checked","defaultChecked","onChange","onSelect"]),o=wh({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:s=>{var a;return(a=n.onChange)==null?void 0:a.call(n,s)},isDisabled:()=>r.disabled});return w(hl,F({role:"menuitemcheckbox",get checked(){return o.isSelected()},onSelect:()=>{var s;(s=n.onSelect)==null||s.call(n),o.toggle()}},r))}var co={next:(e,t)=>e==="ltr"?t==="horizontal"?"ArrowRight":"ArrowDown":t==="horizontal"?"ArrowLeft":"ArrowUp",previous:(e,t)=>co.next(e==="ltr"?"rtl":"ltr",t)},xc={first:e=>e==="horizontal"?"ArrowDown":"ArrowRight",last:e=>e==="horizontal"?"ArrowUp":"ArrowLeft"};function Cc(e){const t=At(),n=Ut(),r=Io(),{direction:o}=xn(),i=Z({id:t.generateId("trigger")},e),[s,a]=_(i,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>t.value();r!==void 0&&(l=()=>t.value()??s.id,r.lastValue()===void 0&&r.setLastValue(l));const c=Ei(()=>n.triggerRef(),()=>"button"),u=L(()=>{var m;return c()==="a"&&((m=n.triggerRef())==null?void 0:m.getAttribute("href"))!=null});j(Ee(()=>r==null?void 0:r.value(),m=>{var y;u()&&m===l()&&((y=n.triggerRef())==null||y.focus())}));const f=()=>{r!==void 0?n.isOpen()?r.value()===l()&&r.closeMenu():(r.autoFocusMenu()||r.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)},d=m=>{ee(m,s.onPointerDown),m.currentTarget.dataset.pointerType=m.pointerType,!s.disabled&&m.pointerType!=="touch"&&m.button===0&&f()},h=m=>{ee(m,s.onClick),s.disabled||m.currentTarget.dataset.pointerType==="touch"&&f()},p=m=>{if(ee(m,s.onKeyDown),!s.disabled){if(u())switch(m.key){case"Enter":case" ":return}switch(m.key){case"Enter":case" ":case xc.first(t.orientation()):m.stopPropagation(),m.preventDefault(),Qm(m.currentTarget),n.open("first"),r==null||r.setAutoFocusMenu(!0),r==null||r.setValue(l);break;case xc.last(t.orientation()):m.stopPropagation(),m.preventDefault(),n.open("last");break;case co.next(o(),t.orientation()):if(r===void 0)break;m.stopPropagation(),m.preventDefault(),r.nextMenu();break;case co.previous(o(),t.orientation()):if(r===void 0)break;m.stopPropagation(),m.preventDefault(),r.previousMenu();break}}},g=m=>{var y;ee(m,s.onMouseOver),((y=n.triggerRef())==null?void 0:y.dataset.pointerType)!=="touch"&&!s.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(l)},v=m=>{ee(m,s.onFocus),r!==void 0&&m.currentTarget.dataset.pointerType!=="touch"&&r.setValue(l)};return j(()=>Y(n.registerTriggerId(s.id))),w(xt,F({ref(m){var y=me(n.setTriggerRef,s.ref);typeof y=="function"&&y(m)},get"data-kb-menu-value-trigger"(){return t.value()},get id(){return s.id},get disabled(){return s.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return L(()=>!!n.isOpen())()?n.contentId():void 0},get"data-highlighted"(){return l()!==void 0&&(r==null?void 0:r.value())===l()?!0:void 0},get tabIndex(){return r!==void 0?r.value()===l()||r.lastValue()===l()?0:-1:void 0},onPointerDown:d,onMouseOver:g,onClick:h,onKeyDown:p,onFocus:v,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),a))}function Mh(e){let t;const n=At(),r=Ut(),o=Io(),i=dl(),{direction:s}=xn(),a=Z({id:n.generateId(`content-${Ie()}`)},e),[l,c]=_(a,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let u=0;const f=()=>r.parentMenuContext()==null&&o===void 0&&n.isModal(),d=gh({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused(),orientation:()=>n.orientation()==="horizontal"?"vertical":"horizontal"},()=>t);Ua({trapFocus:()=>f()&&r.isOpen(),onMountAutoFocus:b=>{var S;o===void 0&&((S=l.onOpenAutoFocus)==null||S.call(l,b))},onUnmountAutoFocus:l.onCloseAutoFocus},()=>t);const h=b=>{if($e(b.currentTarget,b.target)&&(b.key==="Tab"&&r.isOpen()&&b.preventDefault(),o!==void 0&&b.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(b.key){case co.next(s(),n.orientation()):b.stopPropagation(),b.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case co.previous(s(),n.orientation()):if(b.currentTarget.hasAttribute("data-closed"))break;b.stopPropagation(),b.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},p=b=>{var S;(S=l.onEscapeKeyDown)==null||S.call(l,b),o==null||o.setAutoFocusMenu(!1),r.close(!0)},g=b=>{var S;(S=l.onFocusOutside)==null||S.call(l,b),n.isModal()&&b.preventDefault()},v=b=>{var S,C;ee(b,l.onPointerEnter),r.isOpen()&&((S=r.parentMenuContext())==null||S.listState().selectionManager().setFocused(!1),(C=r.parentMenuContext())==null||C.listState().selectionManager().setFocusedKey(void 0))},m=b=>{if(ee(b,l.onPointerMove),b.pointerType!=="mouse")return;const S=b.target,C=u!==b.clientX;$e(b.currentTarget,S)&&C&&(r.setPointerDir(b.clientX>u?"right":"left"),u=b.clientX)};j(()=>Y(r.registerContentId(l.id))),Y(()=>r.setContentRef(void 0));const y={ref:me(b=>{r.setContentRef(b),t=b},l.ref),role:"menu",get id(){return l.id},get tabIndex(){return d.tabIndex()},get"aria-labelledby"(){return r.triggerId()},onKeyDown:ye([l.onKeyDown,d.onKeyDown,h]),onMouseDown:ye([l.onMouseDown,d.onMouseDown]),onFocusIn:ye([l.onFocusIn,d.onFocusIn]),onFocusOut:ye([l.onFocusOut,d.onFocusOut]),onPointerEnter:v,onPointerMove:m,get"data-orientation"(){return n.orientation()}};return w(de,{get when(){return r.contentPresent()},get children(){return w(de,{get when(){return i===void 0||r.parentMenuContext()!=null},get fallback(){return w(le,F({as:"div"},()=>r.dataset(),y,c))},get children(){return w(Cn.Positioner,{get children(){return w(xo,F({get disableOutsidePointerEvents(){return L(()=>!!f())()&&r.isOpen()},get excludedElements(){return[r.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ct({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:p,onFocusOutside:g,get onDismiss(){return r.close}},()=>r.dataset(),y,c))}})}})}})}function k0(e){let t;const n=At(),r=Ut(),[o,i]=_(e,["ref"]);return Ga({element:()=>t??null,enabled:()=>r.contentPresent()&&n.preventScroll()}),w(Mh,F({ref(s){var a=me(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}var Ih=Ce();function V0(){const e=xe(Ih);if(e===void 0)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}function Ph(e){const t=At(),n=Z({id:t.generateId(`group-${Ie()}`)},e),[r,o]=z(),i={generateId:Ye(()=>n.id),registerLabelId:_e(o)};return w(Ih.Provider,{value:i,get children(){return w(le,F({as:"div",role:"group",get"aria-labelledby"(){return r()}},n))}})}function N0(e){const t=V0(),n=Z({id:t.generateId("label")},e),[r,o]=_(n,["id"]);return j(()=>Y(t.registerLabelId(r.id))),w(le,F({as:"span",get id(){return r.id},"aria-hidden":"true"},o))}function Rh(e){const t=Ut(),n=Z({children:"▼"},e);return w(le,F({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function K0(e){return w(hl,F({role:"menuitem",closeOnSelect:!0},e))}function z0(e){const t=fl(),n=Z({id:t.generateId("description")},e),[r,o]=_(n,["id"]);return j(()=>Y(t.registerDescription(r.id))),w(le,F({as:"div",get id(){return r.id}},()=>t.dataset(),o))}function B0(e){const t=fl(),n=Z({id:t.generateId("indicator")},e),[r,o]=_(n,["forceMount"]);return w(de,{get when(){return r.forceMount||t.isChecked()},get children(){return w(le,F({as:"div"},()=>t.dataset(),o))}})}function j0(e){const t=fl(),n=Z({id:t.generateId("label")},e),[r,o]=_(n,["ref","id"]);return j(()=>Y(t.registerLabel(r.id))),w(le,F({as:"div",ref(i){var s=me(t.setLabelRef,r.ref);typeof s=="function"&&s(i)},get id(){return r.id}},()=>t.dataset(),o))}function U0(e){const t=Ut();return w(de,{get when(){return t.contentPresent()},get children(){return w(mo,e)}})}var Oh=Ce();function H0(){const e=xe(Oh);if(e===void 0)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}function G0(e){const n=At().generateId(`radiogroup-${Ie()}`),r=Z({id:n},e),[o,i]=_(r,["value","defaultValue","onChange","disabled"]),[s,a]=wt({value:()=>o.value,defaultValue:()=>o.defaultValue,onChange:c=>{var u;return(u=o.onChange)==null?void 0:u.call(o,c)}}),l={isDisabled:()=>o.disabled,isSelectedValue:c=>c===s(),setSelectedValue:c=>a(c)};return w(Oh.Provider,{value:l,get children(){return w(Ph,i)}})}function q0(e){const t=H0(),n=Z({closeOnSelect:!1},e),[r,o]=_(n,["value","onSelect"]);return w(hl,F({role:"menuitemradio",get checked(){return t.isSelectedValue(r.value)},onSelect:()=>{var s;(s=r.onSelect)==null||s.call(r),t.setSelectedValue(r.value)}},o))}function W0(e,t,n){const r=e.split("-")[0],o=n.getBoundingClientRect(),i=[],s=t.clientX,a=t.clientY;switch(r){case"top":i.push([s,a+5]),i.push([o.left,o.bottom]),i.push([o.left,o.top]),i.push([o.right,o.top]),i.push([o.right,o.bottom]);break;case"right":i.push([s-5,a]),i.push([o.left,o.top]),i.push([o.right,o.top]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]);break;case"bottom":i.push([s,a-5]),i.push([o.right,o.top]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]),i.push([o.left,o.top]);break;case"left":i.push([s+5,a]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]),i.push([o.left,o.top]),i.push([o.right,o.top]);break}return i}function Q0(e,t){return t?hf([e.clientX,e.clientY],t):!1}function Fh(e){const t=At(),n=mh(),r=$i(),o=Io(),i=dl(),s=Z({placement:t.orientation()==="horizontal"?"bottom-start":"right-start"},e),[a,l]=_(s,["open","defaultOpen","onOpenChange"]);let c=0,u=null,f="right";const[d,h]=z(),[p,g]=z(),[v,m]=z(),[y,b]=z(),[S,C]=z(!0),[R,D]=z(l.placement),[V,$]=z([]),[k,N]=z([]),{DomCollectionProvider:B}=D0({items:k,onItemsChange:N}),ne=Co({open:()=>a.open,defaultOpen:()=>a.defaultOpen,onOpenChange:ie=>{var Pe;return(Pe=a.onOpenChange)==null?void 0:Pe.call(a,ie)}}),{present:I}=Vn({show:()=>t.forceMount()||ne.isOpen(),element:()=>y()??null}),M=cl({selectionMode:"none",dataSource:k}),x=ie=>{C(ie),ne.open()},O=(ie=!1)=>{ne.close(),ie&&r&&r.close(!0)},P=ie=>{C(ie),ne.toggle()},A=()=>{const ie=y();ie&&(Fe(ie),M.selectionManager().setFocused(!0),M.selectionManager().setFocusedKey(void 0))},K=()=>{i!=null?setTimeout(()=>A()):A()},H=ie=>{$(Te=>[...Te,ie]);const Pe=r==null?void 0:r.registerNestedMenu(ie);return()=>{$(Te=>Ws(Te,ie)),Pe==null||Pe()}},q=ie=>f===(u==null?void 0:u.side)&&Q0(ie,u==null?void 0:u.area),oe=ie=>{q(ie)&&ie.preventDefault()},J=ie=>{q(ie)||K()},fe=ie=>{q(ie)&&ie.preventDefault()};Ha({isDisabled:()=>!(r==null&&ne.isOpen()&&t.isModal()),targets:()=>[y(),...V()].filter(Boolean)}),j(()=>{const ie=y();if(!ie||!r)return;const Pe=r.registerNestedMenu(ie);Y(()=>{Pe()})}),j(()=>{r===void 0&&(o==null||o.registerMenu(t.value(),[y(),...V()]))}),j(()=>{var ie;r!==void 0||o===void 0||(o.value()===t.value()?((ie=v())==null||ie.focus(),o.autoFocusMenu()&&x(!0)):O())}),j(()=>{r!==void 0||o===void 0||ne.isOpen()&&o.setValue(t.value())}),Y(()=>{r===void 0&&(o==null||o.unregisterMenu(t.value()))});const Je={dataset:L(()=>({"data-expanded":ne.isOpen()?"":void 0,"data-closed":ne.isOpen()?void 0:""})),isOpen:ne.isOpen,contentPresent:I,nestedMenus:V,currentPlacement:R,pointerGraceTimeoutId:()=>c,autoFocus:S,listState:()=>M,parentMenuContext:()=>r,triggerRef:v,contentRef:y,triggerId:d,contentId:p,setTriggerRef:m,setContentRef:b,open:x,close:O,toggle:P,focusContent:K,onItemEnter:oe,onItemLeave:J,onTriggerLeave:fe,setPointerDir:ie=>f=ie,setPointerGraceTimeoutId:ie=>c=ie,setPointerGraceIntent:ie=>u=ie,registerNestedMenu:H,registerItemToParentDomCollection:n==null?void 0:n.registerItem,registerTriggerId:_e(h),registerContentId:_e(g)};return w(B,{get children(){return w(xh.Provider,{value:Je,get children(){return w(de,{when:i===void 0,get fallback(){return l.children},get children(){return w(Cn,F({anchorRef:v,contentRef:y,onCurrentPlacementChange:D},l))}})}})}})}function X0(e){const{direction:t}=xn();return w(Fh,F({get placement(){return t()==="rtl"?"left-start":"right-start"},flip:!0},e))}var Y0={close:(e,t)=>e==="ltr"?[t==="horizontal"?"ArrowLeft":"ArrowUp"]:[t==="horizontal"?"ArrowRight":"ArrowDown"]};function J0(e){const t=Ut(),n=At(),[r,o]=_(e,["onFocusOutside","onKeyDown"]),{direction:i}=xn();return w(Mh,F({onOpenAutoFocus:u=>{u.preventDefault()},onCloseAutoFocus:u=>{u.preventDefault()},onFocusOutside:u=>{var d;(d=r.onFocusOutside)==null||d.call(r,u);const f=u.target;$e(t.triggerRef(),f)||t.close()},onKeyDown:u=>{ee(u,r.onKeyDown);const f=$e(u.currentTarget,u.target),d=Y0.close(i(),n.orientation()).includes(u.key),h=t.parentMenuContext()!=null;f&&d&&h&&(t.close(),Fe(t.triggerRef()))}},o))}var Ec=["Enter"," "],Z0={open:(e,t)=>e==="ltr"?[...Ec,t==="horizontal"?"ArrowRight":"ArrowDown"]:[...Ec,t==="horizontal"?"ArrowLeft":"ArrowUp"]};function eS(e){let t;const n=At(),r=Ut(),o=Z({id:n.generateId(`sub-trigger-${Ie()}`)},e),[i,s]=_(o,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let a=null;const l=()=>{a&&window.clearTimeout(a),a=null},{direction:c}=xn(),u=()=>i.id,f=()=>{const b=r.parentMenuContext();if(b==null)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return b.listState().selectionManager()},d=()=>r.listState().collection(),h=()=>f().focusedKey()===u(),p=ul({key:u,selectionManager:f,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),g=b=>{ee(b,i.onClick),!r.isOpen()&&!i.disabled&&r.open(!0)},v=b=>{var C;if(ee(b,i.onPointerMove),b.pointerType!=="mouse")return;const S=r.parentMenuContext();if(S==null||S.onItemEnter(b),!b.defaultPrevented){if(i.disabled){S==null||S.onItemLeave(b);return}!r.isOpen()&&!a&&((C=r.parentMenuContext())==null||C.setPointerGraceIntent(null),a=window.setTimeout(()=>{r.open(!1),l()},100)),S==null||S.onItemEnter(b),b.defaultPrevented||(r.listState().selectionManager().isFocused()&&(r.listState().selectionManager().setFocused(!1),r.listState().selectionManager().setFocusedKey(void 0)),Fe(b.currentTarget),S==null||S.listState().selectionManager().setFocused(!0),S==null||S.listState().selectionManager().setFocusedKey(u()))}},m=b=>{if(ee(b,i.onPointerLeave),b.pointerType!=="mouse")return;l();const S=r.parentMenuContext(),C=r.contentRef();if(C){S==null||S.setPointerGraceIntent({area:W0(r.currentPlacement(),b,C),side:r.currentPlacement().split("-")[0]}),window.clearTimeout(S==null?void 0:S.pointerGraceTimeoutId());const R=window.setTimeout(()=>{S==null||S.setPointerGraceIntent(null)},300);S==null||S.setPointerGraceTimeoutId(R)}else{if(S==null||S.onTriggerLeave(b),b.defaultPrevented)return;S==null||S.setPointerGraceIntent(null)}S==null||S.onItemLeave(b)},y=b=>{ee(b,i.onKeyDown),!b.repeat&&(i.disabled||Z0.open(c(),n.orientation()).includes(b.key)&&(b.stopPropagation(),b.preventDefault(),f().setFocused(!1),f().setFocusedKey(void 0),r.isOpen()||r.open("first"),r.focusContent(),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(d().getFirstKey())))};return j(()=>{if(r.registerItemToParentDomCollection==null)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");const b=r.registerItemToParentDomCollection({ref:()=>t,type:"item",key:u(),textValue:i.textValue??(t==null?void 0:t.textContent)??"",disabled:i.disabled??!1});Y(b)}),j(Ee(()=>{var b;return(b=r.parentMenuContext())==null?void 0:b.pointerGraceTimeoutId()},b=>{Y(()=>{var S;window.clearTimeout(b),(S=r.parentMenuContext())==null||S.setPointerGraceIntent(null)})})),j(()=>Y(r.registerTriggerId(i.id))),Y(()=>{l()}),w(le,F({as:"div",ref(b){var S=me(C=>{r.setTriggerRef(C),t=C},i.ref);typeof S=="function"&&S(b)},get id(){return i.id},role:"menuitem",get tabIndex(){return p.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return r.isOpen()},get"aria-controls"(){return L(()=>!!r.isOpen())()?r.contentId():void 0},get"aria-disabled"(){return i.disabled},get"data-key"(){return p.dataKey()},get"data-highlighted"(){return h()?"":void 0},get"data-disabled"(){return i.disabled?"":void 0},get onPointerDown(){return ye([i.onPointerDown,p.onPointerDown])},get onPointerUp(){return ye([i.onPointerUp,p.onPointerUp])},get onClick(){return ye([g,p.onClick])},get onKeyDown(){return ye([y,p.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,p.onMouseDown])},get onFocus(){return ye([i.onFocus,p.onFocus])},onPointerMove:v,onPointerLeave:m},()=>r.dataset(),s))}function tS(e){const t=Io(),n=`menu-${Ie()}`,r=Z({id:n,modal:!0},e),[o,i]=_(r,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),s=Co({open:()=>o.open,defaultOpen:()=>o.defaultOpen,onOpenChange:l=>{var c;return(c=o.onOpenChange)==null?void 0:c.call(o,l)}}),a={isModal:()=>o.modal??!0,preventScroll:()=>o.preventScroll??a.isModal(),forceMount:()=>o.forceMount??!1,generateId:Ye(()=>o.id),value:()=>o.value,orientation:()=>o.orientation??(t==null?void 0:t.orientation())??"horizontal"};return w(Eh.Provider,{value:a,get children(){return w(Fh,F({get open(){return s.isOpen()},get onOpenChange(){return s.setIsOpen}},i))}})}function $h(e){const t=Lr(),n=Z({modal:!1},e),[r,o]=_(n,["value"]),i=Ie(),s=t.generateId(`menubar-menu-${i}`),a=Z({id:s},o);return w(tS,F({get value(){return r.value??i}},a))}function nS(e){let t;const n=`menubar-${Ie()}`,r=Z({id:n,loop:!0,orientation:"horizontal"},e),[o,i]=_(r,["ref","value","defaultValue","onValueChange","loop","focusOnAlt","autoFocusMenu","onAutoFocusMenuChange","orientation"]),[s,a]=wt({value:()=>o.value,defaultValue:()=>o.defaultValue,onChange:y=>{var b;return(b=o.onValueChange)==null?void 0:b.call(o,y)}}),[l,c]=z(),[u,f]=z(new Map),[d,h]=wt({value:()=>o.autoFocusMenu,defaultValue:()=>!1,onChange:o.onAutoFocusMenuChange}),p=()=>{var y;return s()&&d()&&!((y=s())!=null&&y.includes("link-trigger-"))},v={dataset:L(()=>({"data-expanded":p()?"":void 0,"data-closed":p()?void 0:""})),value:s,setValue:a,lastValue:l,setLastValue:c,menus:()=>new Set([...u().keys()]),menuRefs:()=>[...u().values()].flat(),menuRefMap:()=>u(),registerMenu:(y,b)=>{f(S=>{const C=new Map;return S.forEach((R,D)=>C.set(D,R)),C.set(y,b),C})},unregisterMenu:y=>{f(b=>{b.delete(y);const S=new Map;return b.forEach((C,R)=>S.set(R,C)),S})},nextMenu:()=>{const y=[...u().keys()];if(s()==null){a(y[0]);return}const b=y.indexOf(s());if(b===y.length-1){o.loop&&a(y[0]);return}a(y[b+1])},previousMenu:()=>{const y=[...u().keys()];if(s()==null){a(y[0]);return}const b=y.indexOf(s());if(b===0){o.loop&&a(y[y.length-1]);return}a(y[b-1])},closeMenu:()=>{h(!1),a(void 0)},autoFocusMenu:()=>d(),setAutoFocusMenu:h,generateId:Ye(()=>i.id),orientation:()=>o.orientation};j(()=>{s()==null&&h(!1)}),Ff({onInteractOutside:()=>{v.closeMenu(),setTimeout(()=>v.closeMenu())},shouldExcludeElement:y=>[t,...u().values()].flat().some(b=>$e(b,y))},()=>t);const m=y=>{y.key==="Alt"&&(y.preventDefault(),y.stopPropagation(),v.value()===void 0?v.nextMenu():v.closeMenu())};return j(()=>{o.focusOnAlt?window.addEventListener("keydown",m):window.removeEventListener("keydown",m),Y(()=>{window.removeEventListener("keydown",m)})}),j(()=>{s()!=null&&c(s())}),w(bh.Provider,{value:v,get children(){return w(le,F({as:"div",ref(y){var b=me(S=>t=S,o.ref);typeof b=="function"&&b(y)},role:"menubar",get"data-orientation"(){return o.orientation},get"aria-orientation"(){return o.orientation}},i))}})}function rS(e){const t=Lr();if($i()===void 0&&Object.hasOwn(e,"href")){const r=t.generateId("link-trigger-")+Ie();return w($h,{value:r,get children(){return w(Cc,e)}})}return Cc(e)}var oS={};dt(oS,{Root:()=>gl,Separator:()=>iS});function gl(e){let t;const n=Z({orientation:"horizontal"},e),[r,o]=_(n,["ref","orientation"]),i=Ei(()=>t,()=>"hr");return w(le,F({as:"hr",ref(s){var a=me(l=>t=l,r.ref);typeof a=="function"&&a(s)},get role(){return i()!=="hr"?"separator":void 0},get"aria-orientation"(){return r.orientation==="vertical"?"vertical":void 0},get"data-orientation"(){return r.orientation}},o))}var iS=gl,Ah=te("<li role=presentation>"),sS=te("<nav>");function aS(e){let t;const n=Lr(),r=Z({size:15},e),[o,i]=_(r,["ref"]),[s,a]=z(0),l=()=>n.orientation()==="horizontal";return j(Ee(n.value,c=>{setTimeout(()=>{if(!c||c.includes("link-trigger-"))return;const u=document.querySelector(`[data-kb-menu-value-trigger="${c}"]`);if(!u||!t)return;const f=u.getBoundingClientRect()[l()?"x":"y"]+u.getBoundingClientRect()[l()?"width":"height"]/2,d=window.getComputedStyle(t),h=t.getBoundingClientRect()[l()?"x":"y"]+t.getBoundingClientRect()[l()?"width":"height"]/2-Number.parseFloat(d.transform.split(",")[l()?4:5]);a(f-h)})})),w(Dr,F({ref(c){var u=me(f=>t=f,o.ref);typeof u=="function"&&u(c)},get style(){return{transform:`translate${l()?"X":"Y"}(${s()}px)`,color:"red"}}},i))}function Th(e){const t=Po(),n=Lr(),r=At(),[o,i]=z(),[s,a]=_(e,["onPointerEnter","onPointerLeave"]),l=u=>{ee(u,s.onPointerEnter),t.cancelLeaveTimer()},c=u=>{ee(u,s.onPointerLeave),t.startLeaveTimer()};return j(Ee(n.value,u=>{bi(()=>{if(!u||u.includes("link-trigger-")){t.setPreviousMenu(void 0);return}if(u===r.value()){if(t.previousMenu()!=null){const p=[...n.menus()],g=p.indexOf(t.previousMenu()),v=p.indexOf(u);g<v?i("from-end"):i("from-start")}else i(void 0);t.setPreviousMenu(u);return}const f=[...n.menus()],d=f.indexOf(t.previousMenu()),h=f.indexOf(u);d>h?i("to-end"):i("to-start")})})),w(k0,F({as:"ul",onPointerEnter:l,onPointerLeave:c,onInteractOutside:()=>{t.setAutoFocusMenu(!1)},get"data-motion"(){return o()}},a))}function Dh(e){return(()=>{var t=Ah();return W(t,w(K0,F({as:"a"},e))),t})()}function Lh(e){const t=Lr(),n=Po(),[r,o]=_(e,["value"]),i=Ie(),s=t.generateId(`navigation-menu-menu-${i}`),a=Z({id:s},o),l=()=>r.value??i,[c,u]=z(!1),f=()=>{var d,h;t.value()!==l()&&u(!1),(d=n.viewportRef())==null||d.removeEventListener("animationend",f),(h=n.viewportRef())==null||h.removeEventListener("animationcancel",f)};return j(Ee(t.value,d=>{if(d===l())u(!0);else{const h=n.viewportRef();if(!h||["","none"].includes(window.getComputedStyle(h).animationName)){u(!1);return}h.addEventListener("animationend",f)}})),w($h,F({get forceMount(){return c()},get value(){return l()}},a))}function _h(e){const t=Po(),n=Ut(),[r,o]=_(e,["ref"]);return w(de,{get when(){return t.viewportPresent()},get children(){return w(U0,F({ref(i){var s=me(a=>{a&&a.setAttribute("role","presentation")},r.ref);typeof s=="function"&&s(i)},get mount(){return L(()=>n.parentMenuContext()==null)()?t.viewportRef():void 0}},o))}})}function kh(e){const t=Z({delayDuration:200,skipDelayDuration:300},e),[n,r,o]=_(t,["ref","delayDuration","skipDelayDuration","autoFocusMenu","onAutoFocusMenuChange","defaultValue","value","onValueChange","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"]),[i,s]=wt({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:$=>{var k;return(k=n.onValueChange)==null?void 0:k.call(n,$)}}),[a,l]=wt({value:()=>n.autoFocusMenu,defaultValue:()=>!1,onChange:n.onAutoFocusMenuChange}),[c,u]=z(),[f,d]=z(),[h,p]=z(r.placement??o.orientation==="vertical"?"right":"bottom");j(()=>{p(o.orientation==="vertical"?"right":"bottom")});let g;const[v,m]=z(),[y,b]=z(!1),[S,C]=z(!1);j(()=>{i()&&!i().includes("link-trigger-")&&a()?bi(()=>{C(!0),b(!0)}):(C(!1),b(!1))});const R=L(()=>({"data-expanded":S()?"":void 0,"data-closed":S()?void 0:""})),{present:D}=Vn({show:()=>n.forceMount||y()||S(),element:()=>c()??null});j(()=>{D()||V.setPreviousMenu(void 0)});const V={dataset:R,delayDuration:()=>n.delayDuration,skipDelayDuration:()=>n.skipDelayDuration,autoFocusMenu:a,setAutoFocusMenu:l,startLeaveTimer:()=>{g=window.setTimeout(()=>{V.setAutoFocusMenu(!1),s(void 0)},V.skipDelayDuration())},cancelLeaveTimer:()=>{g&&clearTimeout(g)},rootRef:f,setRootRef:d,viewportRef:c,setViewportRef:u,viewportPresent:D,currentPlacement:h,previousMenu:v,setPreviousMenu:m};return w(Sh.Provider,{value:V,get children(){return w(Cn,F({anchorRef:f,contentRef:c,get placement(){return h()},onCurrentPlacementChange:p},r,{get children(){var $=sS();return W($,w(nS,F({as:"ul",ref(k){var N=me(V.setRootRef,n.ref);typeof N=="function"&&N(k)},get value(){return i()??null},onValueChange:s,get autoFocusMenu(){return a()},onAutoFocusMenuChange:l},o))),$}}))}})}function Vh(e){const t=Po(),n=$i(),[r,o]=_(e,["onPointerEnter","onPointerLeave","onClick"]);let i;const s=c=>{ee(c,r.onClick),i&&clearTimeout(i)},a=c=>{ee(c,r.onPointerEnter),c.pointerType!=="touch"&&(t.cancelLeaveTimer(),t.dataset()["data-expanded"]!==""&&(i=window.setTimeout(()=>{var u;(u=n==null?void 0:n.triggerRef())==null||u.focus(),setTimeout(()=>{t.setAutoFocusMenu(!0)})},t.delayDuration())))},l=c=>{ee(c,r.onPointerLeave),c.pointerType!=="touch"&&(t.startLeaveTimer(),i&&clearTimeout(i))};return(()=>{var c=Ah();return W(c,w(rS,F({onClick:s,onPointerEnter:a,onPointerLeave:l},o))),c})()}function Nh(e){const t=Po(),n=Lr(),[r,o]=z(),[i,s]=_(e,["ref","style","onEscapeKeyDown"]),a=()=>{n.setAutoFocusMenu(!1),n.closeMenu()},l=d=>{a()},c=b0(r);j(Ee(()=>n.value()?n.menuRefMap().get(n.value()):void 0,d=>{d===void 0||d[0]===void 0||o(d[0])}));const u=L(d=>{if(!(r()===void 0||!t.viewportPresent()))return c.height()===0?d:c.height()}),f=L(d=>{if(!(r()===void 0||!t.viewportPresent()))return c.width()===0?d:c.width()});return w(de,{get when(){return t.viewportPresent()},get children(){return w(Cn.Positioner,{role:"presentation",get children(){return w(xo,F({as:"li",ref(d){var h=me(t.setViewportRef,i.ref);typeof h=="function"&&h(d)},get excludedElements(){return[t.rootRef]},bypassTopMostLayerCheck:!0,get style(){return ct({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)","--kb-navigation-menu-viewport-height":u()?`${u()}px`:void 0,"--kb-navigation-menu-viewport-width":f()?`${f()}px`:void 0,position:"relative"},i.style)},get onEscapeKeyDown(){return ye([i.onEscapeKeyDown,l])},onDismiss:a,get"data-orientation"(){return n.orientation()}},()=>t.dataset(),s))}})}})}Object.assign(kh,{Arrow:aS,CheckboxItem:_0,Content:Th,Group:Ph,GroupLabel:N0,Icon:Rh,Item:Dh,ItemDescription:z0,ItemIndicator:B0,ItemLabel:j0,Portal:_h,RadioGroup:G0,RadioItem:q0,Menu:Lh,Separator:gl,Sub:X0,SubContent:J0,SubTrigger:eS,Trigger:Vh,Viewport:Nh});var lS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class="relative top-px ml-1 size-3 transition duration-200 group-data-[expanded]/trigger:rotate-180 group-data-[orientation=vertical]/menu:-rotate-90 group-data-[orientation=vertical]/menu:group-data-[expanded]/trigger:rotate-90"><path d="M6 9l6 6l6 -6">');const Mc=Lh,Ic=e=>{const[t,n]=_(e,["class","children"]);return w(kh,F({gutter:6,get class(){return ce("group/menu flex w-max flex-1 list-none items-center justify-center data-[orientation=vertical]:flex-col [&>li]:w-full",t.class)}},n,{get children(){return[L(()=>t.children),w(uS,{})]}}))},Pc=e=>{const[t,n]=_(e,["class"]);return w(Vh,F({get class(){return ce("group/trigger inline-flex h-10 w-full items-center justify-center whitespace-nowrap rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[expanded]:bg-accent/50",t.class)}},n))},Rc=()=>w(Rh,{"aria-hidden":"true",get children(){return lS()}}),uS=e=>{const[t,n]=_(e,["class"]);return w(Nh,F({get class(){return ce("pointer-events-none z-[1000] flex h-[var(--kb-navigation-menu-viewport-height)] w-[var(--kb-navigation-menu-viewport-width)] origin-[var(--kb-menu-content-transform-origin)] items-center justify-center overflow-x-clip overflow-y-visible rounded-md border bg-popover opacity-0 shadow-lg data-[expanded]:pointer-events-auto data-[orientation=vertical]:overflow-y-clip data-[orientation=vertical]:overflow-x-visible data-[expanded]:rounded-md","animate-content-hide transition-[width,height] duration-200 ease-in data-[expanded]:animate-content-show data-[expanded]:opacity-100 data-[expanded]:ease-out",t.class)}},n))},Oc=e=>{const[t,n]=_(e,["class"]);return w(_h,{get children(){return w(Th,F({get class(){return ce("pointer-events-none absolute left-0 top-0 box-border p-1 focus:outline-none data-[expanded]:pointer-events-auto","data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out","data-[orientation=horizontal]:data-[motion=from-start]:slide-in-from-left-52 data-[orientation=horizontal]:data-[motion=to-end]:slide-out-to-right-52","data-[orientation=horizontal]:data-[motion=from-end]:slide-in-from-right-52 data-[orientation=horizontal]:data-[motion=to-start]:slide-out-to-left-52","data-[orientation=vertical]:data-[motion=from-start]:slide-in-from-top-52 data-[orientation=vertical]:data-[motion=to-end]:slide-out-to-bottom-52","data-[orientation=vertical]:data-[motion=from-end]:slide-in-from-bottom-52 data-[orientation=vertical]:data-[motion=to-start]:slide-out-to-bottom-52",t.class)}},n))}})},Fc=e=>{const[t,n]=_(e,["class"]);return w(Dh,F({get class(){return ce("text-sm block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t.class)}},n))};var Ai=te("<li>"),cS=te("<ul>"),dS={};dt(dS,{Ellipsis:()=>pl,Item:()=>ml,Items:()=>vl,Next:()=>yl,Pagination:()=>fS,Previous:()=>wl,Root:()=>bl,usePaginationContext:()=>Ro});function pl(e){return(()=>{var t=Ai();return W(t,w(le,F({as:"div"},e))),t})()}var Kh=Ce();function Ro(){const e=xe(Kh);if(e===void 0)throw new Error("[kobalte]: `usePaginationContext` must be used within a `Pagination` component");return e}function ml(e){const t=Ro(),[n,r]=_(e,["page","onClick"]),o=()=>t.page()===n.page,i=()=>{t.setPage(n.page)};return(()=>{var s=Ai();return W(s,w(xt,F({get"aria-current"(){return o()?"page":void 0},get"data-current"(){return o()?"":void 0},get onClick(){return ye([n.onClick,i])}},r))),s})()}function vl(e){const t=Ro(),n=L(()=>{const{count:r,siblingCount:o,page:i,fixedItems:s,showFirst:a,showLast:l}=t,c=r()<2*o()+(s()?6:4);if(c)return{renderItemsDirectly:c};const u=a()&&i()-1>o(),f=l()&&r()-i()>o();let d=i()-(a()?2:1)>o(),h=r()-i()-(l()?1:0)>o(),p=Math.min(i()-1,o()),g=Math.min(r()-i(),o());if(s()!==!1){const v=p,m=g;p+=Math.max(o()-m,0),g+=Math.max(o()-v,0),u||g++,f||p++,s()===!0&&(d||g++,h||p++),i()-p-(a()?2:1)===1&&(d=!1,p++),r()-i()-g-(l()?1:0)===1&&(h=!1,g++)}return{showFirst:u,showLast:f,showFirstEllipsis:d,showLastEllipsis:h,previousSiblingCount:p,nextSiblingCount:g,renderItemsDirectly:c}});return w(de,{get when(){return n().renderItemsDirectly},get fallback(){return[w(de,{get when(){return n().showFirst},get children(){return t.renderItem(1)}}),w(de,{get when(){return n().showFirstEllipsis},get children(){return t.renderEllipsis()}}),w(et,{get each(){return[...Array(n().previousSiblingCount).keys()].reverse()},children:r=>L(()=>t.renderItem(t.page()-(r+1)))}),L(()=>t.renderItem(t.page())),w(et,{get each(){return[...Array(n().nextSiblingCount).keys()]},children:r=>L(()=>t.renderItem(t.page()+(r+1)))}),w(de,{get when(){return n().showLastEllipsis},get children(){return t.renderEllipsis()}}),w(de,{get when(){return n().showLast},get children(){return t.renderItem(t.count())}})]},get children(){return w(et,{get each(){return[...Array(t.count()).keys()]},children:r=>L(()=>t.renderItem(r+1))})}})}function yl(e){const t=Ro(),[n,r]=_(e,["onClick"]),o=()=>{t.setPage(t.page()+1)},i=()=>t.page()===t.count();return(()=>{var s=Ai();return W(s,w(xt,F({get tabIndex(){return i()||t.page()===t.count()?-1:void 0},get disabled(){return i()},get"aria-disabled"(){return i()||void 0},get"data-disabled"(){return i()?"":void 0},get onClick(){return ye([n.onClick,o])}},r))),s})()}function wl(e){const t=Ro(),[n,r]=_(e,["onClick"]),o=()=>{t.setPage(t.page()-1)},i=()=>t.page()===1;return(()=>{var s=Ai();return W(s,w(xt,F({get tabIndex(){return i()||t.page()===1?-1:void 0},get disabled(){return i()},get"aria-disabled"(){return i()||void 0},get"data-disabled"(){return i()?"":void 0},get onClick(){return ye([n.onClick,o])}},r))),s})()}function bl(e){const t=`pagination-${Ie()}`,n=Z({id:t},e),[r,o]=_(n,["page","defaultPage","onPageChange","count","siblingCount","showFirst","showLast","fixedItems","itemComponent","ellipsisComponent","disabled","children"]),i=wt({defaultValue:()=>r.defaultPage??1,onChange:r.onPageChange,value:()=>r.page}),s={count:()=>r.count,siblingCount:()=>r.siblingCount??1,showFirst:()=>r.showFirst??!0,showLast:()=>r.showLast??!0,fixedItems:()=>r.fixedItems??!1,isDisabled:()=>r.disabled??!1,renderItem:a=>r.itemComponent({page:a}),renderEllipsis:r.ellipsisComponent,page:()=>Math.min(i[0]()??1,r.count),setPage:i[1]};return w(Kh.Provider,{value:s,get children(){return w(le,F({as:"nav",get"data-disabled"(){return r.disabled?"":void 0}},o,{get children(){var a=cS();return W(a,()=>r.children),a}}))}})}var fS=Object.assign(bl,{Ellipsis:pl,Item:ml,Items:vl,Next:yl,Previous:wl});const Ti=Mr("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-10"}},defaultVariants:{variant:"default",size:"default"}}),fn=e=>{const[t,n]=_(e,["variant","size","class"]);return w(xt,F({get class(){return ce(Ti({variant:t.variant,size:t.size}),t.class)}},n))};var hS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><circle cx=12 cy=12 r=1></circle><circle cx=19 cy=12 r=1></circle><circle cx=5 cy=12 r=1>'),gS=te("<span class=sr-only>More pages"),pS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M15 6l-6 6l6 6">'),mS=te("<span>Previous"),vS=te("<span>Next"),yS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M9 6l6 6l-6 6">');const wS=vl,bS=e=>{const[t,n]=_(e,["class"]);return w(bl,F({get class(){return ce("[&>*]:flex [&>*]:flex-row [&>*]:items-center [&>*]:gap-1",t.class)}},n))},SS=e=>{const[t,n]=_(e,["class"]);return w(ml,F({get class(){return ce(Ti({variant:"ghost"}),"size-10 data-[current]:border",t.class)}},n))},xS=e=>{const[t,n]=_(e,["class"]);return w(pl,F({get class(){return ce("flex size-10 items-center justify-center",t.class)}},n,{get children(){return[hS(),gS()]}}))},CS=e=>{const[t,n]=_(e,["class","children"]);return w(wl,F({get class(){return ce(Ti({variant:"ghost"}),"gap-1 pl-2.5",t.class)}},n,{get children(){return t.children??[pS(),mS()]}}))},ES=e=>{const[t,n]=_(e,["class","children"]);return w(yl,F({get class(){return ce(Ti({variant:"ghost"}),"gap-1 pl-2.5",t.class)}},n,{get children(){return t.children??[vS(),yS()]}}))};var MS=te('<div class="relative w-full overflow-auto"><table>'),IS=te("<thead>"),PS=te("<tbody>"),RS=te("<tr>"),OS=te("<th>"),FS=te("<td>");const $S=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=MS(),o=r.firstChild;return qe(o,F({get class(){return ce("w-full caption-bottom text-sm",t.class)}},n),!1,!1),r})()},AS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=IS();return qe(r,F({get class(){return ce("[&_tr]:border-b",t.class)}},n),!1,!1),r})()},TS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=PS();return qe(r,F({get class(){return ce(t.class)}},n),!1,!1),r})()},is=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=RS();return qe(r,F({get class(){return ce("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t.class)}},n),!1,!1),r})()},DS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=OS();return qe(r,F({get class(){return ce("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class)}},n),!1,!1),r})()},$c=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=FS();return qe(r,F({get class(){return ce("p-4 align-middle [&:has([role=checkbox])]:pr-0",t.class)}},n),!1,!1),r})()};var LS=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith("__Secure-")&&!n.secure)throw new Error("__Secure- Cookie must have Secure attributes");if(e.startsWith("__Host-")){if(!n.secure)throw new Error("__Host- Cookie must have Secure attributes");if(n.path!=="/")throw new Error('__Host- Cookie must have Path attributes with "/"');if(n.domain)throw new Error("__Host- Cookie must not have Domain attributes")}if(n&&typeof n.maxAge=="number"&&n.maxAge>=0){if(n.maxAge>3456e4)throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");r+=`; Max-Age=${Math.floor(n.maxAge)}`}if(n.domain&&n.prefix!=="host"&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.partitioned){if(!n.secure)throw new Error("Partitioned Cookie must have Secure attributes");r+="; Partitioned"}return r},_S=(e,t,n)=>(t=encodeURIComponent(t),LS(e,t,n)),kS=(e,t)=>(e=e.replace(/\/+$/,""),e=e+"/",t=t.replace(/^\/+/,""),e+t),ca=(e,t)=>{for(const[n,r]of Object.entries(t)){const o=new RegExp("/:"+n+"(?:{[^/]+})?\\??");e=e.replace(o,r?`/${r}`:"")}return e},VS=(e,t)=>{switch(t){case"ws":return e.replace(/^http/,"ws");case"http":return e.replace(/^ws/,"http")}},NS=e=>/^https?:\/\/[^\/]+?\/index$/.test(e)?e.replace(/\/index$/,"/"):e.replace(/\/index$/,"");function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zh(e,t){if(!Uo(e)&&!Uo(t))return t;const n={...e};for(const r in t){const o=t[r];Uo(n[r])&&Uo(o)?n[r]=zh(n[r],o):n[r]=o}return n}var Bh=(e,t)=>new Proxy(()=>{},{get(r,o){if(!(typeof o!="string"||o==="then"))return Bh(e,[...t,o])},apply(r,o,i){return e({path:t,args:i})}}),KS=class{constructor(e,t){Re(this,"url");Re(this,"method");Re(this,"queryParams");Re(this,"pathParams",{});Re(this,"rBody");Re(this,"cType");Re(this,"fetch",async(e,t)=>{if(e){if(e.query){for(const[a,l]of Object.entries(e.query))if(l!==void 0)if(this.queryParams||(this.queryParams=new URLSearchParams),Array.isArray(l))for(const c of l)this.queryParams.append(a,c);else this.queryParams.set(a,l)}if(e.form){const a=new FormData;for(const[l,c]of Object.entries(e.form))if(Array.isArray(c))for(const u of c)a.append(l,u);else a.append(l,c);this.rBody=a}e.json&&(this.rBody=JSON.stringify(e.json),this.cType="application/json"),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase();const r={...(e==null?void 0:e.header)??{},...typeof(t==null?void 0:t.headers)=="function"?await t.headers():t!=null&&t.headers?t.headers:{}};if(e!=null&&e.cookie){const a=[];for(const[l,c]of Object.entries(e.cookie))a.push(_S(l,c,{path:"/"}));r.Cookie=a.join(",")}this.cType&&(r["Content-Type"]=this.cType);const o=new Headers(r??void 0);let i=this.url;i=NS(i),i=ca(i,this.pathParams),this.queryParams&&(i=i+"?"+this.queryParams.toString()),n=this.method.toUpperCase();const s=!(n==="GET"||n==="HEAD");return((t==null?void 0:t.fetch)||fetch)(i,{body:s?this.rBody:void 0,method:n,headers:o,...t==null?void 0:t.init})});this.url=e,this.method=t}},zS=(e,t)=>Bh(function n(r){var c;const o=[...r.path];if(o[o.length-1]==="toString")return o[o.length-2]==="name"?o[o.length-3]||"":n.toString();if(o[o.length-1]==="valueOf")return o[o.length-2]==="name"?o[o.length-3]||"":n;let i="";if(/^\$/.test(o[o.length-1])){const u=o.pop();u&&(i=u.replace(/^\$/,""))}const s=o.join("/"),a=kS(e,s);if(i==="url")return r.args[0]&&r.args[0].param?new URL(ca(a,r.args[0].param)):new URL(a);if(i==="ws"){const u=VS(r.args[0]&&r.args[0].param?ca(a,r.args[0].param):a,"ws"),f=new URL(u),d=(c=r.args[0])==null?void 0:c.query;return d&&Object.entries(d).forEach(([p,g])=>{Array.isArray(g)?g.forEach(v=>f.searchParams.append(p,v)):f.searchParams.set(p,g)}),((...p)=>(t==null?void 0:t.webSocket)!==void 0&&typeof t.webSocket=="function"?t.webSocket(...p):new WebSocket(...p))(f.toString())}const l=new KS(a,i);if(i){t??(t={});const u=zh(t,{...r.args[1]??{}});return l.fetch(r.args[0],u)}return l},[]);const wn=zS("/rpc"),ss="production",BS=e=>xi(()=>({queryKey:["bundles",e()],queryFn:async()=>(await wn.bundles.$get({query:e()})).json(),placeholderData:t=>t,staleTime:Number.POSITIVE_INFINITY})),jS=e=>xi(()=>({queryKey:["bundle",e],queryFn:()=>wn.bundles[":bundleId"].$get({param:{bundleId:e}}).then(t=>t.json()),placeholderData:t=>t,staleTime:Number.POSITIVE_INFINITY})),US=()=>xi(()=>({queryKey:["config"],queryFn:()=>wn.config.$get().then(e=>e.json()),staleTime:Number.POSITIVE_INFINITY,retryOnMount:!1})),jh=()=>xi(()=>({queryKey:["channels"],queryFn:()=>wn.channels.$get().then(e=>e.json()),staleTime:Number.POSITIVE_INFINITY,retryOnMount:!1,select:e=>!e||e.length===0?null:e.includes(ss)?[ss,...e.filter(t=>t!==ss)]:e})),HS=()=>{const e=yo();return mm(()=>({mutationFn:async t=>{const n=await wn.bundles[":bundleId"].$delete({param:{bundleId:t}});if(!n.ok)throw new Error(`Failed to delete bundle: ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["bundles"]})}}))};var GS=te('<div class="transition-opacity duration-300"><div class="flex flex-row justify-end p-3"><div class="flex items-center gap-4"><div class="text-sm text-muted-foreground">Platform:</div><div class="text-sm text-muted-foreground">Channel:</div></div></div><div class="border rounded-md">'),qS=te('<div class="mt-2 text-sm text-muted-foreground text-center">Showing <!> to <!> of <!> results');const WS=20,[Ct,Ho]=z({pageIndex:0,pageSize:WS});function QS(e){var g;const[t]=_(e,["columns","onRowClick"]),{channelFilter:n,platformFilter:r,setPlatformFilter:o,setChannelFilter:i}=Lf(),s=L(()=>({channel:n()??void 0,platform:r()??void 0,limit:Ct().pageSize.toString(),offset:(Ct().pageIndex*Ct().pageSize).toString()})),a=BS(s),l=L(()=>a.data??{data:[],pagination:null}),c=L(()=>l().data??[]),u=L(()=>l().pagination),f=w0({get data(){return c()},columns:t.columns,getCoreRowModel:g0(),getFilteredRowModel:y0(),state:{get pagination(){return Ct()},get globalFilter(){return r()}},onPaginationChange:Ho,globalFilterFn:(v,m,y)=>y?v.original.platform.toLowerCase()===y:!0,manualPagination:!0,pageCount:((g=u())==null?void 0:g.totalPages)??0}),d=v=>()=>{t.onRowClick(v.original)},h=jh();j(()=>{h.isFetched&&h.data&&n()===null&&i(h.data[0])});const p=v=>{Ho(m=>({...m,pageIndex:v}))};return(()=>{var v=GS(),m=v.firstChild,y=m.firstChild,b=y.firstChild,S=b.nextSibling,C=m.nextSibling;return W(y,w(Ic,{get children(){return w(Mc,{get children(){return[w(Pc,{class:"w-[100px]",get children(){return[L(()=>L(()=>!!r())()?r():"All"),w(Rc,{})]}}),w(Oc,{get children(){return w(et,{each:[{label:"All",value:null},{label:"iOS",value:"ios"},{label:"Android",value:"android"}],children:R=>w(Fc,{get classList(){return{"bg-primary text-primary-foreground":R.value===r()}},onClick:()=>{o(R.value),Ho(D=>({...D,pageIndex:0}))},get children(){return R.label}})})}})]}})}}),S),W(y,w(Ic,{get children(){return w(Mc,{get children(){return[w(Pc,{class:"w-[100px]",get children(){return[L(()=>n()),w(Rc,{})]}}),w(Oc,{get children(){return w(et,{get each(){return h.data},children:R=>w(Fc,{get classList(){return{"bg-primary text-primary-foreground":R===n()}},onClick:()=>{i(R),Ho(D=>({...D,pageIndex:0}))},children:R})})}})]}})}}),null),W(C,w($S,{get children(){return[w(AS,{get children(){return w(et,{get each(){return f.getHeaderGroups()},children:R=>w(is,{get children(){return w(et,{get each(){return R.headers},children:D=>w(DS,{get children(){return L(()=>!!D.isPlaceholder)()?null:wc(D.column.columnDef.header,D.getContext())}})})}})})}}),w(TS,{get children(){return L(()=>!!(a.isFetched&&c().length===0))()?w(is,{get children(){return w($c,{get colSpan(){return t.columns.length},class:"h-full text-center",children:"No results."})}}):w(et,{get each(){return f.getRowModel().rows},children:R=>w(is,{get"data-state"(){return R.getIsSelected()&&"selected"},class:"cursor-pointer",get onClick(){return d(R)},get children(){return w(et,{get each(){return R.getVisibleCells()},children:D=>w($c,{get children(){return wc(D.column.columnDef.cell,D.getContext())}})})}})})}})]}})),W(v,w(bS,{class:"mt-2.5 w-full [&>ul]:justify-center",itemComponent:R=>w(SS,{get page(){return R.page},onClick:()=>p(R.page-1),get children(){return R.page}}),ellipsisComponent:()=>w(xS,{}),get count(){var R;return((R=u())==null?void 0:R.totalPages)??1},get children(){return[w(CS,{onClick:()=>p(Ct().pageIndex-1),get disabled(){var R;return!((R=u())!=null&&R.hasPreviousPage)}}),w(wS,{}),w(ES,{onClick:()=>p(Ct().pageIndex+1),get disabled(){var R;return!((R=u())!=null&&R.hasNextPage)}})]}}),null),W(v,(()=>{var R=L(()=>!!u());return()=>R()&&(()=>{var D=qS(),V=D.firstChild,$=V.nextSibling,k=$.nextSibling,N=k.nextSibling,B=N.nextSibling,ne=B.nextSibling;return ne.nextSibling,W(D,()=>Ct().pageIndex*Ct().pageSize+1,$),W(D,()=>Math.min((Ct().pageIndex+1)*Ct().pageSize,u().total),N),W(D,()=>u().total,ne),D})()})(),null),Ve(R=>{var D=!!a.isFetching,V=!!a.isFetching;return D!==R.e&&v.classList.toggle("opacity-50",R.e=D),V!==R.t&&C.classList.toggle("min-h-[400px]",R.t=V),R},{e:void 0,t:void 0}),v})()}var XS={};dt(XS,{Root:()=>Sl,Skeleton:()=>YS});function Sl(e){const t=`skeleton-${Ie()}`,n=Z({visible:!0,animate:!0,id:t},e),[r,o]=_(n,["style","radius","animate","height","width","visible","circle"]);return w(le,F({as:"div",role:"group",get"data-animate"(){return r.animate||void 0},get"data-visible"(){return r.visible||void 0},get style(){return ct({"border-radius":r.circle?"9999px":r.radius?`${r.radius}px`:void 0,width:r.circle?`${r.height}px`:r.width?`${r.width}px`:"100%",height:r.height?`${r.height}px`:"auto"},r.style)}},o))}var YS=Sl;const JS=e=>{const[t,n]=_(e,["class"]);return w(Sl,F({get class(){return ce("bg-primary/10 data-[animate='true']:animate-pulse",t.class)}},n))};var ZS={};dt(ZS,{AlertDialog:()=>ex,CloseButton:()=>Sn,Content:()=>xl,Description:()=>Pr,Overlay:()=>Rr,Portal:()=>Or,Root:()=>Fr,Title:()=>$r,Trigger:()=>Eo});function xl(e){return w(Mi,F({role:"alertdialog"},e))}var ex=Object.assign(Fr,{CloseButton:Sn,Content:xl,Description:Pr,Overlay:Rr,Portal:Or,Title:$r,Trigger:Eo}),tx=te('<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><title>Close dialog</title><path d="M18 6l-12 12"></path><path d="M6 6l12 12">'),nx=te("<span class=sr-only>Close");const Uh=Fr,Hh=Eo,rx=Or,Cl=e=>{const[t,n]=_(e,["class"]);return w(Rr,F({get class(){return ce("fixed inset-0 z-50 backdrop-blur-sm data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0",t.class)}},n))},Gh=e=>{const[t,n]=_(e,["class","children"]);return w(rx,{get children(){return[w(Cl,{}),w(xl,F({get class(){return ce("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0 data-[closed]:zoom-out-95 data-[expanded]:zoom-in-95 data-[closed]:slide-out-to-left-1/2 data-[closed]:slide-out-to-top-[48%] data-[expanded]:slide-in-from-left-1/2 data-[expanded]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",t.class)}},n,{get children(){return[L(()=>t.children),w(Sn,{class:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[expanded]:bg-accent data-[expanded]:text-muted-foreground",get children(){return[tx(),nx()]}})]}}))]}})},qh=e=>{const[t,n]=_(e,["class"]);return w($r,F({get class(){return ce("text-lg font-semibold",t.class)}},n))},Wh=e=>{const[t,n]=_(e,["class"]);return w(Pr,F({get class(){return ce("text-sm text-muted-foreground",t.class)}},n))};var ox=te('<div class="h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent">'),ix=te('<div class="flex gap-2 justify-end mt-4">');const sx=({bundleId:e,onDeleteSuccess:t})=>{const n=HS(),r=()=>{n.mutate(e,{onSuccess:()=>{t()},onError:o=>{console.error("Failed to delete bundle:",o),Yt({title:"Error",description:"Failed to delete bundle. Please try again.",variant:"error"})}})};return w(Uh,{get children(){return[w(Hh,{as:fn,variant:"destructive",size:"sm",class:"gap-2 flex-1",get children(){return[w(nc,{class:"h-4 w-4"}),"Delete Bundle"]}}),w(Cl,{}),w(Gh,{get children(){return[w(qh,{children:"Delete Bundle"}),w(Wh,{children:"Are you sure you want to delete this bundle storage? This action cannot be undone."}),(()=>{var o=ix();return W(o,w(Sn,{as:fn,variant:"outline",size:"sm",children:"Cancel"}),null),W(o,w(fn,{variant:"destructive",size:"sm",onClick:r,get disabled(){return n.isPending},class:"gap-2",get children(){return[w(de,{get when(){return n.isPending},get fallback(){return w(nc,{class:"h-4 w-4"})},get children(){return ox()}}),L(()=>n.isPending?"Deleting...":"Delete")]}}),null),o})()]}})]}})},or=new WeakMap,ri=new WeakMap,vi={current:[]};let as=!1,eo=0;const Xr=new Set,Go=new Map;function Qh(e){const t=Array.from(e).sort((n,r)=>n instanceof zt&&n.options.deps.includes(r)?1:r instanceof zt&&r.options.deps.includes(n)?-1:0);for(const n of t){if(vi.current.includes(n))continue;vi.current.push(n),n.recompute();const r=ri.get(n);if(r)for(const o of r){const i=or.get(o);i&&Qh(i)}}}function ax(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function lx(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Xh(e){if(eo>0&&!Go.has(e)&&Go.set(e,e.prevState),Xr.add(e),!(eo>0)&&!as)try{for(as=!0;Xr.size>0;){const t=Array.from(Xr);Xr.clear();for(const n of t){const r=Go.get(n)??n.prevState;n.prevState=r,ax(n)}for(const n of t){const r=or.get(n);r&&(vi.current.push(n),Qh(r))}for(const n of t){const r=or.get(n);if(r)for(const o of r)lx(o)}}}finally{as=!1,vi.current=[],Go.clear()}}function Et(e){eo++;try{e()}finally{if(eo--,eo===0){const t=Array.from(Xr)[0];t&&Xh(t)}}}function ux(e){return typeof e=="function"}class da{constructor(t,n){this.listeners=new Set,this.subscribe=r=>{var o,i;this.listeners.add(r);const s=(i=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:i.call(o,r,this);return()=>{this.listeners.delete(r),s==null||s()}},this.prevState=t,this.state=t,this.options=n}setState(t){var n,r,o;this.prevState=this.state,(n=this.options)!=null&&n.updateFn?this.state=this.options.updateFn(this.prevState)(t):ux(t)?this.state=t(this.prevState):this.state=t,(o=(r=this.options)==null?void 0:r.onUpdate)==null||o.call(r),Xh(this)}}class zt{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const n=[],r=[];for(const o of this.options.deps)n.push(o.prevState),r.push(o.state);return this.lastSeenDepValues=r,{prevDepVals:n,currDepVals:r,prevVal:this.prevState??void 0}},this.recompute=()=>{var n,r;this.prevState=this.state;const{prevDepVals:o,currDepVals:i,prevVal:s}=this.getDepVals();this.state=this.options.fn({prevDepVals:o,currDepVals:i,prevVal:s}),(r=(n=this.options).onUpdate)==null||r.call(n)},this.checkIfRecalculationNeededDeeply=()=>{for(const i of this.options.deps)i instanceof zt&&i.checkIfRecalculationNeededDeeply();let n=!1;const r=this.lastSeenDepValues,{currDepVals:o}=this.getDepVals();for(let i=0;i<o.length;i++)if(o[i]!==r[i]){n=!0;break}n&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const n of this._subscriptions)n()}),this.subscribe=n=>{var r,o;this.listeners.add(n);const i=(o=(r=this.options).onSubscribe)==null?void 0:o.call(r,n,this);return()=>{this.listeners.delete(n),i==null||i()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(const n of t)if(n instanceof zt)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof da){let r=or.get(n);r||(r=new Set,or.set(n,r)),r.add(this);let o=ri.get(this);o||(o=new Set,ri.set(this,o)),o.add(n)}}unregisterFromGraph(t=this.options.deps){for(const n of t)if(n instanceof zt)this.unregisterFromGraph(n.options.deps);else if(n instanceof da){const r=or.get(n);r&&r.delete(this);const o=ri.get(this);o&&o.delete(n)}}}function El(e,t){return typeof e=="function"?e(t):e}function Yr(e,t){return Ml(t).reduce((r,o)=>{if(r===null)return null;if(typeof r<"u")return r[o]},e)}function qo(e,t,n){const r=Ml(t);function o(i){if(!r.length)return El(n,i);const s=r.shift();if(typeof s=="string"||typeof s=="number"&&!Array.isArray(i))return typeof i=="object"?(i===null&&(i={}),{...i,[s]:o(i[s])}):{[s]:o()};if(Array.isArray(i)&&typeof s=="number"){const a=i.slice(0,s);return[...a.length?a:new Array(s),o(i[s]),...i.slice(s+1)]}return[...new Array(s),o()]}return o(e)}function cx(e,t){const n=Ml(t);function r(o){if(!o)return;if(n.length===1){const s=n[0];if(Array.isArray(o)&&typeof s=="number")return o.filter((c,u)=>u!==s);const{[s]:a,...l}=o;return l}const i=n.shift();if(typeof i=="string"&&typeof o=="object")return{...o,[i]:r(o[i])};if(typeof i=="number"&&Array.isArray(o)){if(i>=o.length)return o;const s=o.slice(0,i);return[...s.length?s:new Array(i),r(o[i]),...o.slice(i+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}return r(e)}const dx=/^(\d+)$/gm,fx=/\.(\d+)(?=\.)/gm,hx=/^(\d+)\./gm,gx=/\.(\d+$)/gm,px=/\.{2,}/gm,fa="__int__",Wo=`${fa}$1`;function Ml(e){if(Array.isArray(e))return[...e];if(typeof e!="string")throw new Error("Path must be a string.");return e.replace(/(^\[)|]/gm,"").replace(/\[/g,".").replace(dx,Wo).replace(fx,`.${Wo}.`).replace(hx,`${Wo}.`).replace(gx,`.${Wo}`).replace(px,".").split(".").map(t=>t.indexOf(fa)===0?parseInt(t.substring(fa.length),10):t)}function mx(e){return!(Array.isArray(e)&&e.length===0)}function ha(e,t){const{asyncDebounceMs:n}=t,{onChangeAsync:r,onBlurAsync:o,onSubmitAsync:i,onBlurAsyncDebounceMs:s,onChangeAsyncDebounceMs:a}=t.validators||{},l=n??0,c={cause:"change",validate:r,debounceMs:a??l},u={cause:"blur",validate:o,debounceMs:s??l},f={cause:"submit",validate:i,debounceMs:0},d=h=>({...h,debounceMs:0});switch(e){case"submit":return[d(c),d(u),f];case"blur":return[u];case"change":return[c];case"server":default:return[]}}function ga(e,t){const{onChange:n,onBlur:r,onSubmit:o,onMount:i}=t.validators||{},s={cause:"change",validate:n},a={cause:"blur",validate:r},l={cause:"submit",validate:o},c={cause:"mount",validate:i},u={cause:"server",validate:()=>{}};switch(e){case"mount":return[c];case"submit":return[s,a,l,u];case"server":return[u];case"blur":return[a,u];case"change":default:return[s,u]}}const pa=e=>!!e&&typeof e=="object"&&"fields"in e;function er(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,i]of e)if(!t.has(o)||!Object.is(i,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!r.includes(o)||!er(e[o],t[o]))return!1;return!0}const Ac=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:"form"}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:"field"}:{newErrorValue:void 0,newSource:void 0},Tc=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:"field"}:e?{newErrorValue:e,newSource:"form"}:{newErrorValue:void 0,newSource:void 0};function vx(e){const t=new Map;for(const n of e){const r=[...n.path??[]].map(o=>{const i=typeof o=="object"?o.key:o;return typeof i=="number"?`[${i}]`:i}).join(".").replace(/\.\[/g,"[");t.set(r,(t.get(r)??[]).concat(n))}return Object.fromEntries(t)}const Dc=e=>{const t=vx(e);return{form:t,fields:t}},ir={validate({value:e,validationSource:t},n){const r=n["~standard"].validate(e);if(r instanceof Promise)throw new Error("async function passed to sync validator");if(r.issues)return t==="field"?r.issues:Dc(r.issues)},async validateAsync({value:e,validationSource:t},n){const r=await n["~standard"].validate(e);if(r.issues)return t==="field"?r.issues:Dc(r.issues)}},Yh=e=>!!e&&"~standard"in e,yi={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{}};function Qo(e){function t(f,d,h,p){const g=r(f,d,h,p);({insert:()=>a(g,f,d),remove:()=>l(g),swap:()=>p!==void 0&&u(g,f,d,p),move:()=>p!==void 0&&c(g,f,d,p)})[h]()}function n(f,d){return`${f}[${d}]`}function r(f,d,h,p){const g=[n(f,d)];if(h==="swap")g.push(n(f,p));else if(h==="move"){const[v,m]=[Math.min(d,p),Math.max(d,p)];for(let y=v;y<=m;y++)g.push(n(f,y))}else{const v=e.getFieldValue(f),m=Array.isArray(v)?v.length:0;for(let y=d+1;y<m;y++)g.push(n(f,y))}return Object.keys(e.fieldInfo).filter(v=>g.some(m=>v.startsWith(m)))}function o(f,d){return f.replace(/\[(\d+)\]/,(h,p)=>{const g=parseInt(p,10);return`[${d==="up"?g+1:Math.max(0,g-1)}]`})}function i(f,d){(d==="up"?f:[...f].reverse()).forEach(p=>{const g=o(p.toString(),d),v=e.getFieldMeta(g);v?e.setFieldMeta(p,v):e.setFieldMeta(p,s())})}const s=()=>yi,a=(f,d,h)=>{i(f,"down"),f.forEach(p=>{p.toString().startsWith(n(d,h))&&e.setFieldMeta(p,s())})},l=f=>{i(f,"up")},c=(f,d,h,p)=>{const g=new Map(Object.keys(e.fieldInfo).filter(v=>v.startsWith(n(d,h))).map(v=>[v,e.getFieldMeta(v)]));i(f,h<p?"up":"down"),Object.keys(e.fieldInfo).filter(v=>v.startsWith(n(d,p))).forEach(v=>{const m=v.replace(n(d,p),n(d,h)),y=g.get(m);y&&e.setFieldMeta(v,y)})},u=(f,d,h,p)=>{f.forEach(g=>{if(!g.toString().startsWith(n(d,h)))return;const v=g.toString().replace(n(d,h),n(d,p)),[m,y]=[e.getFieldMeta(g),e.getFieldMeta(v)];m&&e.setFieldMeta(v,m),y&&e.setFieldMeta(g,y)})};return{handleArrayFieldMetaShift:t}}function ls(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}}}class yx{constructor(t){var n;this.options={},this.fieldInfo={},this.prevTransformArray=[],this.mount=()=>{var r,o;const i=this.fieldMetaDerived.mount(),s=this.store.mount(),a=()=>{i(),s()};(o=(r=this.options.listeners)==null?void 0:r.onMount)==null||o.call(r,{formApi:this});const{onMount:l}=this.options.validators||{};return l&&this.validateSync("mount"),a},this.update=r=>{var o,i;if(!r)return;const s=this.options;this.options=r;const a=!!((i=(o=r.transform)==null?void 0:o.deps)!=null&&i.some((u,f)=>u!==this.prevTransformArray[f])),l=r.defaultValues&&!er(r.defaultValues,s.defaultValues)&&!this.state.isTouched,c=!er(r.defaultState,s.defaultState)&&!this.state.isTouched;!l&&!c&&!a||Et(()=>{this.baseStore.setState(()=>ls(Object.assign({},this.state,c?r.defaultState:{},l?{values:r.defaultValues}:{},a?{_force_re_eval:!this.state._force_re_eval}:{})))})},this.reset=(r,o)=>{const{fieldMeta:i}=this.state,s=this.resetFieldMeta(i);r&&!(o!=null&&o.keepDefaultValues)&&(this.options={...this.options,defaultValues:r}),this.baseStore.setState(()=>{var a;return ls({...this.options.defaultState,values:r??this.options.defaultValues??((a=this.options.defaultState)==null?void 0:a.values),fieldMetaBase:s})})},this.validateAllFields=async r=>{const o=[];return Et(()=>{Object.values(this.fieldInfo).forEach(s=>{if(!s.instance)return;const a=s.instance;o.push(Promise.resolve().then(()=>a.validate(r,{skipFormValidation:!0}))),s.instance.state.meta.isTouched||s.instance.setMeta(l=>({...l,isTouched:!0}))})}),(await Promise.all(o)).flat()},this.validateArrayFieldsStartingFrom=async(r,o,i)=>{const s=this.getFieldValue(r),a=Array.isArray(s)?Math.max(s.length-1,0):null,l=[`${r}[${o}]`];for(let d=o+1;d<=(a??0);d++)l.push(`${r}[${d}]`);const c=Object.keys(this.fieldInfo).filter(d=>l.some(h=>d.startsWith(h))),u=[];return Et(()=>{c.forEach(d=>{u.push(Promise.resolve().then(()=>this.validateField(d,i)))})}),(await Promise.all(u)).flat()},this.validateField=(r,o)=>{var i;const s=(i=this.fieldInfo[r])==null?void 0:i.instance;return s?(s.state.meta.isTouched||s.setMeta(a=>({...a,isTouched:!0})),s.validate(o)):[]},this.validateSync=r=>{const o=ga(r,this.options);let i=!1;const s={};return Et(()=>{var a,l;for(const u of o){if(!u.validate)continue;const f=this.runValidator({validate:u.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:d,fieldErrors:h}=oi(f),p=Xo(u.cause);for(const g of Object.keys(this.state.fieldMeta)){const v=this.getFieldMeta(g);if(!v)continue;const{errorMap:m,errorSourceMap:y}=v,b=h==null?void 0:h[g],{newErrorValue:S,newSource:C}=Ac({newFormValidatorError:b,isPreviousErrorFromFormValidator:(y==null?void 0:y[p])==="form",previousErrorValue:m==null?void 0:m[p]});C==="form"&&(s[g]={...s[g],[p]:b}),(m==null?void 0:m[p])!==S&&this.setFieldMeta(g,R=>({...R,errorMap:{...R.errorMap,[p]:S},errorSourceMap:{...R.errorSourceMap,[p]:C}}))}((a=this.state.errorMap)==null?void 0:a[p])!==d&&this.baseStore.setState(g=>({...g,errorMap:{...g.errorMap,[p]:d}})),(d||h)&&(i=!0)}const c=Xo("submit");(l=this.state.errorMap)!=null&&l[c]&&r!=="submit"&&!i&&this.baseStore.setState(u=>({...u,errorMap:{...u.errorMap,[c]:void 0}}))}),{hasErrored:i,fieldsErrorMap:s}},this.validateAsync=async r=>{const o=ha(r,this.options);this.state.isFormValidating||this.baseStore.setState(c=>({...c,isFormValidating:!0}));const i=[];let s;for(const c of o){if(!c.validate)continue;const u=Xo(c.cause),f=this.state.validationMetaMap[u];f==null||f.lastAbortController.abort();const d=new AbortController;this.state.validationMetaMap[u]={lastAbortController:d},i.push(new Promise(async h=>{let p;try{p=await new Promise((y,b)=>{setTimeout(async()=>{if(d.signal.aborted)return y(void 0);try{y(await this.runValidator({validate:c.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:d.signal},type:"validateAsync"}))}catch(S){b(S)}},c.debounceMs)})}catch(y){p=y}const{formError:g,fieldErrors:v}=oi(p);v&&(s=s?{...s,...v}:v);const m=Xo(c.cause);for(const y of Object.keys(this.state.fieldMeta)){const b=this.getFieldMeta(y);if(!b)continue;const{errorMap:S,errorSourceMap:C}=b,R=s==null?void 0:s[y],{newErrorValue:D,newSource:V}=Ac({newFormValidatorError:R,isPreviousErrorFromFormValidator:(C==null?void 0:C[m])==="form",previousErrorValue:S==null?void 0:S[m]});(S==null?void 0:S[m])!==D&&this.setFieldMeta(y,$=>({...$,errorMap:{...$.errorMap,[m]:D},errorSourceMap:{...$.errorSourceMap,[m]:V}}))}this.baseStore.setState(y=>({...y,errorMap:{...y.errorMap,[m]:g}})),h(s?{fieldErrors:s,errorMapKey:m}:void 0)}))}let a=[];const l={};if(i.length){a=await Promise.all(i);for(const c of a)if(c!=null&&c.fieldErrors){const{errorMapKey:u}=c;for(const[f,d]of Object.entries(c.fieldErrors)){const p={...l[f]||{},[u]:d};l[f]=p}}}return this.baseStore.setState(c=>({...c,isFormValidating:!1})),l},this.validate=r=>{const{hasErrored:o,fieldsErrorMap:i}=this.validateSync(r);return o&&!this.options.asyncAlways?i:this.validateAsync(r)},this.getFieldValue=r=>Yr(this.state.values,r),this.getFieldMeta=r=>this.state.fieldMeta[r],this.getFieldInfo=r=>{var o;return(o=this.fieldInfo)[r]||(o[r]={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}})},this.setFieldMeta=(r,o)=>{this.baseStore.setState(i=>({...i,fieldMetaBase:{...i.fieldMetaBase,[r]:El(o,i.fieldMetaBase[r])}}))},this.resetFieldMeta=r=>Object.keys(r).reduce((o,i)=>{const s=i;return o[s]=yi,o},{}),this.setFieldValue=(r,o,i)=>{const s=(i==null?void 0:i.dontUpdateMeta)??!1;Et(()=>{s||this.setFieldMeta(r,a=>({...a,isTouched:!0,isDirty:!0,errorMap:{...a==null?void 0:a.errorMap,onMount:void 0}})),this.baseStore.setState(a=>({...a,values:qo(a.values,r,o)}))})},this.deleteField=r=>{const i=[...Object.keys(this.fieldInfo).filter(s=>{const a=r.toString();return s!==a&&s.startsWith(a)}),r];this.baseStore.setState(s=>{const a={...s};return i.forEach(l=>{a.values=cx(a.values,l),delete this.fieldInfo[l],delete a.fieldMetaBase[l]}),a})},this.pushFieldValue=(r,o,i)=>{this.setFieldValue(r,s=>[...Array.isArray(s)?s:[],o],i),this.validateField(r,"change")},this.insertFieldValue=async(r,o,i,s)=>{this.setFieldValue(r,a=>[...a.slice(0,o),i,...a.slice(o)],s),await this.validateField(r,"change"),Qo(this).handleArrayFieldMetaShift(r,o,"insert"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.replaceFieldValue=async(r,o,i,s)=>{this.setFieldValue(r,a=>a.map((l,c)=>c===o?i:l),s),await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.removeFieldValue=async(r,o,i)=>{const s=this.getFieldValue(r),a=Array.isArray(s)?Math.max(s.length-1,0):null;if(this.setFieldValue(r,l=>l.filter((c,u)=>u!==o),i),Qo(this).handleArrayFieldMetaShift(r,o,"remove"),a!==null){const l=`${r}[${a}]`;this.deleteField(l)}await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.swapFieldValues=(r,o,i,s)=>{this.setFieldValue(r,a=>{const l=a[o],c=a[i];return qo(qo(a,`${o}`,c),`${i}`,l)},s),Qo(this).handleArrayFieldMetaShift(r,o,"swap",i),this.validateField(r,"change"),this.validateField(`${r}[${o}]`,"change"),this.validateField(`${r}[${i}]`,"change")},this.moveFieldValues=(r,o,i,s)=>{this.setFieldValue(r,a=>{const l=[...a];return l.splice(i,0,l.splice(o,1)[0]),l},s),Qo(this).handleArrayFieldMetaShift(r,o,"move",i),this.validateField(r,"change"),this.validateField(`${r}[${o}]`,"change"),this.validateField(`${r}[${i}]`,"change")},this.clearFieldValues=(r,o)=>{const i=this.getFieldValue(r),s=Array.isArray(i)?Math.max(i.length-1,0):null;if(this.setFieldValue(r,[],o),s!==null)for(let a=0;a<=s;a++){const l=`${r}[${a}]`;this.deleteField(l)}this.validateField(r,"change")},this.resetField=r=>{this.baseStore.setState(o=>({...o,fieldMetaBase:{...o.fieldMetaBase,[r]:yi},values:this.options.defaultValues?qo(o.values,r,Yr(this.options.defaultValues,r)):o.values}))},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((r,[o,i])=>(Object.keys(i).length&&i.errors.length&&(r[o]={errors:i.errors,errorMap:i.errorMap}),r),{})}),this.parseValuesWithSchema=r=>ir.validate({value:this.state.values,validationSource:"form"},r),this.parseValuesWithSchemaAsync=r=>ir.validateAsync({value:this.state.values,validationSource:"form"},r),this.baseStore=new da(ls({...t==null?void 0:t.defaultState,values:(t==null?void 0:t.defaultValues)??((n=t==null?void 0:t.defaultState)==null?void 0:n.values)})),this.fieldMetaDerived=new zt({deps:[this.baseStore],fn:({prevDepVals:r,currDepVals:o,prevVal:i})=>{var s,a,l;const c=i,u=r==null?void 0:r[0],f=o[0];let d=0;const h={};for(const p of Object.keys(f.fieldMetaBase)){const g=f.fieldMetaBase[p],v=u==null?void 0:u.fieldMetaBase[p],m=c==null?void 0:c[p],y=Yr(f.values,p);let b=m==null?void 0:m.errors;if(!v||g.errorMap!==v.errorMap){b=Object.values(g.errorMap??{}).filter(V=>V!==void 0);const D=(s=this.getFieldInfo(p))==null?void 0:s.instance;D&&!D.options.disableErrorFlat&&(b=b==null?void 0:b.flat(1))}const S=!mx(b??[]),C=!g.isDirty,R=er(y,Yr(this.options.defaultValues,p))||er(y,(l=(a=this.getFieldInfo(p))==null?void 0:a.instance)==null?void 0:l.options.defaultValue);if(m&&m.isPristine===C&&m.isValid===S&&m.isDefaultValue===R&&m.errors===b&&g===v){h[p]=m,d++;continue}h[p]={...g,errors:b,isPristine:C,isValid:S,isDefaultValue:R}}return Object.keys(f.fieldMetaBase).length&&c&&d===Object.keys(f.fieldMetaBase).length?c:h}}),this.store=new zt({deps:[this.baseStore,this.fieldMetaDerived],fn:({prevDepVals:r,currDepVals:o,prevVal:i})=>{var s,a,l,c;const u=i,f=r==null?void 0:r[0],d=o[0],h=o[1],p=Object.values(h).filter(Boolean),g=p.some(P=>P.isValidating),v=p.every(P=>P.isValid),m=p.some(P=>P.isTouched),y=p.some(P=>P.isBlurred),b=p.every(P=>P.isDefaultValue),S=m&&((s=d.errorMap)==null?void 0:s.onMount),C=p.some(P=>P.isDirty),R=!C,D=!!((a=d.errorMap)!=null&&a.onMount||p.some(P=>{var A;return(A=P==null?void 0:P.errorMap)==null?void 0:A.onMount})),V=!!g;let $=(u==null?void 0:u.errors)??[];(!f||d.errorMap!==f.errorMap)&&($=Object.values(d.errorMap).reduce((P,A)=>A===void 0?P:A&&pa(A)?(P.push(A.form),P):(P.push(A),P),[]));const k=$.length===0,N=v&&k,B=this.options.canSubmitWhenInvalid??!1,ne=d.submissionAttempts===0&&!m&&!D||!V&&!d.isSubmitting&&N||B;let I=d.errorMap;if(S&&($=$.filter(P=>P!==d.errorMap.onMount),I=Object.assign(I,{onMount:void 0})),u&&f&&u.errorMap===I&&u.fieldMeta===this.fieldMetaDerived.state&&u.errors===$&&u.isFieldsValidating===g&&u.isFieldsValid===v&&u.isFormValid===k&&u.isValid===N&&u.canSubmit===ne&&u.isTouched===m&&u.isBlurred===y&&u.isPristine===R&&u.isDefaultValue===b&&u.isDirty===C&&er(f,d))return u;let M={...d,errorMap:I,fieldMeta:this.fieldMetaDerived.state,errors:$,isFieldsValidating:g,isFieldsValid:v,isFormValid:k,isValid:N,canSubmit:ne,isTouched:m,isBlurred:y,isPristine:R,isDefaultValue:b,isDirty:C};const x=((l=this.options.transform)==null?void 0:l.deps)??[];if(x.length!==this.prevTransformArray.length||x.some((P,A)=>P!==this.prevTransformArray[A])){const P=Object.assign({},this,{state:M});(c=this.options.transform)==null||c.fn(P),M=P.state,this.prevTransformArray=x}return M}}),this.handleSubmit=this.handleSubmit.bind(this),this.update(t||{})}get state(){return this.store.state}runValidator(t){return Yh(t.validate)?ir[t.type](t.value,t.validate):t.validate(t.value)}async handleSubmit(t){var n,r,o,i,s,a,l,c;if(this.baseStore.setState(f=>({...f,isSubmitted:!1,submissionAttempts:f.submissionAttempts+1,isSubmitSuccessful:!1})),Et(()=>{Object.values(this.fieldInfo).forEach(f=>{f.instance&&(f.instance.state.meta.isTouched||f.instance.setMeta(d=>({...d,isTouched:!0})))})}),!this.state.canSubmit)return;this.baseStore.setState(f=>({...f,isSubmitting:!0}));const u=()=>{this.baseStore.setState(f=>({...f,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){u(),(r=(n=this.options).onSubmitInvalid)==null||r.call(n,{value:this.state.values,formApi:this});return}if(await this.validate("submit"),!this.state.isValid){u(),(i=(o=this.options).onSubmitInvalid)==null||i.call(o,{value:this.state.values,formApi:this});return}Et(()=>{Object.values(this.fieldInfo).forEach(f=>{var d,h,p;(p=(h=(d=f.instance)==null?void 0:d.options.listeners)==null?void 0:h.onSubmit)==null||p.call(h,{value:f.instance.state.value,fieldApi:f.instance})})}),(a=(s=this.options.listeners)==null?void 0:s.onSubmit)==null||a.call(s,{formApi:this});try{await((c=(l=this.options).onSubmit)==null?void 0:c.call(l,{value:this.state.values,formApi:this,meta:t??this.options.onSubmitMeta})),Et(()=>{this.baseStore.setState(f=>({...f,isSubmitted:!0,isSubmitSuccessful:!0})),u()})}catch(f){throw this.baseStore.setState(d=>({...d,isSubmitSuccessful:!1})),u(),f}}setErrorMap(t){Et(()=>{Object.entries(t).forEach(([n,r])=>{const o=n;if(pa(r)){const{formError:i,fieldErrors:s}=oi(r);for(const a of Object.keys(this.fieldInfo))this.getFieldMeta(a)&&this.setFieldMeta(a,c=>({...c,errorMap:{...c.errorMap,[o]:s==null?void 0:s[a]},errorSourceMap:{...c.errorSourceMap,[o]:"form"}}));this.baseStore.setState(a=>({...a,errorMap:{...a.errorMap,[o]:i}}))}else this.baseStore.setState(i=>({...i,errorMap:{...i.errorMap,[o]:r}}))})})}}function oi(e){if(e){if(pa(e)){const t=oi(e.form).formError,n=e.fields;return{formError:t,fieldErrors:n}}return{formError:e}}return{formError:void 0}}function Xo(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}class wx{constructor(t){this.options={},this.mount=()=>{var n,r;const o=this.store.mount();this.options.defaultValue!==void 0&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});const i=this.getInfo();i.instance=this,this.update(this.options);const{onMount:s}=this.options.validators||{};if(s){const a=this.runValidator({validate:s,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});a&&this.setMeta(l=>({...l,errorMap:{...l==null?void 0:l.errorMap,onMount:a},errorSourceMap:{...l==null?void 0:l.errorSourceMap,onMount:"field"}}))}return(r=(n=this.options.listeners)==null?void 0:n.onMount)==null||r.call(n,{value:this.state.value,fieldApi:this}),o},this.update=n=>{this.options=n;const r=this.name!==n.name;if(this.name=n.name,this.state.value===void 0){const o=Yr(n.form.options.defaultValues,n.name),i=n.defaultValue??o;r?this.setValue(s=>s||i,{dontUpdateMeta:!0}):i!==void 0&&this.setValue(i,{dontUpdateMeta:!0})}this.form.getFieldMeta(this.name)===void 0&&this.setMeta(this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(n,r)=>{this.form.setFieldValue(this.name,n,r),this.triggerOnChangeListener(),this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=n=>this.form.setFieldMeta(this.name,n),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(n,r)=>{this.form.pushFieldValue(this.name,n,r),this.triggerOnChangeListener()},this.insertValue=(n,r,o)=>{this.form.insertFieldValue(this.name,n,r,o),this.triggerOnChangeListener()},this.replaceValue=(n,r,o)=>{this.form.replaceFieldValue(this.name,n,r,o),this.triggerOnChangeListener()},this.removeValue=(n,r)=>{this.form.removeFieldValue(this.name,n,r),this.triggerOnChangeListener()},this.swapValues=(n,r,o)=>{this.form.swapFieldValues(this.name,n,r,o),this.triggerOnChangeListener()},this.moveValue=(n,r,o)=>{this.form.moveFieldValues(this.name,n,r,o),this.triggerOnChangeListener()},this.clearValues=n=>{this.form.clearFieldValues(this.name,n),this.triggerOnChangeListener()},this.getLinkedFields=n=>{const r=Object.values(this.form.fieldInfo),o=[];for(const i of r){if(!i.instance)continue;const{onChangeListenTo:s,onBlurListenTo:a}=i.instance.options.validators||{};n==="change"&&(s!=null&&s.includes(this.name))&&o.push(i.instance),n==="blur"&&(a!=null&&a.includes(this.name))&&o.push(i.instance)}return o},this.validateSync=(n,r)=>{var o;const i=ga(n,this.options),a=this.getLinkedFields(n).reduce((u,f)=>{const d=ga(n,f.options);return d.forEach(h=>{h.field=f}),u.concat(d)},[]);let l=!1;Et(()=>{const u=(f,d)=>{var h;const p=Yo(d.cause),g=d.validate?Lc(f.runValidator({validate:d.validate,value:{value:f.store.state.value,validationSource:"field",fieldApi:f},type:"validate"})):void 0,v=r[p],{newErrorValue:m,newSource:y}=Tc({formLevelError:v,fieldLevelError:g});((h=f.state.meta.errorMap)==null?void 0:h[p])!==m&&f.setMeta(b=>({...b,errorMap:{...b.errorMap,[p]:m},errorSourceMap:{...b.errorSourceMap,[p]:y}})),m&&(l=!0)};for(const f of i)u(this,f);for(const f of a)f.validate&&u(f.field,f)});const c=Yo("submit");return(o=this.state.meta.errorMap)!=null&&o[c]&&n!=="submit"&&!l&&this.setMeta(u=>({...u,errorMap:{...u.errorMap,[c]:void 0},errorSourceMap:{...u.errorSourceMap,[c]:void 0}})),{hasErrored:l}},this.validateAsync=async(n,r)=>{const o=ha(n,this.options),i=await r,s=this.getLinkedFields(n),a=s.reduce((d,h)=>{const p=ha(n,h.options);return p.forEach(g=>{g.field=h}),d.concat(p)},[]);this.state.meta.isValidating||this.setMeta(d=>({...d,isValidating:!0}));for(const d of s)d.setMeta(h=>({...h,isValidating:!0}));const l=[],c=[],u=(d,h,p)=>{const g=Yo(h.cause),v=d.getInfo().validationMetaMap[g];v==null||v.lastAbortController.abort();const m=new AbortController;this.getInfo().validationMetaMap[g]={lastAbortController:m},p.push(new Promise(async y=>{var b;let S;try{S=await new Promise(($,k)=>{this.timeoutIds.validations[h.cause]&&clearTimeout(this.timeoutIds.validations[h.cause]),this.timeoutIds.validations[h.cause]=setTimeout(async()=>{if(m.signal.aborted)return $(void 0);try{$(await this.runValidator({validate:h.validate,value:{value:d.store.state.value,fieldApi:d,signal:m.signal,validationSource:"field"},type:"validateAsync"}))}catch(N){k(N)}},h.debounceMs)})}catch($){S=$}if(m.signal.aborted)return y(void 0);const C=Lc(S),R=(b=i[this.name])==null?void 0:b[g],{newErrorValue:D,newSource:V}=Tc({formLevelError:R,fieldLevelError:C});d.setMeta($=>({...$,errorMap:{...$==null?void 0:$.errorMap,[g]:D},errorSourceMap:{...$.errorSourceMap,[g]:V}})),y(D)}))};for(const d of o)d.validate&&u(this,d,l);for(const d of a)d.validate&&u(d.field,d,c);let f=[];(l.length||c.length)&&(f=await Promise.all(l),await Promise.all(c)),this.setMeta(d=>({...d,isValidating:!1}));for(const d of s)d.setMeta(h=>({...h,isValidating:!1}));return f.filter(Boolean)},this.validate=(n,r)=>{var o;if(!this.state.meta.isTouched)return[];const{fieldsErrorMap:i}=r!=null&&r.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(n),{hasErrored:s}=this.validateSync(n,i[this.name]??{});if(s&&!this.options.asyncAlways)return(o=this.getInfo().validationMetaMap[Yo(n)])==null||o.lastAbortController.abort(),this.state.meta.errors;const a=r!=null&&r.skipFormValidation?Promise.resolve({}):this.form.validateAsync(n);return this.validateAsync(n,a)},this.handleChange=n=>{this.setValue(n)},this.handleBlur=()=>{this.state.meta.isTouched||(this.setMeta(r=>({...r,isTouched:!0})),this.validate("change")),this.state.meta.isBlurred||this.setMeta(r=>({...r,isBlurred:!0})),this.validate("blur"),this.triggerOnBlurListener()},this.parseValueWithSchema=n=>ir.validate({value:this.state.value,validationSource:"field"},n),this.parseValueWithSchemaAsync=n=>ir.validateAsync({value:this.state.value,validationSource:"field"},n),this.form=t.form,this.name=t.name,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=new zt({deps:[this.form.store],fn:()=>{const n=this.form.getFieldValue(this.name),r=this.form.getFieldMeta(this.name)??{...yi,...t.defaultMeta};return{value:n,meta:r}}}),this.options=t}get state(){return this.store.state}runValidator(t){return Yh(t.validate)?ir[t.type](t.value,t.validate):t.validate(t.value)}setErrorMap(t){this.setMeta(n=>({...n,errorMap:{...n.errorMap,...t}}))}triggerOnBlurListener(){var t,n,r,o,i,s;const a=(t=this.form.options.listeners)==null?void 0:t.onBlurDebounceMs;a&&a>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{var c,u;(u=(c=this.form.options.listeners)==null?void 0:c.onBlur)==null||u.call(c,{formApi:this.form,fieldApi:this})},a)):(r=(n=this.form.options.listeners)==null?void 0:n.onBlur)==null||r.call(n,{formApi:this.form,fieldApi:this});const l=(o=this.options.listeners)==null?void 0:o.onBlurDebounceMs;l&&l>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{var c,u;(u=(c=this.options.listeners)==null?void 0:c.onBlur)==null||u.call(c,{value:this.state.value,fieldApi:this})},l)):(s=(i=this.options.listeners)==null?void 0:i.onBlur)==null||s.call(i,{value:this.state.value,fieldApi:this})}triggerOnChangeListener(){var t,n,r,o,i,s;const a=(t=this.form.options.listeners)==null?void 0:t.onChangeDebounceMs;a&&a>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{var c,u;(u=(c=this.form.options.listeners)==null?void 0:c.onChange)==null||u.call(c,{formApi:this.form,fieldApi:this})},a)):(r=(n=this.form.options.listeners)==null?void 0:n.onChange)==null||r.call(n,{formApi:this.form,fieldApi:this});const l=(o=this.options.listeners)==null?void 0:o.onChangeDebounceMs;l&&l>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{var c,u;(u=(c=this.options.listeners)==null?void 0:c.onChange)==null||u.call(c,{value:this.state.value,fieldApi:this})},l)):(s=(i=this.options.listeners)==null?void 0:i.onChange)==null||s.call(i,{value:this.state.value,fieldApi:this})}}function Lc(e){if(e)return e}function Yo(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}function _c(e,t=n=>n){const[n,r]=vo({value:t(e.state)}),o=e.subscribe(()=>{const i=t(e.state);r("value",qd(i))});return Y(()=>{o()}),()=>n.value}function bx(e){const[t,n]=z(e,{equals:!1}),r=e.store.subscribe(()=>n(e));return Y(r),t}function Jh(e){const t=e(),n=new wx(t),r=n;r.Field=Zh;let o=!1;return Sr(()=>{const i=n.mount();o=!0,Y(()=>{i(),o=!1})}),pt(()=>{o&&n.update(e())}),bx(r)}function Zh(e){const t=Jh(()=>{const{children:n,...r}=e;return r});return L(()=>w(()=>e.children(t),{}))}function Sx(e){const t=e==null?void 0:e(),n=new yx(t),r=n;return r.Field=o=>w(Zh,F(o,{form:n})),r.createField=o=>Jh(()=>({...o(),form:n})),r.useStore=o=>_c(n.store,o),r.Subscribe=o=>El(o.children,_c(n.store,o.selector)),Sr(n.mount),pt(()=>n.update(e==null?void 0:e())),r}var us,kc;function xx(){if(kc)return us;kc=1;class e{constructor(){this.max=1e3,this.map=new Map}get(n){const r=this.map.get(n);if(r!==void 0)return this.map.delete(n),this.map.set(n,r),r}delete(n){return this.map.delete(n)}set(n,r){if(!this.delete(n)&&r!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(n,r)}return this}}return us=e,us}var cs,Vc;function Il(){if(Vc)return cs;Vc=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return cs=r=>r?typeof r!="object"?e:r:t,cs}var Jo={exports:{}},ds,Nc;function Pl(){if(Nc)return ds;Nc=1;const e="2.0.0",t=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,r=16,o=t-6;return ds={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_SAFE_INTEGER:n,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},ds}var fs,Kc;function Di(){if(Kc)return fs;Kc=1;var e={};return fs=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},fs}var zc;function Rl(){return zc||(zc=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:o}=Pl(),i=Di();t=e.exports={};const s=t.re=[],a=t.safeRe=[],l=t.src=[],c=t.safeSrc=[],u=t.t={};let f=0;const d="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",o],[d,r]],p=v=>{for(const[m,y]of h)v=v.split(`${m}*`).join(`${m}{0,${y}}`).split(`${m}+`).join(`${m}{1,${y}}`);return v},g=(v,m,y)=>{const b=p(m),S=f++;i(v,S,m),u[v]=S,l[S]=m,c[S]=b,s[S]=new RegExp(m,y?"g":void 0),a[S]=new RegExp(b,y?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),g("MAINVERSION",`(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${l[u.PRERELEASEIDENTIFIER]}(?:\\.${l[u.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${l[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[u.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${d}+`),g("BUILD",`(?:\\+(${l[u.BUILDIDENTIFIER]}(?:\\.${l[u.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${l[u.MAINVERSION]}${l[u.PRERELEASE]}?${l[u.BUILD]}?`),g("FULL",`^${l[u.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${l[u.MAINVERSIONLOOSE]}${l[u.PRERELEASELOOSE]}?${l[u.BUILD]}?`),g("LOOSE",`^${l[u.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${l[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${l[u.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:${l[u.PRERELEASE]})?${l[u.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:${l[u.PRERELEASELOOSE]})?${l[u.BUILD]}?)?)?`),g("XRANGE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),g("COERCE",`${l[u.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",l[u.COERCEPLAIN]+`(?:${l[u.PRERELEASE]})?(?:${l[u.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",l[u.COERCE],!0),g("COERCERTLFULL",l[u.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${l[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",g("TILDE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${l[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",g("CARET",`^${l[u.LONECARET]}${l[u.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${l[u.LONECARET]}${l[u.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${l[u.GTLT]}\\s*(${l[u.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]}|${l[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${l[u.XRANGEPLAIN]})\\s+-\\s+(${l[u.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${l[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[u.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Jo,Jo.exports)),Jo.exports}var hs,Bc;function Cx(){if(Bc)return hs;Bc=1;const e=/^[0-9]+$/,t=(r,o)=>{const i=e.test(r),s=e.test(o);return i&&s&&(r=+r,o=+o),r===o?0:i&&!s?-1:s&&!i?1:r<o?-1:1};return hs={compareIdentifiers:t,rcompareIdentifiers:(r,o)=>t(o,r)},hs}var gs,jc;function Ol(){if(jc)return gs;jc=1;const e=Di(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=Pl(),{safeRe:r,t:o}=Rl(),i=Il(),{compareIdentifiers:s}=Cx();class a{constructor(c,u){if(u=i(u),c instanceof a){if(c.loose===!!u.loose&&c.includePrerelease===!!u.includePrerelease)return c;c=c.version}else if(typeof c!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof c}".`);if(c.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",c,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const f=c.trim().match(u.loose?r[o.LOOSE]:r[o.FULL]);if(!f)throw new TypeError(`Invalid Version: ${c}`);if(this.raw=c,this.major=+f[1],this.minor=+f[2],this.patch=+f[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");f[4]?this.prerelease=f[4].split(".").map(d=>{if(/^[0-9]+$/.test(d)){const h=+d;if(h>=0&&h<n)return h}return d}):this.prerelease=[],this.build=f[5]?f[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(c){if(e("SemVer.compare",this.version,this.options,c),!(c instanceof a)){if(typeof c=="string"&&c===this.version)return 0;c=new a(c,this.options)}return c.version===this.version?0:this.compareMain(c)||this.comparePre(c)}compareMain(c){return c instanceof a||(c=new a(c,this.options)),s(this.major,c.major)||s(this.minor,c.minor)||s(this.patch,c.patch)}comparePre(c){if(c instanceof a||(c=new a(c,this.options)),this.prerelease.length&&!c.prerelease.length)return-1;if(!this.prerelease.length&&c.prerelease.length)return 1;if(!this.prerelease.length&&!c.prerelease.length)return 0;let u=0;do{const f=this.prerelease[u],d=c.prerelease[u];if(e("prerelease compare",u,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return s(f,d)}while(++u)}compareBuild(c){c instanceof a||(c=new a(c,this.options));let u=0;do{const f=this.build[u],d=c.build[u];if(e("build compare",u,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return s(f,d)}while(++u)}inc(c,u,f){if(c.startsWith("pre")){if(!u&&f===!1)throw new Error("invalid increment argument: identifier is empty");if(u){const d=`-${u}`.match(this.options.loose?r[o.PRERELEASELOOSE]:r[o.PRERELEASE]);if(!d||d[1]!==u)throw new Error(`invalid identifier: ${u}`)}}switch(c){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",u,f);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",u,f);break;case"prepatch":this.prerelease.length=0,this.inc("patch",u,f),this.inc("pre",u,f);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",u,f),this.inc("pre",u,f);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const d=Number(f)?1:0;if(this.prerelease.length===0)this.prerelease=[d];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(u===this.prerelease.join(".")&&f===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(d)}}if(u){let h=[u,d];f===!1&&(h=[u]),s(this.prerelease[0],u)===0?isNaN(this.prerelease[1])&&(this.prerelease=h):this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${c}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return gs=a,gs}var ps,Uc;function _r(){if(Uc)return ps;Uc=1;const e=Ol();return ps=(n,r,o)=>new e(n,o).compare(new e(r,o)),ps}var ms,Hc;function Ex(){if(Hc)return ms;Hc=1;const e=_r();return ms=(n,r,o)=>e(n,r,o)===0,ms}var vs,Gc;function Mx(){if(Gc)return vs;Gc=1;const e=_r();return vs=(n,r,o)=>e(n,r,o)!==0,vs}var ys,qc;function Ix(){if(qc)return ys;qc=1;const e=_r();return ys=(n,r,o)=>e(n,r,o)>0,ys}var ws,Wc;function Px(){if(Wc)return ws;Wc=1;const e=_r();return ws=(n,r,o)=>e(n,r,o)>=0,ws}var bs,Qc;function Rx(){if(Qc)return bs;Qc=1;const e=_r();return bs=(n,r,o)=>e(n,r,o)<0,bs}var Ss,Xc;function Ox(){if(Xc)return Ss;Xc=1;const e=_r();return Ss=(n,r,o)=>e(n,r,o)<=0,Ss}var xs,Yc;function Fx(){if(Yc)return xs;Yc=1;const e=Ex(),t=Mx(),n=Ix(),r=Px(),o=Rx(),i=Ox();return xs=(a,l,c,u)=>{switch(l){case"===":return typeof a=="object"&&(a=a.version),typeof c=="object"&&(c=c.version),a===c;case"!==":return typeof a=="object"&&(a=a.version),typeof c=="object"&&(c=c.version),a!==c;case"":case"=":case"==":return e(a,c,u);case"!=":return t(a,c,u);case">":return n(a,c,u);case">=":return r(a,c,u);case"<":return o(a,c,u);case"<=":return i(a,c,u);default:throw new TypeError(`Invalid operator: ${l}`)}},xs}var Cs,Jc;function $x(){if(Jc)return Cs;Jc=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(u,f){if(f=n(f),u instanceof t){if(u.loose===!!f.loose)return u;u=u.value}u=u.trim().split(/\s+/).join(" "),s("comparator",u,f),this.options=f,this.loose=!!f.loose,this.parse(u),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(u){const f=this.options.loose?r[o.COMPARATORLOOSE]:r[o.COMPARATOR],d=u.match(f);if(!d)throw new TypeError(`Invalid comparator: ${u}`);this.operator=d[1]!==void 0?d[1]:"",this.operator==="="&&(this.operator=""),d[2]?this.semver=new a(d[2],this.options.loose):this.semver=e}toString(){return this.value}test(u){if(s("Comparator.test",u,this.options.loose),this.semver===e||u===e)return!0;if(typeof u=="string")try{u=new a(u,this.options)}catch{return!1}return i(u,this.operator,this.semver,this.options)}intersects(u,f){if(!(u instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new l(u.value,f).test(this.value):u.operator===""?u.value===""?!0:new l(this.value,f).test(u.semver):(f=n(f),f.includePrerelease&&(this.value==="<0.0.0-0"||u.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||u.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&u.operator.startsWith(">")||this.operator.startsWith("<")&&u.operator.startsWith("<")||this.semver.version===u.semver.version&&this.operator.includes("=")&&u.operator.includes("=")||i(this.semver,"<",u.semver,f)&&this.operator.startsWith(">")&&u.operator.startsWith("<")||i(this.semver,">",u.semver,f)&&this.operator.startsWith("<")&&u.operator.startsWith(">")))}}Cs=t;const n=Il(),{safeRe:r,t:o}=Rl(),i=Fx(),s=Di(),a=Ol(),l=eg();return Cs}var Es,Zc;function eg(){if(Zc)return Es;Zc=1;const e=/\s+/g;class t{constructor(M,x){if(x=o(x),M instanceof t)return M.loose===!!x.loose&&M.includePrerelease===!!x.includePrerelease?M:new t(M.raw,x);if(M instanceof i)return this.raw=M.value,this.set=[[M]],this.formatted=void 0,this;if(this.options=x,this.loose=!!x.loose,this.includePrerelease=!!x.includePrerelease,this.raw=M.trim().replace(e," "),this.set=this.raw.split("||").map(O=>this.parseRange(O.trim())).filter(O=>O.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const O=this.set[0];if(this.set=this.set.filter(P=>!g(P[0])),this.set.length===0)this.set=[O];else if(this.set.length>1){for(const P of this.set)if(P.length===1&&v(P[0])){this.set=[P];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let M=0;M<this.set.length;M++){M>0&&(this.formatted+="||");const x=this.set[M];for(let O=0;O<x.length;O++)O>0&&(this.formatted+=" "),this.formatted+=x[O].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(M){const O=((this.options.includePrerelease&&h)|(this.options.loose&&p))+":"+M,P=r.get(O);if(P)return P;const A=this.options.loose,K=A?l[c.HYPHENRANGELOOSE]:l[c.HYPHENRANGE];M=M.replace(K,B(this.options.includePrerelease)),s("hyphen replace",M),M=M.replace(l[c.COMPARATORTRIM],u),s("comparator trim",M),M=M.replace(l[c.TILDETRIM],f),s("tilde trim",M),M=M.replace(l[c.CARETTRIM],d),s("caret trim",M);let H=M.split(" ").map(fe=>y(fe,this.options)).join(" ").split(/\s+/).map(fe=>N(fe,this.options));A&&(H=H.filter(fe=>(s("loose invalid filter",fe,this.options),!!fe.match(l[c.COMPARATORLOOSE])))),s("range list",H);const q=new Map,oe=H.map(fe=>new i(fe,this.options));for(const fe of oe){if(g(fe))return[fe];q.set(fe.value,fe)}q.size>1&&q.has("")&&q.delete("");const J=[...q.values()];return r.set(O,J),J}intersects(M,x){if(!(M instanceof t))throw new TypeError("a Range is required");return this.set.some(O=>m(O,x)&&M.set.some(P=>m(P,x)&&O.every(A=>P.every(K=>A.intersects(K,x)))))}test(M){if(!M)return!1;if(typeof M=="string")try{M=new a(M,this.options)}catch{return!1}for(let x=0;x<this.set.length;x++)if(ne(this.set[x],M,this.options))return!0;return!1}}Es=t;const n=xx(),r=new n,o=Il(),i=$x(),s=Di(),a=Ol(),{safeRe:l,t:c,comparatorTrimReplace:u,tildeTrimReplace:f,caretTrimReplace:d}=Rl(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:p}=Pl(),g=I=>I.value==="<0.0.0-0",v=I=>I.value==="",m=(I,M)=>{let x=!0;const O=I.slice();let P=O.pop();for(;x&&O.length;)x=O.every(A=>P.intersects(A,M)),P=O.pop();return x},y=(I,M)=>(s("comp",I,M),I=R(I,M),s("caret",I),I=S(I,M),s("tildes",I),I=V(I,M),s("xrange",I),I=k(I,M),s("stars",I),I),b=I=>!I||I.toLowerCase()==="x"||I==="*",S=(I,M)=>I.trim().split(/\s+/).map(x=>C(x,M)).join(" "),C=(I,M)=>{const x=M.loose?l[c.TILDELOOSE]:l[c.TILDE];return I.replace(x,(O,P,A,K,H)=>{s("tilde",I,O,P,A,K,H);let q;return b(P)?q="":b(A)?q=`>=${P}.0.0 <${+P+1}.0.0-0`:b(K)?q=`>=${P}.${A}.0 <${P}.${+A+1}.0-0`:H?(s("replaceTilde pr",H),q=`>=${P}.${A}.${K}-${H} <${P}.${+A+1}.0-0`):q=`>=${P}.${A}.${K} <${P}.${+A+1}.0-0`,s("tilde return",q),q})},R=(I,M)=>I.trim().split(/\s+/).map(x=>D(x,M)).join(" "),D=(I,M)=>{s("caret",I,M);const x=M.loose?l[c.CARETLOOSE]:l[c.CARET],O=M.includePrerelease?"-0":"";return I.replace(x,(P,A,K,H,q)=>{s("caret",I,P,A,K,H,q);let oe;return b(A)?oe="":b(K)?oe=`>=${A}.0.0${O} <${+A+1}.0.0-0`:b(H)?A==="0"?oe=`>=${A}.${K}.0${O} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.0${O} <${+A+1}.0.0-0`:q?(s("replaceCaret pr",q),A==="0"?K==="0"?oe=`>=${A}.${K}.${H}-${q} <${A}.${K}.${+H+1}-0`:oe=`>=${A}.${K}.${H}-${q} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.${H}-${q} <${+A+1}.0.0-0`):(s("no pr"),A==="0"?K==="0"?oe=`>=${A}.${K}.${H}${O} <${A}.${K}.${+H+1}-0`:oe=`>=${A}.${K}.${H}${O} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.${H} <${+A+1}.0.0-0`),s("caret return",oe),oe})},V=(I,M)=>(s("replaceXRanges",I,M),I.split(/\s+/).map(x=>$(x,M)).join(" ")),$=(I,M)=>{I=I.trim();const x=M.loose?l[c.XRANGELOOSE]:l[c.XRANGE];return I.replace(x,(O,P,A,K,H,q)=>{s("xRange",I,O,P,A,K,H,q);const oe=b(A),J=oe||b(K),fe=J||b(H),Le=fe;return P==="="&&Le&&(P=""),q=M.includePrerelease?"-0":"",oe?P===">"||P==="<"?O="<0.0.0-0":O="*":P&&Le?(J&&(K=0),H=0,P===">"?(P=">=",J?(A=+A+1,K=0,H=0):(K=+K+1,H=0)):P==="<="&&(P="<",J?A=+A+1:K=+K+1),P==="<"&&(q="-0"),O=`${P+A}.${K}.${H}${q}`):J?O=`>=${A}.0.0${q} <${+A+1}.0.0-0`:fe&&(O=`>=${A}.${K}.0${q} <${A}.${+K+1}.0-0`),s("xRange return",O),O})},k=(I,M)=>(s("replaceStars",I,M),I.trim().replace(l[c.STAR],"")),N=(I,M)=>(s("replaceGTE0",I,M),I.trim().replace(l[M.includePrerelease?c.GTE0PRE:c.GTE0],"")),B=I=>(M,x,O,P,A,K,H,q,oe,J,fe,Le)=>(b(O)?x="":b(P)?x=`>=${O}.0.0${I?"-0":""}`:b(A)?x=`>=${O}.${P}.0${I?"-0":""}`:K?x=`>=${x}`:x=`>=${x}${I?"-0":""}`,b(oe)?q="":b(J)?q=`<${+oe+1}.0.0-0`:b(fe)?q=`<${oe}.${+J+1}.0-0`:Le?q=`<=${oe}.${J}.${fe}-${Le}`:I?q=`<${oe}.${J}.${+fe+1}-0`:q=`<=${q}`,`${x} ${q}`.trim()),ne=(I,M,x)=>{for(let O=0;O<I.length;O++)if(!I[O].test(M))return!1;if(M.prerelease.length&&!x.includePrerelease){for(let O=0;O<I.length;O++)if(s(I[O].semver),I[O].semver!==i.ANY&&I[O].semver.prerelease.length>0){const P=I[O].semver;if(P.major===M.major&&P.minor===M.minor&&P.patch===M.patch)return!0}return!1}return!0};return Es}var Ms,ed;function Ax(){if(ed)return Ms;ed=1;const e=eg();return Ms=(n,r)=>{try{return new e(n,r).range||"*"}catch{return null}},Ms}var Tx=Ax();const td=_f(Tx);var Fl=["id","name","validationState","required","disabled","readOnly"];function $l(e){const t=`form-control-${Ie()}`,n=Z({id:t},e),[r,o]=z(),[i,s]=z(),[a,l]=z(),[c,u]=z(),f=(g,v,m)=>{const y=m!=null||r()!=null;return[m,r(),y&&v!=null?g:void 0].filter(Boolean).join(" ")||void 0},d=g=>[a(),c(),g].filter(Boolean).join(" ")||void 0,h=L(()=>({"data-valid":T(n.validationState)==="valid"?"":void 0,"data-invalid":T(n.validationState)==="invalid"?"":void 0,"data-required":T(n.required)?"":void 0,"data-disabled":T(n.disabled)?"":void 0,"data-readonly":T(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>T(n.name)??T(n.id),dataset:h,validationState:()=>T(n.validationState),isRequired:()=>T(n.required),isDisabled:()=>T(n.disabled),isReadOnly:()=>T(n.readOnly),labelId:r,fieldId:i,descriptionId:a,errorMessageId:c,getAriaLabelledBy:f,getAriaDescribedBy:d,generateId:Ye(()=>T(n.id)),registerLabel:_e(o),registerField:_e(s),registerDescription:_e(l),registerErrorMessage:_e(u)}}}var Li=Ce();function it(){const e=xe(Li);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function Oo(e){const t=it(),n=Z({id:t.generateId("description")},e);return j(()=>Y(t.registerDescription(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}var Al=["id","aria-label","aria-labelledby","aria-describedby"];function Tl(e){const t=it(),n=Z({id:t.generateId("field")},e);return j(()=>Y(t.registerField(T(n.id)))),{fieldProps:{id:()=>T(n.id),ariaLabel:()=>T(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(T(n.id),T(n["aria-label"]),T(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(T(n["aria-describedby"]))}}}function kr(e){let t;const n=it(),r=Z({id:n.generateId("label")},e),[o,i]=_(r,["ref"]),s=Ei(()=>t,()=>"label");return j(()=>Y(n.registerLabel(i.id))),w(le,F({as:"label",ref(a){var l=me(c=>t=c,o.ref);typeof l=="function"&&l(a)},get for(){return L(()=>s()==="label")()?n.fieldId():void 0}},()=>n.dataset(),i))}function Dl(e,t){j(Ee(e,n=>{if(n==null)return;const r=Dx(n);r!=null&&(r.addEventListener("reset",t,{passive:!0}),Y(()=>{r.removeEventListener("reset",t)}))}))}function Dx(e){return Lx(e)?e.form:e.closest("form")}function Lx(e){return e.matches("textarea, input, select, button")}function Fo(e){const t=it(),n=Z({id:t.generateId("error-message")},e),[r,o]=_(n,["forceMount"]),i=()=>t.validationState()==="invalid";return j(()=>{i()&&Y(t.registerErrorMessage(o.id))}),w(de,{get when(){return r.forceMount||i()},get children(){return w(le,F({as:"div"},()=>t.dataset(),o))}})}var _x={};dt(_x,{Control:()=>Ll,Description:()=>ng,ErrorMessage:()=>rg,Input:()=>_l,Label:()=>kl,Root:()=>Vl,Switch:()=>Vx,Thumb:()=>Nl,useSwitchContext:()=>Hn});var tg=Ce();function Hn(){const e=xe(tg);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function Ll(e){const t=it(),n=Hn(),r=Z({id:n.generateId("control")},e),[o,i]=_(r,["onClick","onKeyDown"]);return w(le,F({as:"div",onClick:l=>{var c;ee(l,o.onClick),n.toggle(),(c=n.inputRef())==null||c.focus()},onKeyDown:l=>{var c;ee(l,o.onKeyDown),l.key===Oa.Space&&(n.toggle(),(c=n.inputRef())==null||c.focus())}},()=>t.dataset(),()=>n.dataset(),i))}function ng(e){const t=Hn();return w(Oo,F(()=>t.dataset(),e))}function rg(e){const t=Hn();return w(Fo,F(()=>t.dataset(),e))}function _l(e){const t=it(),n=Hn(),r=Z({id:n.generateId("input")},e),[o,i,s]=_(r,["ref","style","onChange","onFocus","onBlur"],Al),{fieldProps:a}=Tl(i);return w(le,F({as:"input",ref(f){var d=me(n.setInputRef,o.ref);typeof d=="function"&&d(f)},type:"checkbox",role:"switch",get id(){return a.id()},get name(){return t.name()},get value(){return n.value()},get checked(){return n.checked()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return ct({...Ci},o.style)},get"aria-checked"(){return n.checked()},get"aria-label"(){return a.ariaLabel()},get"aria-labelledby"(){return a.ariaLabelledBy()},get"aria-describedby"(){return a.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},onChange:f=>{ee(f,o.onChange),f.stopPropagation();const d=f.target;n.setIsChecked(d.checked),d.checked=n.checked()},onFocus:f=>{ee(f,o.onFocus),n.setIsFocused(!0)},onBlur:f=>{ee(f,o.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),s))}function kl(e){const t=Hn();return w(kr,F(()=>t.dataset(),e))}function Vl(e){let t;const n=`switch-${Ie()}`,r=Z({value:"on",id:n},e),[o,i,s]=_(r,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],Fl),[a,l]=z(),[c,u]=z(!1),{formControlContext:f}=$l(i),d=wh({isSelected:()=>o.checked,defaultIsSelected:()=>o.defaultChecked,onSelectedChange:v=>{var m;return(m=o.onChange)==null?void 0:m.call(o,v)},isDisabled:()=>f.isDisabled(),isReadOnly:()=>f.isReadOnly()});Dl(()=>t,()=>d.setIsSelected(o.defaultChecked??!1));const h=v=>{ee(v,o.onPointerDown),c()&&v.preventDefault()},p=L(()=>({"data-checked":d.isSelected()?"":void 0})),g={value:()=>o.value,dataset:p,checked:()=>d.isSelected(),inputRef:a,generateId:Ye(()=>T(i.id)),toggle:()=>d.toggle(),setIsChecked:v=>d.setIsSelected(v),setIsFocused:u,setInputRef:l};return w(Li.Provider,{value:f,get children(){return w(tg.Provider,{value:g,get children(){return w(le,F({as:"div",ref(v){var m=me(y=>t=y,o.ref);typeof m=="function"&&m(v)},role:"group",get id(){return T(i.id)},onPointerDown:h},()=>f.dataset(),p,s,{get children(){return w(kx,{state:g,get children(){return o.children}})}}))}})}})}function kx(e){const t=xr(()=>{const n=e.children;return un(n)?n(e.state):n});return L(t)}function Nl(e){const t=it(),n=Hn(),r=Z({id:n.generateId("thumb")},e);return w(le,F({as:"div"},()=>t.dataset(),()=>n.dataset(),r))}var Vx=Object.assign(Vl,{Control:Ll,Description:ng,ErrorMessage:rg,Input:_l,Label:kl,Thumb:Nl});const ma=Vl,va=e=>{const[t,n]=_(e,["class","children"]);return[w(_l,{get class(){return ce("[&:focus-visible+div]:outline-none [&:focus-visible+div]:ring-2 [&:focus-visible+div]:ring-ring [&:focus-visible+div]:ring-offset-2 [&:focus-visible+div]:ring-offset-background",t.class)}}),w(Ll,F({get class(){return ce("inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-input transition-[color,background-color,box-shadow] data-[disabled]:cursor-not-allowed data-[checked]:bg-primary data-[disabled]:opacity-50",t.class)}},n,{get children(){return t.children}}))]},ya=e=>{const[t,n]=_(e,["class"]);return w(Nl,F({get class(){return ce("pointer-events-none block size-5 translate-x-0 rounded-full bg-background shadow-lg ring-0 transition-transform data-[checked]:translate-x-5",t.class)}},n))},wa=e=>{const[t,n]=_(e,["class"]);return w(kl,F({get class(){return ce("text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70",t.class)}},n))};var Nx={};dt(Nx,{Description:()=>Oo,ErrorMessage:()=>Fo,Input:()=>zl,Label:()=>kr,Root:()=>Bl,TextArea:()=>sg,TextField:()=>zx,useTextFieldContext:()=>Kl});var og=Ce();function Kl(){const e=xe(og);if(e===void 0)throw new Error("[kobalte]: `useTextFieldContext` must be used within a `TextField` component");return e}function zl(e){return w(ig,F({type:"text"},e))}function ig(e){const t=it(),n=Kl(),r=Z({id:n.generateId("input")},e),[o,i,s]=_(r,["onInput"],Al),{fieldProps:a}=Tl(i);return w(le,F({as:"input",get id(){return a.id()},get name(){return t.name()},get value(){return n.value()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get"aria-label"(){return a.ariaLabel()},get"aria-labelledby"(){return a.ariaLabelledBy()},get"aria-describedby"(){return a.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},get onInput(){return ye([o.onInput,n.onInput])}},()=>t.dataset(),s))}function Bl(e){let t;const n=`textfield-${Ie()}`,r=Z({id:n},e),[o,i,s]=_(r,["ref","value","defaultValue","onChange"],Fl),a=o.value,[l,c]=wt({value:()=>a===void 0?void 0:o.value??"",defaultValue:()=>o.defaultValue,onChange:h=>{var p;return(p=o.onChange)==null?void 0:p.call(o,h)}}),{formControlContext:u}=$l(i);Dl(()=>t,()=>c(o.defaultValue??""));const f=h=>{if(u.isReadOnly()||u.isDisabled())return;const p=h.target;c(p.value),p.value=l()??""},d={value:l,generateId:Ye(()=>T(i.id)),onInput:f};return w(Li.Provider,{value:u,get children(){return w(og.Provider,{value:d,get children(){return w(le,F({as:"div",ref(h){var p=me(g=>t=g,o.ref);typeof p=="function"&&p(h)},role:"group",get id(){return T(i.id)}},()=>u.dataset(),s))}})}})}function sg(e){let t;const n=Kl(),r=Z({id:n.generateId("textarea")},e),[o,i]=_(r,["ref","autoResize","submitOnEnter","onKeyPress"]);j(Ee([()=>t,()=>o.autoResize,()=>n.value()],([a,l])=>{!a||!l||Kx(a)}));const s=a=>{t&&o.submitOnEnter&&a.key==="Enter"&&!a.shiftKey&&t.form&&(t.form.requestSubmit(),a.preventDefault())};return w(ig,F({as:"textarea",get"aria-multiline"(){return o.submitOnEnter?"false":void 0},get onKeyPress(){return ye([o.onKeyPress,s])},ref(a){var l=me(c=>t=c,o.ref);typeof l=="function"&&l(a)}},i))}function Kx(e){const t=e.style.alignSelf,n=e.style.overflow;"MozAppearance"in e.style||(e.style.overflow="hidden"),e.style.alignSelf="start",e.style.height="auto",e.style.height=`${e.scrollHeight+(e.offsetHeight-e.clientHeight)}px`,e.style.overflow=n,e.style.alignSelf=t}var zx=Object.assign(Bl,{Description:Oo,ErrorMessage:Fo,Input:zl,Label:kr,TextArea:sg});const ii=Bl,Is=e=>{const[t,n]=_(e,["type","class"]);return w(zl,F({get type(){return t.type},get class(){return ce("flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50",t.class)}},n))},Bx=Mr("text-sm font-medium leading-none peer-disabled:opacity-70",{variants:{variant:{label:"data-[invalid]:text-destructive",description:"text-destructive",error:"font-normal text-red-500"}},defaultVariants:{variant:"label"}}),si=e=>{const[t,n]=_(e,["class"]);return w(kr,F({get class(){return ce(Bx(),t.class)}},n))};var nd=te("<div>"),jx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Platform: <p class="ml-2 flex flex-row items-center"> iOS'),Ux=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Platform: <p class="ml-2 flex flex-row items-center"> Android'),Hx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Channel: <p class=ml-2>'),Gx=te('<form class="flex flex-col gap-3 flex-1"><div></div><div><div class="flex items-center space-x-2"></div><p class="text-xs text-muted-foreground mt-[2px]">When disabled, this update will not be available to your users.</p></div><div><div class="flex items-center space-x-2"></div><p class="text-xs text-muted-foreground mt-[2px]">When enabled, this update will require users to update before continuing to use the application.</p></div><div class="mt-2 space-y-1"><h3 class="text-md text-bold font-medium">Metadata'),qx=te('<em class="text-xs text-red-500">'),Wx=te('<em class="text-xs text-muted-foreground">'),Qx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">App Version: <p class=ml-2>'),Xx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Commit Hash: '),Yx=te("<a target=_blank rel=noreferrer class=ml-2>"),Jx=te("<p class=ml-2>");const Zx=({bundle:e,onEditSuccess:t})=>{const n=yo(),r=US(),[o,i]=z(!1),s=L(()=>{var u,f;return((f=(u=r.data)==null?void 0:u.console)==null?void 0:f.gitUrl)??null}),a=L(()=>e.gitCommitHash),l=Sx(()=>({defaultValues:{message:e.message,targetAppVersion:e.targetAppVersion,enabled:e.enabled,shouldForceUpdate:e.shouldForceUpdate},onSubmit:async({value:u})=>{i(!0);try{const f=await wn.bundles[":bundleId"].$patch({param:{bundleId:e.id},json:u});if(f.status!==200){const d=await f.json();Yt({title:"Error",description:d.error,variant:"error"})}}catch(f){f instanceof Error&&Yt({title:"Error",description:f.message,variant:"error"})}finally{i(!1),n.invalidateQueries({queryKey:["bundle",e.id]}),n.invalidateQueries({queryKey:["bundles"]}),n.invalidateQueries({queryKey:["channels"]}),t()}}})),c=l.useStore(u=>u.isValid);return(()=>{var u=Gx(),f=u.firstChild,d=f.nextSibling,h=d.firstChild,p=d.nextSibling,g=p.firstChild,v=p.nextSibling;return v.firstChild,u.addEventListener("submit",m=>{m.preventDefault(),m.stopPropagation(),l.handleSubmit()}),W(f,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"message",children:"Message"}),w(l.Field,{name:"message",children:m=>w(Is,{type:"text",id:"message",placeholder:"Message",get name(){return m().name},get value(){return m().state.value??""},get onBlur(){return m().handleBlur},onInput:y=>m().handleChange(y.currentTarget.value)})})]}})),W(u,w(de,{get when(){return e.targetAppVersion},get children(){var m=nd();return W(m,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"targetAppVersion",children:"Target App Version"}),w(l.Field,{name:"targetAppVersion",validators:{onChange:({value:y})=>{if((y==null?void 0:y.length)===0||!td(y))return"Invalid target app version"}},children:y=>[w(Is,{type:"text",id:"targetAppVersion",get class(){return ce(y().state.meta.errors.length>0&&"border-red-500 focus-visible:ring-red-500")},placeholder:"Target App Version",get name(){return y().name},get value(){return y().state.value??""},get onBlur(){return y().handleBlur},onInput:b=>y().handleChange(b.currentTarget.value)}),L(()=>L(()=>y().state.meta.errors.length>0)()?(()=>{var b=qx();return W(b,()=>y().state.meta.errors.join(", ")),b})():(()=>{var b=Wx();return W(b,()=>td(y().state.value)),b})())]})]}})),m}}),d),W(u,w(de,{get when(){return e.fingerprintHash},get children(){var m=nd();return W(m,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"fingerprintHash",children:"Fingerprint Hash"}),w(Is,{type:"text",id:"fingerprintHash",get value(){return e.fingerprintHash??""},disabled:!0})]}})),m}}),d),W(h,w(l.Field,{name:"enabled",children:m=>w(ma,{class:"flex items-center space-x-2",get checked(){return m().state.value},get name(){return m().name},onChange:y=>m().handleChange(y),get children(){return[w(va,{get children(){return w(ya,{})}}),w(wa,{children:"Enabled"})]}})})),W(g,w(l.Field,{name:"shouldForceUpdate",children:m=>w(ma,{class:"flex items-center space-x-2",get checked(){return m().state.value},get name(){return m().name},onChange:y=>m().handleChange(y),get children(){return[w(va,{get children(){return w(ya,{})}}),w(wa,{children:"Force Update"})]}})})),W(u,w(de,{get when(){return!o()},get fallback(){return w(fn,{type:"submit",class:"mt-4",disabled:!0,get children(){return w(lw,{class:"animate-spin"})}})},get children(){return w(fn,{type:"submit",class:"mt-4",get disabled(){return!c()},children:"Save"})}}),v),W(v,w(de,{get when(){return e.platform==="ios"},get children(){var m=jx(),y=m.firstChild,b=y.nextSibling,S=b.firstChild;return W(b,w(Nf,{class:"inline-block"}),S),m}}),null),W(v,w(de,{get when(){return e.platform==="android"},get children(){var m=Ux(),y=m.firstChild,b=y.nextSibling,S=b.firstChild;return W(b,w(Vf,{class:"inline-block"}),S),m}}),null),W(v,w(de,{get when(){var m;return(m=e.metadata)==null?void 0:m.app_version},children:m=>(()=>{var y=Qx(),b=y.firstChild,S=b.nextSibling;return W(S,m),y})()}),null),W(v,w(de,{get when(){return e.channel},get children(){var m=Hx(),y=m.firstChild,b=y.nextSibling;return W(b,()=>e.channel),m}}),null),W(v,w(de,{get when(){return a()},children:m=>(()=>{var y=Xx();return y.firstChild,W(y,(()=>{var b=L(()=>!!s());return()=>b()?(()=>{var S=Yx();return W(S,()=>m().slice(0,8)),Ve(()=>Ln(S,"href",`${s()}/commit/${m}`)),S})():(()=>{var S=Jx();return W(S,()=>m().slice(0,8)),S})()})(),null),y})()}),null),u})()};var ag=te("<div>");const eC=Mr("rounded-md border-l-4 p-2 pl-4",{variants:{variant:{default:"border-info-foreground bg-info text-info-foreground",success:"border-success-foreground bg-success text-success-foreground",warning:"border-warning-foreground bg-warning text-warning-foreground",error:"border-error-foreground bg-error text-error-foreground"}},defaultVariants:{variant:"default"}}),tC=e=>{const[t,n]=_(e,["class","variant"]);return(()=>{var r=ag();return qe(r,F({get class(){return ce(eC({variant:t.variant}),t.class)}},n),!1,!1),r})()},nC=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=ag();return qe(r,F({get class(){return ce("mt-2",t.class)}},n),!1,!1),r})()};var rC=te("<option>"),oC=te("<div aria-hidden=true><input type=text><select tabindex=-1><option>");function iC(e){let t;const[n,r]=_(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),o=it(),[i,s]=z(!1),a=l=>{const c=n.collection.getItem(l);return w(de,{get when(){return(c==null?void 0:c.type)==="item"},get children(){var u=rC();return u.value=l,W(u,()=>c==null?void 0:c.textValue),Ve(()=>u.selected=n.selectionManager.isSelected(l)),u}})};return j(Ee(()=>n.selectionManager.selectedKeys(),(l,c)=>{c&&dh(l,c)||(s(!0),t==null||t.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t==null||t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0})))},{defer:!0})),(()=>{var l=oC(),c=l.firstChild,u=c.nextSibling;u.firstChild,c.addEventListener("focus",()=>n.focusTrigger()),c.style.setProperty("font-size","16px"),u.addEventListener("change",d=>{ee(d,n.onChange),i()||n.selectionManager.setSelectedKeys(new Set([d.target.value])),s(!1)});var f=me(d=>t=d,n.ref);return typeof f=="function"&&Pd(f,u),qe(u,F({get multiple(){return n.isMultiple},get name(){return o.name()},get required(){return o.isRequired()},get disabled(){return o.isDisabled()},get size(){return n.collection.getSize()},get value(){return n.selectionManager.firstSelectedKey()??""}},r),!1,!0),W(u,w(de,{get when(){return n.isVirtualized},get fallback(){return w(et,{get each(){return[...n.collection.getKeys()]},children:a})},get children(){return w(et,{get each(){return[...n.selectionManager.selectedKeys()]},children:a})}}),null),Ve(d=>{var h=Ci,p=n.selectionManager.isFocused()||n.isOpen?-1:0,g=o.isRequired(),v=o.isDisabled(),m=o.isReadOnly();return d.e=Id(l,h,d.e),p!==d.t&&Ln(c,"tabindex",d.t=p),g!==d.a&&(c.required=d.a=g),v!==d.o&&(c.disabled=d.o=v),m!==d.i&&(c.readOnly=d.i=m),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),l})()}var rd=new WeakMap;function ba(e){let t=rd.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return rd.set(e,t),t}var sC={};dt(sC,{Item:()=>$o,ItemDescription:()=>_i,ItemIndicator:()=>Ao,ItemLabel:()=>To,Listbox:()=>aC,Root:()=>Ul,Section:()=>ki,useListboxContext:()=>ug});var lg=Ce();function ug(){const e=xe(lg);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var cg=Ce();function jl(){const e=xe(cg);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function $o(e){let t;const n=ug(),r=`${n.generateId("item")}-${Ie()}`,o=Z({id:r},e),[i,s]=_(o,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=z(),[c,u]=z(),f=()=>n.listState().selectionManager(),d=()=>f().focusedKey()===i.item.key,h=ul({key:()=>i.item.key,selectionManager:f,shouldSelectOnPressUp:n.shouldSelectOnPressUp,allowsDifferentPressOrigin:()=>n.shouldSelectOnPressUp()&&n.shouldFocusOnHover(),shouldUseVirtualFocus:n.shouldUseVirtualFocus,disabled:()=>i.item.disabled},()=>t),p=()=>{if(f().selectionMode()!=="none")return h.isSelected()},g=L(()=>!(wo()&&Dm())),v=()=>g()?i["aria-label"]:void 0,m=()=>g()?a():void 0,y=()=>g()?c():void 0,b=()=>{var $;if(!n.isVirtualized())return;const V=($=n.listState().collection().getItem(i.item.key))==null?void 0:$.index;return V!=null?V+1:void 0},S=()=>{if(n.isVirtualized())return ba(n.listState().collection())},C=V=>{ee(V,i.onPointerMove),V.pointerType==="mouse"&&!h.isDisabled()&&n.shouldFocusOnHover()&&(Fe(V.currentTarget),f().setFocused(!0),f().setFocusedKey(i.item.key))},R=L(()=>({"data-disabled":h.isDisabled()?"":void 0,"data-selected":h.isSelected()?"":void 0,"data-highlighted":d()?"":void 0})),D={isSelected:h.isSelected,dataset:R,generateId:Ye(()=>s.id),registerLabelId:_e(l),registerDescriptionId:_e(u)};return w(cg.Provider,{value:D,get children(){return w(le,F({as:"li",ref(V){var $=me(k=>t=k,i.ref);typeof $=="function"&&$(V)},role:"option",get tabIndex(){return h.tabIndex()},get"aria-disabled"(){return h.isDisabled()},get"aria-selected"(){return p()},get"aria-label"(){return v()},get"aria-labelledby"(){return m()},get"aria-describedby"(){return y()},get"aria-posinset"(){return b()},get"aria-setsize"(){return S()},get"data-key"(){return h.dataKey()},get onPointerDown(){return ye([i.onPointerDown,h.onPointerDown])},get onPointerUp(){return ye([i.onPointerUp,h.onPointerUp])},get onClick(){return ye([i.onClick,h.onClick])},get onKeyDown(){return ye([i.onKeyDown,h.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,h.onMouseDown])},get onFocus(){return ye([i.onFocus,h.onFocus])},onPointerMove:C},R,s))}})}function _i(e){const t=jl(),n=Z({id:t.generateId("description")},e);return j(()=>Y(t.registerDescriptionId(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}function Ao(e){const t=jl(),n=Z({id:t.generateId("indicator")},e),[r,o]=_(n,["forceMount"]);return w(de,{get when(){return r.forceMount||t.isSelected()},get children(){return w(le,F({as:"div","aria-hidden":"true"},()=>t.dataset(),o))}})}function To(e){const t=jl(),n=Z({id:t.generateId("label")},e);return j(()=>Y(t.registerLabelId(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}function Ul(e){let t;const n=`listbox-${Ie()}`,r=Z({id:n,selectionMode:"single",virtualized:!1},e),[o,i]=_(r,["ref","children","renderItem","renderSection","value","defaultValue","onChange","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","state","keyboardDelegate","autoFocus","selectionMode","shouldFocusWrap","shouldUseVirtualFocus","shouldSelectOnPressUp","shouldFocusOnHover","allowDuplicateSelectionEvents","disallowEmptySelection","selectionBehavior","selectOnFocus","disallowTypeAhead","allowsTabNavigation","virtualized","scrollToItem","scrollRef","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]),s=L(()=>o.state?o.state:cl({selectedKeys:()=>o.value,defaultSelectedKeys:()=>o.defaultValue,onSelectionChange:o.onChange,allowDuplicateSelectionEvents:()=>T(o.allowDuplicateSelectionEvents),disallowEmptySelection:()=>T(o.disallowEmptySelection),selectionBehavior:()=>T(o.selectionBehavior),selectionMode:()=>T(o.selectionMode),dataSource:()=>o.options??[],getKey:()=>o.optionValue,getTextValue:()=>o.optionTextValue,getDisabled:()=>o.optionDisabled,getSectionChildren:()=>o.optionGroupChildren})),a=gh({selectionManager:()=>s().selectionManager(),collection:()=>s().collection(),autoFocus:()=>T(o.autoFocus),shouldFocusWrap:()=>T(o.shouldFocusWrap),keyboardDelegate:()=>o.keyboardDelegate,disallowEmptySelection:()=>T(o.disallowEmptySelection),selectOnFocus:()=>T(o.selectOnFocus),disallowTypeAhead:()=>T(o.disallowTypeAhead),shouldUseVirtualFocus:()=>T(o.shouldUseVirtualFocus),allowsTabNavigation:()=>T(o.allowsTabNavigation),isVirtualized:()=>o.virtualized,scrollToKey:()=>o.scrollToItem},()=>t,()=>{var c;return(c=o.scrollRef)==null?void 0:c.call(o)}),l={listState:s,generateId:Ye(()=>i.id),shouldUseVirtualFocus:()=>r.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>r.shouldSelectOnPressUp,shouldFocusOnHover:()=>r.shouldFocusOnHover,isVirtualized:()=>o.virtualized};return w(lg.Provider,{value:l,get children(){return w(le,F({as:"ul",ref(c){var u=me(f=>t=f,o.ref);typeof u=="function"&&u(c)},role:"listbox",get tabIndex(){return a.tabIndex()},get"aria-multiselectable"(){return s().selectionManager().selectionMode()==="multiple"?!0:void 0},get onKeyDown(){return ye([o.onKeyDown,a.onKeyDown])},get onMouseDown(){return ye([o.onMouseDown,a.onMouseDown])},get onFocusIn(){return ye([o.onFocusIn,a.onFocusIn])},get onFocusOut(){return ye([o.onFocusOut,a.onFocusOut])}},i,{get children(){return w(de,{get when(){return!o.virtualized},get fallback(){var c;return(c=o.children)==null?void 0:c.call(o,s().collection)},get children(){return w(Pm,{get each(){return[...s().collection()]},by:"key",children:c=>w(Tg,{get children(){return[w(du,{get when(){return c().type==="section"},get children(){var u;return(u=o.renderSection)==null?void 0:u.call(o,c())}}),w(du,{get when(){return c().type==="item"},get children(){var u;return(u=o.renderItem)==null?void 0:u.call(o,c())}})]}})})}})}}))}})}function ki(e){return w(le,F({as:"li",role:"presentation"},e))}var aC=Object.assign(Ul,{Item:$o,ItemDescription:_i,ItemIndicator:Ao,ItemLabel:To,Section:ki}),dg=Ce();function Ht(){const e=xe(dg);if(e===void 0)throw new Error("[kobalte]: `useComboboxContext` must be used within a `Combobox` component");return e}function Hl(e){let t;const n=Ht(),[r,o]=_(e,["ref","style","onCloseAutoFocus","onFocusOutside"]),i=()=>{n.resetInputValue(n.listState().selectionManager().selectedKeys()),n.close(),setTimeout(()=>{n.close()})},s=a=>{var l;(l=r.onFocusOutside)==null||l.call(r,a),n.isOpen()&&n.isModal()&&a.preventDefault()};return Ha({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>{const a=[];t&&a.push(t);const l=n.controlRef();return l&&a.push(l),a}}),Ga({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ua({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:a=>{a.preventDefault()},onUnmountAutoFocus:a=>{var l;(l=r.onCloseAutoFocus)==null||l.call(r,a),a.defaultPrevented||(Fe(n.inputRef()),a.preventDefault())}},()=>t),w(de,{get when(){return n.contentPresent()},get children(){return w(Cn.Positioner,{get children(){return w(xo,F({ref(a){var l=me(c=>{n.setContentRef(c),t=c},r.ref);typeof l=="function"&&l(a)},get disableOutsidePointerEvents(){return L(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.controlRef]},get style(){return ct({"--kb-combobox-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},r.style)},onFocusOutside:s,onDismiss:i},()=>n.dataset(),o))}})}})}function Gl(e){let t;const n=it(),r=Ht(),o=Z({id:r.generateId("input")},e),[i,s,a]=_(o,["ref","disabled","onClick","onInput","onKeyDown","onFocus","onBlur","onTouchEnd"],Al),l=()=>r.listState().collection(),c=()=>r.listState().selectionManager(),u=()=>i.disabled||r.isDisabled()||n.isDisabled(),{fieldProps:f}=Tl(s),d=b=>{ee(b,i.onClick),r.triggerMode()==="focus"&&!r.isOpen()&&r.open(!1,"focus")},h=b=>{if(ee(b,i.onInput),n.isReadOnly()||u())return;const S=b.target;r.setInputValue(S.value),S.value=r.inputValue()??"",r.isOpen()?l().getSize()<=0&&!r.allowsEmptyCollection()&&r.close():(l().getSize()>0||r.allowsEmptyCollection())&&r.open(!1,"input")},p=b=>{if(ee(b,i.onKeyDown),!(n.isReadOnly()||u()))switch(r.isOpen()&&ee(b,r.onInputKeyDown),b.key){case"Enter":if(r.isOpen()){b.preventDefault();const S=c().focusedKey();S!=null&&c().select(S)}break;case"Tab":r.isOpen()&&(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys()));break;case"Escape":r.isOpen()?(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys())):r.setInputValue("");break;case"ArrowDown":r.isOpen()||r.open(b.altKey?!1:"first","manual");break;case"ArrowUp":r.isOpen()?b.altKey&&(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys())):r.open("last","manual");break;case"ArrowLeft":case"ArrowRight":c().setFocusedKey(void 0);break;case"Backspace":if(r.removeOnBackspace()&&c().selectionMode()==="multiple"&&r.inputValue()===""){const S=[...c().selectedKeys()].pop()??"";c().toggleSelection(S)}break}},g=b=>{ee(b,i.onFocus),!r.isInputFocused()&&r.setIsInputFocused(!0)},v=b=>{ee(b,i.onBlur),!($e(r.controlRef(),b.relatedTarget)||$e(r.contentRef(),b.relatedTarget))&&r.setIsInputFocused(!1)};let m=0;return w(le,F({as:"input",ref(b){var S=me(C=>{r.setInputRef(C),t=C},i.ref);typeof S=="function"&&S(b)},get id(){return f.id()},get value(){return r.inputValue()},get required(){return n.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return n.isReadOnly()},get placeholder(){return r.placeholder()},type:"text",role:"combobox",autoComplete:"off",autoCorrect:"off",spellCheck:"false","aria-haspopup":"listbox","aria-autocomplete":"list",get"aria-expanded"(){return r.isOpen()},get"aria-controls"(){return L(()=>!!r.isOpen())()?r.listboxId():void 0},get"aria-activedescendant"(){return r.activeDescendant()},get"aria-label"(){return f.ariaLabel()},get"aria-labelledby"(){return f.ariaLabelledBy()},get"aria-describedby"(){return f.ariaDescribedBy()},get"aria-invalid"(){return n.validationState()==="invalid"||void 0},get"aria-required"(){return n.isRequired()||void 0},get"aria-disabled"(){return n.isDisabled()||void 0},get"aria-readonly"(){return n.isReadOnly()||void 0},onClick:d,onInput:h,onKeyDown:p,onFocus:g,onBlur:v,onTouchEnd:b=>{if(ee(b,i.onTouchEnd),!t||n.isReadOnly()||u())return;if(b.timeStamp-m<500){b.preventDefault(),t.focus();return}const S=b.target.getBoundingClientRect(),C=b.changedTouches[0],R=Math.ceil(S.left+.5*S.width),D=Math.ceil(S.top+.5*S.height);C.clientX===R&&C.clientY===D&&(b.preventDefault(),t.focus(),r.toggle(!1,"manual"),m=b.timeStamp)}},()=>r.dataset(),()=>n.dataset(),a))}function ql(e){const t=it(),n=Ht(),r=Z({id:n.generateId("listbox")},e),[o,i]=_(r,["ref"]),s=()=>t.getAriaLabelledBy(i.id,n.listboxAriaLabel(),void 0);return j(()=>Y(n.registerListboxId(i.id))),w(Ul,F({ref(a){var l=me(n.setListboxRef,o.ref);typeof l=="function"&&l(a)},get state(){return n.listState()},get autoFocus(){return n.autoFocus()},shouldUseVirtualFocus:!0,shouldSelectOnPressUp:!0,shouldFocusOnHover:!0,get"aria-label"(){return n.listboxAriaLabel()},get"aria-labelledby"(){return s()},get renderItem(){return n.renderItem},get renderSection(){return n.renderSection},get virtualized(){return n.isVirtualized()}},i))}function Wl(e){const t=Ht();return w(de,{get when(){return t.contentPresent()},get children(){return w(mo,e)}})}function Ql(e){const t=it(),n=Ht(),[r,o]=_(e,["ref","children"]),i=()=>n.listState().selectionManager();return w(le,F({as:"div",ref(s){var a=me(n.setControlRef,r.ref);typeof a=="function"&&a(s)}},()=>n.dataset(),()=>t.dataset(),o,{get children(){return w(lC,{state:{selectedOptions:()=>n.selectedOptions(),remove:s=>n.removeOptionFromSelection(s),clear:()=>i().clearSelection()},get children(){return r.children}})}}))}function lC(e){const t=xr(()=>{const n=e.children;return un(n)?n(e.state):n});return L(t)}function fg(e){const t=Ht();return w(iC,F({get collection(){return t.listState().collection()},get selectionManager(){return t.listState().selectionManager()},get isOpen(){return t.isOpen()},get isMultiple(){return t.isMultiple()},get isVirtualized(){return t.isVirtualized()},focusTrigger:()=>{var n;return(n=t.inputRef())==null?void 0:n.focus()}},e))}function Xl(e){const t=Ht(),n=Z({children:"▼"},e);return w(le,F({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}var uC={focusAnnouncement:(e,t)=>`${e}${t?", selected":""}`,countAnnouncement:e=>{switch(e){case 1:return"one option available"}},selectedAnnouncement:e=>`${e}, selected`,triggerLabel:"Show suggestions",listboxLabel:"Suggestions"};function cC(e){const t=`combobox-${Ie()}`,n=Cw({sensitivity:"base"}),r=Z({id:t,selectionMode:"single",allowsEmptyCollection:!1,disallowEmptySelection:!1,allowDuplicateSelectionEvents:!0,closeOnSelection:e.selectionMode==="single",removeOnBackspace:!0,gutter:8,sameWidth:!0,modal:!1,defaultFilter:"contains",triggerMode:"input",translations:uC},e),[o,i,s,a]=_(r,["noResetInputOnBlur","translations","itemComponent","sectionComponent","open","defaultOpen","onOpenChange","onInputChange","value","defaultValue","onChange","triggerMode","placeholder","options","optionValue","optionTextValue","optionLabel","optionDisabled","optionGroupChildren","keyboardDelegate","allowDuplicateSelectionEvents","disallowEmptySelection","defaultFilter","shouldFocusWrap","allowsEmptyCollection","closeOnSelection","removeOnBackspace","selectionBehavior","selectionMode","virtualized","modal","preventScroll","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"],Fl),[l,c]=z(),[u,f]=z(),[d,h]=z(),[p,g]=z(),[v,m]=z(),[y,b]=z(),[S,C]=z(!1),[R,D]=z(!1),[V,$]=z(!1),[k,N]=z(o.options),B=Co({open:()=>o.open,defaultOpen:()=>o.defaultOpen,onOpenChange:U=>{var G;return(G=o.onOpenChange)==null?void 0:G.call(o,U,q)}}),[ne,I]=wt({defaultValue:()=>"",onChange:U=>{var G;(G=o.onInputChange)==null||G.call(o,U),U===""&&o.selectionMode==="single"&&!J.selectionManager().isEmpty()&&o.value===void 0&&J.selectionManager().setSelectedKeys([]),J.selectionManager().setFocusedKey(void 0)}}),M=U=>{const G=o.optionValue;return G==null?String(U):String(un(G)?G(U):U[G])},x=U=>{const G=o.optionLabel;return G==null?String(U):String(un(G)?G(U):U[G])},O=U=>{const G=o.optionTextValue;return G==null?String(U):String(un(G)?G(U):U[G])},P=L(()=>{const U=o.optionGroupChildren;return U==null?o.options:o.options.flatMap(G=>G[U]??G)}),A=U=>{var De;const G=ne()??"";if(un(o.defaultFilter))return(De=o.defaultFilter)==null?void 0:De.call(o,U,G);const we=O(U);switch(o.defaultFilter){case"startsWith":return n.startsWith(we,G);case"endsWith":return n.endsWith(we,G);case"contains":return n.contains(we,G)}},K=L(()=>{const U=o.optionGroupChildren;if(U==null)return o.options.filter(A);const G=[];for(const we of o.options){const De=we[U].filter(A);De.length!==0&&G.push({...we,[U]:De})}return G}),H=L(()=>B.isOpen()?V()?o.options:K():k());let q="focus";const oe=U=>[...U].map(G=>P().find(we=>M(we)===G)).filter(G=>G!=null),J=cl({selectedKeys:()=>o.value!=null?o.value.map(M):o.value,defaultSelectedKeys:()=>o.defaultValue!=null?o.defaultValue.map(M):o.defaultValue,onSelectionChange:U=>{var we;(we=o.onChange)==null||we.call(o,oe(U)),o.closeOnSelection&&B.isOpen()&&U.size>0&&(Pe(),setTimeout(Pe));const G=d();G&&(G.setSelectionRange(G.value.length,G.value.length),Fe(G))},allowDuplicateSelectionEvents:()=>T(o.allowDuplicateSelectionEvents),disallowEmptySelection:()=>o.disallowEmptySelection,selectionBehavior:()=>T(o.selectionBehavior),selectionMode:()=>o.selectionMode,dataSource:H,getKey:()=>o.optionValue,getTextValue:()=>o.optionTextValue,getDisabled:()=>o.optionDisabled,getSectionChildren:()=>o.optionGroupChildren}),fe=L(()=>oe(J.selectionManager().selectedKeys())),Le=U=>{J.selectionManager().toggleSelection(M(U))},{present:Je}=Vn({show:()=>o.forceMount||B.isOpen(),element:()=>v()??null}),ie=(U,G)=>{if(o.triggerMode==="manual"&&G!=="manual"||!($(G==="manual")?o.options.length>0:K().length>0)&&!o.allowsEmptyCollection)return;q=G,C(U),B.open();let qt=J.selectionManager().firstSelectedKey();qt==null&&(U==="first"?qt=J.collection().getFirstKey():U==="last"&&(qt=J.collection().getLastKey())),J.selectionManager().setFocused(!0),J.selectionManager().setFocusedKey(qt)},Pe=()=>{B.close(),J.selectionManager().setFocused(!1),J.selectionManager().setFocusedKey(void 0)},Te=(U,G)=>{B.isOpen()?Pe():ie(U,G)},{formControlContext:st}=$l(s);Dl(d,()=>{const U=o.defaultValue?[...o.defaultValue].map(M):new Rt;J.selectionManager().setSelectedKeys(U)});const Gt=L(()=>{const U=T(o.keyboardDelegate);return U||new hh(J.collection,y,void 0)}),Gn=fh({selectionManager:()=>J.selectionManager(),keyboardDelegate:Gt,disallowTypeAhead:!0,disallowEmptySelection:!0,shouldFocusWrap:()=>o.shouldFocusWrap,isVirtualized:!0},d),hg=U=>{U&&o.triggerMode==="focus"&&ie(!1,"focus"),D(U),J.selectionManager().setFocused(U)},gg=L(()=>{var G,we;const U=J.selectionManager().focusedKey();if(U)return(we=(G=y())==null?void 0:G.querySelector(`[data-key="${U}"]`))==null?void 0:we.id}),Zl=U=>{if(o.selectionMode==="single"){const G=[...U][0],we=P().find(De=>M(De)===G);if(o.noResetInputOnBlur&&!we)return;I(we?x(we):"")}else{if(o.noResetInputOnBlur)return;I("")}},pg=U=>{var G;return(G=o.itemComponent)==null?void 0:G.call(o,{item:U})},mg=U=>{var G;return(G=o.sectionComponent)==null?void 0:G.call(o,{section:U})};j(Ee([K,V],(U,G)=>{if(B.isOpen()&&G!=null){const we=G[0],De=G[1];N(De?o.options:we)}else{const we=U[0],De=U[1];N(De?o.options:we)}})),j(Ee(ne,()=>{V()&&$(!1)})),j(Ee(()=>J.selectionManager().selectedKeys(),Zl));let eu="";j(()=>{var we;const U=J.selectionManager().focusedKey()??"",G=J.collection().getItem(U);if(ti()&&G!=null&&U!==eu){const De=J.selectionManager().isSelected(U),qt=((we=o.translations)==null?void 0:we.focusAnnouncement((G==null?void 0:G.textValue)||"",De))??"";Qi(qt)}U&&(eu=U)});let tu=ba(J.collection()),nu=B.isOpen();j(()=>{var De;const U=ba(J.collection()),G=B.isOpen(),we=G!==nu&&(J.selectionManager().focusedKey()==null||ti());if(G&&(we||U!==tu)){const qt=((De=o.translations)==null?void 0:De.countAnnouncement(U))??"";Qi(qt)}tu=U,nu=G});let ru="";j(()=>{var we;const U=[...J.selectionManager().selectedKeys()].pop()??"",G=J.collection().getItem(U);if(ti()&&R()&&G&&U!==ru){const De=((we=o.translations)==null?void 0:we.selectedAnnouncement((G==null?void 0:G.textValue)||""))??"";Qi(De)}U&&(ru=U)});const ou=L(()=>({"data-expanded":B.isOpen()?"":void 0,"data-closed":B.isOpen()?void 0:""})),iu={dataset:ou,isOpen:B.isOpen,isDisabled:()=>st.isDisabled()??!1,isMultiple:()=>T(o.selectionMode)==="multiple",isVirtualized:()=>o.virtualized??!1,isModal:()=>o.modal??!1,preventScroll:()=>o.preventScroll??iu.isModal(),allowsEmptyCollection:()=>o.allowsEmptyCollection??!1,shouldFocusWrap:()=>o.shouldFocusWrap??!1,removeOnBackspace:()=>o.removeOnBackspace??!0,selectedOptions:fe,isInputFocused:R,contentPresent:Je,autoFocus:S,inputValue:ne,triggerMode:()=>o.triggerMode,activeDescendant:gg,controlRef:u,inputRef:d,triggerRef:p,contentRef:v,listState:()=>J,keyboardDelegate:Gt,listboxId:l,triggerAriaLabel:()=>{var U;return(U=o.translations)==null?void 0:U.triggerLabel},listboxAriaLabel:()=>{var U;return(U=o.translations)==null?void 0:U.listboxLabel},setIsInputFocused:hg,resetInputValue:Zl,setInputValue:I,setControlRef:f,setInputRef:h,setTriggerRef:g,setContentRef:m,setListboxRef:b,open:ie,close:Pe,toggle:Te,placeholder:()=>o.placeholder,renderItem:pg,renderSection:mg,removeOptionFromSelection:Le,onInputKeyDown:U=>Gn.onKeyDown(U),generateId:Ye(()=>T(s.id)),registerListboxId:_e(c)};return w(Li.Provider,{value:st,get children(){return w(dg.Provider,{value:iu,get children(){return w(Cn,F({anchorRef:u,contentRef:v},i,{get children(){return w(le,F({as:"div",role:"group",get id(){return T(s.id)}},()=>st.dataset(),ou,a))}}))}})}})}var dC={};dt(dC,{Arrow:()=>Dr,Combobox:()=>fC,Content:()=>Hl,Control:()=>Ql,Description:()=>Oo,ErrorMessage:()=>Fo,HiddenSelect:()=>fg,Icon:()=>Xl,Input:()=>Gl,Item:()=>$o,ItemDescription:()=>_i,ItemIndicator:()=>Ao,ItemLabel:()=>To,Label:()=>kr,Listbox:()=>ql,Portal:()=>Wl,Root:()=>Yl,Section:()=>ki,Trigger:()=>Jl,useComboboxContext:()=>Ht});function Yl(e){const[t,n]=_(e,["value","defaultValue","onChange","multiple"]),r=L(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),o=L(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return w(cC,F({get value(){return r()},get defaultValue(){return o()},onChange:s=>{var a,l;t.multiple?(a=t.onChange)==null||a.call(t,s??[]):(l=t.onChange)==null||l.call(t,s[0]??null)},get selectionMode(){return t.multiple?"multiple":"single"}},n))}function Jl(e){const t=it(),n=Ht(),r=Z({id:n.generateId("trigger")},e),[o,i]=_(r,["ref","disabled","onPointerDown","onClick","aria-labelledby"]),s=()=>o.disabled||n.isDisabled()||t.isDisabled()||t.isReadOnly(),a=u=>{ee(u,o.onPointerDown),u.currentTarget.dataset.pointerType=u.pointerType,!s()&&u.pointerType!=="touch"&&u.button===0&&(u.preventDefault(),n.toggle(!1,"manual"))},l=u=>{var f;ee(u,o.onClick),s()||(u.currentTarget.dataset.pointerType==="touch"&&n.toggle(!1,"manual"),(f=n.inputRef())==null||f.focus())},c=()=>t.getAriaLabelledBy(i.id,n.triggerAriaLabel(),o["aria-labelledby"]);return w(xt,F({ref(u){var f=me(n.setTriggerRef,o.ref);typeof f=="function"&&f(u)},get disabled(){return s()},tabIndex:-1,"aria-haspopup":"listbox",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return L(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return n.triggerAriaLabel()},get"aria-labelledby"(){return c()},onPointerDown:a,onClick:l},()=>n.dataset(),i))}var fC=Object.assign(Yl,{Arrow:Dr,Content:Hl,Control:Ql,Description:Oo,ErrorMessage:Fo,HiddenSelect:fg,Icon:Xl,Input:Gl,Item:$o,ItemDescription:_i,ItemIndicator:Ao,ItemLabel:To,Label:kr,Listbox:ql,Portal:Wl,Section:ki,Trigger:Jl}),hC=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M5 12l5 5l10 -10">'),gC=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M8 9l4 -4l4 4"></path><path d="M16 15l-4 4l-4 -4">');const pC=Yl,mC=To,vC=e=>{const[t,n]=_(e,["class"]);return w($o,F({get class(){return ce("relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",t.class)}},n))},yC=e=>{const[t,n]=_(e,["children"]);return w(Ao,F(n,{get children(){return w(de,{get when(){return t.children},get fallback(){return hC()},children:r=>r()})}}))},wC=e=>{const[t,n]=_(e,["class"]);return w(Ql,F({get class(){return ce("flex h-10 items-center rounded-md border px-3",t.class)}},n))},bC=e=>{const[t,n]=_(e,["class"]);return w(Gl,F({get class(){return ce("flex size-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t.class)}},n))},SC=e=>{const[t,n]=_(e,["class","children"]);return w(Jl,F({get class(){return ce("size-4 opacity-50",t.class)}},n,{get children(){return w(Xl,{get children(){return w(de,{get when(){return t.children},get fallback(){return gC()},children:r=>r()})}})}}))},xC=e=>{const[t,n]=_(e,["class"]);return w(Wl,{get children(){return w(Hl,F({get class(){return ce("z-50 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80",t.class)}},n,{get children(){return w(ql,{class:"m-0 p-1"})}}))}})};var CC=te('<div class="flex items-center justify-between"><div class=space-y-0.5><div class="text-sm text-muted-foreground">'),EC=te('<div class="mt-4 space-y-4">'),MC=te('<div class="h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent">'),IC=te('<div class="flex gap-2 justify-end mt-4">');const PC=({bundle:e})=>{const t=yo(),n=jh(),[,r]=Kd(),[o,i]=z(!1),[s,a]=z(e.channel),[l,c]=z(!1),[u,f]=z(!1),d=async()=>{i(!0);try{if(u()){const h={...e,id:Eb(e.id),channel:s()},p=await wn.bundles.$post({json:h});if(p.status!==200){const g=await p.json();"error"in g&&Yt({title:"Error",description:g.error,variant:"error"});return}Yt({title:"Success",description:`Created new bundle ${h.id} in ${s()}`,variant:"success"}),r({bundleId:void 0,channel:s()})}else{const h=await wn.bundles[":bundleId"].$patch({param:{bundleId:e.id},json:{channel:s()}});if(h.status!==200){const p=await h.json();Yt({title:"Error",description:p.error,variant:"error"});return}Yt({title:"Success",description:`Moved bundle ${e.id} to ${s()}`,variant:"success"}),r({bundleId:e.id,channel:s()})}t.invalidateQueries({queryKey:["bundle",e.id]}),t.invalidateQueries({queryKey:["bundles"]}),t.invalidateQueries({queryKey:["channels"]}),setTimeout(()=>c(!1),100)}catch(h){h instanceof Error&&Yt({title:"Error",description:h.message,variant:"error"})}finally{i(!1)}};return w(Uh,{get open(){return l()},onOpenChange:c,get children(){return[w(Hh,{as:fn,variant:"outline",size:"sm",class:"gap-2 flex-1",get children(){return[w(tc,{class:"h-4 w-4"}),"Promote Channel"]}}),w(Cl,{}),w(Gh,{get children(){return[w(qh,{children:"Promote Channel"}),w(Wh,{children:"Select or enter a new channel for this bundle. Choose whether to copy the bundle (keeps it in the original channel) or move it (removes from the original channel)."}),(()=>{var h=EC();return W(h,w(ma,{get checked(){return u()},onChange:f,get children(){var p=CC(),g=p.firstChild,v=g.firstChild;return W(g,w(wa,{class:"text-base",get children(){return u()?"Copy bundle":"Move bundle"}}),v),W(v,()=>u()?"Keep original + create copy in target channel":"Move to target channel (removes from current)"),W(p,w(va,{get children(){return w(ya,{})}}),null),p}}),null),W(h,w(de,{get when(){return u()},get children(){return w(tC,{variant:"default",get children(){return w(nC,{class:"mt-0 text-sm",children:"The copied bundle will have a new database ID that differs from the bundle ID inside the JavaScript bundle."})}})}}),null),W(h,w(ii,{class:"grid w-full items-center gap-1.5",get children(){return[w(si,{for:"channel",children:"Channel"}),w(pC,{get defaultValue(){return s()},get options(){return n.data??[]},onChange:p=>p&&a(p),onInputChange:p=>{a(p)},placeholder:"Enter or select a channel...",itemComponent:p=>w(vC,{get item(){return p.item},get children(){return[w(mC,{get children(){return p.item.rawValue}}),w(yC,{})]}}),get children(){return[w(wC,{"aria-label":"Channel",get children(){return[w(bC,{}),w(SC,{})]}}),w(xC,{})]}})]}}),null),h})(),(()=>{var h=IC();return W(h,w(Sn,{as:fn,variant:"outline",size:"sm",children:"Cancel"}),null),W(h,w(fn,{variant:"default",size:"sm",onClick:d,get disabled(){return o()||!s()},class:"gap-2",get children(){return[w(de,{get when(){return o()},get fallback(){return w(tc,{class:"h-4 w-4"})},get children(){return MC()}}),L(()=>L(()=>!!o())()?u()?"Copying...":"Moving...":u()?"Copy":"Move")]}}),null),h})()]}})]}})};var RC=te('<div class="mt-auto gap-3 pt-4 flex justify-between">');const OC=({bundleId:e,onClose:t})=>{const n=jS(e);return w(Ky,{class:"flex flex-col h-full",get children(){return[w(zy,{class:"mb-4",get children(){return w(By,{get children(){return["Edit ",e]}})}}),w(de,{get when(){return n.data},get fallback(){return L(()=>!!n.isFetched)()?w(jy,{get children(){return["No update bundle found for bundle id ",e]}}):w(JS,{height:374,radius:10})},children:r=>w(Zx,{get bundle(){return r()},onEditSuccess:t})}),(()=>{var r=RC();return W(r,w(de,{get when(){return n.data},children:o=>w(PC,{get bundle(){return o()}})}),null),W(r,w(sx,{bundleId:e,onDeleteSuccess:t}),null),r})()]}})};function FC(){const{bundleIdFilter:e,setBundleIdFilter:t}=Lf(),n=L(()=>e()!==null),r=()=>{t(null)};return w(Ly,{get open(){return n()},onOpenChange:o=>{o||t(null)},get children(){return[w(QS,{columns:Rb,onRowClick:o=>{t(o.id)}}),w(de,{get when(){return e()},get children(){return w(Lg,{get children(){return w(OC,{get bundleId(){return e()},onClose:r})}})}})]}})}const $C=new vm;function AC(){return w(dm,{client:$C,get children(){return[w(kp,{root:e=>w(ip,{get children(){return[w(lp,{children:"HotUpdater Console"}),w(bm,{get children(){return e.children}})]}}),get children(){return w(Fp,{path:"/",component:FC})}}),w(fy,{})]}})}const od=document.getElementById("root");od&&Gg(()=>w(AC,{}),od);
27
+ */function wc(e,t){return e?typeof e=="function"?w(e,t):e:null}function w0(e){const t=F({state:{},onStateChange:()=>{},renderFallbackValue:null,mergeOptions:(i,s)=>F(i,s)},e),n=h0(t),[r,o]=vo(n.initialState);return pt(()=>{n.setOptions(i=>F(i,e,{state:F(r,e.state||{}),onStateChange:s=>{o(s),e.onStateChange==null||e.onStateChange(s)}}))}),n}function b0(e){const[t,n]=z(0),[r,o]=z(0);j(()=>{const a=e();if(!a)return;s(a);const l=new ResizeObserver(i);l.observe(a),Y(()=>{l.disconnect()})});const i=a=>{for(const l of a)l.target===e()&&s(l.target)},s=a=>{o(a.offsetWidth),n(a.offsetHeight)};return{width:r,height:t}}function lh(e){let t=e.startIndex??0;const n=e.startLevel??0,r=[],o=l=>{if(l==null)return"";const c=e.getKey??"key",u=Jn(c)?l[c]:c(l);return u!=null?String(u):""},i=l=>{if(l==null)return"";const c=e.getTextValue??"textValue",u=Jn(c)?l[c]:c(l);return u!=null?String(u):""},s=l=>{if(l==null)return!1;const c=e.getDisabled??"disabled";return(Jn(c)?l[c]:c(l))??!1},a=l=>{var c;if(l!=null)return Jn(e.getSectionChildren)?l[e.getSectionChildren]:(c=e.getSectionChildren)==null?void 0:c.call(e,l)};for(const l of e.dataSource){if(Jn(l)||Fm(l)){r.push({type:"item",rawValue:l,key:String(l),textValue:String(l),disabled:s(l),level:n,index:t}),t++;continue}if(a(l)!=null){r.push({type:"section",rawValue:l,key:"",textValue:"",disabled:!1,level:n,index:t}),t++;const c=a(l)??[];if(c.length>0){const u=lh({dataSource:c,getKey:e.getKey,getTextValue:e.getTextValue,getDisabled:e.getDisabled,getSectionChildren:e.getSectionChildren,startIndex:t,startLevel:n+1});r.push(...u),t+=u.length}}else r.push({type:"item",rawValue:l,key:o(l),textValue:i(l),disabled:s(l),level:n,index:t}),t++}return r}function S0(e,t=[]){return L(()=>{const n=lh({dataSource:T(e.dataSource),getKey:T(e.getKey),getTextValue:T(e.getTextValue),getDisabled:T(e.getDisabled),getSectionChildren:T(e.getSectionChildren)});for(let r=0;r<t.length;r++)t[r]();return e.factory(n)})}var Rt=class uh extends Set{constructor(n,r,o){super(n);Re(this,"anchorKey");Re(this,"currentKey");n instanceof uh?(this.anchorKey=r||n.anchorKey,this.currentKey=o||n.currentKey):(this.anchorKey=r,this.currentKey=o)}};function x0(e){const[t,n]=wt(e);return[()=>t()??new Rt,n]}function ch(e){return ti()?e.altKey:e.ctrlKey}function Zn(e){return wo()?e.metaKey:e.ctrlKey}function bc(e){return new Rt(e)}function dh(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function C0(e){const t=Z({selectionMode:"none",selectionBehavior:"toggle"},e),[n,r]=z(!1),[o,i]=z(),s=L(()=>{const g=T(t.selectedKeys);return g!=null?bc(g):g}),a=L(()=>{const g=T(t.defaultSelectedKeys);return g!=null?bc(g):new Rt}),[l,c]=x0({value:s,defaultValue:a,onChange:g=>{var v;return(v=t.onSelectionChange)==null?void 0:v.call(t,g)}}),[u,f]=z(T(t.selectionBehavior)),d=()=>T(t.selectionMode),h=()=>T(t.disallowEmptySelection)??!1,p=g=>{(T(t.allowDuplicateSelectionEvents)||!dh(g,l()))&&c(g)};return j(()=>{const g=l();T(t.selectionBehavior)==="replace"&&u()==="toggle"&&typeof g=="object"&&g.size===0&&f("replace")}),j(()=>{f(T(t.selectionBehavior)??"toggle")}),{selectionMode:d,disallowEmptySelection:h,selectionBehavior:u,setSelectionBehavior:f,isFocused:n,setFocused:r,focusedKey:o,setFocusedKey:i,selectedKeys:l,setSelectedKeys:p}}function E0(e){const[t,n]=z(""),[r,o]=z(-1);return{typeSelectHandlers:{onKeyDown:s=>{var d;if(T(e.isDisabled))return;const a=T(e.keyboardDelegate),l=T(e.selectionManager);if(!a.getKeyForSearch)return;const c=M0(s.key);if(!c||s.ctrlKey||s.metaKey)return;c===" "&&t().trim().length>0&&(s.preventDefault(),s.stopPropagation());let u=n(h=>h+c),f=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u);f==null&&I0(u)&&(u=u[0],f=a.getKeyForSearch(u,l.focusedKey())??a.getKeyForSearch(u)),f!=null&&(l.setFocusedKey(f),(d=e.onTypeSelect)==null||d.call(e,f)),clearTimeout(r()),o(window.setTimeout(()=>n(""),500))}}}}function M0(e){return e.length===1||!/^[A-Z]/i.test(e)?e:""}function I0(e){return e.split("").every(t=>t===e[0])}function fh(e,t,n){const o=F({selectOnFocus:()=>T(e.selectionManager).selectionBehavior()==="replace"},e),i=()=>(n==null?void 0:n())??t(),{direction:s}=xn();let a={top:0,left:0};Mm(()=>T(o.isVirtualized)?void 0:i(),"scroll",()=>{const v=i();v&&(a={top:v.scrollTop,left:v.scrollLeft})});const{typeSelectHandlers:l}=E0({isDisabled:()=>T(o.disallowTypeAhead),keyboardDelegate:()=>T(o.keyboardDelegate),selectionManager:()=>T(o.selectionManager)}),c=()=>T(o.orientation)??"vertical",u=v=>{var V,$,k,N,B,ne,I,M;ee(v,l.onKeyDown),v.altKey&&v.key==="Tab"&&v.preventDefault();const m=t();if(!(m!=null&&m.contains(v.target)))return;const y=T(o.selectionManager),b=T(o.selectOnFocus),S=x=>{x!=null&&(y.setFocusedKey(x),v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&!ch(v)&&y.replaceSelection(x))},C=T(o.keyboardDelegate),R=T(o.shouldFocusWrap),D=y.focusedKey();switch(v.key){case(c()==="vertical"?"ArrowDown":"ArrowRight"):{if(C.getKeyBelow){v.preventDefault();let x;D!=null?x=C.getKeyBelow(D):x=(V=C.getFirstKey)==null?void 0:V.call(C),x==null&&R&&(x=($=C.getFirstKey)==null?void 0:$.call(C,D)),S(x)}break}case(c()==="vertical"?"ArrowUp":"ArrowLeft"):{if(C.getKeyAbove){v.preventDefault();let x;D!=null?x=C.getKeyAbove(D):x=(k=C.getLastKey)==null?void 0:k.call(C),x==null&&R&&(x=(N=C.getLastKey)==null?void 0:N.call(C,D)),S(x)}break}case(c()==="vertical"?"ArrowLeft":"ArrowUp"):{if(C.getKeyLeftOf){v.preventDefault();const x=s()==="rtl";let O;D!=null?O=C.getKeyLeftOf(D):O=x?(B=C.getFirstKey)==null?void 0:B.call(C):(ne=C.getLastKey)==null?void 0:ne.call(C),S(O)}break}case(c()==="vertical"?"ArrowRight":"ArrowDown"):{if(C.getKeyRightOf){v.preventDefault();const x=s()==="rtl";let O;D!=null?O=C.getKeyRightOf(D):O=x?(I=C.getLastKey)==null?void 0:I.call(C):(M=C.getFirstKey)==null?void 0:M.call(C),S(O)}break}case"Home":if(C.getFirstKey){v.preventDefault();const x=C.getFirstKey(D,Zn(v));x!=null&&(y.setFocusedKey(x),Zn(v)&&v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&y.replaceSelection(x))}break;case"End":if(C.getLastKey){v.preventDefault();const x=C.getLastKey(D,Zn(v));x!=null&&(y.setFocusedKey(x),Zn(v)&&v.shiftKey&&y.selectionMode()==="multiple"?y.extendSelection(x):b&&y.replaceSelection(x))}break;case"PageDown":if(C.getKeyPageBelow&&D!=null){v.preventDefault();const x=C.getKeyPageBelow(D);S(x)}break;case"PageUp":if(C.getKeyPageAbove&&D!=null){v.preventDefault();const x=C.getKeyPageAbove(D);S(x)}break;case"a":Zn(v)&&y.selectionMode()==="multiple"&&T(o.disallowSelectAll)!==!0&&(v.preventDefault(),y.selectAll());break;case"Escape":v.defaultPrevented||(v.preventDefault(),T(o.disallowEmptySelection)||y.clearSelection());break;case"Tab":if(!T(o.allowsTabNavigation)){if(v.shiftKey)m.focus();else{const x=Hm(m,{tabbable:!0});let O,P;do P=x.lastChild(),P&&(O=P);while(P);O&&!O.contains(document.activeElement)&&Fe(O)}break}}},f=v=>{var S,C;const m=T(o.selectionManager),y=T(o.keyboardDelegate),b=T(o.selectOnFocus);if(m.isFocused()){v.currentTarget.contains(v.target)||m.setFocused(!1);return}if(v.currentTarget.contains(v.target)){if(m.setFocused(!0),m.focusedKey()==null){const R=V=>{V!=null&&(m.setFocusedKey(V),b&&m.replaceSelection(V))},D=v.relatedTarget;D&&v.currentTarget.compareDocumentPosition(D)&Node.DOCUMENT_POSITION_FOLLOWING?R(m.lastSelectedKey()??((S=y.getLastKey)==null?void 0:S.call(y))):R(m.firstSelectedKey()??((C=y.getFirstKey)==null?void 0:C.call(y)))}else if(!T(o.isVirtualized)){const R=i();if(R){R.scrollTop=a.top,R.scrollLeft=a.left;const D=R.querySelector(`[data-key="${m.focusedKey()}"]`);D&&(Fe(D),Qs(R,D))}}}},d=v=>{const m=T(o.selectionManager);v.currentTarget.contains(v.relatedTarget)||m.setFocused(!1)},h=v=>{i()===v.target&&v.preventDefault()},p=()=>{var R,D;const v=T(o.autoFocus);if(!v)return;const m=T(o.selectionManager),y=T(o.keyboardDelegate);let b;v==="first"&&(b=(R=y.getFirstKey)==null?void 0:R.call(y)),v==="last"&&(b=(D=y.getLastKey)==null?void 0:D.call(y));const S=m.selectedKeys();S.size&&(b=S.values().next().value),m.setFocused(!0),m.setFocusedKey(b);const C=t();C&&b==null&&!T(o.shouldUseVirtualFocus)&&Fe(C)};return Sr(()=>{o.deferAutoFocus?setTimeout(p,0):p()}),j(Ee([i,()=>T(o.isVirtualized),()=>T(o.selectionManager).focusedKey()],v=>{var S;const[m,y,b]=v;if(y)b&&((S=o.scrollToKey)==null||S.call(o,b));else if(b&&m){const C=m.querySelector(`[data-key="${b}"]`);C&&Qs(m,C)}})),{tabIndex:L(()=>{if(!T(o.shouldUseVirtualFocus))return T(o.selectionManager).focusedKey()==null?0:-1}),onKeyDown:u,onMouseDown:h,onFocusIn:f,onFocusOut:d}}function ul(e,t){const n=()=>T(e.selectionManager),r=()=>T(e.key),o=()=>T(e.shouldUseVirtualFocus),i=y=>{n().selectionMode()!=="none"&&(n().selectionMode()==="single"?n().isSelected(r())&&!n().disallowEmptySelection()?n().toggleSelection(r()):n().replaceSelection(r()):y!=null&&y.shiftKey?n().extendSelection(r()):n().selectionBehavior()==="toggle"||Zn(y)||"pointerType"in y&&y.pointerType==="touch"?n().toggleSelection(r()):n().replaceSelection(r()))},s=()=>n().isSelected(r()),a=()=>T(e.disabled)||n().isDisabled(r()),l=()=>!a()&&n().canSelectItem(r());let c=null;const u=y=>{l()&&(c=y.pointerType,y.pointerType==="mouse"&&y.button===0&&!T(e.shouldSelectOnPressUp)&&i(y))},f=y=>{l()&&y.pointerType==="mouse"&&y.button===0&&T(e.shouldSelectOnPressUp)&&T(e.allowsDifferentPressOrigin)&&i(y)},d=y=>{l()&&(T(e.shouldSelectOnPressUp)&&!T(e.allowsDifferentPressOrigin)||c!=="mouse")&&i(y)},h=y=>{!l()||!["Enter"," "].includes(y.key)||(ch(y)?n().toggleSelection(r()):i(y))},p=y=>{a()&&y.preventDefault()},g=y=>{const b=t();o()||a()||!b||y.target===b&&n().setFocusedKey(r())},v=L(()=>{if(!(o()||a()))return r()===n().focusedKey()?0:-1}),m=L(()=>T(e.virtualized)?void 0:r());return j(Ee([t,r,o,()=>n().focusedKey(),()=>n().isFocused()],([y,b,S,C,R])=>{y&&b===C&&R&&!S&&document.activeElement!==y&&(e.focus?e.focus():Fe(y))})),{isSelected:s,isDisabled:a,allowsSelection:l,tabIndex:v,dataKey:m,onPointerDown:u,onPointerUp:f,onClick:d,onKeyDown:h,onMouseDown:p,onFocus:g}}var P0=class{constructor(e,t){Re(this,"collection");Re(this,"state");this.collection=e,this.state=t}selectionMode(){return this.state.selectionMode()}disallowEmptySelection(){return this.state.disallowEmptySelection()}selectionBehavior(){return this.state.selectionBehavior()}setSelectionBehavior(e){this.state.setSelectionBehavior(e)}isFocused(){return this.state.isFocused()}setFocused(e){this.state.setFocused(e)}focusedKey(){return this.state.focusedKey()}setFocusedKey(e){(e==null||this.collection().getItem(e))&&this.state.setFocusedKey(e)}selectedKeys(){return this.state.selectedKeys()}isSelected(e){if(this.state.selectionMode()==="none")return!1;const t=this.getKey(e);return t==null?!1:this.state.selectedKeys().has(t)}isEmpty(){return this.state.selectedKeys().size===0}isSelectAll(){if(this.isEmpty())return!1;const e=this.state.selectedKeys();return this.getAllSelectableKeys().every(t=>e.has(t))}firstSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),r=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index<e.index;(!e||r)&&(e=n)}return e==null?void 0:e.key}lastSelectedKey(){let e;for(const t of this.state.selectedKeys()){const n=this.collection().getItem(t),r=(n==null?void 0:n.index)!=null&&(e==null?void 0:e.index)!=null&&n.index>e.index;(!e||r)&&(e=n)}return e==null?void 0:e.key}extendSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=this.state.selectedKeys(),r=n.anchorKey||t,o=new Rt(n,r,t);for(const i of this.getKeyRange(r,n.currentKey||t))o.delete(i);for(const i of this.getKeyRange(t,r))this.canSelectItem(i)&&o.add(i);this.state.setSelectedKeys(o)}getKeyRange(e,t){const n=this.collection().getItem(e),r=this.collection().getItem(t);return n&&r?n.index!=null&&r.index!=null&&n.index<=r.index?this.getKeyRangeInternal(e,t):this.getKeyRangeInternal(t,e):[]}getKeyRangeInternal(e,t){const n=[];let r=e;for(;r!=null;){const o=this.collection().getItem(r);if(o&&o.type==="item"&&n.push(r),r===t)return n;r=this.collection().getKeyAfter(r)}return[]}getKey(e){const t=this.collection().getItem(e);return t?!t||t.type!=="item"?null:t.key:e}toggleSelection(e){if(this.selectionMode()==="none")return;if(this.selectionMode()==="single"&&!this.isSelected(e)){this.replaceSelection(e);return}const t=this.getKey(e);if(t==null)return;const n=new Rt(this.state.selectedKeys());n.has(t)?n.delete(t):this.canSelectItem(t)&&(n.add(t),n.anchorKey=t,n.currentKey=t),!(this.disallowEmptySelection()&&n.size===0)&&this.state.setSelectedKeys(n)}replaceSelection(e){if(this.selectionMode()==="none")return;const t=this.getKey(e);if(t==null)return;const n=this.canSelectItem(t)?new Rt([t],t,t):new Rt;this.state.setSelectedKeys(n)}setSelectedKeys(e){if(this.selectionMode()==="none")return;const t=new Rt;for(const n of e){const r=this.getKey(n);if(r!=null&&(t.add(r),this.selectionMode()==="single"))break}this.state.setSelectedKeys(t)}selectAll(){this.selectionMode()==="multiple"&&this.state.setSelectedKeys(new Set(this.getAllSelectableKeys()))}clearSelection(){const e=this.state.selectedKeys();!this.disallowEmptySelection()&&e.size>0&&this.state.setSelectedKeys(new Rt)}toggleSelectAll(){this.isSelectAll()?this.clearSelection():this.selectAll()}select(e,t){this.selectionMode()!=="none"&&(this.selectionMode()==="single"?this.isSelected(e)&&!this.disallowEmptySelection()?this.toggleSelection(e):this.replaceSelection(e):this.selectionBehavior()==="toggle"||t&&t.pointerType==="touch"?this.toggleSelection(e):this.replaceSelection(e))}isSelectionEqual(e){if(e===this.state.selectedKeys())return!0;const t=this.selectedKeys();if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;for(const n of t)if(!e.has(n))return!1;return!0}canSelectItem(e){if(this.state.selectionMode()==="none")return!1;const t=this.collection().getItem(e);return t!=null&&!t.disabled}isDisabled(e){const t=this.collection().getItem(e);return!t||t.disabled}getAllSelectableKeys(){const e=[];return(n=>{for(;n!=null;){if(this.canSelectItem(n)){const r=this.collection().getItem(n);if(!r)continue;r.type==="item"&&e.push(n)}n=this.collection().getKeyAfter(n)}})(this.collection().getFirstKey()),e}},Sc=class{constructor(e){Re(this,"keyMap",new Map);Re(this,"iterable");Re(this,"firstKey");Re(this,"lastKey");this.iterable=e;for(const r of e)this.keyMap.set(r.key,r);if(this.keyMap.size===0)return;let t,n=0;for(const[r,o]of this.keyMap)t?(t.nextKey=r,o.prevKey=t.key):(this.firstKey=r,o.prevKey=void 0),o.type==="item"&&(o.index=n++),t=o,t.nextKey=void 0;this.lastKey=t.key}*[Symbol.iterator](){yield*this.iterable}getSize(){return this.keyMap.size}getKeys(){return this.keyMap.keys()}getKeyBefore(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.prevKey}getKeyAfter(e){var t;return(t=this.keyMap.get(e))==null?void 0:t.nextKey}getFirstKey(){return this.firstKey}getLastKey(){return this.lastKey}getItem(e){return this.keyMap.get(e)}at(e){const t=[...this.getKeys()];return this.getItem(t[e])}};function cl(e){const t=C0(e),r=S0({dataSource:()=>T(e.dataSource),getKey:()=>T(e.getKey),getTextValue:()=>T(e.getTextValue),getDisabled:()=>T(e.getDisabled),getSectionChildren:()=>T(e.getSectionChildren),factory:i=>e.filter?new Sc(e.filter(i)):new Sc(i)},[()=>e.filter]),o=new P0(r,t);return pt(()=>{const i=t.focusedKey();i!=null&&!r().getItem(i)&&t.setFocusedKey(void 0)}),{collection:r,selectionManager:()=>o}}var hh=class{constructor(e,t,n){Re(this,"collection");Re(this,"ref");Re(this,"collator");this.collection=e,this.ref=t,this.collator=n}getKeyBelow(e){let t=this.collection().getKeyAfter(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyAfter(t)}}getKeyAbove(e){let t=this.collection().getKeyBefore(e);for(;t!=null;){const n=this.collection().getItem(t);if(n&&n.type==="item"&&!n.disabled)return t;t=this.collection().getKeyBefore(t)}}getFirstKey(){let e=this.collection().getFirstKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyAfter(e)}}getLastKey(){let e=this.collection().getLastKey();for(;e!=null;){const t=this.collection().getItem(e);if(t&&t.type==="item"&&!t.disabled)return e;e=this.collection().getKeyBefore(e)}}getItem(e){var t,n;return((n=(t=this.ref)==null?void 0:t.call(this))==null?void 0:n.querySelector(`[data-key="${e}"]`))??null}getKeyPageAbove(e){var i;const t=(i=this.ref)==null?void 0:i.call(this);let n=this.getItem(e);if(!t||!n)return;const r=Math.max(0,n.offsetTop+n.offsetHeight-t.offsetHeight);let o=e;for(;o&&n&&n.offsetTop>r;)o=this.getKeyAbove(o),n=o!=null?this.getItem(o):null;return o}getKeyPageBelow(e){var i;const t=(i=this.ref)==null?void 0:i.call(this);let n=this.getItem(e);if(!t||!n)return;const r=Math.min(t.scrollHeight,n.offsetTop-n.offsetHeight+t.offsetHeight);let o=e;for(;o&&n&&n.offsetTop<r;)o=this.getKeyBelow(o),n=o!=null?this.getItem(o):null;return o}getKeyForSearch(e,t){var o;const n=(o=this.collator)==null?void 0:o.call(this);if(!n)return;let r=t!=null?this.getKeyBelow(t):this.getFirstKey();for(;r!=null;){const i=this.collection().getItem(r);if(i){const s=i.textValue.slice(0,e.length);if(i.textValue&&n.compare(s,e)===0)return r}r=this.getKeyBelow(r)}}};function gh(e,t,n){const r=zf({usage:"search",sensitivity:"base"}),o=L(()=>{const i=T(e.keyboardDelegate);return i||new hh(e.collection,t,r)});return fh({selectionManager:()=>T(e.selectionManager),keyboardDelegate:o,autoFocus:()=>T(e.autoFocus),deferAutoFocus:()=>T(e.deferAutoFocus),shouldFocusWrap:()=>T(e.shouldFocusWrap),disallowEmptySelection:()=>T(e.disallowEmptySelection),selectOnFocus:()=>T(e.selectOnFocus),disallowTypeAhead:()=>T(e.disallowTypeAhead),shouldUseVirtualFocus:()=>T(e.shouldUseVirtualFocus),allowsTabNavigation:()=>T(e.allowsTabNavigation),isVirtualized:()=>T(e.isVirtualized),scrollToKey:i=>{var s;return(s=T(e.scrollToKey))==null?void 0:s(i)},orientation:()=>T(e.orientation)},t,n)}var ph=Ce();function mh(){return xe(ph)}function R0(){const e=mh();if(e===void 0)throw new Error("[kobalte]: `useDomCollectionContext` must be used within a `DomCollectionProvider` component");return e}function vh(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function O0(e,t){var o;const n=t.ref();if(!n)return-1;let r=e.length;if(!r)return-1;for(;r--;){const i=(o=e[r])==null?void 0:o.ref();if(i&&vh(i,n))return r+1}return 0}function F0(e){const t=e.map((r,o)=>[o,r]);let n=!1;return t.sort(([r,o],[i,s])=>{const a=o.ref(),l=s.ref();return a===l||!a||!l?0:vh(a,l)?(r>i&&(n=!0),-1):(r<i&&(n=!0),1)}),n?t.map(([r,o])=>o):e}function yh(e,t){const n=F0(e);e!==n&&t(n)}function $0(e){var o,i;const t=e[0],n=(o=e[e.length-1])==null?void 0:o.ref();let r=(i=t==null?void 0:t.ref())==null?void 0:i.parentElement;for(;r;){if(n&&r.contains(n))return r;r=r.parentElement}return We(r).body}function A0(e,t){j(()=>{const n=setTimeout(()=>{yh(e(),t)});Y(()=>clearTimeout(n))})}function T0(e,t){if(typeof IntersectionObserver!="function"){A0(e,t);return}let n=[];j(()=>{const r=()=>{const s=!!n.length;n=e(),s&&yh(e(),t)},o=$0(e()),i=new IntersectionObserver(r,{root:o});for(const s of e()){const a=s.ref();a&&i.observe(a)}Y(()=>i.disconnect())})}function D0(e={}){const[t,n]=xy({value:()=>T(e.items),onChange:i=>{var s;return(s=e.onItemsChange)==null?void 0:s.call(e,i)}});T0(t,n);const r=i=>(n(s=>{const a=O0(s,i);return Om(s,i,a)}),()=>{n(s=>{const a=s.filter(l=>l.ref()!==i.ref());return s.length===a.length?s:a})});return{DomCollectionProvider:i=>w(ph.Provider,{value:{registerItem:r},get children(){return i.children}})}}function L0(e){const t=R0(),n=Z({shouldRegisterItem:!0},e);j(()=>{if(!n.shouldRegisterItem)return;const r=t.registerItem(n.getItem());Y(r)})}function wh(e={}){const[t,n]=Af({value:()=>T(e.isSelected),defaultValue:()=>!!T(e.defaultIsSelected),onChange:i=>{var s;return(s=e.onSelectedChange)==null?void 0:s.call(e,i)}});return{isSelected:t,setIsSelected:i=>{!T(e.isReadOnly)&&!T(e.isDisabled)&&n(i)},toggle:()=>{!T(e.isReadOnly)&&!T(e.isDisabled)&&n(!t())}}}var bh=Ce();function Io(){return xe(bh)}function Lr(){const e=Io();if(e===void 0)throw new Error("[kobalte]: `useMenubarContext` must be used within a `Menubar` component");return e}var Sh=Ce();function dl(){return xe(Sh)}function Po(){const e=dl();if(e===void 0)throw new Error("[kobalte]: `useNavigationMenuContext` must be used within a `NavigationMenu` component");return e}var xh=Ce();function $i(){return xe(xh)}function Ut(){const e=$i();if(e===void 0)throw new Error("[kobalte]: `useMenuContext` must be used within a `Menu` component");return e}var Ch=Ce();function fl(){const e=xe(Ch);if(e===void 0)throw new Error("[kobalte]: `useMenuItemContext` must be used within a `Menu.Item` component");return e}var Eh=Ce();function At(){const e=xe(Eh);if(e===void 0)throw new Error("[kobalte]: `useMenuRootContext` must be used within a `MenuRoot` component");return e}function hl(e){let t;const n=At(),r=Ut(),o=Z({id:n.generateId(`item-${Ie()}`)},e),[i,s]=_(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=z(),[c,u]=z(),[f,d]=z(),h=()=>r.listState().selectionManager(),p=()=>s.id,g=()=>h().focusedKey()===p(),v=()=>{var $;($=i.onSelect)==null||$.call(i),i.closeOnSelect&&setTimeout(()=>{r.close(!0)})};L0({getItem:()=>{var $;return{ref:()=>t,type:"item",key:p(),textValue:i.textValue??(($=f())==null?void 0:$.textContent)??(t==null?void 0:t.textContent)??"",disabled:i.disabled??!1}}});const m=ul({key:p,selectionManager:h,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),y=$=>{ee($,i.onPointerMove),$.pointerType==="mouse"&&(i.disabled?r.onItemLeave($):(r.onItemEnter($),$.defaultPrevented||(Fe($.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(p()))))},b=$=>{ee($,i.onPointerLeave),$.pointerType==="mouse"&&r.onItemLeave($)},S=$=>{ee($,i.onPointerUp),!i.disabled&&$.button===0&&v()},C=$=>{if(ee($,i.onKeyDown),!$.repeat&&!i.disabled)switch($.key){case"Enter":case" ":v();break}},R=L(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),D=L(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":g()?"":void 0})),V={isChecked:()=>i.checked,dataset:D,setLabelRef:d,generateId:Ye(()=>s.id),registerLabel:_e(l),registerDescription:_e(u)};return w(Ch.Provider,{value:V,get children(){return w(le,F({as:"div",ref($){var k=me(N=>t=N,i.ref);typeof k=="function"&&k($)},get tabIndex(){return m.tabIndex()},get"aria-checked"(){return R()},get"aria-disabled"(){return i.disabled},get"aria-labelledby"(){return a()},get"aria-describedby"(){return c()},get"data-key"(){return m.dataKey()},get onPointerDown(){return ye([i.onPointerDown,m.onPointerDown])},get onPointerUp(){return ye([S,m.onPointerUp])},get onClick(){return ye([i.onClick,m.onClick])},get onKeyDown(){return ye([C,m.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,m.onMouseDown])},get onFocus(){return ye([i.onFocus,m.onFocus])},onPointerMove:y,onPointerLeave:b},D,s))}})}function _0(e){const t=Z({closeOnSelect:!1},e),[n,r]=_(t,["checked","defaultChecked","onChange","onSelect"]),o=wh({isSelected:()=>n.checked,defaultIsSelected:()=>n.defaultChecked,onSelectedChange:s=>{var a;return(a=n.onChange)==null?void 0:a.call(n,s)},isDisabled:()=>r.disabled});return w(hl,F({role:"menuitemcheckbox",get checked(){return o.isSelected()},onSelect:()=>{var s;(s=n.onSelect)==null||s.call(n),o.toggle()}},r))}var co={next:(e,t)=>e==="ltr"?t==="horizontal"?"ArrowRight":"ArrowDown":t==="horizontal"?"ArrowLeft":"ArrowUp",previous:(e,t)=>co.next(e==="ltr"?"rtl":"ltr",t)},xc={first:e=>e==="horizontal"?"ArrowDown":"ArrowRight",last:e=>e==="horizontal"?"ArrowUp":"ArrowLeft"};function Cc(e){const t=At(),n=Ut(),r=Io(),{direction:o}=xn(),i=Z({id:t.generateId("trigger")},e),[s,a]=_(i,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let l=()=>t.value();r!==void 0&&(l=()=>t.value()??s.id,r.lastValue()===void 0&&r.setLastValue(l));const c=Ei(()=>n.triggerRef(),()=>"button"),u=L(()=>{var m;return c()==="a"&&((m=n.triggerRef())==null?void 0:m.getAttribute("href"))!=null});j(Ee(()=>r==null?void 0:r.value(),m=>{var y;u()&&m===l()&&((y=n.triggerRef())==null||y.focus())}));const f=()=>{r!==void 0?n.isOpen()?r.value()===l()&&r.closeMenu():(r.autoFocusMenu()||r.setAutoFocusMenu(!0),n.open(!1)):n.toggle(!0)},d=m=>{ee(m,s.onPointerDown),m.currentTarget.dataset.pointerType=m.pointerType,!s.disabled&&m.pointerType!=="touch"&&m.button===0&&f()},h=m=>{ee(m,s.onClick),s.disabled||m.currentTarget.dataset.pointerType==="touch"&&f()},p=m=>{if(ee(m,s.onKeyDown),!s.disabled){if(u())switch(m.key){case"Enter":case" ":return}switch(m.key){case"Enter":case" ":case xc.first(t.orientation()):m.stopPropagation(),m.preventDefault(),Qm(m.currentTarget),n.open("first"),r==null||r.setAutoFocusMenu(!0),r==null||r.setValue(l);break;case xc.last(t.orientation()):m.stopPropagation(),m.preventDefault(),n.open("last");break;case co.next(o(),t.orientation()):if(r===void 0)break;m.stopPropagation(),m.preventDefault(),r.nextMenu();break;case co.previous(o(),t.orientation()):if(r===void 0)break;m.stopPropagation(),m.preventDefault(),r.previousMenu();break}}},g=m=>{var y;ee(m,s.onMouseOver),((y=n.triggerRef())==null?void 0:y.dataset.pointerType)!=="touch"&&!s.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(l)},v=m=>{ee(m,s.onFocus),r!==void 0&&m.currentTarget.dataset.pointerType!=="touch"&&r.setValue(l)};return j(()=>Y(n.registerTriggerId(s.id))),w(xt,F({ref(m){var y=me(n.setTriggerRef,s.ref);typeof y=="function"&&y(m)},get"data-kb-menu-value-trigger"(){return t.value()},get id(){return s.id},get disabled(){return s.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return L(()=>!!n.isOpen())()?n.contentId():void 0},get"data-highlighted"(){return l()!==void 0&&(r==null?void 0:r.value())===l()?!0:void 0},get tabIndex(){return r!==void 0?r.value()===l()||r.lastValue()===l()?0:-1:void 0},onPointerDown:d,onMouseOver:g,onClick:h,onKeyDown:p,onFocus:v,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),a))}function Mh(e){let t;const n=At(),r=Ut(),o=Io(),i=dl(),{direction:s}=xn(),a=Z({id:n.generateId(`content-${Ie()}`)},e),[l,c]=_(a,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let u=0;const f=()=>r.parentMenuContext()==null&&o===void 0&&n.isModal(),d=gh({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused(),orientation:()=>n.orientation()==="horizontal"?"vertical":"horizontal"},()=>t);Ua({trapFocus:()=>f()&&r.isOpen(),onMountAutoFocus:b=>{var S;o===void 0&&((S=l.onOpenAutoFocus)==null||S.call(l,b))},onUnmountAutoFocus:l.onCloseAutoFocus},()=>t);const h=b=>{if($e(b.currentTarget,b.target)&&(b.key==="Tab"&&r.isOpen()&&b.preventDefault(),o!==void 0&&b.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(b.key){case co.next(s(),n.orientation()):b.stopPropagation(),b.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case co.previous(s(),n.orientation()):if(b.currentTarget.hasAttribute("data-closed"))break;b.stopPropagation(),b.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},p=b=>{var S;(S=l.onEscapeKeyDown)==null||S.call(l,b),o==null||o.setAutoFocusMenu(!1),r.close(!0)},g=b=>{var S;(S=l.onFocusOutside)==null||S.call(l,b),n.isModal()&&b.preventDefault()},v=b=>{var S,C;ee(b,l.onPointerEnter),r.isOpen()&&((S=r.parentMenuContext())==null||S.listState().selectionManager().setFocused(!1),(C=r.parentMenuContext())==null||C.listState().selectionManager().setFocusedKey(void 0))},m=b=>{if(ee(b,l.onPointerMove),b.pointerType!=="mouse")return;const S=b.target,C=u!==b.clientX;$e(b.currentTarget,S)&&C&&(r.setPointerDir(b.clientX>u?"right":"left"),u=b.clientX)};j(()=>Y(r.registerContentId(l.id))),Y(()=>r.setContentRef(void 0));const y={ref:me(b=>{r.setContentRef(b),t=b},l.ref),role:"menu",get id(){return l.id},get tabIndex(){return d.tabIndex()},get"aria-labelledby"(){return r.triggerId()},onKeyDown:ye([l.onKeyDown,d.onKeyDown,h]),onMouseDown:ye([l.onMouseDown,d.onMouseDown]),onFocusIn:ye([l.onFocusIn,d.onFocusIn]),onFocusOut:ye([l.onFocusOut,d.onFocusOut]),onPointerEnter:v,onPointerMove:m,get"data-orientation"(){return n.orientation()}};return w(de,{get when(){return r.contentPresent()},get children(){return w(de,{get when(){return i===void 0||r.parentMenuContext()!=null},get fallback(){return w(le,F({as:"div"},()=>r.dataset(),y,c))},get children(){return w(Cn.Positioner,{get children(){return w(xo,F({get disableOutsidePointerEvents(){return L(()=>!!f())()&&r.isOpen()},get excludedElements(){return[r.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return ct({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},l.style)},onEscapeKeyDown:p,onFocusOutside:g,get onDismiss(){return r.close}},()=>r.dataset(),y,c))}})}})}})}function k0(e){let t;const n=At(),r=Ut(),[o,i]=_(e,["ref"]);return Ga({element:()=>t??null,enabled:()=>r.contentPresent()&&n.preventScroll()}),w(Mh,F({ref(s){var a=me(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}var Ih=Ce();function V0(){const e=xe(Ih);if(e===void 0)throw new Error("[kobalte]: `useMenuGroupContext` must be used within a `Menu.Group` component");return e}function Ph(e){const t=At(),n=Z({id:t.generateId(`group-${Ie()}`)},e),[r,o]=z(),i={generateId:Ye(()=>n.id),registerLabelId:_e(o)};return w(Ih.Provider,{value:i,get children(){return w(le,F({as:"div",role:"group",get"aria-labelledby"(){return r()}},n))}})}function N0(e){const t=V0(),n=Z({id:t.generateId("label")},e),[r,o]=_(n,["id"]);return j(()=>Y(t.registerLabelId(r.id))),w(le,F({as:"span",get id(){return r.id},"aria-hidden":"true"},o))}function Rh(e){const t=Ut(),n=Z({children:"▼"},e);return w(le,F({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}function K0(e){return w(hl,F({role:"menuitem",closeOnSelect:!0},e))}function z0(e){const t=fl(),n=Z({id:t.generateId("description")},e),[r,o]=_(n,["id"]);return j(()=>Y(t.registerDescription(r.id))),w(le,F({as:"div",get id(){return r.id}},()=>t.dataset(),o))}function B0(e){const t=fl(),n=Z({id:t.generateId("indicator")},e),[r,o]=_(n,["forceMount"]);return w(de,{get when(){return r.forceMount||t.isChecked()},get children(){return w(le,F({as:"div"},()=>t.dataset(),o))}})}function j0(e){const t=fl(),n=Z({id:t.generateId("label")},e),[r,o]=_(n,["ref","id"]);return j(()=>Y(t.registerLabel(r.id))),w(le,F({as:"div",ref(i){var s=me(t.setLabelRef,r.ref);typeof s=="function"&&s(i)},get id(){return r.id}},()=>t.dataset(),o))}function U0(e){const t=Ut();return w(de,{get when(){return t.contentPresent()},get children(){return w(mo,e)}})}var Oh=Ce();function H0(){const e=xe(Oh);if(e===void 0)throw new Error("[kobalte]: `useMenuRadioGroupContext` must be used within a `Menu.RadioGroup` component");return e}function G0(e){const n=At().generateId(`radiogroup-${Ie()}`),r=Z({id:n},e),[o,i]=_(r,["value","defaultValue","onChange","disabled"]),[s,a]=wt({value:()=>o.value,defaultValue:()=>o.defaultValue,onChange:c=>{var u;return(u=o.onChange)==null?void 0:u.call(o,c)}}),l={isDisabled:()=>o.disabled,isSelectedValue:c=>c===s(),setSelectedValue:c=>a(c)};return w(Oh.Provider,{value:l,get children(){return w(Ph,i)}})}function q0(e){const t=H0(),n=Z({closeOnSelect:!1},e),[r,o]=_(n,["value","onSelect"]);return w(hl,F({role:"menuitemradio",get checked(){return t.isSelectedValue(r.value)},onSelect:()=>{var s;(s=r.onSelect)==null||s.call(r),t.setSelectedValue(r.value)}},o))}function W0(e,t,n){const r=e.split("-")[0],o=n.getBoundingClientRect(),i=[],s=t.clientX,a=t.clientY;switch(r){case"top":i.push([s,a+5]),i.push([o.left,o.bottom]),i.push([o.left,o.top]),i.push([o.right,o.top]),i.push([o.right,o.bottom]);break;case"right":i.push([s-5,a]),i.push([o.left,o.top]),i.push([o.right,o.top]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]);break;case"bottom":i.push([s,a-5]),i.push([o.right,o.top]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]),i.push([o.left,o.top]);break;case"left":i.push([s+5,a]),i.push([o.right,o.bottom]),i.push([o.left,o.bottom]),i.push([o.left,o.top]),i.push([o.right,o.top]);break}return i}function Q0(e,t){return t?hf([e.clientX,e.clientY],t):!1}function Fh(e){const t=At(),n=mh(),r=$i(),o=Io(),i=dl(),s=Z({placement:t.orientation()==="horizontal"?"bottom-start":"right-start"},e),[a,l]=_(s,["open","defaultOpen","onOpenChange"]);let c=0,u=null,f="right";const[d,h]=z(),[p,g]=z(),[v,m]=z(),[y,b]=z(),[S,C]=z(!0),[R,D]=z(l.placement),[V,$]=z([]),[k,N]=z([]),{DomCollectionProvider:B}=D0({items:k,onItemsChange:N}),ne=Co({open:()=>a.open,defaultOpen:()=>a.defaultOpen,onOpenChange:ie=>{var Pe;return(Pe=a.onOpenChange)==null?void 0:Pe.call(a,ie)}}),{present:I}=Vn({show:()=>t.forceMount()||ne.isOpen(),element:()=>y()??null}),M=cl({selectionMode:"none",dataSource:k}),x=ie=>{C(ie),ne.open()},O=(ie=!1)=>{ne.close(),ie&&r&&r.close(!0)},P=ie=>{C(ie),ne.toggle()},A=()=>{const ie=y();ie&&(Fe(ie),M.selectionManager().setFocused(!0),M.selectionManager().setFocusedKey(void 0))},K=()=>{i!=null?setTimeout(()=>A()):A()},H=ie=>{$(Te=>[...Te,ie]);const Pe=r==null?void 0:r.registerNestedMenu(ie);return()=>{$(Te=>Ws(Te,ie)),Pe==null||Pe()}},q=ie=>f===(u==null?void 0:u.side)&&Q0(ie,u==null?void 0:u.area),oe=ie=>{q(ie)&&ie.preventDefault()},J=ie=>{q(ie)||K()},fe=ie=>{q(ie)&&ie.preventDefault()};Ha({isDisabled:()=>!(r==null&&ne.isOpen()&&t.isModal()),targets:()=>[y(),...V()].filter(Boolean)}),j(()=>{const ie=y();if(!ie||!r)return;const Pe=r.registerNestedMenu(ie);Y(()=>{Pe()})}),j(()=>{r===void 0&&(o==null||o.registerMenu(t.value(),[y(),...V()]))}),j(()=>{var ie;r!==void 0||o===void 0||(o.value()===t.value()?((ie=v())==null||ie.focus(),o.autoFocusMenu()&&x(!0)):O())}),j(()=>{r!==void 0||o===void 0||ne.isOpen()&&o.setValue(t.value())}),Y(()=>{r===void 0&&(o==null||o.unregisterMenu(t.value()))});const Je={dataset:L(()=>({"data-expanded":ne.isOpen()?"":void 0,"data-closed":ne.isOpen()?void 0:""})),isOpen:ne.isOpen,contentPresent:I,nestedMenus:V,currentPlacement:R,pointerGraceTimeoutId:()=>c,autoFocus:S,listState:()=>M,parentMenuContext:()=>r,triggerRef:v,contentRef:y,triggerId:d,contentId:p,setTriggerRef:m,setContentRef:b,open:x,close:O,toggle:P,focusContent:K,onItemEnter:oe,onItemLeave:J,onTriggerLeave:fe,setPointerDir:ie=>f=ie,setPointerGraceTimeoutId:ie=>c=ie,setPointerGraceIntent:ie=>u=ie,registerNestedMenu:H,registerItemToParentDomCollection:n==null?void 0:n.registerItem,registerTriggerId:_e(h),registerContentId:_e(g)};return w(B,{get children(){return w(xh.Provider,{value:Je,get children(){return w(de,{when:i===void 0,get fallback(){return l.children},get children(){return w(Cn,F({anchorRef:v,contentRef:y,onCurrentPlacementChange:D},l))}})}})}})}function X0(e){const{direction:t}=xn();return w(Fh,F({get placement(){return t()==="rtl"?"left-start":"right-start"},flip:!0},e))}var Y0={close:(e,t)=>e==="ltr"?[t==="horizontal"?"ArrowLeft":"ArrowUp"]:[t==="horizontal"?"ArrowRight":"ArrowDown"]};function J0(e){const t=Ut(),n=At(),[r,o]=_(e,["onFocusOutside","onKeyDown"]),{direction:i}=xn();return w(Mh,F({onOpenAutoFocus:u=>{u.preventDefault()},onCloseAutoFocus:u=>{u.preventDefault()},onFocusOutside:u=>{var d;(d=r.onFocusOutside)==null||d.call(r,u);const f=u.target;$e(t.triggerRef(),f)||t.close()},onKeyDown:u=>{ee(u,r.onKeyDown);const f=$e(u.currentTarget,u.target),d=Y0.close(i(),n.orientation()).includes(u.key),h=t.parentMenuContext()!=null;f&&d&&h&&(t.close(),Fe(t.triggerRef()))}},o))}var Ec=["Enter"," "],Z0={open:(e,t)=>e==="ltr"?[...Ec,t==="horizontal"?"ArrowRight":"ArrowDown"]:[...Ec,t==="horizontal"?"ArrowLeft":"ArrowUp"]};function eS(e){let t;const n=At(),r=Ut(),o=Z({id:n.generateId(`sub-trigger-${Ie()}`)},e),[i,s]=_(o,["ref","id","textValue","disabled","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]);let a=null;const l=()=>{a&&window.clearTimeout(a),a=null},{direction:c}=xn(),u=()=>i.id,f=()=>{const b=r.parentMenuContext();if(b==null)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");return b.listState().selectionManager()},d=()=>r.listState().collection(),h=()=>f().focusedKey()===u(),p=ul({key:u,selectionManager:f,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),g=b=>{ee(b,i.onClick),!r.isOpen()&&!i.disabled&&r.open(!0)},v=b=>{var C;if(ee(b,i.onPointerMove),b.pointerType!=="mouse")return;const S=r.parentMenuContext();if(S==null||S.onItemEnter(b),!b.defaultPrevented){if(i.disabled){S==null||S.onItemLeave(b);return}!r.isOpen()&&!a&&((C=r.parentMenuContext())==null||C.setPointerGraceIntent(null),a=window.setTimeout(()=>{r.open(!1),l()},100)),S==null||S.onItemEnter(b),b.defaultPrevented||(r.listState().selectionManager().isFocused()&&(r.listState().selectionManager().setFocused(!1),r.listState().selectionManager().setFocusedKey(void 0)),Fe(b.currentTarget),S==null||S.listState().selectionManager().setFocused(!0),S==null||S.listState().selectionManager().setFocusedKey(u()))}},m=b=>{if(ee(b,i.onPointerLeave),b.pointerType!=="mouse")return;l();const S=r.parentMenuContext(),C=r.contentRef();if(C){S==null||S.setPointerGraceIntent({area:W0(r.currentPlacement(),b,C),side:r.currentPlacement().split("-")[0]}),window.clearTimeout(S==null?void 0:S.pointerGraceTimeoutId());const R=window.setTimeout(()=>{S==null||S.setPointerGraceIntent(null)},300);S==null||S.setPointerGraceTimeoutId(R)}else{if(S==null||S.onTriggerLeave(b),b.defaultPrevented)return;S==null||S.setPointerGraceIntent(null)}S==null||S.onItemLeave(b)},y=b=>{ee(b,i.onKeyDown),!b.repeat&&(i.disabled||Z0.open(c(),n.orientation()).includes(b.key)&&(b.stopPropagation(),b.preventDefault(),f().setFocused(!1),f().setFocusedKey(void 0),r.isOpen()||r.open("first"),r.focusContent(),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(d().getFirstKey())))};return j(()=>{if(r.registerItemToParentDomCollection==null)throw new Error("[kobalte]: `Menu.SubTrigger` must be used within a `Menu.Sub` component");const b=r.registerItemToParentDomCollection({ref:()=>t,type:"item",key:u(),textValue:i.textValue??(t==null?void 0:t.textContent)??"",disabled:i.disabled??!1});Y(b)}),j(Ee(()=>{var b;return(b=r.parentMenuContext())==null?void 0:b.pointerGraceTimeoutId()},b=>{Y(()=>{var S;window.clearTimeout(b),(S=r.parentMenuContext())==null||S.setPointerGraceIntent(null)})})),j(()=>Y(r.registerTriggerId(i.id))),Y(()=>{l()}),w(le,F({as:"div",ref(b){var S=me(C=>{r.setTriggerRef(C),t=C},i.ref);typeof S=="function"&&S(b)},get id(){return i.id},role:"menuitem",get tabIndex(){return p.tabIndex()},"aria-haspopup":"true",get"aria-expanded"(){return r.isOpen()},get"aria-controls"(){return L(()=>!!r.isOpen())()?r.contentId():void 0},get"aria-disabled"(){return i.disabled},get"data-key"(){return p.dataKey()},get"data-highlighted"(){return h()?"":void 0},get"data-disabled"(){return i.disabled?"":void 0},get onPointerDown(){return ye([i.onPointerDown,p.onPointerDown])},get onPointerUp(){return ye([i.onPointerUp,p.onPointerUp])},get onClick(){return ye([g,p.onClick])},get onKeyDown(){return ye([y,p.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,p.onMouseDown])},get onFocus(){return ye([i.onFocus,p.onFocus])},onPointerMove:v,onPointerLeave:m},()=>r.dataset(),s))}function tS(e){const t=Io(),n=`menu-${Ie()}`,r=Z({id:n,modal:!0},e),[o,i]=_(r,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value","orientation"]),s=Co({open:()=>o.open,defaultOpen:()=>o.defaultOpen,onOpenChange:l=>{var c;return(c=o.onOpenChange)==null?void 0:c.call(o,l)}}),a={isModal:()=>o.modal??!0,preventScroll:()=>o.preventScroll??a.isModal(),forceMount:()=>o.forceMount??!1,generateId:Ye(()=>o.id),value:()=>o.value,orientation:()=>o.orientation??(t==null?void 0:t.orientation())??"horizontal"};return w(Eh.Provider,{value:a,get children(){return w(Fh,F({get open(){return s.isOpen()},get onOpenChange(){return s.setIsOpen}},i))}})}function $h(e){const t=Lr(),n=Z({modal:!1},e),[r,o]=_(n,["value"]),i=Ie(),s=t.generateId(`menubar-menu-${i}`),a=Z({id:s},o);return w(tS,F({get value(){return r.value??i}},a))}function nS(e){let t;const n=`menubar-${Ie()}`,r=Z({id:n,loop:!0,orientation:"horizontal"},e),[o,i]=_(r,["ref","value","defaultValue","onValueChange","loop","focusOnAlt","autoFocusMenu","onAutoFocusMenuChange","orientation"]),[s,a]=wt({value:()=>o.value,defaultValue:()=>o.defaultValue,onChange:y=>{var b;return(b=o.onValueChange)==null?void 0:b.call(o,y)}}),[l,c]=z(),[u,f]=z(new Map),[d,h]=wt({value:()=>o.autoFocusMenu,defaultValue:()=>!1,onChange:o.onAutoFocusMenuChange}),p=()=>{var y;return s()&&d()&&!((y=s())!=null&&y.includes("link-trigger-"))},v={dataset:L(()=>({"data-expanded":p()?"":void 0,"data-closed":p()?void 0:""})),value:s,setValue:a,lastValue:l,setLastValue:c,menus:()=>new Set([...u().keys()]),menuRefs:()=>[...u().values()].flat(),menuRefMap:()=>u(),registerMenu:(y,b)=>{f(S=>{const C=new Map;return S.forEach((R,D)=>C.set(D,R)),C.set(y,b),C})},unregisterMenu:y=>{f(b=>{b.delete(y);const S=new Map;return b.forEach((C,R)=>S.set(R,C)),S})},nextMenu:()=>{const y=[...u().keys()];if(s()==null){a(y[0]);return}const b=y.indexOf(s());if(b===y.length-1){o.loop&&a(y[0]);return}a(y[b+1])},previousMenu:()=>{const y=[...u().keys()];if(s()==null){a(y[0]);return}const b=y.indexOf(s());if(b===0){o.loop&&a(y[y.length-1]);return}a(y[b-1])},closeMenu:()=>{h(!1),a(void 0)},autoFocusMenu:()=>d(),setAutoFocusMenu:h,generateId:Ye(()=>i.id),orientation:()=>o.orientation};j(()=>{s()==null&&h(!1)}),Ff({onInteractOutside:()=>{v.closeMenu(),setTimeout(()=>v.closeMenu())},shouldExcludeElement:y=>[t,...u().values()].flat().some(b=>$e(b,y))},()=>t);const m=y=>{y.key==="Alt"&&(y.preventDefault(),y.stopPropagation(),v.value()===void 0?v.nextMenu():v.closeMenu())};return j(()=>{o.focusOnAlt?window.addEventListener("keydown",m):window.removeEventListener("keydown",m),Y(()=>{window.removeEventListener("keydown",m)})}),j(()=>{s()!=null&&c(s())}),w(bh.Provider,{value:v,get children(){return w(le,F({as:"div",ref(y){var b=me(S=>t=S,o.ref);typeof b=="function"&&b(y)},role:"menubar",get"data-orientation"(){return o.orientation},get"aria-orientation"(){return o.orientation}},i))}})}function rS(e){const t=Lr();if($i()===void 0&&Object.hasOwn(e,"href")){const r=t.generateId("link-trigger-")+Ie();return w($h,{value:r,get children(){return w(Cc,e)}})}return Cc(e)}var oS={};dt(oS,{Root:()=>gl,Separator:()=>iS});function gl(e){let t;const n=Z({orientation:"horizontal"},e),[r,o]=_(n,["ref","orientation"]),i=Ei(()=>t,()=>"hr");return w(le,F({as:"hr",ref(s){var a=me(l=>t=l,r.ref);typeof a=="function"&&a(s)},get role(){return i()!=="hr"?"separator":void 0},get"aria-orientation"(){return r.orientation==="vertical"?"vertical":void 0},get"data-orientation"(){return r.orientation}},o))}var iS=gl,Ah=te("<li role=presentation>"),sS=te("<nav>");function aS(e){let t;const n=Lr(),r=Z({size:15},e),[o,i]=_(r,["ref"]),[s,a]=z(0),l=()=>n.orientation()==="horizontal";return j(Ee(n.value,c=>{setTimeout(()=>{if(!c||c.includes("link-trigger-"))return;const u=document.querySelector(`[data-kb-menu-value-trigger="${c}"]`);if(!u||!t)return;const f=u.getBoundingClientRect()[l()?"x":"y"]+u.getBoundingClientRect()[l()?"width":"height"]/2,d=window.getComputedStyle(t),h=t.getBoundingClientRect()[l()?"x":"y"]+t.getBoundingClientRect()[l()?"width":"height"]/2-Number.parseFloat(d.transform.split(",")[l()?4:5]);a(f-h)})})),w(Dr,F({ref(c){var u=me(f=>t=f,o.ref);typeof u=="function"&&u(c)},get style(){return{transform:`translate${l()?"X":"Y"}(${s()}px)`,color:"red"}}},i))}function Th(e){const t=Po(),n=Lr(),r=At(),[o,i]=z(),[s,a]=_(e,["onPointerEnter","onPointerLeave"]),l=u=>{ee(u,s.onPointerEnter),t.cancelLeaveTimer()},c=u=>{ee(u,s.onPointerLeave),t.startLeaveTimer()};return j(Ee(n.value,u=>{bi(()=>{if(!u||u.includes("link-trigger-")){t.setPreviousMenu(void 0);return}if(u===r.value()){if(t.previousMenu()!=null){const p=[...n.menus()],g=p.indexOf(t.previousMenu()),v=p.indexOf(u);g<v?i("from-end"):i("from-start")}else i(void 0);t.setPreviousMenu(u);return}const f=[...n.menus()],d=f.indexOf(t.previousMenu()),h=f.indexOf(u);d>h?i("to-end"):i("to-start")})})),w(k0,F({as:"ul",onPointerEnter:l,onPointerLeave:c,onInteractOutside:()=>{t.setAutoFocusMenu(!1)},get"data-motion"(){return o()}},a))}function Dh(e){return(()=>{var t=Ah();return W(t,w(K0,F({as:"a"},e))),t})()}function Lh(e){const t=Lr(),n=Po(),[r,o]=_(e,["value"]),i=Ie(),s=t.generateId(`navigation-menu-menu-${i}`),a=Z({id:s},o),l=()=>r.value??i,[c,u]=z(!1),f=()=>{var d,h;t.value()!==l()&&u(!1),(d=n.viewportRef())==null||d.removeEventListener("animationend",f),(h=n.viewportRef())==null||h.removeEventListener("animationcancel",f)};return j(Ee(t.value,d=>{if(d===l())u(!0);else{const h=n.viewportRef();if(!h||["","none"].includes(window.getComputedStyle(h).animationName)){u(!1);return}h.addEventListener("animationend",f)}})),w($h,F({get forceMount(){return c()},get value(){return l()}},a))}function _h(e){const t=Po(),n=Ut(),[r,o]=_(e,["ref"]);return w(de,{get when(){return t.viewportPresent()},get children(){return w(U0,F({ref(i){var s=me(a=>{a&&a.setAttribute("role","presentation")},r.ref);typeof s=="function"&&s(i)},get mount(){return L(()=>n.parentMenuContext()==null)()?t.viewportRef():void 0}},o))}})}function kh(e){const t=Z({delayDuration:200,skipDelayDuration:300},e),[n,r,o]=_(t,["ref","delayDuration","skipDelayDuration","autoFocusMenu","onAutoFocusMenuChange","defaultValue","value","onValueChange","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"]),[i,s]=wt({value:()=>n.value,defaultValue:()=>n.defaultValue,onChange:$=>{var k;return(k=n.onValueChange)==null?void 0:k.call(n,$)}}),[a,l]=wt({value:()=>n.autoFocusMenu,defaultValue:()=>!1,onChange:n.onAutoFocusMenuChange}),[c,u]=z(),[f,d]=z(),[h,p]=z(r.placement??o.orientation==="vertical"?"right":"bottom");j(()=>{p(o.orientation==="vertical"?"right":"bottom")});let g;const[v,m]=z(),[y,b]=z(!1),[S,C]=z(!1);j(()=>{i()&&!i().includes("link-trigger-")&&a()?bi(()=>{C(!0),b(!0)}):(C(!1),b(!1))});const R=L(()=>({"data-expanded":S()?"":void 0,"data-closed":S()?void 0:""})),{present:D}=Vn({show:()=>n.forceMount||y()||S(),element:()=>c()??null});j(()=>{D()||V.setPreviousMenu(void 0)});const V={dataset:R,delayDuration:()=>n.delayDuration,skipDelayDuration:()=>n.skipDelayDuration,autoFocusMenu:a,setAutoFocusMenu:l,startLeaveTimer:()=>{g=window.setTimeout(()=>{V.setAutoFocusMenu(!1),s(void 0)},V.skipDelayDuration())},cancelLeaveTimer:()=>{g&&clearTimeout(g)},rootRef:f,setRootRef:d,viewportRef:c,setViewportRef:u,viewportPresent:D,currentPlacement:h,previousMenu:v,setPreviousMenu:m};return w(Sh.Provider,{value:V,get children(){return w(Cn,F({anchorRef:f,contentRef:c,get placement(){return h()},onCurrentPlacementChange:p},r,{get children(){var $=sS();return W($,w(nS,F({as:"ul",ref(k){var N=me(V.setRootRef,n.ref);typeof N=="function"&&N(k)},get value(){return i()??null},onValueChange:s,get autoFocusMenu(){return a()},onAutoFocusMenuChange:l},o))),$}}))}})}function Vh(e){const t=Po(),n=$i(),[r,o]=_(e,["onPointerEnter","onPointerLeave","onClick"]);let i;const s=c=>{ee(c,r.onClick),i&&clearTimeout(i)},a=c=>{ee(c,r.onPointerEnter),c.pointerType!=="touch"&&(t.cancelLeaveTimer(),t.dataset()["data-expanded"]!==""&&(i=window.setTimeout(()=>{var u;(u=n==null?void 0:n.triggerRef())==null||u.focus(),setTimeout(()=>{t.setAutoFocusMenu(!0)})},t.delayDuration())))},l=c=>{ee(c,r.onPointerLeave),c.pointerType!=="touch"&&(t.startLeaveTimer(),i&&clearTimeout(i))};return(()=>{var c=Ah();return W(c,w(rS,F({onClick:s,onPointerEnter:a,onPointerLeave:l},o))),c})()}function Nh(e){const t=Po(),n=Lr(),[r,o]=z(),[i,s]=_(e,["ref","style","onEscapeKeyDown"]),a=()=>{n.setAutoFocusMenu(!1),n.closeMenu()},l=d=>{a()},c=b0(r);j(Ee(()=>n.value()?n.menuRefMap().get(n.value()):void 0,d=>{d===void 0||d[0]===void 0||o(d[0])}));const u=L(d=>{if(!(r()===void 0||!t.viewportPresent()))return c.height()===0?d:c.height()}),f=L(d=>{if(!(r()===void 0||!t.viewportPresent()))return c.width()===0?d:c.width()});return w(de,{get when(){return t.viewportPresent()},get children(){return w(Cn.Positioner,{role:"presentation",get children(){return w(xo,F({as:"li",ref(d){var h=me(t.setViewportRef,i.ref);typeof h=="function"&&h(d)},get excludedElements(){return[t.rootRef]},bypassTopMostLayerCheck:!0,get style(){return ct({"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)","--kb-navigation-menu-viewport-height":u()?`${u()}px`:void 0,"--kb-navigation-menu-viewport-width":f()?`${f()}px`:void 0,position:"relative"},i.style)},get onEscapeKeyDown(){return ye([i.onEscapeKeyDown,l])},onDismiss:a,get"data-orientation"(){return n.orientation()}},()=>t.dataset(),s))}})}})}Object.assign(kh,{Arrow:aS,CheckboxItem:_0,Content:Th,Group:Ph,GroupLabel:N0,Icon:Rh,Item:Dh,ItemDescription:z0,ItemIndicator:B0,ItemLabel:j0,Portal:_h,RadioGroup:G0,RadioItem:q0,Menu:Lh,Separator:gl,Sub:X0,SubContent:J0,SubTrigger:eS,Trigger:Vh,Viewport:Nh});var lS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class="relative top-px ml-1 size-3 transition duration-200 group-data-[expanded]/trigger:rotate-180 group-data-[orientation=vertical]/menu:-rotate-90 group-data-[orientation=vertical]/menu:group-data-[expanded]/trigger:rotate-90"><path d="M6 9l6 6l6 -6">');const Mc=Lh,Ic=e=>{const[t,n]=_(e,["class","children"]);return w(kh,F({gutter:6,get class(){return ce("group/menu flex w-max flex-1 list-none items-center justify-center data-[orientation=vertical]:flex-col [&>li]:w-full",t.class)}},n,{get children(){return[L(()=>t.children),w(uS,{})]}}))},Pc=e=>{const[t,n]=_(e,["class"]);return w(Vh,F({get class(){return ce("group/trigger inline-flex h-10 w-full items-center justify-center whitespace-nowrap rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[expanded]:bg-accent/50",t.class)}},n))},Rc=()=>w(Rh,{"aria-hidden":"true",get children(){return lS()}}),uS=e=>{const[t,n]=_(e,["class"]);return w(Nh,F({get class(){return ce("pointer-events-none z-[1000] flex h-[var(--kb-navigation-menu-viewport-height)] w-[var(--kb-navigation-menu-viewport-width)] origin-[var(--kb-menu-content-transform-origin)] items-center justify-center overflow-x-clip overflow-y-visible rounded-md border bg-popover opacity-0 shadow-lg data-[expanded]:pointer-events-auto data-[orientation=vertical]:overflow-y-clip data-[orientation=vertical]:overflow-x-visible data-[expanded]:rounded-md","animate-content-hide transition-[width,height] duration-200 ease-in data-[expanded]:animate-content-show data-[expanded]:opacity-100 data-[expanded]:ease-out",t.class)}},n))},Oc=e=>{const[t,n]=_(e,["class"]);return w(_h,{get children(){return w(Th,F({get class(){return ce("pointer-events-none absolute left-0 top-0 box-border p-1 focus:outline-none data-[expanded]:pointer-events-auto","data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out","data-[orientation=horizontal]:data-[motion=from-start]:slide-in-from-left-52 data-[orientation=horizontal]:data-[motion=to-end]:slide-out-to-right-52","data-[orientation=horizontal]:data-[motion=from-end]:slide-in-from-right-52 data-[orientation=horizontal]:data-[motion=to-start]:slide-out-to-left-52","data-[orientation=vertical]:data-[motion=from-start]:slide-in-from-top-52 data-[orientation=vertical]:data-[motion=to-end]:slide-out-to-bottom-52","data-[orientation=vertical]:data-[motion=from-end]:slide-in-from-bottom-52 data-[orientation=vertical]:data-[motion=to-start]:slide-out-to-bottom-52",t.class)}},n))}})},Fc=e=>{const[t,n]=_(e,["class"]);return w(Dh,F({get class(){return ce("text-sm block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t.class)}},n))};var Ai=te("<li>"),cS=te("<ul>"),dS={};dt(dS,{Ellipsis:()=>pl,Item:()=>ml,Items:()=>vl,Next:()=>yl,Pagination:()=>fS,Previous:()=>wl,Root:()=>bl,usePaginationContext:()=>Ro});function pl(e){return(()=>{var t=Ai();return W(t,w(le,F({as:"div"},e))),t})()}var Kh=Ce();function Ro(){const e=xe(Kh);if(e===void 0)throw new Error("[kobalte]: `usePaginationContext` must be used within a `Pagination` component");return e}function ml(e){const t=Ro(),[n,r]=_(e,["page","onClick"]),o=()=>t.page()===n.page,i=()=>{t.setPage(n.page)};return(()=>{var s=Ai();return W(s,w(xt,F({get"aria-current"(){return o()?"page":void 0},get"data-current"(){return o()?"":void 0},get onClick(){return ye([n.onClick,i])}},r))),s})()}function vl(e){const t=Ro(),n=L(()=>{const{count:r,siblingCount:o,page:i,fixedItems:s,showFirst:a,showLast:l}=t,c=r()<2*o()+(s()?6:4);if(c)return{renderItemsDirectly:c};const u=a()&&i()-1>o(),f=l()&&r()-i()>o();let d=i()-(a()?2:1)>o(),h=r()-i()-(l()?1:0)>o(),p=Math.min(i()-1,o()),g=Math.min(r()-i(),o());if(s()!==!1){const v=p,m=g;p+=Math.max(o()-m,0),g+=Math.max(o()-v,0),u||g++,f||p++,s()===!0&&(d||g++,h||p++),i()-p-(a()?2:1)===1&&(d=!1,p++),r()-i()-g-(l()?1:0)===1&&(h=!1,g++)}return{showFirst:u,showLast:f,showFirstEllipsis:d,showLastEllipsis:h,previousSiblingCount:p,nextSiblingCount:g,renderItemsDirectly:c}});return w(de,{get when(){return n().renderItemsDirectly},get fallback(){return[w(de,{get when(){return n().showFirst},get children(){return t.renderItem(1)}}),w(de,{get when(){return n().showFirstEllipsis},get children(){return t.renderEllipsis()}}),w(et,{get each(){return[...Array(n().previousSiblingCount).keys()].reverse()},children:r=>L(()=>t.renderItem(t.page()-(r+1)))}),L(()=>t.renderItem(t.page())),w(et,{get each(){return[...Array(n().nextSiblingCount).keys()]},children:r=>L(()=>t.renderItem(t.page()+(r+1)))}),w(de,{get when(){return n().showLastEllipsis},get children(){return t.renderEllipsis()}}),w(de,{get when(){return n().showLast},get children(){return t.renderItem(t.count())}})]},get children(){return w(et,{get each(){return[...Array(t.count()).keys()]},children:r=>L(()=>t.renderItem(r+1))})}})}function yl(e){const t=Ro(),[n,r]=_(e,["onClick"]),o=()=>{t.setPage(t.page()+1)},i=()=>t.page()===t.count();return(()=>{var s=Ai();return W(s,w(xt,F({get tabIndex(){return i()||t.page()===t.count()?-1:void 0},get disabled(){return i()},get"aria-disabled"(){return i()||void 0},get"data-disabled"(){return i()?"":void 0},get onClick(){return ye([n.onClick,o])}},r))),s})()}function wl(e){const t=Ro(),[n,r]=_(e,["onClick"]),o=()=>{t.setPage(t.page()-1)},i=()=>t.page()===1;return(()=>{var s=Ai();return W(s,w(xt,F({get tabIndex(){return i()||t.page()===1?-1:void 0},get disabled(){return i()},get"aria-disabled"(){return i()||void 0},get"data-disabled"(){return i()?"":void 0},get onClick(){return ye([n.onClick,o])}},r))),s})()}function bl(e){const t=`pagination-${Ie()}`,n=Z({id:t},e),[r,o]=_(n,["page","defaultPage","onPageChange","count","siblingCount","showFirst","showLast","fixedItems","itemComponent","ellipsisComponent","disabled","children"]),i=wt({defaultValue:()=>r.defaultPage??1,onChange:r.onPageChange,value:()=>r.page}),s={count:()=>r.count,siblingCount:()=>r.siblingCount??1,showFirst:()=>r.showFirst??!0,showLast:()=>r.showLast??!0,fixedItems:()=>r.fixedItems??!1,isDisabled:()=>r.disabled??!1,renderItem:a=>r.itemComponent({page:a}),renderEllipsis:r.ellipsisComponent,page:()=>Math.min(i[0]()??1,r.count),setPage:i[1]};return w(Kh.Provider,{value:s,get children(){return w(le,F({as:"nav",get"data-disabled"(){return r.disabled?"":void 0}},o,{get children(){var a=cS();return W(a,()=>r.children),a}}))}})}var fS=Object.assign(bl,{Ellipsis:pl,Item:ml,Items:vl,Next:yl,Previous:wl});const Ti=Mr("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-10"}},defaultVariants:{variant:"default",size:"default"}}),fn=e=>{const[t,n]=_(e,["variant","size","class"]);return w(xt,F({get class(){return ce(Ti({variant:t.variant,size:t.size}),t.class)}},n))};var hS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><circle cx=12 cy=12 r=1></circle><circle cx=19 cy=12 r=1></circle><circle cx=5 cy=12 r=1>'),gS=te("<span class=sr-only>More pages"),pS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M15 6l-6 6l6 6">'),mS=te("<span>Previous"),vS=te("<span>Next"),yS=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M9 6l6 6l-6 6">');const wS=vl,bS=e=>{const[t,n]=_(e,["class"]);return w(bl,F({get class(){return ce("[&>*]:flex [&>*]:flex-row [&>*]:items-center [&>*]:gap-1",t.class)}},n))},SS=e=>{const[t,n]=_(e,["class"]);return w(ml,F({get class(){return ce(Ti({variant:"ghost"}),"size-10 data-[current]:border",t.class)}},n))},xS=e=>{const[t,n]=_(e,["class"]);return w(pl,F({get class(){return ce("flex size-10 items-center justify-center",t.class)}},n,{get children(){return[hS(),gS()]}}))},CS=e=>{const[t,n]=_(e,["class","children"]);return w(wl,F({get class(){return ce(Ti({variant:"ghost"}),"gap-1 pl-2.5",t.class)}},n,{get children(){return t.children??[pS(),mS()]}}))},ES=e=>{const[t,n]=_(e,["class","children"]);return w(yl,F({get class(){return ce(Ti({variant:"ghost"}),"gap-1 pl-2.5",t.class)}},n,{get children(){return t.children??[vS(),yS()]}}))};var MS=te('<div class="relative w-full overflow-auto"><table>'),IS=te("<thead>"),PS=te("<tbody>"),RS=te("<tr>"),OS=te("<th>"),FS=te("<td>");const $S=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=MS(),o=r.firstChild;return qe(o,F({get class(){return ce("w-full caption-bottom text-sm",t.class)}},n),!1,!1),r})()},AS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=IS();return qe(r,F({get class(){return ce("[&_tr]:border-b",t.class)}},n),!1,!1),r})()},TS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=PS();return qe(r,F({get class(){return ce(t.class)}},n),!1,!1),r})()},is=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=RS();return qe(r,F({get class(){return ce("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t.class)}},n),!1,!1),r})()},DS=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=OS();return qe(r,F({get class(){return ce("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t.class)}},n),!1,!1),r})()},$c=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=FS();return qe(r,F({get class(){return ce("p-4 align-middle [&:has([role=checkbox])]:pr-0",t.class)}},n),!1,!1),r})()};var LS=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith("__Secure-")&&!n.secure)throw new Error("__Secure- Cookie must have Secure attributes");if(e.startsWith("__Host-")){if(!n.secure)throw new Error("__Host- Cookie must have Secure attributes");if(n.path!=="/")throw new Error('__Host- Cookie must have Path attributes with "/"');if(n.domain)throw new Error("__Host- Cookie must not have Domain attributes")}if(n&&typeof n.maxAge=="number"&&n.maxAge>=0){if(n.maxAge>3456e4)throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");r+=`; Max-Age=${Math.floor(n.maxAge)}`}if(n.domain&&n.prefix!=="host"&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.partitioned){if(!n.secure)throw new Error("Partitioned Cookie must have Secure attributes");r+="; Partitioned"}return r},_S=(e,t,n)=>(t=encodeURIComponent(t),LS(e,t,n)),kS=(e,t)=>(e=e.replace(/\/+$/,""),e=e+"/",t=t.replace(/^\/+/,""),e+t),ca=(e,t)=>{for(const[n,r]of Object.entries(t)){const o=new RegExp("/:"+n+"(?:{[^/]+})?\\??");e=e.replace(o,r?`/${r}`:"")}return e},VS=(e,t)=>{switch(t){case"ws":return e.replace(/^http/,"ws");case"http":return e.replace(/^ws/,"http")}},NS=e=>/^https?:\/\/[^\/]+?\/index$/.test(e)?e.replace(/\/index$/,"/"):e.replace(/\/index$/,"");function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zh(e,t){if(!Uo(e)&&!Uo(t))return t;const n={...e};for(const r in t){const o=t[r];Uo(n[r])&&Uo(o)?n[r]=zh(n[r],o):n[r]=o}return n}var Bh=(e,t)=>new Proxy(()=>{},{get(r,o){if(!(typeof o!="string"||o==="then"))return Bh(e,[...t,o])},apply(r,o,i){return e({path:t,args:i})}}),KS=class{constructor(e,t){Re(this,"url");Re(this,"method");Re(this,"queryParams");Re(this,"pathParams",{});Re(this,"rBody");Re(this,"cType");Re(this,"fetch",async(e,t)=>{if(e){if(e.query){for(const[a,l]of Object.entries(e.query))if(l!==void 0)if(this.queryParams||(this.queryParams=new URLSearchParams),Array.isArray(l))for(const c of l)this.queryParams.append(a,c);else this.queryParams.set(a,l)}if(e.form){const a=new FormData;for(const[l,c]of Object.entries(e.form))if(Array.isArray(c))for(const u of c)a.append(l,u);else a.append(l,c);this.rBody=a}e.json&&(this.rBody=JSON.stringify(e.json),this.cType="application/json"),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase();const r={...(e==null?void 0:e.header)??{},...typeof(t==null?void 0:t.headers)=="function"?await t.headers():t!=null&&t.headers?t.headers:{}};if(e!=null&&e.cookie){const a=[];for(const[l,c]of Object.entries(e.cookie))a.push(_S(l,c,{path:"/"}));r.Cookie=a.join(",")}this.cType&&(r["Content-Type"]=this.cType);const o=new Headers(r??void 0);let i=this.url;i=NS(i),i=ca(i,this.pathParams),this.queryParams&&(i=i+"?"+this.queryParams.toString()),n=this.method.toUpperCase();const s=!(n==="GET"||n==="HEAD");return((t==null?void 0:t.fetch)||fetch)(i,{body:s?this.rBody:void 0,method:n,headers:o,...t==null?void 0:t.init})});this.url=e,this.method=t}},zS=(e,t)=>Bh(function n(r){var c;const o=[...r.path];if(o[o.length-1]==="toString")return o[o.length-2]==="name"?o[o.length-3]||"":n.toString();if(o[o.length-1]==="valueOf")return o[o.length-2]==="name"?o[o.length-3]||"":n;let i="";if(/^\$/.test(o[o.length-1])){const u=o.pop();u&&(i=u.replace(/^\$/,""))}const s=o.join("/"),a=kS(e,s);if(i==="url")return r.args[0]&&r.args[0].param?new URL(ca(a,r.args[0].param)):new URL(a);if(i==="ws"){const u=VS(r.args[0]&&r.args[0].param?ca(a,r.args[0].param):a,"ws"),f=new URL(u),d=(c=r.args[0])==null?void 0:c.query;return d&&Object.entries(d).forEach(([p,g])=>{Array.isArray(g)?g.forEach(v=>f.searchParams.append(p,v)):f.searchParams.set(p,g)}),((...p)=>(t==null?void 0:t.webSocket)!==void 0&&typeof t.webSocket=="function"?t.webSocket(...p):new WebSocket(...p))(f.toString())}const l=new KS(a,i);if(i){t??(t={});const u=zh(t,{...r.args[1]??{}});return l.fetch(r.args[0],u)}return l},[]);const wn=zS("/rpc"),ss="production",BS=e=>xi(()=>({queryKey:["bundles",e()],queryFn:async()=>(await wn.bundles.$get({query:e()})).json(),placeholderData:t=>t,staleTime:Number.POSITIVE_INFINITY})),jS=e=>xi(()=>({queryKey:["bundle",e],queryFn:()=>wn.bundles[":bundleId"].$get({param:{bundleId:e}}).then(t=>t.json()),placeholderData:t=>t,staleTime:Number.POSITIVE_INFINITY})),US=()=>xi(()=>({queryKey:["config"],queryFn:()=>wn.config.$get().then(e=>e.json()),staleTime:Number.POSITIVE_INFINITY,retryOnMount:!1})),jh=()=>xi(()=>({queryKey:["channels"],queryFn:()=>wn.channels.$get().then(e=>e.json()),staleTime:Number.POSITIVE_INFINITY,retryOnMount:!1,select:e=>!e||e.length===0?null:e.includes(ss)?[ss,...e.filter(t=>t!==ss)]:e})),HS=()=>{const e=yo();return mm(()=>({mutationFn:async t=>{const n=await wn.bundles[":bundleId"].$delete({param:{bundleId:t}});if(!n.ok)throw new Error(`Failed to delete bundle: ${n.status}`);return n.json()},onSuccess:()=>{e.invalidateQueries({queryKey:["bundles"]})}}))};var GS=te('<div class="transition-opacity duration-300"><div class="flex flex-row justify-end p-3"><div class="flex items-center gap-4"><div class="text-sm text-muted-foreground">Platform:</div><div class="text-sm text-muted-foreground">Channel:</div></div></div><div class="border rounded-md">'),qS=te('<div class="mt-2 text-sm text-muted-foreground text-center">Showing <!> to <!> of <!> results');const WS=20,[Ct,Ho]=z({pageIndex:0,pageSize:WS});function QS(e){var g;const[t]=_(e,["columns","onRowClick"]),{channelFilter:n,platformFilter:r,setPlatformFilter:o,setChannelFilter:i}=Lf(),s=L(()=>({channel:n()??void 0,platform:r()??void 0,limit:Ct().pageSize.toString(),offset:(Ct().pageIndex*Ct().pageSize).toString()})),a=BS(s),l=L(()=>a.data??{data:[],pagination:null}),c=L(()=>l().data??[]),u=L(()=>l().pagination),f=w0({get data(){return c()},columns:t.columns,getCoreRowModel:g0(),getFilteredRowModel:y0(),state:{get pagination(){return Ct()},get globalFilter(){return r()}},onPaginationChange:Ho,globalFilterFn:(v,m,y)=>y?v.original.platform.toLowerCase()===y:!0,manualPagination:!0,pageCount:((g=u())==null?void 0:g.totalPages)??0}),d=v=>()=>{t.onRowClick(v.original)},h=jh();j(()=>{h.isFetched&&h.data&&n()===null&&i(h.data[0])});const p=v=>{Ho(m=>({...m,pageIndex:v}))};return(()=>{var v=GS(),m=v.firstChild,y=m.firstChild,b=y.firstChild,S=b.nextSibling,C=m.nextSibling;return W(y,w(Ic,{get children(){return w(Mc,{get children(){return[w(Pc,{class:"w-[100px]",get children(){return[L(()=>L(()=>!!r())()?r():"All"),w(Rc,{})]}}),w(Oc,{get children(){return w(et,{each:[{label:"All",value:null},{label:"iOS",value:"ios"},{label:"Android",value:"android"}],children:R=>w(Fc,{get classList(){return{"bg-primary text-primary-foreground":R.value===r()}},onClick:()=>{o(R.value),Ho(D=>({...D,pageIndex:0}))},get children(){return R.label}})})}})]}})}}),S),W(y,w(Ic,{get children(){return w(Mc,{get children(){return[w(Pc,{class:"w-[100px]",get children(){return[L(()=>n()),w(Rc,{})]}}),w(Oc,{get children(){return w(et,{get each(){return h.data},children:R=>w(Fc,{get classList(){return{"bg-primary text-primary-foreground":R===n()}},onClick:()=>{i(R),Ho(D=>({...D,pageIndex:0}))},children:R})})}})]}})}}),null),W(C,w($S,{get children(){return[w(AS,{get children(){return w(et,{get each(){return f.getHeaderGroups()},children:R=>w(is,{get children(){return w(et,{get each(){return R.headers},children:D=>w(DS,{get children(){return L(()=>!!D.isPlaceholder)()?null:wc(D.column.columnDef.header,D.getContext())}})})}})})}}),w(TS,{get children(){return L(()=>!!(a.isFetched&&c().length===0))()?w(is,{get children(){return w($c,{get colSpan(){return t.columns.length},class:"h-full text-center",children:"No results."})}}):w(et,{get each(){return f.getRowModel().rows},children:R=>w(is,{get"data-state"(){return R.getIsSelected()&&"selected"},class:"cursor-pointer",get onClick(){return d(R)},get children(){return w(et,{get each(){return R.getVisibleCells()},children:D=>w($c,{get children(){return wc(D.column.columnDef.cell,D.getContext())}})})}})})}})]}})),W(v,w(bS,{class:"mt-2.5 w-full [&>ul]:justify-center",itemComponent:R=>w(SS,{get page(){return R.page},onClick:()=>p(R.page-1),get children(){return R.page}}),ellipsisComponent:()=>w(xS,{}),get count(){var R;return((R=u())==null?void 0:R.totalPages)??1},get children(){return[w(CS,{onClick:()=>p(Ct().pageIndex-1),get disabled(){var R;return!((R=u())!=null&&R.hasPreviousPage)}}),w(wS,{}),w(ES,{onClick:()=>p(Ct().pageIndex+1),get disabled(){var R;return!((R=u())!=null&&R.hasNextPage)}})]}}),null),W(v,(()=>{var R=L(()=>!!u());return()=>R()&&(()=>{var D=qS(),V=D.firstChild,$=V.nextSibling,k=$.nextSibling,N=k.nextSibling,B=N.nextSibling,ne=B.nextSibling;return ne.nextSibling,W(D,()=>Ct().pageIndex*Ct().pageSize+1,$),W(D,()=>Math.min((Ct().pageIndex+1)*Ct().pageSize,u().total),N),W(D,()=>u().total,ne),D})()})(),null),Ve(R=>{var D=!!a.isFetching,V=!!a.isFetching;return D!==R.e&&v.classList.toggle("opacity-50",R.e=D),V!==R.t&&C.classList.toggle("min-h-[400px]",R.t=V),R},{e:void 0,t:void 0}),v})()}var XS={};dt(XS,{Root:()=>Sl,Skeleton:()=>YS});function Sl(e){const t=`skeleton-${Ie()}`,n=Z({visible:!0,animate:!0,id:t},e),[r,o]=_(n,["style","radius","animate","height","width","visible","circle"]);return w(le,F({as:"div",role:"group",get"data-animate"(){return r.animate||void 0},get"data-visible"(){return r.visible||void 0},get style(){return ct({"border-radius":r.circle?"9999px":r.radius?`${r.radius}px`:void 0,width:r.circle?`${r.height}px`:r.width?`${r.width}px`:"100%",height:r.height?`${r.height}px`:"auto"},r.style)}},o))}var YS=Sl;const JS=e=>{const[t,n]=_(e,["class"]);return w(Sl,F({get class(){return ce("bg-primary/10 data-[animate='true']:animate-pulse",t.class)}},n))};var ZS={};dt(ZS,{AlertDialog:()=>ex,CloseButton:()=>Sn,Content:()=>xl,Description:()=>Pr,Overlay:()=>Rr,Portal:()=>Or,Root:()=>Fr,Title:()=>$r,Trigger:()=>Eo});function xl(e){return w(Mi,F({role:"alertdialog"},e))}var ex=Object.assign(Fr,{CloseButton:Sn,Content:xl,Description:Pr,Overlay:Rr,Portal:Or,Title:$r,Trigger:Eo}),tx=te('<svg xmlns=http://www.w3.org/2000/svg width=24 height=24 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><title>Close dialog</title><path d="M18 6l-12 12"></path><path d="M6 6l12 12">'),nx=te("<span class=sr-only>Close");const Uh=Fr,Hh=Eo,rx=Or,Cl=e=>{const[t,n]=_(e,["class"]);return w(Rr,F({get class(){return ce("fixed inset-0 z-50 backdrop-blur-sm data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0",t.class)}},n))},Gh=e=>{const[t,n]=_(e,["class","children"]);return w(rx,{get children(){return[w(Cl,{}),w(xl,F({get class(){return ce("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[expanded]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[expanded]:fade-in-0 data-[closed]:zoom-out-95 data-[expanded]:zoom-in-95 data-[closed]:slide-out-to-left-1/2 data-[closed]:slide-out-to-top-[48%] data-[expanded]:slide-in-from-left-1/2 data-[expanded]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",t.class)}},n,{get children(){return[L(()=>t.children),w(Sn,{class:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[expanded]:bg-accent data-[expanded]:text-muted-foreground",get children(){return[tx(),nx()]}})]}}))]}})},qh=e=>{const[t,n]=_(e,["class"]);return w($r,F({get class(){return ce("text-lg font-semibold",t.class)}},n))},Wh=e=>{const[t,n]=_(e,["class"]);return w(Pr,F({get class(){return ce("text-sm text-muted-foreground",t.class)}},n))};var ox=te('<div class="h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent">'),ix=te('<div class="flex gap-2 justify-end mt-4">');const sx=({bundleId:e,onDeleteSuccess:t})=>{const n=HS(),r=()=>{n.mutate(e,{onSuccess:()=>{t()},onError:o=>{console.error("Failed to delete bundle:",o),Yt({title:"Error",description:"Failed to delete bundle. Please try again.",variant:"error"})}})};return w(Uh,{get children(){return[w(Hh,{as:fn,variant:"destructive",size:"sm",class:"gap-2 flex-1",get children(){return[w(nc,{class:"h-4 w-4"}),"Delete Bundle"]}}),w(Cl,{}),w(Gh,{get children(){return[w(qh,{children:"Delete Bundle"}),w(Wh,{children:"Are you sure you want to delete this bundle storage? This action cannot be undone."}),(()=>{var o=ix();return W(o,w(Sn,{as:fn,variant:"outline",size:"sm",children:"Cancel"}),null),W(o,w(fn,{variant:"destructive",size:"sm",onClick:r,get disabled(){return n.isPending},class:"gap-2",get children(){return[w(de,{get when(){return n.isPending},get fallback(){return w(nc,{class:"h-4 w-4"})},get children(){return ox()}}),L(()=>n.isPending?"Deleting...":"Delete")]}}),null),o})()]}})]}})},or=new WeakMap,ri=new WeakMap,vi={current:[]};let as=!1,eo=0;const Xr=new Set,Go=new Map;function Qh(e){const t=Array.from(e).sort((n,r)=>n instanceof zt&&n.options.deps.includes(r)?1:r instanceof zt&&r.options.deps.includes(n)?-1:0);for(const n of t){if(vi.current.includes(n))continue;vi.current.push(n),n.recompute();const r=ri.get(n);if(r)for(const o of r){const i=or.get(o);i&&Qh(i)}}}function ax(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function lx(e){e.listeners.forEach(t=>t({prevVal:e.prevState,currentVal:e.state}))}function Xh(e){if(eo>0&&!Go.has(e)&&Go.set(e,e.prevState),Xr.add(e),!(eo>0)&&!as)try{for(as=!0;Xr.size>0;){const t=Array.from(Xr);Xr.clear();for(const n of t){const r=Go.get(n)??n.prevState;n.prevState=r,ax(n)}for(const n of t){const r=or.get(n);r&&(vi.current.push(n),Qh(r))}for(const n of t){const r=or.get(n);if(r)for(const o of r)lx(o)}}}finally{as=!1,vi.current=[],Go.clear()}}function Et(e){eo++;try{e()}finally{if(eo--,eo===0){const t=Array.from(Xr)[0];t&&Xh(t)}}}function ux(e){return typeof e=="function"}class da{constructor(t,n){this.listeners=new Set,this.subscribe=r=>{var o,i;this.listeners.add(r);const s=(i=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:i.call(o,r,this);return()=>{this.listeners.delete(r),s==null||s()}},this.prevState=t,this.state=t,this.options=n}setState(t){var n,r,o;this.prevState=this.state,(n=this.options)!=null&&n.updateFn?this.state=this.options.updateFn(this.prevState)(t):ux(t)?this.state=t(this.prevState):this.state=t,(o=(r=this.options)==null?void 0:r.onUpdate)==null||o.call(r),Xh(this)}}class zt{constructor(t){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const n=[],r=[];for(const o of this.options.deps)n.push(o.prevState),r.push(o.state);return this.lastSeenDepValues=r,{prevDepVals:n,currDepVals:r,prevVal:this.prevState??void 0}},this.recompute=()=>{var n,r;this.prevState=this.state;const{prevDepVals:o,currDepVals:i,prevVal:s}=this.getDepVals();this.state=this.options.fn({prevDepVals:o,currDepVals:i,prevVal:s}),(r=(n=this.options).onUpdate)==null||r.call(n)},this.checkIfRecalculationNeededDeeply=()=>{for(const i of this.options.deps)i instanceof zt&&i.checkIfRecalculationNeededDeeply();let n=!1;const r=this.lastSeenDepValues,{currDepVals:o}=this.getDepVals();for(let i=0;i<o.length;i++)if(o[i]!==r[i]){n=!0;break}n&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const n of this._subscriptions)n()}),this.subscribe=n=>{var r,o;this.listeners.add(n);const i=(o=(r=this.options).onSubscribe)==null?void 0:o.call(r,n,this);return()=>{this.listeners.delete(n),i==null||i()}},this.options=t,this.state=t.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(t=this.options.deps){for(const n of t)if(n instanceof zt)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof da){let r=or.get(n);r||(r=new Set,or.set(n,r)),r.add(this);let o=ri.get(this);o||(o=new Set,ri.set(this,o)),o.add(n)}}unregisterFromGraph(t=this.options.deps){for(const n of t)if(n instanceof zt)this.unregisterFromGraph(n.options.deps);else if(n instanceof da){const r=or.get(n);r&&r.delete(this);const o=ri.get(this);o&&o.delete(n)}}}function El(e,t){return typeof e=="function"?e(t):e}function Yr(e,t){return Ml(t).reduce((r,o)=>{if(r===null)return null;if(typeof r<"u")return r[o]},e)}function qo(e,t,n){const r=Ml(t);function o(i){if(!r.length)return El(n,i);const s=r.shift();if(typeof s=="string"||typeof s=="number"&&!Array.isArray(i))return typeof i=="object"?(i===null&&(i={}),{...i,[s]:o(i[s])}):{[s]:o()};if(Array.isArray(i)&&typeof s=="number"){const a=i.slice(0,s);return[...a.length?a:new Array(s),o(i[s]),...i.slice(s+1)]}return[...new Array(s),o()]}return o(e)}function cx(e,t){const n=Ml(t);function r(o){if(!o)return;if(n.length===1){const s=n[0];if(Array.isArray(o)&&typeof s=="number")return o.filter((c,u)=>u!==s);const{[s]:a,...l}=o;return l}const i=n.shift();if(typeof i=="string"&&typeof o=="object")return{...o,[i]:r(o[i])};if(typeof i=="number"&&Array.isArray(o)){if(i>=o.length)return o;const s=o.slice(0,i);return[...s.length?s:new Array(i),r(o[i]),...o.slice(i+1)]}throw new Error("It seems we have created an infinite loop in deleteBy. ")}return r(e)}const dx=/^(\d+)$/gm,fx=/\.(\d+)(?=\.)/gm,hx=/^(\d+)\./gm,gx=/\.(\d+$)/gm,px=/\.{2,}/gm,fa="__int__",Wo=`${fa}$1`;function Ml(e){if(Array.isArray(e))return[...e];if(typeof e!="string")throw new Error("Path must be a string.");return e.replace(/(^\[)|]/gm,"").replace(/\[/g,".").replace(dx,Wo).replace(fx,`.${Wo}.`).replace(hx,`${Wo}.`).replace(gx,`.${Wo}`).replace(px,".").split(".").map(t=>t.indexOf(fa)===0?parseInt(t.substring(fa.length),10):t)}function mx(e){return!(Array.isArray(e)&&e.length===0)}function ha(e,t){const{asyncDebounceMs:n}=t,{onChangeAsync:r,onBlurAsync:o,onSubmitAsync:i,onBlurAsyncDebounceMs:s,onChangeAsyncDebounceMs:a}=t.validators||{},l=n??0,c={cause:"change",validate:r,debounceMs:a??l},u={cause:"blur",validate:o,debounceMs:s??l},f={cause:"submit",validate:i,debounceMs:0},d=h=>({...h,debounceMs:0});switch(e){case"submit":return[d(c),d(u),f];case"blur":return[u];case"change":return[c];case"server":default:return[]}}function ga(e,t){const{onChange:n,onBlur:r,onSubmit:o,onMount:i}=t.validators||{},s={cause:"change",validate:n},a={cause:"blur",validate:r},l={cause:"submit",validate:o},c={cause:"mount",validate:i},u={cause:"server",validate:()=>{}};switch(e){case"mount":return[c];case"submit":return[s,a,l,u];case"server":return[u];case"blur":return[a,u];case"change":default:return[s,u]}}const pa=e=>!!e&&typeof e=="object"&&"fields"in e;function er(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,i]of e)if(!t.has(o)||!Object.is(i,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!r.includes(o)||!er(e[o],t[o]))return!1;return!0}const Ac=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:"form"}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:"field"}:{newErrorValue:void 0,newSource:void 0},Tc=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:"field"}:e?{newErrorValue:e,newSource:"form"}:{newErrorValue:void 0,newSource:void 0};function vx(e){const t=new Map;for(const n of e){const r=[...n.path??[]].map(o=>{const i=typeof o=="object"?o.key:o;return typeof i=="number"?`[${i}]`:i}).join(".").replace(/\.\[/g,"[");t.set(r,(t.get(r)??[]).concat(n))}return Object.fromEntries(t)}const Dc=e=>{const t=vx(e);return{form:t,fields:t}},ir={validate({value:e,validationSource:t},n){const r=n["~standard"].validate(e);if(r instanceof Promise)throw new Error("async function passed to sync validator");if(r.issues)return t==="field"?r.issues:Dc(r.issues)},async validateAsync({value:e,validationSource:t},n){const r=await n["~standard"].validate(e);if(r.issues)return t==="field"?r.issues:Dc(r.issues)}},Yh=e=>!!e&&"~standard"in e,yi={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{}};function Qo(e){function t(f,d,h,p){const g=r(f,d,h,p);({insert:()=>a(g,f,d),remove:()=>l(g),swap:()=>p!==void 0&&u(g,f,d,p),move:()=>p!==void 0&&c(g,f,d,p)})[h]()}function n(f,d){return`${f}[${d}]`}function r(f,d,h,p){const g=[n(f,d)];if(h==="swap")g.push(n(f,p));else if(h==="move"){const[v,m]=[Math.min(d,p),Math.max(d,p)];for(let y=v;y<=m;y++)g.push(n(f,y))}else{const v=e.getFieldValue(f),m=Array.isArray(v)?v.length:0;for(let y=d+1;y<m;y++)g.push(n(f,y))}return Object.keys(e.fieldInfo).filter(v=>g.some(m=>v.startsWith(m)))}function o(f,d){return f.replace(/\[(\d+)\]/,(h,p)=>{const g=parseInt(p,10);return`[${d==="up"?g+1:Math.max(0,g-1)}]`})}function i(f,d){(d==="up"?f:[...f].reverse()).forEach(p=>{const g=o(p.toString(),d),v=e.getFieldMeta(g);v?e.setFieldMeta(p,v):e.setFieldMeta(p,s())})}const s=()=>yi,a=(f,d,h)=>{i(f,"down"),f.forEach(p=>{p.toString().startsWith(n(d,h))&&e.setFieldMeta(p,s())})},l=f=>{i(f,"up")},c=(f,d,h,p)=>{const g=new Map(Object.keys(e.fieldInfo).filter(v=>v.startsWith(n(d,h))).map(v=>[v,e.getFieldMeta(v)]));i(f,h<p?"up":"down"),Object.keys(e.fieldInfo).filter(v=>v.startsWith(n(d,p))).forEach(v=>{const m=v.replace(n(d,p),n(d,h)),y=g.get(m);y&&e.setFieldMeta(v,y)})},u=(f,d,h,p)=>{f.forEach(g=>{if(!g.toString().startsWith(n(d,h)))return;const v=g.toString().replace(n(d,h),n(d,p)),[m,y]=[e.getFieldMeta(g),e.getFieldMeta(v)];m&&e.setFieldMeta(v,m),y&&e.setFieldMeta(g,y)})};return{handleArrayFieldMetaShift:t}}function ls(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}}}class yx{constructor(t){var n;this.options={},this.fieldInfo={},this.prevTransformArray=[],this.mount=()=>{var r,o;const i=this.fieldMetaDerived.mount(),s=this.store.mount(),a=()=>{i(),s()};(o=(r=this.options.listeners)==null?void 0:r.onMount)==null||o.call(r,{formApi:this});const{onMount:l}=this.options.validators||{};return l&&this.validateSync("mount"),a},this.update=r=>{var o,i;if(!r)return;const s=this.options;this.options=r;const a=!!((i=(o=r.transform)==null?void 0:o.deps)!=null&&i.some((u,f)=>u!==this.prevTransformArray[f])),l=r.defaultValues&&!er(r.defaultValues,s.defaultValues)&&!this.state.isTouched,c=!er(r.defaultState,s.defaultState)&&!this.state.isTouched;!l&&!c&&!a||Et(()=>{this.baseStore.setState(()=>ls(Object.assign({},this.state,c?r.defaultState:{},l?{values:r.defaultValues}:{},a?{_force_re_eval:!this.state._force_re_eval}:{})))})},this.reset=(r,o)=>{const{fieldMeta:i}=this.state,s=this.resetFieldMeta(i);r&&!(o!=null&&o.keepDefaultValues)&&(this.options={...this.options,defaultValues:r}),this.baseStore.setState(()=>{var a;return ls({...this.options.defaultState,values:r??this.options.defaultValues??((a=this.options.defaultState)==null?void 0:a.values),fieldMetaBase:s})})},this.validateAllFields=async r=>{const o=[];return Et(()=>{Object.values(this.fieldInfo).forEach(s=>{if(!s.instance)return;const a=s.instance;o.push(Promise.resolve().then(()=>a.validate(r,{skipFormValidation:!0}))),s.instance.state.meta.isTouched||s.instance.setMeta(l=>({...l,isTouched:!0}))})}),(await Promise.all(o)).flat()},this.validateArrayFieldsStartingFrom=async(r,o,i)=>{const s=this.getFieldValue(r),a=Array.isArray(s)?Math.max(s.length-1,0):null,l=[`${r}[${o}]`];for(let d=o+1;d<=(a??0);d++)l.push(`${r}[${d}]`);const c=Object.keys(this.fieldInfo).filter(d=>l.some(h=>d.startsWith(h))),u=[];return Et(()=>{c.forEach(d=>{u.push(Promise.resolve().then(()=>this.validateField(d,i)))})}),(await Promise.all(u)).flat()},this.validateField=(r,o)=>{var i;const s=(i=this.fieldInfo[r])==null?void 0:i.instance;return s?(s.state.meta.isTouched||s.setMeta(a=>({...a,isTouched:!0})),s.validate(o)):[]},this.validateSync=r=>{const o=ga(r,this.options);let i=!1;const s={};return Et(()=>{var a,l;for(const u of o){if(!u.validate)continue;const f=this.runValidator({validate:u.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:d,fieldErrors:h}=oi(f),p=Xo(u.cause);for(const g of Object.keys(this.state.fieldMeta)){const v=this.getFieldMeta(g);if(!v)continue;const{errorMap:m,errorSourceMap:y}=v,b=h==null?void 0:h[g],{newErrorValue:S,newSource:C}=Ac({newFormValidatorError:b,isPreviousErrorFromFormValidator:(y==null?void 0:y[p])==="form",previousErrorValue:m==null?void 0:m[p]});C==="form"&&(s[g]={...s[g],[p]:b}),(m==null?void 0:m[p])!==S&&this.setFieldMeta(g,R=>({...R,errorMap:{...R.errorMap,[p]:S},errorSourceMap:{...R.errorSourceMap,[p]:C}}))}((a=this.state.errorMap)==null?void 0:a[p])!==d&&this.baseStore.setState(g=>({...g,errorMap:{...g.errorMap,[p]:d}})),(d||h)&&(i=!0)}const c=Xo("submit");(l=this.state.errorMap)!=null&&l[c]&&r!=="submit"&&!i&&this.baseStore.setState(u=>({...u,errorMap:{...u.errorMap,[c]:void 0}}))}),{hasErrored:i,fieldsErrorMap:s}},this.validateAsync=async r=>{const o=ha(r,this.options);this.state.isFormValidating||this.baseStore.setState(c=>({...c,isFormValidating:!0}));const i=[];let s;for(const c of o){if(!c.validate)continue;const u=Xo(c.cause),f=this.state.validationMetaMap[u];f==null||f.lastAbortController.abort();const d=new AbortController;this.state.validationMetaMap[u]={lastAbortController:d},i.push(new Promise(async h=>{let p;try{p=await new Promise((y,b)=>{setTimeout(async()=>{if(d.signal.aborted)return y(void 0);try{y(await this.runValidator({validate:c.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:d.signal},type:"validateAsync"}))}catch(S){b(S)}},c.debounceMs)})}catch(y){p=y}const{formError:g,fieldErrors:v}=oi(p);v&&(s=s?{...s,...v}:v);const m=Xo(c.cause);for(const y of Object.keys(this.state.fieldMeta)){const b=this.getFieldMeta(y);if(!b)continue;const{errorMap:S,errorSourceMap:C}=b,R=s==null?void 0:s[y],{newErrorValue:D,newSource:V}=Ac({newFormValidatorError:R,isPreviousErrorFromFormValidator:(C==null?void 0:C[m])==="form",previousErrorValue:S==null?void 0:S[m]});(S==null?void 0:S[m])!==D&&this.setFieldMeta(y,$=>({...$,errorMap:{...$.errorMap,[m]:D},errorSourceMap:{...$.errorSourceMap,[m]:V}}))}this.baseStore.setState(y=>({...y,errorMap:{...y.errorMap,[m]:g}})),h(s?{fieldErrors:s,errorMapKey:m}:void 0)}))}let a=[];const l={};if(i.length){a=await Promise.all(i);for(const c of a)if(c!=null&&c.fieldErrors){const{errorMapKey:u}=c;for(const[f,d]of Object.entries(c.fieldErrors)){const p={...l[f]||{},[u]:d};l[f]=p}}}return this.baseStore.setState(c=>({...c,isFormValidating:!1})),l},this.validate=r=>{const{hasErrored:o,fieldsErrorMap:i}=this.validateSync(r);return o&&!this.options.asyncAlways?i:this.validateAsync(r)},this.getFieldValue=r=>Yr(this.state.values,r),this.getFieldMeta=r=>this.state.fieldMeta[r],this.getFieldInfo=r=>{var o;return(o=this.fieldInfo)[r]||(o[r]={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0}})},this.setFieldMeta=(r,o)=>{this.baseStore.setState(i=>({...i,fieldMetaBase:{...i.fieldMetaBase,[r]:El(o,i.fieldMetaBase[r])}}))},this.resetFieldMeta=r=>Object.keys(r).reduce((o,i)=>{const s=i;return o[s]=yi,o},{}),this.setFieldValue=(r,o,i)=>{const s=(i==null?void 0:i.dontUpdateMeta)??!1;Et(()=>{s||this.setFieldMeta(r,a=>({...a,isTouched:!0,isDirty:!0,errorMap:{...a==null?void 0:a.errorMap,onMount:void 0}})),this.baseStore.setState(a=>({...a,values:qo(a.values,r,o)}))})},this.deleteField=r=>{const i=[...Object.keys(this.fieldInfo).filter(s=>{const a=r.toString();return s!==a&&s.startsWith(a)}),r];this.baseStore.setState(s=>{const a={...s};return i.forEach(l=>{a.values=cx(a.values,l),delete this.fieldInfo[l],delete a.fieldMetaBase[l]}),a})},this.pushFieldValue=(r,o,i)=>{this.setFieldValue(r,s=>[...Array.isArray(s)?s:[],o],i),this.validateField(r,"change")},this.insertFieldValue=async(r,o,i,s)=>{this.setFieldValue(r,a=>[...a.slice(0,o),i,...a.slice(o)],s),await this.validateField(r,"change"),Qo(this).handleArrayFieldMetaShift(r,o,"insert"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.replaceFieldValue=async(r,o,i,s)=>{this.setFieldValue(r,a=>a.map((l,c)=>c===o?i:l),s),await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.removeFieldValue=async(r,o,i)=>{const s=this.getFieldValue(r),a=Array.isArray(s)?Math.max(s.length-1,0):null;if(this.setFieldValue(r,l=>l.filter((c,u)=>u!==o),i),Qo(this).handleArrayFieldMetaShift(r,o,"remove"),a!==null){const l=`${r}[${a}]`;this.deleteField(l)}await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,o,"change")},this.swapFieldValues=(r,o,i,s)=>{this.setFieldValue(r,a=>{const l=a[o],c=a[i];return qo(qo(a,`${o}`,c),`${i}`,l)},s),Qo(this).handleArrayFieldMetaShift(r,o,"swap",i),this.validateField(r,"change"),this.validateField(`${r}[${o}]`,"change"),this.validateField(`${r}[${i}]`,"change")},this.moveFieldValues=(r,o,i,s)=>{this.setFieldValue(r,a=>{const l=[...a];return l.splice(i,0,l.splice(o,1)[0]),l},s),Qo(this).handleArrayFieldMetaShift(r,o,"move",i),this.validateField(r,"change"),this.validateField(`${r}[${o}]`,"change"),this.validateField(`${r}[${i}]`,"change")},this.clearFieldValues=(r,o)=>{const i=this.getFieldValue(r),s=Array.isArray(i)?Math.max(i.length-1,0):null;if(this.setFieldValue(r,[],o),s!==null)for(let a=0;a<=s;a++){const l=`${r}[${a}]`;this.deleteField(l)}this.validateField(r,"change")},this.resetField=r=>{this.baseStore.setState(o=>({...o,fieldMetaBase:{...o.fieldMetaBase,[r]:yi},values:this.options.defaultValues?qo(o.values,r,Yr(this.options.defaultValues,r)):o.values}))},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((r,[o,i])=>(Object.keys(i).length&&i.errors.length&&(r[o]={errors:i.errors,errorMap:i.errorMap}),r),{})}),this.parseValuesWithSchema=r=>ir.validate({value:this.state.values,validationSource:"form"},r),this.parseValuesWithSchemaAsync=r=>ir.validateAsync({value:this.state.values,validationSource:"form"},r),this.baseStore=new da(ls({...t==null?void 0:t.defaultState,values:(t==null?void 0:t.defaultValues)??((n=t==null?void 0:t.defaultState)==null?void 0:n.values)})),this.fieldMetaDerived=new zt({deps:[this.baseStore],fn:({prevDepVals:r,currDepVals:o,prevVal:i})=>{var s,a,l;const c=i,u=r==null?void 0:r[0],f=o[0];let d=0;const h={};for(const p of Object.keys(f.fieldMetaBase)){const g=f.fieldMetaBase[p],v=u==null?void 0:u.fieldMetaBase[p],m=c==null?void 0:c[p],y=Yr(f.values,p);let b=m==null?void 0:m.errors;if(!v||g.errorMap!==v.errorMap){b=Object.values(g.errorMap??{}).filter(V=>V!==void 0);const D=(s=this.getFieldInfo(p))==null?void 0:s.instance;D&&!D.options.disableErrorFlat&&(b=b==null?void 0:b.flat(1))}const S=!mx(b??[]),C=!g.isDirty,R=er(y,Yr(this.options.defaultValues,p))||er(y,(l=(a=this.getFieldInfo(p))==null?void 0:a.instance)==null?void 0:l.options.defaultValue);if(m&&m.isPristine===C&&m.isValid===S&&m.isDefaultValue===R&&m.errors===b&&g===v){h[p]=m,d++;continue}h[p]={...g,errors:b,isPristine:C,isValid:S,isDefaultValue:R}}return Object.keys(f.fieldMetaBase).length&&c&&d===Object.keys(f.fieldMetaBase).length?c:h}}),this.store=new zt({deps:[this.baseStore,this.fieldMetaDerived],fn:({prevDepVals:r,currDepVals:o,prevVal:i})=>{var s,a,l,c;const u=i,f=r==null?void 0:r[0],d=o[0],h=o[1],p=Object.values(h).filter(Boolean),g=p.some(P=>P.isValidating),v=p.every(P=>P.isValid),m=p.some(P=>P.isTouched),y=p.some(P=>P.isBlurred),b=p.every(P=>P.isDefaultValue),S=m&&((s=d.errorMap)==null?void 0:s.onMount),C=p.some(P=>P.isDirty),R=!C,D=!!((a=d.errorMap)!=null&&a.onMount||p.some(P=>{var A;return(A=P==null?void 0:P.errorMap)==null?void 0:A.onMount})),V=!!g;let $=(u==null?void 0:u.errors)??[];(!f||d.errorMap!==f.errorMap)&&($=Object.values(d.errorMap).reduce((P,A)=>A===void 0?P:A&&pa(A)?(P.push(A.form),P):(P.push(A),P),[]));const k=$.length===0,N=v&&k,B=this.options.canSubmitWhenInvalid??!1,ne=d.submissionAttempts===0&&!m&&!D||!V&&!d.isSubmitting&&N||B;let I=d.errorMap;if(S&&($=$.filter(P=>P!==d.errorMap.onMount),I=Object.assign(I,{onMount:void 0})),u&&f&&u.errorMap===I&&u.fieldMeta===this.fieldMetaDerived.state&&u.errors===$&&u.isFieldsValidating===g&&u.isFieldsValid===v&&u.isFormValid===k&&u.isValid===N&&u.canSubmit===ne&&u.isTouched===m&&u.isBlurred===y&&u.isPristine===R&&u.isDefaultValue===b&&u.isDirty===C&&er(f,d))return u;let M={...d,errorMap:I,fieldMeta:this.fieldMetaDerived.state,errors:$,isFieldsValidating:g,isFieldsValid:v,isFormValid:k,isValid:N,canSubmit:ne,isTouched:m,isBlurred:y,isPristine:R,isDefaultValue:b,isDirty:C};const x=((l=this.options.transform)==null?void 0:l.deps)??[];if(x.length!==this.prevTransformArray.length||x.some((P,A)=>P!==this.prevTransformArray[A])){const P=Object.assign({},this,{state:M});(c=this.options.transform)==null||c.fn(P),M=P.state,this.prevTransformArray=x}return M}}),this.handleSubmit=this.handleSubmit.bind(this),this.update(t||{})}get state(){return this.store.state}runValidator(t){return Yh(t.validate)?ir[t.type](t.value,t.validate):t.validate(t.value)}async handleSubmit(t){var n,r,o,i,s,a,l,c;if(this.baseStore.setState(f=>({...f,isSubmitted:!1,submissionAttempts:f.submissionAttempts+1,isSubmitSuccessful:!1})),Et(()=>{Object.values(this.fieldInfo).forEach(f=>{f.instance&&(f.instance.state.meta.isTouched||f.instance.setMeta(d=>({...d,isTouched:!0})))})}),!this.state.canSubmit)return;this.baseStore.setState(f=>({...f,isSubmitting:!0}));const u=()=>{this.baseStore.setState(f=>({...f,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){u(),(r=(n=this.options).onSubmitInvalid)==null||r.call(n,{value:this.state.values,formApi:this});return}if(await this.validate("submit"),!this.state.isValid){u(),(i=(o=this.options).onSubmitInvalid)==null||i.call(o,{value:this.state.values,formApi:this});return}Et(()=>{Object.values(this.fieldInfo).forEach(f=>{var d,h,p;(p=(h=(d=f.instance)==null?void 0:d.options.listeners)==null?void 0:h.onSubmit)==null||p.call(h,{value:f.instance.state.value,fieldApi:f.instance})})}),(a=(s=this.options.listeners)==null?void 0:s.onSubmit)==null||a.call(s,{formApi:this});try{await((c=(l=this.options).onSubmit)==null?void 0:c.call(l,{value:this.state.values,formApi:this,meta:t??this.options.onSubmitMeta})),Et(()=>{this.baseStore.setState(f=>({...f,isSubmitted:!0,isSubmitSuccessful:!0})),u()})}catch(f){throw this.baseStore.setState(d=>({...d,isSubmitSuccessful:!1})),u(),f}}setErrorMap(t){Et(()=>{Object.entries(t).forEach(([n,r])=>{const o=n;if(pa(r)){const{formError:i,fieldErrors:s}=oi(r);for(const a of Object.keys(this.fieldInfo))this.getFieldMeta(a)&&this.setFieldMeta(a,c=>({...c,errorMap:{...c.errorMap,[o]:s==null?void 0:s[a]},errorSourceMap:{...c.errorSourceMap,[o]:"form"}}));this.baseStore.setState(a=>({...a,errorMap:{...a.errorMap,[o]:i}}))}else this.baseStore.setState(i=>({...i,errorMap:{...i.errorMap,[o]:r}}))})})}}function oi(e){if(e){if(pa(e)){const t=oi(e.form).formError,n=e.fields;return{formError:t,fieldErrors:n}}return{formError:e}}return{formError:void 0}}function Xo(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}class wx{constructor(t){this.options={},this.mount=()=>{var n,r;const o=this.store.mount();this.options.defaultValue!==void 0&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});const i=this.getInfo();i.instance=this,this.update(this.options);const{onMount:s}=this.options.validators||{};if(s){const a=this.runValidator({validate:s,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});a&&this.setMeta(l=>({...l,errorMap:{...l==null?void 0:l.errorMap,onMount:a},errorSourceMap:{...l==null?void 0:l.errorSourceMap,onMount:"field"}}))}return(r=(n=this.options.listeners)==null?void 0:n.onMount)==null||r.call(n,{value:this.state.value,fieldApi:this}),o},this.update=n=>{this.options=n;const r=this.name!==n.name;if(this.name=n.name,this.state.value===void 0){const o=Yr(n.form.options.defaultValues,n.name),i=n.defaultValue??o;r?this.setValue(s=>s||i,{dontUpdateMeta:!0}):i!==void 0&&this.setValue(i,{dontUpdateMeta:!0})}this.form.getFieldMeta(this.name)===void 0&&this.setMeta(this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(n,r)=>{this.form.setFieldValue(this.name,n,r),this.triggerOnChangeListener(),this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=n=>this.form.setFieldMeta(this.name,n),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(n,r)=>{this.form.pushFieldValue(this.name,n,r),this.triggerOnChangeListener()},this.insertValue=(n,r,o)=>{this.form.insertFieldValue(this.name,n,r,o),this.triggerOnChangeListener()},this.replaceValue=(n,r,o)=>{this.form.replaceFieldValue(this.name,n,r,o),this.triggerOnChangeListener()},this.removeValue=(n,r)=>{this.form.removeFieldValue(this.name,n,r),this.triggerOnChangeListener()},this.swapValues=(n,r,o)=>{this.form.swapFieldValues(this.name,n,r,o),this.triggerOnChangeListener()},this.moveValue=(n,r,o)=>{this.form.moveFieldValues(this.name,n,r,o),this.triggerOnChangeListener()},this.clearValues=n=>{this.form.clearFieldValues(this.name,n),this.triggerOnChangeListener()},this.getLinkedFields=n=>{const r=Object.values(this.form.fieldInfo),o=[];for(const i of r){if(!i.instance)continue;const{onChangeListenTo:s,onBlurListenTo:a}=i.instance.options.validators||{};n==="change"&&(s!=null&&s.includes(this.name))&&o.push(i.instance),n==="blur"&&(a!=null&&a.includes(this.name))&&o.push(i.instance)}return o},this.validateSync=(n,r)=>{var o;const i=ga(n,this.options),a=this.getLinkedFields(n).reduce((u,f)=>{const d=ga(n,f.options);return d.forEach(h=>{h.field=f}),u.concat(d)},[]);let l=!1;Et(()=>{const u=(f,d)=>{var h;const p=Yo(d.cause),g=d.validate?Lc(f.runValidator({validate:d.validate,value:{value:f.store.state.value,validationSource:"field",fieldApi:f},type:"validate"})):void 0,v=r[p],{newErrorValue:m,newSource:y}=Tc({formLevelError:v,fieldLevelError:g});((h=f.state.meta.errorMap)==null?void 0:h[p])!==m&&f.setMeta(b=>({...b,errorMap:{...b.errorMap,[p]:m},errorSourceMap:{...b.errorSourceMap,[p]:y}})),m&&(l=!0)};for(const f of i)u(this,f);for(const f of a)f.validate&&u(f.field,f)});const c=Yo("submit");return(o=this.state.meta.errorMap)!=null&&o[c]&&n!=="submit"&&!l&&this.setMeta(u=>({...u,errorMap:{...u.errorMap,[c]:void 0},errorSourceMap:{...u.errorSourceMap,[c]:void 0}})),{hasErrored:l}},this.validateAsync=async(n,r)=>{const o=ha(n,this.options),i=await r,s=this.getLinkedFields(n),a=s.reduce((d,h)=>{const p=ha(n,h.options);return p.forEach(g=>{g.field=h}),d.concat(p)},[]);this.state.meta.isValidating||this.setMeta(d=>({...d,isValidating:!0}));for(const d of s)d.setMeta(h=>({...h,isValidating:!0}));const l=[],c=[],u=(d,h,p)=>{const g=Yo(h.cause),v=d.getInfo().validationMetaMap[g];v==null||v.lastAbortController.abort();const m=new AbortController;this.getInfo().validationMetaMap[g]={lastAbortController:m},p.push(new Promise(async y=>{var b;let S;try{S=await new Promise(($,k)=>{this.timeoutIds.validations[h.cause]&&clearTimeout(this.timeoutIds.validations[h.cause]),this.timeoutIds.validations[h.cause]=setTimeout(async()=>{if(m.signal.aborted)return $(void 0);try{$(await this.runValidator({validate:h.validate,value:{value:d.store.state.value,fieldApi:d,signal:m.signal,validationSource:"field"},type:"validateAsync"}))}catch(N){k(N)}},h.debounceMs)})}catch($){S=$}if(m.signal.aborted)return y(void 0);const C=Lc(S),R=(b=i[this.name])==null?void 0:b[g],{newErrorValue:D,newSource:V}=Tc({formLevelError:R,fieldLevelError:C});d.setMeta($=>({...$,errorMap:{...$==null?void 0:$.errorMap,[g]:D},errorSourceMap:{...$.errorSourceMap,[g]:V}})),y(D)}))};for(const d of o)d.validate&&u(this,d,l);for(const d of a)d.validate&&u(d.field,d,c);let f=[];(l.length||c.length)&&(f=await Promise.all(l),await Promise.all(c)),this.setMeta(d=>({...d,isValidating:!1}));for(const d of s)d.setMeta(h=>({...h,isValidating:!1}));return f.filter(Boolean)},this.validate=(n,r)=>{var o;if(!this.state.meta.isTouched)return[];const{fieldsErrorMap:i}=r!=null&&r.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(n),{hasErrored:s}=this.validateSync(n,i[this.name]??{});if(s&&!this.options.asyncAlways)return(o=this.getInfo().validationMetaMap[Yo(n)])==null||o.lastAbortController.abort(),this.state.meta.errors;const a=r!=null&&r.skipFormValidation?Promise.resolve({}):this.form.validateAsync(n);return this.validateAsync(n,a)},this.handleChange=n=>{this.setValue(n)},this.handleBlur=()=>{this.state.meta.isTouched||(this.setMeta(r=>({...r,isTouched:!0})),this.validate("change")),this.state.meta.isBlurred||this.setMeta(r=>({...r,isBlurred:!0})),this.validate("blur"),this.triggerOnBlurListener()},this.parseValueWithSchema=n=>ir.validate({value:this.state.value,validationSource:"field"},n),this.parseValueWithSchemaAsync=n=>ir.validateAsync({value:this.state.value,validationSource:"field"},n),this.form=t.form,this.name=t.name,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=new zt({deps:[this.form.store],fn:()=>{const n=this.form.getFieldValue(this.name),r=this.form.getFieldMeta(this.name)??{...yi,...t.defaultMeta};return{value:n,meta:r}}}),this.options=t}get state(){return this.store.state}runValidator(t){return Yh(t.validate)?ir[t.type](t.value,t.validate):t.validate(t.value)}setErrorMap(t){this.setMeta(n=>({...n,errorMap:{...n.errorMap,...t}}))}triggerOnBlurListener(){var t,n,r,o,i,s;const a=(t=this.form.options.listeners)==null?void 0:t.onBlurDebounceMs;a&&a>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{var c,u;(u=(c=this.form.options.listeners)==null?void 0:c.onBlur)==null||u.call(c,{formApi:this.form,fieldApi:this})},a)):(r=(n=this.form.options.listeners)==null?void 0:n.onBlur)==null||r.call(n,{formApi:this.form,fieldApi:this});const l=(o=this.options.listeners)==null?void 0:o.onBlurDebounceMs;l&&l>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{var c,u;(u=(c=this.options.listeners)==null?void 0:c.onBlur)==null||u.call(c,{value:this.state.value,fieldApi:this})},l)):(s=(i=this.options.listeners)==null?void 0:i.onBlur)==null||s.call(i,{value:this.state.value,fieldApi:this})}triggerOnChangeListener(){var t,n,r,o,i,s;const a=(t=this.form.options.listeners)==null?void 0:t.onChangeDebounceMs;a&&a>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{var c,u;(u=(c=this.form.options.listeners)==null?void 0:c.onChange)==null||u.call(c,{formApi:this.form,fieldApi:this})},a)):(r=(n=this.form.options.listeners)==null?void 0:n.onChange)==null||r.call(n,{formApi:this.form,fieldApi:this});const l=(o=this.options.listeners)==null?void 0:o.onChangeDebounceMs;l&&l>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{var c,u;(u=(c=this.options.listeners)==null?void 0:c.onChange)==null||u.call(c,{value:this.state.value,fieldApi:this})},l)):(s=(i=this.options.listeners)==null?void 0:i.onChange)==null||s.call(i,{value:this.state.value,fieldApi:this})}}function Lc(e){if(e)return e}function Yo(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"change":default:return"onChange"}}function _c(e,t=n=>n){const[n,r]=vo({value:t(e.state)}),o=e.subscribe(()=>{const i=t(e.state);r("value",qd(i))});return Y(()=>{o()}),()=>n.value}function bx(e){const[t,n]=z(e,{equals:!1}),r=e.store.subscribe(()=>n(e));return Y(r),t}function Jh(e){const t=e(),n=new wx(t),r=n;r.Field=Zh;let o=!1;return Sr(()=>{const i=n.mount();o=!0,Y(()=>{i(),o=!1})}),pt(()=>{o&&n.update(e())}),bx(r)}function Zh(e){const t=Jh(()=>{const{children:n,...r}=e;return r});return L(()=>w(()=>e.children(t),{}))}function Sx(e){const t=e==null?void 0:e(),n=new yx(t),r=n;return r.Field=o=>w(Zh,F(o,{form:n})),r.createField=o=>Jh(()=>({...o(),form:n})),r.useStore=o=>_c(n.store,o),r.Subscribe=o=>El(o.children,_c(n.store,o.selector)),Sr(n.mount),pt(()=>n.update(e==null?void 0:e())),r}var us,kc;function xx(){if(kc)return us;kc=1;class e{constructor(){this.max=1e3,this.map=new Map}get(n){const r=this.map.get(n);if(r!==void 0)return this.map.delete(n),this.map.set(n,r),r}delete(n){return this.map.delete(n)}set(n,r){if(!this.delete(n)&&r!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(n,r)}return this}}return us=e,us}var cs,Vc;function Il(){if(Vc)return cs;Vc=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return cs=r=>r?typeof r!="object"?e:r:t,cs}var Jo={exports:{}},ds,Nc;function Pl(){if(Nc)return ds;Nc=1;const e="2.0.0",t=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,r=16,o=t-6;return ds={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_SAFE_INTEGER:n,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},ds}var fs,Kc;function Di(){if(Kc)return fs;Kc=1;var e={};return fs=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},fs}var zc;function Rl(){return zc||(zc=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:o}=Pl(),i=Di();t=e.exports={};const s=t.re=[],a=t.safeRe=[],l=t.src=[],c=t.safeSrc=[],u=t.t={};let f=0;const d="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",o],[d,r]],p=v=>{for(const[m,y]of h)v=v.split(`${m}*`).join(`${m}{0,${y}}`).split(`${m}+`).join(`${m}{1,${y}}`);return v},g=(v,m,y)=>{const b=p(m),S=f++;i(v,S,m),u[v]=S,l[S]=m,c[S]=b,s[S]=new RegExp(m,y?"g":void 0),a[S]=new RegExp(b,y?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),g("MAINVERSION",`(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})\\.(${l[u.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})\\.(${l[u.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${l[u.NONNUMERICIDENTIFIER]}|${l[u.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASE",`(?:-(${l[u.PRERELEASEIDENTIFIER]}(?:\\.${l[u.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${l[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[u.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${d}+`),g("BUILD",`(?:\\+(${l[u.BUILDIDENTIFIER]}(?:\\.${l[u.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${l[u.MAINVERSION]}${l[u.PRERELEASE]}?${l[u.BUILD]}?`),g("FULL",`^${l[u.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${l[u.MAINVERSIONLOOSE]}${l[u.PRERELEASELOOSE]}?${l[u.BUILD]}?`),g("LOOSE",`^${l[u.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${l[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${l[u.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:\\.(${l[u.XRANGEIDENTIFIER]})(?:${l[u.PRERELEASE]})?${l[u.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[u.XRANGEIDENTIFIERLOOSE]})(?:${l[u.PRERELEASELOOSE]})?${l[u.BUILD]}?)?)?`),g("XRANGE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${l[u.GTLT]}\\s*${l[u.XRANGEPLAINLOOSE]}$`),g("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),g("COERCE",`${l[u.COERCEPLAIN]}(?:$|[^\\d])`),g("COERCEFULL",l[u.COERCEPLAIN]+`(?:${l[u.PRERELEASE]})?(?:${l[u.BUILD]})?(?:$|[^\\d])`),g("COERCERTL",l[u.COERCE],!0),g("COERCERTLFULL",l[u.COERCEFULL],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${l[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",g("TILDE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${l[u.LONETILDE]}${l[u.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${l[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",g("CARET",`^${l[u.LONECARET]}${l[u.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${l[u.LONECARET]}${l[u.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${l[u.GTLT]}\\s*(${l[u.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${l[u.GTLT]}\\s*(${l[u.LOOSEPLAIN]}|${l[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${l[u.XRANGEPLAIN]})\\s+-\\s+(${l[u.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${l[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[u.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Jo,Jo.exports)),Jo.exports}var hs,Bc;function Cx(){if(Bc)return hs;Bc=1;const e=/^[0-9]+$/,t=(r,o)=>{const i=e.test(r),s=e.test(o);return i&&s&&(r=+r,o=+o),r===o?0:i&&!s?-1:s&&!i?1:r<o?-1:1};return hs={compareIdentifiers:t,rcompareIdentifiers:(r,o)=>t(o,r)},hs}var gs,jc;function Ol(){if(jc)return gs;jc=1;const e=Di(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=Pl(),{safeRe:r,t:o}=Rl(),i=Il(),{compareIdentifiers:s}=Cx();class a{constructor(c,u){if(u=i(u),c instanceof a){if(c.loose===!!u.loose&&c.includePrerelease===!!u.includePrerelease)return c;c=c.version}else if(typeof c!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof c}".`);if(c.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",c,u),this.options=u,this.loose=!!u.loose,this.includePrerelease=!!u.includePrerelease;const f=c.trim().match(u.loose?r[o.LOOSE]:r[o.FULL]);if(!f)throw new TypeError(`Invalid Version: ${c}`);if(this.raw=c,this.major=+f[1],this.minor=+f[2],this.patch=+f[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");f[4]?this.prerelease=f[4].split(".").map(d=>{if(/^[0-9]+$/.test(d)){const h=+d;if(h>=0&&h<n)return h}return d}):this.prerelease=[],this.build=f[5]?f[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(c){if(e("SemVer.compare",this.version,this.options,c),!(c instanceof a)){if(typeof c=="string"&&c===this.version)return 0;c=new a(c,this.options)}return c.version===this.version?0:this.compareMain(c)||this.comparePre(c)}compareMain(c){return c instanceof a||(c=new a(c,this.options)),s(this.major,c.major)||s(this.minor,c.minor)||s(this.patch,c.patch)}comparePre(c){if(c instanceof a||(c=new a(c,this.options)),this.prerelease.length&&!c.prerelease.length)return-1;if(!this.prerelease.length&&c.prerelease.length)return 1;if(!this.prerelease.length&&!c.prerelease.length)return 0;let u=0;do{const f=this.prerelease[u],d=c.prerelease[u];if(e("prerelease compare",u,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return s(f,d)}while(++u)}compareBuild(c){c instanceof a||(c=new a(c,this.options));let u=0;do{const f=this.build[u],d=c.build[u];if(e("build compare",u,f,d),f===void 0&&d===void 0)return 0;if(d===void 0)return 1;if(f===void 0)return-1;if(f===d)continue;return s(f,d)}while(++u)}inc(c,u,f){if(c.startsWith("pre")){if(!u&&f===!1)throw new Error("invalid increment argument: identifier is empty");if(u){const d=`-${u}`.match(this.options.loose?r[o.PRERELEASELOOSE]:r[o.PRERELEASE]);if(!d||d[1]!==u)throw new Error(`invalid identifier: ${u}`)}}switch(c){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",u,f);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",u,f);break;case"prepatch":this.prerelease.length=0,this.inc("patch",u,f),this.inc("pre",u,f);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",u,f),this.inc("pre",u,f);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const d=Number(f)?1:0;if(this.prerelease.length===0)this.prerelease=[d];else{let h=this.prerelease.length;for(;--h>=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(u===this.prerelease.join(".")&&f===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(d)}}if(u){let h=[u,d];f===!1&&(h=[u]),s(this.prerelease[0],u)===0?isNaN(this.prerelease[1])&&(this.prerelease=h):this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${c}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return gs=a,gs}var ps,Uc;function _r(){if(Uc)return ps;Uc=1;const e=Ol();return ps=(n,r,o)=>new e(n,o).compare(new e(r,o)),ps}var ms,Hc;function Ex(){if(Hc)return ms;Hc=1;const e=_r();return ms=(n,r,o)=>e(n,r,o)===0,ms}var vs,Gc;function Mx(){if(Gc)return vs;Gc=1;const e=_r();return vs=(n,r,o)=>e(n,r,o)!==0,vs}var ys,qc;function Ix(){if(qc)return ys;qc=1;const e=_r();return ys=(n,r,o)=>e(n,r,o)>0,ys}var ws,Wc;function Px(){if(Wc)return ws;Wc=1;const e=_r();return ws=(n,r,o)=>e(n,r,o)>=0,ws}var bs,Qc;function Rx(){if(Qc)return bs;Qc=1;const e=_r();return bs=(n,r,o)=>e(n,r,o)<0,bs}var Ss,Xc;function Ox(){if(Xc)return Ss;Xc=1;const e=_r();return Ss=(n,r,o)=>e(n,r,o)<=0,Ss}var xs,Yc;function Fx(){if(Yc)return xs;Yc=1;const e=Ex(),t=Mx(),n=Ix(),r=Px(),o=Rx(),i=Ox();return xs=(a,l,c,u)=>{switch(l){case"===":return typeof a=="object"&&(a=a.version),typeof c=="object"&&(c=c.version),a===c;case"!==":return typeof a=="object"&&(a=a.version),typeof c=="object"&&(c=c.version),a!==c;case"":case"=":case"==":return e(a,c,u);case"!=":return t(a,c,u);case">":return n(a,c,u);case">=":return r(a,c,u);case"<":return o(a,c,u);case"<=":return i(a,c,u);default:throw new TypeError(`Invalid operator: ${l}`)}},xs}var Cs,Jc;function $x(){if(Jc)return Cs;Jc=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(u,f){if(f=n(f),u instanceof t){if(u.loose===!!f.loose)return u;u=u.value}u=u.trim().split(/\s+/).join(" "),s("comparator",u,f),this.options=f,this.loose=!!f.loose,this.parse(u),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(u){const f=this.options.loose?r[o.COMPARATORLOOSE]:r[o.COMPARATOR],d=u.match(f);if(!d)throw new TypeError(`Invalid comparator: ${u}`);this.operator=d[1]!==void 0?d[1]:"",this.operator==="="&&(this.operator=""),d[2]?this.semver=new a(d[2],this.options.loose):this.semver=e}toString(){return this.value}test(u){if(s("Comparator.test",u,this.options.loose),this.semver===e||u===e)return!0;if(typeof u=="string")try{u=new a(u,this.options)}catch{return!1}return i(u,this.operator,this.semver,this.options)}intersects(u,f){if(!(u instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new l(u.value,f).test(this.value):u.operator===""?u.value===""?!0:new l(this.value,f).test(u.semver):(f=n(f),f.includePrerelease&&(this.value==="<0.0.0-0"||u.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||u.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&u.operator.startsWith(">")||this.operator.startsWith("<")&&u.operator.startsWith("<")||this.semver.version===u.semver.version&&this.operator.includes("=")&&u.operator.includes("=")||i(this.semver,"<",u.semver,f)&&this.operator.startsWith(">")&&u.operator.startsWith("<")||i(this.semver,">",u.semver,f)&&this.operator.startsWith("<")&&u.operator.startsWith(">")))}}Cs=t;const n=Il(),{safeRe:r,t:o}=Rl(),i=Fx(),s=Di(),a=Ol(),l=eg();return Cs}var Es,Zc;function eg(){if(Zc)return Es;Zc=1;const e=/\s+/g;class t{constructor(M,x){if(x=o(x),M instanceof t)return M.loose===!!x.loose&&M.includePrerelease===!!x.includePrerelease?M:new t(M.raw,x);if(M instanceof i)return this.raw=M.value,this.set=[[M]],this.formatted=void 0,this;if(this.options=x,this.loose=!!x.loose,this.includePrerelease=!!x.includePrerelease,this.raw=M.trim().replace(e," "),this.set=this.raw.split("||").map(O=>this.parseRange(O.trim())).filter(O=>O.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const O=this.set[0];if(this.set=this.set.filter(P=>!g(P[0])),this.set.length===0)this.set=[O];else if(this.set.length>1){for(const P of this.set)if(P.length===1&&v(P[0])){this.set=[P];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let M=0;M<this.set.length;M++){M>0&&(this.formatted+="||");const x=this.set[M];for(let O=0;O<x.length;O++)O>0&&(this.formatted+=" "),this.formatted+=x[O].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(M){const O=((this.options.includePrerelease&&h)|(this.options.loose&&p))+":"+M,P=r.get(O);if(P)return P;const A=this.options.loose,K=A?l[c.HYPHENRANGELOOSE]:l[c.HYPHENRANGE];M=M.replace(K,B(this.options.includePrerelease)),s("hyphen replace",M),M=M.replace(l[c.COMPARATORTRIM],u),s("comparator trim",M),M=M.replace(l[c.TILDETRIM],f),s("tilde trim",M),M=M.replace(l[c.CARETTRIM],d),s("caret trim",M);let H=M.split(" ").map(fe=>y(fe,this.options)).join(" ").split(/\s+/).map(fe=>N(fe,this.options));A&&(H=H.filter(fe=>(s("loose invalid filter",fe,this.options),!!fe.match(l[c.COMPARATORLOOSE])))),s("range list",H);const q=new Map,oe=H.map(fe=>new i(fe,this.options));for(const fe of oe){if(g(fe))return[fe];q.set(fe.value,fe)}q.size>1&&q.has("")&&q.delete("");const J=[...q.values()];return r.set(O,J),J}intersects(M,x){if(!(M instanceof t))throw new TypeError("a Range is required");return this.set.some(O=>m(O,x)&&M.set.some(P=>m(P,x)&&O.every(A=>P.every(K=>A.intersects(K,x)))))}test(M){if(!M)return!1;if(typeof M=="string")try{M=new a(M,this.options)}catch{return!1}for(let x=0;x<this.set.length;x++)if(ne(this.set[x],M,this.options))return!0;return!1}}Es=t;const n=xx(),r=new n,o=Il(),i=$x(),s=Di(),a=Ol(),{safeRe:l,t:c,comparatorTrimReplace:u,tildeTrimReplace:f,caretTrimReplace:d}=Rl(),{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:p}=Pl(),g=I=>I.value==="<0.0.0-0",v=I=>I.value==="",m=(I,M)=>{let x=!0;const O=I.slice();let P=O.pop();for(;x&&O.length;)x=O.every(A=>P.intersects(A,M)),P=O.pop();return x},y=(I,M)=>(s("comp",I,M),I=R(I,M),s("caret",I),I=S(I,M),s("tildes",I),I=V(I,M),s("xrange",I),I=k(I,M),s("stars",I),I),b=I=>!I||I.toLowerCase()==="x"||I==="*",S=(I,M)=>I.trim().split(/\s+/).map(x=>C(x,M)).join(" "),C=(I,M)=>{const x=M.loose?l[c.TILDELOOSE]:l[c.TILDE];return I.replace(x,(O,P,A,K,H)=>{s("tilde",I,O,P,A,K,H);let q;return b(P)?q="":b(A)?q=`>=${P}.0.0 <${+P+1}.0.0-0`:b(K)?q=`>=${P}.${A}.0 <${P}.${+A+1}.0-0`:H?(s("replaceTilde pr",H),q=`>=${P}.${A}.${K}-${H} <${P}.${+A+1}.0-0`):q=`>=${P}.${A}.${K} <${P}.${+A+1}.0-0`,s("tilde return",q),q})},R=(I,M)=>I.trim().split(/\s+/).map(x=>D(x,M)).join(" "),D=(I,M)=>{s("caret",I,M);const x=M.loose?l[c.CARETLOOSE]:l[c.CARET],O=M.includePrerelease?"-0":"";return I.replace(x,(P,A,K,H,q)=>{s("caret",I,P,A,K,H,q);let oe;return b(A)?oe="":b(K)?oe=`>=${A}.0.0${O} <${+A+1}.0.0-0`:b(H)?A==="0"?oe=`>=${A}.${K}.0${O} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.0${O} <${+A+1}.0.0-0`:q?(s("replaceCaret pr",q),A==="0"?K==="0"?oe=`>=${A}.${K}.${H}-${q} <${A}.${K}.${+H+1}-0`:oe=`>=${A}.${K}.${H}-${q} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.${H}-${q} <${+A+1}.0.0-0`):(s("no pr"),A==="0"?K==="0"?oe=`>=${A}.${K}.${H}${O} <${A}.${K}.${+H+1}-0`:oe=`>=${A}.${K}.${H}${O} <${A}.${+K+1}.0-0`:oe=`>=${A}.${K}.${H} <${+A+1}.0.0-0`),s("caret return",oe),oe})},V=(I,M)=>(s("replaceXRanges",I,M),I.split(/\s+/).map(x=>$(x,M)).join(" ")),$=(I,M)=>{I=I.trim();const x=M.loose?l[c.XRANGELOOSE]:l[c.XRANGE];return I.replace(x,(O,P,A,K,H,q)=>{s("xRange",I,O,P,A,K,H,q);const oe=b(A),J=oe||b(K),fe=J||b(H),Le=fe;return P==="="&&Le&&(P=""),q=M.includePrerelease?"-0":"",oe?P===">"||P==="<"?O="<0.0.0-0":O="*":P&&Le?(J&&(K=0),H=0,P===">"?(P=">=",J?(A=+A+1,K=0,H=0):(K=+K+1,H=0)):P==="<="&&(P="<",J?A=+A+1:K=+K+1),P==="<"&&(q="-0"),O=`${P+A}.${K}.${H}${q}`):J?O=`>=${A}.0.0${q} <${+A+1}.0.0-0`:fe&&(O=`>=${A}.${K}.0${q} <${A}.${+K+1}.0-0`),s("xRange return",O),O})},k=(I,M)=>(s("replaceStars",I,M),I.trim().replace(l[c.STAR],"")),N=(I,M)=>(s("replaceGTE0",I,M),I.trim().replace(l[M.includePrerelease?c.GTE0PRE:c.GTE0],"")),B=I=>(M,x,O,P,A,K,H,q,oe,J,fe,Le)=>(b(O)?x="":b(P)?x=`>=${O}.0.0${I?"-0":""}`:b(A)?x=`>=${O}.${P}.0${I?"-0":""}`:K?x=`>=${x}`:x=`>=${x}${I?"-0":""}`,b(oe)?q="":b(J)?q=`<${+oe+1}.0.0-0`:b(fe)?q=`<${oe}.${+J+1}.0-0`:Le?q=`<=${oe}.${J}.${fe}-${Le}`:I?q=`<${oe}.${J}.${+fe+1}-0`:q=`<=${q}`,`${x} ${q}`.trim()),ne=(I,M,x)=>{for(let O=0;O<I.length;O++)if(!I[O].test(M))return!1;if(M.prerelease.length&&!x.includePrerelease){for(let O=0;O<I.length;O++)if(s(I[O].semver),I[O].semver!==i.ANY&&I[O].semver.prerelease.length>0){const P=I[O].semver;if(P.major===M.major&&P.minor===M.minor&&P.patch===M.patch)return!0}return!1}return!0};return Es}var Ms,ed;function Ax(){if(ed)return Ms;ed=1;const e=eg();return Ms=(n,r)=>{try{return new e(n,r).range||"*"}catch{return null}},Ms}var Tx=Ax();const td=_f(Tx);var Fl=["id","name","validationState","required","disabled","readOnly"];function $l(e){const t=`form-control-${Ie()}`,n=Z({id:t},e),[r,o]=z(),[i,s]=z(),[a,l]=z(),[c,u]=z(),f=(g,v,m)=>{const y=m!=null||r()!=null;return[m,r(),y&&v!=null?g:void 0].filter(Boolean).join(" ")||void 0},d=g=>[a(),c(),g].filter(Boolean).join(" ")||void 0,h=L(()=>({"data-valid":T(n.validationState)==="valid"?"":void 0,"data-invalid":T(n.validationState)==="invalid"?"":void 0,"data-required":T(n.required)?"":void 0,"data-disabled":T(n.disabled)?"":void 0,"data-readonly":T(n.readOnly)?"":void 0}));return{formControlContext:{name:()=>T(n.name)??T(n.id),dataset:h,validationState:()=>T(n.validationState),isRequired:()=>T(n.required),isDisabled:()=>T(n.disabled),isReadOnly:()=>T(n.readOnly),labelId:r,fieldId:i,descriptionId:a,errorMessageId:c,getAriaLabelledBy:f,getAriaDescribedBy:d,generateId:Ye(()=>T(n.id)),registerLabel:_e(o),registerField:_e(s),registerDescription:_e(l),registerErrorMessage:_e(u)}}}var Li=Ce();function it(){const e=xe(Li);if(e===void 0)throw new Error("[kobalte]: `useFormControlContext` must be used within a `FormControlContext.Provider` component");return e}function Oo(e){const t=it(),n=Z({id:t.generateId("description")},e);return j(()=>Y(t.registerDescription(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}var Al=["id","aria-label","aria-labelledby","aria-describedby"];function Tl(e){const t=it(),n=Z({id:t.generateId("field")},e);return j(()=>Y(t.registerField(T(n.id)))),{fieldProps:{id:()=>T(n.id),ariaLabel:()=>T(n["aria-label"]),ariaLabelledBy:()=>t.getAriaLabelledBy(T(n.id),T(n["aria-label"]),T(n["aria-labelledby"])),ariaDescribedBy:()=>t.getAriaDescribedBy(T(n["aria-describedby"]))}}}function kr(e){let t;const n=it(),r=Z({id:n.generateId("label")},e),[o,i]=_(r,["ref"]),s=Ei(()=>t,()=>"label");return j(()=>Y(n.registerLabel(i.id))),w(le,F({as:"label",ref(a){var l=me(c=>t=c,o.ref);typeof l=="function"&&l(a)},get for(){return L(()=>s()==="label")()?n.fieldId():void 0}},()=>n.dataset(),i))}function Dl(e,t){j(Ee(e,n=>{if(n==null)return;const r=Dx(n);r!=null&&(r.addEventListener("reset",t,{passive:!0}),Y(()=>{r.removeEventListener("reset",t)}))}))}function Dx(e){return Lx(e)?e.form:e.closest("form")}function Lx(e){return e.matches("textarea, input, select, button")}function Fo(e){const t=it(),n=Z({id:t.generateId("error-message")},e),[r,o]=_(n,["forceMount"]),i=()=>t.validationState()==="invalid";return j(()=>{i()&&Y(t.registerErrorMessage(o.id))}),w(de,{get when(){return r.forceMount||i()},get children(){return w(le,F({as:"div"},()=>t.dataset(),o))}})}var _x={};dt(_x,{Control:()=>Ll,Description:()=>ng,ErrorMessage:()=>rg,Input:()=>_l,Label:()=>kl,Root:()=>Vl,Switch:()=>Vx,Thumb:()=>Nl,useSwitchContext:()=>Hn});var tg=Ce();function Hn(){const e=xe(tg);if(e===void 0)throw new Error("[kobalte]: `useSwitchContext` must be used within a `Switch` component");return e}function Ll(e){const t=it(),n=Hn(),r=Z({id:n.generateId("control")},e),[o,i]=_(r,["onClick","onKeyDown"]);return w(le,F({as:"div",onClick:l=>{var c;ee(l,o.onClick),n.toggle(),(c=n.inputRef())==null||c.focus()},onKeyDown:l=>{var c;ee(l,o.onKeyDown),l.key===Oa.Space&&(n.toggle(),(c=n.inputRef())==null||c.focus())}},()=>t.dataset(),()=>n.dataset(),i))}function ng(e){const t=Hn();return w(Oo,F(()=>t.dataset(),e))}function rg(e){const t=Hn();return w(Fo,F(()=>t.dataset(),e))}function _l(e){const t=it(),n=Hn(),r=Z({id:n.generateId("input")},e),[o,i,s]=_(r,["ref","style","onChange","onFocus","onBlur"],Al),{fieldProps:a}=Tl(i);return w(le,F({as:"input",ref(f){var d=me(n.setInputRef,o.ref);typeof d=="function"&&d(f)},type:"checkbox",role:"switch",get id(){return a.id()},get name(){return t.name()},get value(){return n.value()},get checked(){return n.checked()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get style(){return ct({...Ci},o.style)},get"aria-checked"(){return n.checked()},get"aria-label"(){return a.ariaLabel()},get"aria-labelledby"(){return a.ariaLabelledBy()},get"aria-describedby"(){return a.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},onChange:f=>{ee(f,o.onChange),f.stopPropagation();const d=f.target;n.setIsChecked(d.checked),d.checked=n.checked()},onFocus:f=>{ee(f,o.onFocus),n.setIsFocused(!0)},onBlur:f=>{ee(f,o.onBlur),n.setIsFocused(!1)}},()=>t.dataset(),()=>n.dataset(),s))}function kl(e){const t=Hn();return w(kr,F(()=>t.dataset(),e))}function Vl(e){let t;const n=`switch-${Ie()}`,r=Z({value:"on",id:n},e),[o,i,s]=_(r,["ref","children","value","checked","defaultChecked","onChange","onPointerDown"],Fl),[a,l]=z(),[c,u]=z(!1),{formControlContext:f}=$l(i),d=wh({isSelected:()=>o.checked,defaultIsSelected:()=>o.defaultChecked,onSelectedChange:v=>{var m;return(m=o.onChange)==null?void 0:m.call(o,v)},isDisabled:()=>f.isDisabled(),isReadOnly:()=>f.isReadOnly()});Dl(()=>t,()=>d.setIsSelected(o.defaultChecked??!1));const h=v=>{ee(v,o.onPointerDown),c()&&v.preventDefault()},p=L(()=>({"data-checked":d.isSelected()?"":void 0})),g={value:()=>o.value,dataset:p,checked:()=>d.isSelected(),inputRef:a,generateId:Ye(()=>T(i.id)),toggle:()=>d.toggle(),setIsChecked:v=>d.setIsSelected(v),setIsFocused:u,setInputRef:l};return w(Li.Provider,{value:f,get children(){return w(tg.Provider,{value:g,get children(){return w(le,F({as:"div",ref(v){var m=me(y=>t=y,o.ref);typeof m=="function"&&m(v)},role:"group",get id(){return T(i.id)},onPointerDown:h},()=>f.dataset(),p,s,{get children(){return w(kx,{state:g,get children(){return o.children}})}}))}})}})}function kx(e){const t=xr(()=>{const n=e.children;return un(n)?n(e.state):n});return L(t)}function Nl(e){const t=it(),n=Hn(),r=Z({id:n.generateId("thumb")},e);return w(le,F({as:"div"},()=>t.dataset(),()=>n.dataset(),r))}var Vx=Object.assign(Vl,{Control:Ll,Description:ng,ErrorMessage:rg,Input:_l,Label:kl,Thumb:Nl});const ma=Vl,va=e=>{const[t,n]=_(e,["class","children"]);return[w(_l,{get class(){return ce("[&:focus-visible+div]:outline-none [&:focus-visible+div]:ring-2 [&:focus-visible+div]:ring-ring [&:focus-visible+div]:ring-offset-2 [&:focus-visible+div]:ring-offset-background",t.class)}}),w(Ll,F({get class(){return ce("inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-input transition-[color,background-color,box-shadow] data-[disabled]:cursor-not-allowed data-[checked]:bg-primary data-[disabled]:opacity-50",t.class)}},n,{get children(){return t.children}}))]},ya=e=>{const[t,n]=_(e,["class"]);return w(Nl,F({get class(){return ce("pointer-events-none block size-5 translate-x-0 rounded-full bg-background shadow-lg ring-0 transition-transform data-[checked]:translate-x-5",t.class)}},n))},wa=e=>{const[t,n]=_(e,["class"]);return w(kl,F({get class(){return ce("text-sm font-medium leading-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-70",t.class)}},n))};var Nx={};dt(Nx,{Description:()=>Oo,ErrorMessage:()=>Fo,Input:()=>zl,Label:()=>kr,Root:()=>Bl,TextArea:()=>sg,TextField:()=>zx,useTextFieldContext:()=>Kl});var og=Ce();function Kl(){const e=xe(og);if(e===void 0)throw new Error("[kobalte]: `useTextFieldContext` must be used within a `TextField` component");return e}function zl(e){return w(ig,F({type:"text"},e))}function ig(e){const t=it(),n=Kl(),r=Z({id:n.generateId("input")},e),[o,i,s]=_(r,["onInput"],Al),{fieldProps:a}=Tl(i);return w(le,F({as:"input",get id(){return a.id()},get name(){return t.name()},get value(){return n.value()},get required(){return t.isRequired()},get disabled(){return t.isDisabled()},get readonly(){return t.isReadOnly()},get"aria-label"(){return a.ariaLabel()},get"aria-labelledby"(){return a.ariaLabelledBy()},get"aria-describedby"(){return a.ariaDescribedBy()},get"aria-invalid"(){return t.validationState()==="invalid"||void 0},get"aria-required"(){return t.isRequired()||void 0},get"aria-disabled"(){return t.isDisabled()||void 0},get"aria-readonly"(){return t.isReadOnly()||void 0},get onInput(){return ye([o.onInput,n.onInput])}},()=>t.dataset(),s))}function Bl(e){let t;const n=`textfield-${Ie()}`,r=Z({id:n},e),[o,i,s]=_(r,["ref","value","defaultValue","onChange"],Fl),a=o.value,[l,c]=wt({value:()=>a===void 0?void 0:o.value??"",defaultValue:()=>o.defaultValue,onChange:h=>{var p;return(p=o.onChange)==null?void 0:p.call(o,h)}}),{formControlContext:u}=$l(i);Dl(()=>t,()=>c(o.defaultValue??""));const f=h=>{if(u.isReadOnly()||u.isDisabled())return;const p=h.target;c(p.value),p.value=l()??""},d={value:l,generateId:Ye(()=>T(i.id)),onInput:f};return w(Li.Provider,{value:u,get children(){return w(og.Provider,{value:d,get children(){return w(le,F({as:"div",ref(h){var p=me(g=>t=g,o.ref);typeof p=="function"&&p(h)},role:"group",get id(){return T(i.id)}},()=>u.dataset(),s))}})}})}function sg(e){let t;const n=Kl(),r=Z({id:n.generateId("textarea")},e),[o,i]=_(r,["ref","autoResize","submitOnEnter","onKeyPress"]);j(Ee([()=>t,()=>o.autoResize,()=>n.value()],([a,l])=>{!a||!l||Kx(a)}));const s=a=>{t&&o.submitOnEnter&&a.key==="Enter"&&!a.shiftKey&&t.form&&(t.form.requestSubmit(),a.preventDefault())};return w(ig,F({as:"textarea",get"aria-multiline"(){return o.submitOnEnter?"false":void 0},get onKeyPress(){return ye([o.onKeyPress,s])},ref(a){var l=me(c=>t=c,o.ref);typeof l=="function"&&l(a)}},i))}function Kx(e){const t=e.style.alignSelf,n=e.style.overflow;"MozAppearance"in e.style||(e.style.overflow="hidden"),e.style.alignSelf="start",e.style.height="auto",e.style.height=`${e.scrollHeight+(e.offsetHeight-e.clientHeight)}px`,e.style.overflow=n,e.style.alignSelf=t}var zx=Object.assign(Bl,{Description:Oo,ErrorMessage:Fo,Input:zl,Label:kr,TextArea:sg});const ii=Bl,Is=e=>{const[t,n]=_(e,["type","class"]);return w(zl,F({get type(){return t.type},get class(){return ce("flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50",t.class)}},n))},Bx=Mr("text-sm font-medium leading-none peer-disabled:opacity-70",{variants:{variant:{label:"data-[invalid]:text-destructive",description:"text-destructive",error:"font-normal text-red-500"}},defaultVariants:{variant:"label"}}),si=e=>{const[t,n]=_(e,["class"]);return w(kr,F({get class(){return ce(Bx(),t.class)}},n))};var nd=te("<div>"),jx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Platform: <p class="ml-2 flex flex-row items-center"> iOS'),Ux=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Platform: <p class="ml-2 flex flex-row items-center"> Android'),Hx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Channel: <p class=ml-2>'),Gx=te('<form class="flex flex-col gap-3 flex-1"><div></div><div><div class="flex items-center space-x-2"></div><p class="text-xs text-muted-foreground mt-[2px]">When disabled, this update will not be available to your users.</p></div><div><div class="flex items-center space-x-2"></div><p class="text-xs text-muted-foreground mt-[2px]">When enabled, this update will require users to update before continuing to use the application.</p></div><div class="mt-2 space-y-1"><h3 class="text-md text-bold font-medium">Metadata'),qx=te('<em class="text-xs text-red-500">'),Wx=te('<em class="text-xs text-muted-foreground">'),Qx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">App Version: <p class=ml-2>'),Xx=te('<div class="text-sm text-muted-foreground flex flex-row items-center">Commit Hash: '),Yx=te("<a target=_blank rel=noreferrer class=ml-2>"),Jx=te("<p class=ml-2>");const Zx=({bundle:e,onEditSuccess:t})=>{const n=yo(),r=US(),[o,i]=z(!1),s=L(()=>{var u,f;return((f=(u=r.data)==null?void 0:u.console)==null?void 0:f.gitUrl)??null}),a=L(()=>e.gitCommitHash),l=Sx(()=>({defaultValues:{message:e.message,targetAppVersion:e.targetAppVersion,enabled:e.enabled,shouldForceUpdate:e.shouldForceUpdate},onSubmit:async({value:u})=>{i(!0);try{const f=await wn.bundles[":bundleId"].$patch({param:{bundleId:e.id},json:u});if(f.status!==200){const d=await f.json();Yt({title:"Error",description:d.error,variant:"error"})}}catch(f){f instanceof Error&&Yt({title:"Error",description:f.message,variant:"error"})}finally{i(!1),n.invalidateQueries({queryKey:["bundle",e.id]}),n.invalidateQueries({queryKey:["bundles"]}),n.invalidateQueries({queryKey:["channels"]}),t()}}})),c=l.useStore(u=>u.isValid);return(()=>{var u=Gx(),f=u.firstChild,d=f.nextSibling,h=d.firstChild,p=d.nextSibling,g=p.firstChild,v=p.nextSibling;return v.firstChild,u.addEventListener("submit",m=>{m.preventDefault(),m.stopPropagation(),l.handleSubmit()}),W(f,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"message",children:"Message"}),w(l.Field,{name:"message",children:m=>w(Is,{type:"text",id:"message",placeholder:"Message",get name(){return m().name},get value(){return m().state.value??""},get onBlur(){return m().handleBlur},onInput:y=>m().handleChange(y.currentTarget.value)})})]}})),W(u,w(de,{get when(){return e.targetAppVersion},get children(){var m=nd();return W(m,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"targetAppVersion",children:"Target App Version"}),w(l.Field,{name:"targetAppVersion",validators:{onChange:({value:y})=>{if((y==null?void 0:y.length)===0||!td(y))return"Invalid target app version"}},children:y=>[w(Is,{type:"text",id:"targetAppVersion",get class(){return ce(y().state.meta.errors.length>0&&"border-red-500 focus-visible:ring-red-500")},placeholder:"Target App Version",get name(){return y().name},get value(){return y().state.value??""},get onBlur(){return y().handleBlur},onInput:b=>y().handleChange(b.currentTarget.value)}),L(()=>L(()=>y().state.meta.errors.length>0)()?(()=>{var b=qx();return W(b,()=>y().state.meta.errors.join(", ")),b})():(()=>{var b=Wx();return W(b,()=>td(y().state.value)),b})())]})]}})),m}}),d),W(u,w(de,{get when(){return e.fingerprintHash},get children(){var m=nd();return W(m,w(ii,{class:"grid w-full max-w-sm items-center gap-1.5",get children(){return[w(si,{for:"fingerprintHash",children:"Fingerprint Hash"}),w(Is,{type:"text",id:"fingerprintHash",get value(){return e.fingerprintHash??""},disabled:!0})]}})),m}}),d),W(h,w(l.Field,{name:"enabled",children:m=>w(ma,{class:"flex items-center space-x-2",get checked(){return m().state.value},get name(){return m().name},onChange:y=>m().handleChange(y),get children(){return[w(va,{get children(){return w(ya,{})}}),w(wa,{children:"Enabled"})]}})})),W(g,w(l.Field,{name:"shouldForceUpdate",children:m=>w(ma,{class:"flex items-center space-x-2",get checked(){return m().state.value},get name(){return m().name},onChange:y=>m().handleChange(y),get children(){return[w(va,{get children(){return w(ya,{})}}),w(wa,{children:"Force Update"})]}})})),W(u,w(de,{get when(){return!o()},get fallback(){return w(fn,{type:"submit",class:"mt-4",disabled:!0,get children(){return w(lw,{class:"animate-spin"})}})},get children(){return w(fn,{type:"submit",class:"mt-4",get disabled(){return!c()},children:"Save"})}}),v),W(v,w(de,{get when(){return e.platform==="ios"},get children(){var m=jx(),y=m.firstChild,b=y.nextSibling,S=b.firstChild;return W(b,w(Nf,{class:"inline-block"}),S),m}}),null),W(v,w(de,{get when(){return e.platform==="android"},get children(){var m=Ux(),y=m.firstChild,b=y.nextSibling,S=b.firstChild;return W(b,w(Vf,{class:"inline-block"}),S),m}}),null),W(v,w(de,{get when(){var m;return(m=e.metadata)==null?void 0:m.app_version},children:m=>(()=>{var y=Qx(),b=y.firstChild,S=b.nextSibling;return W(S,m),y})()}),null),W(v,w(de,{get when(){return e.channel},get children(){var m=Hx(),y=m.firstChild,b=y.nextSibling;return W(b,()=>e.channel),m}}),null),W(v,w(de,{get when(){return a()},children:m=>(()=>{var y=Xx();return y.firstChild,W(y,(()=>{var b=L(()=>!!s());return()=>b()?(()=>{var S=Yx();return W(S,()=>m().slice(0,8)),Ve(()=>Ln(S,"href",`${s()}/commit/${m()}`)),S})():(()=>{var S=Jx();return W(S,()=>m().slice(0,8)),S})()})(),null),y})()}),null),u})()};var ag=te("<div>");const eC=Mr("rounded-md border-l-4 p-2 pl-4",{variants:{variant:{default:"border-info-foreground bg-info text-info-foreground",success:"border-success-foreground bg-success text-success-foreground",warning:"border-warning-foreground bg-warning text-warning-foreground",error:"border-error-foreground bg-error text-error-foreground"}},defaultVariants:{variant:"default"}}),tC=e=>{const[t,n]=_(e,["class","variant"]);return(()=>{var r=ag();return qe(r,F({get class(){return ce(eC({variant:t.variant}),t.class)}},n),!1,!1),r})()},nC=e=>{const[t,n]=_(e,["class"]);return(()=>{var r=ag();return qe(r,F({get class(){return ce("mt-2",t.class)}},n),!1,!1),r})()};var rC=te("<option>"),oC=te("<div aria-hidden=true><input type=text><select tabindex=-1><option>");function iC(e){let t;const[n,r]=_(e,["ref","onChange","collection","selectionManager","isOpen","isMultiple","isVirtualized","focusTrigger"]),o=it(),[i,s]=z(!1),a=l=>{const c=n.collection.getItem(l);return w(de,{get when(){return(c==null?void 0:c.type)==="item"},get children(){var u=rC();return u.value=l,W(u,()=>c==null?void 0:c.textValue),Ve(()=>u.selected=n.selectionManager.isSelected(l)),u}})};return j(Ee(()=>n.selectionManager.selectedKeys(),(l,c)=>{c&&dh(l,c)||(s(!0),t==null||t.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t==null||t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0})))},{defer:!0})),(()=>{var l=oC(),c=l.firstChild,u=c.nextSibling;u.firstChild,c.addEventListener("focus",()=>n.focusTrigger()),c.style.setProperty("font-size","16px"),u.addEventListener("change",d=>{ee(d,n.onChange),i()||n.selectionManager.setSelectedKeys(new Set([d.target.value])),s(!1)});var f=me(d=>t=d,n.ref);return typeof f=="function"&&Pd(f,u),qe(u,F({get multiple(){return n.isMultiple},get name(){return o.name()},get required(){return o.isRequired()},get disabled(){return o.isDisabled()},get size(){return n.collection.getSize()},get value(){return n.selectionManager.firstSelectedKey()??""}},r),!1,!0),W(u,w(de,{get when(){return n.isVirtualized},get fallback(){return w(et,{get each(){return[...n.collection.getKeys()]},children:a})},get children(){return w(et,{get each(){return[...n.selectionManager.selectedKeys()]},children:a})}}),null),Ve(d=>{var h=Ci,p=n.selectionManager.isFocused()||n.isOpen?-1:0,g=o.isRequired(),v=o.isDisabled(),m=o.isReadOnly();return d.e=Id(l,h,d.e),p!==d.t&&Ln(c,"tabindex",d.t=p),g!==d.a&&(c.required=d.a=g),v!==d.o&&(c.disabled=d.o=v),m!==d.i&&(c.readOnly=d.i=m),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),l})()}var rd=new WeakMap;function ba(e){let t=rd.get(e);if(t!=null)return t;t=0;for(const n of e)n.type==="item"&&t++;return rd.set(e,t),t}var sC={};dt(sC,{Item:()=>$o,ItemDescription:()=>_i,ItemIndicator:()=>Ao,ItemLabel:()=>To,Listbox:()=>aC,Root:()=>Ul,Section:()=>ki,useListboxContext:()=>ug});var lg=Ce();function ug(){const e=xe(lg);if(e===void 0)throw new Error("[kobalte]: `useListboxContext` must be used within a `Listbox` component");return e}var cg=Ce();function jl(){const e=xe(cg);if(e===void 0)throw new Error("[kobalte]: `useListboxItemContext` must be used within a `Listbox.Item` component");return e}function $o(e){let t;const n=ug(),r=`${n.generateId("item")}-${Ie()}`,o=Z({id:r},e),[i,s]=_(o,["ref","item","aria-label","aria-labelledby","aria-describedby","onPointerMove","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=z(),[c,u]=z(),f=()=>n.listState().selectionManager(),d=()=>f().focusedKey()===i.item.key,h=ul({key:()=>i.item.key,selectionManager:f,shouldSelectOnPressUp:n.shouldSelectOnPressUp,allowsDifferentPressOrigin:()=>n.shouldSelectOnPressUp()&&n.shouldFocusOnHover(),shouldUseVirtualFocus:n.shouldUseVirtualFocus,disabled:()=>i.item.disabled},()=>t),p=()=>{if(f().selectionMode()!=="none")return h.isSelected()},g=L(()=>!(wo()&&Dm())),v=()=>g()?i["aria-label"]:void 0,m=()=>g()?a():void 0,y=()=>g()?c():void 0,b=()=>{var $;if(!n.isVirtualized())return;const V=($=n.listState().collection().getItem(i.item.key))==null?void 0:$.index;return V!=null?V+1:void 0},S=()=>{if(n.isVirtualized())return ba(n.listState().collection())},C=V=>{ee(V,i.onPointerMove),V.pointerType==="mouse"&&!h.isDisabled()&&n.shouldFocusOnHover()&&(Fe(V.currentTarget),f().setFocused(!0),f().setFocusedKey(i.item.key))},R=L(()=>({"data-disabled":h.isDisabled()?"":void 0,"data-selected":h.isSelected()?"":void 0,"data-highlighted":d()?"":void 0})),D={isSelected:h.isSelected,dataset:R,generateId:Ye(()=>s.id),registerLabelId:_e(l),registerDescriptionId:_e(u)};return w(cg.Provider,{value:D,get children(){return w(le,F({as:"li",ref(V){var $=me(k=>t=k,i.ref);typeof $=="function"&&$(V)},role:"option",get tabIndex(){return h.tabIndex()},get"aria-disabled"(){return h.isDisabled()},get"aria-selected"(){return p()},get"aria-label"(){return v()},get"aria-labelledby"(){return m()},get"aria-describedby"(){return y()},get"aria-posinset"(){return b()},get"aria-setsize"(){return S()},get"data-key"(){return h.dataKey()},get onPointerDown(){return ye([i.onPointerDown,h.onPointerDown])},get onPointerUp(){return ye([i.onPointerUp,h.onPointerUp])},get onClick(){return ye([i.onClick,h.onClick])},get onKeyDown(){return ye([i.onKeyDown,h.onKeyDown])},get onMouseDown(){return ye([i.onMouseDown,h.onMouseDown])},get onFocus(){return ye([i.onFocus,h.onFocus])},onPointerMove:C},R,s))}})}function _i(e){const t=jl(),n=Z({id:t.generateId("description")},e);return j(()=>Y(t.registerDescriptionId(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}function Ao(e){const t=jl(),n=Z({id:t.generateId("indicator")},e),[r,o]=_(n,["forceMount"]);return w(de,{get when(){return r.forceMount||t.isSelected()},get children(){return w(le,F({as:"div","aria-hidden":"true"},()=>t.dataset(),o))}})}function To(e){const t=jl(),n=Z({id:t.generateId("label")},e);return j(()=>Y(t.registerLabelId(n.id))),w(le,F({as:"div"},()=>t.dataset(),n))}function Ul(e){let t;const n=`listbox-${Ie()}`,r=Z({id:n,selectionMode:"single",virtualized:!1},e),[o,i]=_(r,["ref","children","renderItem","renderSection","value","defaultValue","onChange","options","optionValue","optionTextValue","optionDisabled","optionGroupChildren","state","keyboardDelegate","autoFocus","selectionMode","shouldFocusWrap","shouldUseVirtualFocus","shouldSelectOnPressUp","shouldFocusOnHover","allowDuplicateSelectionEvents","disallowEmptySelection","selectionBehavior","selectOnFocus","disallowTypeAhead","allowsTabNavigation","virtualized","scrollToItem","scrollRef","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]),s=L(()=>o.state?o.state:cl({selectedKeys:()=>o.value,defaultSelectedKeys:()=>o.defaultValue,onSelectionChange:o.onChange,allowDuplicateSelectionEvents:()=>T(o.allowDuplicateSelectionEvents),disallowEmptySelection:()=>T(o.disallowEmptySelection),selectionBehavior:()=>T(o.selectionBehavior),selectionMode:()=>T(o.selectionMode),dataSource:()=>o.options??[],getKey:()=>o.optionValue,getTextValue:()=>o.optionTextValue,getDisabled:()=>o.optionDisabled,getSectionChildren:()=>o.optionGroupChildren})),a=gh({selectionManager:()=>s().selectionManager(),collection:()=>s().collection(),autoFocus:()=>T(o.autoFocus),shouldFocusWrap:()=>T(o.shouldFocusWrap),keyboardDelegate:()=>o.keyboardDelegate,disallowEmptySelection:()=>T(o.disallowEmptySelection),selectOnFocus:()=>T(o.selectOnFocus),disallowTypeAhead:()=>T(o.disallowTypeAhead),shouldUseVirtualFocus:()=>T(o.shouldUseVirtualFocus),allowsTabNavigation:()=>T(o.allowsTabNavigation),isVirtualized:()=>o.virtualized,scrollToKey:()=>o.scrollToItem},()=>t,()=>{var c;return(c=o.scrollRef)==null?void 0:c.call(o)}),l={listState:s,generateId:Ye(()=>i.id),shouldUseVirtualFocus:()=>r.shouldUseVirtualFocus,shouldSelectOnPressUp:()=>r.shouldSelectOnPressUp,shouldFocusOnHover:()=>r.shouldFocusOnHover,isVirtualized:()=>o.virtualized};return w(lg.Provider,{value:l,get children(){return w(le,F({as:"ul",ref(c){var u=me(f=>t=f,o.ref);typeof u=="function"&&u(c)},role:"listbox",get tabIndex(){return a.tabIndex()},get"aria-multiselectable"(){return s().selectionManager().selectionMode()==="multiple"?!0:void 0},get onKeyDown(){return ye([o.onKeyDown,a.onKeyDown])},get onMouseDown(){return ye([o.onMouseDown,a.onMouseDown])},get onFocusIn(){return ye([o.onFocusIn,a.onFocusIn])},get onFocusOut(){return ye([o.onFocusOut,a.onFocusOut])}},i,{get children(){return w(de,{get when(){return!o.virtualized},get fallback(){var c;return(c=o.children)==null?void 0:c.call(o,s().collection)},get children(){return w(Pm,{get each(){return[...s().collection()]},by:"key",children:c=>w(Tg,{get children(){return[w(du,{get when(){return c().type==="section"},get children(){var u;return(u=o.renderSection)==null?void 0:u.call(o,c())}}),w(du,{get when(){return c().type==="item"},get children(){var u;return(u=o.renderItem)==null?void 0:u.call(o,c())}})]}})})}})}}))}})}function ki(e){return w(le,F({as:"li",role:"presentation"},e))}var aC=Object.assign(Ul,{Item:$o,ItemDescription:_i,ItemIndicator:Ao,ItemLabel:To,Section:ki}),dg=Ce();function Ht(){const e=xe(dg);if(e===void 0)throw new Error("[kobalte]: `useComboboxContext` must be used within a `Combobox` component");return e}function Hl(e){let t;const n=Ht(),[r,o]=_(e,["ref","style","onCloseAutoFocus","onFocusOutside"]),i=()=>{n.resetInputValue(n.listState().selectionManager().selectedKeys()),n.close(),setTimeout(()=>{n.close()})},s=a=>{var l;(l=r.onFocusOutside)==null||l.call(r,a),n.isOpen()&&n.isModal()&&a.preventDefault()};return Ha({isDisabled:()=>!(n.isOpen()&&n.isModal()),targets:()=>{const a=[];t&&a.push(t);const l=n.controlRef();return l&&a.push(l),a}}),Ga({element:()=>t??null,enabled:()=>n.contentPresent()&&n.preventScroll()}),Ua({trapFocus:()=>n.isOpen()&&n.isModal(),onMountAutoFocus:a=>{a.preventDefault()},onUnmountAutoFocus:a=>{var l;(l=r.onCloseAutoFocus)==null||l.call(r,a),a.defaultPrevented||(Fe(n.inputRef()),a.preventDefault())}},()=>t),w(de,{get when(){return n.contentPresent()},get children(){return w(Cn.Positioner,{get children(){return w(xo,F({ref(a){var l=me(c=>{n.setContentRef(c),t=c},r.ref);typeof l=="function"&&l(a)},get disableOutsidePointerEvents(){return L(()=>!!n.isModal())()&&n.isOpen()},get excludedElements(){return[n.controlRef]},get style(){return ct({"--kb-combobox-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative"},r.style)},onFocusOutside:s,onDismiss:i},()=>n.dataset(),o))}})}})}function Gl(e){let t;const n=it(),r=Ht(),o=Z({id:r.generateId("input")},e),[i,s,a]=_(o,["ref","disabled","onClick","onInput","onKeyDown","onFocus","onBlur","onTouchEnd"],Al),l=()=>r.listState().collection(),c=()=>r.listState().selectionManager(),u=()=>i.disabled||r.isDisabled()||n.isDisabled(),{fieldProps:f}=Tl(s),d=b=>{ee(b,i.onClick),r.triggerMode()==="focus"&&!r.isOpen()&&r.open(!1,"focus")},h=b=>{if(ee(b,i.onInput),n.isReadOnly()||u())return;const S=b.target;r.setInputValue(S.value),S.value=r.inputValue()??"",r.isOpen()?l().getSize()<=0&&!r.allowsEmptyCollection()&&r.close():(l().getSize()>0||r.allowsEmptyCollection())&&r.open(!1,"input")},p=b=>{if(ee(b,i.onKeyDown),!(n.isReadOnly()||u()))switch(r.isOpen()&&ee(b,r.onInputKeyDown),b.key){case"Enter":if(r.isOpen()){b.preventDefault();const S=c().focusedKey();S!=null&&c().select(S)}break;case"Tab":r.isOpen()&&(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys()));break;case"Escape":r.isOpen()?(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys())):r.setInputValue("");break;case"ArrowDown":r.isOpen()||r.open(b.altKey?!1:"first","manual");break;case"ArrowUp":r.isOpen()?b.altKey&&(r.close(),r.resetInputValue(r.listState().selectionManager().selectedKeys())):r.open("last","manual");break;case"ArrowLeft":case"ArrowRight":c().setFocusedKey(void 0);break;case"Backspace":if(r.removeOnBackspace()&&c().selectionMode()==="multiple"&&r.inputValue()===""){const S=[...c().selectedKeys()].pop()??"";c().toggleSelection(S)}break}},g=b=>{ee(b,i.onFocus),!r.isInputFocused()&&r.setIsInputFocused(!0)},v=b=>{ee(b,i.onBlur),!($e(r.controlRef(),b.relatedTarget)||$e(r.contentRef(),b.relatedTarget))&&r.setIsInputFocused(!1)};let m=0;return w(le,F({as:"input",ref(b){var S=me(C=>{r.setInputRef(C),t=C},i.ref);typeof S=="function"&&S(b)},get id(){return f.id()},get value(){return r.inputValue()},get required(){return n.isRequired()},get disabled(){return n.isDisabled()},get readonly(){return n.isReadOnly()},get placeholder(){return r.placeholder()},type:"text",role:"combobox",autoComplete:"off",autoCorrect:"off",spellCheck:"false","aria-haspopup":"listbox","aria-autocomplete":"list",get"aria-expanded"(){return r.isOpen()},get"aria-controls"(){return L(()=>!!r.isOpen())()?r.listboxId():void 0},get"aria-activedescendant"(){return r.activeDescendant()},get"aria-label"(){return f.ariaLabel()},get"aria-labelledby"(){return f.ariaLabelledBy()},get"aria-describedby"(){return f.ariaDescribedBy()},get"aria-invalid"(){return n.validationState()==="invalid"||void 0},get"aria-required"(){return n.isRequired()||void 0},get"aria-disabled"(){return n.isDisabled()||void 0},get"aria-readonly"(){return n.isReadOnly()||void 0},onClick:d,onInput:h,onKeyDown:p,onFocus:g,onBlur:v,onTouchEnd:b=>{if(ee(b,i.onTouchEnd),!t||n.isReadOnly()||u())return;if(b.timeStamp-m<500){b.preventDefault(),t.focus();return}const S=b.target.getBoundingClientRect(),C=b.changedTouches[0],R=Math.ceil(S.left+.5*S.width),D=Math.ceil(S.top+.5*S.height);C.clientX===R&&C.clientY===D&&(b.preventDefault(),t.focus(),r.toggle(!1,"manual"),m=b.timeStamp)}},()=>r.dataset(),()=>n.dataset(),a))}function ql(e){const t=it(),n=Ht(),r=Z({id:n.generateId("listbox")},e),[o,i]=_(r,["ref"]),s=()=>t.getAriaLabelledBy(i.id,n.listboxAriaLabel(),void 0);return j(()=>Y(n.registerListboxId(i.id))),w(Ul,F({ref(a){var l=me(n.setListboxRef,o.ref);typeof l=="function"&&l(a)},get state(){return n.listState()},get autoFocus(){return n.autoFocus()},shouldUseVirtualFocus:!0,shouldSelectOnPressUp:!0,shouldFocusOnHover:!0,get"aria-label"(){return n.listboxAriaLabel()},get"aria-labelledby"(){return s()},get renderItem(){return n.renderItem},get renderSection(){return n.renderSection},get virtualized(){return n.isVirtualized()}},i))}function Wl(e){const t=Ht();return w(de,{get when(){return t.contentPresent()},get children(){return w(mo,e)}})}function Ql(e){const t=it(),n=Ht(),[r,o]=_(e,["ref","children"]),i=()=>n.listState().selectionManager();return w(le,F({as:"div",ref(s){var a=me(n.setControlRef,r.ref);typeof a=="function"&&a(s)}},()=>n.dataset(),()=>t.dataset(),o,{get children(){return w(lC,{state:{selectedOptions:()=>n.selectedOptions(),remove:s=>n.removeOptionFromSelection(s),clear:()=>i().clearSelection()},get children(){return r.children}})}}))}function lC(e){const t=xr(()=>{const n=e.children;return un(n)?n(e.state):n});return L(t)}function fg(e){const t=Ht();return w(iC,F({get collection(){return t.listState().collection()},get selectionManager(){return t.listState().selectionManager()},get isOpen(){return t.isOpen()},get isMultiple(){return t.isMultiple()},get isVirtualized(){return t.isVirtualized()},focusTrigger:()=>{var n;return(n=t.inputRef())==null?void 0:n.focus()}},e))}function Xl(e){const t=Ht(),n=Z({children:"▼"},e);return w(le,F({as:"span","aria-hidden":"true"},()=>t.dataset(),n))}var uC={focusAnnouncement:(e,t)=>`${e}${t?", selected":""}`,countAnnouncement:e=>{switch(e){case 1:return"one option available"}},selectedAnnouncement:e=>`${e}, selected`,triggerLabel:"Show suggestions",listboxLabel:"Suggestions"};function cC(e){const t=`combobox-${Ie()}`,n=Cw({sensitivity:"base"}),r=Z({id:t,selectionMode:"single",allowsEmptyCollection:!1,disallowEmptySelection:!1,allowDuplicateSelectionEvents:!0,closeOnSelection:e.selectionMode==="single",removeOnBackspace:!0,gutter:8,sameWidth:!0,modal:!1,defaultFilter:"contains",triggerMode:"input",translations:uC},e),[o,i,s,a]=_(r,["noResetInputOnBlur","translations","itemComponent","sectionComponent","open","defaultOpen","onOpenChange","onInputChange","value","defaultValue","onChange","triggerMode","placeholder","options","optionValue","optionTextValue","optionLabel","optionDisabled","optionGroupChildren","keyboardDelegate","allowDuplicateSelectionEvents","disallowEmptySelection","defaultFilter","shouldFocusWrap","allowsEmptyCollection","closeOnSelection","removeOnBackspace","selectionBehavior","selectionMode","virtualized","modal","preventScroll","forceMount"],["getAnchorRect","placement","gutter","shift","flip","slide","overlap","sameWidth","fitViewport","hideWhenDetached","detachedPadding","arrowPadding","overflowPadding"],Fl),[l,c]=z(),[u,f]=z(),[d,h]=z(),[p,g]=z(),[v,m]=z(),[y,b]=z(),[S,C]=z(!1),[R,D]=z(!1),[V,$]=z(!1),[k,N]=z(o.options),B=Co({open:()=>o.open,defaultOpen:()=>o.defaultOpen,onOpenChange:U=>{var G;return(G=o.onOpenChange)==null?void 0:G.call(o,U,q)}}),[ne,I]=wt({defaultValue:()=>"",onChange:U=>{var G;(G=o.onInputChange)==null||G.call(o,U),U===""&&o.selectionMode==="single"&&!J.selectionManager().isEmpty()&&o.value===void 0&&J.selectionManager().setSelectedKeys([]),J.selectionManager().setFocusedKey(void 0)}}),M=U=>{const G=o.optionValue;return G==null?String(U):String(un(G)?G(U):U[G])},x=U=>{const G=o.optionLabel;return G==null?String(U):String(un(G)?G(U):U[G])},O=U=>{const G=o.optionTextValue;return G==null?String(U):String(un(G)?G(U):U[G])},P=L(()=>{const U=o.optionGroupChildren;return U==null?o.options:o.options.flatMap(G=>G[U]??G)}),A=U=>{var De;const G=ne()??"";if(un(o.defaultFilter))return(De=o.defaultFilter)==null?void 0:De.call(o,U,G);const we=O(U);switch(o.defaultFilter){case"startsWith":return n.startsWith(we,G);case"endsWith":return n.endsWith(we,G);case"contains":return n.contains(we,G)}},K=L(()=>{const U=o.optionGroupChildren;if(U==null)return o.options.filter(A);const G=[];for(const we of o.options){const De=we[U].filter(A);De.length!==0&&G.push({...we,[U]:De})}return G}),H=L(()=>B.isOpen()?V()?o.options:K():k());let q="focus";const oe=U=>[...U].map(G=>P().find(we=>M(we)===G)).filter(G=>G!=null),J=cl({selectedKeys:()=>o.value!=null?o.value.map(M):o.value,defaultSelectedKeys:()=>o.defaultValue!=null?o.defaultValue.map(M):o.defaultValue,onSelectionChange:U=>{var we;(we=o.onChange)==null||we.call(o,oe(U)),o.closeOnSelection&&B.isOpen()&&U.size>0&&(Pe(),setTimeout(Pe));const G=d();G&&(G.setSelectionRange(G.value.length,G.value.length),Fe(G))},allowDuplicateSelectionEvents:()=>T(o.allowDuplicateSelectionEvents),disallowEmptySelection:()=>o.disallowEmptySelection,selectionBehavior:()=>T(o.selectionBehavior),selectionMode:()=>o.selectionMode,dataSource:H,getKey:()=>o.optionValue,getTextValue:()=>o.optionTextValue,getDisabled:()=>o.optionDisabled,getSectionChildren:()=>o.optionGroupChildren}),fe=L(()=>oe(J.selectionManager().selectedKeys())),Le=U=>{J.selectionManager().toggleSelection(M(U))},{present:Je}=Vn({show:()=>o.forceMount||B.isOpen(),element:()=>v()??null}),ie=(U,G)=>{if(o.triggerMode==="manual"&&G!=="manual"||!($(G==="manual")?o.options.length>0:K().length>0)&&!o.allowsEmptyCollection)return;q=G,C(U),B.open();let qt=J.selectionManager().firstSelectedKey();qt==null&&(U==="first"?qt=J.collection().getFirstKey():U==="last"&&(qt=J.collection().getLastKey())),J.selectionManager().setFocused(!0),J.selectionManager().setFocusedKey(qt)},Pe=()=>{B.close(),J.selectionManager().setFocused(!1),J.selectionManager().setFocusedKey(void 0)},Te=(U,G)=>{B.isOpen()?Pe():ie(U,G)},{formControlContext:st}=$l(s);Dl(d,()=>{const U=o.defaultValue?[...o.defaultValue].map(M):new Rt;J.selectionManager().setSelectedKeys(U)});const Gt=L(()=>{const U=T(o.keyboardDelegate);return U||new hh(J.collection,y,void 0)}),Gn=fh({selectionManager:()=>J.selectionManager(),keyboardDelegate:Gt,disallowTypeAhead:!0,disallowEmptySelection:!0,shouldFocusWrap:()=>o.shouldFocusWrap,isVirtualized:!0},d),hg=U=>{U&&o.triggerMode==="focus"&&ie(!1,"focus"),D(U),J.selectionManager().setFocused(U)},gg=L(()=>{var G,we;const U=J.selectionManager().focusedKey();if(U)return(we=(G=y())==null?void 0:G.querySelector(`[data-key="${U}"]`))==null?void 0:we.id}),Zl=U=>{if(o.selectionMode==="single"){const G=[...U][0],we=P().find(De=>M(De)===G);if(o.noResetInputOnBlur&&!we)return;I(we?x(we):"")}else{if(o.noResetInputOnBlur)return;I("")}},pg=U=>{var G;return(G=o.itemComponent)==null?void 0:G.call(o,{item:U})},mg=U=>{var G;return(G=o.sectionComponent)==null?void 0:G.call(o,{section:U})};j(Ee([K,V],(U,G)=>{if(B.isOpen()&&G!=null){const we=G[0],De=G[1];N(De?o.options:we)}else{const we=U[0],De=U[1];N(De?o.options:we)}})),j(Ee(ne,()=>{V()&&$(!1)})),j(Ee(()=>J.selectionManager().selectedKeys(),Zl));let eu="";j(()=>{var we;const U=J.selectionManager().focusedKey()??"",G=J.collection().getItem(U);if(ti()&&G!=null&&U!==eu){const De=J.selectionManager().isSelected(U),qt=((we=o.translations)==null?void 0:we.focusAnnouncement((G==null?void 0:G.textValue)||"",De))??"";Qi(qt)}U&&(eu=U)});let tu=ba(J.collection()),nu=B.isOpen();j(()=>{var De;const U=ba(J.collection()),G=B.isOpen(),we=G!==nu&&(J.selectionManager().focusedKey()==null||ti());if(G&&(we||U!==tu)){const qt=((De=o.translations)==null?void 0:De.countAnnouncement(U))??"";Qi(qt)}tu=U,nu=G});let ru="";j(()=>{var we;const U=[...J.selectionManager().selectedKeys()].pop()??"",G=J.collection().getItem(U);if(ti()&&R()&&G&&U!==ru){const De=((we=o.translations)==null?void 0:we.selectedAnnouncement((G==null?void 0:G.textValue)||""))??"";Qi(De)}U&&(ru=U)});const ou=L(()=>({"data-expanded":B.isOpen()?"":void 0,"data-closed":B.isOpen()?void 0:""})),iu={dataset:ou,isOpen:B.isOpen,isDisabled:()=>st.isDisabled()??!1,isMultiple:()=>T(o.selectionMode)==="multiple",isVirtualized:()=>o.virtualized??!1,isModal:()=>o.modal??!1,preventScroll:()=>o.preventScroll??iu.isModal(),allowsEmptyCollection:()=>o.allowsEmptyCollection??!1,shouldFocusWrap:()=>o.shouldFocusWrap??!1,removeOnBackspace:()=>o.removeOnBackspace??!0,selectedOptions:fe,isInputFocused:R,contentPresent:Je,autoFocus:S,inputValue:ne,triggerMode:()=>o.triggerMode,activeDescendant:gg,controlRef:u,inputRef:d,triggerRef:p,contentRef:v,listState:()=>J,keyboardDelegate:Gt,listboxId:l,triggerAriaLabel:()=>{var U;return(U=o.translations)==null?void 0:U.triggerLabel},listboxAriaLabel:()=>{var U;return(U=o.translations)==null?void 0:U.listboxLabel},setIsInputFocused:hg,resetInputValue:Zl,setInputValue:I,setControlRef:f,setInputRef:h,setTriggerRef:g,setContentRef:m,setListboxRef:b,open:ie,close:Pe,toggle:Te,placeholder:()=>o.placeholder,renderItem:pg,renderSection:mg,removeOptionFromSelection:Le,onInputKeyDown:U=>Gn.onKeyDown(U),generateId:Ye(()=>T(s.id)),registerListboxId:_e(c)};return w(Li.Provider,{value:st,get children(){return w(dg.Provider,{value:iu,get children(){return w(Cn,F({anchorRef:u,contentRef:v},i,{get children(){return w(le,F({as:"div",role:"group",get id(){return T(s.id)}},()=>st.dataset(),ou,a))}}))}})}})}var dC={};dt(dC,{Arrow:()=>Dr,Combobox:()=>fC,Content:()=>Hl,Control:()=>Ql,Description:()=>Oo,ErrorMessage:()=>Fo,HiddenSelect:()=>fg,Icon:()=>Xl,Input:()=>Gl,Item:()=>$o,ItemDescription:()=>_i,ItemIndicator:()=>Ao,ItemLabel:()=>To,Label:()=>kr,Listbox:()=>ql,Portal:()=>Wl,Root:()=>Yl,Section:()=>ki,Trigger:()=>Jl,useComboboxContext:()=>Ht});function Yl(e){const[t,n]=_(e,["value","defaultValue","onChange","multiple"]),r=L(()=>t.value!=null?t.multiple?t.value:[t.value]:t.value),o=L(()=>t.defaultValue!=null?t.multiple?t.defaultValue:[t.defaultValue]:t.defaultValue);return w(cC,F({get value(){return r()},get defaultValue(){return o()},onChange:s=>{var a,l;t.multiple?(a=t.onChange)==null||a.call(t,s??[]):(l=t.onChange)==null||l.call(t,s[0]??null)},get selectionMode(){return t.multiple?"multiple":"single"}},n))}function Jl(e){const t=it(),n=Ht(),r=Z({id:n.generateId("trigger")},e),[o,i]=_(r,["ref","disabled","onPointerDown","onClick","aria-labelledby"]),s=()=>o.disabled||n.isDisabled()||t.isDisabled()||t.isReadOnly(),a=u=>{ee(u,o.onPointerDown),u.currentTarget.dataset.pointerType=u.pointerType,!s()&&u.pointerType!=="touch"&&u.button===0&&(u.preventDefault(),n.toggle(!1,"manual"))},l=u=>{var f;ee(u,o.onClick),s()||(u.currentTarget.dataset.pointerType==="touch"&&n.toggle(!1,"manual"),(f=n.inputRef())==null||f.focus())},c=()=>t.getAriaLabelledBy(i.id,n.triggerAriaLabel(),o["aria-labelledby"]);return w(xt,F({ref(u){var f=me(n.setTriggerRef,o.ref);typeof f=="function"&&f(u)},get disabled(){return s()},tabIndex:-1,"aria-haspopup":"listbox",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return L(()=>!!n.isOpen())()?n.listboxId():void 0},get"aria-label"(){return n.triggerAriaLabel()},get"aria-labelledby"(){return c()},onPointerDown:a,onClick:l},()=>n.dataset(),i))}var fC=Object.assign(Yl,{Arrow:Dr,Content:Hl,Control:Ql,Description:Oo,ErrorMessage:Fo,HiddenSelect:fg,Icon:Xl,Input:Gl,Item:$o,ItemDescription:_i,ItemIndicator:Ao,ItemLabel:To,Label:kr,Listbox:ql,Portal:Wl,Section:ki,Trigger:Jl}),hC=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M5 12l5 5l10 -10">'),gC=te('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M8 9l4 -4l4 4"></path><path d="M16 15l-4 4l-4 -4">');const pC=Yl,mC=To,vC=e=>{const[t,n]=_(e,["class"]);return w($o,F({get class(){return ce("relative flex cursor-default select-none items-center justify-between rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",t.class)}},n))},yC=e=>{const[t,n]=_(e,["children"]);return w(Ao,F(n,{get children(){return w(de,{get when(){return t.children},get fallback(){return hC()},children:r=>r()})}}))},wC=e=>{const[t,n]=_(e,["class"]);return w(Ql,F({get class(){return ce("flex h-10 items-center rounded-md border px-3",t.class)}},n))},bC=e=>{const[t,n]=_(e,["class"]);return w(Gl,F({get class(){return ce("flex size-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t.class)}},n))},SC=e=>{const[t,n]=_(e,["class","children"]);return w(Jl,F({get class(){return ce("size-4 opacity-50",t.class)}},n,{get children(){return w(Xl,{get children(){return w(de,{get when(){return t.children},get fallback(){return gC()},children:r=>r()})}})}}))},xC=e=>{const[t,n]=_(e,["class"]);return w(Wl,{get children(){return w(Hl,F({get class(){return ce("z-50 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-80",t.class)}},n,{get children(){return w(ql,{class:"m-0 p-1"})}}))}})};var CC=te('<div class="flex items-center justify-between"><div class=space-y-0.5><div class="text-sm text-muted-foreground">'),EC=te('<div class="mt-4 space-y-4">'),MC=te('<div class="h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent">'),IC=te('<div class="flex gap-2 justify-end mt-4">');const PC=({bundle:e})=>{const t=yo(),n=jh(),[,r]=Kd(),[o,i]=z(!1),[s,a]=z(e.channel),[l,c]=z(!1),[u,f]=z(!1),d=async()=>{i(!0);try{if(u()){const h={...e,id:Eb(e.id),channel:s()},p=await wn.bundles.$post({json:h});if(p.status!==200){const g=await p.json();"error"in g&&Yt({title:"Error",description:g.error,variant:"error"});return}Yt({title:"Success",description:`Created new bundle ${h.id} in ${s()}`,variant:"success"}),r({bundleId:void 0,channel:s()})}else{const h=await wn.bundles[":bundleId"].$patch({param:{bundleId:e.id},json:{channel:s()}});if(h.status!==200){const p=await h.json();Yt({title:"Error",description:p.error,variant:"error"});return}Yt({title:"Success",description:`Moved bundle ${e.id} to ${s()}`,variant:"success"}),r({bundleId:e.id,channel:s()})}t.invalidateQueries({queryKey:["bundle",e.id]}),t.invalidateQueries({queryKey:["bundles"]}),t.invalidateQueries({queryKey:["channels"]}),setTimeout(()=>c(!1),100)}catch(h){h instanceof Error&&Yt({title:"Error",description:h.message,variant:"error"})}finally{i(!1)}};return w(Uh,{get open(){return l()},onOpenChange:c,get children(){return[w(Hh,{as:fn,variant:"outline",size:"sm",class:"gap-2 flex-1",get children(){return[w(tc,{class:"h-4 w-4"}),"Promote Channel"]}}),w(Cl,{}),w(Gh,{get children(){return[w(qh,{children:"Promote Channel"}),w(Wh,{children:"Select or enter a new channel for this bundle. Choose whether to copy the bundle (keeps it in the original channel) or move it (removes from the original channel)."}),(()=>{var h=EC();return W(h,w(ma,{get checked(){return u()},onChange:f,get children(){var p=CC(),g=p.firstChild,v=g.firstChild;return W(g,w(wa,{class:"text-base",get children(){return u()?"Copy bundle":"Move bundle"}}),v),W(v,()=>u()?"Keep original + create copy in target channel":"Move to target channel (removes from current)"),W(p,w(va,{get children(){return w(ya,{})}}),null),p}}),null),W(h,w(de,{get when(){return u()},get children(){return w(tC,{variant:"default",get children(){return w(nC,{class:"mt-0 text-sm",children:"The copied bundle will have a new database ID that differs from the bundle ID inside the JavaScript bundle."})}})}}),null),W(h,w(ii,{class:"grid w-full items-center gap-1.5",get children(){return[w(si,{for:"channel",children:"Channel"}),w(pC,{get defaultValue(){return s()},get options(){return n.data??[]},onChange:p=>p&&a(p),onInputChange:p=>{a(p)},placeholder:"Enter or select a channel...",itemComponent:p=>w(vC,{get item(){return p.item},get children(){return[w(mC,{get children(){return p.item.rawValue}}),w(yC,{})]}}),get children(){return[w(wC,{"aria-label":"Channel",get children(){return[w(bC,{}),w(SC,{})]}}),w(xC,{})]}})]}}),null),h})(),(()=>{var h=IC();return W(h,w(Sn,{as:fn,variant:"outline",size:"sm",children:"Cancel"}),null),W(h,w(fn,{variant:"default",size:"sm",onClick:d,get disabled(){return o()||!s()},class:"gap-2",get children(){return[w(de,{get when(){return o()},get fallback(){return w(tc,{class:"h-4 w-4"})},get children(){return MC()}}),L(()=>L(()=>!!o())()?u()?"Copying...":"Moving...":u()?"Copy":"Move")]}}),null),h})()]}})]}})};var RC=te('<div class="mt-auto gap-3 pt-4 flex justify-between">');const OC=({bundleId:e,onClose:t})=>{const n=jS(e);return w(Ky,{class:"flex flex-col h-full",get children(){return[w(zy,{class:"mb-4",get children(){return w(By,{get children(){return["Edit ",e]}})}}),w(de,{get when(){return n.data},get fallback(){return L(()=>!!n.isFetched)()?w(jy,{get children(){return["No update bundle found for bundle id ",e]}}):w(JS,{height:374,radius:10})},children:r=>w(Zx,{get bundle(){return r()},onEditSuccess:t})}),(()=>{var r=RC();return W(r,w(de,{get when(){return n.data},children:o=>w(PC,{get bundle(){return o()}})}),null),W(r,w(sx,{bundleId:e,onDeleteSuccess:t}),null),r})()]}})};function FC(){const{bundleIdFilter:e,setBundleIdFilter:t}=Lf(),n=L(()=>e()!==null),r=()=>{t(null)};return w(Ly,{get open(){return n()},onOpenChange:o=>{o||t(null)},get children(){return[w(QS,{columns:Rb,onRowClick:o=>{t(o.id)}}),w(de,{get when(){return e()},get children(){return w(Lg,{get children(){return w(OC,{get bundleId(){return e()},onClose:r})}})}})]}})}const $C=new vm;function AC(){return w(dm,{client:$C,get children(){return[w(kp,{root:e=>w(ip,{get children(){return[w(lp,{children:"HotUpdater Console"}),w(bm,{get children(){return e.children}})]}}),get children(){return w(Fp,{path:"/",component:FC})}}),w(fy,{})]}})}const od=document.getElementById("root");od&&Gg(()=>w(AC,{}),od);
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/x-icon" href="/assets/favicon-BkwcEHsj.ico" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Hot Updater Console</title>
8
- <script type="module" crossorigin src="/assets/index-BTYk3GnI.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-ijmIcyn1.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DUlKsori.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/console",
3
3
  "type": "module",
4
- "version": "0.25.7",
4
+ "version": "0.25.9",
5
5
  "files": [
6
6
  "dist",
7
7
  "package.json"
@@ -48,13 +48,13 @@
48
48
  "vite": "^6.1.0",
49
49
  "vite-plugin-solid": "^2.11.1",
50
50
  "vite-tsconfig-paths": "^5.1.4",
51
- "@hot-updater/mock": "0.25.7"
51
+ "@hot-updater/mock": "0.25.9"
52
52
  },
53
53
  "dependencies": {
54
54
  "solid-icons": "^1.1.0",
55
- "@hot-updater/cli-tools": "0.25.7",
56
- "@hot-updater/plugin-core": "0.25.7",
57
- "@hot-updater/core": "0.25.7"
55
+ "@hot-updater/cli-tools": "0.25.9",
56
+ "@hot-updater/core": "0.25.9",
57
+ "@hot-updater/plugin-core": "0.25.9"
58
58
  },
59
59
  "description": "React Native OTA solution for self-hosted",
60
60
  "license": "MIT",