@astrale-os/cli 1.0.0-beta.7 → 1.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/dist/astrale.js +1531 -1356
  3. package/dist/public/connect-core.js +4 -4
  4. package/dist/types/admin/binding.d.ts +19 -0
  5. package/dist/types/admin/instance/client.d.ts +22 -0
  6. package/dist/types/admin/instance/index.d.ts +2 -0
  7. package/dist/types/admin/instance/model.d.ts +3 -9
  8. package/dist/types/connection/auth.d.ts +3 -0
  9. package/dist/types/connection/call.d.ts +3 -0
  10. package/dist/types/connection/command.d.ts +27 -0
  11. package/dist/types/connection/credential.d.ts +14 -0
  12. package/dist/types/connection/errors.d.ts +1 -0
  13. package/dist/types/connection/exchange.d.ts +9 -0
  14. package/dist/types/connection/failure/classify.d.ts +2 -0
  15. package/dist/types/connection/failure/index.d.ts +5 -0
  16. package/dist/types/connection/failure/model.d.ts +25 -0
  17. package/dist/types/connection/failure/render.d.ts +3 -0
  18. package/dist/types/connection/index.d.ts +8 -0
  19. package/dist/types/connection/reasons.d.ts +37 -0
  20. package/dist/types/connection/self.d.ts +37 -0
  21. package/dist/types/connection/session.d.ts +31 -0
  22. package/dist/types/connection/target.d.ts +38 -0
  23. package/dist/types/lib/admin-instance.d.ts +17 -0
  24. package/dist/types/lib/failure-debug.d.ts +1 -0
  25. package/dist/types/lib/instance.d.ts +7 -1
  26. package/dist/types/lib/log.d.ts +3 -1
  27. package/dist/types/lib/self.d.ts +9 -0
  28. package/package.json +1 -1
  29. package/src/admin/instance/__tests__/client.test.ts +4 -104
  30. package/src/admin/instance/client.ts +2 -96
  31. package/src/admin/instance/index.ts +1 -2
  32. package/src/admin/instance/model.ts +4 -14
  33. package/src/commands/__tests__/admin-instance.test.ts +11 -8
  34. package/src/commands/__tests__/instance-list-rows.test.ts +1 -1
  35. package/src/commands/call-describe.ts +1 -1
  36. package/src/commands/call.ts +2 -2
  37. package/src/commands/domain/list.ts +1 -1
  38. package/src/commands/domain/publish.ts +14 -11
  39. package/src/commands/get.ts +1 -1
  40. package/src/commands/instance/create.ts +8 -16
  41. package/src/commands/instance/delete.ts +7 -6
  42. package/src/commands/instance/list.ts +2 -2
  43. package/src/commands/instance/status.ts +4 -4
  44. package/src/commands/instance/use.ts +16 -12
  45. package/src/commands/introspect.ts +5 -5
  46. package/src/commands/view.ts +3 -3
  47. package/src/connection/__tests__/credential.test.ts +19 -0
  48. package/src/connection/__tests__/target.test.ts +1 -0
  49. package/src/connection/auth.ts +13 -0
  50. package/src/connection/failure/index.ts +1 -1
  51. package/src/connection/session.ts +12 -1
  52. package/src/lib/__tests__/command-dx.test.ts +1 -1
  53. package/src/lib/__tests__/domain-publication.test.ts +6 -1
  54. package/src/lib/__tests__/instance-candidates.test.ts +1 -3
  55. package/src/lib/__tests__/instance-target.test.ts +1 -0
  56. package/src/lib/__tests__/log-errors.test.ts +11 -0
  57. package/src/lib/admin-instance.ts +14 -8
  58. package/src/lib/command-dx.ts +8 -5
  59. package/src/lib/domain-publication.ts +8 -6
  60. package/src/lib/instance-candidates.ts +2 -2
  61. package/src/lib/instance.ts +14 -10
  62. package/src/lib/log.ts +6 -4
  63. package/src/lib/provision-instance.ts +34 -57
  64. package/src/program/__tests__/program.test.ts +20 -4
  65. package/src/program/build.ts +2 -2
  66. package/src/setup/__tests__/instance-step.test.ts +27 -10
  67. package/src/setup/steps/instance.ts +22 -15
  68. package/studio/client/dist/assets/{elk-api-Di4OXGNH.js → elk-api-ByzoDZWH.js} +1 -1
  69. package/studio/client/dist/assets/{index-DTjvkOUX.js → index-B0RCgUOT.js} +4 -4
  70. package/studio/client/dist/assets/{index-BLm6J11H.js → index-N8J8EKlB.js} +2 -2
  71. package/studio/client/dist/index.html +1 -1
  72. package/studio/server/introspect/runtime.test.ts +2 -2
  73. package/viewer/dist/main.js +28 -28
  74. package/src/commands/__tests__/instance-create-hosts.test.ts +0 -29
  75. /package/src/{connection/failure/debug.ts → lib/failure-debug.ts} +0 -0
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DTjvkOUX.js","assets/index-ChOr3yP0.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B0RCgUOT.js","assets/index-ChOr3yP0.css"])))=>i.map(i=>d[i]);
2
2
  function yE(e,n){for(var r=0;r<n.length;r++){const i=n[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 n=document.createElement("link").relList;if(n&&n.supports&&n.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 gc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rh={exports:{}},Bo={};var Pv;function xE(){if(Pv)return Bo;Pv=1;var e=Symbol.for("react.transitional.element"),n=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 Bo.Fragment=n,Bo.jsx=r,Bo.jsxs=r,Bo}var Hv;function vE(){return Hv||(Hv=1,rh.exports=xE()),rh.exports}var m=vE(),ah={exports:{}},De={};var Uv;function bE(){if(Uv)return De;Uv=1;var e=Symbol.for("react.transitional.element"),n=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,E={};function j(M,z,T){this.props=M,this.context=z,this.refs=E,this.updater=T||w}j.prototype.isReactComponent={},j.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")},j.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function A(){}A.prototype=j.prototype;function R(M,z,T){this.props=M,this.context=z,this.refs=E,this.updater=T||w}var B=R.prototype=new A;B.constructor=R,C(B,j.prototype),B.isPureReactComponent=!0;var P=Array.isArray;function _(){}var q={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function oe(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 oe(M.type,z,M.props)}function ne(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function Q(M){var z={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(T){return z[T]})}var fe=/\/+/g;function le(M,z){return typeof M=="object"&&M!==null&&M.key!=null?Q(""+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 n: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===""?"."+le(M,0):G,P(K)?(T="",me!=null&&(T=me.replace(fe,"$&/")+"/"),L(K,z,T,"",function(tt){return tt})):K!=null&&(ne(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(P(M))for(var ue=0;ue<M.length;ue++)G=M[ue],J=Ne+le(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+le(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 ie(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(!ne(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=j,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 oe(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 oe(M,J,K)},De.createRef=function(){return{current:null}},De.forwardRef=function(M){return{$$typeof:d,render:M}},De.isValidElement=ne,De.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:ie}},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 Bv;function Om(){return Bv||(Bv=1,ah.exports=bE()),ah.exports}var k=Om();const de=gc(k),cs=yE({__proto__:null,default:de},[k]),K0=k.createContext(void 0),Bt=e=>{const n=k.useContext(K0);if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},wE=({client:e,children:n})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(K0.Provider,{value:e,children:n})),SE={setTimeout:(e,n)=>setTimeout(e,n),clearTimeout:e=>clearTimeout(e),setInterval:(e,n)=>setInterval(e,n),clearInterval:e=>clearInterval(e)};var kE=class{#e=SE;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,n){return this.#e.setTimeout(e,n)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,n){return this.#e.setInterval(e,n)}clearInterval(e){this.#e.clearInterval(e)}};const ki=new kE;function CE(e){setTimeout(e,0)}const EE=typeof window>"u"||"Deno"in globalThis;function on(){}function jE(e,n){return typeof e=="function"?e(n):e}function Fh(e){return typeof e=="number"&&e>=0&&e!==1/0}function X0(e,n){return Math.max(e+(n||0)-Date.now(),0)}function Xr(e,n){return typeof e=="function"?e(n):e}function Un(e,n){return typeof e=="function"?e(n):e}function Iv(e,n){const{type:r="all",exact:i,fetchStatus:o,predicate:s,queryKey:u,stale:d}=e;if(u){if(i){if(n.queryHash!==Rm(u,n.options))return!1}else if(!Pl(n.queryKey,u))return!1}if(r!=="all"){const h=n.isActive();if(r==="active"&&!h||r==="inactive"&&h)return!1}return!(typeof d=="boolean"&&n.isStale()!==d||o&&o!==n.state.fetchStatus||s&&!s(n))}function qv(e,n){const{exact:r,status:i,predicate:o,mutationKey:s}=e;if(s){if(!n.options.mutationKey)return!1;if(r){if(ji(n.options.mutationKey)!==ji(s))return!1}else if(!Pl(n.options.mutationKey,s))return!1}return!(i&&n.state.status!==i||o&&!o(n))}function Rm(e,n){return(n?.queryKeyHashFn||ji)(e)}function ji(e){return JSON.stringify(e,(n,r)=>$h(r)?Object.keys(r).sort().reduce((i,o)=>(i[o]=r[o],i),{}):r)}function Pl(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(Array.isArray(e)&&Array.isArray(n)){for(let i=0;i<n.length;i++)if(!Pl(e[i],n[i]))return!1;return!0}const r=Object.keys(n);for(const i of r)if(!Pl(e[i],n[i]))return!1;return!0}return!1}const NE=Object.prototype.hasOwnProperty;function Z0(e,n,r=0){if(e===n)return e;if(r>500)return n;const i=Fv(e)&&Fv(n);if(!i&&!($h(e)&&$h(n)))return n;const o=(i?e:Object.keys(e)).length,s=i?n:Object.keys(n),u=s.length,d=i?new Array(u):{};let h=0;for(let f=0;f<u;f++){const y=i?f:s[f],p=e[y],v=n[y];if(p===v){d[y]=p,(i?f<o:NE.call(e,y))&&h++;continue}if(p===null||v===null||typeof p!="object"||typeof v!="object"){d[y]=v;continue}const b=Z0(p,v,r+1);d[y]=b,b===p&&h++}return o===u&&h===o?e:d}function nc(e,n){if(!n||Object.keys(e).length!==Object.keys(n).length)return!1;for(const r in e)if(e[r]!==n[r])return!1;return!0}function Fv(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function $h(e){if(!$v(e))return!1;const n=e.constructor;if(n===void 0)return!0;const r=n.prototype;return!(!$v(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function $v(e){return Object.prototype.toString.call(e)==="[object Object]"}function AE(e){return new Promise(n=>{ki.setTimeout(n,e)})}function Vh(e,n,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,n):r.structuralSharing!==!1?Z0(e,n):n}function TE(e,n,r=0){const i=[...e,n];return r&&i.length>r?i.slice(1):i}function OE(e,n,r=0){const i=[n,...e];return r&&i.length>r?i.slice(0,-1):i}const _m=Symbol();function W0(e,n){return!e.queryFn&&n?.initialPromise?()=>n.initialPromise:!e.queryFn||e.queryFn===_m?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Dm(e,n){return typeof e=="function"?e(...n):!!e}function RE(e,n,r){let i=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??=n(),i||(i=!0,o.aborted?r():o.addEventListener("abort",r,{once:!0})),o)}),e}const rc=(()=>{let e=()=>EE;return{isServer(){return e()},setIsServer(n){e=n}}})();var Ul=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(){}},_E=class extends Ul{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}};const Mm=new _E,DE=CE;function ME(){let e=[],n=0,r=d=>{d()},i=d=>{d()},o=DE;const s=d=>{n?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;n++;try{h=d()}finally{n--,n||u()}return h},batchCalls:d=>(...h)=>{s(()=>{d(...h)})},schedule:s,setNotifyFunction:d=>{r=d},setBatchNotifyFunction:d=>{i=d},setScheduler:d=>{o=d}}}const Ut=ME();var zE=class extends Ul{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const n=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),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(n=>{n(e)}))}isOnline(){return this.#e}};const ac=new zE;function LE(e){return Math.min(1e3*2**e,3e4)}function J0(e){return(e??"online")==="online"?ac.isOnline():!0}var Yh=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function e1(e){let n=!1,r=0,i,o="pending",s,u;const d=new Promise((A,R)=>{s=A,u=R});d.catch(on);const h=()=>o!=="pending",f=A=>{if(!h()){const R=new Yh(A);C(R),e.onCancel?.(R)}},y=()=>{n=!0},p=()=>{n=!1},v=()=>Mm.isFocused()&&(e.networkMode==="always"||ac.isOnline())&&e.canRun(),b=()=>J0(e.networkMode)&&e.canRun(),w=A=>{h()||(i?.(),o="resolved",s(A))},C=A=>{h()||(i?.(),o="rejected",u(A))},E=()=>new Promise(A=>{i=R=>{(h()||v())&&A(R)},e.onPause?.()}).then(()=>{i=void 0,h()||e.onContinue?.()}),j=()=>{if(h())return;let A;const R=r===0?e.initialPromise:void 0;try{A=R??e.fn()}catch(B){A=Promise.reject(B)}Promise.resolve(A).then(w).catch(B=>{if(h())return;const P=e.retry??(rc.isServer()?0:3),_=e.retryDelay??LE,q=typeof _=="function"?_(r,B):_,I=P===!0||typeof P=="number"&&r<P||typeof P=="function"&&P(r,B);if(n||!I){C(B);return}r++,e.onFail?.(r,B),AE(q).then(()=>v()?void 0:E()).then(()=>{n?C(B):j()})})};return{promise:d,status:()=>o,cancel:f,continue:()=>(i?.(),d),cancelRetry:y,continueRetry:p,canStart:b,start:()=>(b()?j():E().then(j),d)}}var t1=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Fh(this.gcTime)&&(this.#e=ki.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(rc.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(ki.clearTimeout(this.#e),this.#e=void 0)}};function PE(e){return{onFetch:(n,r)=>{const i=n.options,o=n.fetchOptions?.meta?.fetchMore?.direction,s=n.state.data?.pages||[],u=n.state.data?.pageParams||[];let d={pages:[],pageParams:[]},h=0;const f=async()=>{let y=!1;const p=w=>{RE(w,()=>n.signal,()=>y=!0)},v=W0(n.options,n.fetchOptions),b=async(w,C,E)=>{if(y)return Promise.reject(n.signal.reason);if(C==null&&w.pages.length)return Promise.resolve(w);const A=(()=>{const _={client:n.client,queryKey:n.queryKey,pageParam:C,direction:E?"backward":"forward",meta:n.options.meta};return p(_),_})(),R=await v(A),{maxPages:B}=n.options,P=E?OE:TE;return{pages:P(w.pages,R,B),pageParams:P(w.pageParams,C,B)}};if(o&&s.length){const w=o==="backward",C=w?HE:Vv,E={pages:s,pageParams:u};d=await b(E,C(i,E),w)}else{const w=e??s.length;do{const C=h===0?u[0]??i.initialPageParam:Vv(i,d);if(h>0&&C==null)break;d=await b(d,C),h++}while(h<w)}return d};n.options.persister?n.fetchFn=()=>n.options.persister?.(f,{client:n.client,queryKey:n.queryKey,meta:n.options.meta,signal:n.signal},r):n.fetchFn=f}}}function Vv(e,{pages:n,pageParams:r}){const i=n.length-1;return n.length>0?e.getNextPageParam(n[i],n,r[i],r):void 0}function HE(e,{pages:n,pageParams:r}){return n.length>0?e.getPreviousPageParam?.(n[0],n,r[0],r):void 0}var UE=class extends t1{#e;#t;#n;#r;#i;#a;#l;#s;constructor(e){super(),this.#s=!1,this.#l=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=Qv(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.#l,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Qv(this.options);n.data!==void 0&&(this.setState(Yv(n.data,n.dataUpdatedAt)),this.#t=n)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,n){const r=Vh(this.state.data,e,this.options);return this.#o({data:r,type:"success",dataUpdatedAt:n?.updatedAt,manual:n?.manual}),r}setState(e){this.#o({type:"setState",state:e})}cancel(e){const n=this.#a?.promise;return this.#a?.cancel(e),n?n.then(on).catch(on):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=>Un(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===_m||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Xr(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:!X0(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.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){const n=this.observers.indexOf(e);n!==-1&&(this.observers.splice(n,1),this.observers.length||(this.#a&&(this.#s||this.#u()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#u(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,n){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&n?.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.#s=!0,r.signal)})},o=()=>{const h=W0(this.options,n),y=(()=>{const p={client:this.#i,queryKey:this.queryKey,meta:this.meta};return i(p),p})();return this.#s=!1,this.options.persister?this.options.persister(h,y,this):h(y)},u=(()=>{const h={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:o};return i(h),h})();(this.#e==="infinite"?PE(this.options.pages):this.options.behavior)?.onFetch(u,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==u.fetchOptions?.meta)&&this.#o({type:"fetch",meta:u.fetchOptions?.meta});const d=this.#a=e1({initialPromise:n?.initialPromise,fn:u.fetchFn,onCancel:h=>{h instanceof Yh&&h.revert&&this.setState({...this.#n,fetchStatus:"idle"}),r.abort()},onFail:(h,f)=>{this.#o({type:"failed",failureCount:h,error:f})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0});try{const h=await d.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 Yh){if(h.silent)return this.#a.promise;if(h.revert){if(this.state.data===void 0)throw h;return this.state.data}}throw this.#o({type:"error",error:h}),this.#r.config.onError?.(h,this),this.#r.config.onSettled?.(this.state.data,h,this),h}finally{this.#a===d&&(this.#a=void 0),this.scheduleGc()}}#o(e){const n=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,...n1(r.data,this.options),fetchMeta:e.meta??null};case"success":const i={...r,...Yv(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=n(this.state),Ut.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function n1(e,n){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:J0(n.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Yv(e,n){return{data:e,dataUpdatedAt:n??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Qv(e){const n=typeof e.initialData=="function"?e.initialData():e.initialData,r=n!==void 0,i=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:n,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 BE=class extends Ul{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#l;#s;#u;#o;#d;#f;#c;#m=new Set;constructor(e,n){super(),this.options=n,this.#e=e,this.#l=null,this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Gv(this.#t,this.options)?this.#h():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qh(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qh(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#b(),this.#t.removeObserver(this)}setOptions(e){const n=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 Un(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),n._defaulted&&!nc(this.options,n)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&Kv(this.#t,r,this.options,n)&&this.#h(),this.updateResult(),i&&(this.#t!==r||Un(this.options.enabled,this.#t)!==Un(n.enabled,this.#t)||Xr(this.options.staleTime,this.#t)!==Xr(n.staleTime,this.#t))&&this.#p();const o=this.#g();i&&(this.#t!==r||Un(this.options.enabled,this.#t)!==Un(n.enabled,this.#t)||o!==this.#c)&&this.#y(o)}getOptimisticResult(e){const n=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(n,e);return qE(this,r)&&(this.#r=r,this.#a=this.options,this.#i=this.#t.state),r}getCurrentResult(){return this.#r}trackResult(e,n){return new Proxy(e,{get:(r,i)=>(this.trackProp(i),n?.(i),Reflect.get(r,i))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,n);let i=()=>{},o;const s=new Promise(u=>{o=u,i=this.#e.getQueryCache().subscribe(d=>{d.type==="updated"&&d.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),u(this.createResult(r,n)))})});return Promise.race([r.fetch().then(()=>{const u=this.createResult(r,n);return o?.(u),u}).finally(()=>{i()}),s])}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#w();let n=this.#t.fetch(this.options,e);return e?.throwOnError||(n=n.catch(on)),n}#p(){this.#v();const e=Xr(this.options.staleTime,this.#t);if(rc.isServer()||this.#r.isStale||!Fh(e))return;const n=X0(this.#r.dataUpdatedAt,e)+1;this.#d=ki.setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(e){this.#b(),this.#c=e,!(rc.isServer()||Un(this.options.enabled,this.#t)===!1||!Fh(this.#c)||this.#c===0)&&(this.#f=ki.setInterval(()=>{(this.options.refetchIntervalInBackground||Mm.isFocused())&&this.#h()},this.#c))}#x(){this.#p(),this.#y(this.#g())}#v(){this.#d!==void 0&&(ki.clearTimeout(this.#d),this.#d=void 0)}#b(){this.#f!==void 0&&(ki.clearInterval(this.#f),this.#f=void 0)}createResult(e,n){const r=this.#t,i=this.options,o=this.#r,s=this.#i,u=this.#a,d=e!==r?e.state:this.#n,{state:h}=e;let f={...h},y=!1,p;if(n._optimisticResults){const P=this.hasListeners(),_=!P&&Gv(e,n),q=P&&Kv(e,r,n,i);(_||q)&&(f={...f,...n1(h.data,e.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:b,status:w}=f;p=f.data;let C=!1;if(n.placeholderData!==void 0&&p===void 0&&w==="pending"){let P;o?.isPlaceholderData&&n.placeholderData===u?.placeholderData?(P=o.data,C=!0):P=typeof n.placeholderData=="function"?n.placeholderData(this.#o?.state.data,this.#o):n.placeholderData,P!==void 0&&(w="success",p=Vh(o?.data,P,n),y=!0)}if(n.select&&p!==void 0&&!C)if(o&&p===s?.data&&n.select===this.#s)p=this.#u;else try{this.#s=n.select,p=n.select(p),p=Vh(o?.data,p,n),this.#u=p,this.#l=null}catch(P){this.#l=P}else p===void 0&&(this.#l=null);this.#l&&(v=this.#l,p=this.#u,b=Date.now(),w="error",y=!1);const E=f.fetchStatus==="fetching",j=w==="pending",A=w==="error",R=j&&E,B=p!==void 0;return{status:w,fetchStatus:f.fetchStatus,isPending:j,isSuccess:w==="success",isError:A,isInitialLoading:R,isLoading:R,data:p,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:b,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:E,isRefetching:E&&!j,isLoadingError:A&&!B,isPaused:f.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:A&&B,isStale:zm(e,n),refetch:this.refetch,isEnabled:Un(n.enabled,e)!==!1}}updateResult(){const e=this.#r,n=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#o=this.#t),nc(n,e))return;this.#r=n;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!this.#m.size)return!0;const s=new Set(o??this.#m);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.#S({listeners:r()})}#w(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const n=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(n?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#S(e){Ut.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function IE(e,n){return Un(n.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Un(n.retryOnMount,e)===!1)}function Gv(e,n){return IE(e,n)||e.state.data!==void 0&&Qh(e,n,n.refetchOnMount)}function Qh(e,n,r){if(Un(n.enabled,e)!==!1&&Xr(n.staleTime,e)!=="static"){const i=typeof r=="function"?r(e):r;return i==="always"||i!==!1&&zm(e,n)}return!1}function Kv(e,n,r,i){return(e!==n||Un(i.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&zm(e,r)}function zm(e,n){return Un(n.enabled,e)!==!1&&e.isStaleByTime(Xr(n.staleTime,e))}function qE(e,n){return!nc(e.getCurrentResult(),n)}var FE=class extends t1{#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||r1(),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(n=>n!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(e){const n=()=>{this.#i({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},i=this.#r=e1({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(u,d)=>{this.#i({type:"failed",failureCount:u,error:d})},onPause:()=>{this.#i({type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),o=this.state.status==="pending",s=!i.canStart();try{if(o)n();else{this.#i({type:"pending",variables:e,isPaused:s}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);const d=await this.options.onMutate?.(e,r);d!==this.state.context&&this.#i({type:"pending",context:d,variables:e,isPaused:s})}const u=await i.start();return await this.#n.config.onSuccess?.(u,e,this.state.context,this,r),await this.options.onSuccess?.(u,e,this.state.context,r),await this.#n.config.onSettled?.(u,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(u,null,e,this.state.context,r),this.#i({type:"success",data:u}),u}catch(u){try{await this.#n.config.onError?.(u,e,this.state.context,this,r)}catch(d){Promise.reject(d)}try{await this.options.onError?.(u,e,this.state.context,r)}catch(d){Promise.reject(d)}try{await this.#n.config.onSettled?.(void 0,u,this.state.variables,this.state.context,this,r)}catch(d){Promise.reject(d)}try{await this.options.onSettled?.(void 0,u,e,this.state.context,r)}catch(d){Promise.reject(d)}throw this.#i({type:"error",error:u}),u}finally{this.#r===i&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){const n=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=n(this.state),Ut.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function r1(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $E=class extends Ul{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,n,r){const i=new FE({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(n),state:r});return this.add(i),i}add(e){this.#e.add(e);const n=Pu(e);if(typeof n=="string"){const r=this.#t.get(n);r?r.push(e):this.#t.set(n,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const n=Pu(e);if(typeof n=="string"){const r=this.#t.get(n);if(r)if(r.length>1){const i=r.indexOf(e);i!==-1&&r.splice(i,1)}else r[0]===e&&this.#t.delete(n)}}this.notify({type:"removed",mutation:e})}canRun(e){const n=Pu(e);if(typeof n=="string"){const r=this.#t.get(n)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const n=Pu(e);return typeof n=="string"?this.#t.get(n)?.find(r=>r!==e&&r.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 n={exact:!0,...e};return this.getAll().find(r=>qv(n,r))}findAll(e={}){return this.getAll().filter(n=>qv(e,n))}notify(e){Ut.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Ut.batch(()=>Promise.all(e.map(n=>n.continue().catch(on))))}};function Pu(e){return e.options.scope?.id}var VE=class extends Ul{#e;#t=void 0;#n;#r;constructor(n,r){super(),this.#e=n,this.setOptions(r),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){const r=this.options;this.options=this.#e.defaultMutationOptions(n),nc(this.options,r)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),r?.mutationKey&&this.options.mutationKey&&ji(r.mutationKey)!==ji(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onSubscribe(){this.listeners.size===1&&this.#n&&(this.#n.addObserver(this),this.#i())}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(n){this.#i(),this.#a(n)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(n,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(n)}#i(){const n=this.#n?.state??r1();this.#t={...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset}}#a(n){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(n?.type==="success"){try{this.#r.onSuccess?.(n.data,r,i,o)}catch(s){Promise.reject(s)}try{this.#r.onSettled?.(n.data,null,r,i,o)}catch(s){Promise.reject(s)}}else if(n?.type==="error"){try{this.#r.onError?.(n.error,r,i,o)}catch(s){Promise.reject(s)}try{this.#r.onSettled?.(void 0,n.error,r,i,o)}catch(s){Promise.reject(s)}}}this.listeners.forEach(r=>{r(this.#t)})})}},YE=class extends Ul{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,n,r){const i=n.queryKey,o=n.queryHash??Rm(i,n);let s=this.get(o);return s||(s=new UE({client:e,queryKey:i,queryHash:o,options:e.defaultQueryOptions(n),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 n=this.#e.get(e.queryHash);n&&(e.destroy(),n===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 n={exact:!0,...e};return this.getAll().find(r=>Iv(n,r))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(r=>Iv(e,r)):n}notify(e){Ut.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Ut.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ut.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},QE=class{#e;#t;#n;#r;#i;#a;#l;#s;constructor(e={}){this.#e=e.queryCache||new YE,this.#t=e.mutationCache||new $E,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#l=Mm.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ac.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#l?.(),this.#l=void 0,this.#s?.(),this.#s=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 n=this.defaultQueryOptions({queryKey:e});return this.#e.get(n.queryHash)?.state.data}ensureQueryData(e){const n=this.defaultQueryOptions(e),r=this.#e.build(this,n),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Xr(n.staleTime,r))&&this.prefetchQuery(n),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:n,state:r})=>[n,r.data])}setQueryData(e,n,r){const i=this.defaultQueryOptions({queryKey:e}),o=this.#e.get(i.queryHash)?.state.data,s=jE(n,o);if(s!==void 0)return this.#e.build(this,i).setData(s,{...r,manual:!0})}setQueriesData(e,n,r){return Ut.batch(()=>this.#e.findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,n,r)]))}getQueryState(e){const n=this.defaultQueryOptions({queryKey:e});return this.#e.get(n.queryHash)?.state}removeQueries(e){const n=this.#e;Ut.batch(()=>{n.findAll(e).forEach(r=>{n.remove(r)})})}resetQueries(e,n){const r=this.#e;return Ut.batch(()=>{const i=r.findAll(e),o=new Set(i);return i.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:s=>o.has(s)},n)})}cancelQueries(e,n={}){const r={revert:!0,...n},i=Ut.batch(()=>this.#e.findAll(e).map(o=>o.cancel(r)));return Promise.all(i).then(on).catch(on)}invalidateQueries(e,n={}){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"},n)))}refetchQueries(e,n={}){const r={...n,cancelRefetch:n.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(on)),o.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(i).then(on)}async query(e){const n=this.defaultQueryOptions(e);n.retry===void 0&&(n.retry=!1);const r=this.#e.build(this,n),i=r.isStaleByTime(Xr(n.staleTime,r))?await r.fetch(n):r.state.data,o=n.select;return o?o(i):i}fetchQuery(e){const n=this.defaultQueryOptions(e);n.retry===void 0&&(n.retry=!1);const r=this.#e.build(this,n);return r.isStaleByTime(Xr(n.staleTime,r))?r.fetch(n):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(on).catch(on)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(on).catch(on)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return ac.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,n){this.#r.set(ji(e),{queryKey:e,defaultOptions:n})}getQueryDefaults(e){const n=[...this.#r.values()],r={};return n.forEach(i=>{Pl(e,i.queryKey)&&Object.assign(r,i.defaultOptions)}),r}setMutationDefaults(e,n){this.#i.set(ji(e),{mutationKey:e,defaultOptions:n})}getMutationDefaults(e){const n=[...this.#i.values()],r={};return n.forEach(i=>{Pl(e,i.mutationKey)&&Object.assign(r,i.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const n={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return n.queryHash||(n.queryHash=Rm(n.queryKey,n)),n.refetchOnReconnect===void 0&&(n.refetchOnReconnect=n.networkMode!=="always"),n.throwOnError===void 0&&(n.throwOnError=!!n.suspense),!n.networkMode&&n.persister&&(n.networkMode="offlineFirst"),n.queryFn===_m&&(n.enabled=!1),n}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()}};const a1=k.createContext(!1),GE=()=>k.useContext(a1);a1.Provider;function KE(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const XE=k.createContext(KE()),ZE=()=>k.useContext(XE),WE=(e,n,r)=>{const i=r?.state.error&&typeof e.throwOnError=="function"?Dm(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||i)&&(n.isReset()||(e.retryOnMount=!1))},JE=e=>{k.useEffect(()=>{e.clearReset()},[e])},ej=({result:e,errorResetBoundary:n,throwOnError:r,query:i,suspense:o})=>e.isError&&!n.isReset()&&!e.isFetching&&i&&(o&&e.data===void 0||Dm(r,[e.error,i])),tj=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))}},nj=(e,n)=>e?.suspense&&n.isPending,rj=(e,n,r)=>n.fetchOptimistic(e).catch(()=>{r.clearReset()});function aj(e,n,r){const i=GE(),o=ZE(),s=Bt(),u=s.defaultQueryOptions(e),d=s.getQueryCache().get(u.queryHash),h=e.subscribed!==!1;u._optimisticResults=i?"isRestoring":h?"optimistic":void 0,tj(u),WE(u,o,d),JE(o);const[f]=k.useState(()=>new n(s,u)),y=f.getOptimisticResult(u),p=!i&&h;if(k.useSyncExternalStore(k.useCallback(v=>{const b=p?f.subscribe(Ut.batchCalls(v)):on;return f.updateResult(),b},[f,p]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),k.useEffect(()=>{f.setOptions(u)},[u,f]),nj(u,y))throw rj(u,f,o);if(ej({result:y,errorResetBoundary:o,throwOnError:u.throwOnError,query:d,suspense:u.suspense}))throw y.error;return u.notifyOnChangeProps?y:f.trackResult(y)}function mt(e,n){return aj(e,BE)}function sn(e,n){const r=Bt(),[i]=k.useState(()=>new VE(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)=>{i.mutate(u[0],u[1]).catch(on)},[i]);if(o.error&&Dm(i.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:s,mutateAsync:o.mutate}}var ih={exports:{}},Io={},lh={exports:{}},oh={};var Xv;function ij(){return Xv||(Xv=1,(function(e){function n(L,Z){var ie=L.length;L.push(Z);e:for(;0<ie;){var he=ie-1>>>1,O=L[he];if(0<o(O,Z))L[he]=Z,L[ie]=O,ie=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],ie=L.pop();if(ie!==Z){L[0]=ie;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,ie))G<O&&0>o(K,T)?(L[he]=K,L[G]=ie,he=G):(L[he]=T,L[z]=ie,he=z);else if(G<O&&0>o(K,ie))L[he]=K,L[G]=ie,he=G;else break e}}return Z}function o(L,Z){var ie=L.sortIndex-Z.sortIndex;return ie!==0?ie: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,E=!1,j=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function B(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,n(h,Z);else break;Z=r(f)}}function P(L){if(C=!1,B(L),!w)if(r(h)!==null)w=!0,_||(_=!0,Q());else{var Z=r(f);Z!==null&&re(P,Z.startTime-L)}}var _=!1,q=-1,I=5,oe=-1;function U(){return E?!0:!(e.unstable_now()-oe<I)}function ne(){if(E=!1,_){var L=e.unstable_now();oe=L;var Z=!0;try{e:{w=!1,C&&(C=!1,A(q),q=-1),b=!0;var ie=v;try{t:{for(B(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,B(L),Z=!0;break t}p===r(h)&&i(h),B(L)}else i(h);p=r(h)}if(p!==null)Z=!0;else{var M=r(f);M!==null&&re(P,M.startTime-L),Z=!1}}break e}finally{p=null,v=ie,b=!1}Z=void 0}}finally{Z?Q():_=!1}}}var Q;if(typeof R=="function")Q=function(){R(ne)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,le=fe.port2;fe.port1.onmessage=ne,Q=function(){le.postMessage(null)}}else Q=function(){j(ne,0)};function re(L,Z){q=j(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 ie=v;v=Z;try{return L()}finally{v=ie}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(L,Z){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var ie=v;v=L;try{return Z()}finally{v=ie}},e.unstable_scheduleCallback=function(L,Z,ie){var he=e.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?he+ie:he):ie=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=ie+O,L={id:y++,callback:Z,priorityLevel:L,startTime:ie,expirationTime:O,sortIndex:-1},ie>he?(L.sortIndex=ie,n(f,L),r(h)===null&&L===r(f)&&(C?(A(q),q=-1):C=!0,re(P,ie-he))):(L.sortIndex=O,n(h,L),w||b||(w=!0,_||(_=!0,Q()))),L},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(L){var Z=v;return function(){var ie=v;v=Z;try{return L.apply(this,arguments)}finally{v=ie}}}})(oh)),oh}var Zv;function lj(){return Zv||(Zv=1,lh.exports=ij()),lh.exports}var sh={exports:{}},en={};var Wv;function oj(){if(Wv)return en;Wv=1;var e=Om();function n(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(n(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 en.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,en.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(n(299));return s(h,f,null,y)},en.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()}},en.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))},en.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},en.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})}},en.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)},en.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})}},en.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)},en.requestFormReset=function(h){i.d.r(h)},en.unstable_batchedUpdates=function(h,f){return h(f)},en.useFormState=function(h,f,y){return u.H.useFormState(h,f,y)},en.useFormStatus=function(){return u.H.useHostTransitionStatus()},en.version="19.2.8",en}var Jv;function i1(){if(Jv)return sh.exports;Jv=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(n){console.error(n)}}return e(),sh.exports=oj(),sh.exports}var eb;function sj(){if(eb)return Io;eb=1;var e=lj(),n=Om(),r=i1();function i(t){var a="https://react.dev/errors/"+t;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 #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function s(t){var a=t,l=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(l=a.return),t=a.return;while(t)}return a.tag===3?l:null}function u(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function d(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function h(t){if(s(t)!==t)throw Error(i(188))}function f(t){var a=t.alternate;if(!a){if(a=s(t),a===null)throw Error(i(188));return a!==t?null:t}for(var l=t,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),t;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,N=g.child;N;){if(N===l){S=!0,l=g,c=x;break}if(N===c){S=!0,c=g,l=x;break}N=N.sibling}if(!S){for(N=x.child;N;){if(N===l){S=!0,l=x,c=g;break}if(N===c){S=!0,c=x,l=g;break}N=N.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?t:a}function y(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=y(t),a!==null)return a;t=t.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"),E=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),R=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),oe=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function Q(t){return t===null||typeof t!="object"?null:(t=ne&&t[ne]||t["@@iterator"],typeof t=="function"?t:null)}var fe=Symbol.for("react.client.reference");function le(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===fe?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case j:return"Profiler";case E:return"StrictMode";case P:return"Suspense";case _:return"SuspenseList";case oe:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case w:return"Portal";case R:return t.displayName||"Context";case A:return(t._context.displayName||"Context")+".Consumer";case B:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case q:return a=t.displayName||null,a!==null?a:le(t.type)||"Memo";case I:a=t._payload,t=t._init;try{return le(t(a))}catch{}}return null}var re=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},he=[],O=-1;function M(t){return{current:t}}function z(t){0>O||(t.current=he[O],he[O]=null,O--)}function T(t,a){O++,he[O]=t.current,t.current=a}var G=M(null),K=M(null),J=M(null),me=M(null);function Ne(t,a){switch(T(J,a),T(K,t),T(G,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?lv(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=lv(a),t=ov(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}z(G),T(G,t)}function ue(){z(G),z(K),z(J)}function tt(t){t.memoizedState!==null&&T(me,t);var a=G.current,l=ov(a,t.type);a!==l&&(T(K,t),T(G,l))}function bt(t){K.current===t&&(z(G),z(K)),me.current===t&&(z(me),Lo._currentValue=ie)}var It,Zt;function Et(t){if(It===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);It=a&&a[1]||"",Zt=-1<l.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+It+t+Zt}var An=!1;function jr(t,a){if(!t||An)return"";An=!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 Y=X}Reflect.construct(t,[],ae)}else{try{ae.call()}catch(X){Y=X}t.call(ae.prototype)}}else{try{throw Error()}catch(X){Y=X}(ae=t())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(X){if(X&&Y&&typeof X.stack=="string")return[X.stack,Y.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],N=x[1];if(S&&N){var D=S.split(`
@@ -78,4 +78,4 @@ Error generating stack: `+c.message+`
78
78
  `)},rz=0,Al=[];function az(e){var n=k.useRef([]),r=k.useRef([0,0]),i=k.useRef(),o=k.useState(rz++)[0],s=k.useState(AS)[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=EM([e.lockRef.current],(e.shards||[]).map(b0),!0).filter(Boolean);return C.forEach(function(E){return E.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),C.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var d=k.useCallback(function(C,E){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!u.current.allowPinchZoom;var j=Gu(C),A=r.current,R="deltaX"in C?C.deltaX:A[0]-j[0],B="deltaY"in C?C.deltaY:A[1]-j[1],P,_=C.target,q=Math.abs(R)>Math.abs(B)?"h":"v";if("touches"in C&&q==="h"&&_.type==="range")return!1;var I=window.getSelection(),oe=I&&I.anchorNode,U=oe?oe===_||oe.contains(_):!1;if(U)return!1;var ne=x0(q,_);if(!ne)return!0;if(ne?P=q:(P=q==="v"?"h":"v",ne=x0(q,_)),!ne)return!1;if(!i.current&&"changedTouches"in C&&(R||B)&&(i.current=P),!P)return!0;var Q=i.current||P;return ez(Q,E,C,Q==="h"?R:B)},[]),h=k.useCallback(function(C){var E=C;if(!(!Al.length||Al[Al.length-1]!==s)){var j="deltaY"in E?v0(E):Gu(E),A=n.current.filter(function(P){return P.name===E.type&&(P.target===E.target||E.target===P.shadowParent)&&tz(P.delta,j)})[0];if(A&&A.should){E.cancelable&&E.preventDefault();return}if(!A){var R=(u.current.shards||[]).map(b0).filter(Boolean).filter(function(P){return P.contains(E.target)}),B=R.length>0?d(E,R[0]):!u.current.noIsolation;B&&E.cancelable&&E.preventDefault()}}},[]),f=k.useCallback(function(C,E,j,A){var R={name:C,delta:E,target:j,should:A,shadowParent:iz(j)};n.current.push(R),setTimeout(function(){n.current=n.current.filter(function(B){return B!==R})},1)},[]),y=k.useCallback(function(C){r.current=Gu(C),i.current=void 0},[]),p=k.useCallback(function(C){f(C.type,v0(C),C.target,d(C,e.lockRef.current))},[]),v=k.useCallback(function(C){f(C.type,Gu(C),C.target,d(C,e.lockRef.current))},[]);k.useEffect(function(){return Al.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:v}),document.addEventListener("wheel",h,Nl),document.addEventListener("touchmove",h,Nl),document.addEventListener("touchstart",y,Nl),function(){Al=Al.filter(function(C){return C!==s}),document.removeEventListener("wheel",h,Nl),document.removeEventListener("touchmove",h,Nl),document.removeEventListener("touchstart",y,Nl)}},[]);var b=e.removeScrollBar,w=e.inert;return k.createElement(k.Fragment,null,w?k.createElement(s,{styles:nz(o)}):null,b?k.createElement(QM,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function iz(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const lz=MM(NS,az);var dp=k.forwardRef(function(e,n){return k.createElement(_c,vr({},e,{ref:n,sideCar:lz}))});dp.classNames=_c.classNames;var oz=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Tl=new WeakMap,Ku=new WeakMap,Xu={},_h=0,_S=function(e){return e&&(e.host||_S(e.parentNode))},sz=function(e,n){return n.map(function(r){if(e.contains(r))return r;var i=_S(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})},uz=function(e,n,r,i){var o=sz(n,Array.isArray(e)?e:[e]);Xu[r]||(Xu[r]=new WeakMap);var s=Xu[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=(Tl.get(v)||0)+1,E=(s.get(v)||0)+1;Tl.set(v,C),s.set(v,E),u.push(v),C===1&&w&&Ku.set(v,!0),E===1&&v.setAttribute(r,"true"),w||v.setAttribute(i,"true")}catch(j){console.error("aria-hidden: cannot operate on ",v,j)}})};return y(n),d.clear(),_h++,function(){u.forEach(function(p){var v=Tl.get(p)-1,b=s.get(p)-1;Tl.set(p,v),s.set(p,b),v||(Ku.has(p)||p.removeAttribute(i),Ku.delete(p)),b||p.removeAttribute(r)}),_h--,_h||(Tl=new WeakMap,Tl=new WeakMap,Ku=new WeakMap,Xu={})}},DS=function(e,n,r){r===void 0&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),o=oz(e);return o?(i.push.apply(i,Array.from(o.querySelectorAll("[aria-live], script"))),uz(i,o,r,"aria-hidden")):function(){return null}},cz=Object.defineProperty,rr=(e,n)=>cz(e,"name",{value:n,configurable:!0}),fp="Dialog",[MS,cP]=Va(fp),[dz,Cr]=MS(fp),zS=rr(e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:u=!0}=e,d=k.useRef(null),h=k.useRef(null),[f,y]=Fl({prop:i,defaultProp:o??!1,onChange:s,caller:fp}),[p,v]=k.useState(0),[b,w]=k.useState(0);return m.jsx(dz,{scope:n,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"),LS="DialogPortal",[fz,PS]=MS(LS,{forceMount:void 0}),HS=rr(e=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=e,s=Cr(LS,n);return m.jsx(fz,{scope:n,forceMount:r,children:k.Children.map(i,u=>m.jsx(Nn,{present:r||s.open,children:m.jsx(Oc,{asChild:!0,container:o,children:u})}))})},"DialogPortal"),ym="DialogOverlay",US=k.forwardRef(rr(function(n,r){const i=PS(ym,n.__scopeDialog),{forceMount:o=i.forceMount,...s}=n,u=Cr(ym,n.__scopeDialog);return u.modal?m.jsx(Nn,{present:o||u.open,children:m.jsx(mz,{...s,ref:r})}):null},"DialogOverlay")),hz=ys("DialogOverlay.RemoveScroll"),mz=k.forwardRef(rr(function(n,r){const{__scopeDialog:i,...o}=n,s=Cr(ym,i),u=dS(),d=zt(r,u);return m.jsx(dp,{as:hz,allowPinchZoom:!0,shards:[s.contentRef],children:m.jsx(et.div,{"data-state":hp(s.open),...o,ref:d,style:{pointerEvents:"auto",...o.style}})})},"DialogOverlayImpl")),ns="DialogContent",BS=k.forwardRef(rr(function(n,r){const i=PS(ns,n.__scopeDialog),{forceMount:o=i.forceMount,...s}=n,u=Cr(ns,n.__scopeDialog);return m.jsx(Nn,{present:o||u.open,children:u.modal?m.jsx(pz,{...s,ref:r}):m.jsx(gz,{...s,ref:r})})},"DialogContent")),pz=k.forwardRef(rr(function(n,r){const i=Cr(ns,n.__scopeDialog),o=k.useRef(null),s=zt(r,i.contentRef,o);return k.useEffect(()=>{const u=o.current;if(u)return DS(u)},[]),m.jsx(IS,{...n,ref:s,trapFocus:i.open,disableOutsidePointerEvents:i.open,onCloseAutoFocus:Ye(n.onCloseAutoFocus,u=>{u.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Ye(n.onPointerDownOutside,u=>{const d=u.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0;(d.button===2||h)&&u.preventDefault()}),onFocusOutside:Ye(n.onFocusOutside,u=>u.preventDefault())})},"DialogContentModal")),gz=k.forwardRef(rr(function(n,r){const i=Cr(ns,n.__scopeDialog),o=k.useRef(!1),s=k.useRef(!1);return m.jsx(IS,{...n,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{n.onCloseAutoFocus?.(u),u.defaultPrevented||(o.current||i.triggerRef.current?.focus(),u.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:u=>{n.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")),IS=k.forwardRef(rr(function(n,r){const{__scopeDialog:i,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:u,...d}=n,h=Cr(ns,i);return Rc(),m.jsx(m.Fragment,{children:m.jsx(mS,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:u,children:m.jsx(Tc,{role:"dialog",id:h.contentId,"aria-describedby":h.descriptionPresent?h.descriptionId:void 0,"aria-labelledby":h.titlePresent?h.titleId:void 0,"data-state":hp(h.open),...d,ref:r,deferPointerDownOutside:!0,onDismiss:()=>h.onOpenChange(!1)})})})},"DialogContentImpl")),yz="DialogTitle",xz=k.forwardRef(rr(function(n,r){const{__scopeDialog:i,...o}=n,s=Cr(yz,i),{setTitleCount:u}=s;return fn(()=>(u(d=>d+1),()=>u(d=>d-1)),[u]),m.jsx(et.h2,{id:s.titleId,...o,ref:r})},"DialogTitle")),vz="DialogDescription",bz=k.forwardRef(rr(function(n,r){const{__scopeDialog:i,...o}=n,s=Cr(vz,i),{setDescriptionCount:u}=s;return fn(()=>(u(d=>d+1),()=>u(d=>d-1)),[u]),m.jsx(et.p,{id:s.descriptionId,...o,ref:r})},"DialogDescription")),wz="DialogClose",Sz=k.forwardRef(rr(function(n,r){const{__scopeDialog:i,...o}=n,s=Cr(wz,i);return m.jsx(et.button,{type:"button",...o,ref:r,onClick:Ye(n.onClick,()=>s.onOpenChange(!1))})},"DialogClose"));function hp(e){return e?"open":"closed"}rr(hp,"getState");const $l=zS,kz=HS,qS=k.forwardRef(({className:e,...n},r)=>m.jsx(US,{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),...n}));qS.displayName="DialogOverlay";const zi=k.forwardRef(({className:e,children:n,hideClose:r,...i},o)=>m.jsxs(kz,{children:[m.jsx(qS,{}),m.jsxs(BS,{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:[n,!r&&m.jsxs(Sz,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none cursor-pointer",children:[m.jsx(Jo,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zi.displayName="DialogContent";function Vl({className:e,...n}){return m.jsx("div",{className:ge("flex flex-col gap-1.5",e),...n})}function mp({className:e,...n}){return m.jsx("div",{className:ge("flex justify-end gap-2",e),...n})}const Li=k.forwardRef(({className:e,...n},r)=>m.jsx(xz,{ref:r,className:ge("text-lg font-semibold",e),...n}));Li.displayName="DialogTitle";const vs=k.forwardRef(({className:e,...n},r)=>m.jsx(bz,{ref:r,className:ge("text-sm text-muted-foreground",e),...n}));vs.displayName="DialogDescription";var Cz=Object.defineProperty,Ez=(e,n)=>Cz(e,"name",{value:n,configurable:!0}),jz=k.createContext(void 0);function FS(e){const n=k.useContext(jz);return e||n||"ltr"}Ez(FS,"useDirection");var Nz=Object.defineProperty,Az=(e,n)=>Nz(e,"name",{value:n,configurable:!0});function $S(e,[n,r]){return Math.min(r,Math.max(n,e))}Az($S,"clamp");var Tz=Object.defineProperty,Ie=(e,n)=>Tz(e,"name",{value:n,configurable:!0});function VS(e,n){return k.useReducer((r,i)=>n[r][i]??r,e)}Ie(VS,"useStateMachine");var YS="ScrollArea",[QS,dP]=Va(YS),[Oz,ar]=QS(YS),Rz=k.forwardRef(Ie(function(n,r){const{__scopeScrollArea:i,type:o="hover",dir:s,scrollHideDelay:u=600,...d}=n,[h,f]=k.useState(null),[y,p]=k.useState(null),[v,b]=k.useState(null),[w,C]=k.useState(null),[E,j]=k.useState(null),[A,R]=k.useState(0),[B,P]=k.useState(0),[_,q]=k.useState(!1),[I,oe]=k.useState(!1),U=zt(r,f),ne=FS(s);return m.jsx(Oz,{scope:i,type:o,dir:ne,scrollHideDelay:u,scrollArea:h,viewport:y,onViewportChange:p,content:v,onContentChange:b,scrollbarX:w,onScrollbarXChange:C,scrollbarXEnabled:_,onScrollbarXEnabledChange:q,scrollbarY:E,onScrollbarYChange:j,scrollbarYEnabled:I,onScrollbarYEnabledChange:oe,onCornerWidthChange:R,onCornerHeightChange:P,children:m.jsx(et.div,{dir:ne,...d,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":A+"px","--radix-scroll-area-corner-height":B+"px",...n.style}})})},"ScrollArea")),_z="ScrollAreaViewport",Dz=k.forwardRef(Ie(function(n,r){const{__scopeScrollArea:i,children:o,nonce:s,...u}=n,d=ar(_z,i),h=k.useRef(null),f=zt(r,h,d.onViewportChange);return m.jsxs(m.Fragment,{children:[m.jsx(Mz,{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",...n.style},children:m.jsx("div",{ref:d.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})},"ScrollAreaViewport")),Mz=k.memo(Ie(function({nonce:n}){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:n})},"ScrollAreaViewportStyle"),(e,n)=>e.nonce===n.nonce),ia="ScrollAreaScrollbar",zz=k.forwardRef(Ie(function(n,r){const{forceMount:i,...o}=n,s=ar(ia,n.__scopeScrollArea),{onScrollbarXEnabledChange:u,onScrollbarYEnabledChange:d}=s,h=n.orientation==="horizontal";return k.useEffect(()=>(h?u(!0):d(!0),()=>{h?u(!1):d(!1)}),[h,u,d]),s.type==="hover"?m.jsx(Lz,{...o,ref:r,forceMount:i}):s.type==="scroll"?m.jsx(Pz,{...o,ref:r,forceMount:i}):s.type==="auto"?m.jsx(GS,{...o,ref:r,forceMount:i}):s.type==="always"?m.jsx(pp,{...o,ref:r,"data-state":"visible"}):null},"ScrollAreaScrollbar")),Lz=k.forwardRef(Ie(function(n,r){const{forceMount:i,...o}=n,s=ar(ia,n.__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(Nn,{present:i||u,children:m.jsx(GS,{"data-state":u?"visible":"hidden",...o,ref:r})})},"ScrollAreaScrollbarHover")),Pz=k.forwardRef(Ie(function(n,r){const{forceMount:i,...o}=n,s=ar(ia,n.__scopeScrollArea),u=n.orientation==="horizontal",d=ws(()=>f("SCROLL_END"),100),[h,f]=VS("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(Nn,{present:i||h!=="hidden",children:m.jsx(pp,{"data-state":h==="hidden"?"hidden":"visible",...o,ref:r,onPointerEnter:Ye(n.onPointerEnter,()=>f("POINTER_ENTER")),onPointerLeave:Ye(n.onPointerLeave,()=>f("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),GS=k.forwardRef(Ie(function(n,r){const i=ar(ia,n.__scopeScrollArea),{forceMount:o,...s}=n,[u,d]=k.useState(!1),h=n.orientation==="horizontal",f=ws(()=>{if(i.viewport){const y=i.viewport.offsetWidth<i.viewport.scrollWidth,p=i.viewport.offsetHeight<i.viewport.scrollHeight;d(h?y:p)}},10);return Ti(i.viewport,f),Ti(i.content,f),m.jsx(Nn,{present:o||u,children:m.jsx(pp,{"data-state":u?"visible":"hidden",...s,ref:r})})},"ScrollAreaScrollbarAuto")),pp=k.forwardRef(Ie(function(n,r){const{orientation:i="vertical",...o}=n,s=ar(ia,n.__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=gp(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 WS(b,d.current,h,w)}return Ie(v,"getScrollPosition"),i==="horizontal"?m.jsx(Hz,{...p,ref:r,onThumbPositionChange:()=>{if(s.viewport&&u.current){const b=s.viewport.scrollLeft,w=vm(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(Uz,{...p,ref:r,onThumbPositionChange:()=>{if(s.viewport&&u.current){const b=s.viewport.scrollTop,w=vm(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")),Hz=k.forwardRef(Ie(function(n,r){const{sizes:i,onSizesChange:o,...s}=n,u=ar(ia,n.__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(XS,{"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":bs(i)+"px",...n.style},onThumbPointerDown:p=>n.onThumbPointerDown(p.x),onDragScroll:p=>n.onDragScroll(p.x),onWheelScroll:(p,v)=>{if(u.viewport){const b=u.viewport.scrollLeft+p.deltaX;n.onWheelScroll(b),xp(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:rs(d.paddingLeft),paddingEnd:rs(d.paddingRight)}})}})},"ScrollAreaScrollbarX")),Uz=k.forwardRef(Ie(function(n,r){const{sizes:i,onSizesChange:o,...s}=n,u=ar(ia,n.__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(XS,{"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":bs(i)+"px",...n.style},onThumbPointerDown:p=>n.onThumbPointerDown(p.y),onDragScroll:p=>n.onDragScroll(p.y),onWheelScroll:(p,v)=>{if(u.viewport){const b=u.viewport.scrollTop+p.deltaY;n.onWheelScroll(b),xp(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:rs(d.paddingTop),paddingEnd:rs(d.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[Bz,KS]=QS(ia),XS=k.forwardRef(Ie(function(n,r){const{__scopeScrollArea:i,sizes:o,hasThumb:s,onThumbChange:u,onThumbPointerUp:d,onThumbPointerDown:h,onThumbPositionChange:f,onDragScroll:y,onWheelScroll:p,onResize:v,...b}=n,w=ar(ia,i),[C,E]=k.useState(null),j=zt(r,E),A=k.useRef(null),R=k.useRef(""),B=w.viewport,P=o.content-o.viewport,_=kn(p),q=kn(f),I=ws(v,10);function oe(U){if(A.current){const ne=U.clientX-A.current.left,Q=U.clientY-A.current.top;y({x:ne,y:Q})}}return Ie(oe,"handleDragScroll"),k.useEffect(()=>{const U=Ie(ne=>{const Q=ne.target;C?.contains(Q)&&_(ne,P)},"handleWheel");return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[B,C,P,_]),k.useEffect(q,[o,q]),Ti(C,I),Ti(w.content,I),m.jsx(Bz,{scope:i,scrollbar:C,hasThumb:s,onThumbChange:kn(u),onThumbPointerUp:kn(d),onThumbPositionChange:q,onThumbPointerDown:kn(h),children:m.jsx(et.div,{...b,ref:j,style:{position:"absolute",...b.style},onPointerDown:Ye(n.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),A.current=C.getBoundingClientRect(),R.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),oe(U))}),onPointerMove:Ye(n.onPointerMove,oe),onPointerUp:Ye(n.onPointerUp,U=>{const ne=U.target;ne.hasPointerCapture(U.pointerId)&&ne.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=R.current,w.viewport&&(w.viewport.style.scrollBehavior=""),A.current=null})})})},"ScrollAreaScrollbarImpl")),xm="ScrollAreaThumb",Iz=k.forwardRef(Ie(function(n,r){const{forceMount:i,...o}=n,s=KS(xm,n.__scopeScrollArea);return m.jsx(Nn,{present:i||s.hasThumb,children:m.jsx(qz,{ref:r,...o})})},"ScrollAreaThumb")),qz=k.forwardRef(Ie(function(n,r){const{__scopeScrollArea:i,style:o,...s}=n,u=ar(xm,i),d=KS(xm,i),{onThumbPositionChange:h}=d,f=zt(r,d.onThumbChange),y=k.useRef(void 0),p=ws(()=>{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=Vz(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(n.onPointerDownCapture,v=>{const w=v.target.getBoundingClientRect(),C=v.clientX-w.left,E=v.clientY-w.top;d.onThumbPointerDown({x:C,y:E})}),onPointerUp:Ye(n.onPointerUp,d.onThumbPointerUp)})},"ScrollAreaThumbImpl")),ZS="ScrollAreaCorner",Fz=k.forwardRef(Ie(function(n,r){const i=ar(ZS,n.__scopeScrollArea),o=!!(i.scrollbarX&&i.scrollbarY);return i.type!=="scroll"&&o?m.jsx($z,{...n,ref:r}):null},"ScrollAreaCorner")),$z=k.forwardRef(Ie(function(n,r){const{__scopeScrollArea:i,...o}=n,s=ar(ZS,i),[u,d]=k.useState(0),[h,f]=k.useState(0),y=!!(u&&h),{onCornerWidthChange:p,onCornerHeightChange:v}=s;return Ti(s.scrollbarX,()=>{const b=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(b),f(b)}),Ti(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,...n.style}}):null},"ScrollAreaCornerImpl"));function rs(e){return e?parseInt(e,10):0}Ie(rs,"toInt");function gp(e,n){const r=e/n;return isNaN(r)?0:r}Ie(gp,"getThumbRatio");function bs(e){const n=gp(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=(e.scrollbar.size-r)*n;return Math.max(i,18)}Ie(bs,"getThumbSize");function WS(e,n,r,i="ltr"){const o=bs(r),s=o/2,u=n||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 yp([h,f],p)(e)}Ie(WS,"getScrollPositionFromPointer");function vm(e,n,r="ltr"){const i=bs(n),o=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,s=n.scrollbar.size-o,u=n.content-n.viewport,d=s-i,h=r==="ltr"?[0,u]:[u*-1,0],f=$S(e,h);return yp([0,u],[0,d])(f)}Ie(vm,"getThumbOffsetFromScroll");function yp(e,n){return r=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const i=(n[1]-n[0])/(e[1]-e[0]);return n[0]+i*(r-e[0])}}Ie(yp,"linearScale");function xp(e,n){return e>0&&e<n}Ie(xp,"isScrollingWithinScrollbarBounds");var Vz=Ie((e,n=()=>{})=>{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)&&n(),r=s,i=window.requestAnimationFrame(o)}),"loop")(),()=>window.cancelAnimationFrame(i)},"addUnlinkedScrollListener");function ws(e,n){const r=kn(e),i=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(i.current),[]),k.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(r,n)},[r,n])}Ie(ws,"useDebounceCallback");function Ti(e,n){const r=kn(n);fn(()=>{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(Ti,"useResizeObserver");var Yz=Rz,Qz=Dz,Gz=zz,Kz=Iz,Xz=Fz,Zz=Object.defineProperty,JS=(e,n)=>Zz(e,"name",{value:n,configurable:!0}),w0="horizontal",Wz=["horizontal","vertical"],Jz=k.forwardRef(JS(function(n,r){const{decorative:i,orientation:o=w0,...s}=n,u=e2(o)?o:w0,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 e2(e){return Wz.includes(e)}JS(e2,"isValidOrientation");var e6=Jz;const t6=["top","right","bottom","left"],Ba=Math.min,Wr=Math.max,dc=Math.round,Zu=Math.floor,Jr=e=>({x:e,y:e}),n6={left:"right",right:"left",bottom:"top",top:"bottom"};function t2(e,n,r){return Wr(e,Ba(n,r))}function ta(e,n){return typeof e=="function"?e(n):e}function Ia(e){return e.split("-")[0]}function Yl(e){return e.split("-")[1]}function vp(e){return e==="x"?"y":"x"}function bp(e){return e==="y"?"height":"width"}function br(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function wp(e){return vp(br(e))}function r6(e,n,r){r===void 0&&(r=!1);const i=Yl(e),o=wp(e),s=bp(o);let u=o==="x"?i===(r?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[s]>n.floating[s]&&(u=fc(u)),[u,fc(u)]}function a6(e){const n=fc(e);return[bm(e),n,bm(n)]}function bm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const S0=["left","right"],k0=["right","left"],i6=["top","bottom"],l6=["bottom","top"];function o6(e,n,r){switch(e){case"top":case"bottom":return r?n?k0:S0:n?S0:k0;case"left":case"right":return n?i6:l6;default:return[]}}function s6(e,n,r,i){const o=Yl(e);let s=o6(Ia(e),r==="start",i);return o&&(s=s.map(u=>u+"-"+o),n&&(s=s.concat(s.map(bm)))),s}function fc(e){const n=Ia(e);return n6[n]+e.slice(n.length)}function u6(e){var n,r,i,o;return{top:(n=e.top)!=null?n:0,right:(r=e.right)!=null?r:0,bottom:(i=e.bottom)!=null?i:0,left:(o=e.left)!=null?o:0}}function n2(e){return typeof e!="number"?u6(e):{top:e,right:e,bottom:e,left:e}}function hc(e){const{x:n,y:r,width:i,height:o}=e;return{width:i,height:o,top:r,left:n,right:n+i,bottom:r+o,x:n,y:r}}function C0(e,n,r){let{reference:i,floating:o}=e;const s=br(n),u=wp(n),d=bp(u),h=Ia(n),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=Yl(n);return w&&(b[u]+=v*(w==="end"?1:-1)*(r&&f?-1:1)),b}async function c6(e,n){var r;n===void 0&&(n={});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}=ta(n,e),w=n2(b),E=d[v?p==="floating"?"reference":"floating":p],j=hc(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(E)))==null||r?E:E.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(d.floating)),boundary:f,rootBoundary:y,strategy:h})),A=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)),B=await(s.isElement==null?void 0:s.isElement(R))&&await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1},P=hc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:A,offsetParent:R,strategy:h}):A);return{top:(j.top-P.top+w.top)/B.y,bottom:(P.bottom-j.bottom+w.bottom)/B.y,left:(j.left-P.left+w.left)/B.x,right:(P.right-j.right+w.right)/B.x}}const d6=50,f6=async(e,n,r)=>{const{placement:i="bottom",strategy:o="absolute",middleware:s=[],platform:u}=r,d=u.detectOverflow?u:{...u,detectOverflow:c6},h=await(u.isRTL==null?void 0:u.isRTL(n));let f=await u.getElementRects({reference:e,floating:n,strategy:o}),{x:y,y:p}=C0(f,i,h),v=i,b=0;const w={};for(let C=0;C<s.length;C++){const E=s[C];if(!E)continue;const{name:j,fn:A}=E,{x:R,y:B,data:P,reset:_}=await A({x:y,y:p,initialPlacement:i,placement:v,strategy:o,middlewareData:w,rects:f,platform:d,elements:{reference:e,floating:n}});y=R??y,p=B??p,w[j]={...w[j],...P},_&&b<d6&&(b++,typeof _=="object"&&(_.placement&&(v=_.placement),_.rects&&(f=_.rects===!0?await u.getElementRects({reference:e,floating:n,strategy:o}):_.rects),{x:y,y:p}=C0(f,v,h)),C=-1)}return{x:y,y:p,placement:v,strategy:o,middlewareData:w}},h6=e=>({name:"arrow",options:e,async fn(n){const{x:r,y:i,placement:o,rects:s,platform:u,elements:d,middlewareData:h}=n,{element:f,padding:y=0}=ta(e,n)||{};if(f==null)return{};const p=n2(y),v={x:r,y:i},b=wp(o),w=bp(b),C=await u.getDimensions(f),E=b==="y",j=E?"top":"left",A=E?"bottom":"right",R=E?"clientHeight":"clientWidth",B=s.reference[w]+s.reference[b]-v[b]-s.floating[w],P=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=B/2-P/2,oe=q/2-C[w]/2-1,U=Ba(p[j],oe),ne=Ba(p[A],oe),Q=q-C[w]-ne,fe=q/2-C[w]/2+I,le=t2(U,fe,Q),re=!h.arrow&&Yl(o)!=null&&fe!==le&&s.reference[w]/2-(fe<U?U:ne)-C[w]/2<0,L=re?fe<U?fe-U:fe-Q:0;return{[b]:v[b]+L,data:{[b]:le,centerOffset:fe-le-L,...re&&{alignmentOffset:L}},reset:re}}}),m6=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var r,i;const{placement:o,middlewareData:s,rects:u,initialPlacement:d,platform:h,elements:f}=n,{mainAxis:y=!0,crossAxis:p=!0,fallbackPlacements:v,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:C=!0,...E}=ta(e,n);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const j=Ia(o),A=br(d),R=Ia(d)===d,B=await(h.isRTL==null?void 0:h.isRTL(f.floating)),P=v||(R||!C?[fc(d)]:a6(d)),_=w!=="none";!v&&_&&P.push(...s6(d,C,w,B));const q=[d,...P],I=await h.detectOverflow(n,E),oe=[];let U=((i=s.flip)==null?void 0:i.overflows)||[];if(y&&oe.push(I[j]),p){const le=r6(o,u,B);oe.push(I[le[0]],I[le[1]])}if(U=[...U,{placement:o,overflows:oe}],!oe.every(le=>le<=0)){var ne,Q;const le=(((ne=s.flip)==null?void 0:ne.index)||0)+1,re=q[le];if(re&&(!(p==="alignment"?A!==br(re):!1)||U.every(ie=>br(ie.placement)===A?ie.overflows[0]>0:!0)))return{data:{index:le,overflows:U},reset:{placement:re}};let L=(Q=U.filter(Z=>Z.overflows[0]<=0).sort((Z,ie)=>Z.overflows[1]-ie.overflows[1])[0])==null?void 0:Q.placement;if(!L)switch(b){case"bestFit":{var fe;const Z=(fe=U.filter(ie=>{if(_){const he=br(ie.placement);return he===A||he==="y"}return!0}).map(ie=>[ie.placement,ie.overflows.filter(he=>he>0).reduce((he,O)=>he+O,0)]).sort((ie,he)=>ie[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 E0(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function j0(e){return t6.some(n=>e[n]>=0)}const p6=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:r,platform:i}=n,{strategy:o="referenceHidden",...s}=ta(e,n);switch(o){case"referenceHidden":{const u=await i.detectOverflow(n,{...s,elementContext:"reference"}),d=E0(u,r.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:j0(d)}}}case"escaped":{const u=await i.detectOverflow(n,{...s,altBoundary:!0}),d=E0(u,r.floating);return{data:{escapedOffsets:d,escaped:j0(d)}}}default:return{}}}}},r2=new Set(["left","top"]);async function g6(e,n){const{placement:r,platform:i,elements:o}=e,s=await(i.isRTL==null?void 0:i.isRTL(o.floating)),u=Ia(r),d=Yl(r),h=br(r)==="y",f=r2.has(u)?-1:1,y=s&&h?-1:1,p=ta(n,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 y6=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var r,i;const{x:o,y:s,placement:u,middlewareData:d}=n,h=await g6(n,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}}}}},x6=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:r,y:i,placement:o,platform:s}=n,{mainAxis:u=!0,crossAxis:d=!1,limiter:h={fn:A=>{let{x:R,y:B}=A;return{x:R,y:B}}},...f}=ta(e,n),y={x:r,y:i},p=await s.detectOverflow(n,f),v=br(o),b=vp(v);let w=y[b],C=y[v];const E=(A,R)=>t2(R+p[A==="y"?"top":"left"],R,R-p[A==="y"?"bottom":"right"]);u&&(w=E(b,w)),d&&(C=E(v,C));const j=h.fn({...n,[b]:w,[v]:C});return{...j,data:{x:j.x-r,y:j.y-i,enabled:{[b]:u,[v]:d}}}}}},v6=function(e){return e===void 0&&(e={}),{options:e,fn(n){var r,i;const{x:o,y:s,placement:u,rects:d,middlewareData:h}=n,{offset:f=0,mainAxis:y=!0,crossAxis:p=!0}=ta(e,n),v={x:o,y:s},b=br(u),w=vp(b);let C=v[w],E=v[b];const j=ta(f,n),A=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:(r=j.mainAxis)!=null?r:0,crossAxis:(i=j.crossAxis)!=null?i:0};if(y){const P=w==="y"?"height":"width",_=d.reference[w]-d.floating[P]+A.mainAxis,q=d.reference[w]+d.reference[P]-A.mainAxis;C<_?C=_:C>q&&(C=q)}if(p){var R,B;const P=w==="y"?"width":"height",_=r2.has(Ia(u)),q=d.reference[b]-d.floating[P]+(_&&((R=h.offset)==null?void 0:R[b])||0)+(_?0:A.crossAxis),I=d.reference[b]+d.reference[P]+(_?0:((B=h.offset)==null?void 0:B[b])||0)-(_?A.crossAxis:0);E<q?E=q:E>I&&(E=I)}return{[w]:C,[b]:E}}}},b6=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:r,rects:i,platform:o,elements:s}=n,{apply:u=()=>{},...d}=ta(e,n),h=await o.detectOverflow(n,d),f=Ia(r),y=Yl(r),p=br(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 E=b-h.top-h.bottom,j=v-h.left-h.right,A=Ba(b-h[w],E),R=Ba(v-h[C],j),B=n.middlewareData.shift,P=!B;let _=A,q=R;B!=null&&B.enabled.x&&(q=j),B!=null&&B.enabled.y&&(_=E),P&&!y&&(p?q=v-2*Wr(h.left,h.right):_=b-2*Wr(h.top,h.bottom)),await u({...n,availableWidth:q,availableHeight:_});const I=await o.getDimensions(s.floating);return v!==I.width||b!==I.height?{reset:{rects:!0}}:{}}}};function Dc(){return typeof window<"u"}function Ql(e){return a2(e)?(e.nodeName||"").toLowerCase():"#document"}function Cn(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function la(e){var n;return(n=(a2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function a2(e){return Dc()?e instanceof Node||e instanceof Cn(e).Node:!1}function wr(e){return Dc()?e instanceof Element||e instanceof Cn(e).Element:!1}function Ya(e){return Dc()?e instanceof HTMLElement||e instanceof Cn(e).HTMLElement:!1}function N0(e){return!Dc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Cn(e).ShadowRoot}function Mc(e){const{overflow:n,overflowX:r,overflowY:i,display:o}=Sr(e);return/auto|scroll|overlay|hidden|clip/.test(n+i+r)&&o!=="inline"&&o!=="contents"}function w6(e){return/^(table|td|th)$/.test(Ql(e))}function zc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const S6=/transform|translate|scale|rotate|perspective|filter/,k6=/paint|layout|strict|content/,vi=e=>!!e&&e!=="none";let Dh;function Sp(e){const n=wr(e)?Sr(e):e;return vi(n.transform)||vi(n.translate)||vi(n.scale)||vi(n.rotate)||vi(n.perspective)||!kp()&&(vi(n.backdropFilter)||vi(n.filter))||S6.test(n.willChange||"")||k6.test(n.contain||"")}function C6(e){let n=Oi(e);for(;Ya(n)&&!as(n);){if(Sp(n))return n;if(zc(n))return null;n=Oi(n)}return null}function kp(){return Dh==null&&(Dh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Dh}function as(e){return/^(html|body|#document)$/.test(Ql(e))}function Sr(e){return Cn(e).getComputedStyle(e)}function Lc(e){return wr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Oi(e){if(Ql(e)==="html")return e;const n=e.assignedSlot||e.parentNode||N0(e)&&e.host||la(e);return N0(n)?n.host:n}function i2(e){const n=Oi(e);return as(n)?(e.ownerDocument||e).body:Ya(n)&&Mc(n)?n:i2(n)}function is(e,n,r){var i;n===void 0&&(n=[]),r===void 0&&(r=!0);const o=i2(e),s=o===((i=e.ownerDocument)==null?void 0:i.body),u=Cn(o);if(s){const d=wm(u);return n.concat(u,u.visualViewport||[],Mc(o)?o:[],d&&r?is(d):[])}else return n.concat(o,is(o,[],r))}function wm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function l2(e){const n=Sr(e);let r=parseFloat(n.width)||0,i=parseFloat(n.height)||0;const o=Ya(e),s=o?e.offsetWidth:r,u=o?e.offsetHeight:i,d=dc(r)!==s||dc(i)!==u;return d&&(r=s,i=u),{width:r,height:i,$:d}}function Cp(e){return wr(e)?e:e.contextElement}function Ll(e){const n=Cp(e);if(!Ya(n))return Jr(1);const r=n.getBoundingClientRect(),{width:i,height:o,$:s}=l2(n);let u=(s?dc(r.width):r.width)/i,d=(s?dc(r.height):r.height)/o;return(!u||!Number.isFinite(u))&&(u=1),(!d||!Number.isFinite(d))&&(d=1),{x:u,y:d}}const E6=Jr(0);function o2(e){const n=Cn(e);return!kp()||!n.visualViewport?E6:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function j6(e,n,r){return n===void 0&&(n=!1),!!r&&n&&r===Cn(e)}function Ri(e,n,r,i){n===void 0&&(n=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Cp(e);let u=Jr(1);n&&(i?wr(i)&&(u=Ll(i)):u=Ll(e));const d=j6(s,r,i)?o2(s):Jr(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=Cn(s),b=wr(i)?Cn(i):i;let w=v,C=wm(w);for(;C&&b!==w;){const E=Ll(C),j=C.getBoundingClientRect(),A=Sr(C),R=j.left+(C.clientLeft+parseFloat(A.paddingLeft))*E.x,B=j.top+(C.clientTop+parseFloat(A.paddingTop))*E.y;h*=E.x,f*=E.y,y*=E.x,p*=E.y,h+=R,f+=B,w=Cn(C),C=wm(w)}}return hc({width:y,height:p,x:h,y:f})}function Pc(e,n){const r=Lc(e).scrollLeft;return n?n.left+r:Ri(la(e)).left+r}function s2(e,n){const r=e.getBoundingClientRect(),i=r.left+n.scrollLeft-Pc(e,r),o=r.top+n.scrollTop;return{x:i,y:o}}function N6(e){let{elements:n,rect:r,offsetParent:i,strategy:o}=e;const s=o==="fixed",u=la(i),d=n?zc(n.floating):!1;if(i===u||d&&s)return r;let h={scrollLeft:0,scrollTop:0},f=Jr(1);const y=Jr(0),p=Ya(i);if((p||!s)&&((Ql(i)!=="body"||Mc(u))&&(h=Lc(i)),p)){const b=Ri(i);f=Ll(i),y.x=b.x+i.clientLeft,y.y=b.y+i.clientTop}const v=u&&!p&&!s?s2(u,h):Jr(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 A6(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function T6(e){const n=Lc(e),r=e.ownerDocument.body,i=Wr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=Wr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Pc(e);const u=-n.scrollTop;return Sr(r).direction==="rtl"&&(s+=Wr(e.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:u}}const O6=25;function R6(e,n,r){r===void 0&&(r="viewport");const i=r==="layoutViewport",o=Cn(e),s=la(e),u=o.visualViewport;let d=s.clientWidth,h=s.clientHeight,f=0,y=0;if(u){const v=!kp()||n==="fixed";i?v||(f=-u.offsetLeft,y=-u.offsetTop):(d=u.width,h=u.height,v&&(f=u.offsetLeft,y=u.offsetTop))}if(Pc(s)<=0){const v=s.ownerDocument,b=v.body,w=getComputedStyle(b),C=v.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,E=Math.abs(s.clientWidth-b.clientWidth-C),j=getComputedStyle(s).scrollbarGutter==="stable both-edges"?E/2:E;j<=O6&&(d-=j)}return{width:d,height:h,x:f,y}}function _6(e,n){const r=Ri(e,!0,n==="fixed"),i=r.top+e.clientTop,o=r.left+e.clientLeft,s=Ll(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 A0(e,n,r){let i;if(n==="viewport"||n==="layoutViewport")i=R6(e,r,n);else if(n==="document")i=T6(la(e));else if(wr(n))i=_6(n,r);else{const o=o2(e);i={x:n.x-o.x,y:n.y-o.y,width:n.width,height:n.height}}return hc(i)}function D6(e,n){const r=n.get(e);if(r)return r;let i=is(e,[],!1).filter(d=>wr(d)&&Ql(d)!=="body"),o=null;const s=Sr(e).position==="fixed";let u=s?Oi(e):e;for(;wr(u)&&!as(u);){const d=Sr(u),h=Sp(u),f=o?o.position:s?"fixed":"";!h&&(f==="fixed"||f==="absolute"&&d.position==="static")?i=i.filter(p=>p!==u):o=d,u=Oi(u)}return n.set(e,i),i}function M6(e){let{element:n,boundary:r,rootBoundary:i,strategy:o}=e;const u=[...r==="clippingAncestors"?zc(n)?[]:D6(n,this._c):[].concat(r),i],d=A0(n,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=A0(n,u[v],o);h=Wr(b.top,h),f=Ba(b.right,f),y=Ba(b.bottom,y),p=Wr(b.left,p)}return{width:f-p,height:y-h,x:p,y:h}}function z6(e){const{width:n,height:r}=l2(e);return{width:n,height:r}}function L6(e,n,r){const i=Ya(n),o=la(n),s=r==="fixed",u=Ri(e,!0,s,n);let d={scrollLeft:0,scrollTop:0};const h=Jr(0);if((i||!s)&&((Ql(n)!=="body"||Mc(o))&&(d=Lc(n)),i)){const v=Ri(n,!0,s,n);h.x=v.x+n.clientLeft,h.y=v.y+n.clientTop}!i&&o&&(h.x=Pc(o));const f=o&&!i&&!s?s2(o,d):Jr(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 Mh(e){return Sr(e).position==="static"}function T0(e,n){if(!Ya(e)||Sr(e).position==="fixed")return null;if(n)return n(e);let r=e.offsetParent;return la(e)===r&&(r=r.ownerDocument.body),r}function u2(e,n){const r=Cn(e);if(zc(e))return r;if(!Ya(e)){let o=Oi(e);for(;o&&!as(o);){if(wr(o)&&!Mh(o))return o;o=Oi(o)}return r}let i=T0(e,n);for(;i&&w6(i)&&Mh(i);)i=T0(i,n);return i&&as(i)&&Mh(i)&&!Sp(i)?r:i||C6(e)||r}const P6=async function(e){const n=this.getOffsetParent||u2,r=this.getDimensions,i=await r(e.floating);return{reference:L6(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function H6(e){return Sr(e).direction==="rtl"}const U6={convertOffsetParentRelativeRectToViewportRelativeRect:N6,getDocumentElement:la,getClippingRect:M6,getOffsetParent:u2,getElementRects:P6,getClientRects:A6,getDimensions:z6,getScale:Ll,isElement:wr,isRTL:H6};function c2(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function B6(e,n,r){let i=null,o;const s=la(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:E}=v;if(y||n(),!C||!E)return;const j=Zu(w),A=Zu(s.clientWidth-(b+C)),R=Zu(s.clientHeight-(w+E)),B=Zu(b),_={rootMargin:-j+"px "+-A+"px "+-R+"px "+-B+"px",threshold:Wr(0,Ba(1,p))||1};let q=!0;function I(oe){const U=oe[0].intersectionRatio;if(!c2(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=Cn(e),f=()=>d(r);return h.addEventListener("resize",f),d(!0),()=>{h.removeEventListener("resize",f),u()}}function I6(e,n,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=Cp(e),y=o||s?[...f?is(f):[],...n?is(n):[]]:[];y.forEach(j=>{o&&j.addEventListener("scroll",r),s&&j.addEventListener("resize",r)});const p=f&&d?B6(f,r,s):null;let v=-1,b=null;u&&(b=new ResizeObserver(j=>{let[A]=j;A&&A.target===f&&b&&n&&(b.unobserve(n),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(n)})),r()}),f&&!h&&b.observe(f),n&&b.observe(n));let w,C=h?Ri(e):null;h&&E();function E(){const j=Ri(e);C&&!c2(C,j)&&r(),C=j,w=requestAnimationFrame(E)}return r(),()=>{var j;y.forEach(A=>{o&&A.removeEventListener("scroll",r),s&&A.removeEventListener("resize",r)}),p?.(),(j=b)==null||j.disconnect(),b=null,h&&cancelAnimationFrame(w)}}const q6=y6,F6=x6,$6=m6,V6=b6,Y6=p6,O0=h6,Q6=v6,G6=(e,n,r)=>{const i=new Map,o=r??{},s={...U6,...o.platform,_c:i};return f6(e,n,{...o,platform:s})};var K6=typeof document<"u",X6=function(){},tc=K6?k.useLayoutEffect:X6;function mc(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let r,i,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==n.length)return!1;for(i=r;i--!==0;)if(!mc(e[i],n[i]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!{}.hasOwnProperty.call(n,o[i]))return!1;for(i=r;i--!==0;){const s=o[i];if(!(s==="_owner"&&e.$$typeof)&&!mc(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}function d2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function R0(e,n){const r=d2(e);return Math.round(n*r)/r}function zh(e){const n=k.useRef(e);return tc(()=>{n.current=e}),n}function Z6(e){e===void 0&&(e={});const{placement:n="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:n,middlewareData:{},isPositioned:!1}),[v,b]=k.useState(i);mc(v,i)||b(i);const[w,C]=k.useState(null),[E,j]=k.useState(null),A=k.useCallback(ie=>{ie!==_.current&&(_.current=ie,C(ie))},[]),R=k.useCallback(ie=>{ie!==q.current&&(q.current=ie,j(ie))},[]),B=s||w,P=u||E,_=k.useRef(null),q=k.useRef(null),I=k.useRef(y),oe=h!=null,U=zh(h),ne=zh(o),Q=zh(f),fe=k.useCallback(()=>{if(!_.current||!q.current)return;const ie={placement:n,strategy:r,middleware:v};ne.current&&(ie.platform=ne.current),G6(_.current,q.current,ie).then(he=>{const O={...he,isPositioned:Q.current!==!1};le.current&&!mc(I.current,O)&&(I.current=O,yc.flushSync(()=>{p(O)}))})},[v,n,r,ne,Q]);tc(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(ie=>({...ie,isPositioned:!1})))},[f]);const le=k.useRef(!1);tc(()=>(le.current=!0,()=>{le.current=!1}),[]),tc(()=>{if(B&&(_.current=B),P&&(q.current=P),B&&P){if(U.current)return U.current(B,P,fe);fe()}},[B,P,fe,U,oe]);const re=k.useMemo(()=>({reference:_,floating:q,setReference:A,setFloating:R}),[A,R]),L=k.useMemo(()=>({reference:B,floating:P}),[B,P]),Z=k.useMemo(()=>{const ie={position:r,left:0,top:0};if(!L.floating)return ie;const he=R0(L.floating,y.x),O=R0(L.floating,y.y);return d?{...ie,transform:"translate("+he+"px, "+O+"px)",...d2(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 W6=e=>{function n(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&&n(i)?i.current!=null?O0({element:i.current,padding:o}).fn(r):{}:i?O0({element:i,padding:o}).fn(r):{}}}},J6=(e,n)=>{const r=q6(e);return{name:r.name,fn:r.fn,options:[e,n]}},eL=(e,n)=>{const r=F6(e);return{name:r.name,fn:r.fn,options:[e,n]}},tL=(e,n)=>({fn:Q6(e).fn,options:[e,n]}),nL=(e,n)=>{const r=$6(e);return{name:r.name,fn:r.fn,options:[e,n]}},rL=(e,n)=>{const r=V6(e);return{name:r.name,fn:r.fn,options:[e,n]}},aL=(e,n)=>{const r=Y6(e);return{name:r.name,fn:r.fn,options:[e,n]}},iL=(e,n)=>{const r=W6(e);return{name:r.name,fn:r.fn,options:[e,n]}};var lL=Object.defineProperty,oL=(e,n)=>lL(e,"name",{value:n,configurable:!0});function f2(e){const[n,r]=k.useState(void 0);return fn(()=>{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]),n}oL(f2,"useSize");var sL=Object.defineProperty,Ua=(e,n)=>sL(e,"name",{value:n,configurable:!0}),h2="Popper",[m2,Gl]=Va(h2),[uL,p2]=m2(h2),cL=Ua(e=>{const{__scopePopper:n,children:r}=e,[i,o]=k.useState(null),[s,u]=k.useState(void 0);return m.jsx(uL,{scope:n,anchor:i,onAnchorChange:o,placementState:s,setPlacementState:u,children:r})},"Popper"),dL="PopperAnchor",fL=k.forwardRef(Ua(function(n,r){const{__scopePopper:i,virtualRef:o,...s}=n,u=p2(dL,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&&Hc(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")),g2="PopperContent",[hL,fP]=m2(g2),mL=k.forwardRef(Ua(function(n,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,...E}=n,j=p2(g2,i),[A,R]=k.useState(null),B=zt(r,R),[P,_]=k.useState(null),q=f2(P),I=q?.width??0,oe=q?.height??0,U=o+(u!=="center"?"-"+u:""),ne=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Q=Array.isArray(y)?y:[y],fe=Q.length>0,le={padding:ne,boundary:Q.filter(y2),altBoundary:fe},{refs:re,floatingStyles:L,placement:Z,isPositioned:ie,middlewareData:he}=Z6({strategy:"fixed",placement:U,whileElementsMounted:Ua((...ue)=>I6(...ue,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:j.anchor},middleware:[J6({mainAxis:s+oe,alignmentAxis:d}),f&&eL({mainAxis:!0,crossAxis:!1,limiter:v==="partial"?tL():void 0,...le}),f&&nL({...le}),rL({...le,apply:Ua(({elements:ue,rects:tt,availableWidth:bt,availableHeight:It})=>{const{width:Zt,height:Et}=tt.reference,An=ue.floating.style;An.setProperty("--radix-popper-available-width",`${bt}px`),An.setProperty("--radix-popper-available-height",`${It}px`),An.setProperty("--radix-popper-anchor-width",`${Zt}px`),An.setProperty("--radix-popper-anchor-height",`${Et}px`)},"apply")}),P&&iL({element:P,padding:h}),pL({arrowWidth:I,arrowHeight:oe}),b&&aL({strategy:"referenceHidden",...le,boundary:fe?le.boundary:void 0})]}),O=j.setPlacementState;fn(()=>(O(Z),()=>{O(void 0)}),[Z,O]);const[M,z]=Hc(Z),T=kn(C);fn(()=>{ie&&T?.()},[ie,T]);const G=he.arrow?.x,K=he.arrow?.y,J=he.arrow?.centerOffset!==0,[me,Ne]=k.useState();return fn(()=>{A&&Ne(window.getComputedStyle(A).zIndex)},[A]),m.jsx("div",{ref:re.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:ie?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:n.dir,children:m.jsx(hL,{scope:i,placedSide:M,placedAlign:z,onArrowChange:_,arrowX:G,arrowY:K,shouldHideArrow:J,children:m.jsx(et.div,{"data-side":M,"data-align":z,...E,ref:B,style:{...E.style,animation:ie?E.style?.animation:"none"}})})})},"PopperContent"));function y2(e){return e!==null}Ua(y2,"isNotNull");var pL=Ua(e=>({name:"transformOrigin",options:e,fn(n){const{placement:r,rects:i,middlewareData:o}=n,u=o.arrow?.centerOffset!==0,d=u?0:e.arrowWidth,h=u?0:e.arrowHeight,[f,y]=Hc(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 Hc(e){const[n,r="center"]=e.split("-");return[n,r]}Ua(Hc,"getSideAndAlignFromPlacement");var Ep=cL,Uc=fL,jp=mL,gL=Object.defineProperty,yL=(e,n)=>gL(e,"name",{value:n,configurable:!0}),xL=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"}),vL=k.forwardRef(yL(function(n,r){return m.jsx(et.span,{...n,ref:r,style:{...xL,...n.style}})},"VisuallyHidden")),bL=vL,wL=Object.defineProperty,Vt=(e,n)=>wL(e,"name",{value:n,configurable:!0}),[Np,hP]=Va("Tooltip",[Gl]),Ap=Gl(),SL="TooltipProvider",kL=700,Sm="tooltip.open",[CL,Tp]=Np(SL),EL=Vt(e=>{const{__scopeTooltip:n,delayDuration:r=kL,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(CL,{scope:n,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"),km="Tooltip",[jL,Ss]=Np(km),NL=Vt(e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:s,disableHoverableContent:u,delayDuration:d}=e,h=Tp(km,e.__scopeTooltip),f=Ap(n),[y,p]=k.useState(null),[v,b]=k.useState(void 0),w=qn(),C=k.useRef(0),E=u??h.disableHoverableContent,j=d??h.delayDuration,A=k.useRef(!1),[R,B]=Fl({prop:i,defaultProp:o??!1,onChange:Vt(U=>{U?(h.onOpen(),document.dispatchEvent(new CustomEvent(Sm))):h.onClose(),s?.(U)},"onChange"),caller:km}),P=k.useMemo(()=>R?A.current?"delayed-open":"instant-open":"closed",[R]),_=k.useCallback(()=>{window.clearTimeout(C.current),C.current=0,A.current=!1,B(!0)},[B]),q=k.useCallback(()=>{window.clearTimeout(C.current),C.current=0,B(!1)},[B]),I=k.useCallback(()=>{window.clearTimeout(C.current),C.current=window.setTimeout(()=>{A.current=!0,B(!0),C.current=0},j)},[j,B]);k.useEffect(()=>()=>{C.current&&(window.clearTimeout(C.current),C.current=0)},[]);const oe=v??w;return m.jsx(Ep,{...f,children:m.jsx(jL,{scope:n,contentId:oe,setContentId:b,open:R,stateAttribute:P,trigger:y,onTriggerChange:p,onTriggerEnter:k.useCallback(()=>{h.isOpenDelayedRef.current?I():_()},[h.isOpenDelayedRef,I,_]),onTriggerLeave:k.useCallback(()=>{E?q():(window.clearTimeout(C.current),C.current=0)},[q,E]),onOpen:_,onClose:q,disableHoverableContent:E,children:r})})},"Tooltip"),_0="TooltipTrigger",AL=k.forwardRef(Vt(function(n,r){const{__scopeTooltip:i,...o}=n,s=Ss(_0,i),u=Tp(_0,i),d=Ap(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(Uc,{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(n.onPointerMove,b=>{b.pointerType!=="touch"&&!p.current&&!u.isPointerInTransitRef.current&&(s.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ye(n.onPointerLeave,()=>{s.onTriggerLeave(),p.current=!1}),onPointerDown:Ye(n.onPointerDown,()=>{s.open&&s.onClose(),y.current=!0,document.addEventListener("pointerup",v,{once:!0})}),onFocus:Ye(n.onFocus,()=>{y.current||s.onOpen()}),onBlur:Ye(n.onBlur,s.onClose),onClick:Ye(n.onClick,s.onClose)})})},"TooltipTrigger")),x2="TooltipPortal",[TL,OL]=Np(x2,{forceMount:void 0}),RL=Vt(e=>{const{__scopeTooltip:n,forceMount:r,children:i,container:o}=e,s=Ss(x2,n);return m.jsx(TL,{scope:n,forceMount:r,children:m.jsx(Nn,{present:r||s.open,children:m.jsx(Oc,{asChild:!0,container:o,children:i})})})},"TooltipPortal"),ls="TooltipContent",_L=k.forwardRef(Vt(function(n,r){const i=OL(ls,n.__scopeTooltip),{forceMount:o=i.forceMount,side:s="top",...u}=n,d=Ss(ls,n.__scopeTooltip);return m.jsx(Nn,{present:o||d.open,children:d.disableHoverableContent?m.jsx(v2,{side:s,...u,ref:r}):m.jsx(DL,{side:s,...u,ref:r})})},"TooltipContent")),DL=k.forwardRef(Vt(function(n,r){const i=Ss(ls,n.__scopeTooltip),o=Tp(ls,n.__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,E)=>{const j=C.currentTarget,A={x:C.clientX,y:C.clientY},R=b2(A,j.getBoundingClientRect()),B=w2(A,R),P=S2(E.getBoundingClientRect()),_=C2([...B,...P]);h(_),v(!0)},[v]);return k.useEffect(()=>()=>b(),[b]),k.useEffect(()=>{if(f&&p){const C=Vt(j=>w(j,p),"handleTriggerLeave"),E=Vt(j=>w(j,f),"handleContentLeave");return f.addEventListener("pointerleave",C),p.addEventListener("pointerleave",E),()=>{f.removeEventListener("pointerleave",C),p.removeEventListener("pointerleave",E)}}},[f,p,w,b]),k.useEffect(()=>{if(d){const C=Vt(E=>{const j=E.target,A={x:E.clientX,y:E.clientY},R=f?.contains(j)||p?.contains(j),B=!k2(A,d);R?b():B&&(b(),y())},"handleTrackPointerGrace");return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[f,p,d,y,b]),m.jsx(v2,{...n,ref:u})},"TooltipContentHoverable")),ML=Zw("TooltipContent"),v2=k.forwardRef(Vt(function(n,r){const{__scopeTooltip:i,children:o,"aria-label":s,id:u,onEscapeKeyDown:d,onPointerDownOutside:h,...f}=n,y=Ss(ls,i),p=Ap(i),{onClose:v}=y;k.useEffect(()=>(document.addEventListener(Sm,v),()=>document.removeEventListener(Sm,v)),[v]),k.useEffect(()=>{if(y.trigger){const w=Vt(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 fn(()=>(b(u),()=>{b(void 0)}),[u,b]),m.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:w=>w.preventDefault(),onDismiss:v,children:m.jsxs(jp,{"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(ML,{children:o}),s?m.jsx(bL,{id:y.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function b2(e,n){const r=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),s=Math.abs(n.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")}}Vt(b2,"getExitSideFromRect");function w2(e,n,r=5){const i=[];switch(n){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}Vt(w2,"getPaddedExitPoints");function S2(e){const{top:n,right:r,bottom:i,left:o}=e;return[{x:o,y:n},{x:r,y:n},{x:r,y:i},{x:o,y:i}]}Vt(S2,"getPointsFromRect");function k2(e,n){const{x:r,y:i}=e;let o=!1;for(let s=0,u=n.length-1;s<n.length;u=s++){const d=n[s],h=n[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}Vt(k2,"isPointInPolygon");function C2(e){const n=e.slice();return n.sort((r,i)=>r.x<i.x?-1:r.x>i.x?1:r.y<i.y?-1:r.y>i.y?1:0),E2(n)}Vt(C2,"getHull");function E2(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(;n.length>=2;){const s=n[n.length-1],u=n[n.length-2];if((s.x-u.x)*(o.y-u.y)>=(s.y-u.y)*(o.x-u.x))n.pop();else break}n.push(o)}n.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(),n.length===1&&r.length===1&&n[0].x===r[0].x&&n[0].y===r[0].y?n:n.concat(r)}Vt(E2,"getHullPresorted");var zL=EL,LL=NL,PL=AL,HL=RL,UL=_L;const Op=k.forwardRef(({className:e,children:n,...r},i)=>m.jsxs(Yz,{ref:i,className:ge("relative overflow-hidden",e),...r,children:[m.jsx(Qz,{className:"h-full w-full rounded-[inherit]",children:n}),m.jsx(Gz,{orientation:"vertical",className:"flex touch-none select-none transition-colors p-0.5 w-2.5",children:m.jsx(Kz,{className:"relative flex-1 rounded-full bg-border"})}),m.jsx(Xz,{})]}));Op.displayName="ScrollArea";const BL=k.forwardRef(({className:e,orientation:n="horizontal",decorative:r=!0,...i},o)=>m.jsx(e6,{ref:o,decorative:r,orientation:n,className:ge("shrink-0 bg-border",n==="horizontal"?"h-px w-full":"h-full w-px",e),...i}));BL.displayName="Separator";const IL=zL,qL=LL,FL=PL,j2=k.forwardRef(({className:e,sideOffset:n=4,...r},i)=>m.jsx(HL,{children:m.jsx(UL,{ref:i,sideOffset:n,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})}));j2.displayName="TooltipContent";function $L(e){const{data:n}=kc(e);return(n?.comments??[]).filter(r=>r.status==="open"&&r.thread.at(-1)?.role!=="author").length}function VL(e){const n=Math.floor(e/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60);return r<60?`${r}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(r/60)}h ${String(r%60).padStart(2,"0")}m`}function YL(e,n,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:n?Date.parse(n):i;return Math.max(0,u-s)}function N2({run:e,className:n}){const r=wc(e),i=YL(e?.createdAt,e?.finishedAt,r);return i==null?null:m.jsx("span",{className:ge("tabular-nums",n),title:r?"Working time so far":"Total run time",children:VL(i)})}function QL(){const e=Ce(w=>w.domainId),n=fs(e),r=Um(e),i=Zr(w=>w.setRun),o=Zr(w=>w.setDrawer),s=$L(e),[u,d]=k.useState(!1),h=Bt(),f=wc(r),y=n.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(cn,{className:"h-4 w-4 animate-spin"})," Agent working…",m.jsx(N2,{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`:`${n.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(cn,{className:"h-4 w-4 animate-spin"}):m.jsx(Lm,{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(ds,{className:"h-4 w-4"})})]})}function GL(e){switch(e.kind){case"message":return{icon:m.jsx(Ci,{className:"h-3.5 w-3.5"}),tone:"text-primary"};case"thinking":return{icon:m.jsx(ds,{className:"h-3.5 w-3.5"}),tone:"text-muted-foreground"};case"reply":return{icon:m.jsx(f1,{className:"h-3.5 w-3.5"}),tone:"text-success"};case"error":return{icon:m.jsx(vc,{className:"h-3.5 w-3.5"}),tone:"text-destructive"};case"tool":{const n=e.tool??"";return n==="Edit"||n==="Write"||n==="MultiEdit"?{icon:m.jsx(AN,{className:"h-3.5 w-3.5"}),tone:"text-warning"}:n==="Bash"?{icon:m.jsx($A,{className:"h-3.5 w-3.5"}),tone:"text-foreground/70"}:{icon:m.jsx(eT,{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 KL(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)}k`:`${(e/1e6).toFixed(1)}M`}const XL=k.memo(function({e:n}){const{icon:r,tone:i}=GL(n),o=n.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:n.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:n.tool}),n.target&&m.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:n.target})]}):n.kind==="message"||n.kind==="reply"?m.jsx(Gw,{text:n.text}):m.jsx("p",{className:ge("whitespace-pre-wrap break-words text-[13px] leading-relaxed",o?"italic text-muted-foreground":"text-foreground/90"),children:n.text})})]})}),ZL={queued:"warning",running:"warning",succeeded:"success",failed:"destructive",canceled:"muted",interrupted:"warning"};function D0({title:e,text:n}){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:n})]})}function WL({prompt:e,onClose:n}){return m.jsx($l,{open:!0,onOpenChange:r=>!r&&n(),children:m.jsxs(zi,{className:"max-w-4xl",children:[m.jsx(Vl,{children:m.jsx(Li,{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(D0,{title:"Turn prompt (stdin)",text:e.turnPrompt}),m.jsx(D0,{title:"System appendix (--append-system-prompt)",text:e.systemPrompt})]})]})})}function JL(){const e=Zr(I=>I.drawerOpen),n=Zr(I=>I.setDrawer),r=Ce(I=>I.domainId),i=Ce(I=>I.setSection),o=Um(r),s=fs(r),u=Zr(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),E=k.useRef(null),j=wc(o),A=o?.events??[],R=s.data?.conversation,B=R?.turns??0,P=async()=>{if(!(!r||y||j)){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||j)){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&&E.current&&(E.current.scrollTop=E.current.scrollHeight)},[A.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=oe=>{oe.key==="Escape"&&n(!1)};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e,n]),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",j?"bg-warning/15 text-warning":"bg-primary/15 text-primary"),children:j?m.jsx(cn,{className:"h-4 w-4 animate-spin"}):m.jsx(Wj,{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:ZL[o.status],className:"ml-1 capitalize",children:o.status}),o&&m.jsx(N2,{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:()=>n(!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(Jo,{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(VN,{className:"h-3.5 w-3.5 shrink-0 opacity-70"}),m.jsxs("span",{className:"min-w-0 truncate",children:["Conversation · ",B," turn",B===1?"":"s",m.jsx("span",{className:"opacity-60",children:" · the agent remembers earlier turns"})]}),m.jsxs("button",{type:"button",onClick:P,disabled:j||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(cn,{className:"h-3 w-3 animate-spin"}):m.jsx(OA,{className:"h-3 w-3"})," ","Start fresh"]})]}),m.jsx(Op,{className:"flex-1 min-h-0",children:m.jsx("div",{ref:E,className:"h-full overflow-y-auto overflow-x-hidden py-1.5",children:o?A.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:A.map(I=>m.jsx(XL,{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:j?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(cn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Jo,{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(ra,{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:["· ",KL(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(cn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(SA,{className:"h-3.5 w-3.5"})," ","Resume"]}):m.jsxs(Ke,{size:"sm",variant:"outline",onClick:()=>{n(!1),i("comments")},children:[m.jsx(Ci,{className:"h-3.5 w-3.5"})," View replies"]})]}):null})]}),w&&o?.prompt&&m.jsx(WL,{prompt:o.prompt,onClose:()=>C(!1)})]}):null}async function e8(e,n,r,i){const o=await fetch(`/api/domain/${encodeURIComponent(e)}/agent/ask`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),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 t8=(e,n)=>`${e}::${n}`,bi=new Map,nr=bc((e,n)=>({entries:{},openKey:null,start:(r,i,o,s,u)=>{const d=t8(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=n().entries[r];if(!o)return;bi.get(r)?.abort();const s=new AbortController;bi.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});e8(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:n().openKey===r}))}).catch(d=>{s.signal.aborted||u(h=>({...h,status:"error",error:String(d),seen:n().openKey===r}))})},recompose:r=>{bi.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=>{bi.get(r)?.abort(),bi.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:(bi.get(s)?.abort(),bi.delete(s));return{entries:o,openKey:i.openKey&&o[i.openKey]?i.openKey:null}})}));var n8=Object.defineProperty,oa=(e,n)=>n8(e,"name",{value:n,configurable:!0}),Rp="Popover",[A2,mP]=Va(Rp,[Gl]),Bc=Gl(),[r8,Pi]=A2(Rp),a8=oa(e=>{const{__scopePopover:n,children:r,open:i,defaultOpen:o,onOpenChange:s,modal:u=!1}=e,d=Bc(n),h=k.useRef(null),[f,y]=k.useState(!1),[p,v]=Fl({prop:i,defaultProp:o??!1,onChange:s,caller:Rp});return m.jsx(Ep,{...d,children:m.jsx(r8,{scope:n,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"),i8="PopoverAnchor",l8=k.forwardRef(oa(function(n,r){const{__scopePopover:i,...o}=n,s=Pi(i8,i),u=Bc(i),{onCustomAnchorAdd:d,onCustomAnchorRemove:h}=s;return k.useEffect(()=>(d(),()=>h()),[d,h]),m.jsx(Uc,{...u,...o,ref:r})},"PopoverAnchor")),o8="PopoverTrigger",s8=k.forwardRef(oa(function(n,r){const{__scopePopover:i,...o}=n,s=Pi(o8,i),u=Bc(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":_p(s.open),...o,ref:d,onClick:Ye(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?h:m.jsx(Uc,{asChild:!0,...u,children:h})},"PopoverTrigger")),T2="PopoverPortal",[u8,c8]=A2(T2,{forceMount:void 0}),d8=oa(e=>{const{__scopePopover:n,forceMount:r,children:i,container:o}=e,s=Pi(T2,n);return m.jsx(u8,{scope:n,forceMount:r,children:m.jsx(Nn,{present:r||s.open,children:m.jsx(Oc,{asChild:!0,container:o,children:i})})})},"PopoverPortal"),os="PopoverContent",f8=k.forwardRef(oa(function(n,r){const i=c8(os,n.__scopePopover),{forceMount:o=i.forceMount,...s}=n,u=Pi(os,n.__scopePopover);return m.jsx(Nn,{present:o||u.open,children:u.modal?m.jsx(m8,{...s,ref:r}):m.jsx(p8,{...s,ref:r})})},"PopoverContent")),h8=ys("PopoverContent.RemoveScroll"),m8=k.forwardRef(oa(function(n,r){const i=Pi(os,n.__scopePopover),o=k.useRef(null),s=zt(r,o),u=k.useRef(!1);return k.useEffect(()=>{const d=o.current;if(d)return DS(d)},[]),m.jsx(dp,{as:h8,allowPinchZoom:!0,children:m.jsx(O2,{...n,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ye(n.onCloseAutoFocus,d=>{d.preventDefault(),u.current||i.triggerRef.current?.focus()}),onPointerDownOutside:Ye(n.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(n.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),p8=k.forwardRef(oa(function(n,r){const i=Pi(os,n.__scopePopover),o=k.useRef(!1),s=k.useRef(!1);return m.jsx(O2,{...n,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:u=>{n.onCloseAutoFocus?.(u),u.defaultPrevented||(o.current||i.triggerRef.current?.focus(),u.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:u=>{n.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")),O2=k.forwardRef(oa(function(n,r){const{__scopePopover:i,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:u,disableOutsidePointerEvents:d,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:y,onInteractOutside:p,...v}=n,b=Pi(os,i),w=Bc(i);return Rc(),m.jsx(mS,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:u,children:m.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:d,onInteractOutside:p,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:y,onDismiss:()=>b.onOpenChange(!1),deferPointerDownOutside:!0,children:m.jsx(jp,{"data-state":_p(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 _p(e){return e?"open":"closed"}oa(_p,"getState");var g8=a8,y8=l8,x8=s8,v8=d8,b8=f8;const Hi=g8,Ic=x8,Dp=y8,Qa=k.forwardRef(({className:e,align:n="start",side:r="right",sideOffset:i=8,...o},s)=>m.jsx(v8,{children:m.jsx(b8,{ref:s,align:n,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})}));Qa.displayName="PopoverContent";const Er=k.forwardRef(({className:e,...n},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),...n}));Er.displayName="Textarea";function w8(e){const n=e.ref;let r=null;try{n.startsWith("module.")?r=document.querySelector(`.react-flow__node[data-id="grp-${n.slice(7)}"]`):n.startsWith("edge.")?r=document.querySelector(`.react-flow__edge[data-id="edge-${n.slice(5)}"]`):r=document.querySelector(`.react-flow__node[data-id="${n}"]`)||document.querySelector(`[data-anchor-ref="${n}"]`)}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 S8({entry:e}){const n=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&&n(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(ds,{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(gA,{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(Jo,{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(cn,{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(Er,{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(Lm,{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 k8({entry:e,pos:n}){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(Hi,{open:u,modal:!1,onOpenChange:h=>{h?i(e.key):e.status==="composing"?s(e.key):o()},children:[m.jsx(Dp,{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:n.x,top:n.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(cn,{className:"h-3 w-3 animate-spin"}):m.jsx(ds,{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(Qa,{side:"bottom",align:"start",sideOffset:8,className:"w-96",onInteractOutside:h=>{e.status==="composing"&&h.preventDefault()},children:m.jsx(S8,{entry:e})})]})}function C8(){const e=Ce(d=>d.domainId),n=nr(d=>d.entries),r=nr(d=>d.keepOnly),i=Object.values(n).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=w8(w);p[b]=C;const E=y[b];(!E||E.x!==C.x||E.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(k8,{entry:d,pos:o[d.key]},d.key):null)})}var M0=1,E8=.9,j8=.8,N8=.17,Lh=.1,Ph=.999,A8=.9999,T8=.99,O8=/[\\\/_+.#"@\[\(\{&]/,R8=/[\\\/_+.#"@\[\(\{&]/g,_8=/[\s-]/,R2=/[\s-]/g;function Cm(e,n,r,i,o,s,u){if(s===n.length)return o===e.length?M0:T8;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=Cm(e,n,r,i,f+1,s+1,u),p>y&&(f===o?p*=M0:O8.test(e.charAt(f-1))?(p*=j8,b=e.slice(o,f-1).match(R8),b&&o>0&&(p*=Math.pow(Ph,b.length))):_8.test(e.charAt(f-1))?(p*=E8,w=e.slice(o,f-1).match(R2),w&&o>0&&(p*=Math.pow(Ph,w.length))):(p*=N8,o>0&&(p*=Math.pow(Ph,f-o))),e.charAt(f)!==n.charAt(s)&&(p*=A8)),(p<Lh&&r.charAt(f-1)===i.charAt(s+1)||i.charAt(s+1)===i.charAt(s)&&r.charAt(f-1)!==i.charAt(s))&&(v=Cm(e,n,r,i,f+1,s+2,u),v*Lh>p&&(p=v*Lh)),p>y&&(y=p),f=r.indexOf(h,f+1);return u[d]=y,y}function z0(e){return e.toLowerCase().replace(R2," ")}function D8(e,n,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,Cm(e,n,z0(e),z0(n),0,0,{})}var Qo='[cmdk-group=""]',Hh='[cmdk-group-items=""]',M8='[cmdk-group-heading=""]',_2='[cmdk-item=""]',L0=`${_2}:not([aria-disabled="true"])`,Em="cmdk-item-select",Dl="data-value",z8=(e,n,r)=>D8(e,n,r),D2=k.createContext(void 0),ks=()=>k.useContext(D2),M2=k.createContext(void 0),Mp=()=>k.useContext(M2),z2=k.createContext(void 0),L2=k.forwardRef((e,n)=>{let r=Ml(()=>{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=Ml(()=>new Set),o=Ml(()=>new Map),s=Ml(()=>new Map),u=Ml(()=>new Set),d=P2(e),{label:h,children:f,value:y,onValueChange:p,filter:v,shouldFilter:b,loop:w,disablePointerSelection:C=!1,vimBindings:E=!0,...j}=e,A=qn(),R=qn(),B=qn(),P=k.useRef(null),_=Y8();_i(()=>{if(y!==void 0){let z=y.trim();r.current.value=z,q.emit()}},[y]),_i(()=>{_(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")Q(),U(),_(1,ne);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ue=document.getElementById(B);ue?ue.focus():(K=document.getElementById(A))==null||K.focus()}if(_(7,()=>{var ue;r.current.selectedItemId=(ue=le())==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,oe(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,()=>{Q(),U(),r.current.value||ne(),q.emit()}),()=>{s.current.delete(z),i.current.delete(z),r.current.filtered.items.delete(z);let G=le();_(4,()=>{Q(),G?.getAttribute("id")===z&&ne(),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:A,inputId:B,labelId:R,listInnerRef:P}),[]);function oe(z,T){var G,K;let J=(K=(G=d.current)==null?void 0:G.filter)!=null?K:z8;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=P.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(Hh);J?J.appendChild(K.parentElement===J?K:K.closest(`${Hh} > *`)):G.appendChild(K.parentElement===G?K:K.closest(`${Hh} > *`))}),T.sort((K,J)=>J[1]-K[1]).forEach(K=>{var J;let me=(J=P.current)==null?void 0:J.querySelector(`${Qo}[${Dl}="${encodeURIComponent(K[0])}"]`);me?.parentElement.appendChild(me)})}function ne(){let z=re().find(G=>G.getAttribute("aria-disabled")!=="true"),T=z?.getAttribute(Dl);q.setState("value",T||void 0)}function Q(){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=oe(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=le();K&&(((z=K.parentElement)==null?void 0:z.firstChild)===K&&((G=(T=K.closest(Qo))==null?void 0:T.querySelector(M8))==null||G.scrollIntoView({block:"nearest"})),K.scrollIntoView({block:"nearest"}))}function le(){var z;return(z=P.current)==null?void 0:z.querySelector(`${_2}[aria-selected="true"]`)}function re(){var z;return Array.from(((z=P.current)==null?void 0:z.querySelectorAll(L0))||[])}function L(z){let T=re()[z];T&&q.setState("value",T.getAttribute(Dl))}function Z(z){var T;let G=le(),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(Dl))}function ie(z){let T=le(),G=T?.closest(Qo),K;for(;G&&!K;)G=z>0?$8(G,Qo):V8(G,Qo),K=G?.querySelector(L0);K?q.setState("value",K.getAttribute(Dl)):Z(z)}let he=()=>L(re().length-1),O=z=>{z.preventDefault(),z.metaKey?he():z.altKey?ie(1):Z(1)},M=z=>{z.preventDefault(),z.metaKey?L(0):z.altKey?ie(-1):Z(-1)};return k.createElement(et.div,{ref:n,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:z=>{var T;(T=j.onKeyDown)==null||T.call(j,z);let G=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||G))switch(z.key){case"n":case"j":{E&&z.ctrlKey&&O(z);break}case"ArrowDown":{O(z);break}case"p":case"k":{E&&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=le();if(K){let J=new Event(Em);K.dispatchEvent(J)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:I.inputId,id:I.labelId,style:G8},h),qc(e,z=>k.createElement(M2.Provider,{value:q},k.createElement(D2.Provider,{value:I},z))))}),L8=k.forwardRef((e,n)=>{var r,i;let o=qn(),s=k.useRef(null),u=k.useContext(z2),d=ks(),h=P2(e),f=(i=(r=h.current)==null?void 0:r.forceMount)!=null?i:u?.forceMount;_i(()=>{if(!f)return d.item(o,u?.id)},[f]);let y=H2(o,s,[e.value,e.children,s],e.keywords),p=Mp(),v=qa(_=>_.value&&_.value===y.current),b=qa(_=>f||d.filter()===!1?!0:_.search?_.filtered.items.get(o)>0:!0);k.useEffect(()=>{let _=s.current;if(!(!_||e.disabled))return _.addEventListener(Em,w),()=>_.removeEventListener(Em,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:E,value:j,onSelect:A,forceMount:R,keywords:B,...P}=e;return k.createElement(et.div,{ref:Ai(s,n),...P,id:o,"cmdk-item":"",role:"option","aria-disabled":!!E,"aria-selected":!!v,"data-disabled":!!E,"data-selected":!!v,onPointerMove:E||d.getDisablePointerSelection()?void 0:C,onClick:E?void 0:w},e.children)}),P8=k.forwardRef((e,n)=>{let{heading:r,children:i,forceMount:o,...s}=e,u=qn(),d=k.useRef(null),h=k.useRef(null),f=qn(),y=ks(),p=qa(b=>o||y.filter()===!1?!0:b.search?b.filtered.groups.has(u):!0);_i(()=>y.group(u),[]),H2(u,d,[e.value,e.heading,h]);let v=k.useMemo(()=>({id:u,forceMount:o}),[o]);return k.createElement(et.div,{ref:Ai(d,n),...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),qc(e,b=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?f:void 0},k.createElement(z2.Provider,{value:v},b))))}),H8=k.forwardRef((e,n)=>{let{alwaysRender:r,...i}=e,o=k.useRef(null),s=qa(u=>!u.search);return!r&&!s?null:k.createElement(et.div,{ref:Ai(o,n),...i,"cmdk-separator":"",role:"separator"})}),U8=k.forwardRef((e,n)=>{let{onValueChange:r,...i}=e,o=e.value!=null,s=Mp(),u=qa(f=>f.search),d=qa(f=>f.selectedItemId),h=ks();return k.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),k.createElement(et.input,{ref:n,...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)}})}),B8=k.forwardRef((e,n)=>{let{children:r,label:i="Suggestions",...o}=e,s=k.useRef(null),u=k.useRef(null),d=qa(f=>f.selectedItemId),h=ks();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:Ai(s,n),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":d,"aria-label":i,id:h.listId},qc(e,f=>k.createElement("div",{ref:Ai(u,h.listInnerRef),"cmdk-list-sizer":""},f)))}),I8=k.forwardRef((e,n)=>{let{open:r,onOpenChange:i,overlayClassName:o,contentClassName:s,container:u,...d}=e;return k.createElement(zS,{open:r,onOpenChange:i},k.createElement(HS,{container:u},k.createElement(US,{"cmdk-overlay":"",className:o}),k.createElement(BS,{"aria-label":e.label,"cmdk-dialog":"",className:s},k.createElement(L2,{ref:n,...d}))))}),q8=k.forwardRef((e,n)=>qa(r=>r.filtered.count===0)?k.createElement(et.div,{ref:n,...e,"cmdk-empty":"",role:"presentation"}):null),F8=k.forwardRef((e,n)=>{let{progress:r,children:i,label:o="Loading...",...s}=e;return k.createElement(et.div,{ref:n,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},qc(e,u=>k.createElement("div",{"aria-hidden":!0},u)))}),tn=Object.assign(L2,{List:B8,Item:L8,Input:U8,Group:P8,Separator:H8,Dialog:I8,Empty:q8,Loading:F8});function $8(e,n){let r=e.nextElementSibling;for(;r;){if(r.matches(n))return r;r=r.nextElementSibling}}function V8(e,n){let r=e.previousElementSibling;for(;r;){if(r.matches(n))return r;r=r.previousElementSibling}}function P2(e){let n=k.useRef(e);return _i(()=>{n.current=e}),n}var _i=typeof window>"u"?k.useEffect:k.useLayoutEffect;function Ml(e){let n=k.useRef();return n.current===void 0&&(n.current=e()),n}function qa(e){let n=Mp(),r=()=>e(n.snapshot());return k.useSyncExternalStore(n.subscribe,r,r)}function H2(e,n,r,i=[]){let o=k.useRef(),s=ks();return _i(()=>{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=n.current)==null||u.setAttribute(Dl,d),o.current=d}),o}var Y8=()=>{let[e,n]=k.useState(),r=Ml(()=>new Map);return _i(()=>{r.current.forEach(i=>i()),r.current=new Map},[e]),(i,o)=>{r.current.set(i,o),n({})}};function Q8(e){let n=e.type;return typeof n=="function"?n(e.props):"render"in n?n.render(e.props):e}function qc({asChild:e,children:n},r){return e&&k.isValidElement(n)?k.cloneElement(Q8(n),{ref:n.ref},r(n.props.children)):r(n)}var G8={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const P0=[264,190,150,90,30,320,220,55,0,170,120,290];function K8(e){return P0[e%P0.length]}function X8(e,n){return`${e}.${n}`}function U2(e,n){if(!e)return{sourcePath:"root",modulePath:"root"};const r=e.split("/").filter(Boolean),i=n.split("/").filter(Boolean);let o=-1;for(let u=0;u<=r.length-i.length;u+=1)i.every((d,h)=>r[u+h]===d)&&(o=u+i.length);const s=o>=0?r.slice(o):r;return s.length===0?{sourcePath:"root",modulePath:"root"}:(s[s.length-1]=s[s.length-1].replace(/\.tsx?$/u,""),{sourcePath:s.join("/"),modulePath:s.length>1?s.slice(0,-1).join("/"):"root"})}function zp(e,n){return e.ir?Object.entries(e.ir.classes).map(([r,i])=>{const o=i.type==="edge"?"edge":"class";return{name:r,kind:o,...U2(e.overlay.sourceSpans[`${o}.${r}`]?.file,n),icon:i.icon}}):[]}function Lp(e){const n=[...new Set(e.map(r=>r.modulePath.split("/")[0]))].sort();return new Map(n.map((r,i)=>[r,K8(i)]))}function jm(e){return{name:e.name,kind:e.kind,selectId:`class.${e.name}`,ref:X8(e.kind,e.name),icon:e.icon}}function pP(e,n="schema"){const r=zp(e,n),i=Lp(r),o={name:n,path:"",hue:0,children:[],members:[]};for(const s of r){const u=s.modulePath==="root"?[]:s.modulePath.split("/"),d=i.get(u[0]??"root")??264;let h=o;if(u.length===0){let f=o.children.find(y=>y.path==="root");f||(f={name:n,path:"root",hue:d,children:[],members:[]},o.children.push(f)),h=f}for(let f=0;f<u.length;f+=1){const y=u.slice(0,f+1).join("/");let p=h.children.find(v=>v.path===y);p||(p={name:u[f],path:y,hue:d,children:[],members:[]},h.children.push(p)),h=p}h.members.push(jm(s))}return B2(o),o}function B2(e){e.children.sort((n,r)=>n.name.localeCompare(r.name)),e.members.sort((n,r)=>+(n.kind==="edge")-+(r.kind==="edge")||n.name.localeCompare(r.name)),e.children.forEach(B2)}function Z8(e,n="schema"){const r=zp(e,n),i=Lp(r),o=new Map;for(const s of r){const u=s.modulePath.split("/")[0],d=o.get(s.modulePath)??{path:s.modulePath,label:s.modulePath==="root"?n:s.modulePath,hue:i.get(u)??264,classes:[],edges:[]};d[s.kind==="edge"?"edges":"classes"].push(s.name),o.set(s.modulePath,d)}for(const s of o.values())s.classes.sort(),s.edges.sort();return[...o.values()].sort((s,u)=>s.path.localeCompare(u.path))}function W8(e,n,r="schema"){return U2(e.overlay.sourceSpans[`class.${n}`]?.file,r).modulePath}function gP(e,n,r="schema"){const i=zp(e,r),o=Lp(i),s=i.filter(u=>u.modulePath===n||n!=="root"&&u.modulePath.startsWith(`${n}/`));return{path:n,label:n==="root"?r:n,hue:o.get(n.split("/")[0])??264,classes:s.filter(u=>u.kind==="class").map(jm).sort(H0),edges:s.filter(u=>u.kind==="edge").map(jm).sort(H0),files:[...new Set(s.map(u=>u.sourcePath))].sort()}}function H0(e,n){return e.name.localeCompare(n.name)}const J8=[{key:"context",label:"Context"},{key:"schema",label:"Schema"},{key:"process",label:"Process"},{key:"comments",label:"Comments"}];function U0(e,n){if(!e)return"unknown";if(Array.isArray(e.enum)&&e.enum.length)return n?"enum?":"enum";const r=e.type;if(Array.isArray(r)){const o=r.filter(d=>d!=="null"),s=n??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 n?`${i}?`:i}function Go({icon:e,label:n,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:n}),r?m.jsx("span",{className:"ml-2 shrink-0 truncate text-xs text-muted-foreground",children:r}):null]})}const Ol="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 e9(){const e=Ce(y=>y.paletteOpen),n=Ce(y=>y.setPaletteOpen),r=Ce(y=>y.domainId),i=Ce(y=>y.setSection),o=Ce(y=>y.selectClass),s=Ce(y=>y.focusClass),u=Ce(y=>y.setSettingsOpen),{data:d}=Sc(r);k.useEffect(()=>{function y(p){p.key.toLowerCase()==="k"&&(p.metaKey||p.ctrlKey)&&(p.preventDefault(),n(!Ce.getState().paletteOpen))}return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=()=>n(!1),f=k.useMemo(()=>{const y=d?.ir;if(!y||!d)return{classes:[],edges:[],properties:[],modules:[]};const p=Object.values(y.classes).filter(C=>C.type==="node").map(C=>{const E=Object.keys(C.properties).length,j=Object.keys(C.methods).length,A=W8(d,C.name),R=`${E}p · ${j}m`;return{name:C.name,value:`class ${C.name} ${A} ${R}`,meta:A==="root"?R:`${A} · ${R}`}}).sort((C,E)=>C.name.localeCompare(E.name)),v=Object.values(y.classes).filter(C=>C.type==="edge").map(C=>{const[E,j]=C.endpoints??[],A=E?.types.join("|")??"?",R=j?.types.join("|")??"?";return{name:C.name,value:`edge ${C.name} ${A} ${R} relationship`,meta:`${A} → ${R}`}}).sort((C,E)=>C.name.localeCompare(E.name)),b=[];for(const C of Object.values(y.classes))if(C.type==="node")for(const[E,j]of Object.entries(C.properties)){const A=C.required?!C.required.includes(E):void 0;b.push({id:`class.${C.name}.property.${E}`,owner:C.name,prop:E,value:`${C.name}.${E} property ${U0(j,A)}`,meta:U0(j,A)})}b.sort((C,E)=>C.value.localeCompare(E.value));const w=Z8(d).map(C=>{const E=C.classes.length+C.edges.length;return{path:C.path,firstClass:C.classes[0],value:`module ${C.path} ${C.classes.join(" ")} ${C.edges.join(" ")}`,meta:`${E} member${E===1?"":"s"}`}});return{classes:p,edges:v,properties:b,modules:w}},[d]);return m.jsxs(tn.Dialog,{open:e,onOpenChange:n,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(tn.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(tn.List,{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden p-2",children:[m.jsx(tn.Empty,{className:"py-8 text-center text-sm text-muted-foreground",children:"No results"}),m.jsx(tn.Group,{heading:"Studio",children:m.jsxs(tn.Item,{value:"settings power-user options integrations folder configuration",className:Ol,onSelect:()=>{u(!0),h()},children:[m.jsx(b1,{className:"h-4 w-4 text-muted-foreground"}),"Settings…"]})}),f.classes.length>0&&m.jsx(tn.Group,{heading:"Classes",children:f.classes.map(y=>m.jsx(tn.Item,{value:y.value,className:Ol,onSelect:()=>{i("schema"),s(`class.${y.name}`),h()},children:m.jsx(Go,{icon:o1,label:y.name,meta:y.meta})},`class.${y.name}`))}),f.edges.length>0&&m.jsx(tn.Group,{heading:"Relationships",children:f.edges.map(y=>m.jsx(tn.Item,{value:y.value,className:Ol,onSelect:()=>{i("schema"),o(`class.${y.name}`),h()},children:m.jsx(Go,{icon:UA,label:m.jsxs(m.Fragment,{children:[y.name," ",m.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.meta,")"]})]})})},`edge.${y.name}`))}),f.properties.length>0&&m.jsx(tn.Group,{heading:"Properties",children:f.properties.map(y=>m.jsx(tn.Item,{value:y.value,className:Ol,onSelect:()=>{i("schema"),s(`class.${y.owner}`),h()},children:m.jsx(Go,{icon:qA,label:m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"text-muted-foreground",children:[y.owner,"."]}),y.prop]}),meta:y.meta})},y.id))}),f.modules.length>0&&m.jsx(tn.Group,{heading:"Modules",children:f.modules.map(y=>m.jsx(tn.Item,{value:y.value,className:Ol,onSelect:()=>{i("schema"),y.firstClass&&s(`class.${y.firstClass}`),h()},children:m.jsx(Go,{icon:UN,label:y.path,meta:y.meta})},`module.${y.path}`))}),m.jsx(tn.Group,{heading:"Go to",children:J8.map(y=>m.jsx(tn.Item,{value:`go to ${y.label} ${y.key} section`,className:Ol,onSelect:()=>{i(y.key),h()},children:m.jsx(Go,{icon:Gj,label:y.label,meta:"section"})},`section.${y.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 t9({count:e,status:n,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":n==="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",n==="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 n9=Object.defineProperty,Cs=(e,n)=>n9(e,"name",{value:n,configurable:!0}),Pp="Collapsible",[r9,yP]=Va(Pp),[a9,Hp]=r9(Pp),i9=k.forwardRef(Cs(function(n,r){const{__scopeCollapsible:i,open:o,defaultOpen:s,disabled:u,onOpenChange:d,...h}=n,[f,y]=Fl({prop:o,defaultProp:s??!1,onChange:d,caller:Pp});return m.jsx(a9,{scope:i,disabled:u,contentId:qn(),open:f,onOpenToggle:k.useCallback(()=>y(p=>!p),[y]),children:m.jsx(et.div,{"data-state":Fc(f),"data-disabled":u?"":void 0,...h,ref:r})})},"Collapsible")),l9="CollapsibleTrigger",o9=k.forwardRef(Cs(function(n,r){const{__scopeCollapsible:i,...o}=n,s=Hp(l9,i);return m.jsx(et.button,{type:"button","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open||!1,"data-state":Fc(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...o,ref:r,onClick:Ye(n.onClick,s.onOpenToggle)})},"CollapsibleTrigger")),I2="CollapsibleContent",s9=k.forwardRef(Cs(function(n,r){const{forceMount:i,...o}=n,s=Hp(I2,n.__scopeCollapsible);return m.jsx(Nn,{present:i||s.open,children:({present:u})=>m.jsx(u9,{...o,ref:r,present:u})})},"CollapsibleContent")),u9=k.forwardRef(Cs(function(n,r){const{__scopeCollapsible:i,present:o,children:s,...u}=n,d=Hp(I2,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,E=d.open||h,j=k.useRef(E),A=k.useRef(void 0);return k.useEffect(()=>{const R=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(R)},[]),fn(()=>{const R=y.current;if(R){A.current=A.current||{transitionDuration:R.style.transitionDuration,animationName:R.style.animationName},R.style.transitionDuration="0s",R.style.animationName="none";const B=R.getBoundingClientRect();v.current=B.height,w.current=B.width,j.current||(R.style.transitionDuration=A.current.transitionDuration,R.style.animationName=A.current.animationName),f(o)}},[d.open,o]),m.jsx(et.div,{"data-state":Fc(d.open),"data-disabled":d.disabled?"":void 0,id:d.contentId,hidden:!E,...u,ref:p,style:{"--radix-collapsible-content-height":b?`${b}px`:void 0,"--radix-collapsible-content-width":C?`${C}px`:void 0,...n.style},children:E&&s})},"CollapsibleContentImpl"));function Fc(e){return e?"open":"closed"}Cs(Fc,"getState");var c9=i9,d9=o9,f9=s9;const h9=c9,m9=d9,p9=f9;function Nm({title:e,subtitle:n,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}),n&&m.jsx("p",{className:"text-sm text-muted-foreground mt-1 leading-relaxed",children:n})]}),i&&m.jsx("div",{className:"flex items-center gap-2 shrink-0",children:i})]}),o]})})}function B0({label:e,hint:n,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}),n!=null&&m.jsx("span",{className:"text-xs text-muted-foreground/70",children:n})]}),r]})}function Ha({className:e,...n}){return m.jsx("div",{className:ge("rounded-xl border bg-card",e),...n})}const g9={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 Si({children:e,tone:n="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",g9[n]??n,s,i),style:o,children:e})}function q2({leading:e,title:n,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,(n||r)&&m.jsxs("div",{className:"flex-1 min-w-0",children:[n&&m.jsx("div",{className:"text-sm font-extrabold truncate",children:n}),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 y9={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 Bn({children:e,tone:n="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",y9[n],r),...i,children:e})}function xP({label:e="Details",children:n,className:r}){return m.jsxs(h9,{className:r,children:[m.jsxs(m9,{className:"group/disc inline-flex items-center gap-1 text-xs text-muted-foreground/80 hover:text-foreground transition-colors",children:[m.jsx(xc,{className:"h-3 w-3 transition-transform group-data-[state=open]/disc:rotate-90"}),e]}),m.jsx(p9,{className:"overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out",children:m.jsx("div",{className:"pt-2",children:n})})]})}function x9({items:e,className:n}){return m.jsx("dl",{className:ge("grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-xs",n),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 F2({icon:e,title:n,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:n}),r&&m.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:r})]})}var v9=Object.defineProperty,na=(e,n)=>v9(e,"name",{value:n,configurable:!0}),Uh,Up="HoverCard",[$2,vP]=Va(Up,[Gl]),Bp=Gl(),[b9,$c]=$2(Up),w9=na(e=>{const{__scopeHoverCard:n,children:r,open:i,defaultOpen:o,onOpenChange:s,openDelay:u=700,closeDelay:d=300}=e,h=Bp(n),f=k.useRef(0),y=k.useRef(0),p=k.useRef(!1),v=k.useRef(!1),[b,w]=Fl({prop:i,defaultProp:o??!1,onChange:s,caller:Up}),C=k.useCallback(()=>{clearTimeout(y.current),f.current=window.setTimeout(()=>w(!0),u)},[u,w]),E=k.useCallback(()=>{clearTimeout(f.current),!p.current&&!v.current&&(y.current=window.setTimeout(()=>w(!1),d))},[d,w]),j=k.useCallback(()=>w(!1),[w]);return k.useEffect(()=>()=>{clearTimeout(f.current),clearTimeout(y.current)},[]),m.jsx(b9,{scope:n,open:b,onOpenChange:w,onOpen:C,onClose:E,onDismiss:j,hasSelectionRef:p,isPointerDownOnContentRef:v,children:m.jsx(Ep,{...h,children:r})})},"HoverCard"),S9="HoverCardTrigger",k9=k.forwardRef(na(function(n,r){const{__scopeHoverCard:i,...o}=n,s=$c(S9,i),u=Bp(i);return m.jsx(Uc,{asChild:!0,...u,children:m.jsx(et.a,{"data-state":s.open?"open":"closed",...o,ref:r,onPointerEnter:Ye(n.onPointerEnter,ss(s.onOpen)),onPointerLeave:Ye(n.onPointerLeave,ss(s.onClose)),onFocus:Ye(n.onFocus,s.onOpen),onBlur:Ye(n.onBlur,s.onClose),onTouchStart:Ye(n.onTouchStart,d=>d.preventDefault())})})},"HoverCardTrigger")),V2="HoverCardPortal",[C9,E9]=$2(V2,{forceMount:void 0}),j9=na(e=>{const{__scopeHoverCard:n,forceMount:r,children:i,container:o}=e,s=$c(V2,n);return m.jsx(C9,{scope:n,forceMount:r,children:m.jsx(Nn,{present:r||s.open,children:m.jsx(Oc,{asChild:!0,container:o,children:i})})})},"HoverCardPortal"),Am="HoverCardContent",N9=k.forwardRef(na(function(n,r){const i=E9(Am,n.__scopeHoverCard),{forceMount:o=i.forceMount,...s}=n,u=$c(Am,n.__scopeHoverCard);return m.jsx(Nn,{present:o||u.open,children:m.jsx(A9,{"data-state":u.open?"open":"closed",...s,onPointerEnter:Ye(n.onPointerEnter,ss(u.onOpen)),onPointerLeave:Ye(n.onPointerLeave,ss(u.onClose)),ref:r})})},"HoverCardContent")),A9=k.forwardRef(na(function(n,r){const{__scopeHoverCard:i,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:u,onInteractOutside:d,...h}=n,f=$c(Am,i),y=Bp(i),p=k.useRef(null),v=zt(r,p),[b,w]=k.useState(!1);return k.useEffect(()=>{if(b){const C=document.body;return Uh=C.style.userSelect||C.style.webkitUserSelect,C.style.userSelect="none",C.style.webkitUserSelect="none",()=>{C.style.userSelect=Uh,C.style.webkitUserSelect=Uh}}},[b]),k.useEffect(()=>{if(p.current){const C=na(()=>{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&&Y2(p.current).forEach(E=>E.setAttribute("tabindex","-1"))}),m.jsx(Tc,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:d,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:Ye(u,C=>{C.preventDefault()}),onDismiss:f.onDismiss,children:m.jsx(jp,{...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 ss(e){return n=>n.pointerType==="touch"?void 0:e()}na(ss,"excludeTouch");function Y2(e){const n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:na(i=>i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;r.nextNode();)n.push(r.currentNode);return n}na(Y2,"getTabbableNodes");var T9=w9,O9=k9,R9=j9,_9=N9;const Ip=T9,qp=O9,Vc=k.forwardRef(({className:e,align:n="start",sideOffset:r=8,...i},o)=>m.jsx(R9,{children:m.jsx(_9,{ref:o,align:n,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})}));Vc.displayName="HoverCardContent";function Q2({domainId:e,anchor:n,excerpt:r,threads:i,onClose:o}){const s=Ce(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(Ip,{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(xN,{className:"h-3.5 w-3.5"})})}),m.jsx(Vc,{className:"w-auto max-w-xs",children:m.jsx(x9,{items:[{label:"target",value:n.ref},...r&&r!==n.ref?[{label:"on",value:r}]:[],...n.file?[{label:"file",value:n.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(D9,{domainId:u,comment:d},d.id))}),m.jsx(M9,{domainId:u,anchor:n,excerpt:r,hasThreads:i.length>0,onClose:o})]})}function G2({domainId:e,commentId:n,entryId:r,text:i}){const o=Ce(p=>p.domainId),{edit:s}=hs(e??o??""),[u,d]=k.useState(!1),[h,f]=k.useState(i),y=()=>{const p=h.trim();!p||s.isPending||s.mutate({commentId:n,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(Er,{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(Gw,{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(v1,{className:"h-3 w-3"})})]})}function D9({domainId:e,comment:n}){const{reply:r,setStatus:i,remove:o}=hs(e),[s,u]=k.useState(""),d=n.status==="closed",[h,f]=k.useState(!d),y=(n.thread.at(-1)?.text??n.thread[0]?.text??"").trim();return k.useEffect(()=>{f(n.status!=="closed")},[n.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:n.status==="open"?"secondary":"muted",children:d?"resolved":"open"}),n.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(iN,{className:"h-3.5 w-3.5"}):m.jsx(xc,{className:"h-3.5 w-3.5"}),h?"Hide":"Show"]}),m.jsx("button",{type:"button",title:"Delete comment",disabled:o.isPending,onClick:()=>o.mutate(n.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(Pm,{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:n.thread.map((p,v)=>{const b=p.type==="choice"&&!!p.options&&p.role==="author"&&n.status==="open"&&v===n.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(G2,{domainId:e,commentId:n.id,entryId:p.id,text:p.text}),p.type==="choice"&&p.options&&(b?m.jsx(K2,{commentId:n.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)})}),n.status==="open"&&m.jsxs("div",{className:"flex items-end gap-1.5 pt-0.5",children:[m.jsx(Er,{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:n.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:n.id,entry:{role:"user",type:"text",text:s.trim()}},{onSuccess:()=>u("")}),children:"Reply"}),m.jsxs(Ke,{size:"xs",onClick:()=>i.mutate({commentId:n.id,status:"closed"},{onSuccess:()=>Ee.success("Resolved")}),children:[m.jsx(ra,{className:"h-3 w-3"})," Resolve"]})]})]})]})}function K2({commentId:e,options:n,domainId:r}){const{reply:i}=hs(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:[n.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 M9({domainId:e,anchor:n,excerpt:r,hasThreads:i,onClose:o}){const{create:s}=hs(e),[u,d]=k.useState(""),h=()=>{u.trim()&&s.mutate({anchors:[r],anchorRefs:[n],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(Er,{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 X2(e,n){const r=Ce(d=>d.domainId),{data:i}=kc(n??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 bP({anchorRef:e,excerpt:n,className:r,domainId:i}){const o=k.useId(),s=Ce(b=>b.openAnchorRef),u=Ce(b=>b.openAnchorId),d=i?`${i}::${e.ref}`:e.ref,h=s===d&&(u===null||u===o),f=Ce(b=>b.setOpenAnchor),{threads:y,status:p,orphaned:v}=X2(e.ref,i);return y.length===0?null:m.jsxs(Hi,{modal:!1,open:h,onOpenChange:b=>f(b?d:null,b?o:null),children:[m.jsx(Dp,{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(t9,{count:y.length,status:p,orphaned:v})})}),m.jsx(Qa,{onInteractOutside:b=>b.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:m.jsx(Q2,{domainId:i,anchor:e,excerpt:n,threads:y,onClose:()=>f(null)})})]})}function z9(){const e=Ce(i=>i.commentDraft),n=Ce(i=>i.setCommentDraft),{threads:r}=X2(e?.anchor.ref??"__none__",e?.domainId);return e?m.jsxs(Hi,{modal:!1,open:!0,onOpenChange:i=>{i||n(null)},children:[m.jsx(Dp,{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(Qa,{side:"bottom",align:"start",sideOffset:6,className:"w-80",onInteractOutside:i=>i.preventDefault(),children:m.jsx(Q2,{domainId:e.domainId,anchor:e.anchor,excerpt:e.excerpt,threads:r,onClose:()=>n(null)})})]},`${e.anchor.ref}:${e.x}:${e.y}`):null}function L9(e){return/^(class|edge)\./.test(e)?"schema":/^(module|section|view)\./.test(e)?"section":e.startsWith("file.")?"file":"free"}function wP(e,n){return`${e}.${n}`}function P9(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 SP(e,n){return{"data-anchor-ref":e,"data-anchor-excerpt":n,"data-commentable":""}}function H9(e,n,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=(n-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 U9(e,n,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:L9(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=P9(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=H9(e,i,o);return{mode:r,domainId:s,anchor:{ref:`section.${n}`,kind:"section",...f},excerpt:n,x:i,y:o}}return null}function B9(){const e=Ce(h=>h.commentMode),n=Ce(h=>h.askMode),r=Ce(h=>h.toggleCommentMode),i=Ce(h=>h.toggleAskMode),o=Ce(h=>h.setCommentDraft),s=e||n,u=n?"ask":"comment";if(k.useEffect(()=>{if(!s)return;const h=document.body.style.cursor;document.body.style.cursor="crosshair";const f=()=>Ce.getState().askMode?i(!1):r(!1),y=v=>{v.preventDefault(),v.stopPropagation();const b=Ce.getState(),w=b.askMode?"ask":"comment",C=U9(v.target,b.section,w,v.clientX,v.clientY);if(f(),!!C)if(C.mode==="ask"){const E=C.domainId??b.domainId;E&&requestAnimationFrame(()=>nr.getState().start(E,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(ds,{className:"h-3.5 w-3.5 text-violet-400"}):m.jsx(xA,{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 Z2="studio.schemaWorkspace.v1",I0={selectedDomainIds:[],domainPositions:{},externalPositions:{},domainSizes:{},domainContentOffsets:{},collapsedModules:{}};function Fp(e){return[...new Set(e.filter(Boolean))]}function I9(e,n,r){const i=Fp(e);return n&&!i.includes(n)&&i.unshift(n),i.length<=1?[r]:(i.includes(r)||i.push(r),i)}function q9(){try{const e=JSON.parse(localStorage.getItem(Z2)??"null");return e?{selectedDomainIds:Fp(e.selectedDomainIds??[]),domainPositions:e.domainPositions??{},externalPositions:e.externalPositions??{},domainSizes:e.domainSizes??{},domainContentOffsets:e.domainContentOffsets??{},collapsedModules:e.collapsedModules??{}}:I0}catch{return I0}}function Qr(e){try{localStorage.setItem(Z2,JSON.stringify(e))}catch{}}function Gr(e){return{selectedDomainIds:e.selectedDomainIds,domainPositions:e.domainPositions,externalPositions:e.externalPositions,domainSizes:e.domainSizes,domainContentOffsets:e.domainContentOffsets,collapsedModules:e.collapsedModules}}const F9=q9(),Bh=bc(e=>({...F9,replaceDomains:n=>e(r=>{const i=Fp(n),o={...Gr(r),selectedDomainIds:i};return Qr(o),{selectedDomainIds:i}}),toggleDomain:(n,r)=>e(i=>{const o=new Set(i.selectedDomainIds);o.has(n)&&n!==r?o.delete(n):o.add(n),o.add(r);const s=[...o];return Qr({...Gr(i),selectedDomainIds:s}),{selectedDomainIds:s}}),setDomainPosition:(n,r)=>e(i=>{const o={...i.domainPositions,[n]:r};return Qr({...Gr(i),domainPositions:o}),{domainPositions:o}}),setDomainSize:(n,r)=>e(i=>{const o={...i.domainSizes,[n]:r};return Qr({...Gr(i),domainSizes:o}),{domainSizes:o}}),ensureDomainPositions:n=>e(r=>{const i={...r.domainPositions};let o=!1;for(const[s,u]of Object.entries(n))i[s]||(i[s]=u,o=!0);return o?(Qr({...Gr(r),domainPositions:i}),{domainPositions:i}):r}),ensureExternalPositions:n=>e(r=>{const i={...r.externalPositions};let o=!1;for(const[s,u]of Object.entries(n))i[s]||(i[s]=u,o=!0);return o?(Qr({...Gr(r),externalPositions:i}),{externalPositions:i}):r}),ensureDomainContentOffsets:n=>e(r=>{const i={...r.domainContentOffsets};let o=!1;for(const[s,u]of Object.entries(n))i[s]||(i[s]=u,o=!0);return o?(Qr({...Gr(r),domainContentOffsets:i}),{domainContentOffsets:i}):r}),resetWorkspaceFrames:()=>e(n=>(Qr({...Gr(n),domainPositions:{},externalPositions:{},domainSizes:{}}),{domainPositions:{},externalPositions:{},domainSizes:{}})),toggleModule:(n,r)=>e(i=>{const o=new Set(i.collapsedModules[n]??[]);o.has(r)?o.delete(r):o.add(r);const s={...i.collapsedModules,[n]:[...o]};return Qr({...Gr(i),collapsedModules:s}),{collapsedModules:s}})})),W2=k.forwardRef(({className:e,type:n,...r},i)=>m.jsx("input",{ref:i,type:n,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}));W2.displayName="Input";const $9=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function V9(){const{data:e}=k1(),n=Ce(E=>E.domainId),r=Ce(E=>E.setDomain),i=Ce(E=>E.setSection),o=Bh(E=>E.selectedDomainIds),s=Bh(E=>E.replaceDomains),u=Bh(E=>E.toggleDomain),[d,h]=k.useState(!1),[f,y]=k.useState(!1),p=e?.find(E=>E.id===n),v=k.useMemo(()=>new Set((e??[]).map(E=>E.id)),[e]);k.useEffect(()=>{if(!n||!e)return;const E=o.filter(j=>v.has(j));E.includes(n)||E.unshift(n),(E.length!==o.length||E.some((j,A)=>j!==o[A]))&&s(E)},[n,e,s,o,v]);const b=new Set(o);n&&b.add(n);const w=b.size,C=E=>{s(n?I9([...b],n,E):[E]),r(E),h(!1)};return m.jsxs(m.Fragment,{children:[m.jsxs(Hi,{open:d,onOpenChange:h,children:[m.jsx(Ic,{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(tN,{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(KN,{className:"h-3 w-3"})," ",w]}),m.jsx(u1,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),m.jsxs(Qa,{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(E=>E.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(E=>{const j=b.has(E.id),A=E.id===n;return m.jsxs("div",{className:ge("flex items-center gap-1 rounded-md transition-colors",j?"bg-accent/55":"hover:bg-accent/35"),children:[m.jsx("button",{type:"button",role:"checkbox","aria-label":A?`${E.origin} is the active domain on canvas`:`${j?"Remove":"Add"} ${E.origin} ${j?"from":"to"} canvas`,"aria-checked":j,disabled:A,title:A?"The active domain is always on the canvas":void 0,onClick:()=>n&&u(E.id,n),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:j&&m.jsx("span",{className:"grid h-full w-full place-items-center rounded bg-sky-400/15 text-sky-200",children:m.jsx(ra,{className:"h-3 w-3"})})}),m.jsxs("button",{type:"button","aria-current":A?"true":void 0,onClick:()=>C(E.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:E.origin}),m.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground/65",children:[E.path.split("/").pop(),!E.depsInstalled&&" · deps missing"]})]}),A&&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"})]})]},E.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"}),n&&w>1&&m.jsxs("button",{type:"button",onClick:()=>s([n]),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(PN,{className:"h-3.5 w-3.5"})}),"Create new domain"]})]})]}),m.jsx(Y9,{open:f,onOpenChange:y,onCreated:E=>{s([E]),r(E),i("context")}})]})}function Y9({open:e,onOpenChange:n,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&&$9.test(y),v=y?y.includes(".")?y:`${y}.example.dev`:"",b=()=>{s(""),f(null),d(!1)},w=E=>{u||(E||b(),n(E))},C=async()=>{if(!(!p||u)){d(!0),f(null);try{const E=await je.createDomain(y);E.ok&&E.id?(await i.invalidateQueries({queryKey:Se.workspace}),r(E.id),Ee.success(`Created ${E.origin??y}`),b(),n(!1)):f(E.error||"Could not create the domain — check the studio logs.")}catch(E){f(E?.message??String(E))}finally{d(!1)}}};return m.jsx($l,{open:e,onOpenChange:w,children:m.jsxs(zi,{className:"max-w-md",children:[m.jsxs(Vl,{children:[m.jsx(Li,{children:"Create a new domain"}),m.jsxs(vs,{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(W2,{id:"new-domain-name",autoFocus:!0,value:o,disabled:u,placeholder:"crm",spellCheck:!1,autoComplete:"off",className:"font-mono",onChange:E=>{s(E.target.value),f(null)},onKeyDown:E=>{E.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(cn,{className:"h-3.5 w-3.5 animate-spin"})," Scaffolding and installing dependencies — this can take a moment…"]})]}),m.jsxs(mp,{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(cn,{className:"h-4 w-4 animate-spin"})," Creating…"]}):"Create domain"})]})]})})}function Q9({domainId:e}){const{data:n}=j1(e,"dev"),r=Ce(o=>o.setSettingsOpen),i=n?.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(QN,{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 G9(e,n){return e.declared?!e.optional&&n===""?{dot:"bg-destructive",label:"required",tone:"text-destructive"}:n===""?{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 K9=["dev","prod"];function X9({domainId:e}){const[n,r]=k.useState("dev"),{data:i,isLoading:o}=j1(e,n),s=Bt(),[u,d]=k.useState({}),[h,f]=k.useState(()=>new Set);k.useEffect(()=>{d({}),f(new Set)},[n,e]);const y=sn({mutationFn:()=>je.setEnv(e,n,u),onSuccess:C=>{s.setQueryData(Se.env(e,n),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(E=>{const j=new Set(E);return j.has(C)?j.delete(C):j.add(C),j});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:K9.map(C=>m.jsx("button",{type:"button",onClick:()=>r(C),className:ge("rounded px-2 py-0.5 text-[11px] font-medium transition-colors",n===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"}),n==="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 ",n," 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 E=b(C),j=G9(C,E),A=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",j.dot),title:j.label}),m.jsx("span",{className:"truncate font-mono text-[12px]",children:C.name}),m.jsx("span",{className:ge("shrink-0 text-[10px]",j.tone),children:j.label}),m.jsxs("div",{className:"ml-auto flex min-w-0 flex-1 items-center gap-1",children:[m.jsx("input",{type:A?"text":"password",value:E,onChange:R=>d(B=>({...B,[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:A?"Hide":"Reveal",className:"shrink-0 rounded p-1 text-muted-foreground/50 hover:text-foreground",children:A?m.jsx(h1,{className:"h-3.5 w-3.5"}):m.jsx(m1,{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(Pm,{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(vc,{className:"h-3 w-3"})," Plaintext in ",i?.file??`.env.${n}`," ","(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(cn,{className:"h-3 w-3 animate-spin"})," Save ",n]})]})]})}function pc(e){if(!e)return{kind:"unknown",optional:!1};const n=e.type,r=Array.isArray(n)?n.includes("null"):!1,i=Array.isArray(n)?n.find(o=>o!=="null"):n;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:pc(e.items),optional:r};if(i==="object"){const o={};for(const[s,u]of Object.entries(e.properties??{}))o[s]=pc(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 J2(e){switch(e.kind){case"enum":return`enum(${e.values.map(String).join(" | ")})`;case"array":return`${J2(e.items)}[]`;case"object":return`{ ${Object.keys(e.fields).join(", ")} }`;case"ref":return`→${e.target}`;default:return e.kind}}function kP({schema:e,className:n}){const r=pc(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",n),children:[J2(r),r.optional&&m.jsx("span",{className:"text-muted-foreground",children:"?"})]})}function Ih(e){return e?e.replace(/^sha256:/,"").replace(/^sha-?/,"").slice(0,8):"—"}function Z9(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 W9({domainId:e}){const{data:n}=ST(e),{data:r}=Sc(e),{data:i}=C1(),o=Bt(),[s,u]=k.useState("idle"),[d,h]=k.useState(null);if(!n)return null;const f=Z9(n),y=r?!r.depsInstalled:!1,p=i?.active??null,v=!!n.deployTarget&&!!p&&n.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(Hi,{onOpenChange:w=>{!w&&s!=="deploying"&&(u("idle"),h(null))},children:[m.jsx(Ic,{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(ob,{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(Qa,{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:n.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]})]}),n.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"})]})]}),n.drift==="drifted"?m.jsxs("div",{className:"space-y-0.5 font-mono text-[11px]",children:[m.jsxs("div",{className:"text-warning",children:["local ",Ih(n.localRevision??"")]}),m.jsxs("div",{className:"text-muted-foreground",children:["on instance ",Ih(n.installedRevision??"")]})]}):m.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:n.localRevision?Ih(n.localRevision):"revision unavailable"}),n.install==="unknown"&&n.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}),")."]}),n.deployable?s==="idle"?m.jsxs(Ke,{size:"sm",className:"w-full",onClick:b,children:[m.jsx(ob,{className:"h-3.5 w-3.5"})," ",n.install==="installed"?"Re-deploy":"Deploy & install"]}):s==="deploying"?m.jsxs(Ke,{size:"sm",className:"w-full",disabled:!0,children:[m.jsx(cn,{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(ra,{className:"h-3.5 w-3.5"}):m.jsx(vc,{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 J9(e){const n=e?.trim();if(!n)return null;try{const r=new URL(n);return(r.pathname==="/api"||r.pathname==="/api/")&&(r.pathname="/"),r.href.replace(/\/$/,"")}catch{return n.replace(/\/api\/?$/,"")}}function e7(){const{data:e}=C1(),n=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 n.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(Hi,{open:r,onOpenChange:i,children:[m.jsx("div",{className:"-ml-1 inline-flex items-center gap-0.5",children:m.jsx(Ic,{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(x1,{className:"h-4 w-4"})}),m.jsx("span",{className:"font-semibold tracking-tight",children:u??"no instance"}),m.jsx(u1,{className:"h-3.5 w-3.5 text-muted-foreground"})]})})}),m.jsxs(Qa,{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=J9(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(cn,{className:"h-3.5 w-3.5 animate-spin text-primary"}):f.active?m.jsx(ra,{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(bN,{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 $p(e,n){if(n)return e.includes(n)?n:n==="max"&&e.includes("xhigh")||n==="ultracode"&&e.includes("xhigh")?"xhigh":n==="minimal"&&e.includes("low")?"low":e.includes("high")?"high":e[0]}const ek=["minimal","low","medium","high","xhigh","max","ultracode"],Vp=["workspace","full"];function t7(e,n,r){const i=n.trim().toLowerCase();if(!i)return e;const o={...e},s=r.trim();return s?o[i]=s:delete o[i],o}function En({text:e}){return m.jsxs(Ip,{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(cN,{className:"h-3.5 w-3.5"})})}),m.jsx(Vc,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function n7({selected:e,loadout:n,modelOptions:r,onChange:i}){const o=n?.models??r??[],s=e||n?.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(En,{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:n?.nativeModel?`Default — ${n.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":n?.modelSource==="config"?"Codex effective config":n?.modelSource==="default"?"Harness catalog default":n?.modelSource==="runtime"?"Harness runtime default":"Harness-native selection"})]})}const r7={minimal:"Minimal",low:"Low",medium:"Medium",high:"High",xhigh:"X-high",max:"Max",ultracode:"Ultracode"},a7={workspace:"Workspace",full:"Full automation"};function i7({value:e,levels:n,onChange:r}){const i=$p(n,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:n.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:r7[o]},o))})}function l7({value:e,levels:n,onChange:r}){const i=Vp.includes(e)&&n.includes(e)?e:n.includes("full")?"full":n[0];return m.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-md bg-muted/45 p-1",role:"radiogroup",children:n.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:a7[o]},o))})}function o7({domainId:e,harness:n}){const{data:r,isFetching:i}=pT(e),o=Bt(),[s,u]=k.useState(""),d=!r?.harness||r.harness===n?.id;k.useEffect(()=>{if(!e||!n||i||!d){u("");return}u(r?.sessionId??"")},[e,n?.id,i,d,r?.harness,r?.sessionId]);const h=sn({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(En,{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||!n||i||!d||s.trim()===(r?.sessionId??"")||h.isPending,onClick:()=>h.mutate({domainId:e,harness:n.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"],s7={"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 F0({skill:e,domainId:n,expanded:r,onToggle:i}){const{data:o,isLoading:s}=wT(r?n: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(xc,{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 u7({command:e}){const[n,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}),n?m.jsx(ra,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-500"}):m.jsx(d1,{className:"ml-auto h-3 w-3 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-foreground"})]})}function c7({command:e}){const[n,r]=k.useState(!1),i=s7[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(xc,{className:ge("h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform",n&&"rotate-90")})]}),n&&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(u7,{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 d7({skills:e,domainId:n}){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(F0,{skill:y,domainId:n,expanded:o===f,onToggle:()=>s(p=>p===f?null:f)},f):m.jsx(c7,{command:f},f)}),r&&h.map(f=>m.jsx(F0,{skill:f,domainId:n,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 Pa({label:e,value:n,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(En,{text:i})]}),m.jsx("span",{className:"ml-auto truncate font-mono text-[11px]",children:n})]})}const $0=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);function f7({domainId:e}){const[n,r]=k.useState(!1),{data:i,isLoading:o,error:s}=gT(n?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(En,{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:n?"Hide":"Show"})]}),n&&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 h7({loadout:e,loading:n,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(f7,{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(En,{text:u}),m.jsxs("button",{type:"button",disabled:n,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(AA,{className:ge("h-3 w-3",n&&"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}):n&&!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(Pa,{label:"Model",value:e.model??"—"}),m.jsx(Pa,{label:"Source",value:e.source==="configured"?"configured":"runtime",title:e.detail}),m.jsx(Pa,{label:"Tools",value:e.tools.length,title:e.tools.join(", ")}),m.jsx(Pa,{label:"Subagents",value:e.agents.length,title:e.agents.join(", ")}),m.jsx(d7,{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(En,{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(Pa,{label:"Turns",value:i?.runs??0}),m.jsx(Pa,{label:"Tokens",value:$0(i?.tokens??0)}),m.jsx(Pa,{label:"Cost",value:`$${(i?.costUsd??0).toFixed(4)}`}),i?.lastTokens!=null&&m.jsx(Pa,{label:"Last turn",value:`${$0(i.lastTokens)} tok · $${(i.lastCostUsd??0).toFixed(4)}`})]})]})}function m7({domainId:e,settings:n,harness:r,values:i,setValues:o,agentModels:s,setAgentModels:u}){const{data:d,isFetching:h,error:f}=vT(e),{data:y}=bT(e),p=Bt(),v=r?.capabilities.effortLevels??[...ek],b=r?.capabilities.accessLevels??[...Vp],w=$p(v,i.agentEffort??n?.agentEffort),C=sn({mutationFn:P=>je.selectHarness(P.domainId,P.harness),onSuccess:(P,_)=>{p.setQueryData(Se.harness(_.domainId),P),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 ${P.label}`)},onError:P=>Ee.error(String(P))}),E=sn({mutationFn:P=>je.loadout(P,!0),onSuccess:(P,_)=>p.setQueryData(Se.loadout(_),P),onError:P=>Ee.error(String(P))}),j=r?.options??[{id:"claude",label:"Claude Code (local)"}],A=r?.id??"claude",R=s[A]??"",B=P=>u(_=>t7(_,A,P));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(En,{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(y1,{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:P=>C.mutate({domainId:e,harness:P.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:j.map(P=>m.jsx("option",{value:P.id,children:P.label},P.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(n7,{selected:R,loadout:d,modelOptions:r?.capabilities.modelOptions,onChange:B}),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(En,{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(i7,{value:i.agentEffort??n?.agentEffort,levels:v,onChange:P=>o(_=>({..._,agentEffort: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:"Access"}),m.jsx(En,{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??n?.agentAccess??"full"})]}),m.jsx(l7,{value:i.agentAccess??n?.agentAccess,levels:b,onChange:P=>o(_=>({..._,agentAccess:P}))})]}),m.jsx(o7,{domainId:e,harness:r}),m.jsx(h7,{loadout:d,loading:h||E.isPending,errorMessage:f?String(f?.message??f):void 0,usage:y,domainId:e,onRefresh:()=>E.mutate(e)})]})]})}const us={introspectTimeoutMs:{min:250,max:3e5},instancePollMs:{min:1e3,max:36e5},updatesPollMs:{min:1e4,max:864e5},viewProbeTimeoutMs:{min:250,max:12e4}};function p7(e,n){if(typeof n!="number"&&typeof n!="string"||typeof n=="string"&&!n.trim())return null;const r=typeof n=="number"?n:Number(n),{min:i,max:o}=us[e];return Number.isInteger(r)&&r>=i&&r<=o?r:null}const tk=[{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 g7(e,n){const r={};for(const i of tk)for(const o of i.fields){const s=e[o.key]??"";if(o.type==="number"){const u=p7(o.key,s);if(u===null)throw new Error(`${o.label} must be a whole number from ${us[o.key].min} to ${us[o.key].max} ms`);r[o.key]=u}else r[o.key]=s.trim()||n[o.key]}return r}function y7({values:e,onChange:n}){return tk.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(En,{text:i.hint})]}),m.jsx("input",{type:i.type,min:i.type==="number"?us[i.key].min:void 0,max:i.type==="number"?us[i.key].max:void 0,step:i.type==="number"?1:void 0,value:e[i.key]??"",onChange:o=>n(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 Tm=typeof window<"u"&&window.self!==window.top,x7={mint:"Auto-mint",token:"Static token",host:"Host-managed"},v7=["mint","token","host"];function b7({mode:e,setMode:n,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(En,{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:v7.map(h=>m.jsx("button",{type:"button",role:"radio","aria-checked":e===h,onClick:()=>n(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:x7[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(h1,{className:"h-3.5 w-3.5"}):m.jsx(m1,{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:Tm?"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 V0({status:e,help:n=!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"}),n&&m.jsx(En,{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 Y0({label:e,hint:n,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(En,{text:n})]}),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 w7(e,n,r,i){if(!e)return null;const o=n.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 S7({domainId:e,harness:n}){const r=n?.capabilities.gateway==="anthropic",{data:i,isFetching:o}=xT(r?e:void 0),s=Bt(),[u,d]=k.useState(!1),[h,f]=k.useState(""),[y,p]=k.useState(""),[v,b]=k.useState(Tm?"host":"mint"),[w,C]=k.useState(""),[E,j]=k.useState(""),[A,R]=k.useState(!1),[B,P]=k.useState(!1);k.useEffect(()=>{const Q=i?.local??i?.global??null;d(Q?.enabled??!1),f(Q?.baseUrl??""),p(Q?.model??""),b(Q?.auth.mode??(Tm?"host":"mint")),C(Q?.auth.mode==="mint"?Q.auth.instance??"":""),j(Q?.auth.mode==="token"?Q.auth.token:""),R(i?.local==null&&i?.global!=null),P(!1)},[e,i]);const _=()=>v==="token"?{mode:"token",token:E.trim()}:v==="host"?{mode:"host"}:{mode:"mint",...w.trim()?{instance:w.trim()}:{}},q=w7(u,h,v,E),I=sn({mutationFn:Q=>je.setHarnessGateway(Q.domainId,Q.scope,Q.config),onSuccess:(Q,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:Q=>Ee.error(String(Q))}),oe=sn({mutationFn:Q=>je.clearHarnessGateway(Q,"domain"),onSuccess:(Q,fe)=>{s.invalidateQueries({queryKey:Se.harnessGateway(fe)}),s.invalidateQueries({queryKey:Se.loadout(fe)}),Ee.success("Override removed — inheriting the default")},onError:Q=>Ee.error(String(Q))});if(n&&!r)return m.jsxs("div",{children:[m.jsx(V0,{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:n.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.":`${n.label} does not expose a Studio model-gateway adapter.`})]});const U=i?.source??"none",ne=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(V0,{status:ne,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:Q=>d(Q.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(Y0,{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(Y0,{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(b7,{mode:v,setMode:b,instance:w,setInstance:C,token:E,setToken:j,reveal:B,setReveal:P})]}),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:A,onChange:Q=>R(Q.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(En,{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:A?"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…":A?"Save for all domains":"Save for this domain"}),i?.local!=null&&m.jsx("button",{type:"button",disabled:o||oe.isPending,onClick:()=>oe.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 k7(){const e=Ce(p=>p.settingsOpen),n=Ce(p=>p.setSettingsOpen),r=Ce(p=>p.domainId),{data:i}=Bm(e?r:void 0),{data:o}=yT(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=sn({mutationFn:async p=>{const v=g7(p.values,p.settings),b=p.harness?.capabilities.effortLevels??[...ek],w=p.harness?.capabilities.accessLevels??[...Vp],C=$p(b,p.values.agentEffort);C&&(v.agentEffort=C);const E=w.includes(p.values.agentAccess)?p.values.agentAccess:w.includes("full")?"full":w[0];return E&&(v.agentAccess=E),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"),n(!1)},onError:p=>Ee.error(String(p))});return m.jsx($l,{open:e,onOpenChange:n,children:m.jsxs(zi,{className:"w-[calc(100%-2rem)] max-w-xl",children:[m.jsxs(Vl,{children:[m.jsx(Li,{children:"Settings"}),m.jsx(vs,{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(m7,{domainId:e?r:void 0,settings:i,harness:o,values:u,setValues:d,agentModels:h,setAgentModels:f}),m.jsx(S7,{domainId:r,harness:o}),m.jsx(X9,{domainId:r}),m.jsx(y7,{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:()=>n(!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 C7({domainId:e}){const{data:n}=mT(e),r=Bt(),[i,o]=k.useState("idle"),[s,u]=k.useState(null);if(!n?.stale&&i==="idle")return null;const{cli:d,sdk:h}=n??{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(Hi,{onOpenChange:y=>{y||(o("idle"),u(null))},children:[m.jsx(Ic,{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(lb,{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(Qa,{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(lb,{className:"h-3.5 w-3.5"})," Update now"]}):i==="running"?m.jsxs(Ke,{size:"sm",className:"w-full",disabled:!0,children:[m.jsx(cn,{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(ra,{className:"h-3.5 w-3.5"}):m.jsx(vc,{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 E7(e){const n=k.useRef(e);k.useEffect(()=>{n.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{n.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 j7(){const e=Ce(w=>w.copyOpen),n=Ce(w=>w.setCopyOpen),r=Ce(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($l,{open:e,onOpenChange:n,children:m.jsxs(zi,{className:"max-w-3xl",children:[m.jsxs(Vl,{children:[m.jsx(Li,{children:"Copy handoff for the agent"}),m.jsxs(vs,{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(Op,{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(mp,{children:m.jsxs(Ke,{onClick:b,disabled:f||!s,children:[p?m.jsx(ra,{className:"h-4 w-4"}):m.jsx(c1,{className:"h-4 w-4"}),p?"Copied":"Copy to clipboard"]})})]})})}function N7(){const e=Ce(f=>f.mergeOpen),n=Ce(f=>f.setMergeOpen),r=Ce(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(""),n(!1)}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx($l,{open:e,onOpenChange:n,children:m.jsxs(zi,{className:"max-w-2xl",children:[m.jsxs(Vl,{children:[m.jsx(Li,{children:"Paste the agent's reply"}),m.jsxs(vs,{children:["Paste the agent's response (prose + its trailing"," ",m.jsx("code",{className:"font-mono",children:"```json"})," block). Threads merge by id."]})]}),m.jsx(Er,{className:"min-h-[40vh] text-xs",placeholder:"Paste the agent reply here…",value:o,onChange:f=>s(f.target.value)}),m.jsxs(mp,{children:[m.jsx(Ke,{variant:"ghost",onClick:()=>n(!1),children:"Cancel"}),m.jsxs(Ke,{onClick:h,disabled:u||!o.trim(),children:[m.jsx(p1,{className:"h-4 w-4"})," Merge reply"]})]})]})})}function A7(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("edge.")?`Edge · ${e.slice(5)}`:e.startsWith("section.")?e.slice(8).replace(/\./g," · "):e}function T7({domainId:e}){const{data:n,isLoading:r}=kc(e),[i,o]=k.useState("open"),s=Ce(b=>b.setCopyOpen),u=Ce(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(Nm,{title:"Comments",subtitle:d,icon:m.jsx(Ci,{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=n?.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(Nm,{title:"Comments",subtitle:d,icon:m.jsx(Ci,{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(c1,{className:"h-3.5 w-3.5"}),"Copy for agent"]}),m.jsxs(Ke,{variant:"outline",size:"sm",onClick:()=>u(!0),children:[m.jsx(p1,{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(Ha,{children:m.jsx(F2,{icon:m.jsx(Ci,{}),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(R7,{domainId:e,comment:b},b.id))})}),m.jsx(j7,{}),m.jsx(N7,{})]})}function O7({entry:e,commentId:n,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(G2,{commentId:n,entryId:e.id,text:e.text})]}),e.type==="choice"&&e.options&&(u?m.jsx(K2,{commentId:n,options:e.options,domainId:o}):m.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(d=>m.jsx(Bn,{tone:e.answer===d?"primary":"outline",children:d},d))}))]})}function R7({domainId:e,comment:n}){const{reply:r,setStatus:i,remove:o}=hs(e),[s,u]=k.useState(""),d=n.anchorRefs[0];return m.jsxs(Ha,{className:ge("overflow-hidden",n.status==="closed"&&"opacity-70"),children:[m.jsx(q2,{className:"border-b py-3",leading:m.jsx(Ci,{className:"h-4 w-4 text-muted-foreground/70"}),trailing:m.jsx("button",{type:"button",title:"Remove thread",onClick:()=>o.mutate(n.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(Pm,{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(Bn,{tone:n.status==="open"?"primary":"default",children:n.status}),n.orphaned&&m.jsx(Bn,{tone:"danger",children:"orphaned"}),d&&m.jsx("span",{className:"truncate text-xs text-muted-foreground/70",title:d.ref,children:A7(d.ref)})]})}),m.jsx("div",{className:"flex flex-col gap-3 px-4 py-3.5",children:n.thread.map((h,f)=>m.jsx(O7,{entry:h,commentId:n.id,open:n.status==="open",isLast:f===n.thread.length-1,domainId:e},h.id))}),n.status==="open"&&m.jsxs("div",{className:"flex flex-col gap-2.5 border-t px-4 py-3",children:[m.jsx(Er,{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:n.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(ra,{className:"h-3.5 w-3.5"}),"Resolve"]}),m.jsx("button",{type:"button",disabled:!s.trim()||r.isPending,onClick:()=>r.mutate({commentId:n.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 _7(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function D7(e){const n=e.name.toLowerCase(),r=e.type;return/\.pdf$/.test(n)||r==="application/pdf"?{Icon:sb,tint:"bg-red-400/10 text-red-400",label:"PDF"}:/\.(xlsx?|csv|tsv)$/.test(n)||r.includes("sheet")||r==="text/csv"?{Icon:ON,tint:"bg-emerald-400/10 text-emerald-400",label:/\.csv$/.test(n)?"CSV":"XLS"}:/\.(md|mdx|markdown)$/.test(n)||r==="text/markdown"?{Icon:g1,tint:"bg-sky-400/10 text-sky-400",label:"MD"}:/\.(docx?|rtf)$/.test(n)||r.includes("word")?{Icon:DN,tint:"bg-blue-400/10 text-blue-400",label:"DOC"}:r.startsWith("image/")||/\.(png|jpe?g|gif|webp|svg|avif)$/.test(n)?{Icon:jN,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(n)||r.includes("json")?{Icon:CN,tint:"bg-amber-400/10 text-amber-400",label:"CODE"}:r.startsWith("text/")||/\.(txt|log|env)$/.test(n)?{Icon:sb,tint:"bg-slate-400/10 text-slate-400",label:"TXT"}:{Icon:zN,tint:"bg-muted text-muted-foreground",label:(n.split(".").pop()??"file").slice(0,4).toUpperCase()}}const nk=e=>e.type==="text/markdown"||/\.(md|mdx|markdown)$/i.test(e.name),M7=e=>e.type.startsWith("text/")||e.type.includes("json")||nk(e)||/\.(txt|json|ya?ml|csv|tsv|ts|tsx|js|jsx|html|css|toml|env|log)$/i.test(e.name);function rk(e){return`${e.trim().toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"note"}.md`}const z7=e=>rk((e.split(`
81
- `).map(n=>n.replace(/^#+\s*/,"").trim()).find(Boolean)??"").slice(0,60));function L7({domainId:e}){const{data:n}=kT(e),r=Bt(),i=()=>r.invalidateQueries({queryKey:Se.documents(e)}),[o,s]=k.useState(!1),[u,d]=k.useState(null),h=sn({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=sn({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?rk(C):z7(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 E=w.dataTransfer.getData("text/plain");E.trim()&&(w.preventDefault(),p(E))};if(!n)return m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading…"});const b=n.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(P7,{domainId:e}),b===0?m.jsxs("div",{className:"space-y-4",children:[m.jsx(Q0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx(H7,{busy:h.isPending,onFiles:y})]}):m.jsxs("div",{className:"space-y-6",children:[m.jsx(Q0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:n.map(w=>m.jsx(U7,{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(Hm,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm font-medium",children:"Drop to add"})]})}),u&&m.jsx(B7,{domainId:e,doc:u,onClose:()=>d(null),onSaved:i})]})}function ak({expanded:e,onClick:n}){const r=e?mA:uA,i=e?"Collapse editor":"Expand editor";return m.jsx("button",{type:"button",title:i,"aria-label":i,onClick:n,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 P7({domainId:e}){const[n,r]=k.useState(""),[i,o]=k.useState(!1),[s,u]=k.useState(!1),d=fs(e),h=Um(e),f=Zr(C=>C.setRun),y=Bt(),p=wc(h),v=d.data?.available??!1,b=n.trim().length>0&&!s&&!p&&v,w=async()=>{if(b){u(!0);try{const C=await je.agentSubmit(e,n.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(Er,{autoFocus:!0,value:n,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(ak,{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(cn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Lm,{className:"h-3.5 w-3.5"})," ","Send to agent"]})]})]})}function Q0({hero:e,busy:n,onText:r,onFiles:i}){const[o,s]=k.useState(""),[u,d]=k.useState(!1),h=k.useRef(null),f=()=>{!o.trim()||n||(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(Er,{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(ak,{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(Hm,{className:"h-4 w-4"})," ",n?"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:n,children:[m.jsx(f1,{className:"h-3.5 w-3.5"})," Save"]})]})]})}function H7({busy:e,onFiles:n}){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(Hm,{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=>{n(i.target.files),i.target.value=""}})]})}function U7({domainId:e,doc:n,onEdit:r,onDelete:i}){const o=D7(n),s=async()=>{try{await navigator.clipboard.writeText(await je.docContent(e,n.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:[M7(n)&&m.jsx(qh,{title:"Copy",onClick:s,children:m.jsx(d1,{className:"h-3.5 w-3.5"})}),nk(n)&&m.jsx(qh,{title:"Edit",onClick:r,children:m.jsx(v1,{className:"h-3.5 w-3.5"})}),m.jsx(qh,{title:"Remove",danger:!0,onClick:i,children:m.jsx(Jo,{className:"h-3.5 w-3.5"})})]})]}),m.jsxs("a",{href:je.docUrl(e,n.id),target:"_blank",rel:"noreferrer",className:"min-w-0",children:[m.jsx("div",{className:"truncate text-[13px] font-medium leading-snug",title:n.name,children:n.name}),m.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[o.label," · ",_7(n.size)]})]})]})}function qh({title:e,onClick:n,danger:r,children:i}){return m.jsx("button",{type:"button",title:e,onClick:n,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 B7({domainId:e,doc:n,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,n.id).then(y=>f&&s(y)).catch(()=>{f&&(Ee.error("Could not load document"),s(""))}),()=>{f=!1}},[e,n.id]);const h=async()=>{if(o!=null){d(!0);try{await je.updateDocument(e,n.id,o),Ee.success("Saved"),i(),r()}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx($l,{open:!0,onOpenChange:f=>!f&&r(),children:m.jsxs(zi,{className:"max-w-2xl",children:[m.jsx(Vl,{children:m.jsx(Li,{className:"truncate text-sm",children:n.name})}),m.jsx(Er,{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 G0(e,n,r,i){return e.find(o=>o.owner===n&&o.method===r&&o.ownerKind===i)}function ik(e){const n=e?.auth;return n?n==="anonymous"?{level:"public",icon:qN,tone:"sky",label:"Anonymous",auth:n,blurb:"The callable contract permits anonymous callers."}:{level:"secured",icon:LA,tone:"emerald",label:n==="authorized"?"Authorized":"Authenticated",auth:n,blurb:n==="authorized"?"The callable contract requires authorization.":"The callable contract requires an authenticated principal."}:null}const I7={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 q7({method:e,interactive:n=!0}){const r=ik(e);if(!r)return null;const i=r.icon,o=ge("inline-flex items-center justify-center rounded-md transition-colors",I7[r.tone]);return m.jsxs(Ip,{openDelay:80,children:[m.jsx(qp,{asChild:!0,children:n?m.jsx("button",{type:"button","aria-label":`Authorization: ${r.label}`,className:o,children:m.jsx(i,{className:"h-3.5 w-3.5"})}):m.jsx("span",{role:"img","aria-label":`Authorization: ${r.label}`,className:o,children:m.jsx(i,{className:"h-3.5 w-3.5"})})}),m.jsx(Vc,{align:"start",className:"w-96 p-0 overflow-hidden",children:m.jsx(F7,{method:e})})]})}function F7({method:e}){const n=ik(e);if(!n)return null;const r=n.icon;return m.jsxs("div",{className:"text-[13px]",children:[m.jsxs("div",{className:"flex items-start gap-2.5 p-3",children:[m.jsx(Si,{tone:n.tone,size:"sm",children:m.jsx(r,{})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"flex items-center gap-2",children:m.jsx("span",{className:"font-semibold text-foreground",children:n.label})}),m.jsx("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:n.blurb})]})]}),m.jsx("div",{className:"flex flex-wrap gap-1.5 border-t px-3 py-2",children:m.jsxs(Bn,{tone:"outline",className:"font-mono",children:["auth: ",n.auth]})})]})}function CP(e,n){const r=pc(e),i=n??r.optional;switch(r.kind){case"string":return{label:"Text",icon:XA,optional:i};case"number":case"integer":return{label:"Number",icon:g1,optional:i};case"boolean":return{label:"Yes / no",icon:YA,optional:i};case"enum":{const o=r.values.map(String);return{label:`One of: ${o.slice(0,3).join(", ")}${o.length>3?"…":""}`,icon:rA,optional:i}}case"array":return{label:"List",icon:iA,optional:i};case"object":return{label:"Object",icon:s1,optional:i};case"ref":return{label:"Reference",icon:tA,optional:i};default:return{label:"Value",icon:fN,optional:i}}}function $7(e){return e.inheritance==="sealed"?{icon:y1,tone:"amber"}:e.inheritance==="abstract"?{icon:CA,tone:"fuchsia"}:{icon:Gh,tone:"violet"}}function V7(e){if(!e||typeof e!="object"||Array.isArray(e))return 0;const n=e;return(n.nodes&&typeof n.nodes=="object"&&!Array.isArray(n.nodes)?Object.keys(n.nodes).length:0)+(Array.isArray(n.edges)?n.edges.length:0)}function Y7(e){const n=new Set,r=[];for(const i of e)for(const o of Array.isArray(i.viewFor)?i.viewFor:i.viewFor?[i.viewFor]:[])n.has(o)||(n.add(o),r.push(o));return r}function Q7({domainId:e}){const n=Sc(e),r=E1(e),i=Ce(E=>E.setSection),o=Ce(E=>E.focusClass),s=Ce(E=>E.setPanelOverlay),u=n.data,d=r.data,h=u?.ir??null,f=k.useMemo(()=>V7(h?.core),[h?.core]),y=k.useMemo(()=>{if(!h||!u)return[];const E=[],j=Object.entries(h.functions);j.length>0&&E.push({owner:h.domain,label:"Domain callables",className:null,fns:j.map(([A,R])=>({owner:h.domain,ownerKind:"function",name:A,method:R,link:G0(u.overlay.handlerLinks,h.domain,A,"function")}))});for(const A of Object.values(h.classes)){const R=Object.entries(A.methods??{});if(R.length===0)continue;const B=R.map(([P,_])=>({owner:A.name,ownerKind:"class",name:P,method:_,link:G0(u.overlay.handlerLinks,A.name,P,"class")}));E.push({owner:A.name,label:A.name,className:A.name,fns:B})}return E.sort((A,R)=>A.className===null&&R.className!==null?-1:A.className!==null&&R.className===null?1:0)},[h,u]),p=y.reduce((E,j)=>E+j.fns.length,0),v=d?.views??[],b=k.useMemo(()=>Y7(v),[v]),w=E=>{i("schema"),o(`class.${E}`)},C=()=>{i("schema"),s("views")};return n.isLoading||r.isLoading?m.jsx("div",{className:"flex items-center justify-center p-8 text-sm text-muted-foreground",children:"Loading…"}):m.jsx(Nm,{title:"Process",subtitle:"Actions and workflows implementing callable contracts",icon:m.jsx(ic,{className:"h-5 w-5"}),children:h?m.jsxs(m.Fragment,{children:[m.jsx(B0,{label:"Entrypoints",children:m.jsxs("div",{className:"space-y-2",children:[f>0?m.jsxs(Ha,{className:"flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3",children:[m.jsx(Si,{tone:"emerald",children:m.jsx(ub,{})}),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:[f," portable element",f===1?"":"s"," installed with the schema"]})]})]}):m.jsxs(Ha,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Si,{tone:"muted",children:m.jsx(ub,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"No Core genesis data declared in this schema."})]}),v.length>0&&m.jsxs(Ha,{onClick:C,className:"flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[m.jsx(Si,{tone:"sky",children:m.jsx(ZN,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"text-sm font-semibold",children:[v.length," view",v.length===1?"":"s"," ",m.jsx("span",{className:"font-normal text-muted-foreground",children:"· UI entrypoints"})]}),b.length>0&&m.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[b.slice(0,8).map(E=>m.jsx(Bn,{tone:"outline",children:E},E)),b.length>8&&m.jsxs(Bn,{tone:"default",children:["+",b.length-8]})]})]}),m.jsx(Xj,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}),m.jsxs(Ha,{className:"flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground",children:[m.jsx(Si,{tone:"muted",children:m.jsx(jA,{})}),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."})]})]})]})}),p===0?m.jsx(F2,{icon:m.jsx(ic,{}),title:"No callable contracts yet",hint:"Add a standalone Function or class Method to the schema to see it here."}):m.jsx(B0,{label:"Runtime",hint:`${p}`,children:m.jsx("div",{className:"space-y-3",children:y.map(E=>m.jsxs(Ha,{className:"overflow-hidden",children:[m.jsxs("button",{type:"button",onClick:E.className?()=>w(E.className):void 0,className:ge("flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors",E.className&&"hover:bg-accent/40"),children:[m.jsx(Si,{tone:"muted",size:"sm",children:E.className?m.jsx(o1,{}):m.jsx(s1,{})}),m.jsx("span",{className:"flex-1 truncate text-[13px] font-semibold",children:E.label}),m.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[E.fns.length," callable"]})]}),m.jsx("div",{className:"border-t",children:E.fns.map(j=>m.jsx(G7,{fn:j,onClick:j.ownerKind==="class"?()=>w(j.owner):void 0},j.name))})]},E.owner))})})]}):m.jsx(Ha,{className:"px-4 py-3 text-sm text-muted-foreground",children:"Schema unavailable — install dependencies to see this domain’s callable contracts."})})}function G7({fn:e,onClick:n}){const r=e.link?.kind==="workflow"?{icon:ic,tone:"fuchsia"}:e.link?.kind==="action"?{icon:Gh,tone:"violet"}:"inheritance"in e.method?$7(e.method):{icon:Gh,tone:"violet"},i=r.icon,o=e.link?.kernelCalls??[],s=e.link&&!e.link.implemented;return m.jsx(q2,{onClick:n,className:"px-3 py-2 border-t first:border-t-0 rounded-none",leading:m.jsx(Si,{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(q7,{method:e.method,interactive:!n}),e.link&&m.jsx(Bn,{tone:"primary",children:e.link.kind}),"static"in e.method&&e.method.static&&m.jsx(Bn,{tone:"default",children:"static"}),"inheritance"in e.method&&e.method.inheritance==="abstract"&&m.jsx(Bn,{tone:"fuchsia",children:"contract"}),s&&m.jsx(Bn,{tone:"warning",children:"needs handler"}),e.link?.unlinked&&m.jsx(Bn,{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(Bn,{tone:"outline",className:"font-mono",children:u},u)),o.length>3&&m.jsxs(Bn,{tone:"default",children:["+",o.length-3]})]}):void 0})}const K7=k.lazy(()=>Fj(async()=>{const{SchemaSection:e}=await import("./index-DTjvkOUX.js");return{SchemaSection:e}},__vite__mapDeps([0,1])).then(({SchemaSection:e})=>({default:e}))),X7=[{key:"context",label:"Context",icon:JN},{key:"schema",label:"Schema",icon:x1},{key:"process",label:"Process",icon:ic},{key:"comments",label:"Comments",icon:Ci}];function Z7({section:e,domainId:n}){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(K7,{domainId:n})});case"context":return m.jsx(L7,{domainId:n});case"process":return m.jsx(Q7,{domainId:n});case"comments":return m.jsx(T7,{domainId:n})}}function W7(){const{data:e}=k1(),n=Ce(A=>A.domainId),r=Ce(A=>A.section),i=Ce(A=>A.setDomain),o=Ce(A=>A.setSection),s=Ce(A=>A.setPaletteOpen),u=Ce(A=>A.setSettingsOpen),d=Ce(A=>A.commentMode),h=Ce(A=>A.toggleCommentMode),f=Ce(A=>A.toggleAskMode),y=CT(),p=Zr(A=>A.setRun),v=Zr(A=>A.appendEvent),b=Bt();k.useEffect(()=>{if(!n&&e&&e.length){let A=null;try{A=localStorage.getItem("studio.lastDomain")}catch{}i(A&&e.some(R=>R.id===A)?A:e[0].id)}},[e,n,i]);const w=k.useCallback(A=>{if(A.type==="hello"){const R=Ce.getState().domainId;R&&(y(R),b.invalidateQueries({queryKey:Se.agent(R)}));return}if(A.type==="workspace"){b.invalidateQueries({queryKey:Se.workspace});return}if(A.type==="agent-event"){v(A.domainId,A.runId,A.event);return}if(A.type==="agent-run"){p(A.run),b.invalidateQueries({queryKey:Se.agent(A.domainId)});return}if(A.type==="schema-diff"){y(A.domainId),b.invalidateQueries({queryKey:Se.workspace});return}"domainId"in A&&A.domainId&&y(A.domainId)},[y,p,v,b]);E7(w);const{data:C}=fs(n);k.useEffect(()=>{C?.run&&p(C.run)},[C,p]),k.useEffect(()=>{const A=R=>{const B=R.target;B&&(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.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",A),()=>window.removeEventListener("keydown",A)},[h,f]);const{data:E}=kc(n),j=E?.comments.filter(A=>A.status==="open"&&A.thread.at(-1)?.role==="author").length??0;return e?m.jsxs(IL,{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(e7,{}),m.jsx(V9,{}),n&&m.jsx(W9,{domainId:n}),n&&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(b1,{className:"h-4 w-4"})}),n&&m.jsx(C7,{domainId:n}),n&&m.jsx(Q9,{domainId:n})]}),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(_A,{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(fA,{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(QL,{})]})]}),m.jsxs("main",{className:"flex-1 min-h-0 relative overflow-hidden",children:[n?m.jsx(Z7,{section:r,domainId:n}):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:X7.map(A=>{const R=A.icon,B=r===A.key,P=A.key==="comments"?j:0;return m.jsxs(qL,{children:[m.jsx(FL,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":A.label,"aria-current":B?"page":void 0,onClick:()=>o(A.key),className:ge("relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150",B?"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]"}),P>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:P>99?"99+":P}),B&&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(j2,{side:"top",sideOffset:10,children:A.label})]},A.key)})})})]})]}),m.jsx(e9,{}),m.jsx(B9,{}),m.jsx(z9,{}),m.jsx(C8,{}),m.jsx(JL,{}),m.jsx(k7,{})]}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Connecting to studio…"})}const J7=new QE({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});cj.createRoot(document.getElementById("root")).render(m.jsx(k.StrictMode,{children:m.jsxs(wE,{client:J7,children:[m.jsx(W7,{}),m.jsx(Bj,{theme:"dark",position:"bottom-right",richColors:!0,closeButton:!0})]})}));export{Sc as $,o1 as A,Ke as B,tN as C,t9 as D,iN as E,xc as F,cT as G,iP as H,je as I,$l as J,zi as K,Li as L,Ci as M,x1 as N,bN as O,Hi as P,BE as Q,de as R,Ul as S,Q2 as T,AA as U,ra as V,cn as W,Ic as X,u1 as Y,_A as Z,Fj as _,GE as a,Op as a0,vc as a1,F2 as a2,Gj as a3,B0 as a4,rP as a5,Si as a6,SA as a7,bP as a8,CN as a9,nP as aA,gP as aB,X8 as aC,kc as aD,BL as aE,h1 as aF,m1 as aG,hs as aH,Ee as aI,Se as aJ,Z8 as aK,W8 as aL,E1 as aM,oP as aN,uP as aO,Jo as aP,Bh as aQ,pP as aR,hT as aS,k1 as aT,sP as aU,qN as aa,CP as ab,pc as ac,q2 as ad,Ip as ae,qp as af,Vc as ag,x9 as ah,J2 as ai,Bn as aj,G0 as ak,$7 as al,Ha as am,q7 as an,xP as ao,Xj as ap,cN as aq,kP as ar,KN as as,S1 as at,SP as au,aP as av,lP as aw,xA as ax,tP as ay,wP as az,ZE as b,k as c,WE as d,tj as e,JE as f,on as g,nj as h,rj as i,ej as j,pe as k,Om as l,gc as m,Ut as n,m as o,yc as p,X2 as q,Z0 as r,nc as s,Ce as t,Bt as u,Dp as v,ge as w,Qa as x,K8 as y,UA as z};
81
+ `).map(n=>n.replace(/^#+\s*/,"").trim()).find(Boolean)??"").slice(0,60));function L7({domainId:e}){const{data:n}=kT(e),r=Bt(),i=()=>r.invalidateQueries({queryKey:Se.documents(e)}),[o,s]=k.useState(!1),[u,d]=k.useState(null),h=sn({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=sn({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?rk(C):z7(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 E=w.dataTransfer.getData("text/plain");E.trim()&&(w.preventDefault(),p(E))};if(!n)return m.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Loading…"});const b=n.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(P7,{domainId:e}),b===0?m.jsxs("div",{className:"space-y-4",children:[m.jsx(Q0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx(H7,{busy:h.isPending,onFiles:y})]}):m.jsxs("div",{className:"space-y-6",children:[m.jsx(Q0,{busy:h.isPending,onText:p,onFiles:y}),m.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:n.map(w=>m.jsx(U7,{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(Hm,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm font-medium",children:"Drop to add"})]})}),u&&m.jsx(B7,{domainId:e,doc:u,onClose:()=>d(null),onSaved:i})]})}function ak({expanded:e,onClick:n}){const r=e?mA:uA,i=e?"Collapse editor":"Expand editor";return m.jsx("button",{type:"button",title:i,"aria-label":i,onClick:n,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 P7({domainId:e}){const[n,r]=k.useState(""),[i,o]=k.useState(!1),[s,u]=k.useState(!1),d=fs(e),h=Um(e),f=Zr(C=>C.setRun),y=Bt(),p=wc(h),v=d.data?.available??!1,b=n.trim().length>0&&!s&&!p&&v,w=async()=>{if(b){u(!0);try{const C=await je.agentSubmit(e,n.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(Er,{autoFocus:!0,value:n,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(ak,{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(cn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Lm,{className:"h-3.5 w-3.5"})," ","Send to agent"]})]})]})}function Q0({hero:e,busy:n,onText:r,onFiles:i}){const[o,s]=k.useState(""),[u,d]=k.useState(!1),h=k.useRef(null),f=()=>{!o.trim()||n||(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(Er,{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(ak,{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(Hm,{className:"h-4 w-4"})," ",n?"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:n,children:[m.jsx(f1,{className:"h-3.5 w-3.5"})," Save"]})]})]})}function H7({busy:e,onFiles:n}){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(Hm,{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=>{n(i.target.files),i.target.value=""}})]})}function U7({domainId:e,doc:n,onEdit:r,onDelete:i}){const o=D7(n),s=async()=>{try{await navigator.clipboard.writeText(await je.docContent(e,n.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:[M7(n)&&m.jsx(qh,{title:"Copy",onClick:s,children:m.jsx(d1,{className:"h-3.5 w-3.5"})}),nk(n)&&m.jsx(qh,{title:"Edit",onClick:r,children:m.jsx(v1,{className:"h-3.5 w-3.5"})}),m.jsx(qh,{title:"Remove",danger:!0,onClick:i,children:m.jsx(Jo,{className:"h-3.5 w-3.5"})})]})]}),m.jsxs("a",{href:je.docUrl(e,n.id),target:"_blank",rel:"noreferrer",className:"min-w-0",children:[m.jsx("div",{className:"truncate text-[13px] font-medium leading-snug",title:n.name,children:n.name}),m.jsxs("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[o.label," · ",_7(n.size)]})]})]})}function qh({title:e,onClick:n,danger:r,children:i}){return m.jsx("button",{type:"button",title:e,onClick:n,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 B7({domainId:e,doc:n,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,n.id).then(y=>f&&s(y)).catch(()=>{f&&(Ee.error("Could not load document"),s(""))}),()=>{f=!1}},[e,n.id]);const h=async()=>{if(o!=null){d(!0);try{await je.updateDocument(e,n.id,o),Ee.success("Saved"),i(),r()}catch(f){Ee.error(String(f))}finally{d(!1)}}};return m.jsx($l,{open:!0,onOpenChange:f=>!f&&r(),children:m.jsxs(zi,{className:"max-w-2xl",children:[m.jsx(Vl,{children:m.jsx(Li,{className:"truncate text-sm",children:n.name})}),m.jsx(Er,{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 G0(e,n,r,i){return e.find(o=>o.owner===n&&o.method===r&&o.ownerKind===i)}function ik(e){const n=e?.auth;return n?n==="anonymous"?{level:"public",icon:qN,tone:"sky",label:"Anonymous",auth:n,blurb:"The callable contract permits anonymous callers."}:{level:"secured",icon:LA,tone:"emerald",label:n==="authorized"?"Authorized":"Authenticated",auth:n,blurb:n==="authorized"?"The callable contract requires authorization.":"The callable contract requires an authenticated principal."}:null}const I7={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 q7({method:e,interactive:n=!0}){const r=ik(e);if(!r)return null;const i=r.icon,o=ge("inline-flex items-center justify-center rounded-md transition-colors",I7[r.tone]);return m.jsxs(Ip,{openDelay:80,children:[m.jsx(qp,{asChild:!0,children:n?m.jsx("button",{type:"button","aria-label":`Authorization: ${r.label}`,className:o,children:m.jsx(i,{className:"h-3.5 w-3.5"})}):m.jsx("span",{role:"img","aria-label":`Authorization: ${r.label}`,className:o,children:m.jsx(i,{className:"h-3.5 w-3.5"})})}),m.jsx(Vc,{align:"start",className:"w-96 p-0 overflow-hidden",children:m.jsx(F7,{method:e})})]})}function F7({method:e}){const n=ik(e);if(!n)return null;const r=n.icon;return m.jsxs("div",{className:"text-[13px]",children:[m.jsxs("div",{className:"flex items-start gap-2.5 p-3",children:[m.jsx(Si,{tone:n.tone,size:"sm",children:m.jsx(r,{})}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"flex items-center gap-2",children:m.jsx("span",{className:"font-semibold text-foreground",children:n.label})}),m.jsx("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:n.blurb})]})]}),m.jsx("div",{className:"flex flex-wrap gap-1.5 border-t px-3 py-2",children:m.jsxs(Bn,{tone:"outline",className:"font-mono",children:["auth: ",n.auth]})})]})}function CP(e,n){const r=pc(e),i=n??r.optional;switch(r.kind){case"string":return{label:"Text",icon:XA,optional:i};case"number":case"integer":return{label:"Number",icon:g1,optional:i};case"boolean":return{label:"Yes / no",icon:YA,optional:i};case"enum":{const o=r.values.map(String);return{label:`One of: ${o.slice(0,3).join(", ")}${o.length>3?"…":""}`,icon:rA,optional:i}}case"array":return{label:"List",icon:iA,optional:i};case"object":return{label:"Object",icon:s1,optional:i};case"ref":return{label:"Reference",icon:tA,optional:i};default:return{label:"Value",icon:fN,optional:i}}}function $7(e){return e.inheritance==="sealed"?{icon:y1,tone:"amber"}:e.inheritance==="abstract"?{icon:CA,tone:"fuchsia"}:{icon:Gh,tone:"violet"}}function V7(e){if(!e||typeof e!="object"||Array.isArray(e))return 0;const n=e;return(n.nodes&&typeof n.nodes=="object"&&!Array.isArray(n.nodes)?Object.keys(n.nodes).length:0)+(Array.isArray(n.edges)?n.edges.length:0)}function Y7(e){const n=new Set,r=[];for(const i of e)for(const o of Array.isArray(i.viewFor)?i.viewFor:i.viewFor?[i.viewFor]:[])n.has(o)||(n.add(o),r.push(o));return r}function Q7({domainId:e}){const n=Sc(e),r=E1(e),i=Ce(E=>E.setSection),o=Ce(E=>E.focusClass),s=Ce(E=>E.setPanelOverlay),u=n.data,d=r.data,h=u?.ir??null,f=k.useMemo(()=>V7(h?.core),[h?.core]),y=k.useMemo(()=>{if(!h||!u)return[];const E=[],j=Object.entries(h.functions);j.length>0&&E.push({owner:h.domain,label:"Domain callables",className:null,fns:j.map(([A,R])=>({owner:h.domain,ownerKind:"function",name:A,method:R,link:G0(u.overlay.handlerLinks,h.domain,A,"function")}))});for(const A of Object.values(h.classes)){const R=Object.entries(A.methods??{});if(R.length===0)continue;const B=R.map(([P,_])=>({owner:A.name,ownerKind:"class",name:P,method:_,link:G0(u.overlay.handlerLinks,A.name,P,"class")}));E.push({owner:A.name,label:A.name,className:A.name,fns:B})}return E.sort((A,R)=>A.className===null&&R.className!==null?-1:A.className!==null&&R.className===null?1:0)},[h,u]),p=y.reduce((E,j)=>E+j.fns.length,0),v=d?.views??[],b=k.useMemo(()=>Y7(v),[v]),w=E=>{i("schema"),o(`class.${E}`)},C=()=>{i("schema"),s("views")};return n.isLoading||r.isLoading?m.jsx("div",{className:"flex items-center justify-center p-8 text-sm text-muted-foreground",children:"Loading…"}):m.jsx(Nm,{title:"Process",subtitle:"Actions and workflows implementing callable contracts",icon:m.jsx(ic,{className:"h-5 w-5"}),children:h?m.jsxs(m.Fragment,{children:[m.jsx(B0,{label:"Entrypoints",children:m.jsxs("div",{className:"space-y-2",children:[f>0?m.jsxs(Ha,{className:"flex items-center gap-3 border-emerald-500/30 bg-emerald-500/[0.04] px-4 py-3",children:[m.jsx(Si,{tone:"emerald",children:m.jsx(ub,{})}),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:[f," portable element",f===1?"":"s"," installed with the schema"]})]})]}):m.jsxs(Ha,{className:"flex items-center gap-3 px-4 py-3 text-muted-foreground",children:[m.jsx(Si,{tone:"muted",children:m.jsx(ub,{})}),m.jsx("div",{className:"min-w-0 flex-1 text-[13px]",children:"No Core genesis data declared in this schema."})]}),v.length>0&&m.jsxs(Ha,{onClick:C,className:"flex cursor-pointer items-center gap-3 px-4 py-3 transition-colors hover:bg-accent/50",children:[m.jsx(Si,{tone:"sky",children:m.jsx(ZN,{})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"text-sm font-semibold",children:[v.length," view",v.length===1?"":"s"," ",m.jsx("span",{className:"font-normal text-muted-foreground",children:"· UI entrypoints"})]}),b.length>0&&m.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[b.slice(0,8).map(E=>m.jsx(Bn,{tone:"outline",children:E},E)),b.length>8&&m.jsxs(Bn,{tone:"default",children:["+",b.length-8]})]})]}),m.jsx(Xj,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]}),m.jsxs(Ha,{className:"flex items-center gap-3 border-dashed px-4 py-3 text-muted-foreground",children:[m.jsx(Si,{tone:"muted",children:m.jsx(jA,{})}),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."})]})]})]})}),p===0?m.jsx(F2,{icon:m.jsx(ic,{}),title:"No callable contracts yet",hint:"Add a standalone Function or class Method to the schema to see it here."}):m.jsx(B0,{label:"Runtime",hint:`${p}`,children:m.jsx("div",{className:"space-y-3",children:y.map(E=>m.jsxs(Ha,{className:"overflow-hidden",children:[m.jsxs("button",{type:"button",onClick:E.className?()=>w(E.className):void 0,className:ge("flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors",E.className&&"hover:bg-accent/40"),children:[m.jsx(Si,{tone:"muted",size:"sm",children:E.className?m.jsx(o1,{}):m.jsx(s1,{})}),m.jsx("span",{className:"flex-1 truncate text-[13px] font-semibold",children:E.label}),m.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:[E.fns.length," callable"]})]}),m.jsx("div",{className:"border-t",children:E.fns.map(j=>m.jsx(G7,{fn:j,onClick:j.ownerKind==="class"?()=>w(j.owner):void 0},j.name))})]},E.owner))})})]}):m.jsx(Ha,{className:"px-4 py-3 text-sm text-muted-foreground",children:"Schema unavailable — install dependencies to see this domain’s callable contracts."})})}function G7({fn:e,onClick:n}){const r=e.link?.kind==="workflow"?{icon:ic,tone:"fuchsia"}:e.link?.kind==="action"?{icon:Gh,tone:"violet"}:"inheritance"in e.method?$7(e.method):{icon:Gh,tone:"violet"},i=r.icon,o=e.link?.kernelCalls??[],s=e.link&&!e.link.implemented;return m.jsx(q2,{onClick:n,className:"px-3 py-2 border-t first:border-t-0 rounded-none",leading:m.jsx(Si,{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(q7,{method:e.method,interactive:!n}),e.link&&m.jsx(Bn,{tone:"primary",children:e.link.kind}),"static"in e.method&&e.method.static&&m.jsx(Bn,{tone:"default",children:"static"}),"inheritance"in e.method&&e.method.inheritance==="abstract"&&m.jsx(Bn,{tone:"fuchsia",children:"contract"}),s&&m.jsx(Bn,{tone:"warning",children:"needs handler"}),e.link?.unlinked&&m.jsx(Bn,{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(Bn,{tone:"outline",className:"font-mono",children:u},u)),o.length>3&&m.jsxs(Bn,{tone:"default",children:["+",o.length-3]})]}):void 0})}const K7=k.lazy(()=>Fj(async()=>{const{SchemaSection:e}=await import("./index-B0RCgUOT.js");return{SchemaSection:e}},__vite__mapDeps([0,1])).then(({SchemaSection:e})=>({default:e}))),X7=[{key:"context",label:"Context",icon:JN},{key:"schema",label:"Schema",icon:x1},{key:"process",label:"Process",icon:ic},{key:"comments",label:"Comments",icon:Ci}];function Z7({section:e,domainId:n}){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(K7,{domainId:n})});case"context":return m.jsx(L7,{domainId:n});case"process":return m.jsx(Q7,{domainId:n});case"comments":return m.jsx(T7,{domainId:n})}}function W7(){const{data:e}=k1(),n=Ce(A=>A.domainId),r=Ce(A=>A.section),i=Ce(A=>A.setDomain),o=Ce(A=>A.setSection),s=Ce(A=>A.setPaletteOpen),u=Ce(A=>A.setSettingsOpen),d=Ce(A=>A.commentMode),h=Ce(A=>A.toggleCommentMode),f=Ce(A=>A.toggleAskMode),y=CT(),p=Zr(A=>A.setRun),v=Zr(A=>A.appendEvent),b=Bt();k.useEffect(()=>{if(!n&&e&&e.length){let A=null;try{A=localStorage.getItem("studio.lastDomain")}catch{}i(A&&e.some(R=>R.id===A)?A:e[0].id)}},[e,n,i]);const w=k.useCallback(A=>{if(A.type==="hello"){const R=Ce.getState().domainId;R&&(y(R),b.invalidateQueries({queryKey:Se.agent(R)}));return}if(A.type==="workspace"){b.invalidateQueries({queryKey:Se.workspace});return}if(A.type==="agent-event"){v(A.domainId,A.runId,A.event);return}if(A.type==="agent-run"){p(A.run),b.invalidateQueries({queryKey:Se.agent(A.domainId)});return}if(A.type==="schema-diff"){y(A.domainId),b.invalidateQueries({queryKey:Se.workspace});return}"domainId"in A&&A.domainId&&y(A.domainId)},[y,p,v,b]);E7(w);const{data:C}=fs(n);k.useEffect(()=>{C?.run&&p(C.run)},[C,p]),k.useEffect(()=>{const A=R=>{const B=R.target;B&&(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.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",A),()=>window.removeEventListener("keydown",A)},[h,f]);const{data:E}=kc(n),j=E?.comments.filter(A=>A.status==="open"&&A.thread.at(-1)?.role==="author").length??0;return e?m.jsxs(IL,{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(e7,{}),m.jsx(V9,{}),n&&m.jsx(W9,{domainId:n}),n&&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(b1,{className:"h-4 w-4"})}),n&&m.jsx(C7,{domainId:n}),n&&m.jsx(Q9,{domainId:n})]}),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(_A,{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(fA,{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(QL,{})]})]}),m.jsxs("main",{className:"flex-1 min-h-0 relative overflow-hidden",children:[n?m.jsx(Z7,{section:r,domainId:n}):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:X7.map(A=>{const R=A.icon,B=r===A.key,P=A.key==="comments"?j:0;return m.jsxs(qL,{children:[m.jsx(FL,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":A.label,"aria-current":B?"page":void 0,onClick:()=>o(A.key),className:ge("relative h-11 w-11 rounded-xl flex items-center justify-center transition-all duration-150",B?"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]"}),P>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:P>99?"99+":P}),B&&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(j2,{side:"top",sideOffset:10,children:A.label})]},A.key)})})})]})]}),m.jsx(e9,{}),m.jsx(B9,{}),m.jsx(z9,{}),m.jsx(C8,{}),m.jsx(JL,{}),m.jsx(k7,{})]}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Connecting to studio…"})}const J7=new QE({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1,retry:1}}});cj.createRoot(document.getElementById("root")).render(m.jsx(k.StrictMode,{children:m.jsxs(wE,{client:J7,children:[m.jsx(W7,{}),m.jsx(Bj,{theme:"dark",position:"bottom-right",richColors:!0,closeButton:!0})]})}));export{Sc as $,o1 as A,Ke as B,tN as C,t9 as D,iN as E,xc as F,cT as G,iP as H,je as I,$l as J,zi as K,Li as L,Ci as M,x1 as N,bN as O,Hi as P,BE as Q,de as R,Ul as S,Q2 as T,AA as U,ra as V,cn as W,Ic as X,u1 as Y,_A as Z,Fj as _,GE as a,Op as a0,vc as a1,F2 as a2,Gj as a3,B0 as a4,rP as a5,Si as a6,SA as a7,bP as a8,CN as a9,nP as aA,gP as aB,X8 as aC,kc as aD,BL as aE,h1 as aF,m1 as aG,hs as aH,Ee as aI,Se as aJ,Z8 as aK,W8 as aL,E1 as aM,oP as aN,uP as aO,Jo as aP,Bh as aQ,pP as aR,hT as aS,k1 as aT,sP as aU,qN as aa,CP as ab,pc as ac,q2 as ad,Ip as ae,qp as af,Vc as ag,x9 as ah,J2 as ai,Bn as aj,G0 as ak,$7 as al,Ha as am,q7 as an,xP as ao,Xj as ap,cN as aq,kP as ar,KN as as,S1 as at,SP as au,aP as av,lP as aw,xA as ax,tP as ay,wP as az,ZE as b,k as c,WE as d,tj as e,JE as f,on as g,nj as h,rj as i,ej as j,pe as k,Om as l,gc as m,Ut as n,m as o,yc as p,X2 as q,Z0 as r,nc as s,Ce as t,Bt as u,Dp as v,ge as w,Qa as x,K8 as y,UA as z};