@astrale-os/cli 1.0.0-beta.4 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astrale.js +29682 -35214
- package/dist/public/connect-core.js +24198 -30085
- package/dist/public/keys/index.js +24086 -30014
- package/dist/public/paths/index.js +23680 -29365
- package/dist/types/lib/idp.d.ts +1 -0
- package/dist/types/lib/update.d.ts +30 -0
- package/package.json +8 -5
- package/src/admin/__tests__/binding.test.ts +3 -3
- package/src/admin/binding.ts +4 -4
- package/src/admin/catalog/.spec/api.d.ts +1 -1
- package/src/admin/instance/.spec/api.d.ts +1 -1
- package/src/commands/__tests__/update.test.ts +25 -3
- package/src/commands/update.ts +31 -11
- package/src/lib/__tests__/idp.test.ts +25 -0
- package/src/lib/__tests__/update.test.ts +101 -8
- package/src/lib/__tests__/view-open-intent.test.ts +0 -2
- package/src/lib/__tests__/view-server.test.ts +1 -1
- package/src/lib/__tests__/view-session.test.ts +1 -1
- package/src/lib/idp.ts +29 -1
- package/src/lib/update.ts +120 -26
- package/studio/client/dist/assets/{elk-api-lwhFo7vB.js → elk-api-YEDvaNU-.js} +1 -1
- package/studio/client/dist/assets/{index-BckHuAWk.js → index-C-PvAXV4.js} +2 -2
- package/studio/client/dist/assets/{index-B-c-smo9.js → index-CzpmJD0j.js} +4 -4
- package/studio/client/dist/index.html +1 -1
- package/studio/package.json +7 -9
- package/studio/server/introspect/runtime.test.ts +2 -2
- package/studio/shared/contracts/surface.test.ts +1 -0
- package/viewer/dist/main.js +27 -51
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CzpmJD0j.js","assets/index-ChOr3yP0.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
function NE(e,t){for(var r=0;r<t.length;r++){const i=t[r];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in e)){const s=Object.getOwnPropertyDescriptor(i,o);s&&Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const u of s.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function r(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(o){if(o.ep)return;o.ep=!0;const s=r(o);fetch(o.href,s)}})();function bc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh={exports:{}},Io={};var qv;function AE(){if(qv)return Io;qv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(i,o,s){var u=null;if(s!==void 0&&(u=""+s),o.key!==void 0&&(u=""+o.key),"key"in o){s={};for(var d in o)d!=="key"&&(s[d]=o[d])}else s=o;return o=s.ref,{$$typeof:e,type:i,key:u,ref:o!==void 0?o:null,props:s}}return Io.Fragment=t,Io.jsx=r,Io.jsxs=r,Io}var Fv;function TE(){return Fv||(Fv=1,oh.exports=AE()),oh.exports}var m=TE(),Bl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},OE=class extends Bl{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},zm=new OE,RE={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},_E=class{#e=RE;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Ci=new _E;function DE(e){setTimeout(e,0)}var ME=typeof window>"u"||"Deno"in globalThis;function sn(){}function zE(e,t){return typeof e=="function"?e(t):e}function Qh(e){return typeof e=="number"&&e>=0&&e!==1/0}function e1(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ua(e,t){return typeof e=="function"?e(t):e}function Bn(e,t){return typeof e=="function"?e(t):e}function $v(e,t){const{type:r="all",exact:i,fetchStatus:o,predicate:s,queryKey:u,stale:d}=e;if(u){if(i){if(t.queryHash!==Lm(u,t.options))return!1}else if(!Hl(t.queryKey,u))return!1}if(r!=="all"){const h=t.isActive();if(r==="active"&&!h||r==="inactive"&&h)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||o&&o!==t.state.fetchStatus||s&&!s(t))}function Vv(e,t){const{exact:r,status:i,predicate:o,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(r){if(Ni(t.options.mutationKey)!==Ni(s))return!1}else if(!Hl(t.options.mutationKey,s))return!1}return!(i&&t.state.status!==i||o&&!o(t))}function Lm(e,t){return(t?.queryKeyHashFn||Ni)(e)}function Ni(e){return JSON.stringify(e,(t,r)=>Gh(r)?Object.keys(r).sort().reduce((i,o)=>(i[o]=r[o],i),{}):r)}function Hl(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<t.length;i++)if(!Hl(e[i],t[i]))return!1;return!0}const r=Object.keys(t);for(const i of r)if(!Hl(e[i],t[i]))return!1;return!0}return!1}var LE=Object.prototype.hasOwnProperty;function t1(e,t,r=0){if(e===t)return e;if(r>500)return t;const i=Yv(e)&&Yv(t);if(!i&&!(Gh(e)&&Gh(t)))return t;const s=(i?e:Object.keys(e)).length,u=i?t:Object.keys(t),d=u.length,h=i?new Array(d):{};let f=0;for(let y=0;y<d;y++){const p=i?y:u[y],v=e[p],b=t[p];if(v===b){h[p]=v,(i?y<s:LE.call(e,p))&&f++;continue}if(v===null||b===null||typeof v!="object"||typeof b!="object"){h[p]=b;continue}const w=t1(v,b,r+1);h[p]=w,w===v&&f++}return s===d&&f===s?e:h}function lc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Yv(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gh(e){if(!Qv(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Qv(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Qv(e){return Object.prototype.toString.call(e)==="[object Object]"}function PE(e){return new Promise(t=>{Ci.setTimeout(t,e)})}function Kh(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?t1(e,t):t}function HE(e,t,r=0){const i=[...e,t];return r&&i.length>r?i.slice(1):i}function UE(e,t,r=0){const i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var Pm=Symbol();function n1(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Pm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Hm(e,t){return typeof e=="function"?e(...t):!!e}function BE(e,t,r){let i=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??=t(),i||(i=!0,o.aborted?r():o.addEventListener("abort",r,{once:!0})),o)}),e}var Jo=(()=>{let e=()=>ME;return{isServer(){return e()},setIsServer(t){e=t}}})();function Xh(){let e,t;const r=new Promise((o,s)=>{e=o,t=s});r.status="pending",r.catch(()=>{});function i(o){Object.assign(r,o),delete r.resolve,delete r.reject}return r.resolve=o=>{i({status:"fulfilled",value:o}),e(o)},r.reject=o=>{i({status:"rejected",reason:o}),t(o)},r}var IE=DE;function qE(){let e=[],t=0,r=d=>{d()},i=d=>{d()},o=IE;const s=d=>{t?e.push(d):o(()=>{r(d)})},u=()=>{const d=e;e=[],d.length&&o(()=>{i(()=>{d.forEach(h=>{r(h)})})})};return{batch:d=>{let h;t++;try{h=d()}finally{t--,t||u()}return h},batchCalls:d=>(...h)=>{s(()=>{d(...h)})},schedule:s,setNotifyFunction:d=>{r=d},setBatchNotifyFunction:d=>{i=d},setScheduler:d=>{o=d}}}var Ut=qE(),FE=class extends Bl{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},oc=new FE;function $E(e){return Math.min(1e3*2**e,3e4)}function r1(e){return(e??"online")==="online"?oc.isOnline():!0}var Zh=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function a1(e){let t=!1,r=0,i;const o=Xh(),s=()=>o.status!=="pending",u=C=>{if(!s()){const j=new Zh(C);v(j),e.onCancel?.(j)}},d=()=>{t=!0},h=()=>{t=!1},f=()=>zm.isFocused()&&(e.networkMode==="always"||oc.isOnline())&&e.canRun(),y=()=>r1(e.networkMode)&&e.canRun(),p=C=>{s()||(i?.(),o.resolve(C))},v=C=>{s()||(i?.(),o.reject(C))},b=()=>new Promise(C=>{i=j=>{(s()||f())&&C(j)},e.onPause?.()}).then(()=>{i=void 0,s()||e.onContinue?.()}),w=()=>{if(s())return;let C;const j=r===0?e.initialPromise:void 0;try{C=j??e.fn()}catch(E){C=Promise.reject(E)}Promise.resolve(C).then(p).catch(E=>{if(s())return;const N=e.retry??(Jo.isServer()?0:3),R=e.retryDelay??$E,P=typeof R=="function"?R(r,E):R,H=N===!0||typeof N=="number"&&r<N||typeof N=="function"&&N(r,E);if(t||!H){v(E);return}r++,e.onFail?.(r,E),PE(P).then(()=>f()?void 0:b()).then(()=>{t?v(E):w()})})};return{promise:o,status:()=>o.status,cancel:u,continue:()=>(i?.(),o),cancelRetry:d,continueRetry:h,canStart:y,start:()=>(y()?w():b().then(w),o)}}var i1=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qh(this.gcTime)&&(this.#e=Ci.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Jo.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Ci.clearTimeout(this.#e),this.#e=void 0)}};function VE(e){return{onFetch:(t,r)=>{const i=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],u=t.state.data?.pageParams||[];let d={pages:[],pageParams:[]},h=0;const f=async()=>{let y=!1;const p=w=>{BE(w,()=>t.signal,()=>y=!0)},v=n1(t.options,t.fetchOptions),b=async(w,C,j)=>{if(y)return Promise.reject(t.signal.reason);if(C==null&&w.pages.length)return Promise.resolve(w);const N=(()=>{const _={client:t.client,queryKey:t.queryKey,pageParam:C,direction:j?"backward":"forward",meta:t.options.meta};return p(_),_})(),R=await v(N),{maxPages:P}=t.options,H=j?UE:HE;return{pages:H(w.pages,R,P),pageParams:H(w.pageParams,C,P)}};if(o&&s.length){const w=o==="backward",C=w?YE:Gv,j={pages:s,pageParams:u},E=C(i,j);d=await b(j,E,w)}else{const w=e??s.length;do{const C=h===0?u[0]??i.initialPageParam:Gv(i,d);if(h>0&&C==null)break;d=await b(d,C),h++}while(h<w)}return d};t.options.persister?t.fetchFn=()=>t.options.persister?.(f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=f}}}function Gv(e,{pages:t,pageParams:r}){const i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,r[i],r):void 0}function YE(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var QE=class extends i1{#e;#t;#n;#r;#i;#a;#o;#l;constructor(e){super(),this.#l=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Xv(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=Xv(this.options);t.data!==void 0&&(this.setState(Kv(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const r=Kh(this.state.data,e,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e){this.#s({type:"setState",state:e})}cancel(e){const t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(sn).catch(sn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Bn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Pm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Ua(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!e1(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#l||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){const h=this.observers.find(f=>f.options.queryFn);h&&this.setOptions(h.options)}const r=new AbortController,i=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(this.#l=!0,r.signal)})},o=()=>{const h=n1(this.options,t),y=(()=>{const p={client:this.#i,queryKey:this.queryKey,meta:this.meta};return i(p),p})();return this.#l=!1,this.options.persister?this.options.persister(h,y,this):h(y)},u=(()=>{const h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:o};return i(h),h})();(this.#e==="infinite"?VE(this.options.pages):this.options.behavior)?.onFetch(u,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==u.fetchOptions?.meta)&&this.#s({type:"fetch",meta:u.fetchOptions?.meta}),this.#a=a1({initialPromise:t?.initialPromise,fn:u.fetchFn,onCancel:h=>{h instanceof Zh&&h.revert&&this.setState({...this.#n,fetchStatus:"idle"}),r.abort()},onFail:(h,f)=>{this.#s({type:"failed",failureCount:h,error:f})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0});try{const h=await this.#a.start();if(h===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(h),this.#r.config.onSuccess?.(h,this),this.#r.config.onSettled?.(h,this.state.error,this),h}catch(h){if(h instanceof Zh){if(h.silent)return this.#a.promise;if(h.revert){if(this.state.data===void 0)throw h;return this.state.data}}throw this.#s({type:"error",error:h}),this.#r.config.onError?.(h,this),this.#r.config.onSettled?.(this.state.data,h,this),h}finally{this.scheduleGc()}}#s(e){const t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...l1(r.data,this.options),fetchMeta:e.meta??null};case"success":const i={...r,...Kv(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?i:void 0,i;case"error":const o=e.error;return{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),Ut.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function l1(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:r1(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Kv(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Xv(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,i=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var GE=class extends Bl{constructor(e,t){super(),this.options=t,this.#e=e,this.#l=null,this.#o=Xh(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#l;#c;#s;#m;#d;#f;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Zv(this.#t,this.options)?this.#h():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wh(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wh(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Bn(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!lc(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&Wv(this.#t,r,this.options,t)&&this.#h(),this.updateResult(),i&&(this.#t!==r||Bn(this.options.enabled,this.#t)!==Bn(t.enabled,this.#t)||Ua(this.options.staleTime,this.#t)!==Ua(t.staleTime,this.#t))&&this.#g();const o=this.#y();i&&(this.#t!==r||Bn(this.options.enabled,this.#t)!==Bn(t.enabled,this.#t)||o!==this.#u)&&this.#x(o)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(t,e);return XE(this,r)&&(this.#r=r,this.#a=this.options,this.#i=this.#t.state),r}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(r,i)=>(this.trackProp(i),t?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(sn)),t}#g(){this.#b();const e=Ua(this.options.staleTime,this.#t);if(Jo.isServer()||this.#r.isStale||!Qh(e))return;const r=e1(this.#r.dataUpdatedAt,e)+1;this.#d=Ci.setTimeout(()=>{this.#r.isStale||this.updateResult()},r)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#x(e){this.#w(),this.#u=e,!(Jo.isServer()||Bn(this.options.enabled,this.#t)===!1||!Qh(this.#u)||this.#u===0)&&(this.#f=Ci.setInterval(()=>{(this.options.refetchIntervalInBackground||zm.isFocused())&&this.#h()},this.#u))}#v(){this.#g(),this.#x(this.#y())}#b(){this.#d!==void 0&&(Ci.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#f!==void 0&&(Ci.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){const r=this.#t,i=this.options,o=this.#r,s=this.#i,u=this.#a,h=e!==r?e.state:this.#n,{state:f}=e;let y={...f},p=!1,v;if(t._optimisticResults){const I=this.hasListeners(),ie=!I&&Zv(e,t),U=I&&Wv(e,r,t,i);(ie||U)&&(y={...y,...l1(f.data,e.options)}),t._optimisticResults==="isRestoring"&&(y.fetchStatus="idle")}let{error:b,errorUpdatedAt:w,status:C}=y;v=y.data;let j=!1;if(t.placeholderData!==void 0&&v===void 0&&C==="pending"){let I;o?.isPlaceholderData&&t.placeholderData===u?.placeholderData?(I=o.data,j=!0):I=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,I!==void 0&&(C="success",v=Kh(o?.data,I,t),p=!0)}if(t.select&&v!==void 0&&!j)if(o&&v===s?.data&&t.select===this.#c)v=this.#s;else try{this.#c=t.select,v=t.select(v),v=Kh(o?.data,v,t),this.#s=v,this.#l=null}catch(I){this.#l=I}this.#l&&(b=this.#l,v=this.#s,w=Date.now(),C="error");const E=y.fetchStatus==="fetching",N=C==="pending",R=C==="error",P=N&&E,H=v!==void 0,q={status:C,fetchStatus:y.fetchStatus,isPending:N,isSuccess:C==="success",isError:R,isInitialLoading:P,isLoading:P,data:v,dataUpdatedAt:y.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:y.dataUpdateCount>h.dataUpdateCount||y.errorUpdateCount>h.errorUpdateCount,isFetching:E,isRefetching:E&&!N,isLoadingError:R&&!H,isPaused:y.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:R&&H,isStale:Um(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Bn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const I=q.data!==void 0,ie=q.status==="error"&&!I,U=fe=>{ie?fe.reject(q.error):I&&fe.resolve(q.data)},te=()=>{const fe=this.#o=q.promise=Xh();U(fe)},Y=this.#o;switch(Y.status){case"pending":e.queryHash===r.queryHash&&U(Y);break;case"fulfilled":(ie||q.data!==Y.value)&&te();break;case"rejected":(!ie||q.error!==Y.reason)&&te();break}}return q}updateResult(){const e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#m=this.#t),lc(t,e))return;this.#r=t;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!this.#p.size)return!0;const s=new Set(o??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#r).some(u=>{const d=u;return this.#r[d]!==e[d]&&s.has(d)})};this.#k({listeners:r()})}#S(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#k(e){Ut.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function KE(e,t){return Bn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Bn(t.retryOnMount,e)===!1)}function Zv(e,t){return KE(e,t)||e.state.data!==void 0&&Wh(e,t,t.refetchOnMount)}function Wh(e,t,r){if(Bn(t.enabled,e)!==!1&&Ua(t.staleTime,e)!=="static"){const i=typeof r=="function"?r(e):r;return i==="always"||i!==!1&&Um(e,t)}return!1}function Wv(e,t,r,i){return(e!==t||Bn(i.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Um(e,r)}function Um(e,t){return Bn(t.enabled,e)!==!1&&e.isStaleByTime(Ua(t.staleTime,e))}function XE(e,t){return!lc(e.getCurrentResult(),t)}var ZE=class extends i1{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||o1(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#i({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=a1({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(s,u)=>{this.#i({type:"failed",failureCount:s,error:u})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const i=this.state.status==="pending",o=!this.#r.canStart();try{if(i)t();else{this.#i({type:"pending",variables:e,isPaused:o}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);const u=await this.options.onMutate?.(e,r);u!==this.state.context&&this.#i({type:"pending",context:u,variables:e,isPaused:o})}const s=await this.#r.start();return await this.#n.config.onSuccess?.(s,e,this.state.context,this,r),await this.options.onSuccess?.(s,e,this.state.context,r),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(s,null,e,this.state.context,r),this.#i({type:"success",data:s}),s}catch(s){try{await this.#n.config.onError?.(s,e,this.state.context,this,r)}catch(u){Promise.reject(u)}try{await this.options.onError?.(s,e,this.state.context,r)}catch(u){Promise.reject(u)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,r)}catch(u){Promise.reject(u)}try{await this.options.onSettled?.(void 0,s,e,this.state.context,r)}catch(u){Promise.reject(u)}throw this.#i({type:"error",error:s}),s}finally{this.#n.runNext(this)}}#i(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Ut.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function o1(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var WE=class extends Bl{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,r){const i=new ZE({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:r});return this.add(i),i}add(e){this.#e.add(e);const t=Hu(e);if(typeof t=="string"){const r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Hu(e);if(typeof t=="string"){const r=this.#t.get(t);if(r)if(r.length>1){const i=r.indexOf(e);i!==-1&&r.splice(i,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Hu(e);if(typeof t=="string"){const i=this.#t.get(t)?.find(o=>o.state.status==="pending");return!i||i===e}else return!0}runNext(e){const t=Hu(e);return typeof t=="string"?this.#t.get(t)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ut.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(r=>Vv(t,r))}findAll(e={}){return this.getAll().filter(t=>Vv(e,t))}notify(e){Ut.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Ut.batch(()=>Promise.all(e.map(t=>t.continue().catch(sn))))}};function Hu(e){return e.options.scope?.id}var JE=class extends Bl{#e;#t=void 0;#n;#r;constructor(t,r){super(),this.#e=t,this.setOptions(r),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const r=this.options;this.options=this.#e.defaultMutationOptions(t),lc(this.options,r)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),r?.mutationKey&&this.options.mutationKey&&Ni(r.mutationKey)!==Ni(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(t,r){return this.#r=r,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(t)}#i(){const t=this.#n?.state??o1();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){Ut.batch(()=>{if(this.#r&&this.hasListeners()){const r=this.#t.variables,i=this.#t.context,o={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#r.onSuccess?.(t.data,r,i,o)}catch(s){Promise.reject(s)}try{this.#r.onSettled?.(t.data,null,r,i,o)}catch(s){Promise.reject(s)}}else if(t?.type==="error"){try{this.#r.onError?.(t.error,r,i,o)}catch(s){Promise.reject(s)}try{this.#r.onSettled?.(void 0,t.error,r,i,o)}catch(s){Promise.reject(s)}}}this.listeners.forEach(r=>{r(this.#t)})})}},ej=class extends Bl{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){const i=t.queryKey,o=t.queryHash??Lm(i,t);let s=this.get(o);return s||(s=new QE({client:e,queryKey:i,queryHash:o,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(i)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Ut.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(r=>$v(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>$v(e,r)):t}notify(e){Ut.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ut.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ut.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},tj=class{#e;#t;#n;#r;#i;#a;#o;#l;constructor(e={}){this.#e=e.queryCache||new ej,this.#t=e.mutationCache||new WE,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=zm.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#l=oc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#l?.(),this.#l=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=this.#e.build(this,t),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Ua(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{const i=r.data;return[t,i]})}setQueryData(e,t,r){const i=this.defaultQueryOptions({queryKey:e}),s=this.#e.get(i.queryHash)?.state.data,u=zE(t,s);if(u!==void 0)return this.#e.build(this,i).setData(u,{...r,manual:!0})}setQueriesData(e,t,r){return Ut.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,r)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Ut.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#e;return Ut.batch(()=>(r.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},i=Ut.batch(()=>this.#e.findAll(e).map(o=>o.cancel(r)));return Promise.all(i).then(sn).catch(sn)}invalidateQueries(e,t={}){return Ut.batch(()=>(this.#e.findAll(e).forEach(r=>{r.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},i=Ut.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let s=o.fetch(void 0,r);return r.throwOnError||(s=s.catch(sn)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(i).then(sn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=this.#e.build(this,t);return r.isStaleByTime(Ua(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(sn).catch(sn)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(sn).catch(sn)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return oc.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Ni(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],r={};return t.forEach(i=>{Hl(e,i.queryKey)&&Object.assign(r,i.defaultOptions)}),r}setMutationDefaults(e,t){this.#i.set(Ni(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],r={};return t.forEach(i=>{Hl(e,i.mutationKey)&&Object.assign(r,i.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Lm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Pm&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},sh={exports:{}},De={};var Jv;function nj(){if(Jv)return De;Jv=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),v=Symbol.iterator;function b(M){return M===null||typeof M!="object"?null:(M=v&&M[v]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,j={};function E(M,z,T){this.props=M,this.context=z,this.refs=j,this.updater=T||w}E.prototype.isReactComponent={},E.prototype.setState=function(M,z){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,z,"setState")},E.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function N(){}N.prototype=E.prototype;function R(M,z,T){this.props=M,this.context=z,this.refs=j,this.updater=T||w}var P=R.prototype=new N;P.constructor=R,C(P,E.prototype),P.isPureReactComponent=!0;var H=Array.isArray;function _(){}var q={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function ie(M,z,T){var G=T.ref;return{$$typeof:e,type:M,key:z,ref:G!==void 0?G:null,props:T}}function U(M,z){return ie(M.type,z,M.props)}function te(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function Y(M){var z={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(T){return z[T]})}var fe=/\/+/g;function oe(M,z){return typeof M=="object"&&M!==null&&M.key!=null?Y(""+M.key):z.toString(36)}function re(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(_,_):(M.status="pending",M.then(function(z){M.status==="pending"&&(M.status="fulfilled",M.value=z)},function(z){M.status==="pending"&&(M.status="rejected",M.reason=z)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,z,T,G,K){var J=typeof M;(J==="undefined"||J==="boolean")&&(M=null);var me=!1;if(M===null)me=!0;else switch(J){case"bigint":case"string":case"number":me=!0;break;case"object":switch(M.$$typeof){case e:case t:me=!0;break;case y:return me=M._init,L(me(M._payload),z,T,G,K)}}if(me)return K=K(M),me=G===""?"."+oe(M,0):G,H(K)?(T="",me!=null&&(T=me.replace(fe,"$&/")+"/"),L(K,z,T,"",function(tt){return tt})):K!=null&&(te(K)&&(K=U(K,T+(K.key==null||M&&M.key===K.key?"":(""+K.key).replace(fe,"$&/")+"/")+me)),z.push(K)),1;me=0;var Ne=G===""?".":G+":";if(H(M))for(var ue=0;ue<M.length;ue++)G=M[ue],J=Ne+oe(G,ue),me+=L(G,z,T,J,K);else if(ue=b(M),typeof ue=="function")for(M=ue.call(M),ue=0;!(G=M.next()).done;)G=G.value,J=Ne+oe(G,ue++),me+=L(G,z,T,J,K);else if(J==="object"){if(typeof M.then=="function")return L(re(M),z,T,G,K);throw z=String(M),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return me}function Z(M,z,T){if(M==null)return M;var G=[],K=0;return L(M,G,"","",function(J){return z.call(T,J,K++)}),G}function le(M){if(M._status===-1){var z=M._result;z=z(),z.then(function(T){(M._status===0||M._status===-1)&&(M._status=1,M._result=T)},function(T){(M._status===0||M._status===-1)&&(M._status=2,M._result=T)}),M._status===-1&&(M._status=0,M._result=z)}if(M._status===1)return M._result.default;throw M._result}var he=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},O={map:Z,forEach:function(M,z,T){Z(M,function(){z.apply(this,arguments)},T)},count:function(M){var z=0;return Z(M,function(){z++}),z},toArray:function(M){return Z(M,function(z){return z})||[]},only:function(M){if(!te(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return De.Activity=p,De.Children=O,De.Component=E,De.Fragment=r,De.Profiler=o,De.PureComponent=R,De.StrictMode=i,De.Suspense=h,De.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=q,De.__COMPILER_RUNTIME={__proto__:null,c:function(M){return q.H.useMemoCache(M)}},De.cache=function(M){return function(){return M.apply(null,arguments)}},De.cacheSignal=function(){return null},De.cloneElement=function(M,z,T){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var G=C({},M.props),K=M.key;if(z!=null)for(J in z.key!==void 0&&(K=""+z.key),z)!I.call(z,J)||J==="key"||J==="__self"||J==="__source"||J==="ref"&&z.ref===void 0||(G[J]=z[J]);var J=arguments.length-2;if(J===1)G.children=T;else if(1<J){for(var me=Array(J),Ne=0;Ne<J;Ne++)me[Ne]=arguments[Ne+2];G.children=me}return ie(M.type,K,G)},De.createContext=function(M){return M={$$typeof:u,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:s,_context:M},M},De.createElement=function(M,z,T){var G,K={},J=null;if(z!=null)for(G in z.key!==void 0&&(J=""+z.key),z)I.call(z,G)&&G!=="key"&&G!=="__self"&&G!=="__source"&&(K[G]=z[G]);var me=arguments.length-2;if(me===1)K.children=T;else if(1<me){for(var Ne=Array(me),ue=0;ue<me;ue++)Ne[ue]=arguments[ue+2];K.children=Ne}if(M&&M.defaultProps)for(G in me=M.defaultProps,me)K[G]===void 0&&(K[G]=me[G]);return ie(M,J,K)},De.createRef=function(){return{current:null}},De.forwardRef=function(M){return{$$typeof:d,render:M}},De.isValidElement=te,De.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:le}},De.memo=function(M,z){return{$$typeof:f,type:M,compare:z===void 0?null:z}},De.startTransition=function(M){var z=q.T,T={};q.T=T;try{var G=M(),K=q.S;K!==null&&K(T,G),typeof G=="object"&&G!==null&&typeof G.then=="function"&&G.then(_,he)}catch(J){he(J)}finally{z!==null&&T.types!==null&&(z.types=T.types),q.T=z}},De.unstable_useCacheRefresh=function(){return q.H.useCacheRefresh()},De.use=function(M){return q.H.use(M)},De.useActionState=function(M,z,T){return q.H.useActionState(M,z,T)},De.useCallback=function(M,z){return q.H.useCallback(M,z)},De.useContext=function(M){return q.H.useContext(M)},De.useDebugValue=function(){},De.useDeferredValue=function(M,z){return q.H.useDeferredValue(M,z)},De.useEffect=function(M,z){return q.H.useEffect(M,z)},De.useEffectEvent=function(M){return q.H.useEffectEvent(M)},De.useId=function(){return q.H.useId()},De.useImperativeHandle=function(M,z,T){return q.H.useImperativeHandle(M,z,T)},De.useInsertionEffect=function(M,z){return q.H.useInsertionEffect(M,z)},De.useLayoutEffect=function(M,z){return q.H.useLayoutEffect(M,z)},De.useMemo=function(M,z){return q.H.useMemo(M,z)},De.useOptimistic=function(M,z){return q.H.useOptimistic(M,z)},De.useReducer=function(M,z,T){return q.H.useReducer(M,z,T)},De.useRef=function(M){return q.H.useRef(M)},De.useState=function(M){return q.H.useState(M)},De.useSyncExternalStore=function(M,z,T){return q.H.useSyncExternalStore(M,z,T)},De.useTransition=function(){return q.H.useTransition()},De.version="19.2.8",De}var eb;function Bm(){return eb||(eb=1,sh.exports=nj()),sh.exports}var k=Bm();const de=bc(k),ds=NE({__proto__:null,default:de},[k]);var s1=k.createContext(void 0),Bt=e=>{const t=k.useContext(s1);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},rj=({client:e,children:t})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(s1.Provider,{value:e,children:t})),u1=k.createContext(!1),aj=()=>k.useContext(u1);u1.Provider;function ij(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lj=k.createContext(ij()),oj=()=>k.useContext(lj),sj=(e,t,r)=>{const i=r?.state.error&&typeof e.throwOnError=="function"?Hm(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||i)&&(t.isReset()||(e.retryOnMount=!1))},uj=e=>{k.useEffect(()=>{e.clearReset()},[e])},cj=({result:e,errorResetBoundary:t,throwOnError:r,query:i,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(o&&e.data===void 0||Hm(r,[e.error,i])),dj=e=>{if(e.suspense){const r=o=>o==="static"?o:Math.max(o??1e3,1e3),i=e.staleTime;e.staleTime=typeof i=="function"?(...o)=>r(i(...o)):r(i),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},fj=(e,t)=>e.isLoading&&e.isFetching&&!t,hj=(e,t)=>e?.suspense&&t.isPending,tb=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function mj(e,t,r){const i=aj(),o=oj(),s=Bt(),u=s.defaultQueryOptions(e);s.getDefaultOptions().queries?._experimental_beforeQuery?.(u);const d=s.getQueryCache().get(u.queryHash),h=e.subscribed!==!1;u._optimisticResults=i?"isRestoring":h?"optimistic":void 0,dj(u),sj(u,o,d),uj(o);const f=!s.getQueryCache().get(u.queryHash),[y]=k.useState(()=>new t(s,u)),p=y.getOptimisticResult(u),v=!i&&h;if(k.useSyncExternalStore(k.useCallback(b=>{const w=v?y.subscribe(Ut.batchCalls(b)):sn;return y.updateResult(),w},[y,v]),()=>y.getCurrentResult(),()=>y.getCurrentResult()),k.useEffect(()=>{y.setOptions(u)},[u,y]),hj(u,p))throw tb(u,y,o);if(cj({result:p,errorResetBoundary:o,throwOnError:u.throwOnError,query:d,suspense:u.suspense}))throw p.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(u,p),u.experimental_prefetchInRender&&!Jo.isServer()&&fj(p,i)&&(f?tb(u,y,o):d?.promise)?.catch(sn).finally(()=>{y.updateResult()}),u.notifyOnChangeProps?p:y.trackResult(p)}function mt(e,t){return mj(e,GE)}function un(e,t){const r=Bt(),[i]=k.useState(()=>new JE(r,e));k.useEffect(()=>{i.setOptions(e)},[i,e]);const o=k.useSyncExternalStore(k.useCallback(u=>i.subscribe(Ut.batchCalls(u)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),s=k.useCallback((u,d)=>{i.mutate(u,d).catch(sn)},[i]);if(o.error&&Hm(i.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}var uh={exports:{}},qo={},ch={exports:{}},dh={};var nb;function pj(){return nb||(nb=1,(function(e){function t(L,Z){var le=L.length;L.push(Z);e:for(;0<le;){var he=le-1>>>1,O=L[he];if(0<o(O,Z))L[he]=Z,L[le]=O,le=he;else break e}}function r(L){return L.length===0?null:L[0]}function i(L){if(L.length===0)return null;var Z=L[0],le=L.pop();if(le!==Z){L[0]=le;e:for(var he=0,O=L.length,M=O>>>1;he<M;){var z=2*(he+1)-1,T=L[z],G=z+1,K=L[G];if(0>o(T,le))G<O&&0>o(K,T)?(L[he]=K,L[G]=le,he=G):(L[he]=T,L[z]=le,he=z);else if(G<O&&0>o(K,le))L[he]=K,L[G]=le,he=G;else break e}}return Z}function o(L,Z){var le=L.sortIndex-Z.sortIndex;return le!==0?le:L.id-Z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var h=[],f=[],y=1,p=null,v=3,b=!1,w=!1,C=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function P(L){for(var Z=r(f);Z!==null;){if(Z.callback===null)i(f);else if(Z.startTime<=L)i(f),Z.sortIndex=Z.expirationTime,t(h,Z);else break;Z=r(f)}}function H(L){if(C=!1,P(L),!w)if(r(h)!==null)w=!0,_||(_=!0,Y());else{var Z=r(f);Z!==null&&re(H,Z.startTime-L)}}var _=!1,q=-1,I=5,ie=-1;function U(){return j?!0:!(e.unstable_now()-ie<I)}function te(){if(j=!1,_){var L=e.unstable_now();ie=L;var Z=!0;try{e:{w=!1,C&&(C=!1,N(q),q=-1),b=!0;var le=v;try{t:{for(P(L),p=r(h);p!==null&&!(p.expirationTime>L&&U());){var he=p.callback;if(typeof he=="function"){p.callback=null,v=p.priorityLevel;var O=he(p.expirationTime<=L);if(L=e.unstable_now(),typeof O=="function"){p.callback=O,P(L),Z=!0;break t}p===r(h)&&i(h),P(L)}else i(h);p=r(h)}if(p!==null)Z=!0;else{var M=r(f);M!==null&&re(H,M.startTime-L),Z=!1}}break e}finally{p=null,v=le,b=!1}Z=void 0}}finally{Z?Y():_=!1}}}var Y;if(typeof R=="function")Y=function(){R(te)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,oe=fe.port2;fe.port1.onmessage=te,Y=function(){oe.postMessage(null)}}else Y=function(){E(te,0)};function re(L,Z){q=E(function(){L(e.unstable_now())},Z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function(L){switch(v){case 1:case 2:case 3:var Z=3;break;default:Z=v}var le=v;v=Z;try{return L()}finally{v=le}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function(L,Z){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var le=v;v=L;try{return Z()}finally{v=le}},e.unstable_scheduleCallback=function(L,Z,le){var he=e.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?he+le:he):le=he,L){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=le+O,L={id:y++,callback:Z,priorityLevel:L,startTime:le,expirationTime:O,sortIndex:-1},le>he?(L.sortIndex=le,t(f,L),r(h)===null&&L===r(f)&&(C?(N(q),q=-1):C=!0,re(H,le-he))):(L.sortIndex=O,t(h,L),w||b||(w=!0,_||(_=!0,Y()))),L},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(L){var Z=v;return function(){var le=v;v=Z;try{return L.apply(this,arguments)}finally{v=le}}}})(dh)),dh}var rb;function gj(){return rb||(rb=1,ch.exports=pj()),ch.exports}var fh={exports:{}},tn={};var ab;function yj(){if(ab)return tn;ab=1;var e=Bm();function t(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)f+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var i={d:{f:r,r:function(){throw Error(t(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for("react.portal");function s(h,f,y){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:p==null?null:""+p,children:h,containerInfo:f,implementation:y}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return tn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,tn.createPortal=function(h,f){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return s(h,f,null,y)},tn.flushSync=function(h){var f=u.T,y=i.p;try{if(u.T=null,i.p=2,h)return h()}finally{u.T=f,i.p=y,i.d.f()}},tn.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,i.d.C(h,f))},tn.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},tn.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var y=f.as,p=d(y,f.crossOrigin),v=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;y==="style"?i.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:v,fetchPriority:b}):y==="script"&&i.d.X(h,{crossOrigin:p,integrity:v,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},tn.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var y=d(f.as,f.crossOrigin);i.d.M(h,{crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&i.d.M(h)},tn.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var y=f.as,p=d(y,f.crossOrigin);i.d.L(h,y,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},tn.preloadModule=function(h,f){if(typeof h=="string")if(f){var y=d(f.as,f.crossOrigin);i.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:y,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else i.d.m(h)},tn.requestFormReset=function(h){i.d.r(h)},tn.unstable_batchedUpdates=function(h,f){return h(f)},tn.useFormState=function(h,f,y){return u.H.useFormState(h,f,y)},tn.useFormStatus=function(){return u.H.useHostTransitionStatus()},tn.version="19.2.8",tn}var ib;function c1(){if(ib)return fh.exports;ib=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),fh.exports=yj(),fh.exports}var lb;function xj(){if(lb)return qo;lb=1;var e=gj(),t=Bm(),r=c1();function i(n){var a="https://react.dev/errors/"+n;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function s(n){var a=n,l=n;if(n.alternate)for(;a.return;)a=a.return;else{n=a;do a=n,(a.flags&4098)!==0&&(l=a.return),n=a.return;while(n)}return a.tag===3?l:null}function u(n){if(n.tag===13){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function d(n){if(n.tag===31){var a=n.memoizedState;if(a===null&&(n=n.alternate,n!==null&&(a=n.memoizedState)),a!==null)return a.dehydrated}return null}function h(n){if(s(n)!==n)throw Error(i(188))}function f(n){var a=n.alternate;if(!a){if(a=s(n),a===null)throw Error(i(188));return a!==n?null:n}for(var l=n,c=a;;){var g=l.return;if(g===null)break;var x=g.alternate;if(x===null){if(c=g.return,c!==null){l=c;continue}break}if(g.child===x.child){for(x=g.child;x;){if(x===l)return h(g),n;if(x===c)return h(g),a;x=x.sibling}throw Error(i(188))}if(l.return!==c.return)l=g,c=x;else{for(var S=!1,A=g.child;A;){if(A===l){S=!0,l=g,c=x;break}if(A===c){S=!0,c=g,l=x;break}A=A.sibling}if(!S){for(A=x.child;A;){if(A===l){S=!0,l=x,c=g;break}if(A===c){S=!0,c=x,l=g;break}A=A.sibling}if(!S)throw Error(i(189))}}if(l.alternate!==c)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:a}function y(n){var a=n.tag;if(a===5||a===26||a===27||a===6)return n;for(n=n.child;n!==null;){if(a=y(n),a!==null)return a;n=n.sibling}return null}var p=Object.assign,v=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),R=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function Y(n){return n===null||typeof n!="object"?null:(n=te&&n[te]||n["@@iterator"],typeof n=="function"?n:null)}var fe=Symbol.for("react.client.reference");function oe(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===fe?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case C:return"Fragment";case E:return"Profiler";case j:return"StrictMode";case H:return"Suspense";case _:return"SuspenseList";case ie:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case w:return"Portal";case R:return n.displayName||"Context";case N:return(n._context.displayName||"Context")+".Consumer";case P:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case q:return a=n.displayName||null,a!==null?a:oe(n.type)||"Memo";case I:a=n._payload,n=n._init;try{return oe(n(a))}catch{}}return null}var re=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},he=[],O=-1;function M(n){return{current:n}}function z(n){0>O||(n.current=he[O],he[O]=null,O--)}function T(n,a){O++,he[O]=n.current,n.current=a}var G=M(null),K=M(null),J=M(null),me=M(null);function Ne(n,a){switch(T(J,a),T(K,n),T(G,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?dv(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=dv(a),n=fv(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}z(G),T(G,n)}function ue(){z(G),z(K),z(J)}function tt(n){n.memoizedState!==null&&T(me,n);var a=G.current,l=fv(a,n.type);a!==l&&(T(K,n),T(G,l))}function bt(n){K.current===n&&(z(G),z(K)),me.current===n&&(z(me),Po._currentValue=le)}var It,Wt;function Et(n){if(It===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);It=a&&a[1]||"",Wt=-1<l.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+It+n+Wt}var Tn=!1;function Tr(n,a){if(!n||Tn)return"";Tn=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(a){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(X){var Q=X}Reflect.construct(n,[],ae)}else{try{ae.call()}catch(X){Q=X}n.call(ae.prototype)}}else{try{throw Error()}catch(X){Q=X}(ae=n())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(X){if(X&&Q&&typeof X.stack=="string")return[X.stack,Q.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var g=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");g&&g.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=c.DetermineComponentFrameRoot(),S=x[0],A=x[1];if(S&&A){var D=S.split(`
|
|
@@ -78,4 +78,4 @@ Error generating stack: `+c.message+`
|
|
|
78
78
|
`)},gz=0,Tl=[];function yz(e){var t=k.useRef([]),r=k.useRef([0,0]),i=k.useRef(),o=k.useState(gz++)[0],s=k.useState(LS)[0],u=k.useRef(e);k.useEffect(function(){u.current=e},[e]),k.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var C=HM([e.lockRef.current],(e.shards||[]).map(j0),!0).filter(Boolean);return C.forEach(function(j){return j.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),C.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var d=k.useCallback(function(C,j){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!u.current.allowPinchZoom;var E=Xu(C),N=r.current,R="deltaX"in C?C.deltaX:N[0]-E[0],P="deltaY"in C?C.deltaY:N[1]-E[1],H,_=C.target,q=Math.abs(R)>Math.abs(P)?"h":"v";if("touches"in C&&q==="h"&&_.type==="range")return!1;var I=window.getSelection(),ie=I&&I.anchorNode,U=ie?ie===_||ie.contains(_):!1;if(U)return!1;var te=C0(q,_);if(!te)return!0;if(te?H=q:(H=q==="v"?"h":"v",te=C0(q,_)),!te)return!1;if(!i.current&&"changedTouches"in C&&(R||P)&&(i.current=H),!H)return!0;var Y=i.current||H;return hz(Y,j,C,Y==="h"?R:P)},[]),h=k.useCallback(function(C){var j=C;if(!(!Tl.length||Tl[Tl.length-1]!==s)){var E="deltaY"in j?E0(j):Xu(j),N=t.current.filter(function(H){return H.name===j.type&&(H.target===j.target||j.target===H.shadowParent)&&mz(H.delta,E)})[0];if(N&&N.should){j.cancelable&&j.preventDefault();return}if(!N){var R=(u.current.shards||[]).map(j0).filter(Boolean).filter(function(H){return H.contains(j.target)}),P=R.length>0?d(j,R[0]):!u.current.noIsolation;P&&j.cancelable&&j.preventDefault()}}},[]),f=k.useCallback(function(C,j,E,N){var R={name:C,delta:j,target:E,should:N,shadowParent:xz(E)};t.current.push(R),setTimeout(function(){t.current=t.current.filter(function(P){return P!==R})},1)},[]),y=k.useCallback(function(C){r.current=Xu(C),i.current=void 0},[]),p=k.useCallback(function(C){f(C.type,E0(C),C.target,d(C,e.lockRef.current))},[]),v=k.useCallback(function(C){f(C.type,Xu(C),C.target,d(C,e.lockRef.current))},[]);k.useEffect(function(){return Tl.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:v}),document.addEventListener("wheel",h,Al),document.addEventListener("touchmove",h,Al),document.addEventListener("touchstart",y,Al),function(){Tl=Tl.filter(function(C){return C!==s}),document.removeEventListener("wheel",h,Al),document.removeEventListener("touchmove",h,Al),document.removeEventListener("touchstart",y,Al)}},[]);var b=e.removeScrollBar,w=e.inert;return k.createElement(k.Fragment,null,w?k.createElement(s,{styles:pz(o)}):null,b?k.createElement(lz,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function xz(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vz=QM(zS,yz);var gp=k.forwardRef(function(e,t){return k.createElement(Lc,Sr({},e,{ref:t,sideCar:vz}))});gp.classNames=Lc.classNames;var bz=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ol=new WeakMap,Zu=new WeakMap,Wu={},Lh=0,BS=function(e){return e&&(e.host||BS(e.parentNode))},wz=function(e,t){return t.map(function(r){if(e.contains(r))return r;var i=BS(r);return i&&e.contains(i)?i:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},Sz=function(e,t,r,i){var o=wz(t,Array.isArray(e)?e:[e]);Wu[r]||(Wu[r]=new WeakMap);var s=Wu[r],u=[],d=new Set,h=new Set(o),f=function(p){!p||d.has(p)||(d.add(p),f(p.parentNode))};o.forEach(f);var y=function(p){!p||h.has(p)||Array.prototype.forEach.call(p.children,function(v){if(d.has(v))y(v);else try{var b=v.getAttribute(i),w=b!==null&&b!=="false",C=(Ol.get(v)||0)+1,j=(s.get(v)||0)+1;Ol.set(v,C),s.set(v,j),u.push(v),C===1&&w&&Zu.set(v,!0),j===1&&v.setAttribute(r,"true"),w||v.setAttribute(i,"true")}catch(E){console.error("aria-hidden: cannot operate on ",v,E)}})};return y(t),d.clear(),Lh++,function(){u.forEach(function(p){var v=Ol.get(p)-1,b=s.get(p)-1;Ol.set(p,v),s.set(p,b),v||(Zu.has(p)||p.removeAttribute(i),Zu.delete(p)),b||p.removeAttribute(r)}),Lh--,Lh||(Ol=new WeakMap,Ol=new WeakMap,Zu=new WeakMap,Wu={})}},IS=function(e,t,r){r===void 0&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),o=bz(e);return o?(i.push.apply(i,Array.from(o.querySelectorAll("[aria-live], script"))),Sz(i,o,r,"aria-hidden")):function(){return null}},kz=Object.defineProperty,rr=(e,t)=>kz(e,"name",{value:t,configurable:!0}),yp="Dialog",[qS,NP]=Ya(yp),[Cz,Nr]=qS(yp),FS=rr(e=>{const{__scopeDialog:t,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:u=!0}=e,d=k.useRef(null),h=k.useRef(null),[f,y]=$l({prop:i,defaultProp:o??!1,onChange:s,caller:yp}),[p,v]=k.useState(0),[b,w]=k.useState(0);return m.jsx(Cz,{scope:t,triggerRef:d,contentRef:h,contentId:qn(),titleId:qn(),descriptionId:qn(),titlePresent:p>0,descriptionPresent:b>0,setTitleCount:v,setDescriptionCount:w,open:f,onOpenChange:y,onOpenToggle:k.useCallback(()=>y(C=>!C),[y]),modal:u,children:r})},"Dialog"),$S="DialogPortal",[Ez,VS]=qS($S,{forceMount:void 0}),YS=rr(e=>{const{__scopeDialog:t,forceMount:r,children:i,container:o}=e,s=Nr($S,t);return m.jsx(Ez,{scope:t,forceMount:r,children:k.Children.map(i,u=>m.jsx(An,{present:r||s.open,children:m.jsx(Mc,{asChild:!0,container:o,children:u})}))})},"DialogPortal"),km="DialogOverlay",QS=k.forwardRef(rr(function(t,r){const i=VS(km,t.__scopeDialog),{forceMount:o=i.forceMount,...s}=t,u=Nr(km,t.__scopeDialog);return u.modal?m.jsx(An,{present:o||u.open,children:m.jsx(Nz,{...s,ref:r})}):null},"DialogOverlay")),jz=xs("DialogOverlay.RemoveScroll"),Nz=k.forwardRef(rr(function(t,r){const{__scopeDialog:i,...o}=t,s=Nr(km,i),u=vS(),d=zt(r,u);return m.jsx(gp,{as:jz,allowPinchZoom:!0,shards:[s.contentRef],children:m.jsx(et.div,{"data-state":xp(s.open),...o,ref:d,style:{pointerEvents:"auto",...o.style}})})},"DialogOverlayImpl")),rs="DialogContent",GS=k.forwardRef(rr(function(t,r){const i=VS(rs,t.__scopeDialog),{forceMount:o=i.forceMount,...s}=t,u=Nr(rs,t.__scopeDialog);return m.jsx(An,{present:o||u.open,children:u.modal?m.jsx(Az,{...s,ref:r}):m.jsx(Tz,{...s,ref:r})})},"DialogContent")),Az=k.forwardRef(rr(function(t,r){const i=Nr(rs,t.__scopeDialog),o=k.useRef(null),s=zt(r,i.contentRef,o);return k.useEffect(()=>{const u=o.current;if(u)return IS(u)},[]),m.jsx(KS,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:Ye(t.onCloseAutoFocus,u=>{u.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Ye(t.onPointerDownOutside,u=>{const d=u.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0;(d.button===2||h)&&u.preventDefault()}),onFocusOutside:Ye(t.onFocusOutside,u=>u.preventDefault())})},"DialogContentModal")),Tz=k.forwardRef(rr(function(t,r){const i=Nr(rs,t.__scopeDialog),o=k.useRef(!1),s=k.useRef(!1);return m.jsx(KS,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{t.onCloseAutoFocus?.(u),u.defaultPrevented||(o.current||i.triggerRef.current?.focus(),u.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:u=>{t.onInteractOutside?.(u),u.defaultPrevented||(o.current=!0,u.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const d=u.target;i.triggerRef.current?.contains(d)&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&s.current&&u.preventDefault()}})},"DialogContentNonModal")),KS=k.forwardRef(rr(function(t,r){const{__scopeDialog:i,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:u,...d}=t,h=Nr(rs,i);return zc(),m.jsx(m.Fragment,{children:m.jsx(SS,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:u,children:m.jsx(Dc,{role:"dialog",id:h.contentId,"aria-describedby":h.descriptionPresent?h.descriptionId:void 0,"aria-labelledby":h.titlePresent?h.titleId:void 0,"data-state":xp(h.open),...d,ref:r,deferPointerDownOutside:!0,onDismiss:()=>h.onOpenChange(!1)})})})},"DialogContentImpl")),Oz="DialogTitle",Rz=k.forwardRef(rr(function(t,r){const{__scopeDialog:i,...o}=t,s=Nr(Oz,i),{setTitleCount:u}=s;return hn(()=>(u(d=>d+1),()=>u(d=>d-1)),[u]),m.jsx(et.h2,{id:s.titleId,...o,ref:r})},"DialogTitle")),_z="DialogDescription",Dz=k.forwardRef(rr(function(t,r){const{__scopeDialog:i,...o}=t,s=Nr(_z,i),{setDescriptionCount:u}=s;return hn(()=>(u(d=>d+1),()=>u(d=>d-1)),[u]),m.jsx(et.p,{id:s.descriptionId,...o,ref:r})},"DialogDescription")),Mz="DialogClose",zz=k.forwardRef(rr(function(t,r){const{__scopeDialog:i,...o}=t,s=Nr(Mz,i);return m.jsx(et.button,{type:"button",...o,ref:r,onClick:Ye(t.onClick,()=>s.onOpenChange(!1))})},"DialogClose"));function xp(e){return e?"open":"closed"}rr(xp,"getState");const Vl=FS,Lz=YS,XS=k.forwardRef(({className:e,...t},r)=>m.jsx(QS,{ref:r,className:ge("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out",e),...t}));XS.displayName="DialogOverlay";const Li=k.forwardRef(({className:e,children:t,hideClose:r,...i},o)=>m.jsxs(Lz,{children:[m.jsx(XS,{}),m.jsxs(GS,{ref:o,className:ge("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-card p-5 shadow-lg rounded-xl",e),...i,children:[t,!r&&m.jsxs(zz,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none cursor-pointer",children:[m.jsx(es,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Li.displayName="DialogContent";function Yl({className:e,...t}){return m.jsx("div",{className:ge("flex flex-col gap-1.5",e),...t})}function vp({className:e,...t}){return m.jsx("div",{className:ge("flex justify-end gap-2",e),...t})}const Pi=k.forwardRef(({className:e,...t},r)=>m.jsx(Rz,{ref:r,className:ge("text-lg font-semibold",e),...t}));Pi.displayName="DialogTitle";const bs=k.forwardRef(({className:e,...t},r)=>m.jsx(Dz,{ref:r,className:ge("text-sm text-muted-foreground",e),...t}));bs.displayName="DialogDescription";var Pz=Object.defineProperty,Hz=(e,t)=>Pz(e,"name",{value:t,configurable:!0}),Uz=k.createContext(void 0);function ZS(e){const t=k.useContext(Uz);return e||t||"ltr"}Hz(ZS,"useDirection");var Bz=Object.defineProperty,Iz=(e,t)=>Bz(e,"name",{value:t,configurable:!0});function WS(e,[t,r]){return Math.min(r,Math.max(t,e))}Iz(WS,"clamp");var qz=Object.defineProperty,Ie=(e,t)=>qz(e,"name",{value:t,configurable:!0});function JS(e,t){return k.useReducer((r,i)=>t[r][i]??r,e)}Ie(JS,"useStateMachine");var e2="ScrollArea",[t2,AP]=Ya(e2),[Fz,ar]=t2(e2),$z=k.forwardRef(Ie(function(t,r){const{__scopeScrollArea:i,type:o="hover",dir:s,scrollHideDelay:u=600,...d}=t,[h,f]=k.useState(null),[y,p]=k.useState(null),[v,b]=k.useState(null),[w,C]=k.useState(null),[j,E]=k.useState(null),[N,R]=k.useState(0),[P,H]=k.useState(0),[_,q]=k.useState(!1),[I,ie]=k.useState(!1),U=zt(r,f),te=ZS(s);return m.jsx(Fz,{scope:i,type:o,dir:te,scrollHideDelay:u,scrollArea:h,viewport:y,onViewportChange:p,content:v,onContentChange:b,scrollbarX:w,onScrollbarXChange:C,scrollbarXEnabled:_,onScrollbarXEnabledChange:q,scrollbarY:j,onScrollbarYChange:E,scrollbarYEnabled:I,onScrollbarYEnabledChange:ie,onCornerWidthChange:R,onCornerHeightChange:H,children:m.jsx(et.div,{dir:te,...d,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":P+"px",...t.style}})})},"ScrollArea")),Vz="ScrollAreaViewport",Yz=k.forwardRef(Ie(function(t,r){const{__scopeScrollArea:i,children:o,nonce:s,...u}=t,d=ar(Vz,i),h=k.useRef(null),f=zt(r,h,d.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx(Qz,{nonce:s}),m.jsx(et.div,{"data-radix-scroll-area-viewport":"",...u,ref:f,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...t.style},children:m.jsx("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})},"ScrollAreaViewport")),Qz=k.memo(Ie(function({nonce:t}){return m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t})},"ScrollAreaViewportStyle"),(e,t)=>e.nonce===t.nonce),la="ScrollAreaScrollbar",Gz=k.forwardRef(Ie(function(t,r){const{forceMount:i,...o}=t,s=ar(la,t.__scopeScrollArea),{onScrollbarXEnabledChange:u,onScrollbarYEnabledChange:d}=s,h=t.orientation==="horizontal";return k.useEffect(()=>(h?u(!0):d(!0),()=>{h?u(!1):d(!1)}),[h,u,d]),s.type==="hover"?m.jsx(Kz,{...o,ref:r,forceMount:i}):s.type==="scroll"?m.jsx(Xz,{...o,ref:r,forceMount:i}):s.type==="auto"?m.jsx(n2,{...o,ref:r,forceMount:i}):s.type==="always"?m.jsx(bp,{...o,ref:r,"data-state":"visible"}):null},"ScrollAreaScrollbar")),Kz=k.forwardRef(Ie(function(t,r){const{forceMount:i,...o}=t,s=ar(la,t.__scopeScrollArea),[u,d]=k.useState(!1);return k.useEffect(()=>{const h=s.scrollArea;let f=0;if(h){const y=Ie(()=>{window.clearTimeout(f),d(!0)},"handlePointerEnter"),p=Ie(()=>{f=window.setTimeout(()=>d(!1),s.scrollHideDelay)},"handlePointerLeave");return h.addEventListener("pointerenter",y),h.addEventListener("pointerleave",p),()=>{window.clearTimeout(f),h.removeEventListener("pointerenter",y),h.removeEventListener("pointerleave",p)}}},[s.scrollArea,s.scrollHideDelay]),m.jsx(An,{present:i||u,children:m.jsx(n2,{"data-state":u?"visible":"hidden",...o,ref:r})})},"ScrollAreaScrollbarHover")),Xz=k.forwardRef(Ie(function(t,r){const{forceMount:i,...o}=t,s=ar(la,t.__scopeScrollArea),u=t.orientation==="horizontal",d=Ss(()=>f("SCROLL_END"),100),[h,f]=JS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return k.useEffect(()=>{if(h==="idle"){const y=window.setTimeout(()=>f("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(y)}},[h,s.scrollHideDelay,f]),k.useEffect(()=>{const y=s.viewport,p=u?"scrollLeft":"scrollTop";if(y){let v=y[p];const b=Ie(()=>{const w=y[p];v!==w&&(f("SCROLL"),d()),v=w},"handleScroll");return y.addEventListener("scroll",b),()=>y.removeEventListener("scroll",b)}},[s.viewport,u,f,d]),m.jsx(An,{present:i||h!=="hidden",children:m.jsx(bp,{"data-state":h==="hidden"?"hidden":"visible",...o,ref:r,onPointerEnter:Ye(t.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Ye(t.onPointerLeave,()=>f("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),n2=k.forwardRef(Ie(function(t,r){const i=ar(la,t.__scopeScrollArea),{forceMount:o,...s}=t,[u,d]=k.useState(!1),h=t.orientation==="horizontal",f=Ss(()=>{if(i.viewport){const y=i.viewport.offsetWidth<i.viewport.scrollWidth,p=i.viewport.offsetHeight<i.viewport.scrollHeight;d(h?y:p)}},10);return Oi(i.viewport,f),Oi(i.content,f),m.jsx(An,{present:o||u,children:m.jsx(bp,{"data-state":u?"visible":"hidden",...s,ref:r})})},"ScrollAreaScrollbarAuto")),bp=k.forwardRef(Ie(function(t,r){const{orientation:i="vertical",...o}=t,s=ar(la,t.__scopeScrollArea),u=k.useRef(null),d=k.useRef(0),[h,f]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),y=wp(h.viewport,h.content),p={...o,sizes:h,onSizesChange:f,hasThumb:y>0&&y<1,onThumbChange:Ie(b=>u.current=b,"onThumbChange"),onThumbPointerUp:Ie(()=>d.current=0,"onThumbPointerUp"),onThumbPointerDown:Ie(b=>d.current=b,"onThumbPointerDown")};function v(b,w){return l2(b,d.current,h,w)}return Ie(v,"getScrollPosition"),i==="horizontal"?m.jsx(Zz,{...p,ref:r,onThumbPositionChange:()=>{if(s.viewport&&u.current){const b=s.viewport.scrollLeft,w=Em(b,h,s.dir);u.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:b=>{s.viewport&&(s.viewport.scrollLeft=b)},onDragScroll:b=>{s.viewport&&(s.viewport.scrollLeft=v(b,s.dir))}}):i==="vertical"?m.jsx(Wz,{...p,ref:r,onThumbPositionChange:()=>{if(s.viewport&&u.current){const b=s.viewport.scrollTop,w=Em(b,h);u.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:b=>{s.viewport&&(s.viewport.scrollTop=b)},onDragScroll:b=>{s.viewport&&(s.viewport.scrollTop=v(b))}}):null},"ScrollAreaScrollbarVisible")),Zz=k.forwardRef(Ie(function(t,r){const{sizes:i,onSizesChange:o,...s}=t,u=ar(la,t.__scopeScrollArea),[d,h]=k.useState(),f=k.useRef(null),y=zt(r,f,u.onScrollbarXChange);return k.useEffect(()=>{f.current&&h(getComputedStyle(f.current))},[f]),m.jsx(a2,{"data-orientation":"horizontal",...s,ref:y,sizes:i,style:{bottom:0,left:u.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:u.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ws(i)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,v)=>{if(u.viewport){const b=u.viewport.scrollLeft+p.deltaX;t.onWheelScroll(b),kp(b,v)&&p.preventDefault()}},onResize:()=>{f.current&&u.viewport&&d&&o({content:u.viewport.scrollWidth,viewport:u.viewport.offsetWidth,scrollbar:{size:f.current.clientWidth,paddingStart:as(d.paddingLeft),paddingEnd:as(d.paddingRight)}})}})},"ScrollAreaScrollbarX")),Wz=k.forwardRef(Ie(function(t,r){const{sizes:i,onSizesChange:o,...s}=t,u=ar(la,t.__scopeScrollArea),[d,h]=k.useState(),f=k.useRef(null),y=zt(r,f,u.onScrollbarYChange);return k.useEffect(()=>{f.current&&h(getComputedStyle(f.current))},[f]),m.jsx(a2,{"data-orientation":"vertical",...s,ref:y,sizes:i,style:{top:0,right:u.dir==="ltr"?0:void 0,left:u.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ws(i)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,v)=>{if(u.viewport){const b=u.viewport.scrollTop+p.deltaY;t.onWheelScroll(b),kp(b,v)&&p.preventDefault()}},onResize:()=>{f.current&&u.viewport&&d&&o({content:u.viewport.scrollHeight,viewport:u.viewport.offsetHeight,scrollbar:{size:f.current.clientHeight,paddingStart:as(d.paddingTop),paddingEnd:as(d.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[Jz,r2]=t2(la),a2=k.forwardRef(Ie(function(t,r){const{__scopeScrollArea:i,sizes:o,hasThumb:s,onThumbChange:u,onThumbPointerUp:d,onThumbPointerDown:h,onThumbPositionChange:f,onDragScroll:y,onWheelScroll:p,onResize:v,...b}=t,w=ar(la,i),[C,j]=k.useState(null),E=zt(r,j),N=k.useRef(null),R=k.useRef(""),P=w.viewport,H=o.content-o.viewport,_=Cn(p),q=Cn(f),I=Ss(v,10);function ie(U){if(N.current){const te=U.clientX-N.current.left,Y=U.clientY-N.current.top;y({x:te,y:Y})}}return Ie(ie,"handleDragScroll"),k.useEffect(()=>{const U=Ie(te=>{const Y=te.target;C?.contains(Y)&&_(te,H)},"handleWheel");return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[P,C,H,_]),k.useEffect(q,[o,q]),Oi(C,I),Oi(w.content,I),m.jsx(Jz,{scope:i,scrollbar:C,hasThumb:s,onThumbChange:Cn(u),onThumbPointerUp:Cn(d),onThumbPositionChange:q,onThumbPointerDown:Cn(h),children:m.jsx(et.div,{...b,ref:E,style:{position:"absolute",...b.style},onPointerDown:Ye(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),N.current=C.getBoundingClientRect(),R.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),ie(U))}),onPointerMove:Ye(t.onPointerMove,ie),onPointerUp:Ye(t.onPointerUp,U=>{const te=U.target;te.hasPointerCapture(U.pointerId)&&te.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=R.current,w.viewport&&(w.viewport.style.scrollBehavior=""),N.current=null})})})},"ScrollAreaScrollbarImpl")),Cm="ScrollAreaThumb",e6=k.forwardRef(Ie(function(t,r){const{forceMount:i,...o}=t,s=r2(Cm,t.__scopeScrollArea);return m.jsx(An,{present:i||s.hasThumb,children:m.jsx(t6,{ref:r,...o})})},"ScrollAreaThumb")),t6=k.forwardRef(Ie(function(t,r){const{__scopeScrollArea:i,style:o,...s}=t,u=ar(Cm,i),d=r2(Cm,i),{onThumbPositionChange:h}=d,f=zt(r,d.onThumbChange),y=k.useRef(void 0),p=Ss(()=>{y.current&&(y.current(),y.current=void 0)},100);return k.useEffect(()=>{const v=u.viewport;if(v){const b=Ie(()=>{if(p(),!y.current){const w=a6(v,h);y.current=w,h()}},"handleScroll");return h(),v.addEventListener("scroll",b),()=>v.removeEventListener("scroll",b)}},[u.viewport,p,h]),m.jsx(et.div,{"data-state":d.hasThumb?"visible":"hidden",...s,ref:f,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:Ye(t.onPointerDownCapture,v=>{const w=v.target.getBoundingClientRect(),C=v.clientX-w.left,j=v.clientY-w.top;d.onThumbPointerDown({x:C,y:j})}),onPointerUp:Ye(t.onPointerUp,d.onThumbPointerUp)})},"ScrollAreaThumbImpl")),i2="ScrollAreaCorner",n6=k.forwardRef(Ie(function(t,r){const i=ar(i2,t.__scopeScrollArea),o=!!(i.scrollbarX&&i.scrollbarY);return i.type!=="scroll"&&o?m.jsx(r6,{...t,ref:r}):null},"ScrollAreaCorner")),r6=k.forwardRef(Ie(function(t,r){const{__scopeScrollArea:i,...o}=t,s=ar(i2,i),[u,d]=k.useState(0),[h,f]=k.useState(0),y=!!(u&&h),{onCornerWidthChange:p,onCornerHeightChange:v}=s;return Oi(s.scrollbarX,()=>{const b=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(b),f(b)}),Oi(s.scrollbarY,()=>{const b=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(b),d(b)}),k.useEffect(()=>()=>{p(0),v(0)},[p,v]),y?m.jsx(et.div,{...o,ref:r,style:{width:u,height:h,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null},"ScrollAreaCornerImpl"));function as(e){return e?parseInt(e,10):0}Ie(as,"toInt");function wp(e,t){const r=e/t;return isNaN(r)?0:r}Ie(wp,"getThumbRatio");function ws(e){const t=wp(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=(e.scrollbar.size-r)*t;return Math.max(i,18)}Ie(ws,"getThumbSize");function l2(e,t,r,i="ltr"){const o=ws(r),s=o/2,u=t||s,d=o-u,h=r.scrollbar.paddingStart+u,f=r.scrollbar.size-r.scrollbar.paddingEnd-d,y=r.content-r.viewport,p=i==="ltr"?[0,y]:[y*-1,0];return Sp([h,f],p)(e)}Ie(l2,"getScrollPositionFromPointer");function Em(e,t,r="ltr"){const i=ws(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,u=t.content-t.viewport,d=s-i,h=r==="ltr"?[0,u]:[u*-1,0],f=WS(e,h);return Sp([0,u],[0,d])(f)}Ie(Em,"getThumbOffsetFromScroll");function Sp(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(r-e[0])}}Ie(Sp,"linearScale");function kp(e,t){return e>0&&e<t}Ie(kp,"isScrollingWithinScrollbarBounds");var a6=Ie((e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},i=0;return Ie((function o(){const s={left:e.scrollLeft,top:e.scrollTop},u=r.left!==s.left,d=r.top!==s.top;(u||d)&&t(),r=s,i=window.requestAnimationFrame(o)}),"loop")(),()=>window.cancelAnimationFrame(i)},"addUnlinkedScrollListener");function Ss(e,t){const r=Cn(e),i=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(i.current),[]),k.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(r,t)},[r,t])}Ie(Ss,"useDebounceCallback");function Oi(e,t){const r=Cn(t);hn(()=>{let i=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(i),i=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(i),o.unobserve(e)}}},[e,r])}Ie(Oi,"useResizeObserver");var i6=$z,l6=Yz,o6=Gz,s6=e6,u6=n6,c6=Object.defineProperty,o2=(e,t)=>c6(e,"name",{value:t,configurable:!0}),N0="horizontal",d6=["horizontal","vertical"],f6=k.forwardRef(o2(function(t,r){const{decorative:i,orientation:o=N0,...s}=t,u=s2(o)?o:N0,h=i?{role:"none"}:{"aria-orientation":u==="vertical"?u:void 0,role:"separator"};return m.jsx(et.div,{"data-orientation":u,...h,...s,ref:r})},"Separator"));function s2(e){return d6.includes(e)}o2(s2,"isValidOrientation");var h6=f6;const m6=["top","right","bottom","left"],Ia=Math.min,Jr=Math.max,hc=Math.round,Ju=Math.floor,ea=e=>({x:e,y:e}),p6={left:"right",right:"left",bottom:"top",top:"bottom"};function u2(e,t,r){return Jr(e,Ia(t,r))}function na(e,t){return typeof e=="function"?e(t):e}function qa(e){return e.split("-")[0]}function Ql(e){return e.split("-")[1]}function Cp(e){return e==="x"?"y":"x"}function Ep(e){return e==="y"?"height":"width"}function kr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function jp(e){return Cp(kr(e))}function g6(e,t,r){r===void 0&&(r=!1);const i=Ql(e),o=jp(e),s=Ep(o);let u=o==="x"?i===(r?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(u=mc(u)),[u,mc(u)]}function y6(e){const t=mc(e);return[jm(e),t,jm(t)]}function jm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const A0=["left","right"],T0=["right","left"],x6=["top","bottom"],v6=["bottom","top"];function b6(e,t,r){switch(e){case"top":case"bottom":return r?t?T0:A0:t?A0:T0;case"left":case"right":return t?x6:v6;default:return[]}}function w6(e,t,r,i){const o=Ql(e);let s=b6(qa(e),r==="start",i);return o&&(s=s.map(u=>u+"-"+o),t&&(s=s.concat(s.map(jm)))),s}function mc(e){const t=qa(e);return p6[t]+e.slice(t.length)}function S6(e){var t,r,i,o;return{top:(t=e.top)!=null?t:0,right:(r=e.right)!=null?r:0,bottom:(i=e.bottom)!=null?i:0,left:(o=e.left)!=null?o:0}}function c2(e){return typeof e!="number"?S6(e):{top:e,right:e,bottom:e,left:e}}function pc(e){const{x:t,y:r,width:i,height:o}=e;return{width:i,height:o,top:r,left:t,right:t+i,bottom:r+o,x:t,y:r}}function O0(e,t,r){let{reference:i,floating:o}=e;const s=kr(t),u=jp(t),d=Ep(u),h=qa(t),f=s==="y",y=i.x+i.width/2-o.width/2,p=i.y+i.height/2-o.height/2,v=i[d]/2-o[d]/2;let b;switch(h){case"top":b={x:y,y:i.y-o.height};break;case"bottom":b={x:y,y:i.y+i.height};break;case"right":b={x:i.x+i.width,y:p};break;case"left":b={x:i.x-o.width,y:p};break;default:b={x:i.x,y:i.y}}const w=Ql(t);return w&&(b[u]+=v*(w==="end"?1:-1)*(r&&f?-1:1)),b}async function k6(e,t){var r;t===void 0&&(t={});const{x:i,y:o,platform:s,rects:u,elements:d,strategy:h}=e,{boundary:f="clippingAncestors",rootBoundary:y="viewport",elementContext:p="floating",altBoundary:v=!1,padding:b=0}=na(t,e),w=c2(b),j=d[v?p==="floating"?"reference":"floating":p],E=pc(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(j)))==null||r?j:j.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(d.floating)),boundary:f,rootBoundary:y,strategy:h})),N=p==="floating"?{x:i,y:o,width:u.floating.width,height:u.floating.height}:u.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d.floating)),P=await(s.isElement==null?void 0:s.isElement(R))&&await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1},H=pc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:N,offsetParent:R,strategy:h}):N);return{top:(E.top-H.top+w.top)/P.y,bottom:(H.bottom-E.bottom+w.bottom)/P.y,left:(E.left-H.left+w.left)/P.x,right:(H.right-E.right+w.right)/P.x}}const C6=50,E6=async(e,t,r)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:u}=r,d=u.detectOverflow?u:{...u,detectOverflow:k6},h=await(u.isRTL==null?void 0:u.isRTL(t));let f=await u.getElementRects({reference:e,floating:t,strategy:o}),{x:y,y:p}=O0(f,i,h),v=i,b=0;const w={};for(let C=0;C<s.length;C++){const j=s[C];if(!j)continue;const{name:E,fn:N}=j,{x:R,y:P,data:H,reset:_}=await N({x:y,y:p,initialPlacement:i,placement:v,strategy:o,middlewareData:w,rects:f,platform:d,elements:{reference:e,floating:t}});y=R??y,p=P??p,w[E]={...w[E],...H},_&&b<C6&&(b++,typeof _=="object"&&(_.placement&&(v=_.placement),_.rects&&(f=_.rects===!0?await u.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:y,y:p}=O0(f,v,h)),C=-1)}return{x:y,y:p,placement:v,strategy:o,middlewareData:w}},j6=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:i,placement:o,rects:s,platform:u,elements:d,middlewareData:h}=t,{element:f,padding:y=0}=na(e,t)||{};if(f==null)return{};const p=c2(y),v={x:r,y:i},b=jp(o),w=Ep(b),C=await u.getDimensions(f),j=b==="y",E=j?"top":"left",N=j?"bottom":"right",R=j?"clientHeight":"clientWidth",P=s.reference[w]+s.reference[b]-v[b]-s.floating[w],H=v[b]-s.reference[b],_=await(u.getOffsetParent==null?void 0:u.getOffsetParent(f));let q=_?_[R]:0;(!q||!await(u.isElement==null?void 0:u.isElement(_)))&&(q=d.floating[R]||s.floating[w]);const I=P/2-H/2,ie=q/2-C[w]/2-1,U=Ia(p[E],ie),te=Ia(p[N],ie),Y=q-C[w]-te,fe=q/2-C[w]/2+I,oe=u2(U,fe,Y),re=!h.arrow&&Ql(o)!=null&&fe!==oe&&s.reference[w]/2-(fe<U?U:te)-C[w]/2<0,L=re?fe<U?fe-U:fe-Y:0;return{[b]:v[b]+L,data:{[b]:oe,centerOffset:fe-oe-L,...re&&{alignmentOffset:L}},reset:re}}}),N6=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,i;const{placement:o,middlewareData:s,rects:u,initialPlacement:d,platform:h,elements:f}=t,{mainAxis:y=!0,crossAxis:p=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:C=!0,...j}=na(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const E=qa(o),N=kr(d),R=qa(d)===d,P=await(h.isRTL==null?void 0:h.isRTL(f.floating)),H=v||(R||!C?[mc(d)]:y6(d)),_=w!=="none";!v&&_&&H.push(...w6(d,C,w,P));const q=[d,...H],I=await h.detectOverflow(t,j),ie=[];let U=((i=s.flip)==null?void 0:i.overflows)||[];if(y&&ie.push(I[E]),p){const oe=g6(o,u,P);ie.push(I[oe[0]],I[oe[1]])}if(U=[...U,{placement:o,overflows:ie}],!ie.every(oe=>oe<=0)){var te,Y;const oe=(((te=s.flip)==null?void 0:te.index)||0)+1,re=q[oe];if(re&&(!(p==="alignment"?N!==kr(re):!1)||U.every(le=>kr(le.placement)===N?le.overflows[0]>0:!0)))return{data:{index:oe,overflows:U},reset:{placement:re}};let L=(Y=U.filter(Z=>Z.overflows[0]<=0).sort((Z,le)=>Z.overflows[1]-le.overflows[1])[0])==null?void 0:Y.placement;if(!L)switch(b){case"bestFit":{var fe;const Z=(fe=U.filter(le=>{if(_){const he=kr(le.placement);return he===N||he==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(he=>he>0).reduce((he,O)=>he+O,0)]).sort((le,he)=>le[1]-he[1])[0])==null?void 0:fe[0];Z&&(L=Z);break}case"initialPlacement":L=d;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function R0(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _0(e){return m6.some(t=>e[t]>=0)}const A6=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:i}=t,{strategy:o="referenceHidden",...s}=na(e,t);switch(o){case"referenceHidden":{const u=await i.detectOverflow(t,{...s,elementContext:"reference"}),d=R0(u,r.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:_0(d)}}}case"escaped":{const u=await i.detectOverflow(t,{...s,altBoundary:!0}),d=R0(u,r.floating);return{data:{escapedOffsets:d,escaped:_0(d)}}}default:return{}}}}},d2=new Set(["left","top"]);async function T6(e,t){const{placement:r,platform:i,elements:o}=e,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),u=qa(r),d=Ql(r),h=kr(r)==="y",f=d2.has(u)?-1:1,y=s&&h?-1:1,p=na(t,e);let{mainAxis:v,crossAxis:b,alignmentAxis:w}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return d&&typeof w=="number"&&(b=d==="end"?w*-1:w),h?{x:b*y,y:v*f}:{x:v*f,y:b*y}}const O6=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,i;const{x:o,y:s,placement:u,middlewareData:d}=t,h=await T6(t,e);return u===((r=d.offset)==null?void 0:r.placement)&&(i=d.arrow)!=null&&i.alignmentOffset?{}:{x:o+h.x,y:s+h.y,data:{...h,placement:u}}}}},R6=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:i,placement:o,platform:s}=t,{mainAxis:u=!0,crossAxis:d=!1,limiter:h={fn:N=>{let{x:R,y:P}=N;return{x:R,y:P}}},...f}=na(e,t),y={x:r,y:i},p=await s.detectOverflow(t,f),v=kr(o),b=Cp(v);let w=y[b],C=y[v];const j=(N,R)=>u2(R+p[N==="y"?"top":"left"],R,R-p[N==="y"?"bottom":"right"]);u&&(w=j(b,w)),d&&(C=j(v,C));const E=h.fn({...t,[b]:w,[v]:C});return{...E,data:{x:E.x-r,y:E.y-i,enabled:{[b]:u,[v]:d}}}}}},_6=function(e){return e===void 0&&(e={}),{options:e,fn(t){var r,i;const{x:o,y:s,placement:u,rects:d,middlewareData:h}=t,{offset:f=0,mainAxis:y=!0,crossAxis:p=!0}=na(e,t),v={x:o,y:s},b=kr(u),w=Cp(b);let C=v[w],j=v[b];const E=na(f,t),N=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:(r=E.mainAxis)!=null?r:0,crossAxis:(i=E.crossAxis)!=null?i:0};if(y){const H=w==="y"?"height":"width",_=d.reference[w]-d.floating[H]+N.mainAxis,q=d.reference[w]+d.reference[H]-N.mainAxis;C<_?C=_:C>q&&(C=q)}if(p){var R,P;const H=w==="y"?"width":"height",_=d2.has(qa(u)),q=d.reference[b]-d.floating[H]+(_&&((R=h.offset)==null?void 0:R[b])||0)+(_?0:N.crossAxis),I=d.reference[b]+d.reference[H]+(_?0:((P=h.offset)==null?void 0:P[b])||0)-(_?N.crossAxis:0);j<q?j=q:j>I&&(j=I)}return{[w]:C,[b]:j}}}},D6=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:r,rects:i,platform:o,elements:s}=t,{apply:u=()=>{},...d}=na(e,t),h=await o.detectOverflow(t,d),f=qa(r),y=Ql(r),p=kr(r)==="y",{width:v,height:b}=i.floating;let w,C;f==="top"||f==="bottom"?(w=f,C=y===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(C=f,w=y==="end"?"top":"bottom");const j=b-h.top-h.bottom,E=v-h.left-h.right,N=Ia(b-h[w],j),R=Ia(v-h[C],E),P=t.middlewareData.shift,H=!P;let _=N,q=R;P!=null&&P.enabled.x&&(q=E),P!=null&&P.enabled.y&&(_=j),H&&!y&&(p?q=v-2*Jr(h.left,h.right):_=b-2*Jr(h.top,h.bottom)),await u({...t,availableWidth:q,availableHeight:_});const I=await o.getDimensions(s.floating);return v!==I.width||b!==I.height?{reset:{rects:!0}}:{}}}};function Pc(){return typeof window<"u"}function Gl(e){return f2(e)?(e.nodeName||"").toLowerCase():"#document"}function En(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function oa(e){var t;return(t=(f2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function f2(e){return Pc()?e instanceof Node||e instanceof En(e).Node:!1}function Cr(e){return Pc()?e instanceof Element||e instanceof En(e).Element:!1}function Qa(e){return Pc()?e instanceof HTMLElement||e instanceof En(e).HTMLElement:!1}function D0(e){return!Pc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof En(e).ShadowRoot}function Hc(e){const{overflow:t,overflowX:r,overflowY:i,display:o}=Er(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+r)&&o!=="inline"&&o!=="contents"}function M6(e){return/^(table|td|th)$/.test(Gl(e))}function Uc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const z6=/transform|translate|scale|rotate|perspective|filter/,L6=/paint|layout|strict|content/,bi=e=>!!e&&e!=="none";let Ph;function Np(e){const t=Cr(e)?Er(e):e;return bi(t.transform)||bi(t.translate)||bi(t.scale)||bi(t.rotate)||bi(t.perspective)||!Ap()&&(bi(t.backdropFilter)||bi(t.filter))||z6.test(t.willChange||"")||L6.test(t.contain||"")}function P6(e){let t=Ri(e);for(;Qa(t)&&!is(t);){if(Np(t))return t;if(Uc(t))return null;t=Ri(t)}return null}function Ap(){return Ph==null&&(Ph=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ph}function is(e){return/^(html|body|#document)$/.test(Gl(e))}function Er(e){return En(e).getComputedStyle(e)}function Bc(e){return Cr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ri(e){if(Gl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||D0(e)&&e.host||oa(e);return D0(t)?t.host:t}function h2(e){const t=Ri(e);return is(t)?(e.ownerDocument||e).body:Qa(t)&&Hc(t)?t:h2(t)}function ls(e,t,r){var i;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=h2(e),s=o===((i=e.ownerDocument)==null?void 0:i.body),u=En(o);if(s){const d=Nm(u);return t.concat(u,u.visualViewport||[],Hc(o)?o:[],d&&r?ls(d):[])}else return t.concat(o,ls(o,[],r))}function Nm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function m2(e){const t=Er(e);let r=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const o=Qa(e),s=o?e.offsetWidth:r,u=o?e.offsetHeight:i,d=hc(r)!==s||hc(i)!==u;return d&&(r=s,i=u),{width:r,height:i,$:d}}function Tp(e){return Cr(e)?e:e.contextElement}function Pl(e){const t=Tp(e);if(!Qa(t))return ea(1);const r=t.getBoundingClientRect(),{width:i,height:o,$:s}=m2(t);let u=(s?hc(r.width):r.width)/i,d=(s?hc(r.height):r.height)/o;return(!u||!Number.isFinite(u))&&(u=1),(!d||!Number.isFinite(d))&&(d=1),{x:u,y:d}}const H6=ea(0);function p2(e){const t=En(e);return!Ap()||!t.visualViewport?H6:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function U6(e,t,r){return t===void 0&&(t=!1),!!r&&t&&r===En(e)}function _i(e,t,r,i){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Tp(e);let u=ea(1);t&&(i?Cr(i)&&(u=Pl(i)):u=Pl(e));const d=U6(s,r,i)?p2(s):ea(0);let h=(o.left+d.x)/u.x,f=(o.top+d.y)/u.y,y=o.width/u.x,p=o.height/u.y;if(s&&i){const v=En(s),b=Cr(i)?En(i):i;let w=v,C=Nm(w);for(;C&&b!==w;){const j=Pl(C),E=C.getBoundingClientRect(),N=Er(C),R=E.left+(C.clientLeft+parseFloat(N.paddingLeft))*j.x,P=E.top+(C.clientTop+parseFloat(N.paddingTop))*j.y;h*=j.x,f*=j.y,y*=j.x,p*=j.y,h+=R,f+=P,w=En(C),C=Nm(w)}}return pc({width:y,height:p,x:h,y:f})}function Ic(e,t){const r=Bc(e).scrollLeft;return t?t.left+r:_i(oa(e)).left+r}function g2(e,t){const r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-Ic(e,r),o=r.top+t.scrollTop;return{x:i,y:o}}function B6(e){let{elements:t,rect:r,offsetParent:i,strategy:o}=e;const s=o==="fixed",u=oa(i),d=t?Uc(t.floating):!1;if(i===u||d&&s)return r;let h={scrollLeft:0,scrollTop:0},f=ea(1);const y=ea(0),p=Qa(i);if((p||!s)&&((Gl(i)!=="body"||Hc(u))&&(h=Bc(i)),p)){const b=_i(i);f=Pl(i),y.x=b.x+i.clientLeft,y.y=b.y+i.clientTop}const v=u&&!p&&!s?g2(u,h):ea(0);return{width:r.width*f.x,height:r.height*f.y,x:r.x*f.x-h.scrollLeft*f.x+y.x+v.x,y:r.y*f.y-h.scrollTop*f.y+y.y+v.y}}function I6(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function q6(e){const t=Bc(e),r=e.ownerDocument.body,i=Jr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=Jr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-t.scrollLeft+Ic(e);const u=-t.scrollTop;return Er(r).direction==="rtl"&&(s+=Jr(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:u}}const F6=25;function $6(e,t,r){r===void 0&&(r="viewport");const i=r==="layoutViewport",o=En(e),s=oa(e),u=o.visualViewport;let d=s.clientWidth,h=s.clientHeight,f=0,y=0;if(u){const v=!Ap()||t==="fixed";i?v||(f=-u.offsetLeft,y=-u.offsetTop):(d=u.width,h=u.height,v&&(f=u.offsetLeft,y=u.offsetTop))}if(Ic(s)<=0){const v=s.ownerDocument,b=v.body,w=getComputedStyle(b),C=v.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,j=Math.abs(s.clientWidth-b.clientWidth-C),E=getComputedStyle(s).scrollbarGutter==="stable both-edges"?j/2:j;E<=F6&&(d-=E)}return{width:d,height:h,x:f,y}}function V6(e,t){const r=_i(e,!0,t==="fixed"),i=r.top+e.clientTop,o=r.left+e.clientLeft,s=Pl(e),u=e.clientWidth*s.x,d=e.clientHeight*s.y,h=o*s.x,f=i*s.y;return{width:u,height:d,x:h,y:f}}function M0(e,t,r){let i;if(t==="viewport"||t==="layoutViewport")i=$6(e,r,t);else if(t==="document")i=q6(oa(e));else if(Cr(t))i=V6(t,r);else{const o=p2(e);i={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return pc(i)}function Y6(e,t){const r=t.get(e);if(r)return r;let i=ls(e,[],!1).filter(d=>Cr(d)&&Gl(d)!=="body"),o=null;const s=Er(e).position==="fixed";let u=s?Ri(e):e;for(;Cr(u)&&!is(u);){const d=Er(u),h=Np(u),f=o?o.position:s?"fixed":"";!h&&(f==="fixed"||f==="absolute"&&d.position==="static")?i=i.filter(p=>p!==u):o=d,u=Ri(u)}return t.set(e,i),i}function Q6(e){let{element:t,boundary:r,rootBoundary:i,strategy:o}=e;const u=[...r==="clippingAncestors"?Uc(t)?[]:Y6(t,this._c):[].concat(r),i],d=M0(t,u[0],o);let h=d.top,f=d.right,y=d.bottom,p=d.left;for(let v=1;v<u.length;v++){const b=M0(t,u[v],o);h=Jr(b.top,h),f=Ia(b.right,f),y=Ia(b.bottom,y),p=Jr(b.left,p)}return{width:f-p,height:y-h,x:p,y:h}}function G6(e){const{width:t,height:r}=m2(e);return{width:t,height:r}}function K6(e,t,r){const i=Qa(t),o=oa(t),s=r==="fixed",u=_i(e,!0,s,t);let d={scrollLeft:0,scrollTop:0};const h=ea(0);if((i||!s)&&((Gl(t)!=="body"||Hc(o))&&(d=Bc(t)),i)){const v=_i(t,!0,s,t);h.x=v.x+t.clientLeft,h.y=v.y+t.clientTop}!i&&o&&(h.x=Ic(o));const f=o&&!i&&!s?g2(o,d):ea(0),y=u.left+d.scrollLeft-h.x-f.x,p=u.top+d.scrollTop-h.y-f.y;return{x:y,y:p,width:u.width,height:u.height}}function Hh(e){return Er(e).position==="static"}function z0(e,t){if(!Qa(e)||Er(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return oa(e)===r&&(r=r.ownerDocument.body),r}function y2(e,t){const r=En(e);if(Uc(e))return r;if(!Qa(e)){let o=Ri(e);for(;o&&!is(o);){if(Cr(o)&&!Hh(o))return o;o=Ri(o)}return r}let i=z0(e,t);for(;i&&M6(i)&&Hh(i);)i=z0(i,t);return i&&is(i)&&Hh(i)&&!Np(i)?r:i||P6(e)||r}const X6=async function(e){const t=this.getOffsetParent||y2,r=this.getDimensions,i=await r(e.floating);return{reference:K6(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Z6(e){return Er(e).direction==="rtl"}const W6={convertOffsetParentRelativeRectToViewportRelativeRect:B6,getDocumentElement:oa,getClippingRect:Q6,getOffsetParent:y2,getElementRects:X6,getClientRects:I6,getDimensions:G6,getScale:Pl,isElement:Cr,isRTL:Z6};function x2(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function J6(e,t,r){let i=null,o;const s=oa(e);function u(){var y;clearTimeout(o),(y=i)==null||y.disconnect(),i=null}function d(y,p){y===void 0&&(y=!1),p===void 0&&(p=1),u();const v=e.getBoundingClientRect(),{left:b,top:w,width:C,height:j}=v;if(y||t(),!C||!j)return;const E=Ju(w),N=Ju(s.clientWidth-(b+C)),R=Ju(s.clientHeight-(w+j)),P=Ju(b),_={rootMargin:-E+"px "+-N+"px "+-R+"px "+-P+"px",threshold:Jr(0,Ia(1,p))||1};let q=!0;function I(ie){const U=ie[0].intersectionRatio;if(!x2(v,e.getBoundingClientRect()))return d();if(U!==p){if(!q)return d();U?d(!1,U):o=setTimeout(()=>{d(!1,1e-7)},1e3)}q=!1}try{i=new IntersectionObserver(I,{..._,root:s.ownerDocument})}catch{i=new IntersectionObserver(I,_)}i.observe(e)}const h=En(e),f=()=>d(r);return h.addEventListener("resize",f),d(!0),()=>{h.removeEventListener("resize",f),u()}}function eL(e,t,r,i){i===void 0&&(i={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:u=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:h=!1}=i,f=Tp(e),y=o||s?[...f?ls(f):[],...t?ls(t):[]]:[];y.forEach(E=>{o&&E.addEventListener("scroll",r),s&&E.addEventListener("resize",r)});const p=f&&d?J6(f,r,s):null;let v=-1,b=null;u&&(b=new ResizeObserver(E=>{let[N]=E;N&&N.target===f&&b&&t&&(b.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(t)})),r()}),f&&!h&&b.observe(f),t&&b.observe(t));let w,C=h?_i(e):null;h&&j();function j(){const E=_i(e);C&&!x2(C,E)&&r(),C=E,w=requestAnimationFrame(j)}return r(),()=>{var E;y.forEach(N=>{o&&N.removeEventListener("scroll",r),s&&N.removeEventListener("resize",r)}),p?.(),(E=b)==null||E.disconnect(),b=null,h&&cancelAnimationFrame(w)}}const tL=O6,nL=R6,rL=N6,aL=D6,iL=A6,L0=j6,lL=_6,oL=(e,t,r)=>{const i=new Map,o=r??{},s={...W6,...o.platform,_c:i};return E6(e,t,{...o,platform:s})};var sL=typeof document<"u",uL=function(){},ic=sL?k.useLayoutEffect:uL;function gc(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,i,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(i=r;i--!==0;)if(!gc(e[i],t[i]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(i=r;i--!==0;)if(!{}.hasOwnProperty.call(t,o[i]))return!1;for(i=r;i--!==0;){const s=o[i];if(!(s==="_owner"&&e.$$typeof)&&!gc(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function v2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function P0(e,t){const r=v2(e);return Math.round(t*r)/r}function Uh(e){const t=k.useRef(e);return ic(()=>{t.current=e}),t}function cL(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:i=[],platform:o,elements:{reference:s,floating:u}={},transform:d=!0,whileElementsMounted:h,open:f}=e,[y,p]=k.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[v,b]=k.useState(i);gc(v,i)||b(i);const[w,C]=k.useState(null),[j,E]=k.useState(null),N=k.useCallback(le=>{le!==_.current&&(_.current=le,C(le))},[]),R=k.useCallback(le=>{le!==q.current&&(q.current=le,E(le))},[]),P=s||w,H=u||j,_=k.useRef(null),q=k.useRef(null),I=k.useRef(y),ie=h!=null,U=Uh(h),te=Uh(o),Y=Uh(f),fe=k.useCallback(()=>{if(!_.current||!q.current)return;const le={placement:t,strategy:r,middleware:v};te.current&&(le.platform=te.current),oL(_.current,q.current,le).then(he=>{const O={...he,isPositioned:Y.current!==!1};oe.current&&!gc(I.current,O)&&(I.current=O,wc.flushSync(()=>{p(O)}))})},[v,t,r,te,Y]);ic(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(le=>({...le,isPositioned:!1})))},[f]);const oe=k.useRef(!1);ic(()=>(oe.current=!0,()=>{oe.current=!1}),[]),ic(()=>{if(P&&(_.current=P),H&&(q.current=H),P&&H){if(U.current)return U.current(P,H,fe);fe()}},[P,H,fe,U,ie]);const re=k.useMemo(()=>({reference:_,floating:q,setReference:N,setFloating:R}),[N,R]),L=k.useMemo(()=>({reference:P,floating:H}),[P,H]),Z=k.useMemo(()=>{const le={position:r,left:0,top:0};if(!L.floating)return le;const he=P0(L.floating,y.x),O=P0(L.floating,y.y);return d?{...le,transform:"translate("+he+"px, "+O+"px)",...v2(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:he,top:O}},[r,d,L.floating,y.x,y.y]);return k.useMemo(()=>({...y,update:fe,refs:re,elements:L,floatingStyles:Z}),[y,fe,re,L,Z])}const dL=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:i,padding:o}=typeof e=="function"?e(r):e;return i&&t(i)?i.current!=null?L0({element:i.current,padding:o}).fn(r):{}:i?L0({element:i,padding:o}).fn(r):{}}}},fL=(e,t)=>{const r=tL(e);return{name:r.name,fn:r.fn,options:[e,t]}},hL=(e,t)=>{const r=nL(e);return{name:r.name,fn:r.fn,options:[e,t]}},mL=(e,t)=>({fn:lL(e).fn,options:[e,t]}),pL=(e,t)=>{const r=rL(e);return{name:r.name,fn:r.fn,options:[e,t]}},gL=(e,t)=>{const r=aL(e);return{name:r.name,fn:r.fn,options:[e,t]}},yL=(e,t)=>{const r=iL(e);return{name:r.name,fn:r.fn,options:[e,t]}},xL=(e,t)=>{const r=dL(e);return{name:r.name,fn:r.fn,options:[e,t]}};var vL=Object.defineProperty,bL=(e,t)=>vL(e,"name",{value:t,configurable:!0});function b2(e){const[t,r]=k.useState(void 0);return hn(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let u,d;if("borderBoxSize"in s){const h=s.borderBoxSize,f=Array.isArray(h)?h[0]:h;u=f.inlineSize,d=f.blockSize}else u=e.offsetWidth,d=e.offsetHeight;r({width:u,height:d})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else r(void 0)},[e]),t}bL(b2,"useSize");var wL=Object.defineProperty,Ba=(e,t)=>wL(e,"name",{value:t,configurable:!0}),w2="Popper",[S2,Kl]=Ya(w2),[SL,k2]=S2(w2),kL=Ba(e=>{const{__scopePopper:t,children:r}=e,[i,o]=k.useState(null),[s,u]=k.useState(void 0);return m.jsx(SL,{scope:t,anchor:i,onAnchorChange:o,placementState:s,setPlacementState:u,children:r})},"Popper"),CL="PopperAnchor",EL=k.forwardRef(Ba(function(t,r){const{__scopePopper:i,virtualRef:o,...s}=t,u=k2(CL,i),d=k.useRef(null),h=u.onAnchorChange,f=k.useCallback(C=>{d.current=C,C&&h(C)},[h]),y=zt(r,f),p=k.useRef(null);k.useEffect(()=>{if(!o)return;const C=p.current;p.current=o.current,C!==p.current&&h(p.current)});const v=u.placementState&&qc(u.placementState),b=v?.[0],w=v?.[1];return o?null:m.jsx(et.div,{"data-radix-popper-side":b,"data-radix-popper-align":w,...s,ref:y})},"PopperAnchor")),C2="PopperContent",[jL,TP]=S2(C2),NL=k.forwardRef(Ba(function(t,r){const{__scopePopper:i,side:o="bottom",sideOffset:s=0,align:u="center",alignOffset:d=0,arrowPadding:h=0,avoidCollisions:f=!0,collisionBoundary:y=[],collisionPadding:p=0,sticky:v="partial",hideWhenDetached:b=!1,updatePositionStrategy:w="optimized",onPlaced:C,...j}=t,E=k2(C2,i),[N,R]=k.useState(null),P=zt(r,R),[H,_]=k.useState(null),q=b2(H),I=q?.width??0,ie=q?.height??0,U=o+(u!=="center"?"-"+u:""),te=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Y=Array.isArray(y)?y:[y],fe=Y.length>0,oe={padding:te,boundary:Y.filter(E2),altBoundary:fe},{refs:re,floatingStyles:L,placement:Z,isPositioned:le,middlewareData:he}=cL({strategy:"fixed",placement:U,whileElementsMounted:Ba((...ue)=>eL(...ue,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:E.anchor},middleware:[fL({mainAxis:s+ie,alignmentAxis:d}),f&&hL({mainAxis:!0,crossAxis:!1,limiter:v==="partial"?mL():void 0,...oe}),f&&pL({...oe}),gL({...oe,apply:Ba(({elements:ue,rects:tt,availableWidth:bt,availableHeight:It})=>{const{width:Wt,height:Et}=tt.reference,Tn=ue.floating.style;Tn.setProperty("--radix-popper-available-width",`${bt}px`),Tn.setProperty("--radix-popper-available-height",`${It}px`),Tn.setProperty("--radix-popper-anchor-width",`${Wt}px`),Tn.setProperty("--radix-popper-anchor-height",`${Et}px`)},"apply")}),H&&xL({element:H,padding:h}),AL({arrowWidth:I,arrowHeight:ie}),b&&yL({strategy:"referenceHidden",...oe,boundary:fe?oe.boundary:void 0})]}),O=E.setPlacementState;hn(()=>(O(Z),()=>{O(void 0)}),[Z,O]);const[M,z]=qc(Z),T=Cn(C);hn(()=>{le&&T?.()},[le,T]);const G=he.arrow?.x,K=he.arrow?.y,J=he.arrow?.centerOffset!==0,[me,Ne]=k.useState();return hn(()=>{N&&Ne(window.getComputedStyle(N).zIndex)},[N]),m.jsx("div",{ref:re.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:le?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:me,"--radix-popper-transform-origin":[he.transformOrigin?.x,he.transformOrigin?.y].join(" "),...he.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:m.jsx(jL,{scope:i,placedSide:M,placedAlign:z,onArrowChange:_,arrowX:G,arrowY:K,shouldHideArrow:J,children:m.jsx(et.div,{"data-side":M,"data-align":z,...j,ref:P,style:{...j.style,animation:le?j.style?.animation:"none"}})})})},"PopperContent"));function E2(e){return e!==null}Ba(E2,"isNotNull");var AL=Ba(e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:i,middlewareData:o}=t,u=o.arrow?.centerOffset!==0,d=u?0:e.arrowWidth,h=u?0:e.arrowHeight,[f,y]=qc(r),p={start:"0%",center:"50%",end:"100%"}[y],v=(o.arrow?.x??0)+d/2,b=(o.arrow?.y??0)+h/2;let w="",C="";return f==="bottom"?(w=u?p:`${v}px`,C=`${-h}px`):f==="top"?(w=u?p:`${v}px`,C=`${i.floating.height+h}px`):f==="right"?(w=`${-h}px`,C=u?p:`${b}px`):f==="left"&&(w=`${i.floating.width+h}px`,C=u?p:`${b}px`),{data:{x:w,y:C}}}}),"transformOrigin");function qc(e){const[t,r="center"]=e.split("-");return[t,r]}Ba(qc,"getSideAndAlignFromPlacement");var Op=kL,Fc=EL,Rp=NL,TL=Object.defineProperty,OL=(e,t)=>TL(e,"name",{value:t,configurable:!0}),RL=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),_L=k.forwardRef(OL(function(t,r){return m.jsx(et.span,{...t,ref:r,style:{...RL,...t.style}})},"VisuallyHidden")),DL=_L,ML=Object.defineProperty,Yt=(e,t)=>ML(e,"name",{value:t,configurable:!0}),[_p,OP]=Ya("Tooltip",[Kl]),Dp=Kl(),zL="TooltipProvider",LL=700,Am="tooltip.open",[PL,Mp]=_p(zL),HL=Yt(e=>{const{__scopeTooltip:t,delayDuration:r=LL,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:s}=e,u=k.useRef(!0),d=k.useRef(!1),h=k.useRef(0);return k.useEffect(()=>{const f=h.current;return()=>window.clearTimeout(f)},[]),m.jsx(PL,{scope:t,isOpenDelayedRef:u,delayDuration:r,onOpen:k.useCallback(()=>{i<=0||(window.clearTimeout(h.current),u.current=!1)},[i]),onClose:k.useCallback(()=>{i<=0||(window.clearTimeout(h.current),h.current=window.setTimeout(()=>u.current=!0,i))},[i]),isPointerInTransitRef:d,onPointerInTransitChange:k.useCallback(f=>{d.current=f},[]),disableHoverableContent:o,children:s})},"TooltipProvider"),Tm="Tooltip",[UL,ks]=_p(Tm),BL=Yt(e=>{const{__scopeTooltip:t,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:u,delayDuration:d}=e,h=Mp(Tm,e.__scopeTooltip),f=Dp(t),[y,p]=k.useState(null),[v,b]=k.useState(void 0),w=qn(),C=k.useRef(0),j=u??h.disableHoverableContent,E=d??h.delayDuration,N=k.useRef(!1),[R,P]=$l({prop:i,defaultProp:o??!1,onChange:Yt(U=>{U?(h.onOpen(),document.dispatchEvent(new CustomEvent(Am))):h.onClose(),s?.(U)},"onChange"),caller:Tm}),H=k.useMemo(()=>R?N.current?"delayed-open":"instant-open":"closed",[R]),_=k.useCallback(()=>{window.clearTimeout(C.current),C.current=0,N.current=!1,P(!0)},[P]),q=k.useCallback(()=>{window.clearTimeout(C.current),C.current=0,P(!1)},[P]),I=k.useCallback(()=>{window.clearTimeout(C.current),C.current=window.setTimeout(()=>{N.current=!0,P(!0),C.current=0},E)},[E,P]);k.useEffect(()=>()=>{C.current&&(window.clearTimeout(C.current),C.current=0)},[]);const ie=v??w;return m.jsx(Op,{...f,children:m.jsx(UL,{scope:t,contentId:ie,setContentId:b,open:R,stateAttribute:H,trigger:y,onTriggerChange:p,onTriggerEnter:k.useCallback(()=>{h.isOpenDelayedRef.current?I():_()},[h.isOpenDelayedRef,I,_]),onTriggerLeave:k.useCallback(()=>{j?q():(window.clearTimeout(C.current),C.current=0)},[q,j]),onOpen:_,onClose:q,disableHoverableContent:j,children:r})})},"Tooltip"),H0="TooltipTrigger",IL=k.forwardRef(Yt(function(t,r){const{__scopeTooltip:i,...o}=t,s=ks(H0,i),u=Mp(H0,i),d=Dp(i),h=k.useRef(null),f=zt(r,h,s.onTriggerChange),y=k.useRef(!1),p=k.useRef(!1),v=k.useCallback(()=>y.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",v),[v]),m.jsx(Fc,{asChild:!0,...d,children:m.jsx(et.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...o,ref:f,onPointerMove:Ye(t.onPointerMove,b=>{b.pointerType!=="touch"&&!p.current&&!u.isPointerInTransitRef.current&&(s.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ye(t.onPointerLeave,()=>{s.onTriggerLeave(),p.current=!1}),onPointerDown:Ye(t.onPointerDown,()=>{s.open&&s.onClose(),y.current=!0,document.addEventListener("pointerup",v,{once:!0})}),onFocus:Ye(t.onFocus,()=>{y.current||s.onOpen()}),onBlur:Ye(t.onBlur,s.onClose),onClick:Ye(t.onClick,s.onClose)})})},"TooltipTrigger")),j2="TooltipPortal",[qL,FL]=_p(j2,{forceMount:void 0}),$L=Yt(e=>{const{__scopeTooltip:t,forceMount:r,children:i,container:o}=e,s=ks(j2,t);return m.jsx(qL,{scope:t,forceMount:r,children:m.jsx(An,{present:r||s.open,children:m.jsx(Mc,{asChild:!0,container:o,children:i})})})},"TooltipPortal"),os="TooltipContent",VL=k.forwardRef(Yt(function(t,r){const i=FL(os,t.__scopeTooltip),{forceMount:o=i.forceMount,side:s="top",...u}=t,d=ks(os,t.__scopeTooltip);return m.jsx(An,{present:o||d.open,children:d.disableHoverableContent?m.jsx(N2,{side:s,...u,ref:r}):m.jsx(YL,{side:s,...u,ref:r})})},"TooltipContent")),YL=k.forwardRef(Yt(function(t,r){const i=ks(os,t.__scopeTooltip),o=Mp(os,t.__scopeTooltip),s=k.useRef(null),u=zt(r,s),[d,h]=k.useState(null),{trigger:f,onClose:y}=i,p=s.current,{onPointerInTransitChange:v}=o,b=k.useCallback(()=>{h(null),v(!1)},[v]),w=k.useCallback((C,j)=>{const E=C.currentTarget,N={x:C.clientX,y:C.clientY},R=A2(N,E.getBoundingClientRect()),P=T2(N,R),H=O2(j.getBoundingClientRect()),_=_2([...P,...H]);h(_),v(!0)},[v]);return k.useEffect(()=>()=>b(),[b]),k.useEffect(()=>{if(f&&p){const C=Yt(E=>w(E,p),"handleTriggerLeave"),j=Yt(E=>w(E,f),"handleContentLeave");return f.addEventListener("pointerleave",C),p.addEventListener("pointerleave",j),()=>{f.removeEventListener("pointerleave",C),p.removeEventListener("pointerleave",j)}}},[f,p,w,b]),k.useEffect(()=>{if(d){const C=Yt(j=>{const E=j.target,N={x:j.clientX,y:j.clientY},R=f?.contains(E)||p?.contains(E),P=!R2(N,d);R?b():P&&(b(),y())},"handleTrackPointerGrace");return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[f,p,d,y,b]),m.jsx(N2,{...t,ref:u})},"TooltipContentHoverable")),QL=iS("TooltipContent"),N2=k.forwardRef(Yt(function(t,r){const{__scopeTooltip:i,children:o,"aria-label":s,id:u,onEscapeKeyDown:d,onPointerDownOutside:h,...f}=t,y=ks(os,i),p=Dp(i),{onClose:v}=y;k.useEffect(()=>(document.addEventListener(Am,v),()=>document.removeEventListener(Am,v)),[v]),k.useEffect(()=>{if(y.trigger){const w=Yt(C=>{C.target instanceof Node&&C.target.contains(y.trigger)&&v()},"handleScroll");return window.addEventListener("scroll",w,{capture:!0}),()=>window.removeEventListener("scroll",w,{capture:!0})}},[y.trigger,v]);const{setContentId:b}=y;return hn(()=>(b(u),()=>{b(void 0)}),[u,b]),m.jsx(Dc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:w=>w.preventDefault(),onDismiss:v,children:m.jsxs(Rp,{"data-state":y.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:y.contentId,...p,...f,ref:r,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(QL,{children:o}),s?m.jsx(DL,{id:y.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function A2(e,t){const r=Math.abs(t.top-e.y),i=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(r,i,o,s)){case s:return"left";case o:return"right";case r:return"top";case i:return"bottom";default:throw new Error("unreachable")}}Yt(A2,"getExitSideFromRect");function T2(e,t,r=5){const i=[];switch(t){case"top":i.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":i.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":i.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":i.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return i}Yt(T2,"getPaddedExitPoints");function O2(e){const{top:t,right:r,bottom:i,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:i},{x:o,y:i}]}Yt(O2,"getPointsFromRect");function R2(e,t){const{x:r,y:i}=e;let o=!1;for(let s=0,u=t.length-1;s<t.length;u=s++){const d=t[s],h=t[u],f=d.x,y=d.y,p=h.x,v=h.y;y>i!=v>i&&r<(p-f)*(i-y)/(v-y)+f&&(o=!o)}return o}Yt(R2,"isPointInPolygon");function _2(e){const t=e.slice();return t.sort((r,i)=>r.x<i.x?-1:r.x>i.x?1:r.y<i.y?-1:r.y>i.y?1:0),D2(t)}Yt(_2,"getHull");function D2(e){if(e.length<=1)return e.slice();const t=[];for(let i=0;i<e.length;i++){const o=e[i];for(;t.length>=2;){const s=t[t.length-1],u=t[t.length-2];if((s.x-u.x)*(o.y-u.y)>=(s.y-u.y)*(o.x-u.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let i=e.length-1;i>=0;i--){const o=e[i];for(;r.length>=2;){const s=r[r.length-1],u=r[r.length-2];if((s.x-u.x)*(o.y-u.y)>=(s.y-u.y)*(o.x-u.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}Yt(D2,"getHullPresorted");var GL=HL,KL=BL,XL=IL,ZL=$L,WL=VL;const zp=k.forwardRef(({className:e,children:t,...r},i)=>m.jsxs(i6,{ref:i,className:ge("relative overflow-hidden",e),...r,children:[m.jsx(l6,{className:"h-full w-full rounded-[inherit]",children:t}),m.jsx(o6,{orientation:"vertical",className:"flex touch-none select-none transition-colors p-0.5 w-2.5",children:m.jsx(s6,{className:"relative flex-1 rounded-full bg-border"})}),m.jsx(u6,{})]}));zp.displayName="ScrollArea";const JL=k.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...i},o)=>m.jsx(h6,{ref:o,decorative:r,orientation:t,className:ge("shrink-0 bg-border",t==="horizontal"?"h-px w-full":"h-full w-px",e),...i}));JL.displayName="Separator";const e8=GL,t8=KL,n8=XL,M2=k.forwardRef(({className:e,sideOffset:t=4,...r},i)=>m.jsx(ZL,{children:m.jsx(WL,{ref:i,sideOffset:t,className:ge("z-50 overflow-hidden rounded-md border bg-popover px-2.5 py-1 text-xs text-popover-foreground shadow-md max-w-xs",e),...r})}));M2.displayName="TooltipContent";function r8(e){const{data:t}=Nc(e);return(t?.comments??[]).filter(r=>r.status==="open"&&r.thread.at(-1)?.role!=="author").length}function a8(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60);return r<60?`${r}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(r/60)}h ${String(r%60).padStart(2,"0")}m`}function i8(e,t,r){const[i,o]=k.useState(()=>Date.now());if(k.useEffect(()=>{if(!r)return;o(Date.now());const d=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(d)},[r]),!e)return null;const s=Date.parse(e);if(Number.isNaN(s))return null;const u=r?i:t?Date.parse(t):i;return Math.max(0,u-s)}function z2({run:e,className:t}){const r=Ec(e),i=i8(e?.createdAt,e?.finishedAt,r);return i==null?null:m.jsx("span",{className:ge("tabular-nums",t),title:r?"Working time so far":"Total run time",children:a8(i)})}function l8(){const e=ke(w=>w.domainId),t=hs(e),r=$m(e),i=Wr(w=>w.setRun),o=Wr(w=>w.setDrawer),s=r8(e),[u,d]=k.useState(!1),h=Bt(),f=Ec(r),y=t.data?.available??!1,p=async()=>{if(e){d(!0);try{const w=await je.agentSubmit(e);w.error?Ee.error(w.error):(i(w),Ee.success("Sent to the agent"))}catch(w){Ee.error(String(w))}finally{d(!1),h.invalidateQueries({queryKey:Se.agent(e)})}}};if(f)return m.jsxs(Ke,{size:"sm",variant:"secondary",onClick:()=>o(!0),title:"Show agent activity — running time so far",children:[m.jsx(dn,{className:"h-4 w-4 animate-spin"})," Agent working…",m.jsx(z2,{run:r,className:"ml-0.5 text-[11px] font-normal text-muted-foreground"})]});const v=u||!y,b=y?s===0?"No open threads awaiting a reply yet":`Send ${s} open thread${s===1?"":"s"} to the agent`:`${t.data?.harness??"agent"} not available — set DOMAIN_STUDIO_HARNESS or install the CLI`;return m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs(Ke,{size:"sm",onClick:p,disabled:v,title:b,children:[u?m.jsx(dn,{className:"h-4 w-4 animate-spin"}):m.jsx(Im,{className:"h-4 w-4"})," Submit to agent",s>0&&m.jsx("span",{className:"rounded-full bg-primary-foreground/20 px-1.5 text-[10px] font-semibold",children:s})]}),r&&m.jsx(Ke,{size:"icon",variant:"ghost",onClick:()=>o(!0),title:"Agent activity",children:m.jsx(fs,{className:"h-4 w-4"})})]})}function o8(e){switch(e.kind){case"message":return{icon:m.jsx(Ei,{className:"h-3.5 w-3.5"}),tone:"text-primary"};case"thinking":return{icon:m.jsx(fs,{className:"h-3.5 w-3.5"}),tone:"text-muted-foreground"};case"reply":return{icon:m.jsx(y1,{className:"h-3.5 w-3.5"}),tone:"text-success"};case"error":return{icon:m.jsx(kc,{className:"h-3.5 w-3.5"}),tone:"text-destructive"};case"tool":{const t=e.tool??"";return t==="Edit"||t==="Write"||t==="MultiEdit"?{icon:m.jsx(PN,{className:"h-3.5 w-3.5"}),tone:"text-warning"}:t==="Bash"?{icon:m.jsx(rT,{className:"h-3.5 w-3.5"}),tone:"text-foreground/70"}:{icon:m.jsx(hT,{className:"h-3.5 w-3.5"}),tone:"text-foreground/60"}}default:return{icon:m.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/50"}),tone:"text-muted-foreground"}}}function s8(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)}k`:`${(e/1e6).toFixed(1)}M`}const u8=k.memo(function({e:t}){const{icon:r,tone:i}=o8(t),o=t.kind==="thinking";return m.jsxs("div",{className:"flex gap-2.5 px-4 py-2",children:[m.jsx("div",{className:ge("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center",i),children:r}),m.jsx("div",{className:"min-w-0 flex-1",children:t.kind==="tool"?m.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[13px]",children:[m.jsx("span",{className:"font-medium text-foreground/90",children:t.tool}),t.target&&m.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:t.target})]}):t.kind==="message"||t.kind==="reply"?m.jsx(nS,{text:t.text}):m.jsx("p",{className:ge("whitespace-pre-wrap break-words text-[13px] leading-relaxed",o?"italic text-muted-foreground":"text-foreground/90"),children:t.text})})]})}),c8={queued:"warning",running:"warning",succeeded:"success",failed:"destructive",canceled:"muted",interrupted:"warning"};function U0({title:e,text:t}){return m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:e}),m.jsx("pre",{className:"max-h-[36vh] overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/35 p-3 font-mono text-[11px] leading-relaxed",children:t})]})}function d8({prompt:e,onClose:t}){return m.jsx(Vl,{open:!0,onOpenChange:r=>!r&&t(),children:m.jsxs(Li,{className:"max-w-4xl",children:[m.jsx(Yl,{children:m.jsx(Pi,{children:"Prompt sent to agent"})}),m.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[m.jsx("span",{children:e.firstTurn?"new session":"follow-up turn"}),m.jsx("span",{children:e.resumed?"resumed":"fresh"}),e.model&&m.jsxs("span",{className:"font-mono",children:["model ",e.model]}),e.effort&&m.jsxs("span",{children:["effort ",e.effort]}),m.jsx("span",{children:new Date(e.createdAt).toLocaleString()}),e.sessionId&&m.jsxs("span",{className:"font-mono",children:["session ",e.sessionId]}),e.mcpTools.length>0&&m.jsxs("span",{children:["bridge tools: ",e.mcpTools.join(", ")]})]}),m.jsxs("div",{className:"max-h-[72vh] space-y-4 overflow-y-auto pr-1",children:[m.jsx(U0,{title:"Turn prompt (stdin)",text:e.turnPrompt}),m.jsx(U0,{title:"System appendix (--append-system-prompt)",text:e.systemPrompt})]})]})})}function f8(){const e=Wr(I=>I.drawerOpen),t=Wr(I=>I.setDrawer),r=ke(I=>I.domainId),i=ke(I=>I.setSection),o=$m(r),s=hs(r),u=Wr(I=>I.setRun),d=Bt(),[h,f]=k.useState(!1),[y,p]=k.useState(!1),[v,b]=k.useState(!1),[w,C]=k.useState(!1),j=k.useRef(null),E=Ec(o),N=o?.events??[],R=s.data?.conversation,P=R?.turns??0,H=async()=>{if(!(!r||y||E)){p(!0);try{(await je.agentReset(r)).ok?Ee.success("Started a fresh conversation — the next submit won’t remember earlier turns"):Ee.error("Could not reset — a run may be in progress")}catch(I){Ee.error(String(I))}finally{p(!1),d.invalidateQueries({queryKey:Se.agent(r)})}}},_=async()=>{if(!(!r||v||E)){b(!0);try{const I=await je.agentResume(r);I.error?Ee.error(I.error):(u(I),Ee.success("Resuming where the agent left off"))}catch(I){Ee.error(String(I))}finally{b(!1),d.invalidateQueries({queryKey:Se.agent(r)})}}};k.useEffect(()=>{e&&j.current&&(j.current.scrollTop=j.current.scrollHeight)},[N.length,e]),k.useEffect(()=>f(!1),[o?.id]);const q=async()=>{if(!(!r||h)){f(!0);try{await je.agentCancel(r),Ee.message("Cancelling the agent…")}catch{f(!1)}}};return k.useEffect(()=>{if(!e)return;const I=ie=>{ie.key==="Escape"&&t(!1)};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e,t]),e?m.jsxs(m.Fragment,{children:[m.jsxs("aside",{className:"fixed inset-y-0 right-0 z-50 flex w-[440px] max-w-[92vw] flex-col border-l bg-card shadow-2xl",children:[m.jsxs("div",{className:"flex items-center gap-2.5 border-b px-4 h-14 shrink-0",children:[m.jsx("div",{className:ge("flex h-7 w-7 items-center justify-center rounded-lg",E?"bg-warning/15 text-warning":"bg-primary/15 text-primary"),children:E?m.jsx(dn,{className:"h-4 w-4 animate-spin"}):m.jsx(oN,{className:"h-4 w-4"})}),m.jsx("div",{className:"min-w-0",children:m.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:["Agent",m.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:s.data?.harness??o?.harness})]})}),o&&m.jsx(Wo,{variant:c8[o.status],className:"ml-1 capitalize",children:o.status}),o&&m.jsx(z2,{run:o,className:"text-[11px] text-muted-foreground/70"}),o?.prompt&&m.jsx("button",{type:"button",onClick:()=>C(!0),className:"ml-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground",title:"Show the exact prompt sent to the local agent",children:"Sent prompt"}),m.jsx("button",{type:"button",onClick:()=>t(!1),className:"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 hover:bg-accent hover:text-foreground",children:m.jsx(es,{className:"h-4 w-4"})})]}),R?.active&&m.jsxs("div",{className:"flex items-center gap-2 border-b bg-muted/30 px-4 py-1.5 text-xs text-muted-foreground shrink-0",children:[m.jsx(JN,{className:"h-3.5 w-3.5 shrink-0 opacity-70"}),m.jsxs("span",{className:"min-w-0 truncate",children:["Conversation · ",P," turn",P===1?"":"s",m.jsx("span",{className:"opacity-60",children:" · the agent remembers earlier turns"})]}),m.jsxs("button",{type:"button",onClick:H,disabled:E||y,className:"ml-auto inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 hover:bg-accent hover:text-foreground disabled:opacity-40",title:"Start a fresh conversation — the next submit won't remember earlier turns",children:[y?m.jsx(dn,{className:"h-3 w-3 animate-spin"}):m.jsx(HA,{className:"h-3 w-3"})," ","Start fresh"]})]}),m.jsx(zp,{className:"flex-1 min-h-0",children:m.jsx("div",{ref:j,className:"h-full overflow-y-auto overflow-x-hidden py-1.5",children:o?N.length===0?m.jsx("div",{className:"px-4 py-16 text-center text-sm text-muted-foreground",children:"Starting the agent…"}):m.jsx("div",{className:"divide-y divide-border/40",children:N.map(I=>m.jsx(u8,{e:I},I.id))}):m.jsxs("div",{className:"px-4 py-16 text-center text-sm text-muted-foreground",children:["No agent run yet. Add a comment and press"," ",m.jsx("span",{className:"font-medium text-foreground",children:"Submit to agent"}),"."]})})}),m.jsx("div",{className:"border-t px-4 py-3 shrink-0",children:E?m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-xs text-muted-foreground",children:"Editing your domain…"}),m.jsxs(Ke,{size:"sm",variant:"outline",onClick:q,disabled:h,children:[h?m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(es,{className:"h-3.5 w-3.5"})," ","Cancel"]})]}):o?m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",children:[o.status==="canceled"?m.jsx("span",{className:"text-muted-foreground",children:"canceled — stopped before finishing"}):o.status==="interrupted"?m.jsx("span",{className:"text-warning",children:"Interrupted by a studio restart — conversation intact."}):o.status==="failed"?m.jsx("span",{className:"text-destructive",children:o.error??"failed"}):m.jsxs(m.Fragment,{children:[m.jsx(aa,{className:"h-3.5 w-3.5 text-success"}),[o.liveReplies?`${o.liveReplies} live`:"",o.merge&&(o.merge.merged||o.merge.closed)?`merged ${o.merge.merged}, closed ${o.merge.closed}`:""].filter(Boolean).join(" · ")||"done"]}),o.merge?.schemaMismatch&&m.jsx("span",{className:"text-warning",children:"⚠ replied against an older schema"}),o.merge&&o.merge.unknownIds.length>0&&m.jsxs("span",{className:"text-warning",children:["⚠ ",o.merge.unknownIds.length," unknown id(s)"]}),typeof o.tokens=="number"&&o.tokens>0&&m.jsxs("span",{className:"opacity-60",children:["· ",s8(o.tokens)," tokens"]})]}),o.status==="interrupted"?m.jsxs(Ke,{size:"sm",onClick:_,disabled:v,title:"Continue the agent from where it was interrupted",children:[v?m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(OA,{className:"h-3.5 w-3.5"})," ","Resume"]}):m.jsxs(Ke,{size:"sm",variant:"outline",onClick:()=>{t(!1),i("comments")},children:[m.jsx(Ei,{className:"h-3.5 w-3.5"})," View replies"]})]}):null})]}),w&&o?.prompt&&m.jsx(d8,{prompt:o.prompt,onClose:()=>C(!1)})]}):null}async function h8(e,t,r,i){const o=await fetch(`/api/domain/${encodeURIComponent(e)}/agent/ask`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:i});if(!o.ok||!o.body){const y=await o.text().catch(()=>o.statusText);return{text:"",error:`${o.status} ${y}`.trim()}}const s=o.body.getReader(),u=new TextDecoder;let d="",h="",f;for(;;){const{value:y,done:p}=await s.read();if(p)break;d+=u.decode(y,{stream:!0});let v;for(;(v=d.indexOf(`
|
|
79
79
|
`))>=0;){const b=d.slice(0,v).trim();if(d=d.slice(v+1),!!b)try{const w=JSON.parse(b);typeof w.delta=="string"?r(w.delta):typeof w.done=="string"?h=w.done:w.error&&(f=String(w.error))}catch{}}}return{text:h,error:f}}const m8=(e,t)=>`${e}::${t}`,wi=new Map,nr=Cc((e,t)=>({entries:{},openKey:null,start:(r,i,o,s,u)=>{const d=m8(r,i.ref);e(h=>{const f=h.entries[d],y=f?{...f,x:s,y:u,seen:!0}:{key:d,ref:i.ref,domainId:r,anchor:i,excerpt:o,x:s,y:u,question:"",answer:"",status:"composing",seen:!0};return{entries:{...h.entries,[d]:y},openKey:d}})},submit:(r,i)=>{const o=t().entries[r];if(!o)return;wi.get(r)?.abort();const s=new AbortController;wi.set(r,s),e(d=>({entries:{...d.entries,[r]:{...o,question:i,answer:"",status:"streaming",error:void 0,seen:!0}}}));const u=d=>e(h=>{const f=h.entries[r];return f?{entries:{...h.entries,[r]:d(f)}}:h});h8(o.domainId,{anchor:o.anchor,excerpt:o.excerpt,question:i},d=>{s.signal.aborted||u(h=>({...h,answer:h.answer+d}))},s.signal).then(d=>{s.signal.aborted||u(h=>({...h,status:d.error?"error":"done",error:d.error,answer:h.answer||d.text,seen:t().openKey===r}))}).catch(d=>{s.signal.aborted||u(h=>({...h,status:"error",error:String(d),seen:t().openKey===r}))})},recompose:r=>{wi.get(r)?.abort(),e(i=>{const o=i.entries[r];return o?{entries:{...i.entries,[r]:{...o,question:"",answer:"",status:"composing",error:void 0,seen:!0}}}:i})},open:r=>e(i=>({openKey:r,entries:i.entries[r]?{...i.entries,[r]:{...i.entries[r],seen:!0}}:i.entries})),collapse:()=>e({openKey:null}),remove:r=>{wi.get(r)?.abort(),wi.delete(r),e(i=>{const{[r]:o,...s}=i.entries;return{entries:s,openKey:i.openKey===r?null:i.openKey}})},keepOnly:r=>e(i=>{const o={};for(const[s,u]of Object.entries(i.entries))u.domainId===r?o[s]=u:(wi.get(s)?.abort(),wi.delete(s));return{entries:o,openKey:i.openKey&&o[i.openKey]?i.openKey:null}})}));var p8=Object.defineProperty,sa=(e,t)=>p8(e,"name",{value:t,configurable:!0}),Lp="Popover",[L2,RP]=Ya(Lp,[Kl]),$c=Kl(),[g8,Hi]=L2(Lp),y8=sa(e=>{const{__scopePopover:t,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:u=!1}=e,d=$c(t),h=k.useRef(null),[f,y]=k.useState(!1),[p,v]=$l({prop:i,defaultProp:o??!1,onChange:s,caller:Lp});return m.jsx(Op,{...d,children:m.jsx(g8,{scope:t,contentId:qn(),triggerRef:h,open:p,onOpenChange:v,onOpenToggle:k.useCallback(()=>v(b=>!b),[v]),hasCustomAnchor:f,onCustomAnchorAdd:k.useCallback(()=>y(!0),[]),onCustomAnchorRemove:k.useCallback(()=>y(!1),[]),modal:u,children:r})})},"Popover"),x8="PopoverAnchor",v8=k.forwardRef(sa(function(t,r){const{__scopePopover:i,...o}=t,s=Hi(x8,i),u=$c(i),{onCustomAnchorAdd:d,onCustomAnchorRemove:h}=s;return k.useEffect(()=>(d(),()=>h()),[d,h]),m.jsx(Fc,{...u,...o,ref:r})},"PopoverAnchor")),b8="PopoverTrigger",w8=k.forwardRef(sa(function(t,r){const{__scopePopover:i,...o}=t,s=Hi(b8,i),u=$c(i),d=zt(r,s.triggerRef),h=m.jsx(et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":Pp(s.open),...o,ref:d,onClick:Ye(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?h:m.jsx(Fc,{asChild:!0,...u,children:h})},"PopoverTrigger")),P2="PopoverPortal",[S8,k8]=L2(P2,{forceMount:void 0}),C8=sa(e=>{const{__scopePopover:t,forceMount:r,children:i,container:o}=e,s=Hi(P2,t);return m.jsx(S8,{scope:t,forceMount:r,children:m.jsx(An,{present:r||s.open,children:m.jsx(Mc,{asChild:!0,container:o,children:i})})})},"PopoverPortal"),ss="PopoverContent",E8=k.forwardRef(sa(function(t,r){const i=k8(ss,t.__scopePopover),{forceMount:o=i.forceMount,...s}=t,u=Hi(ss,t.__scopePopover);return m.jsx(An,{present:o||u.open,children:u.modal?m.jsx(N8,{...s,ref:r}):m.jsx(A8,{...s,ref:r})})},"PopoverContent")),j8=xs("PopoverContent.RemoveScroll"),N8=k.forwardRef(sa(function(t,r){const i=Hi(ss,t.__scopePopover),o=k.useRef(null),s=zt(r,o),u=k.useRef(!1);return k.useEffect(()=>{const d=o.current;if(d)return IS(d)},[]),m.jsx(gp,{as:j8,allowPinchZoom:!0,children:m.jsx(H2,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ye(t.onCloseAutoFocus,d=>{d.preventDefault(),u.current||i.triggerRef.current?.focus()}),onPointerDownOutside:Ye(t.onPointerDownOutside,d=>{const h=d.detail.originalEvent,f=h.button===0&&h.ctrlKey===!0,y=h.button===2||f;u.current=y},{checkForDefaultPrevented:!1}),onFocusOutside:Ye(t.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),A8=k.forwardRef(sa(function(t,r){const i=Hi(ss,t.__scopePopover),o=k.useRef(!1),s=k.useRef(!1);return m.jsx(H2,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{t.onCloseAutoFocus?.(u),u.defaultPrevented||(o.current||i.triggerRef.current?.focus(),u.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:u=>{t.onInteractOutside?.(u),u.defaultPrevented||(o.current=!0,u.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const d=u.target;i.triggerRef.current?.contains(d)&&u.preventDefault(),u.detail.originalEvent.type==="focusin"&&s.current&&u.preventDefault()}})},"PopoverContentNonModal")),H2=k.forwardRef(sa(function(t,r){const{__scopePopover:i,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:u,disableOutsidePointerEvents:d,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:y,onInteractOutside:p,...v}=t,b=Hi(ss,i),w=$c(i);return zc(),m.jsx(SS,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:u,children:m.jsx(Dc,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:p,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:y,onDismiss:()=>b.onOpenChange(!1),deferPointerDownOutside:!0,children:m.jsx(Rp,{"data-state":Pp(b.open),role:"dialog",id:b.contentId,...w,...v,ref:r,style:{...v.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function Pp(e){return e?"open":"closed"}sa(Pp,"getState");var T8=y8,O8=v8,R8=w8,_8=C8,D8=E8;const Ui=T8,Vc=R8,Hp=O8,Ga=k.forwardRef(({className:e,align:t="start",side:r="right",sideOffset:i=8,...o},s)=>m.jsx(_8,{children:m.jsx(D8,{ref:s,align:t,side:r,sideOffset:i,collisionPadding:12,avoidCollisions:!0,sticky:"partial",onOpenAutoFocus:u=>u.preventDefault(),className:ge("z-50 w-80 max-h-[var(--radix-popover-content-available-height)] overflow-hidden rounded-xl border bg-card p-3 shadow-lg outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...o})}));Ga.displayName="PopoverContent";const Ar=k.forwardRef(({className:e,...t},r)=>m.jsx("textarea",{ref:r,className:ge("flex min-h-20 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 font-mono",e),...t}));Ar.displayName="Textarea";function M8(e){const t=e.ref;let r=null;try{t.startsWith("module.")?r=document.querySelector(`.react-flow__node[data-id="grp-${t.slice(7)}"]`):t.startsWith("edge.")?r=document.querySelector(`.react-flow__edge[data-id="edge-${t.slice(5)}"]`):r=document.querySelector(`.react-flow__node[data-id="${t}"]`)||document.querySelector(`[data-anchor-ref="${t}"]`)}catch{r=null}if(r){const i=r.getBoundingClientRect();if((i.width||i.height)&&i.bottom>0&&i.top<window.innerHeight)return{x:i.right-10,y:i.top+10}}return{x:e.x,y:e.y}}function z8({entry:e}){const t=nr(y=>y.submit),r=nr(y=>y.recompose),i=nr(y=>y.remove),o=nr(y=>y.collapse),[s,u]=k.useState(""),d=e.status==="composing",h=e.status==="done"||e.status==="error",f=()=>{const y=s.trim();y&&t(e.key,y)};return m.jsxs("div",{className:"flex flex-col gap-2 text-sm",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[m.jsx(fs,{className:"h-3.5 w-3.5 text-violet-400"}),m.jsx("span",{className:"text-muted-foreground",children:"Ask"}),m.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground/70",children:e.ref}),m.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-muted-foreground/60",children:"ephemeral"}),h&&m.jsx("button",{type:"button",title:"Minimize",onClick:o,className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-accent hover:text-foreground",children:m.jsx(CA,{className:"h-3.5 w-3.5"})}),(d||h)&&m.jsx("button",{type:"button",title:d?"Cancel":"Close",onClick:()=>i(e.key),className:"-mr-1 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-accent hover:text-foreground",children:m.jsx(es,{className:"h-3.5 w-3.5"})})]}),!d&&m.jsxs("div",{className:"space-y-1.5 rounded-md border bg-background/40 p-2",children:[m.jsxs("div",{className:"text-[13px] leading-snug",children:[m.jsx("span",{className:"mr-1.5 text-[10px] font-medium uppercase text-muted-foreground",children:"you"}),e.question]}),m.jsxs("div",{className:"text-[13px] leading-snug",children:[m.jsx("span",{className:"mr-1.5 text-[10px] font-medium uppercase text-violet-400",children:"agent"}),e.status==="streaming"&&!e.answer?m.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[m.jsx(dn,{className:"h-3 w-3 animate-spin"})," thinking…"]}):e.status==="error"?m.jsx("span",{className:"text-destructive",children:e.error}):m.jsxs("span",{className:"whitespace-pre-wrap break-words",children:[e.answer,e.status==="streaming"&&m.jsx("span",{className:"ml-0.5 inline-block h-3 w-[3px] animate-pulse bg-foreground/50 align-middle"})]})]})]}),d?m.jsxs("div",{className:"space-y-2",children:[m.jsx(Ar,{autoFocus:!0,className:"min-h-16 text-[13px]",placeholder:`Ask about ${e.excerpt}…`,value:s,onChange:y=>u(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),f())}}),m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("span",{className:"mr-auto text-[10px] text-muted-foreground",children:"⌘↵ to ask · forked aside"}),m.jsxs(Ke,{size:"sm",onClick:f,disabled:!s.trim(),children:[m.jsx(Im,{className:"h-3.5 w-3.5"})," Ask"]})]})]}):h?m.jsx("div",{className:"flex items-center justify-end",children:m.jsx(Ke,{size:"xs",variant:"secondary",onClick:()=>{r(e.key),u("")},children:"Ask another"})}):null]})}function L8({entry:e,pos:t}){const r=nr(h=>h.openKey),i=nr(h=>h.open),o=nr(h=>h.collapse),s=nr(h=>h.remove),u=r===e.key,d=e.status==="streaming"?"streaming":e.status==="error"?"error":e.status==="done"&&!e.seen?"ready":"idle";return m.jsxs(Ui,{open:u,modal:!1,onOpenChange:h=>{h?i(e.key):e.status==="composing"?s(e.key):o()},children:[m.jsx(Hp,{asChild:!0,children:m.jsxs("button",{type:"button",title:e.status==="streaming"?"Ask — answering…":e.status==="done"?"Ask — answer ready":e.status==="error"?"Ask — error":"Ask",onClick:()=>u?o():i(e.key),style:{position:"fixed",left:t.x,top:t.y,transform:"translate(-50%, -50%)"},className:ge("z-40 inline-flex h-5 w-5 items-center justify-center rounded-full text-white shadow-md ring-2 ring-card transition-colors",d==="streaming"&&"bg-violet-500",d==="ready"&&"bg-emerald-500",d==="error"&&"bg-destructive",d==="idle"&&"bg-violet-500/80 hover:bg-violet-500"),children:[e.status==="streaming"?m.jsx(dn,{className:"h-3 w-3 animate-spin"}):m.jsx(fs,{className:"h-3 w-3"}),d==="ready"&&m.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 animate-pulse rounded-full bg-emerald-300 ring-2 ring-card"})]})}),m.jsx(Ga,{side:"bottom",align:"start",sideOffset:8,className:"w-96",onInteractOutside:h=>{e.status==="composing"&&h.preventDefault()},children:m.jsx(z8,{entry:e})})]})}function P8(){const e=ke(d=>d.domainId),t=nr(d=>d.entries),r=nr(d=>d.keepOnly),i=Object.values(t).filter(d=>d.domainId===e),[o,s]=k.useState({});k.useEffect(()=>{e&&r(e)},[e,r]);const u=i.map(d=>d.key).join("|");return k.useEffect(()=>{if(!u){s({});return}let d=0;const h=()=>{const f=nr.getState().entries;s(y=>{const p={};let v=!1;for(const b of u.split("|")){const w=f[b];if(!w)continue;const C=M8(w);p[b]=C;const j=y[b];(!j||j.x!==C.x||j.y!==C.y)&&(v=!0)}return!v&&Object.keys(y).length===Object.keys(p).length?y:p}),d=requestAnimationFrame(h)};return d=requestAnimationFrame(h),()=>cancelAnimationFrame(d)},[u]),m.jsx(m.Fragment,{children:i.map(d=>o[d.key]?m.jsx(L8,{entry:d,pos:o[d.key]},d.key):null)})}var B0=1,H8=.9,U8=.8,B8=.17,Bh=.1,Ih=.999,I8=.9999,q8=.99,F8=/[\\\/_+.#"@\[\(\{&]/,$8=/[\\\/_+.#"@\[\(\{&]/g,V8=/[\s-]/,U2=/[\s-]/g;function Om(e,t,r,i,o,s,u){if(s===t.length)return o===e.length?B0:q8;var d=`${o},${s}`;if(u[d]!==void 0)return u[d];for(var h=i.charAt(s),f=r.indexOf(h,o),y=0,p,v,b,w;f>=0;)p=Om(e,t,r,i,f+1,s+1,u),p>y&&(f===o?p*=B0:F8.test(e.charAt(f-1))?(p*=U8,b=e.slice(o,f-1).match($8),b&&o>0&&(p*=Math.pow(Ih,b.length))):V8.test(e.charAt(f-1))?(p*=H8,w=e.slice(o,f-1).match(U2),w&&o>0&&(p*=Math.pow(Ih,w.length))):(p*=B8,o>0&&(p*=Math.pow(Ih,f-o))),e.charAt(f)!==t.charAt(s)&&(p*=I8)),(p<Bh&&r.charAt(f-1)===i.charAt(s+1)||i.charAt(s+1)===i.charAt(s)&&r.charAt(f-1)!==i.charAt(s))&&(v=Om(e,t,r,i,f+1,s+2,u),v*Bh>p&&(p=v*Bh)),p>y&&(y=p),f=r.indexOf(h,f+1);return u[d]=y,y}function I0(e){return e.toLowerCase().replace(U2," ")}function Y8(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,Om(e,t,I0(e),I0(t),0,0,{})}var Go='[cmdk-group=""]',qh='[cmdk-group-items=""]',Q8='[cmdk-group-heading=""]',B2='[cmdk-item=""]',q0=`${B2}:not([aria-disabled="true"])`,Rm="cmdk-item-select",Ml="data-value",G8=(e,t,r)=>Y8(e,t,r),I2=k.createContext(void 0),Cs=()=>k.useContext(I2),q2=k.createContext(void 0),Up=()=>k.useContext(q2),F2=k.createContext(void 0),$2=k.forwardRef((e,t)=>{let r=zl(()=>{var z,T;return{search:"",value:(T=(z=e.value)!=null?z:e.defaultValue)!=null?T:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=zl(()=>new Set),o=zl(()=>new Map),s=zl(()=>new Map),u=zl(()=>new Set),d=V2(e),{label:h,children:f,value:y,onValueChange:p,filter:v,shouldFilter:b,loop:w,disablePointerSelection:C=!1,vimBindings:j=!0,...E}=e,N=qn(),R=qn(),P=qn(),H=k.useRef(null),_=i7();Di(()=>{if(y!==void 0){let z=y.trim();r.current.value=z,q.emit()}},[y]),Di(()=>{_(6,fe)},[]);let q=k.useMemo(()=>({subscribe:z=>(u.current.add(z),()=>u.current.delete(z)),snapshot:()=>r.current,setState:(z,T,G)=>{var K,J,me,Ne;if(!Object.is(r.current[z],T)){if(r.current[z]=T,z==="search")Y(),U(),_(1,te);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ue=document.getElementById(P);ue?ue.focus():(K=document.getElementById(N))==null||K.focus()}if(_(7,()=>{var ue;r.current.selectedItemId=(ue=oe())==null?void 0:ue.id,q.emit()}),G||_(5,fe),((J=d.current)==null?void 0:J.value)!==void 0){let ue=T??"";(Ne=(me=d.current).onValueChange)==null||Ne.call(me,ue);return}}q.emit()}},emit:()=>{u.current.forEach(z=>z())}}),[]),I=k.useMemo(()=>({value:(z,T,G)=>{var K;T!==((K=s.current.get(z))==null?void 0:K.value)&&(s.current.set(z,{value:T,keywords:G}),r.current.filtered.items.set(z,ie(T,G)),_(2,()=>{U(),q.emit()}))},item:(z,T)=>(i.current.add(z),T&&(o.current.has(T)?o.current.get(T).add(z):o.current.set(T,new Set([z]))),_(3,()=>{Y(),U(),r.current.value||te(),q.emit()}),()=>{s.current.delete(z),i.current.delete(z),r.current.filtered.items.delete(z);let G=oe();_(4,()=>{Y(),G?.getAttribute("id")===z&&te(),q.emit()})}),group:z=>(o.current.has(z)||o.current.set(z,new Set),()=>{s.current.delete(z),o.current.delete(z)}),filter:()=>d.current.shouldFilter,label:h||e["aria-label"],getDisablePointerSelection:()=>d.current.disablePointerSelection,listId:N,inputId:P,labelId:R,listInnerRef:H}),[]);function ie(z,T){var G,K;let J=(K=(G=d.current)==null?void 0:G.filter)!=null?K:G8;return z?J(z,r.current.search,T):0}function U(){if(!r.current.search||d.current.shouldFilter===!1)return;let z=r.current.filtered.items,T=[];r.current.filtered.groups.forEach(K=>{let J=o.current.get(K),me=0;J.forEach(Ne=>{let ue=z.get(Ne);me=Math.max(ue,me)}),T.push([K,me])});let G=H.current;re().sort((K,J)=>{var me,Ne;let ue=K.getAttribute("id"),tt=J.getAttribute("id");return((me=z.get(tt))!=null?me:0)-((Ne=z.get(ue))!=null?Ne:0)}).forEach(K=>{let J=K.closest(qh);J?J.appendChild(K.parentElement===J?K:K.closest(`${qh} > *`)):G.appendChild(K.parentElement===G?K:K.closest(`${qh} > *`))}),T.sort((K,J)=>J[1]-K[1]).forEach(K=>{var J;let me=(J=H.current)==null?void 0:J.querySelector(`${Go}[${Ml}="${encodeURIComponent(K[0])}"]`);me?.parentElement.appendChild(me)})}function te(){let z=re().find(G=>G.getAttribute("aria-disabled")!=="true"),T=z?.getAttribute(Ml);q.setState("value",T||void 0)}function Y(){var z,T,G,K;if(!r.current.search||d.current.shouldFilter===!1){r.current.filtered.count=i.current.size;return}r.current.filtered.groups=new Set;let J=0;for(let me of i.current){let Ne=(T=(z=s.current.get(me))==null?void 0:z.value)!=null?T:"",ue=(K=(G=s.current.get(me))==null?void 0:G.keywords)!=null?K:[],tt=ie(Ne,ue);r.current.filtered.items.set(me,tt),tt>0&&J++}for(let[me,Ne]of o.current)for(let ue of Ne)if(r.current.filtered.items.get(ue)>0){r.current.filtered.groups.add(me);break}r.current.filtered.count=J}function fe(){var z,T,G;let K=oe();K&&(((z=K.parentElement)==null?void 0:z.firstChild)===K&&((G=(T=K.closest(Go))==null?void 0:T.querySelector(Q8))==null||G.scrollIntoView({block:"nearest"})),K.scrollIntoView({block:"nearest"}))}function oe(){var z;return(z=H.current)==null?void 0:z.querySelector(`${B2}[aria-selected="true"]`)}function re(){var z;return Array.from(((z=H.current)==null?void 0:z.querySelectorAll(q0))||[])}function L(z){let T=re()[z];T&&q.setState("value",T.getAttribute(Ml))}function Z(z){var T;let G=oe(),K=re(),J=K.findIndex(Ne=>Ne===G),me=K[J+z];(T=d.current)!=null&&T.loop&&(me=J+z<0?K[K.length-1]:J+z===K.length?K[0]:K[J+z]),me&&q.setState("value",me.getAttribute(Ml))}function le(z){let T=oe(),G=T?.closest(Go),K;for(;G&&!K;)G=z>0?r7(G,Go):a7(G,Go),K=G?.querySelector(q0);K?q.setState("value",K.getAttribute(Ml)):Z(z)}let he=()=>L(re().length-1),O=z=>{z.preventDefault(),z.metaKey?he():z.altKey?le(1):Z(1)},M=z=>{z.preventDefault(),z.metaKey?L(0):z.altKey?le(-1):Z(-1)};return k.createElement(et.div,{ref:t,tabIndex:-1,...E,"cmdk-root":"",onKeyDown:z=>{var T;(T=E.onKeyDown)==null||T.call(E,z);let G=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||G))switch(z.key){case"n":case"j":{j&&z.ctrlKey&&O(z);break}case"ArrowDown":{O(z);break}case"p":case"k":{j&&z.ctrlKey&&M(z);break}case"ArrowUp":{M(z);break}case"Home":{z.preventDefault(),L(0);break}case"End":{z.preventDefault(),he();break}case"Enter":{z.preventDefault();let K=oe();if(K){let J=new Event(Rm);K.dispatchEvent(J)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:I.inputId,id:I.labelId,style:o7},h),Yc(e,z=>k.createElement(q2.Provider,{value:q},k.createElement(I2.Provider,{value:I},z))))}),K8=k.forwardRef((e,t)=>{var r,i;let o=qn(),s=k.useRef(null),u=k.useContext(F2),d=Cs(),h=V2(e),f=(i=(r=h.current)==null?void 0:r.forceMount)!=null?i:u?.forceMount;Di(()=>{if(!f)return d.item(o,u?.id)},[f]);let y=Y2(o,s,[e.value,e.children,s],e.keywords),p=Up(),v=Fa(_=>_.value&&_.value===y.current),b=Fa(_=>f||d.filter()===!1?!0:_.search?_.filtered.items.get(o)>0:!0);k.useEffect(()=>{let _=s.current;if(!(!_||e.disabled))return _.addEventListener(Rm,w),()=>_.removeEventListener(Rm,w)},[b,e.onSelect,e.disabled]);function w(){var _,q;C(),(q=(_=h.current).onSelect)==null||q.call(_,y.current)}function C(){p.setState("value",y.current,!0)}if(!b)return null;let{disabled:j,value:E,onSelect:N,forceMount:R,keywords:P,...H}=e;return k.createElement(et.div,{ref:Ti(s,t),...H,id:o,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!v,"data-disabled":!!j,"data-selected":!!v,onPointerMove:j||d.getDisablePointerSelection()?void 0:C,onClick:j?void 0:w},e.children)}),X8=k.forwardRef((e,t)=>{let{heading:r,children:i,forceMount:o,...s}=e,u=qn(),d=k.useRef(null),h=k.useRef(null),f=qn(),y=Cs(),p=Fa(b=>o||y.filter()===!1?!0:b.search?b.filtered.groups.has(u):!0);Di(()=>y.group(u),[]),Y2(u,d,[e.value,e.heading,h]);let v=k.useMemo(()=>({id:u,forceMount:o}),[o]);return k.createElement(et.div,{ref:Ti(d,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},r&&k.createElement("div",{ref:h,"cmdk-group-heading":"","aria-hidden":!0,id:f},r),Yc(e,b=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?f:void 0},k.createElement(F2.Provider,{value:v},b))))}),Z8=k.forwardRef((e,t)=>{let{alwaysRender:r,...i}=e,o=k.useRef(null),s=Fa(u=>!u.search);return!r&&!s?null:k.createElement(et.div,{ref:Ti(o,t),...i,"cmdk-separator":"",role:"separator"})}),W8=k.forwardRef((e,t)=>{let{onValueChange:r,...i}=e,o=e.value!=null,s=Up(),u=Fa(f=>f.search),d=Fa(f=>f.selectedItemId),h=Cs();return k.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),k.createElement(et.input,{ref:t,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":h.listId,"aria-labelledby":h.labelId,"aria-activedescendant":d,id:h.inputId,type:"text",value:o?e.value:u,onChange:f=>{o||s.setState("search",f.target.value),r?.(f.target.value)}})}),J8=k.forwardRef((e,t)=>{let{children:r,label:i="Suggestions",...o}=e,s=k.useRef(null),u=k.useRef(null),d=Fa(f=>f.selectedItemId),h=Cs();return k.useEffect(()=>{if(u.current&&s.current){let f=u.current,y=s.current,p,v=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let b=f.offsetHeight;y.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return v.observe(f),()=>{cancelAnimationFrame(p),v.unobserve(f)}}},[]),k.createElement(et.div,{ref:Ti(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":i,id:h.listId},Yc(e,f=>k.createElement("div",{ref:Ti(u,h.listInnerRef),"cmdk-list-sizer":""},f)))}),e7=k.forwardRef((e,t)=>{let{open:r,onOpenChange:i,overlayClassName:o,contentClassName:s,container:u,...d}=e;return k.createElement(FS,{open:r,onOpenChange:i},k.createElement(YS,{container:u},k.createElement(QS,{"cmdk-overlay":"",className:o}),k.createElement(GS,{"aria-label":e.label,"cmdk-dialog":"",className:s},k.createElement($2,{ref:t,...d}))))}),t7=k.forwardRef((e,t)=>Fa(r=>r.filtered.count===0)?k.createElement(et.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),n7=k.forwardRef((e,t)=>{let{progress:r,children:i,label:o="Loading...",...s}=e;return k.createElement(et.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Yc(e,u=>k.createElement("div",{"aria-hidden":!0},u)))}),$t=Object.assign($2,{List:J8,Item:K8,Input:W8,Group:X8,Separator:Z8,Dialog:e7,Empty:t7,Loading:n7});function r7(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function a7(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function V2(e){let t=k.useRef(e);return Di(()=>{t.current=e}),t}var Di=typeof window>"u"?k.useEffect:k.useLayoutEffect;function zl(e){let t=k.useRef();return t.current===void 0&&(t.current=e()),t}function Fa(e){let t=Up(),r=()=>e(t.snapshot());return k.useSyncExternalStore(t.subscribe,r,r)}function Y2(e,t,r,i=[]){let o=k.useRef(),s=Cs();return Di(()=>{var u;let d=(()=>{var f;for(let y of r){if(typeof y=="string")return y.trim();if(typeof y=="object"&&"current"in y)return y.current?(f=y.current.textContent)==null?void 0:f.trim():o.current}})(),h=i.map(f=>f.trim());s.value(e,d,h),(u=t.current)==null||u.setAttribute(Ml,d),o.current=d}),o}var i7=()=>{let[e,t]=k.useState(),r=zl(()=>new Map);return Di(()=>{r.current.forEach(i=>i()),r.current=new Map},[e]),(i,o)=>{r.current.set(i,o),t({})}};function l7(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Yc({asChild:e,children:t},r){return e&&k.isValidElement(t)?k.cloneElement(l7(t),{ref:t.ref},r(t.props.children)):r(t)}var o7={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const F0=[264,190,150,90,30,320,220,55,0,170,120,290],$0="kernel.astrale.ai";function Q2(e){return typeof e=="string"?`legacy:interface.${e}`:tc(e)}function s7(e,t){return typeof e=="string"?`interface.${e}`:e.origin===t?`interface.${e.name}`:`interface.${Q2(e)}`}function _P(e){const t=CT(e);return O1(t)&&/^[A-Za-z_$][\w$]*$/.test(t.name)?t:void 0}function DP(e,t){return{name:typeof e=="string"?e:e.name,identity:Q2(e),...typeof e=="string"?{}:{ref:e},selectionId:s7(e,t)}}function u7(e){return F0[e%F0.length]}function yc(e,t){if(!e)return{sourcePath:"root",modulePath:"root"};const r=e.split("/").filter(Boolean),i=r.lastIndexOf(t),o=i>=0?r.slice(i+1):r;return o.length===0?{sourcePath:"root",modulePath:"root"}:(o[o.length-1]=o[o.length-1].replace(/\.tsx?$/,""),{sourcePath:o.join("/"),modulePath:o.length>1?o.slice(0,-1).join("/"):"root"})}function G2(e,t){return e==="interface"?`interface.${t}`:`class.${t}`}function K2(e,t){return`${e}.${t}`}function Bp(e,t){const r=e.ir;if(!r)return[];const i=[],o=s=>e.overlay.sourceSpans[s]?.file;for(const s of Object.keys(r.interfaces)){const u=yc(o(`interface.${s}`),t);i.push({name:s,kind:"interface",...u})}for(const[s,u]of Object.entries(r.classes)){const d=u.type==="edge"?"edge":"class",h=yc(o(`${d}.${s}`),t);i.push({name:s,kind:d,...h,icon:u.icon})}return i}function Ip(e){const t=[...new Set(e.map(i=>i.modulePath.split("/")[0]))].sort(),r=new Map;return t.forEach((i,o)=>r.set(i,u7(o))),r}function MP(e,t="schema"){const r=Bp(e,t),i=Ip(r),o={name:t,path:"",hue:0,children:[],members:[]};for(const s of r){const u=s.modulePath==="root"?[]:s.modulePath.split("/"),d=u[0],h=i.get(d??"root")??264;let f=o;if(u.length===0){let y=o.children.find(p=>p.path==="root");y||(y={name:t,path:"root",hue:h,children:[],members:[]},o.children.push(y)),f=y}for(let y=0;y<u.length;y++){const p=u[y],v=u.slice(0,y+1).join("/");let b=f.children.find(w=>w.path===v);b||(b={name:p,path:v,hue:h,children:[],members:[]},f.children.push(b)),f=b}f.members.push({name:s.name,kind:s.kind,selectId:G2(s.kind,s.name),ref:K2(s.kind,s.name),icon:s.icon})}return X2(o),o}function X2(e){e.children.sort((r,i)=>r.name.localeCompare(i.name));const t={interface:0,class:1,edge:2};e.members.sort((r,i)=>t[r.kind]-t[i.kind]||r.name.localeCompare(i.name)),e.children.forEach(X2)}function c7(e,t="schema"){if(!e.ir)return[];const i=Bp(e,t),o=Ip(i),s=new Map;for(const u of i){const d=u.modulePath.split("/")[0];s.has(u.modulePath)||s.set(u.modulePath,{path:u.modulePath,label:u.modulePath==="root"?t:u.modulePath,hue:o.get(d)??264,classes:[],interfaces:[],edges:[]});const h=s.get(u.modulePath);u.kind==="class"?h.classes.push(u.name):u.kind==="interface"?h.interfaces.push(u.name):h.edges.push(u.name)}for(const u of s.values())u.classes.sort(),u.interfaces.sort(),u.edges.sort();return[...s.values()].sort((u,d)=>u.path.localeCompare(d.path))}function d7(e,t){const r=e.ir,i=r?.classes[t];return!r||!i?[]:i.implementsRefs!==void 0?i.implementsRefs.filter(O1):(i.implements??[]).flatMap(o=>{if(r.interfaces[o])return[{origin:r.domain,kind:"interface",name:o}];const s=r.imports[o];return!s||s.definition!=="interface"?[]:[s.ref?.kind==="interface"?{origin:s.ref.origin,kind:"interface",name:s.ref.name}:{origin:s.origin,kind:"interface",name:o}]})}function zP(e,t){const r=e.ir;if(!r)return[];const i=r.classes[t];return i?i.implementsRefs===void 0?(i.implements??[]).filter(o=>{if(r.interfaces[o])return!0;const s=r.imports[o];return s?.definition==="interface"&&s.origin!==$0}):d7(e,t).filter(o=>o.origin===r.domain?r.interfaces[o.name]!==void 0:o.origin!==$0):[]}function f7(e,t,r="schema"){return yc(e.overlay.sourceSpans[`class.${t}`]?.file,r).modulePath}function LP(e,t,r="schema"){return yc(e.overlay.sourceSpans[`interface.${t}`]?.file,r).modulePath}function PP(e,t,r="schema"){const i=Bp(e,r),o=Ip(i),s=f=>f===t||t!=="root"&&f.startsWith(`${t}/`),u=t.split("/"),d={path:t,label:t==="root"?r:t,hue:o.get(u[0])??264,interfaces:[],classes:[],edges:[],files:[]},h=new Set;for(const f of i){if(!s(f.modulePath))continue;h.add(f.sourcePath);const y={name:f.name,kind:f.kind,selectId:G2(f.kind,f.name),ref:K2(f.kind,f.name),icon:f.icon};f.kind==="interface"?d.interfaces.push(y):f.kind==="edge"?d.edges.push(y):d.classes.push(y)}return d.files=[...h].sort(),d.interfaces.sort((f,y)=>f.name.localeCompare(y.name)),d.classes.sort((f,y)=>f.name.localeCompare(y.name)),d.edges.sort((f,y)=>f.name.localeCompare(y.name)),d}const h7=[{key:"context",label:"Context"},{key:"schema",label:"Schema"},{key:"process",label:"Process"},{key:"comments",label:"Comments"}];function ec(e,t){if(!e)return"unknown";if(Array.isArray(e.enum)&&e.enum.length)return t?"enum?":"enum";const r=e.type;if(Array.isArray(r)){const o=r.filter(d=>d!=="null"),s=t??r.includes("null"),u=o.length===1?o[0]:o.join(" | ")||"unknown";return s?`${u}?`:u}const i=r==="array"?`${e.items?.type??"unknown"}[]`:r??"unknown";return t?`${i}?`:i}function Rl({icon:e,label:t,meta:r}){return m.jsxs(m.Fragment,{children:[m.jsx(e,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),m.jsx("span",{className:"flex-1 truncate",children:t}),r?m.jsx("span",{className:"ml-2 shrink-0 truncate text-xs text-muted-foreground",children:r}):null]})}const Si="flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm text-foreground outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground";function m7(){const e=ke(p=>p.paletteOpen),t=ke(p=>p.setPaletteOpen),r=ke(p=>p.domainId),i=ke(p=>p.setSection),o=ke(p=>p.selectClass),s=ke(p=>p.focusClass),u=ke(p=>p.setFocus),d=ke(p=>p.setSettingsOpen),{data:h}=jc(r);k.useEffect(()=>{function p(v){v.key.toLowerCase()==="k"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),t(!ke.getState().paletteOpen))}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]);const f=()=>t(!1),y=k.useMemo(()=>{const p=h?.ir;if(!p||!h)return{classes:[],interfaces:[],edges:[],properties:[],modules:[]};const v=Object.values(p.classes).filter(E=>E.type==="node").map(E=>{const N=Object.keys(E.properties).length,R=Object.keys(E.methods).length,P=f7(h,E.name),H=`${N}p · ${R}m`;return{name:E.name,value:`class ${E.name} ${P} ${H}`,meta:P==="root"?H:`${P} · ${H}`}}).sort((E,N)=>E.name.localeCompare(N.name)),b=Object.values(p.interfaces).map(E=>{const N=Object.keys(E.properties).length,R=Object.keys(E.methods).length;return{name:E.name,value:`interface ${E.name} ${(E.extends??[]).join(" ")}`,meta:`${N}p · ${R}m`}}).sort((E,N)=>E.name.localeCompare(N.name)),w=Object.values(p.classes).filter(E=>E.type==="edge").map(E=>{const[N,R]=E.endpoints??[],P=N?.types.join("|")??"?",H=R?.types.join("|")??"?";return{name:E.name,value:`edge ${E.name} ${P} ${H} relationship`,meta:`${P} → ${H}`}}).sort((E,N)=>E.name.localeCompare(N.name)),C=[];for(const E of Object.values(p.classes))if(E.type==="node")for(const[N,R]of Object.entries(E.properties)){const P=E.required?!E.required.includes(N):void 0;C.push({id:`class.${E.name}.property.${N}`,owner:E.name,ownerKind:"class",prop:N,value:`${E.name}.${N} property ${ec(R,P)}`,meta:ec(R,P)})}for(const E of Object.values(p.interfaces))for(const[N,R]of Object.entries(E.properties)){const P=E.required?!E.required.includes(N):void 0;C.push({id:`interface.${E.name}.property.${N}`,owner:E.name,ownerKind:"interface",prop:N,value:`${E.name}.${N} property ${ec(R,P)}`,meta:ec(R,P)})}C.sort((E,N)=>E.value.localeCompare(N.value));const j=c7(h).map(E=>{const N=E.classes.length+E.interfaces.length+E.edges.length;return{path:E.path,firstClass:E.classes[0],value:`module ${E.path} ${E.classes.join(" ")} ${E.interfaces.join(" ")}`,meta:`${N} member${N===1?"":"s"}`}});return{classes:v,interfaces:b,edges:w,properties:C,modules:j}},[h]);return m.jsxs($t.Dialog,{open:e,onOpenChange:t,label:"Command palette",shouldFilter:!0,overlayClassName:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",contentClassName:ge("fixed left-1/2 top-[15%] z-50 w-full max-w-[640px] -translate-x-1/2","overflow-hidden rounded-xl border bg-card text-card-foreground shadow-2xl","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5","[&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium","[&_[cmdk-group-heading]]:text-muted-foreground"),children:[m.jsx("div",{className:"flex items-center border-b px-3",children:m.jsx($t.Input,{autoFocus:!0,placeholder:"Search classes, interfaces, edges, properties, modules…",className:"h-12 w-full bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"})}),m.jsxs($t.List,{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden p-2",children:[m.jsx($t.Empty,{className:"py-8 text-center text-sm text-muted-foreground",children:"No results"}),m.jsx($t.Group,{heading:"Studio",children:m.jsxs($t.Item,{value:"settings power-user options integrations folder configuration",className:Si,onSelect:()=>{d(!0),f()},children:[m.jsx(j1,{className:"h-4 w-4 text-muted-foreground"}),"Settings…"]})}),y.classes.length>0&&m.jsx($t.Group,{heading:"Classes",children:y.classes.map(p=>m.jsx($t.Item,{value:p.value,className:Si,onSelect:()=>{i("schema"),s(`class.${p.name}`),f()},children:m.jsx(Rl,{icon:f1,label:p.name,meta:p.meta})},`class.${p.name}`))}),y.interfaces.length>0&&m.jsx($t.Group,{heading:"Interfaces",children:y.interfaces.map(p=>m.jsx($t.Item,{value:p.value,className:Si,onSelect:()=>{i("schema"),o(`interface.${p.name}`),u(null),f()},children:m.jsx(Rl,{icon:$A,label:p.name,meta:p.meta})},`interface.${p.name}`))}),y.edges.length>0&&m.jsx($t.Group,{heading:"Relationships",children:y.edges.map(p=>m.jsx($t.Item,{value:p.value,className:Si,onSelect:()=>{i("schema"),o(`class.${p.name}`),f()},children:m.jsx(Rl,{icon:WA,label:m.jsxs(m.Fragment,{children:[p.name," ",m.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",p.meta,")"]})]})})},`edge.${p.name}`))}),y.properties.length>0&&m.jsx($t.Group,{heading:"Properties",children:y.properties.map(p=>m.jsx($t.Item,{value:p.value,className:Si,onSelect:()=>{i("schema"),p.ownerKind==="interface"?(o(`interface.${p.owner}`),u(null)):s(`class.${p.owner}`),f()},children:m.jsx(Rl,{icon:tT,label:m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-muted-foreground",children:[p.owner,"."]}),p.prop]}),meta:p.meta})},p.id))}),y.modules.length>0&&m.jsx($t.Group,{heading:"Modules",children:y.modules.map(p=>m.jsx($t.Item,{value:p.value,className:Si,onSelect:()=>{i("schema"),p.firstClass&&s(`class.${p.firstClass}`),f()},children:m.jsx(Rl,{icon:GN,label:p.path,meta:p.meta})},`module.${p.path}`))}),m.jsx($t.Group,{heading:"Go to",children:h7.map(p=>m.jsx($t.Item,{value:`go to ${p.label} ${p.key} section`,className:Si,onSelect:()=>{i(p.key),f()},children:m.jsx(Rl,{icon:aN,label:p.label,meta:"section"})},`section.${p.key}`))})]}),m.jsxs("div",{className:"flex items-center justify-end gap-3 border-t px-3 py-2 text-[11px] text-muted-foreground",children:[m.jsx("span",{children:"↑↓ navigate"}),m.jsx("span",{children:"·"}),m.jsx("span",{children:"↵ select"}),m.jsx("span",{children:"·"}),m.jsx("span",{children:"esc close"})]})]})}function p7({count:e,status:t,orphaned:r,onClick:i,className:o}){return m.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),i?.(s)},title:`${e} ${e===1?"thread":"threads"}${r?" · orphaned":t==="resolved"?" · resolved":""}`,className:ge("inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-semibold leading-none tabular-nums shadow-sm transition-colors","ring-1 ring-inset cursor-pointer select-none",t==="open"?"bg-primary text-primary-foreground ring-primary/40 hover:bg-primary/90":"bg-muted text-muted-foreground ring-border hover:bg-muted/80",r&&"ring-2 ring-destructive text-destructive bg-destructive/15",o),children:e})}var g7=Object.defineProperty,Es=(e,t)=>g7(e,"name",{value:t,configurable:!0}),qp="Collapsible",[y7,HP]=Ya(qp),[x7,Fp]=y7(qp),v7=k.forwardRef(Es(function(t,r){const{__scopeCollapsible:i,open:o,defaultOpen:s,disabled:u,onOpenChange:d,...h}=t,[f,y]=$l({prop:o,defaultProp:s??!1,onChange:d,caller:qp});return m.jsx(x7,{scope:i,disabled:u,contentId:qn(),open:f,onOpenToggle:k.useCallback(()=>y(p=>!p),[y]),children:m.jsx(et.div,{"data-state":Qc(f),"data-disabled":u?"":void 0,...h,ref:r})})},"Collapsible")),b7="CollapsibleTrigger",w7=k.forwardRef(Es(function(t,r){const{__scopeCollapsible:i,...o}=t,s=Fp(b7,i);return m.jsx(et.button,{type:"button","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open||!1,"data-state":Qc(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...o,ref:r,onClick:Ye(t.onClick,s.onOpenToggle)})},"CollapsibleTrigger")),Z2="CollapsibleContent",S7=k.forwardRef(Es(function(t,r){const{forceMount:i,...o}=t,s=Fp(Z2,t.__scopeCollapsible);return m.jsx(An,{present:i||s.open,children:({present:u})=>m.jsx(k7,{...o,ref:r,present:u})})},"CollapsibleContent")),k7=k.forwardRef(Es(function(t,r){const{__scopeCollapsible:i,present:o,children:s,...u}=t,d=Fp(Z2,i),[h,f]=k.useState(o),y=k.useRef(null),p=zt(r,y),v=k.useRef(0),b=v.current,w=k.useRef(0),C=w.current,j=d.open||h,E=k.useRef(j),N=k.useRef(void 0);return k.useEffect(()=>{const R=requestAnimationFrame(()=>E.current=!1);return()=>cancelAnimationFrame(R)},[]),hn(()=>{const R=y.current;if(R){N.current=N.current||{transitionDuration:R.style.transitionDuration,animationName:R.style.animationName},R.style.transitionDuration="0s",R.style.animationName="none";const P=R.getBoundingClientRect();v.current=P.height,w.current=P.width,E.current||(R.style.transitionDuration=N.current.transitionDuration,R.style.animationName=N.current.animationName),f(o)}},[d.open,o]),m.jsx(et.div,{"data-state":Qc(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!j,...u,ref:p,style:{"--radix-collapsible-content-height":b?`${b}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...t.style},children:j&&s})},"CollapsibleContentImpl"));function Qc(e){return e?"open":"closed"}Es(Qc,"getState");var C7=v7,E7=w7,j7=S7;const N7=C7,A7=E7,T7=j7;function _m({title:e,subtitle:t,icon:r,actions:i,children:o,wide:s,className:u}){return m.jsx("div",{className:"h-full overflow-y-auto",children:m.jsxs("div",{className:ge("mx-auto px-8 pt-8 pb-28",s?"max-w-6xl":"max-w-3xl",u),children:[m.jsxs("header",{className:"flex items-start gap-3 mb-7",children:[r&&m.jsx("div",{className:"text-muted-foreground mt-0.5",children:r}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:e}),t&&m.jsx("p",{className:"text-sm text-muted-foreground mt-1 leading-relaxed",children:t})]}),i&&m.jsx("div",{className:"flex items-center gap-2 shrink-0",children:i})]}),o]})})}function V0({label:e,hint:t,children:r,className:i}){return m.jsxs("section",{className:ge("mb-8",i),children:[e&&m.jsxs("div",{className:"flex items-baseline justify-between mb-2.5 px-1",children:[m.jsx("h2",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),t!=null&&m.jsx("span",{className:"text-xs text-muted-foreground/70",children:t})]}),r]})}function wr({className:e,...t}){return m.jsx("div",{className:ge("rounded-xl border bg-card",e),...t})}const O7={violet:"bg-primary/12 text-primary",sky:"bg-sky-500/12 text-sky-400",emerald:"bg-emerald-500/12 text-emerald-400",amber:"bg-amber-500/12 text-amber-400",rose:"bg-rose-500/12 text-rose-400",fuchsia:"bg-fuchsia-500/12 text-fuchsia-400",muted:"bg-muted text-muted-foreground"};function Zr({children:e,tone:t="muted",size:r="md",className:i,style:o}){const s=r==="lg"?"h-10 w-10 [&_svg]:h-5 [&_svg]:w-5":r==="sm"?"h-7 w-7 [&_svg]:h-3.5 [&_svg]:w-3.5":"h-9 w-9 [&_svg]:h-[18px] [&_svg]:w-[18px]";return m.jsx("div",{className:ge("inline-flex items-center justify-center rounded-lg shrink-0",O7[t]??t,s,i),style:o,children:e})}function W2({leading:e,title:t,subtitle:r,trailing:i,onClick:o,active:s,className:u,children:d,anchorRef:h,anchorExcerpt:f}){const y=o?"button":"div";return m.jsxs(y,{onClick:o,"data-anchor-ref":h,"data-anchor-excerpt":f,"data-commentable":h?"":void 0,className:ge("group/row w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors",o&&"hover:bg-accent/60 cursor-pointer",s&&"bg-accent",u),children:[e,(t||r)&&m.jsxs("div",{className:"flex-1 min-w-0",children:[t&&m.jsx("div",{className:"text-sm font-extrabold truncate",children:t}),r&&m.jsx("div",{className:"text-[13px] text-muted-foreground truncate leading-snug",children:r})]}),d,i&&m.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:i})]})}const R7={default:"bg-muted text-muted-foreground",primary:"bg-primary/12 text-primary",success:"bg-success/12 text-success",warning:"bg-warning/15 text-warning",danger:"bg-destructive/12 text-destructive",fuchsia:"bg-fuchsia-500/12 text-fuchsia-300",outline:"border border-border text-muted-foreground"};function nn({children:e,tone:t="default",className:r,...i}){return m.jsx("span",{className:ge("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium whitespace-nowrap",R7[t],r),...i,children:e})}function UP({label:e="Details",children:t,className:r}){return m.jsxs(N7,{className:r,children:[m.jsxs(A7,{className:"group/disc inline-flex items-center gap-1 text-xs text-muted-foreground/80 hover:text-foreground transition-colors",children:[m.jsx(Sc,{className:"h-3 w-3 transition-transform group-data-[state=open]/disc:rotate-90"}),e]}),m.jsx(T7,{className:"overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out",children:m.jsx("div",{className:"pt-2",children:t})})]})}function _7({items:e,className:t}){return m.jsx("dl",{className:ge("grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs",t),children:e.map((r,i)=>m.jsxs(k.Fragment,{children:[m.jsx("dt",{className:"text-muted-foreground/70 whitespace-nowrap",children:r.label}),m.jsx("dd",{className:"font-mono text-muted-foreground break-all",children:r.value})]},i))})}function D7({children:e,className:t}){return m.jsx("pre",{className:ge("max-h-56 overflow-auto rounded-md bg-muted/50 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap break-words",t),children:e})}function J2({icon:e,title:t,hint:r}){return m.jsxs("div",{className:"flex flex-col items-center justify-center text-center py-12 px-6",children:[e&&m.jsx("div",{className:"text-muted-foreground/40 mb-3 [&_svg]:h-8 [&_svg]:w-8",children:e}),m.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:t}),r&&m.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:r})]})}var M7=Object.defineProperty,ra=(e,t)=>M7(e,"name",{value:t,configurable:!0}),Fh,$p="HoverCard",[ek,BP]=Ya($p,[Kl]),Vp=Kl(),[z7,Gc]=ek($p),L7=ra(e=>{const{__scopeHoverCard:t,children:r,open:i,defaultOpen:o,onOpenChange:s,openDelay:u=700,closeDelay:d=300}=e,h=Vp(t),f=k.useRef(0),y=k.useRef(0),p=k.useRef(!1),v=k.useRef(!1),[b,w]=$l({prop:i,defaultProp:o??!1,onChange:s,caller:$p}),C=k.useCallback(()=>{clearTimeout(y.current),f.current=window.setTimeout(()=>w(!0),u)},[u,w]),j=k.useCallback(()=>{clearTimeout(f.current),!p.current&&!v.current&&(y.current=window.setTimeout(()=>w(!1),d))},[d,w]),E=k.useCallback(()=>w(!1),[w]);return k.useEffect(()=>()=>{clearTimeout(f.current),clearTimeout(y.current)},[]),m.jsx(z7,{scope:t,open:b,onOpenChange:w,onOpen:C,onClose:j,onDismiss:E,hasSelectionRef:p,isPointerDownOnContentRef:v,children:m.jsx(Op,{...h,children:r})})},"HoverCard"),P7="HoverCardTrigger",H7=k.forwardRef(ra(function(t,r){const{__scopeHoverCard:i,...o}=t,s=Gc(P7,i),u=Vp(i);return m.jsx(Fc,{asChild:!0,...u,children:m.jsx(et.a,{"data-state":s.open?"open":"closed",...o,ref:r,onPointerEnter:Ye(t.onPointerEnter,us(s.onOpen)),onPointerLeave:Ye(t.onPointerLeave,us(s.onClose)),onFocus:Ye(t.onFocus,s.onOpen),onBlur:Ye(t.onBlur,s.onClose),onTouchStart:Ye(t.onTouchStart,d=>d.preventDefault())})})},"HoverCardTrigger")),tk="HoverCardPortal",[U7,B7]=ek(tk,{forceMount:void 0}),I7=ra(e=>{const{__scopeHoverCard:t,forceMount:r,children:i,container:o}=e,s=Gc(tk,t);return m.jsx(U7,{scope:t,forceMount:r,children:m.jsx(An,{present:r||s.open,children:m.jsx(Mc,{asChild:!0,container:o,children:i})})})},"HoverCardPortal"),Dm="HoverCardContent",q7=k.forwardRef(ra(function(t,r){const i=B7(Dm,t.__scopeHoverCard),{forceMount:o=i.forceMount,...s}=t,u=Gc(Dm,t.__scopeHoverCard);return m.jsx(An,{present:o||u.open,children:m.jsx(F7,{"data-state":u.open?"open":"closed",...s,onPointerEnter:Ye(t.onPointerEnter,us(u.onOpen)),onPointerLeave:Ye(t.onPointerLeave,us(u.onClose)),ref:r})})},"HoverCardContent")),F7=k.forwardRef(ra(function(t,r){const{__scopeHoverCard:i,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:u,onInteractOutside:d,...h}=t,f=Gc(Dm,i),y=Vp(i),p=k.useRef(null),v=zt(r,p),[b,w]=k.useState(!1);return k.useEffect(()=>{if(b){const C=document.body;return Fh=C.style.userSelect||C.style.webkitUserSelect,C.style.userSelect="none",C.style.webkitUserSelect="none",()=>{C.style.userSelect=Fh,C.style.webkitUserSelect=Fh}}},[b]),k.useEffect(()=>{if(p.current){const C=ra(()=>{w(!1),f.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(f.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",C),()=>{document.removeEventListener("pointerup",C),f.hasSelectionRef.current=!1,f.isPointerDownOnContentRef.current=!1}}},[f.isPointerDownOnContentRef,f.hasSelectionRef]),k.useEffect(()=>{p.current&&nk(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),m.jsx(Dc,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:d,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:Ye(u,C=>{C.preventDefault()}),onDismiss:f.onDismiss,children:m.jsx(Rp,{...y,...h,onPointerDown:Ye(h.onPointerDown,C=>{C.currentTarget.contains(C.target)&&w(!0),f.hasSelectionRef.current=!1,f.isPointerDownOnContentRef.current=!0}),ref:v,style:{...h.style,userSelect:b?"text":void 0,WebkitUserSelect:b?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function us(e){return t=>t.pointerType==="touch"?void 0:e()}ra(us,"excludeTouch");function nk(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:ra(i=>i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;r.nextNode();)t.push(r.currentNode);return t}ra(nk,"getTabbableNodes");var $7=L7,V7=H7,Y7=I7,Q7=q7;const Yp=$7,Qp=V7,Kc=k.forwardRef(({className:e,align:t="start",sideOffset:r=8,...i},o)=>m.jsx(Y7,{children:m.jsx(Q7,{ref:o,align:t,sideOffset:r,className:ge("z-50 w-72 rounded-xl border bg-popover p-3 text-popover-foreground shadow-lg outline-none","data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...i})}));Kc.displayName="HoverCardContent";function rk({domainId:e,anchor:t,excerpt:r,threads:i,onClose:o}){const s=ke(d=>d.domainId),u=e??s??"";return m.jsxs("div",{className:"flex max-h-[calc(var(--radix-popover-content-available-height)-1.5rem)] min-h-0 flex-col gap-2 text-sm",children:[m.jsxs("div",{className:"flex shrink-0 items-center justify-between",children:[m.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:i.length>0?`${i.length} comment${i.length===1?"":"s"}`:"New comment"}),m.jsxs(Yp,{openDelay:120,children:[m.jsx(Qp,{asChild:!0,children:m.jsx("button",{type:"button",title:"Target",className:"text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:m.jsx(NN,{className:"h-3.5 w-3.5"})})}),m.jsx(Kc,{className:"w-auto max-w-xs",children:m.jsx(_7,{items:[{label:"target",value:t.ref},...r&&r!==t.ref?[{label:"on",value:r}]:[],...t.file?[{label:"file",value:t.file}]:[]]})})]})]}),i.length>0&&m.jsx("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto pr-1",children:i.map(d=>m.jsx(G7,{domainId:u,comment:d},d.id))}),m.jsx(K7,{domainId:u,anchor:t,excerpt:r,hasThreads:i.length>0,onClose:o})]})}function ak({domainId:e,commentId:t,entryId:r,text:i}){const o=ke(p=>p.domainId),{edit:s}=ms(e??o??""),[u,d]=k.useState(!1),[h,f]=k.useState(i),y=()=>{const p=h.trim();!p||s.isPending||s.mutate({commentId:t,entryId:r,text:p},{onSuccess:()=>{d(!1),Ee.success("Edited")},onError:v=>Ee.error(String(v))})};return u?m.jsxs("span",{className:"mt-1 flex items-end gap-1.5",children:[m.jsx(Ar,{autoFocus:!0,className:"min-h-8 flex-1 text-[13px]",value:h,onChange:p=>f(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)?(p.preventDefault(),y()):p.key==="Escape"&&(f(i),d(!1))}}),m.jsx(Ke,{size:"xs",variant:"secondary",disabled:!h.trim()||s.isPending,onClick:y,children:"Save"})]}):m.jsxs("div",{className:"group/e relative",children:[m.jsx(nS,{text:i}),m.jsx("button",{type:"button",title:"Edit",onClick:()=>{f(i),d(!0)},className:"absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded bg-background/80 text-transparent backdrop-blur-sm transition-colors group-hover/e:text-muted-foreground/50 hover:!text-foreground",children:m.jsx(E1,{className:"h-3 w-3"})})]})}function G7({domainId:e,comment:t}){const{reply:r,setStatus:i,remove:o}=ms(e),[s,u]=k.useState(""),d=t.status==="closed",[h,f]=k.useState(!d),y=(t.thread.at(-1)?.text??t.thread[0]?.text??"").trim();return k.useEffect(()=>{f(t.status!=="closed")},[t.status]),m.jsxs("div",{className:ge("rounded-md border bg-background/40 p-2 space-y-1.5",d&&"bg-muted/20"),children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Wo,{variant:t.status==="open"?"secondary":"muted",children:d?"resolved":"open"}),t.orphaned&&m.jsx(Wo,{variant:"destructive",children:"orphaned"}),d&&m.jsxs("button",{type:"button",onClick:()=>f(p=>!p),className:"ml-auto inline-flex h-6 items-center gap-1 rounded-md px-1.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[h?m.jsx(mN,{className:"h-3.5 w-3.5"}):m.jsx(Sc,{className:"h-3.5 w-3.5"}),h?"Hide":"Show"]}),m.jsx("button",{type:"button",title:"Delete comment",disabled:o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>Ee.success("Deleted")}),className:ge("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-50",!d&&"ml-auto"),children:m.jsx(qm,{className:"h-3.5 w-3.5"})})]}),d&&!h&&y&&m.jsx("button",{type:"button",onClick:()=>f(!0),className:"block w-full truncate rounded-sm px-0.5 py-0.5 text-left text-[12px] leading-snug text-muted-foreground/75 hover:text-foreground",children:y}),(!d||h)&&m.jsx("div",{className:ge("space-y-1",d&&"opacity-75"),children:t.thread.map((p,v)=>{const b=p.type==="choice"&&!!p.options&&p.role==="author"&&t.status==="open"&&v===t.thread.length-1;return m.jsxs("div",{className:"text-[13px] leading-snug",children:[m.jsx("span",{className:ge("mb-0.5 block text-[10px] font-medium uppercase",p.role==="author"?"text-primary":"text-muted-foreground"),children:p.role==="author"?"agent":"you"}),m.jsx(ak,{domainId:e,commentId:t.id,entryId:p.id,text:p.text}),p.type==="choice"&&p.options&&(b?m.jsx(ik,{commentId:t.id,options:p.options,domainId:e}):m.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:p.options.map(w=>m.jsx(Wo,{variant:p.answer===w?"default":"outline",children:w},w))}))]},p.id)})}),t.status==="open"&&m.jsxs("div",{className:"flex items-end gap-1.5 pt-0.5",children:[m.jsx(Ar,{className:"min-h-8 flex-1 text-[13px]",placeholder:"Reply…",value:s,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&s.trim()&&r.mutate({commentId:t.id,entry:{role:"user",type:"text",text:s.trim()}},{onSuccess:()=>u("")})}}),m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsx(Ke,{size:"xs",variant:"secondary",disabled:!s.trim()||r.isPending,onClick:()=>r.mutate({commentId:t.id,entry:{role:"user",type:"text",text:s.trim()}},{onSuccess:()=>u("")}),children:"Reply"}),m.jsxs(Ke,{size:"xs",onClick:()=>i.mutate({commentId:t.id,status:"closed"},{onSuccess:()=>Ee.success("Resolved")}),children:[m.jsx(aa,{className:"h-3 w-3"})," Resolve"]})]})]})]})}function ik({commentId:e,options:t,domainId:r}){const{reply:i}=ms(r),[o,s]=k.useState(""),[u,d]=k.useState(!1),h=f=>{const y=f.trim();!y||i.isPending||i.mutate({commentId:e,entry:{role:"user",type:"text",text:y}},{onSuccess:()=>{s(""),d(!1)}})};return m.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[t.map(f=>m.jsx("button",{type:"button",disabled:i.isPending,onClick:()=>h(f),className:"rounded-full border border-primary/35 bg-primary/5 px-2.5 py-1 text-[12px] font-medium transition-colors hover:border-primary hover:bg-primary/15 disabled:opacity-50",children:f},f)),u?m.jsxs("span",{className:"inline-flex items-center gap-1",children:[m.jsx("input",{autoFocus:!0,value:o,onChange:f=>s(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),h(o))},placeholder:"Your answer…",className:"h-7 w-36 rounded-md border bg-background px-2 text-[12px] outline-none focus:border-primary"}),m.jsx(Ke,{size:"xs",variant:"secondary",disabled:!o.trim()||i.isPending,onClick:()=>h(o),children:"Send"})]}):m.jsx("button",{type:"button",onClick:()=>d(!0),className:"rounded-full border border-dashed px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:border-foreground/40 hover:text-foreground",children:"Other…"})]})}function K7({domainId:e,anchor:t,excerpt:r,hasThreads:i,onClose:o}){const{create:s}=ms(e),[u,d]=k.useState(""),h=()=>{u.trim()&&s.mutate({anchors:[r],anchorRefs:[t],text:u.trim(),firstRole:"user",type:"text"},{onSuccess:()=>{Ee.success("Comment added"),o()},onError:f=>Ee.error(String(f))})};return m.jsxs("div",{className:"shrink-0 space-y-2 border-t pt-2",children:[m.jsx(Ar,{autoFocus:!i,className:"min-h-16 text-[13px]",placeholder:i?"Add another comment…":"Note for the agent…",value:u,onChange:f=>d(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&(f.preventDefault(),h())}}),m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("span",{className:"mr-auto text-[10px] text-muted-foreground",children:"⌘↵ to submit"}),m.jsx(Ke,{size:"sm",onClick:h,disabled:!u.trim()||s.isPending,children:"Add comment"})]})]})}function lk(e,t){const r=ke(d=>d.domainId),{data:i}=Nc(t??r),o=(i?.comments??[]).filter(d=>d.anchorRefs.some(h=>h.ref===e)),s=o.some(d=>d.status==="open")?"open":"resolved",u=o.some(d=>d.orphaned);return{threads:o,status:s,orphaned:u}}function IP({anchorRef:e,excerpt:t,className:r,domainId:i}){const o=k.useId(),s=ke(b=>b.openAnchorRef),u=ke(b=>b.openAnchorId),d=i?`${i}::${e.ref}`:e.ref,h=s===d&&(u===null||u===o),f=ke(b=>b.setOpenAnchor),{threads:y,status:p,orphaned:v}=lk(e.ref,i);return y.length===0?null:m.jsxs(Ui,{modal:!1,open:h,onOpenChange:b=>f(b?d:null,b?o:null),children:[m.jsx(Hp,{asChild:!0,children:m.jsx("button",{type:"button","data-anchor-ref":e.ref,"data-domain-id":i,"aria-label":`Comments on ${e.ref}`,onClick:b=>{b.stopPropagation(),f(h?null:d,o)},className:ge("inline-flex shrink-0 align-middle",r),children:m.jsx(p7,{count:y.length,status:p,orphaned:v})})}),m.jsx(Ga,{onInteractOutside:b=>b.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:m.jsx(rk,{domainId:i,anchor:e,excerpt:t,threads:y,onClose:()=>f(null)})})]})}function X7(){const e=ke(i=>i.commentDraft),t=ke(i=>i.setCommentDraft),{threads:r}=lk(e?.anchor.ref??"__none__",e?.domainId);return e?m.jsxs(Ui,{modal:!1,open:!0,onOpenChange:i=>{i||t(null)},children:[m.jsx(Hp,{asChild:!0,children:m.jsx("div",{"aria-hidden":!0,className:"pointer-events-none fixed",style:{left:e.x,top:e.y,width:1,height:1}})}),m.jsx(Ga,{side:"bottom",align:"start",sideOffset:6,className:"w-80",onInteractOutside:i=>i.preventDefault(),children:m.jsx(rk,{domainId:e.domainId,anchor:e.anchor,excerpt:e.excerpt,threads:r,onClose:()=>t(null)})})]},`${e.anchor.ref}:${e.x}:${e.y}`):null}function Z7(e){return/^(class|interface|edge)\./.test(e)?"schema":/^(module|section|view)\./.test(e)?"section":e.startsWith("file.")?"file":"free"}function qP(e,t){return`${e}.${t}`}function W7(e){const r=(e.startsWith("workspace-edge:")?`edge-${e.split(":")[2]??""}`:e.startsWith("workspace:")?e.split(":").slice(2).join(":"):e).replace(/^edge-/,"").split("__")[0]?.trim();return r?`edge.${r}`:null}function FP(e,t){return{"data-anchor-ref":e,"data-anchor-excerpt":t,"data-commentable":""}}function J7(e,t,r){const i=e.closest(".react-flow"),o=i?.querySelector(".react-flow__viewport");if(!i||!o)return null;const s=i.getBoundingClientRect(),u=getComputedStyle(o).transform;let d=0,h=0,f=1;if(u&&u!=="none")try{const v=new DOMMatrixReadOnly(u);d=v.e,h=v.f,f=v.a||1}catch{return null}const y=(t-s.left-d)/f,p=(r-s.top-h)/f;return!Number.isFinite(y)||!Number.isFinite(p)?null:{x:Math.round(y),y:Math.round(p)}}function e9(e,t,r,i,o){if(!e)return null;const s=e.closest("[data-domain-id]")?.dataset.domainId,u=e.closest("[data-anchor-ref]");if(u?.dataset.anchorRef){const f=u.dataset.anchorRef,y=(u.dataset.anchorExcerpt||u.textContent||f).trim().slice(0,80);return{mode:r,domainId:u.dataset.domainId??s,anchor:{ref:f,kind:Z7(f)},excerpt:y,x:i,y:o}}const d=e.closest(".react-flow__node");if(d){const f=d.getAttribute("data-id")??"",y=f.startsWith("workspace:")?f.split(":").slice(2).join(":"):f;if(y.startsWith("class."))return{mode:r,domainId:s,anchor:{ref:y,kind:"schema"},excerpt:y.slice(6),x:i,y:o};if(y.startsWith("grp-")){const p=y.slice(4);return{mode:r,domainId:s,anchor:{ref:`module.${p}`,kind:"section"},excerpt:p,x:i,y:o}}}const h=e.closest(".react-flow__edge");if(h){const f=h.getAttribute("data-id")??"",y=W7(f),p=f.startsWith("workspace-edge:")?f.split(":")[1]:void 0;if(y)return{mode:r,domainId:p?decodeURIComponent(p):s,anchor:{ref:y,kind:"schema"},excerpt:y.slice(5),x:i,y:o}}if(e.closest("main")){const f=J7(e,i,o);return{mode:r,domainId:s,anchor:{ref:`section.${t}`,kind:"section",...f},excerpt:t,x:i,y:o}}return null}function t9(){const e=ke(h=>h.commentMode),t=ke(h=>h.askMode),r=ke(h=>h.toggleCommentMode),i=ke(h=>h.toggleAskMode),o=ke(h=>h.setCommentDraft),s=e||t,u=t?"ask":"comment";if(k.useEffect(()=>{if(!s)return;const h=document.body.style.cursor;document.body.style.cursor="crosshair";const f=()=>ke.getState().askMode?i(!1):r(!1),y=v=>{v.preventDefault(),v.stopPropagation();const b=ke.getState(),w=b.askMode?"ask":"comment",C=e9(v.target,b.section,w,v.clientX,v.clientY);if(f(),!!C)if(C.mode==="ask"){const j=C.domainId??b.domainId;j&&requestAnimationFrame(()=>nr.getState().start(j,C.anchor,C.excerpt,C.x,C.y))}else requestAnimationFrame(()=>o(C))},p=v=>{v.key==="Escape"&&(v.preventDefault(),f())};return document.addEventListener("click",y,!0),document.addEventListener("keydown",p,!0),()=>{document.body.style.cursor=h,document.removeEventListener("click",y,!0),document.removeEventListener("keydown",p,!0)}},[s,r,i,o]),!s)return null;const d=u==="ask";return m.jsx("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-50 flex justify-center",children:m.jsxs("div",{className:ge("flex items-center gap-2 rounded-full border bg-card/95 px-4 py-1.5 text-xs font-medium text-foreground shadow-lg backdrop-blur",d?"border-violet-400/50":"border-primary/40"),children:[d?m.jsx(fs,{className:"h-3.5 w-3.5 text-violet-400"}):m.jsx(jA,{className:"h-3.5 w-3.5 text-primary"}),m.jsxs("span",{children:[d?"Ask mode — click anything to ask a quick question":"Comment mode — click anything to comment"," ",m.jsx("kbd",{className:"ml-1 rounded border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:"Esc"})," ","to exit"]})]})})}const ok="studio.schemaWorkspace.v1",Y0={selectedDomainIds:[],domainPositions:{},externalPositions:{},domainSizes:{},domainContentOffsets:{},collapsedModules:{},badgeInterfaces:{}};function Gp(e){return[...new Set(e.filter(Boolean))]}function n9(e,t,r){const i=Gp(e);return t&&!i.includes(t)&&i.unshift(t),i.length<=1?[r]:(i.includes(r)||i.push(r),i)}function r9(){try{const e=JSON.parse(localStorage.getItem(ok)??"null");return e?{selectedDomainIds:Gp(e.selectedDomainIds??[]),domainPositions:e.domainPositions??{},externalPositions:e.externalPositions??{},domainSizes:e.domainSizes??{},domainContentOffsets:e.domainContentOffsets??{},collapsedModules:e.collapsedModules??{},badgeInterfaces:e.badgeInterfaces??{}}:Y0}catch{return Y0}}function xr(e){try{localStorage.setItem(ok,JSON.stringify(e))}catch{}}function vr(e){return{selectedDomainIds:e.selectedDomainIds,domainPositions:e.domainPositions,externalPositions:e.externalPositions,domainSizes:e.domainSizes,domainContentOffsets:e.domainContentOffsets,collapsedModules:e.collapsedModules,badgeInterfaces:e.badgeInterfaces}}const a9=r9(),$h=Cc(e=>({...a9,replaceDomains:t=>e(r=>{const i=Gp(t),o={...vr(r),selectedDomainIds:i};return xr(o),{selectedDomainIds:i}}),toggleDomain:(t,r)=>e(i=>{const o=new Set(i.selectedDomainIds);o.has(t)&&t!==r?o.delete(t):o.add(t),o.add(r);const s=[...o];return xr({...vr(i),selectedDomainIds:s}),{selectedDomainIds:s}}),setDomainPosition:(t,r)=>e(i=>{const o={...i.domainPositions,[t]:r};return xr({...vr(i),domainPositions:o}),{domainPositions:o}}),setDomainSize:(t,r)=>e(i=>{const o={...i.domainSizes,[t]:r};return xr({...vr(i),domainSizes:o}),{domainSizes:o}}),ensureDomainPositions:t=>e(r=>{const i={...r.domainPositions};let o=!1;for(const[s,u]of Object.entries(t))i[s]||(i[s]=u,o=!0);return o?(xr({...vr(r),domainPositions:i}),{domainPositions:i}):r}),ensureExternalPositions:t=>e(r=>{const i={...r.externalPositions};let o=!1;for(const[s,u]of Object.entries(t))i[s]||(i[s]=u,o=!0);return o?(xr({...vr(r),externalPositions:i}),{externalPositions:i}):r}),ensureDomainContentOffsets:t=>e(r=>{const i={...r.domainContentOffsets};let o=!1;for(const[s,u]of Object.entries(t))i[s]||(i[s]=u,o=!0);return o?(xr({...vr(r),domainContentOffsets:i}),{domainContentOffsets:i}):r}),resetWorkspaceFrames:()=>e(t=>(xr({...vr(t),domainPositions:{},externalPositions:{},domainSizes:{}}),{domainPositions:{},externalPositions:{},domainSizes:{}})),toggleModule:(t,r)=>e(i=>{const o=new Set(i.collapsedModules[t]??[]);o.has(r)?o.delete(r):o.add(r);const s={...i.collapsedModules,[t]:[...o]};return xr({...vr(i),collapsedModules:s}),{collapsedModules:s}}),toggleInterface:(t,r)=>e(i=>{const o=new Set(i.badgeInterfaces[t]??[]);o.has(r)?o.delete(r):o.add(r);const s={...i.badgeInterfaces,[t]:[...o]};return xr({...vr(i),badgeInterfaces:s}),{badgeInterfaces:s}})})),sk=k.forwardRef(({className:e,type:t,...r},i)=>m.jsx("input",{ref:i,type:t,className:ge("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...r}));sk.displayName="Input";const i9=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function l9(){const{data:e}=R1(),t=ke(j=>j.domainId),r=ke(j=>j.setDomain),i=ke(j=>j.setSection),o=$h(j=>j.selectedDomainIds),s=$h(j=>j.replaceDomains),u=$h(j=>j.toggleDomain),[d,h]=k.useState(!1),[f,y]=k.useState(!1),p=e?.find(j=>j.id===t),v=k.useMemo(()=>new Set((e??[]).map(j=>j.id)),[e]);k.useEffect(()=>{if(!t||!e)return;const j=o.filter(E=>v.has(E));j.includes(t)||j.unshift(t),(j.length!==o.length||j.some((E,N)=>E!==o[N]))&&s(j)},[t,e,s,o,v]);const b=new Set(o);t&&b.add(t);const w=b.size,C=j=>{s(t?n9([...b],t,j):[j]),r(j),h(!1)};return m.jsxs(m.Fragment,{children:[m.jsxs(Ui,{open:d,onOpenChange:h,children:[m.jsx(Vc,{asChild:!0,children:m.jsxs("button",{type:"button","data-testid":"domain-selector",title:"Domain canvas — choose the active domain and optional companions",className:ge("inline-flex h-8 items-center gap-2 rounded-lg border pl-1.5 pr-2 text-sm font-medium outline-none transition-colors",w>1?"border-sky-400/35 bg-sky-400/10 text-sky-100 hover:bg-sky-400/15":"bg-card hover:bg-accent/50"),children:[m.jsx("span",{className:"grid h-5 w-5 place-items-center rounded-md bg-primary/10 text-primary",children:m.jsx(cN,{className:"h-3.5 w-3.5"})}),m.jsx("span",{className:"max-w-[15rem] truncate",children:p?.origin??"select domain"}),m.jsxs("span",{className:ge("inline-flex h-5 items-center gap-1 rounded-full px-1.5 text-[10px] tabular-nums",w>1?"bg-sky-300/15 text-sky-100":"bg-muted text-muted-foreground"),children:[m.jsx(rA,{className:"h-3 w-3"})," ",w]}),m.jsx(m1,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),m.jsxs(Ga,{align:"start",className:"w-80 p-1.5",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3 px-2 pb-2 pt-1",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Domain canvas"}),m.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground/70",children:"Open one domain, then check companions to compose their schemas."})]}),!!e?.length&&m.jsx("button",{type:"button",onClick:()=>s(e.map(j=>j.id)),className:"shrink-0 rounded-md px-1.5 py-1 text-[10px] font-medium text-sky-300 hover:bg-sky-400/10",children:"Select all"})]}),m.jsxs("div",{className:"max-h-[50vh] space-y-0.5 overflow-y-auto",children:[(e??[]).map(j=>{const E=b.has(j.id),N=j.id===t;return m.jsxs("div",{className:ge("flex items-center gap-1 rounded-md transition-colors",E?"bg-accent/55":"hover:bg-accent/35"),children:[m.jsx("button",{type:"button",role:"checkbox","aria-label":N?`${j.origin} is the active domain on canvas`:`${E?"Remove":"Add"} ${j.origin} ${E?"from":"to"} canvas`,"aria-checked":E,disabled:N,title:N?"The active domain is always on the canvas":void 0,onClick:()=>t&&u(j.id,t),className:"group ml-2 grid h-5 w-5 shrink-0 place-items-center rounded border border-border text-transparent transition-colors enabled:hover:border-sky-400/60 disabled:cursor-default",children:E&&m.jsx("span",{className:"grid h-full w-full place-items-center rounded bg-sky-400/15 text-sky-200",children:m.jsx(aa,{className:"h-3 w-3"})})}),m.jsxs("button",{type:"button","aria-current":N?"true":void 0,onClick:()=>C(j.id),className:"flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-left",children:[m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"block truncate text-[13px] font-semibold",children:j.origin}),m.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground/65",children:[j.path.split("/").pop(),!j.depsInstalled&&" · deps missing"]})]}),N&&m.jsx("span",{className:"rounded-full border border-primary/25 bg-primary/10 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-primary",children:"active"})]})]},j.id)}),!e?.length&&m.jsx("div",{className:"px-2 py-3 text-center text-[12px] text-muted-foreground",children:"No domains found"})]}),m.jsx("div",{className:"my-1 h-px bg-border/60"}),t&&w>1&&m.jsxs("button",{type:"button",onClick:()=>s([t]),className:"flex w-full items-center rounded-md px-2 py-1.5 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:["Show only ",p?.origin??"active domain"]}),m.jsxs("button",{type:"button",onClick:()=>{h(!1),y(!0)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[m.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:m.jsx(YN,{className:"h-3.5 w-3.5"})}),"Create new domain"]})]})]}),m.jsx(o9,{open:f,onOpenChange:y,onCreated:j=>{s([j]),r(j),i("context")}})]})}function o9({open:e,onOpenChange:t,onCreated:r}){const i=Bt(),[o,s]=k.useState(""),[u,d]=k.useState(!1),[h,f]=k.useState(null),y=o.trim().toLowerCase(),p=!!y&&y.length<=64&&i9.test(y),v=y?y.includes(".")?y:`${y}.example.dev`:"",b=()=>{s(""),f(null),d(!1)},w=j=>{u||(j||b(),t(j))},C=async()=>{if(!(!p||u)){d(!0),f(null);try{const j=await je.createDomain(y);j.ok&&j.id?(await i.invalidateQueries({queryKey:Se.workspace}),r(j.id),Ee.success(`Created ${j.origin??y}`),b(),t(!1)):f(j.error||"Could not create the domain — check the studio logs.")}catch(j){f(j?.message??String(j))}finally{d(!1)}}};return m.jsx(Vl,{open:e,onOpenChange:w,children:m.jsxs(Li,{className:"max-w-md",children:[m.jsxs(Yl,{children:[m.jsx(Pi,{children:"Create a new domain"}),m.jsxs(bs,{children:["Scaffolds a fresh Astrale domain with"," ",m.jsx("span",{className:"font-mono text-[12px]",children:"create-astrale-domain"})," and installs its dependencies."]})]}),m.jsxs("div",{className:"space-y-3 py-1",children:[m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("label",{htmlFor:"new-domain-name",className:"text-[12px] font-medium text-muted-foreground",children:"Domain name"}),m.jsx(sk,{id:"new-domain-name",autoFocus:!0,value:o,disabled:u,placeholder:"crm",spellCheck:!1,autoComplete:"off",className:"font-mono",onChange:j=>{s(j.target.value),f(null)},onKeyDown:j=>{j.key==="Enter"&&C()}})]}),y&&p&&m.jsxs("div",{className:"space-y-0.5 rounded-lg border bg-muted/30 px-3 py-2 text-[12px] leading-relaxed text-muted-foreground",children:[m.jsxs("div",{children:["origin ",m.jsx("span",{className:"font-mono text-foreground",children:v}),!y.includes(".")&&m.jsx("span",{className:"text-muted-foreground/70",children:" · placeholder, edit later"})]}),m.jsxs("div",{children:["folder ",m.jsxs("span",{className:"font-mono text-foreground",children:[y,"/"]})," · managed (astrale) adapter"]})]}),y&&!p&&m.jsx("p",{className:"text-[12px] text-destructive",children:"Use lowercase letters, digits, dots and dashes."}),h&&m.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] leading-relaxed text-destructive",children:h}),u&&m.jsxs("p",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"})," Scaffolding and installing dependencies — this can take a moment…"]})]}),m.jsxs(vp,{children:[m.jsx(Ke,{variant:"ghost",onClick:()=>w(!1),disabled:u,children:"Cancel"}),m.jsx(Ke,{onClick:C,disabled:!p||u,children:u?m.jsxs(m.Fragment,{children:[m.jsx(dn,{className:"h-4 w-4 animate-spin"})," Creating…"]}):"Create domain"})]})]})})}function s9({domainId:e}){const{data:t}=M1(e,"dev"),r=ke(o=>o.setSettingsOpen),i=t?.requiredMissing??0;return i===0?null:m.jsxs("button",{type:"button",onClick:()=>r(!0),title:`${i} required env var${i===1?"":"s"} need a value — open Settings → Environment`,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-destructive/40 bg-destructive/10 px-2 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20",children:[m.jsx(tA,{className:"h-3.5 w-3.5"}),m.jsxs("span",{children:[i," env"]}),m.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-destructive"})]})}function u9(e,t){return e.declared?!e.optional&&t===""?{dot:"bg-destructive",label:"required",tone:"text-destructive"}:t===""?{dot:"bg-muted-foreground/40",label:"optional",tone:"text-muted-foreground/60"}:{dot:"bg-emerald-500",label:"set",tone:"text-muted-foreground/60"}:{dot:"bg-amber-500",label:"orphan",tone:"text-amber-600 dark:text-amber-500"}}const c9=["dev","prod"];function d9({domainId:e}){const[t,r]=k.useState("dev"),{data:i,isLoading:o}=M1(e,t),s=Bt(),[u,d]=k.useState({}),[h,f]=k.useState(()=>new Set);k.useEffect(()=>{d({}),f(new Set)},[t,e]);const y=un({mutationFn:()=>je.setEnv(e,t,u),onSuccess:C=>{s.setQueryData(Se.env(e,t),C),d({}),Ee.success(`Saved ${C.file}`)},onError:C=>Ee.error(String(C))}),p=(i?.rows??[]).filter(C=>u[C.name]!==null),v=Object.keys(u).length>0,b=C=>C.name in u?u[C.name]??"":C.value,w=C=>f(j=>{const E=new Set(j);return E.has(C)?E.delete(C):E.add(C),E});return m.jsxs("div",{children:[m.jsxs("div",{className:"mb-1.5 flex items-center justify-between px-1",children:[m.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Environment"}),m.jsx("div",{className:"flex items-center gap-0.5 rounded-md border bg-card/40 p-0.5",children:c9.map(C=>m.jsx("button",{type:"button",onClick:()=>r(C),className:ge("rounded px-2 py-0.5 text-[11px] font-medium transition-colors",t===C?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"),children:C},C))})]}),i&&m.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 px-1 text-[10px] text-muted-foreground/60",children:[m.jsx("span",{className:"font-mono",children:i.file}),!i.exists&&m.jsx("span",{children:"· new on save"}),!i.configured&&m.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"· not wired in astrale.config"}),t==="prod"&&i.adapter==="astrale"&&m.jsx("span",{children:"· managed prod → platform store on `pnpm prod`"}),i.requiredMissing>0&&m.jsxs("span",{className:"font-medium text-destructive",children:["· ",i.requiredMissing," required missing"]})]}),m.jsx("div",{className:"divide-y divide-border/50 rounded-lg border bg-card/40",children:o&&!i?m.jsxs("div",{className:"px-3 py-2.5 text-[12px] text-muted-foreground/70",children:["Loading ",t," env…"]}):p.length===0?m.jsxs("div",{className:"px-3 py-2.5 text-[12px] text-muted-foreground/70",children:["No variables declared in env.ts and none set in ",i?.file,"."]}):p.map(C=>{const j=b(C),E=u9(C,j),N=h.has(C.name);return m.jsxs("div",{className:"space-y-1 px-3 py-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:ge("h-1.5 w-1.5 shrink-0 rounded-full",E.dot),title:E.label}),m.jsx("span",{className:"truncate font-mono text-[12px]",children:C.name}),m.jsx("span",{className:ge("shrink-0 text-[10px]",E.tone),children:E.label}),m.jsxs("div",{className:"ml-auto flex min-w-0 flex-1 items-center gap-1",children:[m.jsx("input",{type:N?"text":"password",value:j,onChange:R=>d(P=>({...P,[C.name]:R.target.value})),placeholder:!C.optional&&C.declared?"required — set a value":"unset",spellCheck:!1,autoComplete:"off",className:"w-full min-w-0 rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary"}),m.jsx("button",{type:"button",onClick:()=>w(C.name),title:N?"Hide":"Reveal",className:"shrink-0 rounded p-1 text-muted-foreground/50 hover:text-foreground",children:N?m.jsx(x1,{className:"h-3.5 w-3.5"}):m.jsx(v1,{className:"h-3.5 w-3.5"})}),!C.declared&&m.jsx("button",{type:"button",onClick:()=>d(R=>({...R,[C.name]:null})),title:"Remove this variable from the file",className:"shrink-0 rounded p-1 text-muted-foreground/50 hover:text-destructive",children:m.jsx(qm,{className:"h-3.5 w-3.5"})})]})]}),C.doc&&m.jsx("p",{className:"pl-3.5 text-[11px] leading-snug text-muted-foreground/70",children:C.doc})]},C.name)})}),m.jsxs("div",{className:"mt-1.5 flex items-center gap-2 px-1",children:[m.jsxs("p",{className:"flex items-center gap-1 text-[10px] text-muted-foreground/50",children:[m.jsx(kc,{className:"h-3 w-3"})," Plaintext in ",i?.file??`.env.${t}`," ","(gitignored) · edits the file, not a deploy"]}),v&&m.jsxs("button",{type:"button",onClick:()=>y.mutate(),disabled:y.isPending,className:"ml-auto inline-flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:[y.isPending&&m.jsx(dn,{className:"h-3 w-3 animate-spin"})," Save ",t]})]})]})}function xc(e){if(!e)return{kind:"unknown",optional:!1};const t=e.type,r=Array.isArray(t)?t.includes("null"):!1,i=Array.isArray(t)?t.find(o=>o!=="null"):t;if(e.enum)return{kind:"enum",values:e.enum,optional:r};if(e.$nodeRef)return{kind:"ref",target:"node",refKind:"node",optional:r};if(e.$dataRef)return{kind:"ref",target:"data",refKind:"data",optional:r};if(i==="array")return{kind:"array",items:xc(e.items),optional:r};if(i==="object"){const o={};for(const[s,u]of Object.entries(e.properties??{}))o[s]=xc(u);return{kind:"object",fields:o,required:e.required??[],optional:r}}return i==="string"||i==="number"||i==="integer"||i==="boolean"||i==="null"?{kind:i,optional:r}:{kind:"unknown",optional:r}}function uk(e){switch(e.kind){case"enum":return`enum(${e.values.map(String).join(" | ")})`;case"array":return`${uk(e.items)}[]`;case"object":return`{ ${Object.keys(e.fields).join(", ")} }`;case"ref":return`→${e.target}`;default:return e.kind}}function $P({schema:e,className:t}){const r=xc(e),i={string:"text-emerald-400",integer:"text-sky-400",number:"text-sky-400",boolean:"text-amber-400",enum:"text-fuchsia-400",object:"text-violet-400",array:"text-violet-400",ref:"text-rose-400",unknown:"text-muted-foreground",null:"text-muted-foreground"};return m.jsxs("span",{className:ge("font-mono text-xs",i[r.kind]??"text-muted-foreground",t),children:[uk(r),r.optional&&m.jsx("span",{className:"text-muted-foreground",children:"?"})]})}function Vh(e){return e?e.replace(/^sha256:/,"").replace(/^sha-?/,"").slice(0,8):"—"}function f9(e){return e.deployable?e.install==="unknown"?{word:"unreachable",tone:"text-muted-foreground",dot:"bg-muted-foreground/40"}:e.install==="not-installed"?{word:"not installed",tone:"text-warning",dot:"bg-warning"}:e.drift==="drifted"?{word:"drifted",tone:"text-warning",dot:"bg-warning"}:{word:"installed",tone:"text-success",dot:"bg-success"}:{word:"local only",tone:"text-muted-foreground",dot:"bg-muted-foreground/40"}}function h9({domainId:e}){const{data:t}=zT(e),{data:r}=jc(e),{data:i}=_1(),o=Bt(),[s,u]=k.useState("idle"),[d,h]=k.useState(null);if(!t)return null;const f=f9(t),y=r?!r.depsInstalled:!1,p=i?.active??null,v=!!t.deployTarget&&!!p&&t.deployTarget!==p,b=async()=>{u("deploying"),h(null);try{const w=await je.deployInstance(e);h(w),u("done"),o.invalidateQueries({queryKey:Se.instance(e)}),w.ok?Ee.success("Deployed & installed"):Ee.error("Deploy failed")}catch(w){h({ok:!1,url:null,output:String(w)}),u("done")}};return m.jsxs(Ui,{onOpenChange:w=>{!w&&s!=="deploying"&&(u("idle"),h(null))},children:[m.jsx(Vc,{asChild:!0,children:m.jsxs("button",{type:"button",title:`Deploy — ${f.word}`,className:"inline-flex h-7 items-center gap-1.5 rounded-md border bg-card px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[m.jsx(mb,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Deploy"}),m.jsx("span",{className:ge("h-1.5 w-1.5 rounded-full",y?"bg-warning":f.dot)})]})}),m.jsxs(Ga,{align:"end",className:"w-64 space-y-2.5 p-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Deploy target instance"}),m.jsxs("div",{className:"mt-0.5 flex items-center justify-between gap-2",children:[m.jsx("span",{className:"truncate text-sm font-semibold",children:t.deployTarget??"no target"}),m.jsxs("span",{className:ge("inline-flex shrink-0 items-center gap-1 text-xs font-medium",f.tone),children:[m.jsx("span",{className:ge("h-1.5 w-1.5 rounded-full",f.dot)})," ",f.word]})]}),t.deployTarget&&m.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground/60",children:["from ",m.jsx("code",{className:"font-mono",children:"astrale.config.ts"})]})]}),t.drift==="drifted"?m.jsxs("div",{className:"space-y-0.5 font-mono text-[11px]",children:[m.jsxs("div",{className:"text-warning",children:["local ",Vh(t.localRevision??"")]}),m.jsxs("div",{className:"text-muted-foreground",children:["on instance ",Vh(t.installedRevision??"")]})]}):m.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:t.localRevision?Vh(t.localRevision):"revision unavailable"}),t.install==="unknown"&&t.deployTarget&&m.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Can’t reach it to check status — deploy still works."}),y&&m.jsx("div",{className:"text-[11px] text-warning",children:"Dependencies not installed"}),v&&m.jsxs("div",{className:"text-[11px] leading-snug text-muted-foreground",children:["Independent of your active instance (",m.jsx("b",{children:p}),")."]}),t.deployable?s==="idle"?m.jsxs(Ke,{size:"sm",className:"w-full",onClick:b,children:[m.jsx(mb,{className:"h-3.5 w-3.5"})," ",t.install==="installed"?"Re-deploy":"Deploy & install"]}):s==="deploying"?m.jsxs(Ke,{size:"sm",className:"w-full",disabled:!0,children:[m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"})," Deploying…"]}):m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:ge("flex items-center gap-1.5 text-xs font-medium",d?.ok?"text-success":"text-destructive"),children:[d?.ok?m.jsx(aa,{className:"h-3.5 w-3.5"}):m.jsx(kc,{className:"h-3.5 w-3.5"}),d?.ok?"Deployed":"Failed"]}),d?.output&&m.jsx("pre",{className:"max-h-28 overflow-auto whitespace-pre-wrap break-all rounded bg-muted/50 p-1.5 text-[10px] leading-tight text-muted-foreground",children:d.output.slice(-1200)}),m.jsx(Ke,{size:"xs",variant:"outline",className:"w-full",onClick:()=>u("idle"),children:"Done"})]}):null]})]})}function m9(e){const t=e?.trim();if(!t)return null;try{const r=new URL(t);return(r.pathname==="/api"||r.pathname==="/api/")&&(r.pathname="/"),r.href.replace(/\/$/,"")}catch{return t.replace(/\/api\/?$/,"")}}function p9(){const{data:e}=_1(),t=Bt(),[r,i]=k.useState(!1),[o,s]=k.useState(null),u=e?.active??null,d=e?.instances??[],h=async f=>{if(!(f===u||o)){s(f);try{const y=await je.switchInstance(f);y.ok?(await t.invalidateQueries({queryKey:Se.instances}),Ee.success(`Switched to ${y.active??f}`),i(!1)):Ee.error(`Couldn't switch: ${y.output.split(`
|
|
80
80
|
`).filter(Boolean).pop()??"failed"}`)}finally{s(null)}}};return m.jsxs(Ui,{open:r,onOpenChange:i,children:[m.jsx("div",{className:"-ml-1 inline-flex items-center gap-0.5",children:m.jsx(Vc,{asChild:!0,children:m.jsxs("button",{type:"button",title:"Active instance — click to switch",className:"inline-flex items-center gap-2 rounded-lg px-2 py-1 transition-colors hover:bg-accent/50",children:[m.jsx("span",{className:"grid h-7 w-7 place-items-center rounded-lg bg-primary/15 text-primary",children:m.jsx(C1,{className:"h-4 w-4"})}),m.jsx("span",{className:"font-semibold tracking-tight",children:u??"no instance"}),m.jsx(m1,{className:"h-3.5 w-3.5 text-muted-foreground"})]})})}),m.jsxs(Ga,{align:"start",className:"w-64 p-1.5",children:[m.jsx("div",{className:"px-2 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Active instance"}),m.jsxs("div",{className:"space-y-0.5",children:[d.map(f=>{const y=m9(f.url);return m.jsxs("div",{className:ge("flex w-full items-center gap-1 rounded-md transition-colors hover:bg-accent",f.active&&"bg-accent/40"),children:[m.jsxs("button",{type:"button",onClick:()=>h(f.name),className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left",children:[m.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:o===f.name?m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin text-primary"}):f.active?m.jsx(aa,{className:"h-3.5 w-3.5 text-primary"}):null}),m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"block truncate text-sm font-medium",children:f.name}),m.jsx("span",{className:"block truncate text-[11px] text-muted-foreground",children:y?y.replace(/^https?:\/\//,""):"no URL"})]}),f.kind==="managed"&&m.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-wide text-muted-foreground/50",children:"managed"})]}),y&&m.jsx("a",{href:y,target:"_blank",rel:"noreferrer",title:`Open ${f.name} in a new tab`,className:"mr-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground",children:m.jsx(TN,{className:"h-3.5 w-3.5"})})]},f.name)}),d.length===0&&m.jsx("div",{className:"px-2 py-3 text-center text-[12px] text-muted-foreground",children:"No instances found"})]})]})]})}function Kp(e,t){if(t)return e.includes(t)?t:t==="max"&&e.includes("xhigh")||t==="ultracode"&&e.includes("xhigh")?"xhigh":t==="minimal"&&e.includes("low")?"low":e.includes("high")?"high":e[0]}const ck=["minimal","low","medium","high","xhigh","max","ultracode"],Xp=["workspace","full"];function g9(e,t,r){const i=t.trim().toLowerCase();if(!i)return e;const o={...e},s=r.trim();return s?o[i]=s:delete o[i],o}function jn({text:e}){return m.jsxs(Yp,{openDelay:80,children:[m.jsx(Qp,{asChild:!0,children:m.jsx("button",{type:"button","aria-label":"What's this?",className:"text-muted-foreground/40 transition-colors hover:text-foreground",children:m.jsx(vN,{className:"h-3.5 w-3.5"})})}),m.jsx(Kc,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function y9({selected:e,loadout:t,modelOptions:r,onChange:i}){const o=t?.models??r??[],s=e||t?.model||"harness default";return m.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Model"}),m.jsx(jn,{text:"Leave this on Default to preserve the selected harness's own config and account default. An explicit choice is remembered independently for this domain and harness, then passed as --model to normal turns, resumed turns, and Ask forks."}),m.jsx("span",{className:"ml-auto max-w-[55%] truncate font-mono text-[11px] text-muted-foreground/70",children:s})]}),m.jsx("input",{"aria-label":"Agent model",list:o.length>0?"agent-model-options":void 0,value:e,onChange:u=>i(u.target.value),placeholder:t?.nativeModel?`Default — ${t.nativeModel}`:"Default — choose an alias or type a full model id",spellCheck:!1,className:"w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none focus:border-primary"}),o.length>0&&m.jsx("datalist",{id:"agent-model-options",children:o.map(u=>m.jsx("option",{value:u.id,label:`${u.label}${u.isDefault?" — catalog default":""}`},u.id))}),m.jsx("p",{className:"text-[10px] text-muted-foreground/50",children:e?"Studio override · saved when you press Save":t?.modelSource==="config"?"Codex effective config":t?.modelSource==="default"?"Harness catalog default":t?.modelSource==="runtime"?"Harness runtime default":"Harness-native selection"})]})}const x9={minimal:"Minimal",low:"Low",medium:"Medium",high:"High",xhigh:"X-high",max:"Max",ultracode:"Ultracode"},v9={workspace:"Workspace",full:"Full automation"};function b9({value:e,levels:t,onChange:r}){const i=Kp(t,e);return m.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-md bg-muted/45 p-1 sm:grid-cols-6",role:"radiogroup","aria-label":"Agent effort",children:t.map(o=>m.jsx("button",{type:"button",value:o,title:o==="ultracode"?"Claude: X-high effort plus dynamic workflow orchestration":void 0,role:"radio","aria-checked":i===o,onClick:()=>r(o),className:ge("min-w-0 rounded px-1.5 py-1 text-center text-[11px] font-medium transition-colors",i===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:x9[o]},o))})}function w9({value:e,levels:t,onChange:r}){const i=Xp.includes(e)&&t.includes(e)?e:t.includes("full")?"full":t[0];return m.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-md bg-muted/45 p-1",role:"radiogroup",children:t.map(o=>m.jsx("button",{type:"button",role:"radio","aria-checked":i===o,onClick:()=>r(o),className:ge("rounded px-2 py-1 text-center text-[11px] font-medium transition-colors",i===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:v9[o]},o))})}function S9({domainId:e,harness:t}){const{data:r,isFetching:i}=AT(e),o=Bt(),[s,u]=k.useState(""),d=!r?.harness||r.harness===t?.id;k.useEffect(()=>{if(!e||!t||i||!d){u("");return}u(r?.sessionId??"")},[e,t?.id,i,d,r?.harness,r?.sessionId]);const h=un({mutationFn:f=>je.setAgentSession(f.domainId,f.harness,f.sessionId),onSuccess:(f,y)=>{o.setQueryData(Se.agentSession(y.domainId),f),o.invalidateQueries({queryKey:Se.agent(y.domainId)}),Ee.success(f.sessionId?"Agent session changed":"Agent session cleared")},onError:f=>Ee.error(String(f))});return m.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Session ID"}),m.jsx(jn,{text:"The agent's resumable conversation id. Paste another to resume that conversation; clear it to start fresh on the next turn. Cannot be changed while a turn is running."}),r&&m.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground/60",children:r.sessionId?`${r.turns} turn${r.turns===1?"":"s"}${r.harness?` · ${r.harness}`:""}`:"no active conversation"})]}),m.jsx("input",{value:s,onChange:f=>u(f.target.value),placeholder:"(none — a fresh conversation starts next turn)",spellCheck:!1,className:"w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none focus:border-primary"}),m.jsx("div",{className:"flex justify-end",children:m.jsx("button",{type:"button",disabled:!e||!t||i||!d||s.trim()===(r?.sessionId??"")||h.isPending,onClick:()=>h.mutate({domainId:e,harness:t.id,sessionId:s.trim()}),className:"rounded-md px-2.5 py-1 text-[12px] font-medium text-primary transition-colors hover:bg-primary/10 disabled:opacity-40",children:h.isPending?"Applying…":"Apply session"})})]})}const Q0=["astrale-cli","astrale-domain","agent-browser"],k9={"astrale-cli":["npx skills add astrale-os/cli -g"],"astrale-domain":["npx skills add astrale-os/cli -g"],"agent-browser":["npm install -g agent-browser && agent-browser install","npx skills add vercel-labs/agent-browser -g"]};function G0({skill:e,domainId:t,expanded:r,onToggle:i}){const{data:o,isLoading:s}=MT(r?t:void 0,r?e.command:void 0),u=e.source==="plugin"?e.plugin??"plugin":e.source;return m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/40",title:e.description??e.command,children:[m.jsx("span",{className:ge("h-1.5 w-1.5 shrink-0 rounded-full",e.loaded?"bg-emerald-500":"bg-amber-500"),title:e.loaded?"available to the selected harness here":"installed but disabled here"}),m.jsx("span",{className:"truncate font-mono text-[12px]",children:e.command}),m.jsx("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground/80",children:u}),m.jsx(Sc,{className:ge("h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform",r&&"rotate-90")})]}),r&&m.jsx("div",{className:"border-t bg-background/60 px-2.5 py-2",children:s?m.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Loading…"}):o?m.jsxs(m.Fragment,{children:[m.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 text-[11px] leading-relaxed",children:o.content}),m.jsx("p",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/50",title:o.path,children:o.path})]}):m.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Couldn't read this skill's SKILL.md."})})]})}function C9({command:e}){const[t,r]=k.useState(!1);return m.jsxs("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)}catch{Ee.error("Copy failed — select the command and copy it manually.")}},className:"group flex w-full items-center gap-2 rounded bg-muted/40 px-2 py-1 text-left font-mono text-[11px] transition-colors hover:bg-muted",title:"Copy to clipboard",children:[m.jsx("span",{className:"truncate",children:e}),t?m.jsx(aa,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-500"}):m.jsx(g1,{className:"ml-auto h-3 w-3 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-foreground"})]})}function E9({command:e}){const[t,r]=k.useState(!1),i=k9[e];return m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:()=>i&&r(o=>!o),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/40",title:"not installed on disk in this workspace — click to see how",children:[m.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-destructive",title:"not installed"}),m.jsx("span",{className:"truncate font-mono text-[12px] text-muted-foreground/60 line-through",children:e}),m.jsx("span",{className:"ml-auto shrink-0 rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:"not installed"}),i&&m.jsx(Sc,{className:ge("h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform",t&&"rotate-90")})]}),t&&i&&m.jsxs("div",{className:"space-y-1.5 border-t bg-background/60 px-2.5 py-2",children:[m.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Run, then hit re-probe above:"}),i.map(o=>m.jsx(C9,{command:o},o)),m.jsxs("p",{className:"text-[10px] text-muted-foreground/50",children:["Or run ",m.jsx("span",{className:"font-mono",children:"astrale setup"})," to equip everything at once."]})]})]})}function j9({skills:e,domainId:t}){const[r,i]=k.useState(!1),[o,s]=k.useState(null),u=new Map(e.map(f=>[f.command,f])),d=new Set(Q0),h=e.filter(f=>!d.has(f.command)).sort((f,y)=>Number(f.loaded)-Number(y.loaded)||f.command.localeCompare(y.command));return m.jsxs("div",{className:"space-y-1",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[m.jsx("span",{children:"Skills"}),m.jsxs("span",{className:"ml-auto font-mono text-[11px] text-muted-foreground/80",children:[e.filter(f=>f.loaded).length," loaded / ",e.length]})]}),m.jsxs("div",{className:ge("divide-y divide-border/50 overflow-hidden rounded-md border bg-background/40",r&&"max-h-64 overflow-y-auto"),children:[Q0.map(f=>{const y=u.get(f);return y?m.jsx(G0,{skill:y,domainId:t,expanded:o===f,onToggle:()=>s(p=>p===f?null:f)},f):m.jsx(E9,{command:f},f)}),r&&h.map(f=>m.jsx(G0,{skill:f,domainId:t,expanded:o===f.command,onToggle:()=>s(y=>y===f.command?null:f.command)},f.command))]}),h.length>0&&m.jsx("button",{type:"button",onClick:()=>i(f=>!f),className:"px-1 text-[11px] text-muted-foreground/60 transition-colors hover:text-foreground",children:r?"Hide others":`Show all (${h.length} more)`})]})}function Ha({label:e,value:t,title:r,hint:i}){return m.jsxs("div",{className:"flex items-center gap-3",title:r,children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e,i&&m.jsx(jn,{text:i})]}),m.jsx("span",{className:"ml-auto truncate font-mono text-[11px]",children:t})]})}const K0=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);function N9({domainId:e}){const[t,r]=k.useState(!1),{data:i,isLoading:o,error:s}=TT(t?e:void 0);return m.jsxs("div",{className:"space-y-2 px-3 py-2.5 text-[12px]",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Injected system prompt"}),m.jsx(jn,{text:"The exact developer/system appendix passed to the selected local harness. It is hidden by default because it is long and mostly protocol."})]}),m.jsx("button",{type:"button",onClick:()=>r(u=>!u),className:"ml-auto rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground",children:t?"Hide":"Show"})]}),t&&m.jsx("div",{children:o?m.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Loading…"}):s?m.jsx("p",{className:"text-[11px] text-destructive",children:String(s?.message??s)}):m.jsxs(m.Fragment,{children:[m.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 font-mono text-[11px] leading-relaxed",children:i?.systemPrompt??""}),m.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground/50",children:["bridge tools: ",i?.bridge?"enabled":"disabled"]})]})})]})}function A9({loadout:e,loading:t,errorMessage:r,usage:i,domainId:o,onRefresh:s}){const u=e?.source==="configured"?"What the selected harness has configured or installed for this folder. Codex discovers runtime tools when a turn starts.":"What the selected harness actually loaded for this folder, probed from its runtime initialization event.";return m.jsxs(m.Fragment,{children:[m.jsx(N9,{domainId:o}),m.jsxs("div",{className:"space-y-2 px-3 py-2.5 text-[12px]",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Loaded by the harness"}),m.jsx(jn,{text:u}),m.jsxs("button",{type:"button",disabled:t,onClick:s,className:"ml-auto inline-flex items-center gap-1 text-[11px] text-muted-foreground/60 transition-colors hover:text-foreground disabled:opacity-50",title:"Re-probe",children:[m.jsx(LA,{className:ge("h-3 w-3",t&&"animate-spin")})," re-probe"]})]}),r?m.jsx("p",{className:"text-[11px] leading-relaxed text-destructive",children:r.includes("404")?"The studio server predates this feature (no /agent/loadout route). Restart it — bun server/index.ts … — to pick it up.":r}):t&&!e?m.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Probing the harness…"}):e?.ok?m.jsxs("div",{className:"space-y-2",children:[m.jsx(Ha,{label:"Model",value:e.model??"—"}),m.jsx(Ha,{label:"Source",value:e.source==="configured"?"configured":"runtime",title:e.detail}),m.jsx(Ha,{label:"Tools",value:e.tools.length,title:e.tools.join(", ")}),m.jsx(Ha,{label:"Subagents",value:e.agents.length,title:e.agents.join(", ")}),m.jsx(j9,{skills:e.skills,domainId:o})]}):m.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:e?.detail??"Loadout unavailable."})]}),m.jsxs("div",{className:"space-y-1.5 px-3 py-2.5 text-[12px]",children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Usage"}),m.jsx(jn,{text:"This Studio's agent turns on this domain (succeeded or not). Machine-wide harness totals are out of scope."}),m.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground/60",children:"this domain"})]}),m.jsx(Ha,{label:"Turns",value:i?.runs??0}),m.jsx(Ha,{label:"Tokens",value:K0(i?.tokens??0)}),m.jsx(Ha,{label:"Cost",value:`$${(i?.costUsd??0).toFixed(4)}`}),i?.lastTokens!=null&&m.jsx(Ha,{label:"Last turn",value:`${K0(i.lastTokens)} tok · $${(i.lastCostUsd??0).toFixed(4)}`})]})]})}function T9({domainId:e,settings:t,harness:r,values:i,setValues:o,agentModels:s,setAgentModels:u}){const{data:d,isFetching:h,error:f}=_T(e),{data:y}=DT(e),p=Bt(),v=r?.capabilities.effortLevels??[...ck],b=r?.capabilities.accessLevels??[...Xp],w=Kp(v,i.agentEffort??t?.agentEffort),C=un({mutationFn:H=>je.selectHarness(H.domainId,H.harness),onSuccess:(H,_)=>{p.setQueryData(Se.harness(_.domainId),H),p.setQueryData(Se.agentSession(_.domainId),void 0),p.setQueryData(Se.loadout(_.domainId),void 0),p.invalidateQueries({queryKey:Se.harness(_.domainId)}),p.invalidateQueries({queryKey:Se.agentSession(_.domainId)}),p.invalidateQueries({queryKey:Se.agent(_.domainId)}),p.invalidateQueries({queryKey:Se.loadout(_.domainId)}),Ee.success(`Using ${H.label}`)},onError:H=>Ee.error(String(H))}),j=un({mutationFn:H=>je.loadout(H,!0),onSuccess:(H,_)=>p.setQueryData(Se.loadout(_),H),onError:H=>Ee.error(String(H))}),E=r?.options??[{id:"claude",label:"Claude Code (local)"}],N=r?.id??"claude",R=s[N]??"",P=H=>u(_=>g9(_,N,H));return m.jsxs("div",{children:[m.jsx("div",{className:"mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Agent"}),m.jsxs("div",{className:"divide-y divide-border/50 rounded-lg border bg-card/40",children:[m.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-[13px]",children:[m.jsx("span",{className:"truncate",children:"Harness"}),m.jsx(jn,{text:"Which installed local coding agent handles Studio turns. Conversations are preserved independently per harness."})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[r?.locked&&m.jsx(k1,{className:"h-3 w-3 shrink-0 text-muted-foreground/40"}),m.jsx("select",{disabled:!e||!r||r.locked||C.isPending,value:r?.id??"claude",onChange:H=>C.mutate({domainId:e,harness:H.target.value}),className:"w-40 shrink-0 rounded-md border bg-background px-2 py-1 text-[13px] outline-none disabled:cursor-not-allowed disabled:text-muted-foreground",children:E.map(H=>m.jsx("option",{value:H.id,children:H.label},H.id))})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[m.jsx("span",{className:ge("h-2 w-2 shrink-0 rounded-full",r?r.ok?"bg-emerald-500":"bg-destructive":"bg-muted-foreground/30")}),m.jsx("span",{className:ge("truncate",r&&!r.ok?"font-medium text-destructive":"text-muted-foreground/70"),children:r?r.message:"Checking…"}),r?.locked&&m.jsx("span",{className:"ml-auto shrink-0 text-muted-foreground/50",children:"locked by --harness"})]})]}),m.jsx(y9,{selected:R,loadout:d,modelOptions:r?.capabilities.modelOptions,onChange:P}),m.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Effort"}),m.jsx(jn,{text:"Passed using the selected harness's native reasoning-effort setting. Only values supported by that harness are shown."}),m.jsx("span",{className:"ml-auto font-mono text-[11px] text-muted-foreground/70",children:w??"high"})]}),m.jsx(b9,{value:i.agentEffort??t?.agentEffort,levels:v,onChange:H=>o(_=>({..._,agentEffort:H}))})]}),m.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[m.jsxs("div",{className:"flex items-center gap-1.5 text-[13px]",children:[m.jsx("span",{children:"Access"}),m.jsx(jn,{text:"Workspace keeps the agent sandboxed to local edits. Full automation preserves Studio's deploy/install capability and grants unrestricted local command access."}),m.jsx("span",{className:"ml-auto font-mono text-[11px] text-muted-foreground/70",children:i.agentAccess??t?.agentAccess??"full"})]}),m.jsx(w9,{value:i.agentAccess??t?.agentAccess,levels:b,onChange:H=>o(_=>({..._,agentAccess:H}))})]}),m.jsx(S9,{domainId:e,harness:r}),m.jsx(A9,{loadout:d,loading:h||j.isPending,errorMessage:f?String(f?.message??f):void 0,usage:y,domainId:e,onRefresh:()=>j.mutate(e)})]})]})}const cs={introspectTimeoutMs:{min:250,max:3e5},instancePollMs:{min:1e3,max:36e5},updatesPollMs:{min:1e4,max:864e5},viewProbeTimeoutMs:{min:250,max:12e4}};function O9(e,t){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&!t.trim())return null;const r=typeof t=="number"?t:Number(t),{min:i,max:o}=cs[e];return Number.isInteger(r)&&r>=i&&r<=o?r:null}const dk=[{title:"Detection",fields:[{key:"integrationsDir",label:"Integrations folder",hint:"Folder under the domain root scanned for integrations.",type:"text",placeholder:"integrations"}]},{title:"Performance",fields:[{key:"introspectTimeoutMs",label:"Schema extraction timeout",hint:"How long the Bun introspector may run before it is killed (ms). Raise for very large domains.",type:"number",placeholder:"20000"},{key:"instancePollMs",label:"Instance status poll",hint:"How often the deploy / instance status refreshes (ms). Raise to make fewer CLI calls.",type:"number",placeholder:"30000"},{key:"updatesPollMs",label:"Updates check interval",hint:"How often the studio re-checks for stale schema / available updates (ms).",type:"number",placeholder:"600000"},{key:"viewProbeTimeoutMs",label:"View URL probe timeout",hint:"How long to wait when resolving a live view URL from the instance (ms).",type:"number",placeholder:"8000"}]}];function R9(e,t){const r={};for(const i of dk)for(const o of i.fields){const s=e[o.key]??"";if(o.type==="number"){const u=O9(o.key,s);if(u===null)throw new Error(`${o.label} must be a whole number from ${cs[o.key].min} to ${cs[o.key].max} ms`);r[o.key]=u}else r[o.key]=s.trim()||t[o.key]}return r}function _9({values:e,onChange:t}){return dk.map(r=>m.jsxs("div",{children:[m.jsx("div",{className:"mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:r.title}),m.jsx("div",{className:"divide-y divide-border/50 rounded-lg border bg-card/40",children:r.fields.map(i=>m.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[m.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5 text-[13px]",children:[m.jsx("span",{className:"truncate",children:i.label}),m.jsx(jn,{text:i.hint})]}),m.jsx("input",{type:i.type,min:i.type==="number"?cs[i.key].min:void 0,max:i.type==="number"?cs[i.key].max:void 0,step:i.type==="number"?1:void 0,value:e[i.key]??"",onChange:o=>t(i.key,o.target.value),placeholder:i.placeholder,className:"w-32 shrink-0 rounded-md border bg-background px-2 py-1 text-right font-mono text-[13px] outline-none focus:border-primary"})]},i.key))})]},r.title))}const Mm=typeof window<"u"&&window.self!==window.top,D9={mint:"Auto-mint",token:"Static token",host:"Host-managed"},M9=["mint","token","host"];function z9({mode:e,setMode:t,instance:r,setInstance:i,token:o,setToken:s,reveal:u,setReveal:d}){return m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:["Authentication",m.jsx(jn,{text:"How the harness gets its bearer token. Auto-mint: the studio mints a short-lived delegation token per run via `astrale token` (no secret stored) — best for Astrale gateways. Static token: a bearer you paste. Host-managed: the embedding Astrale app supplies it via the shell (used when the studio runs inside the Astrale GUI)."})]}),m.jsx("div",{className:"grid grid-cols-3 gap-1 rounded-md bg-muted/45 p-1",role:"radiogroup","aria-label":"Auth mode",children:M9.map(h=>m.jsx("button",{type:"button",role:"radio","aria-checked":e===h,onClick:()=>t(h),className:ge("rounded px-1.5 py-1 text-center text-[11px] font-medium transition-colors",e===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:D9[h]},h))}),e==="mint"&&m.jsxs("div",{className:"space-y-1 pt-0.5",children:[m.jsx("input",{value:r,onChange:h=>i(h.target.value),placeholder:"instance to mint on (blank = active instance)",spellCheck:!1,autoComplete:"off",className:"w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary"}),m.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground/60",children:"A fresh delegation token is minted per run (no secret stored). You must be signed in to the instance and have USE on the model node."})]}),e==="token"&&m.jsxs("div",{className:"space-y-1 pt-0.5",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("input",{type:u?"text":"password",value:o,onChange:h=>s(h.target.value),placeholder:"bearer token (e.g. astrale token --audience <gateway-origin>)",spellCheck:!1,autoComplete:"off",className:"w-full min-w-0 rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary"}),m.jsx("button",{type:"button",onClick:()=>d(!u),title:u?"Hide":"Reveal",className:"shrink-0 rounded-md p-1 text-muted-foreground/60 transition-colors hover:text-foreground",children:u?m.jsx(x1,{className:"h-3.5 w-3.5"}):m.jsx(v1,{className:"h-3.5 w-3.5"})})]}),m.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground/60",children:"Stored locally in .domain-studio. It will stop working when the token expires."})]}),e==="host"&&m.jsx("p",{className:"pt-0.5 text-[10px] leading-relaxed text-muted-foreground/60",children:Mm?"The embedding Astrale app supplies (and refreshes) the token via the shell.":"For when the studio runs embedded in the Astrale GUI — the host then supplies the token via the shell. No effect standalone."})]})}function X0({status:e,help:t=!1}){return m.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 px-1",children:[m.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Model gateway"}),t&&m.jsx(jn,{text:"Route the local Claude Code harness through a custom Anthropic-compatible endpoint (e.g. an Astrale ai-gateway model node) instead of its built-in auth. The URL + token are set as ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN on the spawned `claude` child ONLY — never your shell or a `claude` you run outside the studio."}),m.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:e})]})}function Z0({label:e,hint:t,value:r,onChange:i,placeholder:o}){return m.jsxs("div",{className:"space-y-1",children:[m.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-muted-foreground",children:[e,m.jsx(jn,{text:t})]}),m.jsx("input",{value:r,onChange:s=>i(s.target.value),placeholder:o,spellCheck:!1,autoComplete:"off",className:"w-full rounded-md border bg-background px-2 py-1 font-mono text-[12px] outline-none placeholder:text-muted-foreground/40 focus:border-primary"})]})}function L9(e,t,r,i){if(!e)return null;const o=t.trim();if(!o)return"Base URL is required while the custom gateway is enabled.";try{const s=new URL(o);if(s.protocol!=="http:"&&s.protocol!=="https:")return"Base URL must use http:// or https://."}catch{return"Base URL must be a valid URL."}return r==="token"&&!i.trim()?"A static bearer token is required in token mode.":null}function P9({domainId:e,harness:t}){const r=t?.capabilities.gateway==="anthropic",{data:i,isFetching:o}=RT(r?e:void 0),s=Bt(),[u,d]=k.useState(!1),[h,f]=k.useState(""),[y,p]=k.useState(""),[v,b]=k.useState(Mm?"host":"mint"),[w,C]=k.useState(""),[j,E]=k.useState(""),[N,R]=k.useState(!1),[P,H]=k.useState(!1);k.useEffect(()=>{const Y=i?.local??i?.global??null;d(Y?.enabled??!1),f(Y?.baseUrl??""),p(Y?.model??""),b(Y?.auth.mode??(Mm?"host":"mint")),C(Y?.auth.mode==="mint"?Y.auth.instance??"":""),E(Y?.auth.mode==="token"?Y.auth.token:""),R(i?.local==null&&i?.global!=null),H(!1)},[e,i]);const _=()=>v==="token"?{mode:"token",token:j.trim()}:v==="host"?{mode:"host"}:{mode:"mint",...w.trim()?{instance:w.trim()}:{}},q=L9(u,h,v,j),I=un({mutationFn:Y=>je.setHarnessGateway(Y.domainId,Y.scope,Y.config),onSuccess:(Y,fe)=>{s.invalidateQueries({queryKey:Se.harnessGateway(fe.domainId)}),s.invalidateQueries({queryKey:Se.loadout(fe.domainId)}),Ee.success(fe.scope==="global"?"Saved for all domains":"Saved for this domain")},onError:Y=>Ee.error(String(Y))}),ie=un({mutationFn:Y=>je.clearHarnessGateway(Y,"domain"),onSuccess:(Y,fe)=>{s.invalidateQueries({queryKey:Se.harnessGateway(fe)}),s.invalidateQueries({queryKey:Se.loadout(fe)}),Ee.success("Override removed — inheriting the default")},onError:Y=>Ee.error(String(Y))});if(t&&!r)return m.jsxs("div",{children:[m.jsx(X0,{status:"not applicable"}),m.jsx("div",{className:"rounded-lg border bg-card/40 px-3 py-2.5 text-[12px] leading-relaxed text-muted-foreground",children:t.id==="codex"?"Codex uses its own local login. The Astrale gateway currently exposes Chat Completions and Anthropic Messages, while Codex custom providers require the Responses API.":`${t.label} does not expose a Studio model-gateway adapter.`})]});const U=i?.source??"none",te=U==="domain"?"active for this domain":U==="global"?"inherited from the studio-wide default":"off — the harness uses its own Claude Code auth";return m.jsxs("div",{children:[m.jsx(X0,{status:te,help:!0}),m.jsxs("div",{className:"space-y-2.5 rounded-lg border bg-card/40 px-3 py-2.5",children:[m.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[13px]",children:[m.jsx("input",{type:"checkbox",checked:u,onChange:Y=>d(Y.target.checked),className:"h-3.5 w-3.5 accent-primary"}),m.jsx("span",{children:"Use a custom model gateway"})]}),u&&m.jsxs("div",{className:"space-y-2.5 border-t pt-2.5",children:[m.jsx(Z0,{label:"Base URL",hint:"ANTHROPIC_BASE_URL. Claude Code POSTs to `${baseUrl}/v1/messages`. For an Astrale model node: https://<gateway-host>/v1/models/<modelNodeId>. The token audience is derived from this URL's origin.",value:h,onChange:f,placeholder:"https://ai-gateway.astrale.ai/v1/models/<modelNodeId>"}),m.jsx(Z0,{label:"Model label",hint:"ANTHROPIC_MODEL — shown in the loadout and sent as the request `model`. Cosmetic: an Astrale gateway pins the real model by URL, so this is just a name (e.g. glm-5.2).",value:y,onChange:p,placeholder:"glm-5.2 (optional)"}),m.jsx(z9,{mode:v,setMode:b,instance:w,setInstance:C,token:j,setToken:E,reveal:P,setReveal:H})]}),m.jsxs("label",{className:"flex cursor-pointer items-center gap-2 border-t pt-2.5 text-[12px]",children:[m.jsx("input",{type:"checkbox",checked:N,onChange:Y=>R(Y.target.checked),className:"h-3.5 w-3.5 accent-primary"}),m.jsxs("span",{className:"flex items-center gap-1.5",children:["Apply to all domains",m.jsx(jn,{text:"Save as the studio-wide default for every domain (and clear this domain's own override so it inherits it). Off ⇒ this setting applies to THIS domain only. Either way it never leaks outside the studio."})]})]}),m.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[m.jsx("button",{type:"button",disabled:!e||!i||o||!!q||I.isPending,onClick:()=>I.mutate({domainId:e,scope:N?"global":"domain",config:{enabled:u,baseUrl:h.trim(),model:y.trim()||void 0,auth:_()}}),className:"rounded-md bg-primary px-2.5 py-1 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:I.isPending?"Saving…":N?"Save for all domains":"Save for this domain"}),i?.local!=null&&m.jsx("button",{type:"button",disabled:o||ie.isPending,onClick:()=>ie.mutate(e),className:"rounded-md px-2.5 py-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",title:"Remove this domain's override and inherit the studio-wide default (or default auth)",children:"Reset to default"})]}),q&&m.jsx("p",{className:"text-[11px] text-destructive",children:q})]})]})}function H9(){const e=ke(p=>p.settingsOpen),t=ke(p=>p.setSettingsOpen),r=ke(p=>p.domainId),{data:i}=Vm(e?r:void 0),{data:o}=OT(e?r:void 0),s=Bt(),[u,d]=k.useState({}),[h,f]=k.useState({});k.useEffect(()=>{i&&(d(Object.fromEntries(Object.entries(i).filter(([,p])=>typeof p!="object").map(([p,v])=>[p,String(v)]))),f({...i.agentModels}))},[i]);const y=un({mutationFn:async p=>{const v=R9(p.values,p.settings),b=p.harness?.capabilities.effortLevels??[...ck],w=p.harness?.capabilities.accessLevels??[...Xp],C=Kp(b,p.values.agentEffort);C&&(v.agentEffort=C);const j=w.includes(p.values.agentAccess)?p.values.agentAccess:w.includes("full")?"full":w[0];return j&&(v.agentAccess=j),v.agentModels=p.agentModels,je.updateSettings(p.domainId,v)},onSuccess:(p,v)=>{s.invalidateQueries({queryKey:Se.settings(v.domainId)}),s.invalidateQueries({queryKey:Se.anatomy(v.domainId)}),s.invalidateQueries({queryKey:Se.agent(v.domainId)}),s.invalidateQueries({queryKey:Se.loadout(v.domainId)}),Ee.success("Settings saved"),t(!1)},onError:p=>Ee.error(String(p))});return m.jsx(Vl,{open:e,onOpenChange:t,children:m.jsxs(Li,{className:"w-[calc(100%-2rem)] max-w-xl",children:[m.jsxs(Yl,{children:[m.jsx(Pi,{children:"Settings"}),m.jsx(bs,{children:"Power-user overrides for this domain — stored in .domain-studio/settings.json."})]}),m.jsxs("div",{className:"-mx-1 max-h-[60vh] space-y-5 overflow-y-auto px-1",children:[m.jsx(T9,{domainId:e?r:void 0,settings:i,harness:o,values:u,setValues:d,agentModels:h,setAgentModels:f}),m.jsx(P9,{domainId:r,harness:o}),m.jsx(d9,{domainId:r}),m.jsx(_9,{values:u,onChange:(p,v)=>d(b=>({...b,[p]:v}))})]}),m.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[m.jsx("button",{type:"button",onClick:()=>t(!1),className:"rounded-md px-3 py-1.5 text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:"Cancel"}),m.jsx("button",{type:"button",disabled:!r||!i||y.isPending,onClick:()=>y.mutate({domainId:r,settings:i,harness:o,values:{...u},agentModels:{...h}}),className:"rounded-md bg-primary px-3 py-1.5 text-[13px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:"Save"})]})]})})}function U9({domainId:e}){const{data:t}=NT(e),r=Bt(),[i,o]=k.useState("idle"),[s,u]=k.useState(null);if(!t?.stale&&i==="idle")return null;const{cli:d,sdk:h}=t??{cli:{stale:!1},sdk:{stale:!1,outdated:[]}},f=async()=>{o("running"),u(null);try{const y=await je.applyUpdate(e);u(y),o("done"),y.ok?(Ee.success("Updated"),r.invalidateQueries({queryKey:Se.updates(e)})):Ee.error("Update failed")}catch(y){u({ok:!1,output:String(y)}),o("done")}};return m.jsxs(Ui,{onOpenChange:y=>{y||(o("idle"),u(null))},children:[m.jsx(Vc,{asChild:!0,children:m.jsxs("button",{type:"button",title:"Update available",className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-2 text-xs font-medium text-warning transition-colors hover:bg-warning/20",children:[m.jsx(hb,{className:"h-3.5 w-3.5"}),m.jsx("span",{children:"Update"}),m.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-warning"})]})}),m.jsxs(Ga,{align:"end",className:"w-72 space-y-2.5 p-3",children:[m.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Update available"}),d.stale&&m.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[m.jsx("span",{className:"font-medium text-foreground",children:"Astrale CLI"}),m.jsxs("span",{className:"shrink-0 font-mono text-muted-foreground",children:[d.current," → ",d.latest,d.channel?m.jsxs("span",{className:"text-muted-foreground/60",children:[" (",d.channel,")"]}):null]})]}),h.stale&&m.jsxs("div",{className:"space-y-0.5 text-[11px]",children:[m.jsx("div",{className:"font-medium text-foreground",children:"SDK packages"}),h.outdated.map(y=>m.jsxs("div",{className:"flex items-center justify-between gap-2 font-mono text-muted-foreground",children:[m.jsx("span",{className:"truncate",children:y.pkg}),m.jsxs("span",{className:"shrink-0",children:[y.current," → ",y.latest]})]},y.pkg))]}),i==="idle"?m.jsxs(Ke,{size:"sm",className:"w-full",onClick:f,children:[m.jsx(hb,{className:"h-3.5 w-3.5"})," Update now"]}):i==="running"?m.jsxs(Ke,{size:"sm",className:"w-full",disabled:!0,children:[m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"})," Updating…"]}):m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:ge("flex items-center gap-1.5 text-xs font-medium",s?.ok?"text-success":"text-destructive"),children:[s?.ok?m.jsx(aa,{className:"h-3.5 w-3.5"}):m.jsx(kc,{className:"h-3.5 w-3.5"}),s?.ok?"Updated":"Failed"]}),s?.output&&m.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded bg-muted/50 p-1.5 text-[10px] leading-tight text-muted-foreground",children:s.output.slice(-1600)}),m.jsx(Ke,{size:"xs",variant:"outline",className:"w-full",onClick:()=>o("idle"),children:"Done"})]})]})]})}function B9(e){const t=k.useRef(e);k.useEffect(()=>{t.current=e}),k.useEffect(()=>{let r=null,i,o=!1,s=1e3;const u=()=>{r=new EventSource("/api/events"),r.onmessage=d=>{s=1e3;try{t.current(JSON.parse(d.data))}catch{}},r.onerror=()=>{r&&r.readyState===EventSource.CLOSED&&!o&&(r.close(),i=setTimeout(u,s),s=Math.min(s*2,15e3))}};return u(),()=>{o=!0,clearTimeout(i),r?.close()}},[])}function I9(){const e=ke(w=>w.copyOpen),t=ke(w=>w.setCopyOpen),r=ke(w=>w.domainId),[i,o]=k.useState(!1),[s,u]=k.useState(""),[d,h]=k.useState(0),[f,y]=k.useState(!1),[p,v]=k.useState(!1);k.useEffect(()=>{!e||!r||(y(!0),je.copyPayload(r,i).then(w=>{u(w.markdown),h(w.openComments)}).catch(w=>Ee.error(String(w))).finally(()=>y(!1)))},[e,r,i]);const b=async()=>{await navigator.clipboard.writeText(s),v(!0),Ee.success("Copied — paste into your terminal agent"),setTimeout(()=>v(!1),1500)};return m.jsx(Vl,{open:e,onOpenChange:t,children:m.jsxs(Li,{className:"max-w-3xl",children:[m.jsxs(Yl,{children:[m.jsx(Pi,{children:"Copy handoff for the agent"}),m.jsxs(bs,{children:[d," open thread",d===1?"":"s"," + embedded context and document paths. Paste into Claude Code / Codex."]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Ke,{size:"sm",variant:i?"default":"outline",onClick:()=>o(w=>!w),children:i?"Including auto-context":"Include auto-context"}),m.jsx(Wo,{variant:"muted",children:"read-only handoff"})]}),m.jsx(zp,{className:"h-[50vh] rounded-md border bg-muted/40",children:m.jsx("pre",{className:"p-3 text-xs font-mono whitespace-pre-wrap",children:f?"Building payload…":s})}),m.jsx(vp,{children:m.jsxs(Ke,{onClick:b,disabled:f||!s,children:[p?m.jsx(aa,{className:"h-4 w-4"}):m.jsx(p1,{className:"h-4 w-4"}),p?"Copied":"Copy to clipboard"]})})]})})}function q9(){const e=ke(f=>f.mergeOpen),t=ke(f=>f.setMergeOpen),r=ke(f=>f.domainId),i=Bt(),[o,s]=k.useState(""),[u,d]=k.useState(!1),h=async()=>{if(!(!r||!o.trim())){d(!0);try{const f=await je.mergeReply(r,o);i.invalidateQueries({queryKey:Se.comments(r)});const y=[`merged ${f.merged}`,`closed ${f.closed}`];f.unknownIds.length&&y.push(`${f.unknownIds.length} unknown id(s)`),f.schemaMismatch&&y.push("⚠ authored against an older schema"),Ee.success(`Reply merged — ${y.join(", ")}`),s(""),t(!1)}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx(Vl,{open:e,onOpenChange:t,children:m.jsxs(Li,{className:"max-w-2xl",children:[m.jsxs(Yl,{children:[m.jsx(Pi,{children:"Paste the agent's reply"}),m.jsxs(bs,{children:["Paste the agent's response (prose + its trailing"," ",m.jsx("code",{className:"font-mono",children:"```json"})," block). Threads merge by id."]})]}),m.jsx(Ar,{className:"min-h-[40vh] text-xs",placeholder:"Paste the agent reply here…",value:o,onChange:f=>s(f.target.value)}),m.jsxs(vp,{children:[m.jsx(Ke,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),m.jsxs(Ke,{onClick:h,disabled:u||!o.trim(),children:[m.jsx(b1,{className:"h-4 w-4"})," Merge reply"]})]})]})})}function F9(e){return e==="section.schema"?"Schema canvas":e.startsWith("view.")?`View · ${e.slice(5)}`:e.startsWith("module.")?`Module · ${e.slice(7)}`:e.startsWith("class.")?`Class · ${e.slice(6)}`:e.startsWith("interface.")?`Interface · ${e.slice(10)}`:e.startsWith("edge.")?`Edge · ${e.slice(5)}`:e.startsWith("section.")?e.slice(8).replace(/\./g," · "):e}function $9({domainId:e}){const{data:t,isLoading:r}=Nc(e),[i,o]=k.useState("open"),s=ke(b=>b.setCopyOpen),u=ke(b=>b.setMergeOpen),d="Pin notes to any element, then Submit to the agent — it edits the code and replies here.";if(r)return m.jsx(_m,{title:"Comments",subtitle:d,icon:m.jsx(Ei,{className:"h-5 w-5"}),children:m.jsx("div",{className:"flex items-center justify-center py-12 text-sm text-muted-foreground",children:"Loading comments…"})});const h=t?.comments??[],f=h.filter(b=>b.status==="open"),y=h.filter(b=>b.status==="closed"),p=i==="open"?f:y,v=[{key:"open",label:"Open",count:f.length},{key:"closed",label:"Resolved",count:y.length}];return m.jsxs(m.Fragment,{children:[m.jsx(_m,{title:"Comments",subtitle:d,icon:m.jsx(Ei,{className:"h-5 w-5"}),actions:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs(Ke,{variant:"outline",size:"sm",onClick:()=>s(!0),children:[m.jsx(p1,{className:"h-3.5 w-3.5"}),"Copy for agent"]}),m.jsxs(Ke,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[m.jsx(b1,{className:"h-3.5 w-3.5"}),"Merge reply"]}),m.jsx("div",{className:"inline-flex items-center gap-0.5 rounded-lg bg-muted/60 p-0.5",children:v.map(b=>m.jsxs("button",{type:"button",onClick:()=>o(b.key),className:ge("inline-flex items-center gap-1.5 rounded-md px-3 py-1 text-[13px] font-medium transition-colors",i===b.key?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[b.label,m.jsx("span",{className:ge("text-xs",i===b.key?"text-muted-foreground":"text-muted-foreground/60"),children:b.count})]},b.key))})]}),children:p.length===0?m.jsx(wr,{children:m.jsx(J2,{icon:m.jsx(Ei,{}),title:i==="open"?"No open threads":"No resolved threads yet",hint:i==="open"?"Hover any element and click the comment icon to start one.":void 0})}):m.jsx("div",{className:"flex flex-col gap-3",children:p.map(b=>m.jsx(Y9,{domainId:e,comment:b},b.id))})}),m.jsx(I9,{}),m.jsx(q9,{})]})}function V9({entry:e,commentId:t,open:r,isLast:i,domainId:o}){const s=e.role==="author",u=e.type==="choice"&&!!e.options&&s&&r&&i;return m.jsxs("div",{className:"flex flex-col gap-1",children:[m.jsxs("div",{className:"flex flex-col gap-0.5 text-[13px] leading-relaxed",children:[m.jsx("span",{className:ge("text-[11px] font-semibold uppercase tracking-wider",s?"text-primary":"text-muted-foreground"),children:s?"agent":"you"}),m.jsx(ak,{commentId:t,entryId:e.id,text:e.text})]}),e.type==="choice"&&e.options&&(u?m.jsx(ik,{commentId:t,options:e.options,domainId:o}):m.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(d=>m.jsx(nn,{tone:e.answer===d?"primary":"outline",children:d},d))}))]})}function Y9({domainId:e,comment:t}){const{reply:r,setStatus:i,remove:o}=ms(e),[s,u]=k.useState(""),d=t.anchorRefs[0];return m.jsxs(wr,{className:ge("overflow-hidden",t.status==="closed"&&"opacity-70"),children:[m.jsx(W2,{className:"border-b py-3",leading:m.jsx(Ei,{className:"h-4 w-4 text-muted-foreground/70"}),trailing:m.jsx("button",{type:"button",title:"Remove thread",onClick:()=>o.mutate(t.id,{onSuccess:()=>Ee.success("Deleted")}),className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover/row:opacity-100",children:m.jsx(qm,{className:"h-3.5 w-3.5"})}),children:m.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[m.jsx(nn,{tone:t.status==="open"?"primary":"default",children:t.status}),t.orphaned&&m.jsx(nn,{tone:"danger",children:"orphaned"}),d&&m.jsx("span",{className:"truncate text-xs text-muted-foreground/70",title:d.ref,children:F9(d.ref)})]})}),m.jsx("div",{className:"flex flex-col gap-3 px-4 py-3.5",children:t.thread.map((h,f)=>m.jsx(V9,{entry:h,commentId:t.id,open:t.status==="open",isLast:f===t.thread.length-1,domainId:e},h.id))}),t.status==="open"&&m.jsxs("div",{className:"flex flex-col gap-2.5 border-t px-4 py-3",children:[m.jsx(Ar,{className:"min-h-16 resize-none font-sans text-[13px]",placeholder:"Reply…",value:s,onChange:h=>u(h.target.value)}),m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsxs("button",{type:"button",onClick:()=>i.mutate({commentId:t.id,status:"closed"},{onSuccess:()=>Ee.success("Resolved")}),className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[m.jsx(aa,{className:"h-3.5 w-3.5"}),"Resolve"]}),m.jsx("button",{type:"button",disabled:!s.trim()||r.isPending,onClick:()=>r.mutate({commentId:t.id,entry:{role:"user",type:"text",text:s.trim()}},{onSuccess:()=>u("")}),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary/12 px-3 py-1.5 text-[13px] font-medium text-primary transition-colors hover:bg-primary/20 disabled:opacity-50",children:"Reply"})]})]})]})}function Q9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function G9(e){const t=e.name.toLowerCase(),r=e.type;return/\.pdf$/.test(t)||r==="application/pdf"?{Icon:pb,tint:"bg-red-400/10 text-red-400",label:"PDF"}:/\.(xlsx?|csv|tsv)$/.test(t)||r.includes("sheet")||r==="text/csv"?{Icon:UN,tint:"bg-emerald-400/10 text-emerald-400",label:/\.csv$/.test(t)?"CSV":"XLS"}:/\.(md|mdx|markdown)$/.test(t)||r==="text/markdown"?{Icon:S1,tint:"bg-sky-400/10 text-sky-400",label:"MD"}:/\.(docx?|rtf)$/.test(t)||r.includes("word")?{Icon:qN,tint:"bg-blue-400/10 text-blue-400",label:"DOC"}:r.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)$/.test(t)?{Icon:zN,tint:"bg-fuchsia-400/10 text-fuchsia-400",label:"IMG"}:/\.(json|ya?ml|toml|ts|tsx|js|jsx|py|go|rs|sh|html|css)$/.test(t)||r.includes("json")?{Icon:DN,tint:"bg-amber-400/10 text-amber-400",label:"CODE"}:r.startsWith("text/")||/\.(txt|log|env)$/.test(t)?{Icon:pb,tint:"bg-slate-400/10 text-slate-400",label:"TXT"}:{Icon:$N,tint:"bg-muted text-muted-foreground",label:(t.split(".").pop()??"file").slice(0,4).toUpperCase()}}const fk=e=>e.type==="text/markdown"||/\.(md|mdx|markdown)$/i.test(e.name),K9=e=>e.type.startsWith("text/")||e.type.includes("json")||fk(e)||/\.(txt|json|ya?ml|csv|tsv|ts|tsx|js|jsx|html|css|toml|env|log)$/i.test(e.name);function hk(e){return`${e.trim().toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note"}.md`}const X9=e=>hk((e.split(`
|
|
81
|
-
`).map(t=>t.replace(/^#+\s*/,"").trim()).find(Boolean)??"").slice(0,60));function Z9({domainId:e}){const{data:t}=LT(e),r=Bt(),i=()=>r.invalidateQueries({queryKey:Se.documents(e)}),[o,s]=k.useState(!1),[u,d]=k.useState(null),h=un({mutationFn:w=>je.uploadDocuments(e,w),onSuccess:w=>{i(),Ee.success(`Added ${w.length} document${w.length===1?"":"s"}`)},onError:w=>Ee.error(String(w))}),f=un({mutationFn:w=>je.deleteDocument(e,w),onSuccess:i}),y=w=>{const C=w?[...w]:[];C.length&&h.mutate(C)},p=(w,C)=>h.mutate([new File([w],C?hk(C):X9(w),{type:"text/markdown"})]),v=w=>{const C=w.dataTransfer.files;if(C?.length){w.preventDefault(),s(!1),y(C);return}if(s(!1),w.target.closest("textarea, input"))return;const j=w.dataTransfer.getData("text/plain");j.trim()&&(w.preventDefault(),p(j))};if(!t)return m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading…"});const b=t.length;return m.jsxs("div",{className:"relative h-full",onDragOver:w=>{Array.from(w.dataTransfer.types).includes("Files")&&(w.preventDefault(),s(!0))},onDragLeave:w=>{w.currentTarget.contains(w.relatedTarget)||s(!1)},onDrop:v,children:[m.jsx("div",{className:"h-full overflow-y-auto",children:m.jsxs("div",{className:"mx-auto w-full max-w-3xl space-y-6 px-6 pb-28 pt-10",children:[m.jsx(W9,{domainId:e}),b===0?m.jsxs("div",{className:"space-y-4",children:[m.jsx(W0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx(J9,{busy:h.isPending,onFiles:y})]}):m.jsxs("div",{className:"space-y-6",children:[m.jsx(W0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(w=>m.jsx(eP,{domainId:e,doc:w,onEdit:()=>d(w),onDelete:()=>f.mutate(w.id)},w.id))})]})]})}),o&&m.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl border-2 border-dashed border-primary/60 px-16 py-12 text-primary",children:[m.jsx(Fm,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm font-medium",children:"Drop to add"})]})}),u&&m.jsx(tP,{domainId:e,doc:u,onClose:()=>d(null),onSaved:i})]})}function mk({expanded:e,onClick:t}){const r=e?SA:yA,i=e?"Collapse editor":"Expand editor";return m.jsx("button",{type:"button",title:i,"aria-label":i,onClick:t,className:"absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:m.jsx(r,{className:"h-3.5 w-3.5"})})}function W9({domainId:e}){const[t,r]=k.useState(""),[i,o]=k.useState(!1),[s,u]=k.useState(!1),d=hs(e),h=$m(e),f=Wr(C=>C.setRun),y=Bt(),p=Ec(h),v=d.data?.available??!1,b=t.trim().length>0&&!s&&!p&&v,w=async()=>{if(b){u(!0);try{const C=await je.agentSubmit(e,t.trim());if(C.error){Ee.error(C.error);return}f(C),r(""),Ee.success("Sent to the agent")}catch(C){Ee.error(String(C))}finally{u(!1),y.invalidateQueries({queryKey:Se.agent(e)})}}};return m.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Ar,{autoFocus:!0,value:t,onChange:C=>r(C.target.value),onKeyDown:C=>{(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),w())},placeholder:"Tell me what you want to do?",className:ge("max-h-[65vh] min-h-[120px] resize-y border-0 bg-transparent pr-10 text-[15px] leading-relaxed shadow-none focus-visible:ring-0",i&&"min-h-[45vh]")}),m.jsx(mk,{expanded:i,onClick:()=>o(C=>!C)})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 border-t px-3 py-2",children:[m.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:p?"Agent working…":v?"⌘↵ to send":"agent unavailable"}),m.jsxs(Ke,{size:"sm",onClick:w,disabled:!b,children:[s||p?m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Im,{className:"h-3.5 w-3.5"})," ","Send to agent"]})]})]})}function W0({hero:e,busy:t,onText:r,onFiles:i}){const[o,s]=k.useState(""),[u,d]=k.useState(!1),h=k.useRef(null),f=()=>{!o.trim()||t||(r(o),s(""))};return m.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Ar,{autoFocus:e,value:o,onChange:y=>s(y.target.value),onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.key==="Enter"&&(y.preventDefault(),f())},placeholder:e?"Paste anything — notes, specs, decisions…":"Paste text to save as markdown…",className:ge("max-h-[65vh] resize-y border-0 bg-transparent pr-10 leading-relaxed shadow-none focus-visible:ring-0",u?e?"min-h-[45vh] text-[15px]":"min-h-[32vh]":e?"min-h-[180px] text-[15px]":"min-h-[80px]")}),m.jsx(mk,{expanded:u,onClick:()=>d(y=>!y)})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 border-t px-3 py-2",children:[e?m.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"⌘↵ to save"}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",onClick:()=>h.current?.click(),className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[m.jsx(Fm,{className:"h-4 w-4"})," ",t?"Uploading…":"Upload"]}),m.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:y=>{i(y.target.files),y.target.value=""}})]}),o.trim()&&m.jsxs(Ke,{size:"sm",onClick:f,disabled:t,children:[m.jsx(y1,{className:"h-3.5 w-3.5"})," Save"]})]})]})}function J9({busy:e,onFiles:t}){const r=k.useRef(null);return m.jsxs("button",{type:"button",onClick:()=>r.current?.click(),className:"flex w-full flex-col items-center justify-center gap-2 rounded-2xl border border-dashed py-10 text-muted-foreground transition-colors hover:border-muted-foreground/40 hover:bg-accent/20",children:[m.jsx(Fm,{className:"h-6 w-6"}),m.jsx("p",{className:"text-[13px]",children:e?"Uploading…":"Drop files or browse"}),m.jsx("input",{ref:r,type:"file",multiple:!0,className:"hidden",onChange:i=>{t(i.target.files),i.target.value=""}})]})}function eP({domainId:e,doc:t,onEdit:r,onDelete:i}){const o=G9(t),s=async()=>{try{await navigator.clipboard.writeText(await je.docContent(e,t.id)),Ee.success("Copied")}catch{Ee.error("Copy failed")}};return m.jsxs("div",{className:"group flex flex-col gap-2.5 rounded-xl border bg-card/50 p-3 transition-colors hover:border-muted-foreground/30 hover:bg-accent/30",children:[m.jsxs("div",{className:"flex items-start justify-between",children:[m.jsx("div",{className:ge("flex h-9 w-9 items-center justify-center rounded-lg",o.tint),children:m.jsx(o.Icon,{className:"h-[18px] w-[18px]"})}),m.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[K9(t)&&m.jsx(Yh,{title:"Copy",onClick:s,children:m.jsx(g1,{className:"h-3.5 w-3.5"})}),fk(t)&&m.jsx(Yh,{title:"Edit",onClick:r,children:m.jsx(E1,{className:"h-3.5 w-3.5"})}),m.jsx(Yh,{title:"Remove",danger:!0,onClick:i,children:m.jsx(es,{className:"h-3.5 w-3.5"})})]})]}),m.jsxs("a",{href:je.docUrl(e,t.id),target:"_blank",rel:"noreferrer",className:"min-w-0",children:[m.jsx("div",{className:"truncate text-[13px] font-medium leading-snug",title:t.name,children:t.name}),m.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[o.label," · ",Q9(t.size)]})]})]})}function Yh({title:e,onClick:t,danger:r,children:i}){return m.jsx("button",{type:"button",title:e,onClick:t,className:ge("flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors",r?"hover:bg-destructive/10 hover:text-destructive":"hover:bg-accent hover:text-foreground"),children:i})}function tP({domainId:e,doc:t,onClose:r,onSaved:i}){const[o,s]=k.useState(null),[u,d]=k.useState(!1);k.useEffect(()=>{let f=!0;return s(null),je.docContent(e,t.id).then(y=>f&&s(y)).catch(()=>{f&&(Ee.error("Could not load document"),s(""))}),()=>{f=!1}},[e,t.id]);const h=async()=>{if(o!=null){d(!0);try{await je.updateDocument(e,t.id,o),Ee.success("Saved"),i(),r()}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx(Vl,{open:!0,onOpenChange:f=>!f&&r(),children:m.jsxs(Li,{className:"max-w-2xl",children:[m.jsx(Yl,{children:m.jsx(Pi,{className:"truncate text-sm",children:t.name})}),m.jsx(Ar,{autoFocus:!0,value:o??"",disabled:o==null,onChange:f=>s(f.target.value),onKeyDown:f=>{(f.metaKey||f.ctrlKey)&&f.key==="Enter"&&(f.preventDefault(),h())},placeholder:o==null?"Loading…":"",className:"min-h-[50vh] resize-none font-mono text-[12px] leading-relaxed"}),m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("span",{className:"mr-auto text-[11px] text-muted-foreground/60",children:"⌘↵ to save"}),m.jsx(Ke,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),m.jsx(Ke,{size:"sm",onClick:h,disabled:u||o==null,children:u?"Saving…":"Save"})]})]})})}function J0(e,t,r,i){const o=e.filter(s=>s.owner===t&&s.method===r);return o.find(s=>s.ownerKind===i)??o.find(s=>!("ownerKind"in s)||s.ownerKind===void 0)}function nP(e){return e==="anonymous"?{level:"public",warn:!1,icon:w1,tone:"sky",chipTone:"primary",label:"Anonymous",auth:e,authorize:"absent",blurb:"The canonical callable contract permits anonymous callers."}:e==="authenticated"?{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Authenticated",auth:e,authorize:"absent",blurb:"The canonical callable contract requires an authenticated principal."}:{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Authorized",auth:e,authorize:"custom",blurb:"The canonical callable contract requires authorization."}}function rP(e){return e==="anonymous"||e==="authenticated"||e==="authorized"}function pk(e){return!!e&&typeof e=="object"&&"method"in e&&typeof e.method=="string"}function vc(e,t){const r=pk(e),i=r?void 0:e,o=r?e:t,s=i?.auth??o?.callableAuth;if(rP(s))return nP(s);if(!o)return null;const u=o.auth??"required",d=o.authorize??"absent",h=d==="custom";return u==="public"?{level:"public",warn:!1,icon:w1,tone:"sky",chipTone:"primary",label:"Public",auth:u,authorize:d,blurb:"Public — no credential required."}:h?{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Secured",auth:u,authorize:d,blurb:"Runs an authorization check."}:u==="optional"?{level:"open",warn:!0,icon:KA,tone:"rose",chipTone:"danger",label:"Open",auth:u,authorize:d,blurb:"No authz check — even anonymous callers pass."}:{level:"insecure",warn:!0,icon:YA,tone:"amber",chipTone:"warning",label:"Unguarded",auth:u,authorize:d,blurb:"No authz check — any authenticated caller passes."}}function VP(e){let t=0;for(const r of e)(pk(r)?vc(r):vc(r?.method,r?.link))?.warn&&t++;return t}const aP={emerald:"text-emerald-400 hover:text-emerald-300",sky:"text-sky-400 hover:text-sky-300",amber:"text-amber-400 hover:text-amber-300",rose:"text-rose-400 hover:text-rose-300"};function iP({method:e,link:t,interactive:r=!0}){const i=vc(e,t);if(!i)return null;const o=i.icon,s=ge("inline-flex items-center justify-center rounded-md transition-colors",aP[i.tone]);return m.jsxs(Yp,{openDelay:80,children:[m.jsx(Qp,{asChild:!0,children:r?m.jsx("button",{type:"button","aria-label":`Authorization: ${i.label}`,className:s,children:m.jsx(o,{className:"h-3.5 w-3.5"})}):m.jsx("span",{role:"img","aria-label":`Authorization: ${i.label}`,className:s,children:m.jsx(o,{className:"h-3.5 w-3.5"})})}),m.jsx(Kc,{align:"start",className:"w-96 p-0 overflow-hidden",children:m.jsx(lP,{method:e,link:t})})]})}function lP({method:e,link:t}){const r=vc(e,t);if(!r)return null;const i=r.icon;return m.jsxs("div",{className:"text-[13px]",children:[m.jsxs("div",{className:"flex items-start gap-2.5 p-3",children:[m.jsx(Zr,{tone:r.tone,size:"sm",children:m.jsx(i,{})}),m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-semibold text-foreground",children:r.label}),r.warn&&m.jsx(nn,{tone:r.chipTone,children:"review"})]}),m.jsx("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:r.blurb})]})]}),m.jsxs("div",{className:"flex flex-wrap gap-1.5 border-t px-3 py-2",children:[m.jsxs(nn,{tone:"outline",className:"font-mono",children:["auth: ",r.auth]}),m.jsxs(nn,{tone:"outline",className:"font-mono",children:["authorize: ",r.authorize]})]}),r.authorize==="custom"&&t?.authorizeSnippet&&m.jsxs("div",{className:"border-t px-3 py-2",children:[m.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"authorize"}),m.jsx(D7,{children:t.authorizeSnippet})]})]})}function YP(e,t){const r=xc(e),i=t??r.optional;switch(r.kind){case"string":return{label:"Text",icon:uT,optional:i};case"number":case"integer":return{label:"Number",icon:S1,optional:i};case"boolean":return{label:"Yes / no",icon:iT,optional:i};case"enum":{const o=r.values.map(String);return{label:`One of: ${o.slice(0,3).join(", ")}${o.length>3?"…":""}`,icon:dA,optional:i}}case"array":return{label:"List",icon:hA,optional:i};case"object":return{label:"Object",icon:h1,optional:i};case"ref":return{label:"Reference",icon:uA,optional:i};default:return{label:"Value",icon:wN,optional:i}}}function oP(e){return e.inheritance==="sealed"?{icon:k1,tone:"amber"}:e.inheritance==="abstract"?{icon:_A,tone:"fuchsia"}:{icon:gT,tone:"violet"}}function sP(e){if(!e)return null;const t=e.split(":"),r=t.findIndex(s=>s.startsWith("class."));if(r===-1||r+1>=t.length)return null;const i=t[r].slice(6),o=t[r+1];return i&&o?{owner:i,method:o}:null}function uP(e){if(!e||typeof e!="object"||Array.isArray(e))return 0;const t=e;return(t.nodes&&typeof t.nodes=="object"&&!Array.isArray(t.nodes)?Object.keys(t.nodes).length:0)+(Array.isArray(t.edges)?t.edges.length:0)}function cP(e){const t=new Set,r=[];for(const i of e)for(const o of Array.isArray(i.viewFor)?i.viewFor:i.viewFor?[i.viewFor]:[])t.has(o)||(t.add(o),r.push(o));return r}function dP({domainId:e}){const t=jc(e),r=D1(e),i=ke(N=>N.setSection),o=ke(N=>N.focusClass),s=ke(N=>N.setPanelOverlay),u=t.data,d=r.data,h=u?.ir??null,f=k.useMemo(()=>sP(u?.overlay.postInstall),[u?.overlay.postInstall]),y=h?.format==="astrale.dsl",p=k.useMemo(()=>uP(h?.core),[h?.core]),v=k.useMemo(()=>{if(!h||!u)return[];const N=[],R=Object.entries(h.functions??{});R.length>0&&N.push({owner:h.domain,label:"Domain functions",className:null,fns:R.map(([P,H])=>({owner:h.domain,ownerKind:"function",name:P,method:H,link:J0(u.overlay.handlerLinks,h.domain,P,"function"),isSeed:!1}))});for(const P of Object.values(h.classes)){const H=Object.entries(P.methods??{});if(H.length===0)continue;const _=H.map(([q,I])=>({owner:P.name,ownerKind:"class",name:q,method:I,link:J0(u.overlay.handlerLinks,P.name,q,"class"),isSeed:!!f&&f.owner===P.name&&f.method===q}));N.push({owner:P.name,label:P.name,className:P.name,fns:_})}return N.sort((P,H)=>P.owner===f?.owner?-1:H.owner===f?.owner?1:P.className===null&&H.className!==null?-1:P.className!==null&&H.className===null?1:0)},[h,u,f]),b=v.reduce((N,R)=>N+R.fns.length,0),w=d?.views??[],C=k.useMemo(()=>cP(w),[w]),j=N=>{i("schema"),o(`class.${N}`)},E=()=>{i("schema"),s("views")};return t.isLoading||r.isLoading?m.jsx("div",{className:"flex items-center justify-center p-8 text-sm text-muted-foreground",children:"Loading…"}):m.jsx(_m,{title:"Process",subtitle:"Entrypoints and the functions they run",icon:m.jsx(em,{className:"h-5 w-5"}),children:h?m.jsxs(m.Fragment,{children:[m.jsx(V0,{label:"Entrypoints",children:m.jsxs("div",{className:"space-y-2",children:[y?p>0?m.jsxs(wr,{className:"flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3",children:[m.jsx(Zr,{tone:"emerald",children:m.jsx(Bu,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate text-sm font-semibold",children:"Core genesis"}),m.jsxs("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:[p," portable element",p===1?"":"s"," installed with the schema"]})]})]}):m.jsxs(wr,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(Bu,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"No Core genesis data declared in this schema."})]}):f?m.jsxs(wr,{onClick:()=>j(f.owner),className:"flex cursor-pointer items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3 transition-colors hover:bg-emerald-500/[0.08]",children:[m.jsx(Zr,{tone:"emerald",children:m.jsx(Bu,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"truncate text-sm font-semibold",children:[f.owner,".",f.method]}),m.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:"Seed — runs once on install"})]}),m.jsx(fb,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}):m.jsxs(wr,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(Bu,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"This legacy domain has no post-install seed Method."})]}),w.length>0&&m.jsxs(wr,{onClick:E,className:"flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[m.jsx(Zr,{tone:"sky",children:m.jsx(iA,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"text-sm font-semibold",children:[w.length," view",w.length===1?"":"s"," ",m.jsx("span",{className:"font-normal text-muted-foreground",children:"· UI entrypoints"})]}),C.length>0&&m.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[C.slice(0,8).map(N=>m.jsx(nn,{tone:"outline",children:N},N)),C.length>8&&m.jsxs(nn,{tone:"default",children:["+",C.length-8]})]})]}),m.jsx(fb,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}),m.jsxs(wr,{className:"flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(MA,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Triggers"}),m.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground/70",children:"On event · polling · cron — wired via the services domain. Not parsed yet."})]})]})]})}),b===0?m.jsx(J2,{icon:m.jsx(em,{}),title:"No functions yet",hint:"Add a standalone Function or class Method to the schema to see it here."}):m.jsx(V0,{label:"Functions",hint:`${b}`,children:m.jsx("div",{className:"space-y-3",children:v.map(N=>m.jsxs(wr,{className:"overflow-hidden",children:[m.jsxs("button",{type:"button",onClick:N.className?()=>j(N.className):void 0,className:ge("flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors",N.className&&"hover:bg-accent/40"),children:[m.jsx(Zr,{tone:"muted",size:"sm",children:N.className?m.jsx(f1,{}):m.jsx(h1,{})}),m.jsx("span",{className:"flex-1 truncate text-[13px] font-semibold",children:N.label}),m.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[N.fns.length," fn"]})]}),m.jsx("div",{className:"border-t",children:N.fns.map(R=>m.jsx(fP,{fn:R,onClick:R.ownerKind==="class"?()=>j(R.owner):void 0},R.name))})]},N.owner))})})]}):m.jsx(wr,{className:"px-4 py-3 text-sm text-muted-foreground",children:"Schema unavailable — install dependencies to see this domain’s functions."})})}function fP({fn:e,onClick:t}){const r=oP(e.method),i=r.icon,o=e.link?.kernelCalls??[],s=e.link&&!e.link.implemented;return m.jsx(W2,{onClick:t,className:"px-3 py-2 border-t first:border-t-0 rounded-none",leading:m.jsx(Zr,{tone:r.tone,size:"sm",children:m.jsx(i,{})}),title:m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"font-semibold",children:e.name}),m.jsx(iP,{method:e.method,link:e.link,interactive:!t}),e.ownerKind==="function"&&m.jsx(nn,{tone:"primary",children:"function"}),e.isSeed&&m.jsx(nn,{tone:"success",children:"seed"}),e.method.static&&m.jsx(nn,{tone:"default",children:"static"}),e.method.inheritance==="abstract"&&m.jsx(nn,{tone:"fuchsia",children:"contract"}),s&&m.jsx(nn,{tone:"warning",children:"needs handler"}),e.link?.unlinked&&m.jsx(nn,{tone:"default",children:"unlinked"})]}),trailing:o.length>0?m.jsxs("div",{className:"hidden items-center gap-1 sm:flex",children:[o.slice(0,3).map(u=>m.jsx(nn,{tone:"outline",className:"font-mono",children:u},u)),o.length>3&&m.jsxs(nn,{tone:"default",children:["+",o.length-3]})]}):void 0})}const hP=k.lazy(()=>Jj(async()=>{const{SchemaSection:e}=await import("./index-B-c-smo9.js");return{SchemaSection:e}},__vite__mapDeps([0,1])).then(({SchemaSection:e})=>({default:e}))),mP=[{key:"context",label:"Context",icon:oA},{key:"schema",label:"Schema",icon:C1},{key:"process",label:"Process",icon:em},{key:"comments",label:"Comments",icon:Ei}];function pP({section:e,domainId:t}){switch(e){case"schema":return m.jsx(k.Suspense,{fallback:m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading schema studio…"}),children:m.jsx(hP,{domainId:t})});case"context":return m.jsx(Z9,{domainId:t});case"process":return m.jsx(dP,{domainId:t});case"comments":return m.jsx($9,{domainId:t})}}function gP(){const{data:e}=R1(),t=ke(N=>N.domainId),r=ke(N=>N.section),i=ke(N=>N.setDomain),o=ke(N=>N.setSection),s=ke(N=>N.setPaletteOpen),u=ke(N=>N.setSettingsOpen),d=ke(N=>N.commentMode),h=ke(N=>N.toggleCommentMode),f=ke(N=>N.toggleAskMode),y=PT(),p=Wr(N=>N.setRun),v=Wr(N=>N.appendEvent),b=Bt();k.useEffect(()=>{if(!t&&e&&e.length){let N=null;try{N=localStorage.getItem("studio.lastDomain")}catch{}i(N&&e.some(R=>R.id===N)?N:e[0].id)}},[e,t,i]);const w=k.useCallback(N=>{if(N.type==="hello"){const R=ke.getState().domainId;R&&(y(R),b.invalidateQueries({queryKey:Se.agent(R)}));return}if(N.type==="workspace"){b.invalidateQueries({queryKey:Se.workspace});return}if(N.type==="agent-event"){v(N.domainId,N.runId,N.event);return}if(N.type==="agent-run"){p(N.run),b.invalidateQueries({queryKey:Se.agent(N.domainId)});return}if(N.type==="schema-diff"){y(N.domainId),b.invalidateQueries({queryKey:Se.workspace});return}"domainId"in N&&N.domainId&&y(N.domainId)},[y,p,v,b]);B9(w);const{data:C}=hs(t);k.useEffect(()=>{C?.run&&p(C.run)},[C,p]),k.useEffect(()=>{const N=R=>{const P=R.target;P&&(P.tagName==="INPUT"||P.tagName==="TEXTAREA"||P.isContentEditable)||R.metaKey||R.ctrlKey||R.altKey||(R.key==="c"||R.key==="C"?(R.preventDefault(),h()):(R.key==="a"||R.key==="A")&&(R.preventDefault(),f()))};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,f]);const{data:j}=Nc(t),E=j?.comments.filter(N=>N.status==="open"&&N.thread.at(-1)?.role==="author").length??0;return e?m.jsxs(e8,{delayDuration:200,children:[m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("header",{className:"flex items-center gap-3 px-5 h-14 border-b shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(p9,{}),m.jsx(l9,{}),t&&m.jsx(h9,{domainId:t}),t&&m.jsx("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>u(!0),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/40 transition-colors hover:bg-accent/60 hover:text-foreground",children:m.jsx(j1,{className:"h-4 w-4"})}),t&&m.jsx(U9,{domainId:t}),t&&m.jsx(s9,{domainId:t})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[m.jsxs(Ke,{variant:"ghost",size:"sm",onClick:()=>s(!0),title:"Search (⌘K)",children:[m.jsx(BA,{className:"h-4 w-4"}),m.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"⌘K"})]}),m.jsxs(Ke,{variant:d?"default":"ghost",size:"sm","aria-label":"Comment mode",onClick:()=>h(),title:"Comment mode — click any element to comment (C)",children:[m.jsx(bA,{className:"h-4 w-4"}),m.jsx("kbd",{className:ge("rounded px-1.5 py-0.5 text-[10px]",d?"bg-primary-foreground/20 text-primary-foreground":"bg-muted text-muted-foreground"),children:"C"})]}),m.jsx("div",{className:"h-5 w-px bg-border mx-0.5"}),m.jsx(l8,{})]})]}),m.jsxs("main",{className:"flex-1 min-h-0 relative overflow-hidden",children:[t?m.jsx(pP,{section:r,domainId:t}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No domain selected"}),m.jsx("nav",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-40",children:m.jsx("div",{className:"flex items-center gap-1 rounded-2xl border bg-card/70 px-2 py-2 shadow-2xl shadow-black/40 backdrop-blur-xl",children:mP.map(N=>{const R=N.icon,P=r===N.key,H=N.key==="comments"?E:0;return m.jsxs(t8,{children:[m.jsx(n8,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":N.label,"aria-current":P?"page":void 0,onClick:()=>o(N.key),className:ge("relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150",P?"bg-primary/15 text-primary":"text-muted-foreground hover:-translate-y-1 hover:bg-accent hover:text-foreground"),children:[m.jsx(R,{className:"h-[19px] w-[19px]"}),H>0&&m.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-primary-foreground",children:H>99?"99+":H}),P&&m.jsx("span",{className:"absolute -bottom-0.5 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full bg-primary"})]})}),m.jsx(M2,{side:"top",sideOffset:10,children:N.label})]},N.key)})})})]})]}),m.jsx(m7,{}),m.jsx(t9,{}),m.jsx(X7,{}),m.jsx(P8,{}),m.jsx(f8,{}),m.jsx(H9,{})]}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Connecting to studio…"})}const yP=new tj({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});bj.createRoot(document.getElementById("root")).render(m.jsx(k.StrictMode,{children:m.jsxs(rj,{client:yP,children:[m.jsx(gP,{}),m.jsx(Xj,{theme:"dark",position:"bottom-right",richColors:!0,closeButton:!0})]})}));export{BA as $,f1 as A,Ke as B,cN as C,p7 as D,mN as E,Sc as F,tc as G,O1 as H,SP as I,je as J,Vl as K,Li as L,Ei as M,C1 as N,Pi as O,Ui as P,GE as Q,de as R,Bl as S,rk as T,TN as U,LA as V,aa as W,dn as X,Vc as Y,m1 as Z,Jj as _,aj as a,jT as a$,jc as a0,zp as a1,kc as a2,J2 as a3,aN as a4,V0 as a5,bP as a6,Zr as a7,OA as a8,IP as a9,kP as aA,jA as aB,qP as aC,d7 as aD,vP as aE,VP as aF,PP as aG,zP as aH,DP as aI,K2 as aJ,Nc as aK,JL as aL,x1 as aM,v1 as aN,ms as aO,Ee as aP,Se as aQ,c7 as aR,f7 as aS,LP as aT,gT as aU,D1 as aV,CP as aW,jP as aX,es as aY,$h as aZ,MP as a_,DN as aa,w1 as ab,_P as ac,s7 as ad,YP as ae,xc as af,W2 as ag,Yp as ah,Qp as ai,Kc as aj,_7 as ak,uk as al,nn as am,J0 as an,oP as ao,wr as ap,iP as aq,UP as ar,fb as as,vN as at,$P as au,$A as av,rA as aw,T1 as ax,FP as ay,wP as az,oj as b,R1 as b0,EP as b1,k as c,sj as d,dj as e,uj as f,sn as g,hj as h,tb as i,cj as j,pe as k,Bm as l,bc as m,Ut as n,m as o,wc as p,lk as q,t1 as r,lc as s,ke as t,Bt as u,Hp as v,ge as w,Ga as x,u7 as y,WA as z};
|
|
81
|
+
`).map(t=>t.replace(/^#+\s*/,"").trim()).find(Boolean)??"").slice(0,60));function Z9({domainId:e}){const{data:t}=LT(e),r=Bt(),i=()=>r.invalidateQueries({queryKey:Se.documents(e)}),[o,s]=k.useState(!1),[u,d]=k.useState(null),h=un({mutationFn:w=>je.uploadDocuments(e,w),onSuccess:w=>{i(),Ee.success(`Added ${w.length} document${w.length===1?"":"s"}`)},onError:w=>Ee.error(String(w))}),f=un({mutationFn:w=>je.deleteDocument(e,w),onSuccess:i}),y=w=>{const C=w?[...w]:[];C.length&&h.mutate(C)},p=(w,C)=>h.mutate([new File([w],C?hk(C):X9(w),{type:"text/markdown"})]),v=w=>{const C=w.dataTransfer.files;if(C?.length){w.preventDefault(),s(!1),y(C);return}if(s(!1),w.target.closest("textarea, input"))return;const j=w.dataTransfer.getData("text/plain");j.trim()&&(w.preventDefault(),p(j))};if(!t)return m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading…"});const b=t.length;return m.jsxs("div",{className:"relative h-full",onDragOver:w=>{Array.from(w.dataTransfer.types).includes("Files")&&(w.preventDefault(),s(!0))},onDragLeave:w=>{w.currentTarget.contains(w.relatedTarget)||s(!1)},onDrop:v,children:[m.jsx("div",{className:"h-full overflow-y-auto",children:m.jsxs("div",{className:"mx-auto w-full max-w-3xl space-y-6 px-6 pb-28 pt-10",children:[m.jsx(W9,{domainId:e}),b===0?m.jsxs("div",{className:"space-y-4",children:[m.jsx(W0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx(J9,{busy:h.isPending,onFiles:y})]}):m.jsxs("div",{className:"space-y-6",children:[m.jsx(W0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(w=>m.jsx(eP,{domainId:e,doc:w,onEdit:()=>d(w),onDelete:()=>f.mutate(w.id)},w.id))})]})]})}),o&&m.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-2xl border-2 border-dashed border-primary/60 px-16 py-12 text-primary",children:[m.jsx(Fm,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm font-medium",children:"Drop to add"})]})}),u&&m.jsx(tP,{domainId:e,doc:u,onClose:()=>d(null),onSaved:i})]})}function mk({expanded:e,onClick:t}){const r=e?SA:yA,i=e?"Collapse editor":"Expand editor";return m.jsx("button",{type:"button",title:i,"aria-label":i,onClick:t,className:"absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:m.jsx(r,{className:"h-3.5 w-3.5"})})}function W9({domainId:e}){const[t,r]=k.useState(""),[i,o]=k.useState(!1),[s,u]=k.useState(!1),d=hs(e),h=$m(e),f=Wr(C=>C.setRun),y=Bt(),p=Ec(h),v=d.data?.available??!1,b=t.trim().length>0&&!s&&!p&&v,w=async()=>{if(b){u(!0);try{const C=await je.agentSubmit(e,t.trim());if(C.error){Ee.error(C.error);return}f(C),r(""),Ee.success("Sent to the agent")}catch(C){Ee.error(String(C))}finally{u(!1),y.invalidateQueries({queryKey:Se.agent(e)})}}};return m.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Ar,{autoFocus:!0,value:t,onChange:C=>r(C.target.value),onKeyDown:C=>{(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),w())},placeholder:"Tell me what you want to do?",className:ge("max-h-[65vh] min-h-[120px] resize-y border-0 bg-transparent pr-10 text-[15px] leading-relaxed shadow-none focus-visible:ring-0",i&&"min-h-[45vh]")}),m.jsx(mk,{expanded:i,onClick:()=>o(C=>!C)})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 border-t px-3 py-2",children:[m.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:p?"Agent working…":v?"⌘↵ to send":"agent unavailable"}),m.jsxs(Ke,{size:"sm",onClick:w,disabled:!b,children:[s||p?m.jsx(dn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Im,{className:"h-3.5 w-3.5"})," ","Send to agent"]})]})]})}function W0({hero:e,busy:t,onText:r,onFiles:i}){const[o,s]=k.useState(""),[u,d]=k.useState(!1),h=k.useRef(null),f=()=>{!o.trim()||t||(r(o),s(""))};return m.jsxs("div",{className:"rounded-2xl border bg-card/50 shadow-sm transition-colors focus-within:border-primary/50",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Ar,{autoFocus:e,value:o,onChange:y=>s(y.target.value),onKeyDown:y=>{(y.metaKey||y.ctrlKey)&&y.key==="Enter"&&(y.preventDefault(),f())},placeholder:e?"Paste anything — notes, specs, decisions…":"Paste text to save as markdown…",className:ge("max-h-[65vh] resize-y border-0 bg-transparent pr-10 leading-relaxed shadow-none focus-visible:ring-0",u?e?"min-h-[45vh] text-[15px]":"min-h-[32vh]":e?"min-h-[180px] text-[15px]":"min-h-[80px]")}),m.jsx(mk,{expanded:u,onClick:()=>d(y=>!y)})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2 border-t px-3 py-2",children:[e?m.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"⌘↵ to save"}):m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",onClick:()=>h.current?.click(),className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[m.jsx(Fm,{className:"h-4 w-4"})," ",t?"Uploading…":"Upload"]}),m.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:y=>{i(y.target.files),y.target.value=""}})]}),o.trim()&&m.jsxs(Ke,{size:"sm",onClick:f,disabled:t,children:[m.jsx(y1,{className:"h-3.5 w-3.5"})," Save"]})]})]})}function J9({busy:e,onFiles:t}){const r=k.useRef(null);return m.jsxs("button",{type:"button",onClick:()=>r.current?.click(),className:"flex w-full flex-col items-center justify-center gap-2 rounded-2xl border border-dashed py-10 text-muted-foreground transition-colors hover:border-muted-foreground/40 hover:bg-accent/20",children:[m.jsx(Fm,{className:"h-6 w-6"}),m.jsx("p",{className:"text-[13px]",children:e?"Uploading…":"Drop files or browse"}),m.jsx("input",{ref:r,type:"file",multiple:!0,className:"hidden",onChange:i=>{t(i.target.files),i.target.value=""}})]})}function eP({domainId:e,doc:t,onEdit:r,onDelete:i}){const o=G9(t),s=async()=>{try{await navigator.clipboard.writeText(await je.docContent(e,t.id)),Ee.success("Copied")}catch{Ee.error("Copy failed")}};return m.jsxs("div",{className:"group flex flex-col gap-2.5 rounded-xl border bg-card/50 p-3 transition-colors hover:border-muted-foreground/30 hover:bg-accent/30",children:[m.jsxs("div",{className:"flex items-start justify-between",children:[m.jsx("div",{className:ge("flex h-9 w-9 items-center justify-center rounded-lg",o.tint),children:m.jsx(o.Icon,{className:"h-[18px] w-[18px]"})}),m.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[K9(t)&&m.jsx(Yh,{title:"Copy",onClick:s,children:m.jsx(g1,{className:"h-3.5 w-3.5"})}),fk(t)&&m.jsx(Yh,{title:"Edit",onClick:r,children:m.jsx(E1,{className:"h-3.5 w-3.5"})}),m.jsx(Yh,{title:"Remove",danger:!0,onClick:i,children:m.jsx(es,{className:"h-3.5 w-3.5"})})]})]}),m.jsxs("a",{href:je.docUrl(e,t.id),target:"_blank",rel:"noreferrer",className:"min-w-0",children:[m.jsx("div",{className:"truncate text-[13px] font-medium leading-snug",title:t.name,children:t.name}),m.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[o.label," · ",Q9(t.size)]})]})]})}function Yh({title:e,onClick:t,danger:r,children:i}){return m.jsx("button",{type:"button",title:e,onClick:t,className:ge("flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/60 transition-colors",r?"hover:bg-destructive/10 hover:text-destructive":"hover:bg-accent hover:text-foreground"),children:i})}function tP({domainId:e,doc:t,onClose:r,onSaved:i}){const[o,s]=k.useState(null),[u,d]=k.useState(!1);k.useEffect(()=>{let f=!0;return s(null),je.docContent(e,t.id).then(y=>f&&s(y)).catch(()=>{f&&(Ee.error("Could not load document"),s(""))}),()=>{f=!1}},[e,t.id]);const h=async()=>{if(o!=null){d(!0);try{await je.updateDocument(e,t.id,o),Ee.success("Saved"),i(),r()}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx(Vl,{open:!0,onOpenChange:f=>!f&&r(),children:m.jsxs(Li,{className:"max-w-2xl",children:[m.jsx(Yl,{children:m.jsx(Pi,{className:"truncate text-sm",children:t.name})}),m.jsx(Ar,{autoFocus:!0,value:o??"",disabled:o==null,onChange:f=>s(f.target.value),onKeyDown:f=>{(f.metaKey||f.ctrlKey)&&f.key==="Enter"&&(f.preventDefault(),h())},placeholder:o==null?"Loading…":"",className:"min-h-[50vh] resize-none font-mono text-[12px] leading-relaxed"}),m.jsxs("div",{className:"flex items-center justify-end gap-2",children:[m.jsx("span",{className:"mr-auto text-[11px] text-muted-foreground/60",children:"⌘↵ to save"}),m.jsx(Ke,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),m.jsx(Ke,{size:"sm",onClick:h,disabled:u||o==null,children:u?"Saving…":"Save"})]})]})})}function J0(e,t,r,i){const o=e.filter(s=>s.owner===t&&s.method===r);return o.find(s=>s.ownerKind===i)??o.find(s=>!("ownerKind"in s)||s.ownerKind===void 0)}function nP(e){return e==="anonymous"?{level:"public",warn:!1,icon:w1,tone:"sky",chipTone:"primary",label:"Anonymous",auth:e,authorize:"absent",blurb:"The canonical callable contract permits anonymous callers."}:e==="authenticated"?{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Authenticated",auth:e,authorize:"absent",blurb:"The canonical callable contract requires an authenticated principal."}:{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Authorized",auth:e,authorize:"custom",blurb:"The canonical callable contract requires authorization."}}function rP(e){return e==="anonymous"||e==="authenticated"||e==="authorized"}function pk(e){return!!e&&typeof e=="object"&&"method"in e&&typeof e.method=="string"}function vc(e,t){const r=pk(e),i=r?void 0:e,o=r?e:t,s=i?.auth??o?.callableAuth;if(rP(s))return nP(s);if(!o)return null;const u=o.auth??"required",d=o.authorize??"absent",h=d==="custom";return u==="public"?{level:"public",warn:!1,icon:w1,tone:"sky",chipTone:"primary",label:"Public",auth:u,authorize:d,blurb:"Public — no credential required."}:h?{level:"secured",warn:!1,icon:Jh,tone:"emerald",chipTone:"success",label:"Secured",auth:u,authorize:d,blurb:"Runs an authorization check."}:u==="optional"?{level:"open",warn:!0,icon:KA,tone:"rose",chipTone:"danger",label:"Open",auth:u,authorize:d,blurb:"No authz check — even anonymous callers pass."}:{level:"insecure",warn:!0,icon:YA,tone:"amber",chipTone:"warning",label:"Unguarded",auth:u,authorize:d,blurb:"No authz check — any authenticated caller passes."}}function VP(e){let t=0;for(const r of e)(pk(r)?vc(r):vc(r?.method,r?.link))?.warn&&t++;return t}const aP={emerald:"text-emerald-400 hover:text-emerald-300",sky:"text-sky-400 hover:text-sky-300",amber:"text-amber-400 hover:text-amber-300",rose:"text-rose-400 hover:text-rose-300"};function iP({method:e,link:t,interactive:r=!0}){const i=vc(e,t);if(!i)return null;const o=i.icon,s=ge("inline-flex items-center justify-center rounded-md transition-colors",aP[i.tone]);return m.jsxs(Yp,{openDelay:80,children:[m.jsx(Qp,{asChild:!0,children:r?m.jsx("button",{type:"button","aria-label":`Authorization: ${i.label}`,className:s,children:m.jsx(o,{className:"h-3.5 w-3.5"})}):m.jsx("span",{role:"img","aria-label":`Authorization: ${i.label}`,className:s,children:m.jsx(o,{className:"h-3.5 w-3.5"})})}),m.jsx(Kc,{align:"start",className:"w-96 p-0 overflow-hidden",children:m.jsx(lP,{method:e,link:t})})]})}function lP({method:e,link:t}){const r=vc(e,t);if(!r)return null;const i=r.icon;return m.jsxs("div",{className:"text-[13px]",children:[m.jsxs("div",{className:"flex items-start gap-2.5 p-3",children:[m.jsx(Zr,{tone:r.tone,size:"sm",children:m.jsx(i,{})}),m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"font-semibold text-foreground",children:r.label}),r.warn&&m.jsx(nn,{tone:r.chipTone,children:"review"})]}),m.jsx("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:r.blurb})]})]}),m.jsxs("div",{className:"flex flex-wrap gap-1.5 border-t px-3 py-2",children:[m.jsxs(nn,{tone:"outline",className:"font-mono",children:["auth: ",r.auth]}),m.jsxs(nn,{tone:"outline",className:"font-mono",children:["authorize: ",r.authorize]})]}),r.authorize==="custom"&&t?.authorizeSnippet&&m.jsxs("div",{className:"border-t px-3 py-2",children:[m.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"authorize"}),m.jsx(D7,{children:t.authorizeSnippet})]})]})}function YP(e,t){const r=xc(e),i=t??r.optional;switch(r.kind){case"string":return{label:"Text",icon:uT,optional:i};case"number":case"integer":return{label:"Number",icon:S1,optional:i};case"boolean":return{label:"Yes / no",icon:iT,optional:i};case"enum":{const o=r.values.map(String);return{label:`One of: ${o.slice(0,3).join(", ")}${o.length>3?"…":""}`,icon:dA,optional:i}}case"array":return{label:"List",icon:hA,optional:i};case"object":return{label:"Object",icon:h1,optional:i};case"ref":return{label:"Reference",icon:uA,optional:i};default:return{label:"Value",icon:wN,optional:i}}}function oP(e){return e.inheritance==="sealed"?{icon:k1,tone:"amber"}:e.inheritance==="abstract"?{icon:_A,tone:"fuchsia"}:{icon:gT,tone:"violet"}}function sP(e){if(!e)return null;const t=e.split(":"),r=t.findIndex(s=>s.startsWith("class."));if(r===-1||r+1>=t.length)return null;const i=t[r].slice(6),o=t[r+1];return i&&o?{owner:i,method:o}:null}function uP(e){if(!e||typeof e!="object"||Array.isArray(e))return 0;const t=e;return(t.nodes&&typeof t.nodes=="object"&&!Array.isArray(t.nodes)?Object.keys(t.nodes).length:0)+(Array.isArray(t.edges)?t.edges.length:0)}function cP(e){const t=new Set,r=[];for(const i of e)for(const o of Array.isArray(i.viewFor)?i.viewFor:i.viewFor?[i.viewFor]:[])t.has(o)||(t.add(o),r.push(o));return r}function dP({domainId:e}){const t=jc(e),r=D1(e),i=ke(N=>N.setSection),o=ke(N=>N.focusClass),s=ke(N=>N.setPanelOverlay),u=t.data,d=r.data,h=u?.ir??null,f=k.useMemo(()=>sP(u?.overlay.postInstall),[u?.overlay.postInstall]),y=h?.format==="astrale.dsl",p=k.useMemo(()=>uP(h?.core),[h?.core]),v=k.useMemo(()=>{if(!h||!u)return[];const N=[],R=Object.entries(h.functions??{});R.length>0&&N.push({owner:h.domain,label:"Domain functions",className:null,fns:R.map(([P,H])=>({owner:h.domain,ownerKind:"function",name:P,method:H,link:J0(u.overlay.handlerLinks,h.domain,P,"function"),isSeed:!1}))});for(const P of Object.values(h.classes)){const H=Object.entries(P.methods??{});if(H.length===0)continue;const _=H.map(([q,I])=>({owner:P.name,ownerKind:"class",name:q,method:I,link:J0(u.overlay.handlerLinks,P.name,q,"class"),isSeed:!!f&&f.owner===P.name&&f.method===q}));N.push({owner:P.name,label:P.name,className:P.name,fns:_})}return N.sort((P,H)=>P.owner===f?.owner?-1:H.owner===f?.owner?1:P.className===null&&H.className!==null?-1:P.className!==null&&H.className===null?1:0)},[h,u,f]),b=v.reduce((N,R)=>N+R.fns.length,0),w=d?.views??[],C=k.useMemo(()=>cP(w),[w]),j=N=>{i("schema"),o(`class.${N}`)},E=()=>{i("schema"),s("views")};return t.isLoading||r.isLoading?m.jsx("div",{className:"flex items-center justify-center p-8 text-sm text-muted-foreground",children:"Loading…"}):m.jsx(_m,{title:"Process",subtitle:"Entrypoints and the functions they run",icon:m.jsx(em,{className:"h-5 w-5"}),children:h?m.jsxs(m.Fragment,{children:[m.jsx(V0,{label:"Entrypoints",children:m.jsxs("div",{className:"space-y-2",children:[y?p>0?m.jsxs(wr,{className:"flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3",children:[m.jsx(Zr,{tone:"emerald",children:m.jsx(Bu,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate text-sm font-semibold",children:"Core genesis"}),m.jsxs("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:[p," portable element",p===1?"":"s"," installed with the schema"]})]})]}):m.jsxs(wr,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(Bu,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"No Core genesis data declared in this schema."})]}):f?m.jsxs(wr,{onClick:()=>j(f.owner),className:"flex cursor-pointer items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3 transition-colors hover:bg-emerald-500/[0.08]",children:[m.jsx(Zr,{tone:"emerald",children:m.jsx(Bu,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"truncate text-sm font-semibold",children:[f.owner,".",f.method]}),m.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground",children:"Seed — runs once on install"})]}),m.jsx(fb,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}):m.jsxs(wr,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(Bu,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"This legacy domain has no post-install seed Method."})]}),w.length>0&&m.jsxs(wr,{onClick:E,className:"flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[m.jsx(Zr,{tone:"sky",children:m.jsx(iA,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"text-sm font-semibold",children:[w.length," view",w.length===1?"":"s"," ",m.jsx("span",{className:"font-normal text-muted-foreground",children:"· UI entrypoints"})]}),C.length>0&&m.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[C.slice(0,8).map(N=>m.jsx(nn,{tone:"outline",children:N},N)),C.length>8&&m.jsxs(nn,{tone:"default",children:["+",C.length-8]})]})]}),m.jsx(fb,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}),m.jsxs(wr,{className:"flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground",children:[m.jsx(Zr,{tone:"muted",children:m.jsx(MA,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Triggers"}),m.jsx("div",{className:"mt-0.5 text-[13px] text-muted-foreground/70",children:"On event · polling · cron — wired via the services domain. Not parsed yet."})]})]})]})}),b===0?m.jsx(J2,{icon:m.jsx(em,{}),title:"No functions yet",hint:"Add a standalone Function or class Method to the schema to see it here."}):m.jsx(V0,{label:"Functions",hint:`${b}`,children:m.jsx("div",{className:"space-y-3",children:v.map(N=>m.jsxs(wr,{className:"overflow-hidden",children:[m.jsxs("button",{type:"button",onClick:N.className?()=>j(N.className):void 0,className:ge("flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors",N.className&&"hover:bg-accent/40"),children:[m.jsx(Zr,{tone:"muted",size:"sm",children:N.className?m.jsx(f1,{}):m.jsx(h1,{})}),m.jsx("span",{className:"flex-1 truncate text-[13px] font-semibold",children:N.label}),m.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[N.fns.length," fn"]})]}),m.jsx("div",{className:"border-t",children:N.fns.map(R=>m.jsx(fP,{fn:R,onClick:R.ownerKind==="class"?()=>j(R.owner):void 0},R.name))})]},N.owner))})})]}):m.jsx(wr,{className:"px-4 py-3 text-sm text-muted-foreground",children:"Schema unavailable — install dependencies to see this domain’s functions."})})}function fP({fn:e,onClick:t}){const r=oP(e.method),i=r.icon,o=e.link?.kernelCalls??[],s=e.link&&!e.link.implemented;return m.jsx(W2,{onClick:t,className:"px-3 py-2 border-t first:border-t-0 rounded-none",leading:m.jsx(Zr,{tone:r.tone,size:"sm",children:m.jsx(i,{})}),title:m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"font-semibold",children:e.name}),m.jsx(iP,{method:e.method,link:e.link,interactive:!t}),e.ownerKind==="function"&&m.jsx(nn,{tone:"primary",children:"function"}),e.isSeed&&m.jsx(nn,{tone:"success",children:"seed"}),e.method.static&&m.jsx(nn,{tone:"default",children:"static"}),e.method.inheritance==="abstract"&&m.jsx(nn,{tone:"fuchsia",children:"contract"}),s&&m.jsx(nn,{tone:"warning",children:"needs handler"}),e.link?.unlinked&&m.jsx(nn,{tone:"default",children:"unlinked"})]}),trailing:o.length>0?m.jsxs("div",{className:"hidden items-center gap-1 sm:flex",children:[o.slice(0,3).map(u=>m.jsx(nn,{tone:"outline",className:"font-mono",children:u},u)),o.length>3&&m.jsxs(nn,{tone:"default",children:["+",o.length-3]})]}):void 0})}const hP=k.lazy(()=>Jj(async()=>{const{SchemaSection:e}=await import("./index-CzpmJD0j.js");return{SchemaSection:e}},__vite__mapDeps([0,1])).then(({SchemaSection:e})=>({default:e}))),mP=[{key:"context",label:"Context",icon:oA},{key:"schema",label:"Schema",icon:C1},{key:"process",label:"Process",icon:em},{key:"comments",label:"Comments",icon:Ei}];function pP({section:e,domainId:t}){switch(e){case"schema":return m.jsx(k.Suspense,{fallback:m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading schema studio…"}),children:m.jsx(hP,{domainId:t})});case"context":return m.jsx(Z9,{domainId:t});case"process":return m.jsx(dP,{domainId:t});case"comments":return m.jsx($9,{domainId:t})}}function gP(){const{data:e}=R1(),t=ke(N=>N.domainId),r=ke(N=>N.section),i=ke(N=>N.setDomain),o=ke(N=>N.setSection),s=ke(N=>N.setPaletteOpen),u=ke(N=>N.setSettingsOpen),d=ke(N=>N.commentMode),h=ke(N=>N.toggleCommentMode),f=ke(N=>N.toggleAskMode),y=PT(),p=Wr(N=>N.setRun),v=Wr(N=>N.appendEvent),b=Bt();k.useEffect(()=>{if(!t&&e&&e.length){let N=null;try{N=localStorage.getItem("studio.lastDomain")}catch{}i(N&&e.some(R=>R.id===N)?N:e[0].id)}},[e,t,i]);const w=k.useCallback(N=>{if(N.type==="hello"){const R=ke.getState().domainId;R&&(y(R),b.invalidateQueries({queryKey:Se.agent(R)}));return}if(N.type==="workspace"){b.invalidateQueries({queryKey:Se.workspace});return}if(N.type==="agent-event"){v(N.domainId,N.runId,N.event);return}if(N.type==="agent-run"){p(N.run),b.invalidateQueries({queryKey:Se.agent(N.domainId)});return}if(N.type==="schema-diff"){y(N.domainId),b.invalidateQueries({queryKey:Se.workspace});return}"domainId"in N&&N.domainId&&y(N.domainId)},[y,p,v,b]);B9(w);const{data:C}=hs(t);k.useEffect(()=>{C?.run&&p(C.run)},[C,p]),k.useEffect(()=>{const N=R=>{const P=R.target;P&&(P.tagName==="INPUT"||P.tagName==="TEXTAREA"||P.isContentEditable)||R.metaKey||R.ctrlKey||R.altKey||(R.key==="c"||R.key==="C"?(R.preventDefault(),h()):(R.key==="a"||R.key==="A")&&(R.preventDefault(),f()))};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,f]);const{data:j}=Nc(t),E=j?.comments.filter(N=>N.status==="open"&&N.thread.at(-1)?.role==="author").length??0;return e?m.jsxs(e8,{delayDuration:200,children:[m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("header",{className:"flex items-center gap-3 px-5 h-14 border-b shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(p9,{}),m.jsx(l9,{}),t&&m.jsx(h9,{domainId:t}),t&&m.jsx("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>u(!0),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/40 transition-colors hover:bg-accent/60 hover:text-foreground",children:m.jsx(j1,{className:"h-4 w-4"})}),t&&m.jsx(U9,{domainId:t}),t&&m.jsx(s9,{domainId:t})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[m.jsxs(Ke,{variant:"ghost",size:"sm",onClick:()=>s(!0),title:"Search (⌘K)",children:[m.jsx(BA,{className:"h-4 w-4"}),m.jsx("kbd",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"⌘K"})]}),m.jsxs(Ke,{variant:d?"default":"ghost",size:"sm","aria-label":"Comment mode",onClick:()=>h(),title:"Comment mode — click any element to comment (C)",children:[m.jsx(bA,{className:"h-4 w-4"}),m.jsx("kbd",{className:ge("rounded px-1.5 py-0.5 text-[10px]",d?"bg-primary-foreground/20 text-primary-foreground":"bg-muted text-muted-foreground"),children:"C"})]}),m.jsx("div",{className:"h-5 w-px bg-border mx-0.5"}),m.jsx(l8,{})]})]}),m.jsxs("main",{className:"flex-1 min-h-0 relative overflow-hidden",children:[t?m.jsx(pP,{section:r,domainId:t}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No domain selected"}),m.jsx("nav",{className:"absolute bottom-5 left-1/2 -translate-x-1/2 z-40",children:m.jsx("div",{className:"flex items-center gap-1 rounded-2xl border bg-card/70 px-2 py-2 shadow-2xl shadow-black/40 backdrop-blur-xl",children:mP.map(N=>{const R=N.icon,P=r===N.key,H=N.key==="comments"?E:0;return m.jsxs(t8,{children:[m.jsx(n8,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":N.label,"aria-current":P?"page":void 0,onClick:()=>o(N.key),className:ge("relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150",P?"bg-primary/15 text-primary":"text-muted-foreground hover:-translate-y-1 hover:bg-accent hover:text-foreground"),children:[m.jsx(R,{className:"h-[19px] w-[19px]"}),H>0&&m.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-semibold leading-none text-primary-foreground",children:H>99?"99+":H}),P&&m.jsx("span",{className:"absolute -bottom-0.5 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full bg-primary"})]})}),m.jsx(M2,{side:"top",sideOffset:10,children:N.label})]},N.key)})})})]})]}),m.jsx(m7,{}),m.jsx(t9,{}),m.jsx(X7,{}),m.jsx(P8,{}),m.jsx(f8,{}),m.jsx(H9,{})]}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Connecting to studio…"})}const yP=new tj({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});bj.createRoot(document.getElementById("root")).render(m.jsx(k.StrictMode,{children:m.jsxs(rj,{client:yP,children:[m.jsx(gP,{}),m.jsx(Xj,{theme:"dark",position:"bottom-right",richColors:!0,closeButton:!0})]})}));export{BA as $,f1 as A,Ke as B,cN as C,p7 as D,mN as E,Sc as F,tc as G,O1 as H,SP as I,je as J,Vl as K,Li as L,Ei as M,C1 as N,Pi as O,Ui as P,GE as Q,de as R,Bl as S,rk as T,TN as U,LA as V,aa as W,dn as X,Vc as Y,m1 as Z,Jj as _,aj as a,jT as a$,jc as a0,zp as a1,kc as a2,J2 as a3,aN as a4,V0 as a5,bP as a6,Zr as a7,OA as a8,IP as a9,kP as aA,jA as aB,qP as aC,d7 as aD,vP as aE,VP as aF,PP as aG,zP as aH,DP as aI,K2 as aJ,Nc as aK,JL as aL,x1 as aM,v1 as aN,ms as aO,Ee as aP,Se as aQ,c7 as aR,f7 as aS,LP as aT,gT as aU,D1 as aV,CP as aW,jP as aX,es as aY,$h as aZ,MP as a_,DN as aa,w1 as ab,_P as ac,s7 as ad,YP as ae,xc as af,W2 as ag,Yp as ah,Qp as ai,Kc as aj,_7 as ak,uk as al,nn as am,J0 as an,oP as ao,wr as ap,iP as aq,UP as ar,fb as as,vN as at,$P as au,$A as av,rA as aw,T1 as ax,FP as ay,wP as az,oj as b,R1 as b0,EP as b1,k as c,sj as d,dj as e,uj as f,sn as g,hj as h,tb as i,cj as j,pe as k,Bm as l,bc as m,Ut as n,m as o,wc as p,lk as q,t1 as r,lc as s,ke as t,Bt as u,Hp as v,ge as w,Ga as x,u7 as y,WA as z};
|