truecourse 0.6.0-next.7 → 0.6.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cli.mjs +22 -3
- package/package.json +1 -1
- package/public/assets/{index-CkKIAyL2.js → index-BABCLoif.js} +3 -3
- package/public/index.html +1 -1
- package/server.mjs +15 -2
|
@@ -535,7 +535,7 @@ Please change the parent <Route path="${x}"> to <Route path="${x==="/"?"*":`${x}
|
|
|
535
535
|
*/const Ine=Ae("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function xS(){return typeof window<"u"}function OO(t){return kq(t)?(t.nodeName||"").toLowerCase():"#document"}function ai(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function kl(t){var e;return(e=(kq(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function kq(t){return xS()?t instanceof Node||t instanceof ai(t).Node:!1}function jn(t){return xS()?t instanceof Element||t instanceof ai(t).Element:!1}function yi(t){return xS()?t instanceof HTMLElement||t instanceof ai(t).HTMLElement:!1}function qy(t){return!xS()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ai(t).ShadowRoot}function fO(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=fo(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&i!=="inline"&&i!=="contents"}function nxe(t){return/^(table|td|th)$/.test(OO(t))}function QS(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const rxe=/transform|translate|scale|rotate|perspective|filter/,ixe=/paint|layout|strict|content/,HO=t=>!!t&&t!=="none";let pk;function _q(t){const e=jn(t)?fo(t):t;return HO(e.transform)||HO(e.translate)||HO(e.scale)||HO(e.rotate)||HO(e.perspective)||!bS()&&(HO(e.backdropFilter)||HO(e.filter))||rxe.test(e.willChange||"")||ixe.test(e.contain||"")}function axe(t){let e=Cc(t);for(;yi(e)&&!bc(e);){if(_q(e))return e;if(QS(e))return null;e=Cc(e)}return null}function bS(){return pk==null&&(pk=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),pk}function bc(t){return/^(html|body|#document)$/.test(OO(t))}function fo(t){return ai(t).getComputedStyle(t)}function SS(t){return jn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Cc(t){if(OO(t)==="html")return t;const e=t.assignedSlot||t.parentNode||qy(t)&&t.host||kl(t);return qy(e)?e.host:e}function Dne(t){const e=Cc(t);return bc(e)?t.ownerDocument?t.ownerDocument.body:t.body:yi(e)&&fO(e)?e:Dne(e)}function Zy(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Dne(t),a=i===((r=t.ownerDocument)==null?void 0:r.body),o=ai(i);if(a){const s=zC(o);return e.concat(o,o.visualViewport||[],fO(i)?i:[],s&&n?Zy(s):[])}else return e.concat(i,Zy(i,[],n))}function zC(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const e8={};function yo(t,e){const n=_.useRef(e8);return n.current===e8&&(n.current=t(e)),n}const mk=tne[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],oxe=mk&&mk!==_.useLayoutEffect?mk:t=>t();function tn(t){const e=yo(sxe).current;return e.next=t,oxe(e.effect),e.trampoline}function sxe(){const t={next:void 0,callback:lxe,trampoline:(...e)=>{var n;return(n=t.callback)==null?void 0:n.call(t,...e)},effect:()=>{t.callback=t.next}};return t}function lxe(){}const cxe={...tne},uxe=()=>{},qt=typeof document<"u"?_.useLayoutEffect:uxe;function YC(t,e){if(t&&!e)return t;if(!t&&e)return e;if(t||e)return{...t,...e}}const sy={};function Xq(t,e,n,r,i){let a={...AC(t,sy)};return e&&(a=Pb(a,e)),n&&(a=Pb(a,n)),r&&(a=Pb(a,r)),a}function Oxe(t){if(t.length===0)return sy;if(t.length===1)return AC(t[0],sy);let e={...AC(t[0],sy)};for(let n=1;n<t.length;n+=1)e=Pb(e,t[n]);return e}function Pb(t,e){return Lne(e)?e(t):fxe(t,e)}function fxe(t,e){if(!e)return t;for(const n in e){const r=e[n];switch(n){case"style":{t[n]=YC(t.style,r);break}case"className":{t[n]=Gne(t.className,r);break}default:dxe(n,r)?t[n]=hxe(t[n],r):t[n]=r}}return t}function dxe(t,e){const n=t.charCodeAt(0),r=t.charCodeAt(1),i=t.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof e=="function"||typeof e>"u")}function Lne(t){return typeof t=="function"}function AC(t,e){return Lne(t)?t(e):t??sy}function hxe(t,e){return e?t?n=>{if(pxe(n)){const i=n;qC(i);const a=e(i);return i.baseUIHandlerPrevented||t==null||t(i),a}const r=e(n);return t==null||t(n),r}:e:t}function qC(t){return t.preventBaseUIHandler=()=>{t.baseUIHandlerPrevented=!0},t}function Gne(t,e){return e?t?e+" "+t:e:t}function pxe(t){return t!=null&&typeof t=="object"&&"nativeEvent"in t}function mxe(t,e){return function(r,...i){const a=new URL(t);return a.searchParams.set("code",r.toString()),i.forEach(o=>a.searchParams.append("args[]",o)),`${e} error #${r}; visit ${a} for the full message.`}}const _s=mxe("https://base-ui.com/production-error","Base UI"),gxe=_.createContext(void 0);function yxe(t=!1){const e=_.useContext(gxe);if(e===void 0&&!t)throw new Error(_s(16));return e}function $xe(t){const{focusableWhenDisabled:e,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=t,o=r&&e!==!1,s=r&&e===!1;return{props:_.useMemo(()=>{const c={onKeyDown(u){n&&e&&u.key!=="Tab"&&u.preventDefault()}};return r||(c.tabIndex=i,!a&&n&&(c.tabIndex=e?i:-1)),(a&&(e||o)||!a&&n)&&(c["aria-disabled"]=n),a&&(!e||s)&&(c.disabled=n),c},[r,n,e,o,s,a,i])}}function Rq(t={}){const{disabled:e=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=t,o=_.useRef(null),s=yxe(!0),l=a??s!==void 0,{props:c}=$xe({focusableWhenDisabled:n,disabled:e,composite:l,tabIndex:r,isNativeButton:i}),u=_.useCallback(()=>{const p=o.current;gk(p)&&l&&e&&c.disabled===void 0&&p.disabled&&(p.disabled=!1)},[e,c.disabled,l]);qt(u,[u]);const f=_.useCallback((p={})=>{const{onClick:y,onMouseDown:v,onKeyUp:$,onKeyDown:x,onPointerDown:S,...b}=p;return Xq({type:i?"button":void 0,onClick(w){if(e){w.preventDefault();return}y==null||y(w)},onMouseDown(w){e||v==null||v(w)},onKeyDown(w){if(e||(qC(w),x==null||x(w),w.baseUIHandlerPrevented))return;const P=w.target===w.currentTarget,k=w.currentTarget,R=gk(k),E=!i&&vxe(k),C=P&&(i?R:!E),z=w.key==="Enter",Y=w.key===" ",W=k.getAttribute("role"),A=(W==null?void 0:W.startsWith("menuitem"))||W==="option"||W==="gridcell";if(P&&l&&Y){if(w.defaultPrevented&&A)return;w.preventDefault(),E||i&&R?(k.click(),w.preventBaseUIHandler()):C&&(y==null||y(w),w.preventBaseUIHandler());return}C&&(!i&&(Y||z)&&w.preventDefault(),!i&&z&&(y==null||y(w)))},onKeyUp(w){if(!e){if(qC(w),$==null||$(w),w.target===w.currentTarget&&i&&l&&gk(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!i&&!l&&w.key===" "&&(y==null||y(w))}},onPointerDown(w){if(e){w.preventDefault();return}S==null||S(w)}},i?void 0:{role:"button"},c,b)},[e,c,l,i]),h=tn(p=>{o.current=p,u()});return{getButtonProps:f,buttonRef:h}}function gk(t){return yi(t)&&t.tagName==="BUTTON"}function vxe(t){return!!((t==null?void 0:t.tagName)==="A"&&(t!=null&&t.href))}function a0(t,e,n,r){const i=yo(Bne).current;return Qxe(i,t,e,n,r)&&Fne(i,[t,e,n,r]),i.callback}function xxe(t){const e=yo(Bne).current;return bxe(e,t)&&Fne(e,t),e.callback}function Bne(){return{callback:null,cleanup:null,refs:[]}}function Qxe(t,e,n,r,i){return t.refs[0]!==e||t.refs[1]!==n||t.refs[2]!==r||t.refs[3]!==i}function bxe(t,e){return t.refs.length!==e.length||t.refs.some((n,r)=>n!==e[r])}function Fne(t,e){if(t.refs=e,e.every(n=>n==null)){t.callback=null;return}t.callback=n=>{if(t.cleanup&&(t.cleanup(),t.cleanup=null),n!=null){const r=Array(e.length).fill(null);for(let i=0;i<e.length;i+=1){const a=e[i];if(a!=null)switch(typeof a){case"function":{const o=a(n);typeof o=="function"&&(r[i]=o);break}case"object":{a.current=n;break}}}t.cleanup=()=>{for(let i=0;i<e.length;i+=1){const a=e[i];if(a!=null)switch(typeof a){case"function":{const o=r[i];typeof o=="function"?o():a(null);break}case"object":{a.current=null;break}}}}}}}const Sxe=parseInt(_.version,10);function jq(t){return Sxe>=t}function t8(t){if(!_.isValidElement(t))return null;const e=t,n=e.props;return(jq(19)?n==null?void 0:n.ref:e.ref)??null}function wxe(t,e){const n={};for(const r in t){const i=t[r];if(e!=null&&e.hasOwnProperty(r)){const a=e[r](i);a!=null&&Object.assign(n,a);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Pxe(t,e){return typeof t=="function"?t(e):t}function Txe(t,e){return typeof t=="function"?t(e):t}function Ra(){}const Ii=Object.freeze({}),kxe={style:{transition:"none"}},Hne="data-base-ui-click-trigger",_xe={fallbackAxisSide:"end"},Xxe={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function ha(t,e,n={}){const r=e.render,i=Rxe(e,n);if(n.enabled===!1)return null;const a=n.state??Ii;return Exe(t,r,i,a)}function Rxe(t,e={}){const{className:n,style:r,render:i}=t,{state:a=Ii,ref:o,props:s,stateAttributesMapping:l,enabled:c=!0}=e,u=c?Pxe(n,a):void 0,f=c?Txe(r,a):void 0,h=c?wxe(a,l):Ii,p=c?YC(h,Array.isArray(s)?Oxe(s):s)??Ii:Ii;return typeof document<"u"&&(c?Array.isArray(o)?p.ref=xxe([p.ref,t8(i),...o]):p.ref=a0(p.ref,t8(i),o):a0(null,null)),c?(u!==void 0&&(p.className=Gne(p.className,u)),f!==void 0&&(p.style=YC(p.style,f)),p):Ii}const jxe=Symbol.for("react.lazy");function Exe(t,e,n,r){if(e){if(typeof e=="function")return e(n,r);const i=Xq(n,e.props);i.ref=n.ref;let a=e;return(a==null?void 0:a.$$typeof)===jxe&&(a=_.Children.toArray(e)[0]),_.cloneElement(a,i)}if(t&&typeof t=="string")return Cxe(t,n);throw new Error(_s(8))}function Cxe(t,e){return t==="button"?_.createElement("button",{type:"button",...e,key:e.key}):t==="img"?_.createElement("img",{alt:"",...e,key:e.key}):_.createElement(t,e)}const zxe=_.forwardRef(function(e,n){const{render:r,className:i,disabled:a=!1,focusableWhenDisabled:o=!1,nativeButton:s=!0,...l}=e,{getButtonProps:c,buttonRef:u}=Rq({disabled:a,focusableWhenDisabled:o,native:s});return ha("button",e,{state:{disabled:a},ref:[n,u],props:[l,c]})});function Kne(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=Kne(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function zt(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=Kne(t))&&(r&&(r+=" "),r+=e);return r}const n8=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,r8=zt,Eq=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return r8(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],f=a==null?void 0:a[c];if(u===null)return null;const h=n8(u)||n8(f);return i[c][h]}),s=n&&Object.entries(n).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:f,className:h,...p}=u;return Object.entries(p).every(y=>{let[v,$]=y;return Array.isArray($)?$.includes({...a,...s}[v]):{...a,...s}[v]===$})?[...c,f,h]:c},[]);return r8(t,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},Yxe=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},Axe=(t,e)=>({classGroupId:t,validator:e}),Jne=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),o0="-",i8=[],qxe="arbitrary..",Zxe=t=>{const e=Uxe(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Vxe(o);const s=o.split(o0),l=s[0]===""&&s.length>1?1:0;return ere(s,l,e)},getConflictingClassGroupIds:(o,s)=>{if(s){const l=r[o],c=n[o];return l?c?Yxe(c,l):l:c||i8}return n[o]||i8}}},ere=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const i=t[e],a=n.nextPart.get(i);if(a){const c=ere(t,e+1,a);if(c)return c}const o=n.validators;if(o===null)return;const s=e===0?t.join(o0):t.slice(e).join(o0),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(s))return u.classGroupId}},Vxe=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?qxe+r:void 0})(),Uxe=t=>{const{theme:e,classGroups:n}=t;return Nxe(n,e)},Nxe=(t,e)=>{const n=Jne();for(const r in t){const i=t[r];Cq(i,n,r,e)}return n},Cq=(t,e,n,r)=>{const i=t.length;for(let a=0;a<i;a++){const o=t[a];Wxe(o,e,n,r)}},Wxe=(t,e,n,r)=>{if(typeof t=="string"){Mxe(t,e,n);return}if(typeof t=="function"){Ixe(t,e,n,r);return}Dxe(t,e,n,r)},Mxe=(t,e,n)=>{const r=t===""?e:tre(e,t);r.classGroupId=n},Ixe=(t,e,n,r)=>{if(Lxe(t)){Cq(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(Axe(n,t))},Dxe=(t,e,n,r)=>{const i=Object.entries(t),a=i.length;for(let o=0;o<a;o++){const[s,l]=i[o];Cq(l,tre(e,s),n,r)}},tre=(t,e)=>{let n=t;const r=e.split(o0),i=r.length;for(let a=0;a<i;a++){const o=r[a];let s=n.nextPart.get(o);s||(s=Jne(),n.nextPart.set(o,s)),n=s}return n},Lxe=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Gxe=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const i=(a,o)=>{n[a]=o,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(a){let o=n[a];if(o!==void 0)return o;if((o=r[a])!==void 0)return i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},ZC="!",a8=":",Bxe=[],o8=(t,e,n,r,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Fxe=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const a=[];let o=0,s=0,l=0,c;const u=i.length;for(let v=0;v<u;v++){const $=i[v];if(o===0&&s===0){if($===a8){a.push(i.slice(l,v)),l=v+1;continue}if($==="/"){c=v;continue}}$==="["?o++:$==="]"?o--:$==="("?s++:$===")"&&s--}const f=a.length===0?i:i.slice(l);let h=f,p=!1;f.endsWith(ZC)?(h=f.slice(0,-1),p=!0):f.startsWith(ZC)&&(h=f.slice(1),p=!0);const y=c&&c>l?c-l:void 0;return o8(a,p,h,y)};if(e){const i=e+a8,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):o8(Bxe,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},Hxe=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a<n.length;a++){const o=n[a],s=o[0]==="[",l=e.has(o);s||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},Kxe=t=>({cache:Gxe(t.cacheSize),parseClassName:Fxe(t),sortModifiers:Hxe(t),...Zxe(t)}),Jxe=/\s+/,eQe=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=e,o=[],s=t.trim().split(Jxe);let l="";for(let c=s.length-1;c>=0;c-=1){const u=s[c],{isExternal:f,modifiers:h,hasImportantModifier:p,baseClassName:y,maybePostfixModifierPosition:v}=n(u);if(f){l=u+(l.length>0?" "+l:l);continue}let $=!!v,x=r($?y.substring(0,v):y);if(!x){if(!$){l=u+(l.length>0?" "+l:l);continue}if(x=r(y),!x){l=u+(l.length>0?" "+l:l);continue}$=!1}const S=h.length===0?"":h.length===1?h[0]:a(h).join(":"),b=p?S+ZC:S,T=b+x;if(o.indexOf(T)>-1)continue;o.push(T);const w=i(x,$);for(let P=0;P<w.length;++P){const k=w[P];o.push(b+k)}l=u+(l.length>0?" "+l:l)}return l},tQe=(...t)=>{let e=0,n,r,i="";for(;e<t.length;)(n=t[e++])&&(r=nre(n))&&(i&&(i+=" "),i+=r);return i},nre=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=nre(t[r]))&&(n&&(n+=" "),n+=e);return n},nQe=(t,...e)=>{let n,r,i,a;const o=l=>{const c=e.reduce((u,f)=>f(u),t());return n=Kxe(c),r=n.cache.get,i=n.cache.set,a=s,s(l)},s=l=>{const c=r(l);if(c)return c;const u=eQe(l,n);return i(l,u),u};return a=o,(...l)=>a(tQe(...l))},rQe=[],hi=t=>{const e=n=>n[t]||rQe;return e.isThemeGetter=!0,e},rre=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ire=/^\((?:(\w[\w-]*):)?(.+)\)$/i,iQe=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,aQe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oQe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sQe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lQe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,cQe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Tu=t=>iQe.test(t),Lt=t=>!!t&&!Number.isNaN(Number(t)),ku=t=>!!t&&Number.isInteger(Number(t)),yk=t=>t.endsWith("%")&&Lt(t.slice(0,-1)),rc=t=>aQe.test(t),are=()=>!0,uQe=t=>oQe.test(t)&&!sQe.test(t),zq=()=>!1,OQe=t=>lQe.test(t),fQe=t=>cQe.test(t),dQe=t=>!nt(t)&&!it(t),hQe=t=>dO(t,lre,zq),nt=t=>rre.test(t),KO=t=>dO(t,cre,uQe),s8=t=>dO(t,QQe,Lt),pQe=t=>dO(t,Ore,are),mQe=t=>dO(t,ure,zq),l8=t=>dO(t,ore,zq),gQe=t=>dO(t,sre,fQe),lQ=t=>dO(t,fre,OQe),it=t=>ire.test(t),xg=t=>Hf(t,cre),yQe=t=>Hf(t,ure),c8=t=>Hf(t,ore),$Qe=t=>Hf(t,lre),vQe=t=>Hf(t,sre),cQ=t=>Hf(t,fre,!0),xQe=t=>Hf(t,Ore,!0),dO=(t,e,n)=>{const r=rre.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Hf=(t,e,n=!1)=>{const r=ire.exec(t);return r?r[1]?e(r[1]):n:!1},ore=t=>t==="position"||t==="percentage",sre=t=>t==="image"||t==="url",lre=t=>t==="length"||t==="size"||t==="bg-size",cre=t=>t==="length",QQe=t=>t==="number",ure=t=>t==="family-name",Ore=t=>t==="number"||t==="weight",fre=t=>t==="shadow",bQe=()=>{const t=hi("color"),e=hi("font"),n=hi("text"),r=hi("font-weight"),i=hi("tracking"),a=hi("leading"),o=hi("breakpoint"),s=hi("container"),l=hi("spacing"),c=hi("radius"),u=hi("shadow"),f=hi("inset-shadow"),h=hi("text-shadow"),p=hi("drop-shadow"),y=hi("blur"),v=hi("perspective"),$=hi("aspect"),x=hi("ease"),S=hi("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...T(),it,nt],P=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],R=()=>[it,nt,l],E=()=>[Tu,"full","auto",...R()],C=()=>[ku,"none","subgrid",it,nt],z=()=>["auto",{span:["full",ku,it,nt]},ku,it,nt],Y=()=>[ku,"auto",it,nt],W=()=>["auto","min","max","fr",it,nt],A=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],N=()=>["auto",...R()],Z=()=>[Tu,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],D=()=>[Tu,"screen","full","dvw","lvw","svw","min","max","fit",...R()],M=()=>[Tu,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],V=()=>[t,it,nt],I=()=>[...T(),c8,l8,{position:[it,nt]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",$Qe,hQe,{size:[it,nt]}],J=()=>[yk,xg,KO],K=()=>["","none","full",c,it,nt],H=()=>["",Lt,xg,KO],re=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=()=>[Lt,yk,c8,l8],ie=()=>["","none",y,it,nt],se=()=>["none",Lt,it,nt],ae=()=>["none",Lt,it,nt],ue=()=>[Lt,it,nt],Oe=()=>[Tu,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[rc],breakpoint:[rc],color:[are],container:[rc],"drop-shadow":[rc],ease:["in","out","in-out"],font:[dQe],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[rc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[rc],shadow:[rc],spacing:["px",Lt],text:[rc],"text-shadow":[rc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Tu,nt,it,$]}],container:["container"],columns:[{columns:[Lt,nt,it,s]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[ku,"auto",it,nt]}],basis:[{basis:[Tu,"full","auto",s,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Lt,Tu,"auto","initial","none",nt]}],grow:[{grow:["",Lt,it,nt]}],shrink:[{shrink:["",Lt,it,nt]}],order:[{order:[ku,"first","last","none",it,nt]}],"grid-cols":[{"grid-cols":C()}],"col-start-end":[{col:z()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":C()}],"row-start-end":[{row:z()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...A(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...A()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:N()}],mx:[{mx:N()}],my:[{my:N()}],ms:[{ms:N()}],me:[{me:N()}],mbs:[{mbs:N()}],mbe:[{mbe:N()}],mt:[{mt:N()}],mr:[{mr:N()}],mb:[{mb:N()}],ml:[{ml:N()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"inline-size":[{inline:["auto",...D()]}],"min-inline-size":[{"min-inline":["auto",...D()]}],"max-inline-size":[{"max-inline":["none",...D()]}],"block-size":[{block:["auto",...M()]}],"min-block-size":[{"min-block":["auto",...M()]}],"max-block-size":[{"max-block":["none",...M()]}],w:[{w:[s,"screen",...Z()]}],"min-w":[{"min-w":[s,"screen","none",...Z()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[o]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",n,xg,KO]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,xQe,pQe]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",yk,nt]}],"font-family":[{font:[yQe,mQe,e]}],"font-features":[{"font-features":[nt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,it,nt]}],"line-clamp":[{"line-clamp":[Lt,"none",it,s8]}],leading:[{leading:[a,...R()]}],"list-image":[{"list-image":["none",it,nt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",it,nt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[Lt,"from-font","auto",it,KO]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[Lt,"auto",it,nt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",it,nt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",it,nt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:I()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ku,it,nt],radial:["",it,nt],conic:[ku,it,nt]},vQe,gQe]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:K()}],"rounded-s":[{"rounded-s":K()}],"rounded-e":[{"rounded-e":K()}],"rounded-t":[{"rounded-t":K()}],"rounded-r":[{"rounded-r":K()}],"rounded-b":[{"rounded-b":K()}],"rounded-l":[{"rounded-l":K()}],"rounded-ss":[{"rounded-ss":K()}],"rounded-se":[{"rounded-se":K()}],"rounded-ee":[{"rounded-ee":K()}],"rounded-es":[{"rounded-es":K()}],"rounded-tl":[{"rounded-tl":K()}],"rounded-tr":[{"rounded-tr":K()}],"rounded-br":[{"rounded-br":K()}],"rounded-bl":[{"rounded-bl":K()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-bs":[{"border-bs":V()}],"border-color-be":[{"border-be":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Lt,it,nt]}],"outline-w":[{outline:["",Lt,xg,KO]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",u,cQ,lQ]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",f,cQ,lQ]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[Lt,KO]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",h,cQ,lQ]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[Lt,it,nt]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Lt]}],"mask-image-linear-from-pos":[{"mask-linear-from":te()}],"mask-image-linear-to-pos":[{"mask-linear-to":te()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":te()}],"mask-image-t-to-pos":[{"mask-t-to":te()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":te()}],"mask-image-r-to-pos":[{"mask-r-to":te()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":te()}],"mask-image-b-to-pos":[{"mask-b-to":te()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":te()}],"mask-image-l-to-pos":[{"mask-l-to":te()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":te()}],"mask-image-x-to-pos":[{"mask-x-to":te()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":te()}],"mask-image-y-to-pos":[{"mask-y-to":te()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[it,nt]}],"mask-image-radial-from-pos":[{"mask-radial-from":te()}],"mask-image-radial-to-pos":[{"mask-radial-to":te()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Lt]}],"mask-image-conic-from-pos":[{"mask-conic-from":te()}],"mask-image-conic-to-pos":[{"mask-conic-to":te()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:I()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",it,nt]}],filter:[{filter:["","none",it,nt]}],blur:[{blur:ie()}],brightness:[{brightness:[Lt,it,nt]}],contrast:[{contrast:[Lt,it,nt]}],"drop-shadow":[{"drop-shadow":["","none",p,cQ,lQ]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",Lt,it,nt]}],"hue-rotate":[{"hue-rotate":[Lt,it,nt]}],invert:[{invert:["",Lt,it,nt]}],saturate:[{saturate:[Lt,it,nt]}],sepia:[{sepia:["",Lt,it,nt]}],"backdrop-filter":[{"backdrop-filter":["","none",it,nt]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[Lt,it,nt]}],"backdrop-contrast":[{"backdrop-contrast":[Lt,it,nt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Lt,it,nt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Lt,it,nt]}],"backdrop-invert":[{"backdrop-invert":["",Lt,it,nt]}],"backdrop-opacity":[{"backdrop-opacity":[Lt,it,nt]}],"backdrop-saturate":[{"backdrop-saturate":[Lt,it,nt]}],"backdrop-sepia":[{"backdrop-sepia":["",Lt,it,nt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",it,nt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Lt,"initial",it,nt]}],ease:[{ease:["linear","initial",x,it,nt]}],delay:[{delay:[Lt,it,nt]}],animate:[{animate:["none",S,it,nt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,it,nt]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:ue()}],"skew-x":[{"skew-x":ue()}],"skew-y":[{"skew-y":ue()}],transform:[{transform:[it,nt,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Oe()}],"translate-x":[{"translate-x":Oe()}],"translate-y":[{"translate-y":Oe()}],"translate-z":[{"translate-z":Oe()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",it,nt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",it,nt]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[Lt,xg,KO,s8]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},SQe=nQe(bQe);function jr(...t){return SQe(zt(t))}const Tb=Eq("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function xn({className:t,variant:e="default",size:n="default",...r}){return m.jsx(zxe,{"data-slot":"button",className:jr(Tb({variant:e,size:n,className:t})),...r})}var wn;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const a={};for(const o of i)a[o]=o;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(const s of a)o[s]=i[s];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},t.find=(i,a)=>{for(const o of i)if(a(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(wn||(wn={}));var u8;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(u8||(u8={}));const rt=wn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Au=t=>{switch(typeof t){case"undefined":return rt.undefined;case"string":return rt.string;case"number":return Number.isNaN(t)?rt.nan:rt.number;case"boolean":return rt.boolean;case"function":return rt.function;case"bigint":return rt.bigint;case"symbol":return rt.symbol;case"object":return Array.isArray(t)?rt.array:t===null?rt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?rt.promise:typeof Map<"u"&&t instanceof Map?rt.map:typeof Set<"u"&&t instanceof Set?rt.set:typeof Date<"u"&&t instanceof Date?rt.date:rt.object;default:return rt.unknown}},Ve=wn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class zc extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},r={_errors:[]},i=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(n(o))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),r}static assert(e){if(!(e instanceof zc))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,wn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const a=i.path[0];n[a]=n[a]||[],n[a].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}zc.create=t=>new zc(t);const VC=(t,e)=>{let n;switch(t.code){case Ve.invalid_type:t.received===rt.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Ve.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,wn.jsonStringifyReplacer)}`;break;case Ve.unrecognized_keys:n=`Unrecognized key(s) in object: ${wn.joinValues(t.keys,", ")}`;break;case Ve.invalid_union:n="Invalid input";break;case Ve.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${wn.joinValues(t.options)}`;break;case Ve.invalid_enum_value:n=`Invalid enum value. Expected ${wn.joinValues(t.options)}, received '${t.received}'`;break;case Ve.invalid_arguments:n="Invalid function arguments";break;case Ve.invalid_return_type:n="Invalid function return type";break;case Ve.invalid_date:n="Invalid date";break;case Ve.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:wn.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Ve.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case Ve.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case Ve.custom:n="Invalid input";break;case Ve.invalid_intersection_types:n="Intersection results could not be merged";break;case Ve.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Ve.not_finite:n="Number must be finite";break;default:n=e.defaultError,wn.assertNever(t)}return{message:n}};let wQe=VC;function PQe(){return wQe}const TQe=t=>{const{data:e,path:n,errorMaps:r,issueData:i}=t,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)s=c(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}};function Be(t,e){const n=PQe(),r=TQe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===VC?void 0:VC].filter(i=>!!i)});t.common.issues.push(r)}class ua{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return Rt;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n){const a=await i.key,o=await i.value;r.push({key:a,value:o})}return ua.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return Rt;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const Rt=Object.freeze({status:"aborted"}),Bg=t=>({status:"dirty",value:t}),Io=t=>({status:"valid",value:t}),O8=t=>t.status==="aborted",f8=t=>t.status==="dirty",Fh=t=>t.status==="valid",s0=t=>typeof Promise<"u"&&t instanceof Promise;var st;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(st||(st={}));class Ql{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const d8=(t,e)=>{if(Fh(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new zc(t.common.issues);return this._error=n,this._error}}};function Mt(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{const{message:l}=t;return o.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:l??n??s.defaultError}},description:i}}class fn{get description(){return this._def.description}_getType(e){return Au(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Au(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ua,ctx:{common:e.parent.common,data:e.data,parsedType:Au(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(s0(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Au(e)},i=this._parseSync({data:e,path:r.path,parent:r});return d8(r,i)}"~validate"(e){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Au(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return Fh(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(i=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>Fh(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Au(e)},i=this._parse({data:e,path:r.path,parent:r}),a=await(s0(i)?i:Promise.resolve(i));return d8(r,a)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,a)=>{const o=e(i),s=()=>a.addIssue({code:Ve.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new Jh({schema:this,typeName:Xt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Fu.create(this,this._def)}nullable(){return ep.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dl.create(this)}promise(){return f0.create(this,this._def)}or(e){return c0.create([this,e],this._def)}and(e){return u0.create(this,e,this._def)}transform(e){return new Jh({...Mt(this._def),schema:this,typeName:Xt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new WC({...Mt(this._def),innerType:this,defaultValue:n,typeName:Xt.ZodDefault})}brand(){return new FQe({typeName:Xt.ZodBranded,type:this,...Mt(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new MC({...Mt(this._def),innerType:this,catchValue:n,typeName:Xt.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Yq.create(this,e)}readonly(){return IC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kQe=/^c[^\s-]{8,}$/i,_Qe=/^[0-9a-z]+$/,XQe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,RQe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jQe=/^[a-z0-9_-]{21}$/i,EQe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,CQe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zQe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YQe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $k;const AQe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qQe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ZQe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,VQe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,UQe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NQe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dre="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",WQe=new RegExp(`^${dre}$`);function hre(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function MQe(t){return new RegExp(`^${hre(t)}$`)}function IQe(t){let e=`${dre}T${hre(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function DQe(t,e){return!!((e==="v4"||!e)&&AQe.test(t)||(e==="v6"||!e)&&ZQe.test(t))}function LQe(t,e){if(!EQe.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function GQe(t,e){return!!((e==="v4"||!e)&&qQe.test(t)||(e==="v6"||!e)&&VQe.test(t))}class mc extends fn{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==rt.string){const a=this._getOrReturnCtx(e);return Be(a,{code:Ve.invalid_type,expected:rt.string,received:a.parsedType}),Rt}const r=new ua;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?Be(i,{code:Ve.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&Be(i,{code:Ve.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")zQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"email",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")$k||($k=new RegExp(YQe,"u")),$k.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"emoji",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")RQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"uuid",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")jQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"nanoid",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")kQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cuid",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")_Qe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cuid2",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")XQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"ulid",code:Ve.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Be(i,{validation:"url",code:Ve.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"regex",code:Ve.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?IQe(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?WQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?MQe(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?CQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"duration",code:Ve.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?DQe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"ip",code:Ve.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?LQe(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"jwt",code:Ve.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?GQe(e.data,a.version)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"cidr",code:Ve.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?UQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"base64",code:Ve.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?NQe.test(e.data)||(i=this._getOrReturnCtx(e,i),Be(i,{validation:"base64url",code:Ve.invalid_string,message:a.message}),r.dirty()):wn.assertNever(a);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:Ve.invalid_string,...st.errToObj(r)})}_addCheck(e){return new mc({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...st.errToObj(e)})}url(e){return this._addCheck({kind:"url",...st.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...st.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...st.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...st.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...st.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...st.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...st.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...st.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...st.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...st.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...st.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...st.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...st.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...st.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...st.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...st.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...st.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...st.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...st.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...st.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...st.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...st.errToObj(n)})}nonempty(e){return this.min(1,st.errToObj(e))}trim(){return new mc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mc({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mc({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}mc.create=t=>new mc({checks:[],typeName:Xt.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Mt(t)});function BQe(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,a=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return a%o/10**i}class Hh extends fn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==rt.number){const a=this._getOrReturnCtx(e);return Be(a,{code:Ve.invalid_type,expected:rt.number,received:a.parsedType}),Rt}let r;const i=new ua;for(const a of this._def.checks)a.kind==="int"?wn.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?BQe(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.not_finite,message:a.message}),i.dirty()):wn.assertNever(a);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,st.toString(n))}gt(e,n){return this.setLimit("min",e,!1,st.toString(n))}lte(e,n){return this.setLimit("max",e,!0,st.toString(n))}lt(e,n){return this.setLimit("max",e,!1,st.toString(n))}setLimit(e,n,r,i){return new Hh({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:st.toString(i)}]})}_addCheck(e){return new Hh({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:st.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:st.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:st.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:st.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:st.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:st.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:st.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:st.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:st.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&wn.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Hh.create=t=>new Hh({checks:[],typeName:Xt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Mt(t)});class Vy extends fn{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==rt.bigint)return this._getInvalidInput(e);let r;const i=new ua;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),Be(r,{code:Ve.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):wn.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Be(n,{code:Ve.invalid_type,expected:rt.bigint,received:n.parsedType}),Rt}gte(e,n){return this.setLimit("min",e,!0,st.toString(n))}gt(e,n){return this.setLimit("min",e,!1,st.toString(n))}lte(e,n){return this.setLimit("max",e,!0,st.toString(n))}lt(e,n){return this.setLimit("max",e,!1,st.toString(n))}setLimit(e,n,r,i){return new Vy({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:st.toString(i)}]})}_addCheck(e){return new Vy({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:st.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:st.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:st.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:st.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:st.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Vy.create=t=>new Vy({checks:[],typeName:Xt.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Mt(t)});class UC extends fn{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==rt.boolean){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.boolean,received:r.parsedType}),Rt}return Io(e.data)}}UC.create=t=>new UC({typeName:Xt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Mt(t)});class l0 extends fn{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==rt.date){const a=this._getOrReturnCtx(e);return Be(a,{code:Ve.invalid_type,expected:rt.date,received:a.parsedType}),Rt}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return Be(a,{code:Ve.invalid_date}),Rt}const r=new ua;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),Be(i,{code:Ve.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):wn.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new l0({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:st.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:st.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}l0.create=t=>new l0({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Xt.ZodDate,...Mt(t)});class h8 extends fn{_parse(e){if(this._getType(e)!==rt.symbol){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.symbol,received:r.parsedType}),Rt}return Io(e.data)}}h8.create=t=>new h8({typeName:Xt.ZodSymbol,...Mt(t)});class p8 extends fn{_parse(e){if(this._getType(e)!==rt.undefined){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.undefined,received:r.parsedType}),Rt}return Io(e.data)}}p8.create=t=>new p8({typeName:Xt.ZodUndefined,...Mt(t)});class m8 extends fn{_parse(e){if(this._getType(e)!==rt.null){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.null,received:r.parsedType}),Rt}return Io(e.data)}}m8.create=t=>new m8({typeName:Xt.ZodNull,...Mt(t)});class g8 extends fn{constructor(){super(...arguments),this._any=!0}_parse(e){return Io(e.data)}}g8.create=t=>new g8({typeName:Xt.ZodAny,...Mt(t)});class y8 extends fn{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Io(e.data)}}y8.create=t=>new y8({typeName:Xt.ZodUnknown,...Mt(t)});class eO extends fn{_parse(e){const n=this._getOrReturnCtx(e);return Be(n,{code:Ve.invalid_type,expected:rt.never,received:n.parsedType}),Rt}}eO.create=t=>new eO({typeName:Xt.ZodNever,...Mt(t)});class $8 extends fn{_parse(e){if(this._getType(e)!==rt.undefined){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.void,received:r.parsedType}),Rt}return Io(e.data)}}$8.create=t=>new $8({typeName:Xt.ZodVoid,...Mt(t)});class dl extends fn{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==rt.array)return Be(n,{code:Ve.invalid_type,expected:rt.array,received:n.parsedType}),Rt;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(Be(n,{code:o?Ve.too_big:Ve.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Be(n,{code:Ve.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Be(n,{code:Ve.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>i.type._parseAsync(new Ql(n,o,n.path,s)))).then(o=>ua.mergeArray(r,o));const a=[...n.data].map((o,s)=>i.type._parseSync(new Ql(n,o,n.path,s)));return ua.mergeArray(r,a)}get element(){return this._def.type}min(e,n){return new dl({...this._def,minLength:{value:e,message:st.toString(n)}})}max(e,n){return new dl({...this._def,maxLength:{value:e,message:st.toString(n)}})}length(e,n){return new dl({...this._def,exactLength:{value:e,message:st.toString(n)}})}nonempty(e){return this.min(1,e)}}dl.create=(t,e)=>new dl({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Xt.ZodArray,...Mt(e)});function ph(t){if(t instanceof ei){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Fu.create(ph(r))}return new ei({...t._def,shape:()=>e})}else return t instanceof dl?new dl({...t._def,type:ph(t.element)}):t instanceof Fu?Fu.create(ph(t.unwrap())):t instanceof ep?ep.create(ph(t.unwrap())):t instanceof Rf?Rf.create(t.items.map(e=>ph(e))):t}class ei extends fn{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=wn.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==rt.object){const c=this._getOrReturnCtx(e);return Be(c,{code:Ve.invalid_type,expected:rt.object,received:c.parsedType}),Rt}const{status:r,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof eO&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||s.push(c);const l=[];for(const c of o){const u=a[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Ql(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof eO){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Be(i,{code:Ve.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const f=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Ql(i,f,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const f=await u.key,h=await u.value;c.push({key:f,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>ua.mergeObjectSync(r,c)):ua.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return st.errToObj,new ei({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var a,o;const i=((o=(a=this._def).errorMap)==null?void 0:o.call(a,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:st.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new ei({...this._def,unknownKeys:"strip"})}passthrough(){return new ei({...this._def,unknownKeys:"passthrough"})}extend(e){return new ei({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ei({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Xt.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new ei({...this._def,catchall:e})}pick(e){const n={};for(const r of wn.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new ei({...this._def,shape:()=>n})}omit(e){const n={};for(const r of wn.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new ei({...this._def,shape:()=>n})}deepPartial(){return ph(this)}partial(e){const n={};for(const r of wn.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new ei({...this._def,shape:()=>n})}required(e){const n={};for(const r of wn.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Fu;)a=a._def.innerType;n[r]=a}return new ei({...this._def,shape:()=>n})}keyof(){return pre(wn.objectKeys(this.shape))}}ei.create=(t,e)=>new ei({shape:()=>t,unknownKeys:"strip",catchall:eO.create(),typeName:Xt.ZodObject,...Mt(e)});ei.strictCreate=(t,e)=>new ei({shape:()=>t,unknownKeys:"strict",catchall:eO.create(),typeName:Xt.ZodObject,...Mt(e)});ei.lazycreate=(t,e)=>new ei({shape:t,unknownKeys:"strip",catchall:eO.create(),typeName:Xt.ZodObject,...Mt(e)});class c0 extends fn{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function i(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(s=>new zc(s.ctx.common.issues));return Be(n,{code:Ve.invalid_union,unionErrors:o}),Rt}if(n.common.async)return Promise.all(r.map(async a=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let a;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=o.map(l=>new zc(l));return Be(n,{code:Ve.invalid_union,unionErrors:s}),Rt}}get options(){return this._def.options}}c0.create=(t,e)=>new c0({options:t,typeName:Xt.ZodUnion,...Mt(e)});function NC(t,e){const n=Au(t),r=Au(e);if(t===e)return{valid:!0,data:t};if(n===rt.object&&r===rt.object){const i=wn.objectKeys(e),a=wn.objectKeys(t).filter(s=>i.indexOf(s)!==-1),o={...t,...e};for(const s of a){const l=NC(t[s],e[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(n===rt.array&&r===rt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const o=t[a],s=e[a],l=NC(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===rt.date&&r===rt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class u0 extends fn{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(a,o)=>{if(O8(a)||O8(o))return Rt;const s=NC(a.value,o.value);return s.valid?((f8(a)||f8(o))&&n.dirty(),{status:n.value,value:s.data}):(Be(r,{code:Ve.invalid_intersection_types}),Rt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}u0.create=(t,e,n)=>new u0({left:t,right:e,typeName:Xt.ZodIntersection,...Mt(n)});class Rf extends fn{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==rt.array)return Be(r,{code:Ve.invalid_type,expected:rt.array,received:r.parsedType}),Rt;if(r.data.length<this._def.items.length)return Be(r,{code:Ve.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Rt;!this._def.rest&&r.data.length>this._def.items.length&&(Be(r,{code:Ve.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((o,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new Ql(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>ua.mergeArray(n,o)):ua.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new Rf({...this._def,rest:e})}}Rf.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rf({items:t,typeName:Xt.ZodTuple,rest:null,...Mt(e)})};class O0 extends fn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==rt.object)return Be(r,{code:Ve.invalid_type,expected:rt.object,received:r.parsedType}),Rt;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in r.data)i.push({key:a._parse(new Ql(r,s,r.path,s)),value:o._parse(new Ql(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?ua.mergeObjectAsync(n,i):ua.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof fn?new O0({keyType:e,valueType:n,typeName:Xt.ZodRecord,...Mt(r)}):new O0({keyType:mc.create(),valueType:e,typeName:Xt.ZodRecord,...Mt(n)})}}class v8 extends fn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==rt.map)return Be(r,{code:Ve.invalid_type,expected:rt.map,received:r.parsedType}),Rt;const i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:i._parse(new Ql(r,s,r.path,[c,"key"])),value:a._parse(new Ql(r,l,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Rt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Rt;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(c.value,u.value)}return{status:n.value,value:s}}}}v8.create=(t,e,n)=>new v8({valueType:e,keyType:t,typeName:Xt.ZodMap,...Mt(n)});class Uy extends fn{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==rt.set)return Be(r,{code:Ve.invalid_type,expected:rt.set,received:r.parsedType}),Rt;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Be(r,{code:Ve.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Be(r,{code:Ve.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const a=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Rt;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const s=[...r.data.values()].map((l,c)=>a._parse(new Ql(r,l,r.path,c)));return r.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(e,n){return new Uy({...this._def,minSize:{value:e,message:st.toString(n)}})}max(e,n){return new Uy({...this._def,maxSize:{value:e,message:st.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Uy.create=(t,e)=>new Uy({valueType:t,minSize:null,maxSize:null,typeName:Xt.ZodSet,...Mt(e)});class x8 extends fn{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}x8.create=(t,e)=>new x8({getter:t,typeName:Xt.ZodLazy,...Mt(e)});class Q8 extends fn{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Be(n,{received:n.data,code:Ve.invalid_literal,expected:this._def.value}),Rt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Q8.create=(t,e)=>new Q8({value:t,typeName:Xt.ZodLiteral,...Mt(e)});function pre(t,e){return new Kh({values:t,typeName:Xt.ZodEnum,...Mt(e)})}class Kh extends fn{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Be(n,{expected:wn.joinValues(r),received:n.parsedType,code:Ve.invalid_type}),Rt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return Be(n,{received:n.data,code:Ve.invalid_enum_value,options:r}),Rt}return Io(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return Kh.create(e,{...this._def,...n})}exclude(e,n=this._def){return Kh.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}Kh.create=pre;class b8 extends fn{_parse(e){const n=wn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==rt.string&&r.parsedType!==rt.number){const i=wn.objectValues(n);return Be(r,{expected:wn.joinValues(i),received:r.parsedType,code:Ve.invalid_type}),Rt}if(this._cache||(this._cache=new Set(wn.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=wn.objectValues(n);return Be(r,{received:r.data,code:Ve.invalid_enum_value,options:i}),Rt}return Io(e.data)}get enum(){return this._def.values}}b8.create=(t,e)=>new b8({values:t,typeName:Xt.ZodNativeEnum,...Mt(e)});class f0 extends fn{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==rt.promise&&n.common.async===!1)return Be(n,{code:Ve.invalid_type,expected:rt.promise,received:n.parsedType}),Rt;const r=n.parsedType===rt.promise?n.data:Promise.resolve(n.data);return Io(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}f0.create=(t,e)=>new f0({type:t,typeName:Xt.ZodPromise,...Mt(e)});class Jh extends fn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:o=>{Be(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const o=i.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return Rt;const l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?Rt:l.status==="dirty"||n.value==="dirty"?Bg(l.value):l});{if(n.value==="aborted")return Rt;const s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?Rt:s.status==="dirty"||n.value==="dirty"?Bg(s.value):s}}if(i.type==="refinement"){const o=s=>{const l=i.refinement(s,a);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Rt:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Rt:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Fh(o))return Rt;const s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Fh(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):Rt);wn.assertNever(i)}}Jh.create=(t,e,n)=>new Jh({schema:t,typeName:Xt.ZodEffects,effect:e,...Mt(n)});Jh.createWithPreprocess=(t,e,n)=>new Jh({schema:e,effect:{type:"preprocess",transform:t},typeName:Xt.ZodEffects,...Mt(n)});class Fu extends fn{_parse(e){return this._getType(e)===rt.undefined?Io(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fu.create=(t,e)=>new Fu({innerType:t,typeName:Xt.ZodOptional,...Mt(e)});class ep extends fn{_parse(e){return this._getType(e)===rt.null?Io(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ep.create=(t,e)=>new ep({innerType:t,typeName:Xt.ZodNullable,...Mt(e)});class WC extends fn{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===rt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}WC.create=(t,e)=>new WC({innerType:t,typeName:Xt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Mt(e)});class MC extends fn{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return s0(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zc(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new zc(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}MC.create=(t,e)=>new MC({innerType:t,typeName:Xt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Mt(e)});class S8 extends fn{_parse(e){if(this._getType(e)!==rt.nan){const r=this._getOrReturnCtx(e);return Be(r,{code:Ve.invalid_type,expected:rt.nan,received:r.parsedType}),Rt}return{status:"valid",value:e.data}}}S8.create=t=>new S8({typeName:Xt.ZodNaN,...Mt(t)});class FQe extends fn{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Yq extends fn{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Rt:a.status==="dirty"?(n.dirty(),Bg(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Rt:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new Yq({in:e,out:n,typeName:Xt.ZodPipeline})}}class IC extends fn{_parse(e){const n=this._def.innerType._parse(e),r=i=>(Fh(i)&&(i.value=Object.freeze(i.value)),i);return s0(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}IC.create=(t,e)=>new IC({innerType:t,typeName:Xt.ZodReadonly,...Mt(e)});var Xt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Xt||(Xt={}));const ge=mc.create,ht=Hh.create,En=UC.create;eO.create;const bt=dl.create,mt=ei.create;c0.create;u0.create;Rf.create;const w8=O0.create,Pr=Kh.create;f0.create;Fu.create;ep.create;const HQe=Pr(["typescript","tsx","javascript","python"]),Jp=mt({filePath:ge(),startLine:ht(),startColumn:ht(),endLine:ht(),endColumn:ht()}),KQe=mt({name:ge(),type:ge().optional(),defaultValue:ge().optional()}),mre=mt({name:ge(),params:bt(KQe),returnType:ge().optional(),isAsync:En(),isExported:En(),location:Jp,lineCount:ht().optional(),statementCount:ht().optional(),maxNestingDepth:ht().optional()}),JQe=mt({name:ge(),type:ge().optional(),isStatic:En().optional()}),ebe=mt({name:ge(),methods:bt(mre),properties:bt(JQe),superClass:ge().optional(),interfaces:bt(ge()).optional(),decorators:bt(ge()).optional(),location:Jp}),tbe=mt({name:ge(),alias:ge().optional(),isDefault:En(),isNamespace:En()}),nbe=mt({source:ge(),specifiers:bt(tbe),isTypeOnly:En(),isFunctionScoped:En().optional()}),rbe=mt({name:ge(),isDefault:En(),source:ge().optional()}),ibe=mt({callee:ge(),arguments:bt(ge()).optional(),location:Jp,callerFunction:ge().optional()}),gre=mt({method:Pr(["GET","POST","PUT","DELETE","PATCH"]),url:ge(),location:Jp}),abe=mt({httpMethod:Pr(["GET","POST","PUT","DELETE","PATCH","ALL"]),path:ge(),handlerName:ge(),location:Jp}),obe=mt({path:ge(),routerName:ge(),location:Jp});mt({filePath:ge(),language:HQe,functions:bt(mre),classes:bt(ebe),imports:bt(nbe),exports:bt(rbe),calls:bt(ibe),httpCalls:bt(gre),routeRegistrations:bt(abe).optional(),routerMounts:bt(obe).optional()});mt({source:ge(),target:ge(),importedNames:bt(ge())});const sbe=Pr(["class","interface","standalone"]);mt({name:ge(),filePath:ge(),kind:sbe,serviceName:ge(),layerName:ge(),methodCount:ht(),propertyCount:ht(),importCount:ht(),exportCount:ht(),superClass:ge().optional(),startLine:ht().optional(),endLine:ht().optional(),lineCount:ht().optional()});mt({name:ge(),moduleName:ge(),serviceName:ge(),filePath:ge(),signature:ge(),paramCount:ht(),returnType:ge().optional(),isAsync:En(),isExported:En(),startLine:ht().optional(),endLine:ht().optional(),lineCount:ht().optional(),statementCount:ht().optional(),maxNestingDepth:ht().optional(),isImplicitCall:En().optional()});mt({sourceModule:ge(),sourceService:ge(),sourceFilePath:ge().optional(),targetModule:ge(),targetService:ge(),targetFilePath:ge().optional(),importedNames:bt(ge())});mt({callerMethod:ge(),callerModule:ge(),callerService:ge(),callerFilePath:ge().optional(),calleeMethod:ge(),calleeModule:ge(),calleeService:ge(),calleeFilePath:ge().optional(),callCount:ht()});const lbe=mt({name:ge(),type:ge(),isPrimaryKey:En().optional(),isNullable:En().optional(),decorators:bt(ge()).optional()}),cbe=mt({type:Pr(["oneToOne","oneToMany","manyToOne","manyToMany"]),targetEntity:ge(),fieldName:ge()});mt({name:ge(),service:ge(),framework:ge(),fields:bt(lbe),relationships:bt(cbe),confidence:ht().min(0).max(1),signals:bt(ge())});const d0=Pr(["data","api","service","external"]),ube=mt({layer:d0,confidence:ht().min(0).max(1),evidence:bt(ge())}),yre=Pr(["frontend","api-server","worker","library","unknown"]),Obe=Pr(["monolith","microservices"]);mt({name:ge(),rootPath:ge(),type:yre,framework:ge().optional(),fileCount:ht(),layers:bt(ube),files:bt(ge())});const fbe=mt({filePath:ge(),importedFrom:ge(),importedNames:bt(ge())});mt({source:ge(),target:ge(),dependencies:bt(fbe),httpCalls:bt(gre).optional()});mt({serviceName:ge(),layer:d0,fileCount:ht(),filePaths:bt(ge()),confidence:ht(),evidence:bt(ge())});mt({sourceServiceName:ge(),sourceLayer:d0,targetServiceName:ge(),targetLayer:d0,dependencyCount:ht(),isViolation:En(),violationReason:ge().optional()});const dbe=Pr(["architecture","dependency","violation","suggestion","warning","database","module","service","function"]),hbe=Pr(["info","low","medium","high","critical"]),pbe=Pr(["new","unchanged","resolved"]),mbe=Pr(["rule","contract-drift"]),gbe=mt({id:ge(),type:dbe,category:mbe.default("rule"),subcategory:ge().nullable().optional(),title:ge(),content:ge(),severity:hbe,status:pbe.optional(),targetServiceId:ge().optional(),targetDatabaseId:ge().optional(),targetModuleId:ge().optional(),targetMethodId:ge().optional(),targetTable:ge().optional(),fixPrompt:ge().optional(),ruleKey:ge().optional(),deterministicViolationId:ge().optional(),firstSeenAt:ge().optional(),resolvedAt:ge().optional(),createdAt:ge()}),ybe=mt({name:ge(),type:yre,framework:ge().optional(),fileCount:ht(),layers:bt(ge())});mt({architecture:Obe,totalServices:ht(),totalFiles:ht(),violations:bt(gbe),services:bt(ybe)});const $be=Pr(["postgres","redis","mongodb","mysql","sqlite"]),vbe=mt({name:ge(),type:ge(),isNullable:En().optional(),isPrimaryKey:En().optional(),isUnique:En().optional(),defaultValue:ge().optional(),isForeignKey:En().optional(),referencesTable:ge().optional(),referencesColumn:ge().optional()}),xbe=mt({name:ge().optional(),columns:bt(ge()),isUnique:En().optional()}),Qbe=mt({name:ge(),columns:bt(vbe),primaryKey:ge().optional(),indexes:bt(xbe).optional(),aliases:bt(ge()).optional()}),bbe=mt({sourceTable:ge(),targetTable:ge(),relationType:Pr(["one-to-one","one-to-many","many-to-many"]),foreignKeyColumn:ge(),foreignKeyReferencesColumn:ge().optional()}),Sbe=mt({name:ge(),type:$be,driver:ge(),connectionEnvVar:ge().optional(),tables:bt(Qbe),relations:bt(bbe),connectedServices:bt(ge())}),wbe=mt({serviceName:ge(),databaseName:ge(),driver:ge(),layerName:ge().optional()});mt({databases:bt(Sbe),connections:bt(wbe)});const Pbe=Pr(["architecture","security","bugs","code-quality","style","database","performance","reliability"]),Tbe=Pr(["service","database","module","method","code"]),kbe=Pr(["info","low","medium","high","critical"]),_be=Pr(["deterministic","llm"]),Xbe=Pr(["metadata","targeted","full-file"]),Rbe=mt({hasAsyncFunctions:En().optional(),hasRouteHandlers:En().optional(),hasDbCalls:En().optional(),hasCatchBlocks:En().optional(),hasImportsFrom:bt(ge()).optional(),hasCallsTo:bt(ge()).optional(),isTestFile:En().optional(),languages:bt(ge()).optional()}),jbe=mt({isAsync:En().optional(),isRouteHandler:En().optional(),containsCatchBlock:En().optional(),callsAny:bt(ge()).optional()}),Ebe=mt({tier:Xbe,fileFilter:Rbe.optional(),functionFilter:jbe.optional(),metadataFields:bt(Pr(["functions","classes","imports","exports","calls","httpCalls","routeRegistrations"])).optional()});mt({key:ge(),category:Tbe,domain:Pbe.optional(),name:ge(),description:ge(),prompt:ge().optional(),enabled:En(),severity:kbe,type:_be,contextRequirement:Ebe.optional()});const Cbe=Pr(["call","http","db-read","db-write","event"]),zbe=Pr(["http","event","cron","startup"]),Ybe=mt({id:ge(),flowId:ge(),stepOrder:ht(),sourceService:ge(),sourceModule:ge(),sourceMethod:ge(),targetService:ge(),targetModule:ge(),targetMethod:ge(),stepType:Cbe,dataDescription:ge().nullable(),isAsync:En(),isConditional:En()});mt({id:ge(),analysisId:ge(),name:ge(),description:ge().nullable(),entryService:ge(),entryMethod:ge(),category:ge(),trigger:zbe,stepCount:ht(),steps:bt(Ybe).optional(),createdAt:ge().optional()});const Abe=mt({analysisId:ge(),date:ge(),branch:ge().nullable(),total:ht(),new:ht(),unchanged:ht(),resolved:ht(),critical:ht(),high:ht(),medium:ht(),low:ht(),info:ht()});mt({points:bt(Abe)});mt({byCategory:w8(ge(),ht()),bySeverity:w8(ge(),ht()),total:ht()});const qbe=mt({id:ge(),name:ge(),kind:Pr(["service","module"]),violationCount:ht(),criticalCount:ht(),highCount:ht()});mt({offenders:bt(qbe),analysisId:ge()});mt({avgTimeToResolveMs:ht().nullable(),totalResolved:ht(),totalActive:ht(),resolutionRate:ht(),staleCount:ht(),staleDays:ht()});const $re=[];mt({path:ge().min(1)});mt({mode:Pr(["full","diff"]),skipGit:En().optional().default(!1)});mt({analysisId:ge().uuid().optional()});var vk={exports:{}},P8;function Zbe(){return P8||(P8=1,(function(t){function e(K){return Array.isArray(K)?K:[K]}const n=void 0,r="",i=" ",a="\\",o=/^\s+$/,s=/(?:[^\\]|^)\\$/,l=/^\\!/,c=/^\\#/,u=/\r?\n/g,f=/^\.{0,2}\/|^\.{1,2}$/,h=/\/$/,p="/";let y="node-ignore";typeof Symbol<"u"&&(y=Symbol.for("node-ignore"));const v=y,$=(K,H,re)=>(Object.defineProperty(K,H,{value:re}),re),x=/([0-z])-([0-z])/g,S=()=>!1,b=K=>K.replace(x,(H,re,F)=>re.charCodeAt(0)<=F.charCodeAt(0)?H:r),T=K=>{const{length:H}=K;return K.slice(0,H-H%2)},w=[[/^\uFEFF/,()=>r],[/((?:\\\\)*?)(\\?\s+)$/,(K,H,re)=>H+(re.indexOf("\\")===0?i:r)],[/(\\+?)\s/g,(K,H)=>{const{length:re}=H;return H.slice(0,re-re%2)+i}],[/[\\$.|*+(){^]/g,K=>`\\${K}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(K,H,re)=>H+6<re.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(K,H,re)=>{const F=re.replace(/\\\*/g,"[^\\/]*");return H+F}],[/\\\\\\(?=[$.|*+(){^])/g,()=>a],[/\\\\/g,()=>a],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(K,H,re,F,te)=>H===a?`\\[${re}${T(F)}${te}`:te==="]"&&F.length%2===0?`[${b(re)}${F}]`:"[]"],[/(?:[^*])$/,K=>/\/$/.test(K)?`${K}$`:`${K}(?=$|\\/$)`]],P=/(^|\\\/)?\\\*$/,k="regex",R="checkRegex",E="_",C={[k](K,H){return`${H?`${H}[^/]+`:"[^/]*"}(?=$|\\/$)`},[R](K,H){return`${H?`${H}[^/]*`:"[^/]*"}(?=$|\\/$)`}},z=K=>w.reduce((H,[re,F])=>H.replace(re,F.bind(K)),K),Y=K=>typeof K=="string",W=K=>K&&Y(K)&&!o.test(K)&&!s.test(K)&&K.indexOf("#")!==0,A=K=>K.split(u).filter(Boolean);class q{constructor(H,re,F,te,ie,se){this.pattern=H,this.mark=re,this.negative=ie,$(this,"body",F),$(this,"ignoreCase",te),$(this,"regexPrefix",se)}get regex(){const H=E+k;return this[H]?this[H]:this._make(k,H)}get checkRegex(){const H=E+R;return this[H]?this[H]:this._make(R,H)}_make(H,re){const F=this.regexPrefix.replace(P,C[H]),te=this.ignoreCase?new RegExp(F,"i"):new RegExp(F);return $(this,re,te)}}const N=({pattern:K,mark:H},re)=>{let F=!1,te=K;te.indexOf("!")===0&&(F=!0,te=te.substr(1)),te=te.replace(l,"!").replace(c,"#");const ie=z(te);return new q(K,H,te,re,F,ie)};class Z{constructor(H){this._ignoreCase=H,this._rules=[]}_add(H){if(H&&H[v]){this._rules=this._rules.concat(H._rules._rules),this._added=!0;return}if(Y(H)&&(H={pattern:H}),W(H.pattern)){const re=N(H,this._ignoreCase);this._added=!0,this._rules.push(re)}}add(H){return this._added=!1,e(Y(H)?A(H):H).forEach(this._add,this),this._added}test(H,re,F){let te=!1,ie=!1,se;this._rules.forEach(ue=>{const{negative:Oe}=ue;ie===Oe&&te!==ie||Oe&&!te&&!ie&&!re||!ue[F].test(H)||(te=!Oe,ie=Oe,se=Oe?n:ue)});const ae={ignored:te,unignored:ie};return se&&(ae.rule=se),ae}}const D=(K,H)=>{throw new H(K)},M=(K,H,re)=>Y(K)?K?M.isNotRelative(K)?re(`path should be a \`path.relative()\`d string, but got "${H}"`,RangeError):!0:re("path must not be empty",TypeError):re(`path must be a string, but got \`${H}\``,TypeError),V=K=>f.test(K);M.isNotRelative=V,M.convert=K=>K;class I{constructor({ignorecase:H=!0,ignoreCase:re=H,allowRelativePaths:F=!1}={}){$(this,v,!0),this._rules=new Z(re),this._strictPathCheck=!F,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(H){return this._rules.add(H)&&this._initCache(),this}addPattern(H){return this.add(H)}_test(H,re,F,te){const ie=H&&M.convert(H);return M(ie,H,this._strictPathCheck?D:S),this._t(ie,re,F,te)}checkIgnore(H){if(!h.test(H))return this.test(H);const re=H.split(p).filter(Boolean);if(re.pop(),re.length){const F=this._t(re.join(p)+p,this._testCache,!0,re);if(F.ignored)return F}return this._rules.test(H,!1,R)}_t(H,re,F,te){if(H in re)return re[H];if(te||(te=H.split(p).filter(Boolean)),te.pop(),!te.length)return re[H]=this._rules.test(H,F,k);const ie=this._t(te.join(p)+p,re,F,te);return re[H]=ie.ignored?ie:this._rules.test(H,F,k)}ignores(H){return this._test(H,this._ignoreCache,!1).ignored}createFilter(){return H=>!this.ignores(H)}filter(H){return e(H).filter(this.createFilter())}test(H){return this._test(H,this._testCache,!0)}}const B=K=>new I(K),L=K=>M(K&&M.convert(K),K,S),J=()=>{const K=re=>/^\\\\\?\\/.test(re)||/["<>|\u0000-\u001F]+/u.test(re)?re:re.replace(/\\/g,"/");M.convert=K;const H=/^[a-z]:\//i;M.isNotRelative=re=>H.test(re)||V(re)};typeof process<"u"&&process.platform==="win32"&&J(),t.exports=B,B.default=B,t.exports.isPathValid=L,$(t.exports,Symbol.for("setupWindows"),J)})(vk)),vk.exports}Zbe();function ly(){if(typeof window>"u")return"";const t=window.location.port;return t&&t!=="3001"?`http://${window.location.hostname}:3001`:""}const Vbe=ly();class em extends Error{constructor(e,n){super(n),this.status=e,this.name="ApiError"}}async function gt(t,e){const n=`${Vbe}${t}`,r=await fetch(n,{...e,credentials:"include",headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}});if(!r.ok){let i="Unknown error";try{const a=await r.json();i=a.error||JSON.stringify(a)}catch{i=await r.text().catch(()=>"Unknown error")}throw new em(r.status,i)}if(r.status!==204)return r.json()}function Ube(){return gt("/api/capabilities")}function Nbe(){return gt("/api/repos")}function T8(t){return gt(`/api/repos/${t}`)}function Wbe(t){return gt("/api/repos",{method:"POST",body:JSON.stringify({path:t})})}function Mbe(t){return gt(`/api/repos/${t}`,{method:"DELETE"})}function vre(t,e){return gt(`/api/repos/${t}/analyses`,{method:"POST",body:JSON.stringify({mode:"full",...(e==null?void 0:e.skipGit)!=null?{skipGit:e.skipGit}:{}})})}function Ibe(t){return gt(`/api/repos/${t}/analyses`)}function Dbe(t,e){return gt(`/api/repos/${t}/analyses/${e}/usage`)}function Lbe(t,e){return gt(`/api/repos/${t}/analyses/${e}`,{method:"DELETE"})}function Gbe(t){return gt(`/api/repos/${t}/analyses/cancel`,{method:"POST"})}function Bbe(t,e){const n=new URLSearchParams;e!=null&&e.branch&&n.set("branch",e.branch),e!=null&&e.level&&n.set("level",e.level),e!=null&&e.analysisId&&n.set("analysisId",e.analysisId);const r=n.toString();return gt(`/api/repos/${t}/graph${r?`?${r}`:""}`)}function k8(t,e,n,r){const i=new URLSearchParams;n&&i.set("branch",n),r&&i.set("level",r);const a=i.toString();return gt(`/api/repos/${t}/graph/positions${a?`?${a}`:""}`,{method:"PUT",body:JSON.stringify({positions:e})})}function Fbe(t,e,n){const r=new URLSearchParams;e&&r.set("branch",e),n&&r.set("level",n);const i=r.toString();return gt(`/api/repos/${t}/graph/positions${i?`?${i}`:""}`,{method:"DELETE"})}function _8(t,e,n,r){const i=new URLSearchParams;n&&i.set("branch",n),r&&i.set("level",r);const a=i.toString();return gt(`/api/repos/${t}/graph/collapsed${a?`?${a}`:""}`,{method:"PUT",body:JSON.stringify({collapsedIds:e})})}function Hbe(t,e){const n=e?`?ref=${encodeURIComponent(e)}`:"";return gt(`/api/repos/${t}/files${n}`)}function xre(t,e){const n=new URLSearchParams;e&&n.set("analysisId",e);const r=n.toString();return gt(`/api/repos/${t}/violations${r?`?${r}`:""}`)}function Kbe(t,e,n){const r=new URLSearchParams;e&&r.set("branch",e),n&&r.set("analysisId",n);const i=r.toString();return gt(`/api/repos/${t}/databases${i?`?${i}`:""}`)}function Jbe(t,e,n){const r=n?`?analysisId=${encodeURIComponent(n)}`:"";return gt(`/api/repos/${t}/databases/${e}/schema${r}`)}function e0e(t){const e=t?`/api/repos/${encodeURIComponent(t)}/rules`:"/api/rules";return gt(e)}function Qre(t,e,n){return gt(`/api/repos/${encodeURIComponent(t)}/rules/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({enabled:n})})}function t0e(t){return gt(`/api/repos/${t}/analyses`,{method:"POST",body:JSON.stringify({mode:"diff"})})}function X8(t){return gt(`/api/repos/${t}/analyses/diff`)}function n0e(t,e,n){const r=new URLSearchParams({path:e});return n&&r.set("ref",n),gt(`/api/repos/${t}/file-content?${r.toString()}`)}function r0e(t,e,n){const r=new URLSearchParams;e&&r.set("file",e),n&&r.set("analysisId",n);const i=r.toString();return gt(`/api/repos/${t}/violations${i?`?${i}`:""}`)}function bre(t,e){const n=new URLSearchParams;e&&n.set("analysisId",e);const r=n.toString();return gt(`/api/repos/${t}/violations/summary${r?`?${r}`:""}`)}function i0e(t,e){const n=e?`?analysisId=${encodeURIComponent(e)}`:"";return gt(`/api/repos/${t}/flows${n}`)}function a0e(t,e,n){const r=n?`?analysisId=${encodeURIComponent(n)}`:"";return gt(`/api/repos/${t}/flows/${e}${r}`)}function o0e(t,e){return gt(`/api/repos/${t}/flows/${e}/enrich`,{method:"POST"})}function s0e(t,e,n,r){const i=new URLSearchParams;e&&i.set("branch",e),r&&i.set("analysisId",r);const a=i.toString();return gt(`/api/repos/${t}/analytics/trend${a?`?${a}`:""}`)}function l0e(t,e,n){const r=new URLSearchParams;e&&r.set("branch",e),n&&r.set("analysisId",n);const i=r.toString();return gt(`/api/repos/${t}/analytics/breakdown${i?`?${i}`:""}`)}function c0e(t,e,n){const r=new URLSearchParams;e&&r.set("branch",e),n&&r.set("analysisId",n);const i=r.toString();return gt(`/api/repos/${t}/analytics/top-offenders${i?`?${i}`:""}`)}function u0e(t,e,n){const r=new URLSearchParams;e&&r.set("branch",e),n&&r.set("analysisId",n);const i=r.toString();return gt(`/api/repos/${t}/analytics/resolution${i?`?${i}`:""}`)}function O0e(t){return gt(`/api/repos/${t}/spec/scan`)}function f0e(t){return gt(`/api/repos/${t}/spec/canonical/tree`)}function d0e(t,e,n){const r=new URLSearchParams({module:e,topic:n});return gt(`/api/repos/${t}/spec/canonical/section?${r.toString()}`)}function h0e(t){return gt(`/api/repos/${t}/contracts/tree`)}function p0e(t,e){return gt(`/api/repos/${t}/contracts/file?path=${encodeURIComponent(e)}`)}async function m0e(t){try{return await gt(`/api/repos/${t}/verify/state`)}catch(e){if(e instanceof em&&e.status===404)return null;throw e}}function g0e(t){return gt(`/api/repos/${t}/verify/run`,{method:"POST"})}async function y0e(t){try{return await gt(`/api/repos/${t}/verify/diff`)}catch(e){if(e instanceof em&&e.status===404)return null;throw e}}function $0e(t){return gt(`/api/repos/${t}/verify/diff`,{method:"POST"})}async function R8(t){try{return await gt(`/api/repos/${t}/verify/history`)}catch(e){if(e instanceof em&&e.status===404)return{runs:[]};throw e}}function v0e(t,e){return gt(`/api/repos/${t}/verify/runs/${e}`)}function x0e(t,e){return gt(`/api/repos/${t}/verify/runs/${e}`,{method:"DELETE"})}async function Q0e(t){try{return await gt(`/api/repos/${t}/spec/scan-state`)}catch(e){if(e instanceof em&&e.status===404)return null;throw e}}function b0e(t,e){return gt(`/api/repos/${t}/spec/decisions/${encodeURIComponent(e)}`,{method:"DELETE"})}function S0e(t,e){return gt(`/api/repos/${t}/spec/decisions`,{method:"POST",body:JSON.stringify(e)})}function w0e(t,e){return gt(`/api/repos/${t}/spec/docs/include`,{method:"POST",body:JSON.stringify(e)})}function P0e(t,e){return gt(`/api/repos/${t}/spec/chains/manual`,{method:"POST",body:JSON.stringify(e)})}function T0e(t,e){return gt(`/api/repos/${t}/spec/decisions/batch`,{method:"POST",body:JSON.stringify({mode:e})})}function k0e(t){return gt(`/api/repos/${t}/contracts/generate`,{method:"POST"})}function _0e(t){return gt(`/api/repos/${t}/spec/staleness`)}const Sre={edition:"community",capabilities:new Set($re),isLoading:!0,error:null},Aq=_.createContext(Sre);function X0e({children:t,initial:e}){const[n,r]=_.useState(()=>e?{edition:e.edition,capabilities:new Set(e.capabilities),isLoading:!1,error:null}:Sre);_.useEffect(()=>{if(e)return;let a=!1;return(async()=>{try{const o=await Ube();if(a)return;r({edition:o.edition,capabilities:new Set(o.capabilities),isLoading:!1,error:null})}catch(o){if(a)return;r({edition:"community",capabilities:new Set($re),isLoading:!1,error:o instanceof Error?o:new Error(String(o))})}})(),()=>{a=!0}},[e]);const i=_.useMemo(()=>n,[n]);return m.jsx(Aq.Provider,{value:i,children:t})}function R0e(){return _.useContext(Aq).edition}function wS(){return _.useContext(Aq)}const PS=[{id:"analysis",label:"Code Analysis",description:"Architecture graphs, files, flows, databases",icon:Ay,defaultTab:"home",tabs:[{id:"home",label:"Home",icon:Zve,noPanel:!0},{id:"graphs",label:"Graphs",icon:Ay,noPanel:!0},{id:"flows",label:"Flows",icon:Wne},{id:"files",label:"Files",icon:Yve},{id:"databases",label:"Databases",icon:xl},{id:"analyses",label:"Analyses",icon:JW,noPanel:!0}]},{id:"drift",label:"BL Drift",description:"Spec consolidation, contracts, verification",icon:Bu,defaultTab:"spec",tabs:[{id:"spec",label:"Spec",icon:Sve},{id:"contracts",label:"Contracts",icon:xq},{id:"verify",label:"Verify",icon:Bu,noPanel:!0},{id:"runs",label:"Runs",icon:JW,noPanel:!0},{id:"decisions",label:"Decisions",icon:EC}]}];function wre(t){return PS.find(e=>e.id===t)}function Pre(){return PS.flatMap(t=>t.tabs)}function j0e(t){return Pre().find(e=>e.id===t)}function DC(t){var e;return((e=wre(t))==null?void 0:e.defaultTab)??""}function E0e(){return new Set(Pre().map(t=>t.id))}function C0e(t){var e;return(e=PS.find(n=>n.tabs.some(r=>r.id===t)))==null?void 0:e.id}function h0(t,e){return t===void 0||e.has(t)}function z0e(){const{capabilities:t}=wS();return _.useMemo(()=>PS.filter(e=>h0(e.requiredCapability,t)).map(e=>({...e,tabs:e.tabs.filter(n=>h0(n.requiredCapability,t))})),[t])}function Y0e(t){const{capabilities:e}=wS();return _.useMemo(()=>{const n=wre(t);return n?h0(n.requiredCapability,e)?n.tabs.filter(r=>h0(r.requiredCapability,e)):[]:[]},[t,e])}function A0e({value:t,onChange:e}){const n=z0e(),[r,i]=_.useState(!1),a=_.useRef(null);_.useEffect(()=>{if(!r)return;const l=c=>{a.current&&!a.current.contains(c.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]);const o=n.find(l=>l.id===t)??n[0];if(!o)return null;const s=o.icon;return m.jsxs("div",{className:"relative",ref:a,children:[m.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"flex items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-muted/50 transition-colors","aria-haspopup":"menu","aria-expanded":r,children:[m.jsx(s,{className:"h-3.5 w-3.5 text-muted-foreground"}),m.jsx("span",{className:"font-medium",children:o.label}),m.jsx(qa,{className:"h-3 w-3 text-muted-foreground"})]}),r&&m.jsx("div",{role:"menu",className:"absolute left-0 top-full z-50 mt-1 min-w-64 rounded-md border border-border bg-popover p-1 shadow-lg",children:n.map(l=>{const c=l.icon,u=l.id===t;return m.jsxs("button",{role:"menuitemradio","aria-checked":u,onClick:()=>{i(!1),u||e(l.id)},className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${u?"bg-accent text-accent-foreground":"hover:bg-muted text-foreground"}`,children:[m.jsx(c,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"font-medium",children:l.label}),u&&m.jsx(Ff,{className:"h-3 w-3 text-primary"})]}),m.jsx("div",{className:"text-[11px] text-muted-foreground",children:l.description})]})]},l.id)})})]})}function q0e({branch:t}){return t?m.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[m.jsx(bq,{className:"h-3.5 w-3.5"}),t]}):null}function tm({children:t,content:e,side:n="bottom",align:r="center",width:i="auto",popoverClassName:a=""}){if(e==null)return m.jsx(m.Fragment,{children:t});const o=i==="auto"?"whitespace-nowrap":i==="narrow"?"w-64 whitespace-normal":"w-80 whitespace-normal",s=n==="top"?"bottom-full mb-1.5":"top-full mt-1.5",l=r==="start"?"left-0":r==="end"?"right-0":"left-1/2 -translate-x-1/2";return m.jsxs("span",{className:"group relative inline-flex",children:[t,m.jsx("span",{role:"tooltip",className:`pointer-events-none absolute z-50 ${s} ${l} ${o} rounded border border-border bg-popover px-3 py-2 text-xs leading-snug text-popover-foreground opacity-0 shadow-md transition-opacity group-hover:opacity-100 ${a}`,children:e})]})}function Z0e({subject:t}){return m.jsxs("div",{className:"space-y-2 text-[11px] leading-relaxed",children:[m.jsxs("div",{children:[m.jsx("p",{className:"font-semibold text-foreground",children:"Normal mode"}),m.jsxs("p",{children:["Stashes pending changes, ",t.verb," the committed code, then restores your changes. The baseline is always the committed state."]})]}),m.jsxs("div",{children:[m.jsx("p",{className:"font-semibold text-foreground",children:"Git Diff mode"}),m.jsxs("p",{children:["Compares your working tree against the committed baseline. Shows which ",t.plural," your pending changes introduce or resolve."]})]})]})}function Tre({diffMode:t,onToggle:e,subject:n}){return m.jsx(tm,{align:"end",width:"wide",content:m.jsx(Z0e,{subject:n}),children:m.jsxs("div",{className:"flex items-center rounded-md border border-border p-0.5",children:[m.jsx("button",{type:"button",onClick:()=>t&&e(!1),className:`rounded px-2 py-0.5 text-xs font-medium transition-colors ${t?"text-muted-foreground hover:text-foreground":"bg-accent text-accent-foreground"}`,children:"Normal"}),m.jsx("button",{type:"button",onClick:()=>!t&&e(!0),className:`rounded px-2 py-0.5 text-xs font-medium transition-colors ${t?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Git Diff"})]})})}function kre({items:t,selectedId:e,onSelect:n}){var s;const[r,i]=_.useState(!1),a=_.useRef(null);if(_.useEffect(()=>{const l=c=>{a.current&&!a.current.contains(c.target)&&i(!1)};return r&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),t.length<=1)return null;const o=e?((s=t.find(l=>l.id===e))==null?void 0:s.label)??"Past run":"Latest";return m.jsxs("div",{className:"relative",ref:a,children:[m.jsxs("button",{className:"flex items-center gap-1 rounded-md border border-border bg-card px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(l=>!l),children:[o,m.jsx(qa,{className:"h-3 w-3"})]}),r&&m.jsx("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-56 rounded-md border border-border bg-popover shadow-lg",children:m.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[m.jsx("button",{className:`w-full whitespace-nowrap px-3 py-1.5 text-left text-xs hover:bg-accent transition-colors ${e?"text-muted-foreground":"bg-accent/50 font-medium text-foreground"}`,onClick:()=>{n(null),i(!1)},children:"Latest"}),t.map((l,c)=>{const u=c===0,f=u?!e:e===l.id;return m.jsxs("button",{className:`w-full whitespace-nowrap px-3 py-1.5 text-left text-xs hover:bg-accent transition-colors ${f?"bg-accent/50 font-medium text-foreground":"text-muted-foreground"}`,onClick:()=>{n(u?null:l.id),i(!1)},children:[m.jsx("span",{children:l.label}),l.branch&&m.jsx("span",{className:"ml-1.5 font-mono opacity-60",children:l.branch}),u&&m.jsx("span",{className:"ml-1.5 text-primary/70",children:"(latest)"})]},l.id)})]})})]})}async function V0e(){return null}const _re=_.createContext({routes:[],navItems:[],loaded:!1});function U0e({children:t}){const{edition:e,isLoading:n,capabilities:r}=wS(),[i,a]=_.useState(null);_.useEffect(()=>{if(n)return;if(e!=="enterprise"){a(null);return}let s=!1;return V0e().then(l=>{s||a(l)}),()=>{s=!0}},[e,n]);const o=_.useMemo(()=>{const s=l=>!l||r.has(l);return{routes:((i==null?void 0:i.routes)??[]).filter(l=>s(l.requiredCapability)),navItems:((i==null?void 0:i.navItems)??[]).filter(l=>s(l.requiredCapability)),homeComponent:i==null?void 0:i.homeComponent,loaded:i!==null}},[i,r]);return m.jsx(_re.Provider,{value:o,children:t})}function Xre(){return _.useContext(_re)}const N0e={Building2:Tve};function W0e(){const{navItems:t}=Xre(),{pathname:e}=ks();return t.length===0?null:m.jsx(m.Fragment,{children:t.map(n=>{const r=n.iconName?N0e[n.iconName]:void 0,i=e===n.to;return m.jsxs(Dh,{to:n.to,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors ${i?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[r&&m.jsx(r,{className:"h-4 w-4"}),n.label]},n.id)})})}const xk="/api/ee/auth",Rre=_.createContext({status:"disabled",user:null,signIn:()=>{},signOut:async()=>{}});function M0e({children:t}){const{edition:e,isLoading:n}=wS(),[r,i]=_.useState("loading"),[a,o]=_.useState(null);_.useEffect(()=>{if(n)return;if(e!=="enterprise"){i("disabled"),o(null);return}let u=!1;return i("loading"),fetch(`${ly()}${xk}/me`,{credentials:"include"}).then(async f=>{if(!u)if(f.ok){const h=await f.json();o(h.user),i("authed")}else o(null),i("anon")}).catch(()=>{u||(o(null),i("anon"))}),()=>{u=!0}},[e,n]);const s=_.useCallback(()=>{window.location.href=`${ly()}${xk}/login`},[]),l=_.useCallback(async()=>{try{const f=await(await fetch(`${ly()}${xk}/logout`,{method:"POST",credentials:"include"})).json().catch(()=>({}));window.location.href=f.logoutUrl??"/"}catch{window.location.href="/"}},[]),c=_.useMemo(()=>({status:r,user:a,signIn:s,signOut:l}),[r,a,s,l]);return m.jsx(Rre.Provider,{value:c,children:t})}function jre(){return _.useContext(Rre)}function j8({children:t}){return m.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-background text-foreground",children:t})}function I0e({children:t}){const{status:e,signIn:n}=jre(),r=new URLSearchParams(window.location.search).get("auth_error");return _.useEffect(()=>{e==="anon"&&!r&&n()},[e,r,n]),e==="disabled"||e==="authed"?m.jsx(m.Fragment,{children:t}):e==="anon"&&r?m.jsx(j8,{children:m.jsxs("div",{className:"max-w-sm text-center",children:[m.jsx("p",{className:"text-sm font-medium",children:"Sign-in failed"}),m.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["We couldn't complete authentication (",r,")."]}),m.jsx("button",{onClick:n,className:"mt-4 rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:opacity-90",children:"Try again"})]})}):m.jsx(j8,{children:m.jsx(yn,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}function Ere(){const[t,e]=_.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));return _.useEffect(()=>{if(typeof document>"u")return;const n=document.documentElement,r=new MutationObserver(()=>{e(n.classList.contains("dark"))});return r.observe(n,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}function Cre(){const t=Ere(),e=_.useCallback(()=>{const n=!document.documentElement.classList.contains("dark");document.documentElement.classList.toggle("dark",n),localStorage.setItem("theme",n?"dark":"light")},[]);return{isDark:t,toggle:e}}const zre="https://github.com/truecourse-ai/truecourse",Yre="https://discord.gg/TanxB63arz";function Are({className:t}){return m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:t,children:m.jsx("path",{d:"M20.317 4.369a19.79 19.79 0 0 0-4.885-1.515.074.074 0 0 0-.078.037c-.21.375-.444.864-.608 1.249a18.27 18.27 0 0 0-5.487 0 12.683 12.683 0 0 0-.617-1.249.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.369a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.105 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128c.126-.094.252-.192.372-.291a.074.074 0 0 1 .077-.01c3.927 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .078.009c.12.099.246.198.373.292a.077.077 0 0 1-.006.128 12.3 12.3 0 0 1-1.873.891.077.077 0 0 0-.041.106c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.84 19.84 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.548-13.66a.061.061 0 0 0-.031-.028zM8.02 15.331c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.418 2.157-2.418 1.21 0 2.176 1.094 2.157 2.418 0 1.334-.956 2.419-2.157 2.419zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.418 2.157-2.418 1.21 0 2.176 1.094 2.157 2.418 0 1.334-.946 2.419-2.157 2.419z"})})}const uQ="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-foreground hover:bg-muted transition-colors";function D0e(){var u;const{status:t,user:e,signOut:n}=jre(),{isDark:r,toggle:i}=Cre(),[a,o]=_.useState(!1),s=_.useRef(null);if(_.useEffect(()=>{if(!a)return;const f=h=>{s.current&&!s.current.contains(h.target)&&o(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a]),t!=="authed"||!e)return null;const l=[e.firstName,e.lastName].filter(Boolean).join(" ")||e.email,c=(((u=e.firstName)==null?void 0:u[0])??e.email[0]??"?").toUpperCase();return m.jsxs("div",{className:"relative",ref:s,children:[m.jsxs("button",{type:"button",onClick:()=>o(f=>!f),className:"flex items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-haspopup":"menu","aria-expanded":a,children:[m.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary/20 text-[10px] font-semibold text-primary",children:c}),m.jsx(qa,{className:"h-3 w-3"})]}),a&&m.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-50 mt-1 min-w-56 rounded-md border border-border bg-popover p-1 shadow-lg",children:[m.jsxs("div",{className:"px-2 py-1.5",children:[m.jsx("div",{className:"truncate text-xs font-medium text-foreground",children:l}),m.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:e.email})]}),m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{role:"menuitem",onClick:i,className:uQ,children:[r?m.jsx(Vne,{className:"h-3.5 w-3.5"}):m.jsx(Cne,{className:"h-3.5 w-3.5"}),r?"Light mode":"Dark mode"]}),m.jsxs("a",{role:"menuitem",href:zre,target:"_blank",rel:"noopener noreferrer",onClick:()=>o(!1),className:uQ,children:[m.jsx(Xne,{className:"h-3.5 w-3.5"}),"Star on GitHub",m.jsx(Zne,{className:"ml-auto h-3 w-3 text-muted-foreground"})]}),m.jsxs("a",{role:"menuitem",href:Yre,target:"_blank",rel:"noopener noreferrer",onClick:()=>o(!1),className:uQ+" text-[#5865F2] hover:text-[#5865F2]",children:[m.jsx(Are,{className:"h-3.5 w-3.5"}),"Discord"]}),m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{role:"menuitem",onClick:()=>{o(!1),n()},className:uQ,children:[m.jsx(Wve,{className:"h-3.5 w-3.5"}),"Sign out"]})]})]})}function qq({repoName:t,currentBranch:e,onAnalyze:n,isAnalyzing:r,showBack:i,backHref:a="/",isDiffMode:o,onEnterDiffMode:s,onExitDiffMode:l,analyses:c,selectedAnalysisId:u,onSelectAnalysis:f,currentAnalysisId:h,dashboardSection:p,onDashboardSectionChange:y,sectionActions:v}){const $=R0e(),{isDark:x,toggle:S}=Cre();return m.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-border bg-card px-4",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[i&&m.jsx(Dh,{to:a,className:Tb({variant:"ghost",size:"icon-sm"}),children:m.jsx(Qne,{className:"h-5 w-5"})}),m.jsxs(Dh,{to:"/",className:"flex items-center gap-2 text-lg font-bold text-foreground",children:[m.jsx("img",{src:"/logo.svg",alt:"TrueCourse",className:"h-7 w-7"}),"TrueCourse"]}),p&&y&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted-foreground/60",children:"/"}),m.jsx(A0e,{value:p,onChange:y})]})]}),m.jsxs("div",{className:"flex items-center gap-3",children:[t&&m.jsx("span",{className:"text-sm font-medium text-foreground",children:t}),m.jsx(q0e,{branch:e}),c&&f&&m.jsx(kre,{items:c.map(b=>{const T=new Date(b.createdAt);return{id:b.id,label:`${T.toLocaleDateString()} ${T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`,branch:b.branch}}),selectedId:u??null,onSelect:f}),s&&m.jsx(Tre,{diffMode:!!o,onToggle:b=>b?s==null?void 0:s():l==null?void 0:l(),subject:{verb:"analyzes",plural:"violations"}}),v&&m.jsx("div",{className:"flex items-center gap-2",children:v}),n&&m.jsx("div",{className:"relative flex items-center",children:m.jsxs(xn,{size:"sm",onClick:()=>n(),disabled:r,children:[r&&m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}),r?"Analyzing...":"Analyze"]})})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(W0e,{}),m.jsx(D0e,{}),$!=="enterprise"&&m.jsxs(m.Fragment,{children:[m.jsxs("a",{href:zre,target:"_blank",rel:"noopener noreferrer",className:Tb({variant:"ghost",size:"sm"})+" gap-1.5","aria-label":"Star TrueCourse on GitHub",children:[m.jsx(Xne,{className:"h-4 w-4"}),m.jsx(Zne,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Star"})]}),m.jsxs("a",{href:Yre,target:"_blank",rel:"noopener noreferrer",className:Tb({variant:"ghost",size:"sm"})+" gap-1.5 text-[#5865F2] hover:text-[#5865F2]","aria-label":"Join the TrueCourse Discord",children:[m.jsx(Are,{className:"h-4 w-4"}),m.jsx("span",{className:"text-xs font-medium",children:"Discord"})]}),m.jsx(xn,{variant:"ghost",size:"icon-sm",onClick:S,"aria-label":"Toggle theme",children:x?m.jsx(Vne,{className:"h-5 w-5"}):m.jsx(Cne,{className:"h-5 w-5"})})]})]})]})}let E8=(function(t){return t.disabled="data-disabled",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t})({});const L0e={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Fg={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},G0e={disabled:!1,...Fg},B0e={valid(t){return t===null?null:t?{[E8.valid]:""}:{[E8.invalid]:""}}},F0e=_.createContext({invalid:void 0,name:void 0,validityData:{state:L0e,errors:[],error:"",value:"",initialValue:null},setValidityData:Ra,disabled:void 0,touched:Fg.touched,setTouched:Ra,dirty:Fg.dirty,setDirty:Ra,filled:Fg.filled,setFilled:Ra,focused:Fg.focused,setFocused:Ra,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:G0e,markedDirtyRef:{current:!1},validation:{getValidationProps:(t=Ii)=>t,getInputValidationProps:(t=Ii)=>t,inputRef:{current:null},commit:async()=>{}}});function qre(t=!0){const e=_.useContext(F0e);if(e.setValidityData===Ra&&!t)throw new Error(_s(28));return e}const H0e=_.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Ra,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function K0e(){return _.useContext(H0e)}let C8=0;function J0e(t,e="mui"){const[n,r]=_.useState(t),i=t||n;return _.useEffect(()=>{n==null&&(C8+=1,r(`${e}-${C8}`))},[n,e]),i}const z8=cxe.useId;function Ov(t,e){if(z8!==void 0){const n=z8();return t??(e?`${e}-${n}`:n)}return J0e(t,e)}function fv(t){return Ov(t,"base-ui")}const e1e=_.createContext({controlId:void 0,registerControlId:Ra,labelId:void 0,setLabelId:Ra,messageIds:[],setMessageIds:Ra,getDescriptionProps:t=>t});function Zre(){return _.useContext(e1e)}const t1e=[];function Zq(t){_.useEffect(t,t1e)}const Qg=0;class Qs{constructor(){Wn(this,"currentId",Qg);Wn(this,"clear",()=>{this.currentId!==Qg&&(clearTimeout(this.currentId),this.currentId=Qg)});Wn(this,"disposeEffect",()=>this.clear)}static create(){return new Qs}start(e,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Qg,n()},e)}isStarted(){return this.currentId!==Qg}}function tO(){const t=yo(Qs.create).current;return Zq(t.disposeEffect),t}function n1e(t,e){return{...t,state:{...t.state,valid:!e&&t.state.valid}}}function dr(t){return(t==null?void 0:t.ownerDocument)||document}const nm=typeof navigator<"u",Qk=i1e(),Vre=o1e(),Ure=a1e(),Nre=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Wre=Qk.platform==="MacIntel"&&Qk.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Qk.platform),Mre=nm&&/apple/i.test(navigator.vendor),LC=nm&&/android/i.test(Vre)||/android/i.test(Ure),r1e=nm&&Vre.toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints,Ire=Ure.includes("jsdom/");function i1e(){if(!nm)return{platform:"",maxTouchPoints:-1};const t=navigator.userAgentData;return t!=null&&t.platform?{platform:t.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function a1e(){if(!nm)return"";const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(({brand:e,version:n})=>`${e}/${n}`).join(" "):navigator.userAgent}function o1e(){if(!nm)return"";const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform??""}const GC="data-base-ui-focusable",Dre="active",Lre="selected",Gre="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Js(t){var n;let e=t.activeElement;for(;((n=e==null?void 0:e.shadowRoot)==null?void 0:n.activeElement)!=null;)e=e.shadowRoot.activeElement;return e}function ln(t,e){var r;if(!t||!e)return!1;const n=(r=e.getRootNode)==null?void 0:r.call(e);if(t.contains(e))return!0;if(n&&qy(n)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function p0(t,e){if(!jn(t))return!1;const n=t;if(e.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,r]of e.entries())if(ln(r,n))return!r.hasAttribute("data-trigger-disabled");return!1}function _a(t){return"composedPath"in t?t.composedPath()[0]:t.target}function as(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function s1e(t){return t.matches("html,body")}function TS(t){return yi(t)&&t.matches(Gre)}function Y8(t){return t?t.getAttribute("role")==="combobox"&&TS(t):!1}function l1e(t){if(!t||Ire)return!0;try{return t.matches(":focus-visible")}catch{return!0}}function BC(t){return t?t.hasAttribute(GC)?t:t.querySelector(`[${GC}]`)||t:null}function Sc(t,e,n=!0){return t.filter(i=>{var a;return i.parentId===e&&(!n||((a=i.context)==null?void 0:a.open))}).flatMap(i=>[i,...Sc(t,i.id,n)])}function A8(t,e){var i;let n=[],r=(i=t.find(a=>a.id===e))==null?void 0:i.parentId;for(;r;){const a=t.find(o=>o.id===r);r=a==null?void 0:a.parentId,a&&(n=n.concat(a))}return n}function c1e(t){t.preventDefault(),t.stopPropagation()}function u1e(t){return"nativeEvent"in t}function O1e(t){return t.pointerType===""&&t.isTrusted?!0:LC&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function f1e(t){return Ire?!1:!LC&&t.width===0&&t.height===0||LC&&t.width===1&&t.height===1&&t.pressure===0&&t.detail===0&&t.pointerType==="mouse"||t.width<1&&t.height<1&&t.pressure===0&&t.detail===0&&t.pointerType==="touch"}function tp(t,e){const n=["mouse","pen"];return e||n.push("",void 0),n.includes(t)}function Bre(t){const e=t.type;return e==="click"||e==="mousedown"||e==="keydown"||e==="keyup"}const d1e=["top","right","bottom","left"],np=Math.min,io=Math.max,m0=Math.round,OQ=Math.floor,hl=t=>({x:t,y:t}),h1e={left:"right",right:"left",bottom:"top",top:"bottom"};function FC(t,e,n){return io(t,np(e,n))}function Yc(t,e){return typeof t=="function"?t(e):t}function Ca(t){return t.split("-")[0]}function hO(t){return t.split("-")[1]}function Vq(t){return t==="x"?"y":"x"}function Uq(t){return t==="y"?"height":"width"}function zo(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Nq(t){return Vq(zo(t))}function p1e(t,e,n){n===void 0&&(n=!1);const r=hO(t),i=Nq(t),a=Uq(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=g0(o)),[o,g0(o)]}function m1e(t){const e=g0(t);return[HC(t),e,HC(e)]}function HC(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const q8=["left","right"],Z8=["right","left"],g1e=["top","bottom"],y1e=["bottom","top"];function $1e(t,e,n){switch(t){case"top":case"bottom":return n?e?Z8:q8:e?q8:Z8;case"left":case"right":return e?g1e:y1e;default:return[]}}function v1e(t,e,n,r){const i=hO(t);let a=$1e(Ca(t),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(HC)))),a}function g0(t){const e=Ca(t);return h1e[e]+t.slice(e.length)}function x1e(t){return{top:0,right:0,bottom:0,left:0,...t}}function Fre(t){return typeof t!="number"?x1e(t):{top:t,right:t,bottom:t,left:t}}function y0(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Q1e(t){return fo(t).display!=="none"}/*!
|
|
536
536
|
* tabbable 6.4.0
|
|
537
537
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
538
|
-
*/var b1e=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],$0=b1e.join(","),Hre=typeof Element>"u",rp=Hre?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,v0=!Hre&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},x0=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",o=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):x0(e.parentNode));return o},S1e=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},Kre=function(e,n,r){if(x0(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll($0));return n&&rp.call(e,$0)&&i.unshift(e),i=i.filter(r),i},Q0=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var o=a.shift();if(!x0(o,!1))if(o.tagName==="SLOT"){var s=o.assignedElements(),l=s.length?s:o.children,c=Q0(l,!0,r);r.flatten?i.push.apply(i,c):i.push({scopeParent:o,candidates:c})}else{var u=rp.call(o,$0);u&&r.filter(o)&&(n||!e.includes(o))&&i.push(o);var f=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),h=!x0(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(f&&h){var p=Q0(f===!0?o.children:f.children,!0,r);r.flatten?i.push.apply(i,p):i.push({scopeParent:o,candidates:p})}else a.unshift.apply(a,o.children)}}return i},Jre=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},eie=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||S1e(e))&&!Jre(e)?0:e.tabIndex},w1e=function(e,n){var r=eie(e);return r<0&&n&&!Jre(e)?0:r},P1e=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},tie=function(e){return e.tagName==="INPUT"},T1e=function(e){return tie(e)&&e.type==="hidden"},k1e=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},_1e=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},X1e=function(e){if(!e.name)return!0;var n=e.form||v0(e),r=function(s){return n.querySelectorAll('input[type="radio"][name="'+s+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var a=_1e(i,e.form);return!a||a===e},R1e=function(e){return tie(e)&&e.type==="radio"},j1e=function(e){return R1e(e)&&!X1e(e)},E1e=function(e){var n,r=e&&v0(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var o,s,l;for(a=!!((o=i)!==null&&o!==void 0&&(s=o.ownerDocument)!==null&&s!==void 0&&s.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var c,u,f;r=v0(i),i=(c=r)===null||c===void 0?void 0:c.host,a=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i))}}return a},V8=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},C1e=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var o=rp.call(e,"details>summary:first-of-type"),s=o?e.parentElement:e;if(rp.call(s,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var c=e.parentElement,u=v0(e);if(c&&!c.shadowRoot&&i(c)===!0)return V8(e);e.assignedSlot?e=e.assignedSlot:!c&&u!==e.ownerDocument?e=u.host:e=c}e=l}if(E1e(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return V8(e);return!1},z1e=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return rp.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},KC=function(e,n){return!(n.disabled||T1e(n)||C1e(n,e)||k1e(n)||z1e(n))},JC=function(e,n){return!(j1e(n)||eie(n)<0||!KC(e,n))},Y1e=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},nie=function(e){var n=[],r=[];return e.forEach(function(i,a){var o=!!i.scopeParent,s=o?i.scopeParent:i,l=w1e(s,o),c=o?nie(i.candidates):s;l===0?o?n.push.apply(n,c):n.push(s):r.push({documentOrder:a,tabIndex:l,item:i,isScope:o,content:c})}),r.sort(P1e).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},kS=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Q0([e],n.includeContainer,{filter:JC.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Y1e}):r=Kre(e,n.includeContainer,JC.bind(null,n)),nie(r)},A1e=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Q0([e],n.includeContainer,{filter:KC.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Kre(e,n.includeContainer,KC.bind(null,n)),r},rie=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return rp.call(e,$0)===!1?!1:JC(n,e)};const dv=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function iie(t,e){const n=kS(t,dv()),r=n.length;if(r===0)return;const i=Js(dr(t)),a=n.indexOf(i),o=a===-1?e===1?0:r-1:a+e;return n[o]}function aie(t){return iie(dr(t).body,1)||t}function oie(t){return iie(dr(t).body,-1)||t}function cy(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!ln(n,r)}function q1e(t){kS(t,dv()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function U8(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const fQ=null;class Z1e{constructor(){Wn(this,"callbacks",[]);Wn(this,"callbacksCount",0);Wn(this,"nextId",1);Wn(this,"startId",1);Wn(this,"isScheduled",!1);Wn(this,"tick",e=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let a=0;a<n.length;a+=1)(i=n[a])==null||i.call(n,e)})}request(e){const n=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(e){const n=e-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const dQ=new Z1e;class el{constructor(){Wn(this,"currentId",fQ);Wn(this,"cancel",()=>{this.currentId!==fQ&&(dQ.cancel(this.currentId),this.currentId=fQ)});Wn(this,"disposeEffect",()=>this.cancel)}static create(){return new el}static request(e){return dQ.request(e)}static cancel(e){return dQ.cancel(e)}request(e){this.cancel(),this.currentId=dQ.request(()=>{this.currentId=fQ,e()})}}function Wq(){const t=yo(el.create).current;return Zq(t.disposeEffect),t}function sc(t){return t==null?t:"current"in t?t.current:t}let Ny=(function(t){return t.startingStyle="data-starting-style",t.endingStyle="data-ending-style",t})({});const V1e={[Ny.startingStyle]:""},U1e={[Ny.endingStyle]:""},Mq={transitionStatus(t){return t==="starting"?V1e:t==="ending"?U1e:null}};function N1e(t,e=!1,n=!0){const r=Wq();return tn((i,a=null)=>{r.cancel();function o(){Pl.flushSync(i)}const s=sc(t);if(s==null)return;const l=s;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let f=function(){const p=Ny.startingStyle;if(!l.hasAttribute(p)){r.request(h);return}const y=new MutationObserver(()=>{l.hasAttribute(p)||(y.disconnect(),h())});y.observe(l,{attributes:!0,attributeFilter:[p]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},h=function(){Promise.all(l.getAnimations().map(p=>p.finished)).then(()=>{a!=null&&a.aborted||o()}).catch(()=>{const p=l.getAnimations();if(n){if(a!=null&&a.aborted)return;o()}else p.length>0&&p.some(y=>y.pending||y.playState!=="finished")&&h()})};var c=f,u=h;if(e){f();return}r.request(h)}})}function Iq(t){const{enabled:e=!0,open:n,ref:r,onComplete:i}=t,a=tn(i),o=N1e(r,n,!1);_.useEffect(()=>{if(!e)return;const s=new AbortController;return o(a,s.signal),()=>{s.abort()}},[e,n,a,o])}function W1e(t,e=!1,n=!1){const[r,i]=_.useState(t&&e?"idle":void 0),[a,o]=_.useState(t);return t&&!a&&(o(!0),i("starting")),!t&&a&&r!=="ending"&&!n&&i("ending"),!t&&!a&&r==="ending"&&i(void 0),qt(()=>{if(!t&&a&&r!=="ending"&&n){const s=el.request(()=>{i("ending")});return()=>{el.cancel(s)}}},[t,a,r,n]),qt(()=>{if(!t||e)return;const s=el.request(()=>{i(void 0)});return()=>{el.cancel(s)}},[e,t]),qt(()=>{if(!t||!e)return;t&&a&&r!=="idle"&&i("starting");const s=el.request(()=>{i("idle")});return()=>{el.cancel(s)}},[e,t,a,i,r]),_.useMemo(()=>({mounted:a,setMounted:o,transitionStatus:r}),[a,r])}function M1e({controlled:t,default:e,name:n,state:r="value"}){const{current:i}=_.useRef(t!==void 0),[a,o]=_.useState(e),s=i?t:a,l=_.useCallback(c=>{i||o(c)},[]);return[s,l]}function I1e(t={}){const{id:e,implicit:n=!1,controlRef:r}=t,{controlId:i,registerControlId:a}=Zre(),o=fv(e),s=n?i:void 0,l=yo(()=>Symbol("labelable-control")),c=_.useRef(!1),u=_.useRef(e!=null),f=tn(()=>{!c.current||a===Ra||(c.current=!1,a(l.current,void 0))});return qt(()=>{if(a===Ra)return;let h;if(n){const p=r==null?void 0:r.current;jn(p)&&p.closest("label")!=null?h=e??null:h=s??o}else if(e!=null)u.current=!0,h=e;else if(u.current)h=o;else{f();return}if(h===void 0){f();return}c.current=!0,a(l.current,h)},[e,r,s,a,n,o,l,f]),_.useEffect(()=>f,[f]),i??o}function D1e(t){const{enabled:e=!0,value:n,id:r,name:i,controlRef:a,commit:o}=t,{formRef:s}=K0e(),{invalid:l,markedDirtyRef:c,validityData:u,setValidityData:f}=qre(),h=tn(t.getValue);qt(()=>{if(!e)return;let p=n;p===void 0&&(p=h()),u.initialValue===null&&p!==null&&f(y=>({...y,initialValue:p}))},[e,f,n,u.initialValue,h]),qt(()=>{!e||!r||s.current.fields.set(r,{getValue:h,name:i,controlRef:a,validityData:n1e(u,l),validate(p=!0){let y=n;y===void 0&&(y=h()),c.current=!0,p?Pl.flushSync(()=>o(y)):o(y)}})},[o,a,e,s,h,r,l,c,i,u,n]),qt(()=>{const p=s.current.fields;return()=>{r&&p.delete(r)}},[s,r])}const Dq="none",Wy="trigger-press",us="trigger-hover",kb="trigger-focus",sie="outside-press",L1e="close-press",lie="focus-out",Lq="escape-key",G1e="disabled",cie="imperative-action";function or(t,e,n,r){let i=!1,a=!1;const o=Ii;return{reason:t,event:e??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}const B1e=_.forwardRef(function(e,n){const{render:r,className:i,id:a,name:o,value:s,disabled:l=!1,onValueChange:c,defaultValue:u,autoFocus:f=!1,...h}=e,{state:p,name:y,disabled:v,setTouched:$,setDirty:x,validityData:S,setFocused:b,setFilled:T,validationMode:w,validation:P}=qre(),k=v||l,R=y??o,E={...p,disabled:k},{labelId:C}=Zre(),z=I1e({id:a});qt(()=>{var D;const Z=s!=null;(D=P.inputRef.current)!=null&&D.value||Z&&s!==""?T(!0):Z&&s===""&&T(!1)},[P.inputRef,T,s]);const Y=_.useRef(null);qt(()=>{f&&Y.current===Js(dr(Y.current))&&b(!0)},[f,b]);const[W]=M1e({controlled:s,default:u,name:"FieldControl",state:"value"}),A=s!==void 0,q=A?W:void 0;return D1e({id:z,name:R,commit:P.commit,value:q,getValue:()=>{var Z;return(Z=P.inputRef.current)==null?void 0:Z.value},controlRef:P.inputRef}),ha("input",e,{ref:[n,Y],state:E,props:[{id:z,disabled:k,name:R,ref:P.inputRef,"aria-labelledby":C,autoFocus:f,...A?{value:q}:{defaultValue:u},onChange(Z){const D=Z.currentTarget.value;c==null||c(D,or(Dq,Z.nativeEvent)),x(D!==S.initialValue),T(D!=="")},onFocus(){b(!0)},onBlur(Z){$(!0),b(!1),w==="onBlur"&&P.commit(Z.currentTarget.value)},onKeyDown(Z){Z.currentTarget.tagName==="INPUT"&&Z.key==="Enter"&&($(!0),P.commit(Z.currentTarget.value))}},P.getInputValidationProps(),h],stateAttributesMapping:B0e})}),F1e=_.forwardRef(function(e,n){return m.jsx(B1e,{ref:n,...e})});function H1e({className:t,type:e,...n}){return m.jsx(F1e,{type:e,"data-slot":"input",className:jr("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...n})}function K1e({onAdd:t}){const[e,n]=_.useState(""),[r,i]=_.useState(!1),a=async o=>{if(o.preventDefault(),!!e.trim()){i(!0);try{await t(e.trim()),n("")}catch{}finally{i(!1)}}};return m.jsx("form",{onSubmit:a,className:"w-full",children:m.jsxs("div",{className:"flex gap-2",children:[m.jsxs("div",{className:"relative flex-1",children:[m.jsx(zve,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),m.jsx(H1e,{type:"text",value:e,onChange:o=>n(o.target.value),placeholder:"Paste repository path...",className:"pl-10"})]}),m.jsxs(xn,{type:"submit",disabled:r||!e.trim(),children:[r?m.jsx(yn,{className:"h-4 w-4 animate-spin"}):m.jsx(Yne,{className:"h-4 w-4"}),"Add Repository"]})]})})}function J1e({repos:t,onDelete:e}){const n=(r,i)=>{r.preventDefault(),r.stopPropagation();const a=i.lastAnalyzed?`Delete "${i.name}"? This will remove all analyses, violations, and chat history.`:`Delete "${i.name}"?`;confirm(a)&&e(i.id)};return t.length===0?m.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border py-16",children:[m.jsx(Lh,{className:"mb-4 h-12 w-12 text-muted-foreground"}),m.jsx("p",{className:"text-lg font-medium text-foreground",children:"No repositories yet"}),m.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add a repository path above to get started"})]}):m.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map(r=>m.jsxs(Dh,{to:`/repos/${r.id}`,className:"group relative flex flex-col rounded-xl border border-border bg-card p-4 ring-1 ring-foreground/10 transition-all hover:shadow-md hover:ring-primary/30",children:[m.jsx("button",{onClick:i=>n(i,r),className:"absolute right-3 top-3 rounded-md p-1 text-muted-foreground/50 opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100","aria-label":"Delete repository",children:m.jsx(Pq,{className:"h-3.5 w-3.5"})}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-lg bg-primary/10",children:m.jsx(Lh,{className:"h-5 w-5 text-primary"})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),m.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:r.path})]})]}),m.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[r.lastAnalyzed?m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[m.jsx(gS,{className:"h-3 w-3"}),m.jsxs("span",{children:["Analyzed"," ",new Date(r.lastAnalyzed).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}):m.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"Not analyzed yet"}),m.jsx(Qve,{className:"h-3.5 w-3.5 text-muted-foreground/50 transition-transform group-hover:translate-x-0.5 group-hover:text-primary"})]})]},r.id))})}function eSe(){const[t,e]=_.useState([]),[n,r]=_.useState(!0),[i,a]=_.useState(null),o=_.useCallback(async()=>{r(!0),a(null);try{const u=await Nbe();e(u)}catch(u){a(u instanceof Error?u.message:"Failed to fetch repos")}finally{r(!1)}},[]);_.useEffect(()=>{o()},[o]);const s=_.useCallback(async u=>{try{const f=await Wbe(u);return e(h=>[...h,f]),f}catch(f){const h=f instanceof Error?f.message:"Failed to add repo";throw a(h),f}},[]),l=_.useCallback(async u=>{try{await Mbe(u),e(f=>f.filter(h=>h.id!==u))}catch(f){const h=f instanceof Error?f.message:"Failed to delete repo";throw a(h),f}},[]),c=_.useCallback(async(u,f)=>{try{return await vre(u,f)}catch(h){const p=h instanceof Error?h.message:"Failed to start analysis";throw a(p),h}},[]);return{repos:t,isLoading:n,error:i,addRepo:s,deleteRepo:l,analyzeRepo:c,refetch:o}}const tSe=Eq("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function uy({className:t,variant:e,...n}){return m.jsx("div",{"data-slot":"alert",role:"alert",className:jr(tSe({variant:e}),t),...n})}function N8({className:t,...e}){return m.jsx("div",{"data-slot":"alert-title",className:jr("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),...e})}function Oy({className:t,...e}){return m.jsx("div",{"data-slot":"alert-description",className:jr("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),...e})}function nSe(){const{repos:t,isLoading:e,error:n,addRepo:r,deleteRepo:i}=eSe(),a=async o=>{try{await i(o)}catch{}};return m.jsxs("div",{className:"flex min-h-screen flex-col",children:[m.jsx(qq,{}),m.jsxs("main",{className:"mx-auto w-full max-w-5xl flex-1 px-4 py-8",children:[m.jsxs("div",{className:"mb-8 text-center",children:[m.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"TrueCourse"}),m.jsx("p",{className:"mt-2 text-muted-foreground",children:"Visualize and understand your codebase architecture"})]}),m.jsxs("div",{className:"mb-8 space-y-5",children:[m.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-lg border border-border bg-card p-6",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this from your project directory:"}),m.jsx("code",{className:"rounded-md bg-muted px-4 py-2.5 font-mono text-sm text-foreground select-all",children:"npx truecourse add"})]}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"h-px flex-1 bg-border"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"or add manually"}),m.jsx("div",{className:"h-px flex-1 bg-border"})]}),m.jsx(K1e,{onAdd:r})]}),n&&m.jsx(uy,{variant:"destructive",className:"mb-6",children:m.jsx(Oy,{children:n})}),e?m.jsx("div",{className:"flex items-center justify-center py-16",children:m.jsx(yn,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m.jsx(J1e,{repos:t,onDelete:a})]})]})}function rSe({section:t,activeTab:e,onTabChange:n,children:r,defaultWidth:i=350,minWidth:a=260,badgeCounts:o,tabWarnings:s}){var S;const[l,c]=_.useState(i),[u,f]=_.useState(800),h=_.useRef(!1),p=Y0e(t),y=_.useMemo(()=>new Set(p.filter(b=>b.noPanel).map(b=>b.id)),[p]);_.useEffect(()=>{const b=()=>Math.floor(window.innerWidth*.8);f(b());const T=()=>f(b());return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]);const v=_.useCallback(b=>{b.preventDefault(),h.current=!0;const T=b.clientX,w=l,P=R=>{if(!h.current)return;const E=R.clientX-T;c(Math.min(u,Math.max(a,w+E)))},k=()=>{h.current=!1,document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",k)},[l,a,u]),$=e!==null&&!y.has(e),x=e?((S=j0e(e))==null?void 0:S.label)??"":"";return m.jsxs("div",{className:"flex flex-shrink-0 h-full",children:[m.jsx("div",{className:"flex w-12 flex-col items-center gap-1 border-r border-border bg-card pt-2",children:p.map(b=>{const T=b.icon,w=e===b.id;return m.jsxs("button",{onClick:()=>n(w?null:b.id),className:`group relative flex h-10 w-10 items-center justify-center rounded-md transition-colors ${w?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,"aria-label":b.label,children:[w&&m.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r bg-primary"}),m.jsx(T,{className:"h-5 w-5"}),m.jsx("span",{className:"pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md border border-border opacity-0 group-hover:opacity-100 transition-opacity z-50",children:b.label}),(()=>{const P=o==null?void 0:o[b.id];return P==null?null:typeof P=="number"?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-[9px] font-bold text-primary-foreground",children:P}):null:P.newCount+P.resolvedCount>0?m.jsxs("span",{className:"absolute -right-1 -top-1 flex items-center gap-px rounded-full bg-card border border-border px-1 py-px",children:[P.newCount>0&&m.jsxs("span",{className:"text-[8px] font-bold text-red-400",children:["+",P.newCount]}),P.resolvedCount>0&&m.jsxs("span",{className:"text-[8px] font-bold text-emerald-400",children:["-",P.resolvedCount]})]}):null})()]},b.id)})}),$&&m.jsxs("aside",{className:"relative flex-shrink-0 border-r border-border bg-card",style:{width:l},children:[m.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-border px-3",children:[m.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:x}),(()=>{const b=e?s==null?void 0:s[e]:void 0;return b?m.jsx(tm,{align:"start",width:"wide",content:b,children:m.jsx("span",{className:"flex items-center text-amber-400",children:m.jsx(zi,{className:"h-3.5 w-3.5"})})}):null})(),(()=>{const b=e?o==null?void 0:o[e]:void 0;return b==null?null:typeof b=="number"?b>0?m.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:b}):null:b.newCount+b.resolvedCount>0?m.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium",children:[b.newCount>0&&m.jsxs("span",{className:"text-red-400",children:["+",b.newCount," new"]}),b.resolvedCount>0&&m.jsxs("span",{className:"text-emerald-400",children:["-",b.resolvedCount," resolved"]})]}):null})()]}),m.jsx("div",{className:"h-[calc(100%-40px)] overflow-hidden",children:r}),m.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:v})]})]})}const W8=["tab","mode","scopeService","scopeModule","file","flow","canonical","contract","drift"];function ez(t){return(t==null?void 0:t.get("section"))==="drift"?"drift":"analysis"}function M8(t){const e=(t==null?void 0:t.get("tab"))??null;return e==="violations"?"graphs":e==="analytics"?"home":e&&E0e().has(e)?e:t!=null&&t.get("flow")?"flows":t!=null&&t.get("file")?"files":t!=null&&t.get("canonical")?"spec":t!=null&&t.get("contract")?"contracts":t!=null&&t.get("drift")?"verify":DC(ez(t))}const uie=_.createContext(null);function iSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(()=>ez(e)),[a,o]=_.useState(()=>M8(e)),s=_.useCallback(u=>{i(u);const f=DC(u);o(f);const h=new URL(window.location.href);u==="drift"?h.searchParams.set("section","drift"):h.searchParams.delete("section");for(const p of W8)h.searchParams.delete(p);h.searchParams.delete("view"),f!=="home"&&h.searchParams.set("tab",f),n(h.pathname+h.search)},[n]),l=_.useCallback(u=>{o(u);const f=new URL(window.location.href);if(u&&u!=="home")f.searchParams.set("tab",u);else for(const h of W8)f.searchParams.delete(h);n(f.pathname+f.search)},[n]);_.useEffect(()=>{const u=ez(e),f=M8(e),p=C0e(f)===u?f:DC(u);i(u),o(p)},[e]);const c=_.useMemo(()=>({section:r,leftTab:a,setSection:s,setLeftTab:l}),[r,a,s,l]);return m.jsx(uie.Provider,{value:c,children:t})}function Oie(){const t=_.useContext(uie);if(!t)throw new Error("useNavigation must be used inside <NavigationProvider>");return t}const I8={services:"services",modules:"modules",functions:"methods"},D8={services:"services",modules:"modules",methods:"functions"},fie=_.createContext(null);function aSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(null),[a,o]=_.useState(()=>I8[(e==null?void 0:e.get("mode"))||""]||"services"),[s,l]=_.useState(()=>(e==null?void 0:e.get("scopeService"))||null),[c,u]=_.useState(()=>(e==null?void 0:e.get("scopeModule"))||null),[f,h]=_.useState(null),p=_.useCallback(S=>{l(S);const b=new URL(window.location.href);S?b.searchParams.set("scopeService",S):b.searchParams.delete("scopeService"),n(b.pathname+b.search)},[n]),y=_.useCallback(S=>{u(S);const b=new URL(window.location.href);S?b.searchParams.set("scopeModule",S):b.searchParams.delete("scopeModule"),n(b.pathname+b.search)},[n]),v=_.useCallback(S=>{o(S);const b=new URL(window.location.href);S==="services"?(b.searchParams.delete("mode"),b.searchParams.delete("scopeService"),b.searchParams.delete("scopeModule")):S==="modules"?(b.searchParams.set("mode","modules"),b.searchParams.delete("scopeModule"),s&&b.searchParams.set("scopeService",s)):(b.searchParams.set("mode",D8[S]),s&&b.searchParams.set("scopeService",s),c&&b.searchParams.set("scopeModule",c)),n(b.pathname+b.search)},[n,s,c]),$=_.useCallback((S,b,T)=>{const w=b??a;let P=s,k=c;w==="services"?(P=null,k=null):w==="modules"?((T==null?void 0:T.serviceId)!==void 0&&(P=T.serviceId??null),k=null):((T==null?void 0:T.serviceId)!==void 0&&(P=T.serviceId??null),(T==null?void 0:T.moduleId)!==void 0&&(k=T.moduleId??null)),o(w),l(P),u(k);const R=new URL(window.location.href);w==="services"?R.searchParams.delete("mode"):R.searchParams.set("mode",D8[w]),P?R.searchParams.set("scopeService",P):R.searchParams.delete("scopeService"),k?R.searchParams.set("scopeModule",k):R.searchParams.delete("scopeModule"),n(R.pathname+R.search),b&&b!==a?setTimeout(()=>h({nodeId:S,key:Date.now()}),500):h({nodeId:S,key:Date.now()})},[a,s,c,n]);_.useEffect(()=>{o(I8[(e==null?void 0:e.get("mode"))??""]??"services"),l((e==null?void 0:e.get("scopeService"))??null),u((e==null?void 0:e.get("scopeModule"))??null)},[e]);const x=_.useMemo(()=>({selectedService:r,setSelectedService:i,depthLevel:a,setDepthLevel:v,scopedServiceId:s,setScopedServiceId:p,scopedModuleId:c,setScopedModuleId:y,focusRequest:f,setFocusRequest:h,locateNode:$}),[r,a,v,s,p,c,y,f,$]);return m.jsx(fie.Provider,{value:x,children:t})}function oSe(){const t=_.useContext(fie);if(!t)throw new Error("useGraphView must be used inside <GraphViewProvider>");return t}const die=_.createContext(null);function sSe({children:t}){const[e]=uv(),n=uO(),{setLeftTab:r}=Oie(),i=(e==null?void 0:e.get("file"))||null,[a,o]=_.useState(()=>i?[{path:i,pinned:!0}]:[]),[s,l]=_.useState(i),c=_.useCallback(M=>{l(M);const V=new URL(window.location.href);M?V.searchParams.set("file",M):V.searchParams.delete("file"),n(V.pathname+V.search)},[n]),u=_.useCallback((M,V,I)=>{o(B=>B.find(K=>K.path===M)?B.map(K=>K.path===M?{...K,pinned:V||K.pinned,scrollToLine:I??K.scrollToLine}:K):V?[...B,{path:M,pinned:!0,scrollToLine:I}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{path:M,pinned:!1,scrollToLine:I}):[...B,{path:M,pinned:!1,scrollToLine:I}]),c(M),r("files")},[c,r]),f=_.useCallback(M=>{if(o(V=>V.filter(I=>I.path!==M)),s===M){const V=a.filter(I=>I.path!==M);c(V.length>0?V[V.length-1].path:null)}},[a,s,c]),h=(e==null?void 0:e.get("flow"))||null,[p,y]=_.useState(()=>h?[{id:h,name:"Flow",pinned:!0}]:[]),[v,$]=_.useState(h),x=_.useCallback(M=>{$(M);const V=new URL(window.location.href);M?(V.searchParams.set("flow",M),V.searchParams.delete("file")):V.searchParams.delete("flow"),n(V.pathname+V.search)},[n]),S=_.useCallback(M=>{if(y(V=>V.filter(I=>I.id!==M)),v===M){const V=p.filter(I=>I.id!==M);x(V.length>0?V[V.length-1].id:null)}},[p,v,x]),b=_.useCallback(M=>{M.length!==0&&y(V=>V.map(I=>{const B=M.find(L=>L.id===I.id);return B?{...I,name:B.name}:I}))},[]),[T,w]=_.useState([]),[P,k]=_.useState(null),R=_.useCallback(M=>{k(M)},[]),E=_.useCallback(M=>{if(w(V=>V.filter(I=>I.id!==M)),P===M){const V=T.filter(I=>I.id!==M);R(V.length>0?V[V.length-1].id:null)}},[T,P,R]),C=_.useCallback(()=>{c(null),x(null),R(null)},[c,x,R]),z=_.useCallback(M=>{c(M),x(null),R(null),M!==null&&r("files")},[c,x,R,r]),Y=_.useCallback(M=>{z(M)},[z]),W=_.useCallback(M=>{x(M),c(null),R(null),M!==null&&r("flows")},[x,c,R,r]),A=_.useCallback(M=>{R(M),c(null),x(null),M!==null&&r("databases")},[R,c,x,r]),q=_.useCallback((M,V,I)=>{y(B=>B.find(K=>K.id===M)?B.map(K=>K.id===M?{...K,name:V,pinned:I||K.pinned}:K):I?[...B,{id:M,name:V,pinned:!0}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{id:M,name:V,pinned:!1}):[...B,{id:M,name:V,pinned:!1}]),W(M)},[W]),N=_.useCallback((M,V,I)=>{w(B=>B.find(K=>K.id===M)?B.map(K=>K.id===M?{...K,pinned:I||K.pinned}:K):I?[...B,{id:M,name:V,pinned:!0}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{id:M,name:V,pinned:!1}):[...B,{id:M,name:V,pinned:!1}]),A(M)},[A]),Z=_.useCallback(M=>{const V=M??"home";r(V),V==="flows"&&v===null&&p.length>0?x(p[p.length-1].id):V==="files"&&s===null&&a.length>0?c(a[a.length-1].path):V==="databases"&&P===null&&T.length>0&&R(T[T.length-1].id)},[r,v,p,x,s,a,c,P,T,R]);_.useEffect(()=>{l((e==null?void 0:e.get("file"))??null),$((e==null?void 0:e.get("flow"))??null)},[e]);const D=_.useMemo(()=>({openFiles:a,activeFilePath:s,setActiveFilePath:c,handleOpenFile:u,handleCloseFile:f,openFlows:p,activeFlowId:v,setActiveFlowId:x,handleOpenFlow:q,handleCloseFlow:S,syncFlowNames:b,openDatabases:T,activeDbId:P,setActiveDbId:R,handleOpenDatabase:N,handleCloseDatabase:E,clearActiveDetailView:C,showFileView:z,handleSelectTab:Y,showFlowView:W,showDatabaseView:A,handleLeftTabChange:Z}),[a,s,c,u,f,p,v,x,q,S,b,T,P,R,N,E,C,z,Y,W,A,Z]);return m.jsx(die.Provider,{value:D,children:t})}function lSe(){const t=_.useContext(die);if(!t)throw new Error("useOpenTabs must be used inside <OpenTabsProvider>");return t}const hie=_.createContext(null);function cSe({children:t}){const[e]=uv(),n=uO(),r=(e==null?void 0:e.get("canonical"))||null,i=(e==null?void 0:e.get("contract"))||null,[a,o]=_.useState(null),[s,l]=_.useState(r),[c,u]=_.useState(()=>r?[{path:r,pinned:!0}]:[]),f=_.useCallback(q=>{l(q);const N=new URL(window.location.href);q?N.searchParams.set("canonical",q):N.searchParams.delete("canonical"),n(N.pathname+N.search)},[n]),[h,p]=_.useState(i),[y,v]=_.useState(()=>i?[{path:i,pinned:!0}]:[]),$=_.useCallback(q=>{p(q);const N=new URL(window.location.href);q?N.searchParams.set("contract",q):N.searchParams.delete("contract"),n(N.pathname+N.search)},[n]),x=_.useCallback((q,N)=>{v(Z=>Z.find(V=>V.path===q)?Z.map(V=>V.path===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{path:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{path:q,pinned:!1}):[...Z,{path:q,pinned:!1}]),$(q)},[]),S=_.useCallback(q=>{if(v(N=>N.filter(Z=>Z.path!==q)),h===q){const N=y.filter(Z=>Z.path!==q);$(N.length>0?N[N.length-1].path:null)}},[y,h]),b=_.useCallback((q,N)=>{u(Z=>Z.find(V=>V.path===q)?Z.map(V=>V.path===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{path:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{path:q,pinned:!1}):[...Z,{path:q,pinned:!1}]),f(q),o(null)},[]),T=_.useCallback(q=>{o(q),q!==null&&f(null)},[]),w=_.useCallback(q=>{if(u(N=>N.filter(Z=>Z.path!==q)),s===q){const N=c.filter(Z=>Z.path!==q);f(N.length>0?N[N.length-1].path:null)}},[c,s]),P=(e==null?void 0:e.get("drift"))||null,[k,R]=_.useState(P),[E,C]=_.useState(()=>P?[{id:P,pinned:!0}]:[]),z=_.useCallback((q,N)=>{C(Z=>Z.find(V=>V.id===q)?Z.map(V=>V.id===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{id:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{id:q,pinned:!1}):[...Z,{id:q,pinned:!1}]),R(q)},[]),Y=_.useCallback(q=>{if(C(N=>N.filter(Z=>Z.id!==q)),k===q){const N=E.filter(Z=>Z.id!==q);R(N.length>0?N[N.length-1].id:null)}},[E,k]),W=_.useCallback(q=>{if(q===null){C([]),R(null);return}C(N=>N.filter(Z=>q.has(Z.id))),R(N=>N&&q.has(N)?N:null)},[]);_.useEffect(()=>{l((e==null?void 0:e.get("canonical"))??null),p((e==null?void 0:e.get("contract"))??null),R((e==null?void 0:e.get("drift"))??null)},[e]),_.useEffect(()=>{const q=new URLSearchParams(window.location.search).get("drift");if((k??"")===(q??""))return;const N=new URL(window.location.href);k?N.searchParams.set("drift",k):N.searchParams.delete("drift"),n(N.pathname+N.search)},[k,n]);const A=_.useMemo(()=>({activeSpecConflictId:a,setActiveSpecConflictId:o,handleSelectSpecConflict:T,activeCanonicalPath:s,setActiveCanonicalPath:f,openCanonicalFiles:c,handleOpenCanonical:b,handleCloseCanonical:w,activeContractsPath:h,setActiveContractsPath:$,openContractsFiles:y,handleOpenContracts:x,handleCloseContracts:S,activeDriftId:k,setActiveDriftId:R,openDriftTabs:E,handleOpenDrift:z,handleCloseDrift:Y,reconcileDriftTabs:W}),[a,T,s,c,b,w,h,y,x,S,k,E,z,Y,W]);return m.jsx(hie.Provider,{value:A,children:t})}function uSe(){const t=_.useContext(hie);if(!t)throw new Error("useDriftView must be used inside <DriftViewProvider>");return t}const pie=_.createContext(null);function OSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(()=>(e==null?void 0:e.get("view"))==="diff"),[a,o]=_.useState(null),[s,l]=_.useState(null),c=_.useCallback(f=>{i(f);const h=new URL(window.location.href);f?h.searchParams.set("view","diff"):h.searchParams.delete("view"),n(h.pathname+h.search)},[n]);_.useEffect(()=>{i((e==null?void 0:e.get("view"))==="diff")},[e]);const u=_.useMemo(()=>({isDiffMode:r,setIsDiffMode:c,selectedAnalysisId:a,setSelectedAnalysisId:o,selectedPath:s,setSelectedPath:l}),[r,c,a,s]);return m.jsx(pie.Provider,{value:u,children:t})}function fSe(){const t=_.useContext(pie);if(!t)throw new Error("useViewMode must be used inside <ViewModeProvider>");return t}const mie=_.createContext(null);function dSe({repoId:t,children:e}){const[n,r]=_.useState(null),[i,a]=_.useState(!0),[o,s]=_.useState(!1),[l,c]=_.useState(null),[u,f]=_.useState(null),[h,p]=_.useState(0);_.useEffect(()=>{let w=!1;return(async()=>{try{const P=await Q0e(t);!w&&P&&r(P)}catch(P){w||c(P.message)}finally{w||a(!1)}})(),()=>{w=!0}},[t]);const y=_.useCallback(async()=>{s(!0),c(null);try{const w=await O0e(t);r(w),p(P=>P+1)}catch(w){ah("Spec scan failed",w,c)}finally{s(!1)}},[t]),v=_.useCallback(async(w,P)=>{f(w.id);try{await S0e(t,{conflictId:w.id,resolution:P,candidateFingerprint:w.candidateFingerprint}),await y()}catch(k){ah("Saving decision failed",k,c)}finally{f(null)}},[t,y]),$=_.useCallback(async()=>{s(!0);try{await T0e(t,"all-defaults"),await y()}catch(w){ah("Accept all defaults failed",w,c)}finally{s(!1)}},[t,y]),x=_.useCallback(async w=>{f(w);try{await b0e(t,w),await y()}catch(P){ah("Revoking decision failed",P,c)}finally{f(null)}},[t,y]),S=_.useCallback(async(w,P,k)=>{s(!0);try{await P0e(t,{older:w,newer:P,note:k}),await y()}catch(R){ah("Marking supersession failed",R,c)}finally{s(!1)}},[t,y]),b=_.useCallback(async w=>{s(!0);try{await w0e(t,{path:w}),await y()}catch(P){ah("Including doc failed",P,c)}finally{s(!1)}},[t,y]),T=_.useMemo(()=>({scan:n,hydrating:i,loading:o,error:l,busyConflictId:u,canonicalVersion:h,refresh:y,resolveConflict:v,acceptAllDefaults:$,revokeDecision:x,markSuperseded:S,includeDoc:b}),[n,i,o,l,u,h,y,v,$,x,S,b]);return m.jsx(mie.Provider,{value:T,children:e})}function Mc(){const t=_.useContext(mie);if(!t)throw new Error("useSpec must be used inside <SpecProvider>");return t}function ah(t,e,n){const r=e instanceof Error?e.message:String(e);n(r),hc.error(t,{description:r})}function hSe(){const{scan:t,loading:e,refresh:n,acceptAllDefaults:r}=Mc(),i=((t==null?void 0:t.openConflicts.length)??0)>0,a=!t;return m.jsxs(m.Fragment,{children:[m.jsxs(xn,{size:"sm",variant:"outline",onClick:n,disabled:e,title:"Discover docs, extract claims, surface conflicts",children:[e?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(vS,{className:"mr-2 h-3.5 w-3.5"}),e?"Scanning...":"Scan"]}),m.jsxs(xn,{size:"sm",variant:"outline",onClick:r,disabled:a||!i||e,title:"Accept the engine's default pick on every open conflict (chains first, then content)",children:[m.jsx(Nne,{className:"mr-2 h-3.5 w-3.5"}),"Accept all defaults"]})]})}function pSe(){const{scan:t}=Mc(),e=t&&t.openConflicts.length===0?"Select a section from the canonical spec to view it.":"Select a conflict from the list to review its candidates, or pick a canonical section below.";return m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:e})})}function mSe({progress:t,onDismiss:e}){const n=t.step==="error";return m.jsxs("div",{className:`fixed bottom-4 left-1/2 z-40 w-80 -translate-x-1/2 rounded-lg border bg-card p-3 shadow-lg ${n?"border-destructive/50":"border-border"}`,children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:`text-[11px] font-medium ${n?"text-destructive":"text-foreground"}`,children:n?"Spec failed":"Running…"}),n&&m.jsx("button",{onClick:e,className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),n?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(i0,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.detail||"An error occurred"})]}):t.steps&&t.steps.length>0?m.jsx("div",{className:"space-y-1",children:t.steps.map(r=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 translate-y-px",children:[r.status==="done"&&m.jsx(Ff,{className:"h-3.5 w-3.5 text-emerald-500"}),r.status==="active"&&m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin text-primary"}),r.status==="error"&&m.jsx(i0,{className:"h-3.5 w-3.5 text-destructive"}),r.status==="pending"&&m.jsx("div",{className:"h-2.5 w-2.5 rounded-full border border-muted-foreground/30"})]}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsxs("span",{className:`text-[11px] leading-[18px] ${r.status==="active"?"font-medium text-foreground":r.status==="done"?"text-muted-foreground":r.status==="error"?"text-destructive":"text-muted-foreground/60"}`,children:[r.label,r.detail&&r.status!=="pending"&&m.jsx("span",{className:"ml-1.5 text-[10px] font-normal text-muted-foreground/70",children:r.detail})]})})]},r.key))}):m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(yn,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.detail||t.step})]})]})}function pl({icon:t,title:e,body:n}){return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[m.jsx(t,{className:"h-8 w-8 text-muted-foreground/60"}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-sm font-semibold text-foreground",children:e}),m.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})]})}function gSe({tree:t,isLoading:e,error:n,activePath:r,validationIssues:i,onOpen:a}){if(e&&!t)return m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})});if(n)return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-4 text-center text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-5 w-5 text-destructive"}),m.jsx("span",{children:n})]});if(!t||!t.hasContracts)return m.jsx(pl,{icon:xq,title:"No contracts yet",body:m.jsxs(m.Fragment,{children:["Resolve all open conflicts in ",m.jsx("strong",{children:"Spec"}),", click"," ",m.jsx("strong",{children:"Apply"}),", then click ",m.jsx("strong",{children:"Generate"})," here to extract TC contracts."]})});const o=i??[],s=o.filter(c=>c.severity==="hard"),l=o.filter(c=>c.severity==="soft");return m.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[o.length>0&&m.jsx($Se,{hardIssues:s,softIssues:l}),m.jsx("div",{className:"flex-1 overflow-auto",children:t.modules.map(c=>m.jsx(ySe,{label:c.name,files:c.files,activePath:r,onOpen:a},c.name))})]})}function ySe({label:t,files:e,activePath:n,onOpen:r}){const[i,a]=_.useState(!0),o=e.some(s=>s.path===n);return m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:`sticky top-0 z-10 flex w-full items-center justify-between gap-2 border-b border-border bg-card px-4 py-1.5 text-left text-[10px] uppercase tracking-wider hover:text-foreground ${o?"text-foreground":"text-muted-foreground"}`,"aria-expanded":i,children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[i?m.jsx(qa,{className:"h-3 w-3 shrink-0"}):m.jsx(Wc,{className:"h-3 w-3 shrink-0"}),m.jsx(Lh,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:"truncate",children:t})]}),m.jsx("span",{children:e.length})]}),i&&e.map(s=>{const l=s.path===n,c=s.path.replace(/^[^/]+\//,"");return m.jsxs("button",{type:"button",onClick:()=>r(s.path,!1),onDoubleClick:()=>r(s.path,!0),className:`flex w-full items-center gap-2 border-b border-border/60 px-4 py-2 pl-9 text-left text-[13px] transition-colors ${l?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-muted/40 hover:text-foreground"}`,title:`${s.path} — click to preview, double-click to pin`,children:[m.jsx(xq,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:"truncate",children:c})]},s.path)})]})}function $Se({hardIssues:t,softIssues:e}){const[n,r]=_.useState(!0),i=t.length+e.length,a=t.length>0,o=a?"text-red-400":"text-amber-400",s=a?"border-red-500/30":"border-amber-500/30",l=a?"bg-red-500/5":"bg-amber-500/5";return m.jsxs("div",{className:`shrink-0 border-b ${s} ${l}`,children:[m.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:`flex w-full items-center justify-between px-4 py-1.5 text-[10px] uppercase tracking-wider ${o} hover:opacity-80`,"aria-expanded":n,children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[n?m.jsx(qa,{className:"h-3 w-3"}):m.jsx(Wc,{className:"h-3 w-3"}),m.jsx("span",{children:"Validation issues"})]}),m.jsx("span",{children:i})]}),n&&m.jsxs("ul",{className:"max-h-72 overflow-auto px-2 pb-2",children:[t.map((c,u)=>m.jsx(L8,{issue:c},`hard-${c.artifactKey}-${u}`)),e.map((c,u)=>m.jsx(L8,{issue:c},`soft-${c.artifactKey}-${u}`))]})]})}function L8({issue:t}){const[e,n]=_.useState(!1),r=t.severity==="hard"?"border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300":"border-amber-500/30 bg-amber-500/5 text-amber-800 dark:text-amber-200";return m.jsx("li",{className:`mt-1.5 rounded border ${r} px-2 py-1.5`,children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("span",{className:`mt-0.5 shrink-0 rounded px-1 py-0.5 text-[9px] uppercase tracking-wider ${t.severity==="hard"?"bg-red-500/20 text-red-700 dark:text-red-300":"bg-amber-500/20 text-amber-800 dark:text-amber-200"}`,children:t.severity}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"truncate font-mono text-[11px] text-foreground",children:t.artifactKey}),t.tcSource&&m.jsx("button",{type:"button",onClick:()=>n(i=>!i),className:"shrink-0 text-[10px] text-muted-foreground hover:text-foreground",children:e?"hide":"source"})]}),m.jsx("div",{className:"mt-0.5 break-words text-[11px]",children:t.message}),e&&t.tcSource&&m.jsx("pre",{className:"mt-1 max-h-40 overflow-auto rounded bg-muted/40 p-2 font-mono text-[10px] text-muted-foreground",children:t.tcSource})]})]})})}let tz=[],gie=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?gie:tz).push(n=n+t[e])})();function vSe(t){if(t<768)return!1;for(let e=0,n=tz.length;;){let r=e+n>>1;if(t<tz[r])n=r;else if(t>=gie[r])e=r+1;else return!0;if(e==n)return!1}}function G8(t){return t>=127462&&t<=127487}const B8=8205;function xSe(t,e,n=!0,r=!0){return(n?yie:QSe)(t,e,r)}function yie(t,e,n){if(e==t.length)return e;e&&$ie(t.charCodeAt(e))&&vie(t.charCodeAt(e-1))&&e--;let r=bk(t,e);for(e+=F8(r);e<t.length;){let i=bk(t,e);if(r==B8||i==B8||n&&vSe(i))e+=F8(i),r=i;else if(G8(i)){let a=0,o=e-2;for(;o>=0&&G8(bk(t,o));)a++,o-=2;if(a%2==0)break;e+=2}else break}return e}function QSe(t,e,n){for(;e>0;){let r=yie(t,e-2,n);if(r<e)return r;e--}return 0}function bk(t,e){let n=t.charCodeAt(e);if(!vie(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return $ie(r)?(n-55296<<10)+(r-56320)+65536:n}function $ie(t){return t>=56320&&t<57344}function vie(t){return t>=55296&&t<56320}function F8(t){return t<65536?1:2}let qn=class xie{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=ip(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),rl.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=ip(this,e,n);let r=[];return this.decompose(e,n,r,0),rl.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new fy(this),a=new fy(e);for(let o=n,s=n;;){if(i.next(o),a.next(o),o=0,i.lineBreak!=a.lineBreak||i.done!=a.done||i.value!=a.value)return!1;if(s+=i.value.length,i.done||s>=r)return!0}}iter(e=1){return new fy(this,e)}iterRange(e,n=this.length){return new Qie(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new bie(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?xie.empty:e.length<=32?new Lr(e):rl.from(Lr.split(e,[]))}};class Lr extends qn{constructor(e,n=bSe(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let a=0;;a++){let o=this.text[a],s=i+o.length;if((n?r:s)>=e)return new SSe(i,s,r,o);i=s+1,r++}}decompose(e,n,r,i){let a=e<=0&&n>=this.length?this:new Lr(H8(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),s=_b(a.text,o.text.slice(),0,a.length);if(s.length<=32)r.push(new Lr(s,o.length+a.length));else{let l=s.length>>1;r.push(new Lr(s.slice(0,l)),new Lr(s.slice(l)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Lr))return super.replace(e,n,r);[e,n]=ip(this,e,n);let i=_b(this.text,_b(r.text,H8(this.text,0,e)),n),a=this.length+r.length-(n-e);return i.length<=32?new Lr(i,a):rl.from(Lr.split(i,[]),a)}sliceString(e,n=this.length,r=`
|
|
538
|
+
*/var b1e=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],$0=b1e.join(","),Hre=typeof Element>"u",rp=Hre?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,v0=!Hre&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},x0=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",o=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):x0(e.parentNode));return o},S1e=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},Kre=function(e,n,r){if(x0(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll($0));return n&&rp.call(e,$0)&&i.unshift(e),i=i.filter(r),i},Q0=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var o=a.shift();if(!x0(o,!1))if(o.tagName==="SLOT"){var s=o.assignedElements(),l=s.length?s:o.children,c=Q0(l,!0,r);r.flatten?i.push.apply(i,c):i.push({scopeParent:o,candidates:c})}else{var u=rp.call(o,$0);u&&r.filter(o)&&(n||!e.includes(o))&&i.push(o);var f=o.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(o),h=!x0(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(o));if(f&&h){var p=Q0(f===!0?o.children:f.children,!0,r);r.flatten?i.push.apply(i,p):i.push({scopeParent:o,candidates:p})}else a.unshift.apply(a,o.children)}}return i},Jre=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},eie=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||S1e(e))&&!Jre(e)?0:e.tabIndex},w1e=function(e,n){var r=eie(e);return r<0&&n&&!Jre(e)?0:r},P1e=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},tie=function(e){return e.tagName==="INPUT"},T1e=function(e){return tie(e)&&e.type==="hidden"},k1e=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},_1e=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},X1e=function(e){if(!e.name)return!0;var n=e.form||v0(e),r=function(s){return n.querySelectorAll('input[type="radio"][name="'+s+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(o){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",o.message),!1}var a=_1e(i,e.form);return!a||a===e},R1e=function(e){return tie(e)&&e.type==="radio"},j1e=function(e){return R1e(e)&&!X1e(e)},E1e=function(e){var n,r=e&&v0(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var o,s,l;for(a=!!((o=i)!==null&&o!==void 0&&(s=o.ownerDocument)!==null&&s!==void 0&&s.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var c,u,f;r=v0(i),i=(c=r)===null||c===void 0?void 0:c.host,a=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i))}}return a},V8=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},C1e=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var o=rp.call(e,"details>summary:first-of-type"),s=o?e.parentElement:e;if(rp.call(s,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var c=e.parentElement,u=v0(e);if(c&&!c.shadowRoot&&i(c)===!0)return V8(e);e.assignedSlot?e=e.assignedSlot:!c&&u!==e.ownerDocument?e=u.host:e=c}e=l}if(E1e(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return V8(e);return!1},z1e=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return rp.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},KC=function(e,n){return!(n.disabled||T1e(n)||C1e(n,e)||k1e(n)||z1e(n))},JC=function(e,n){return!(j1e(n)||eie(n)<0||!KC(e,n))},Y1e=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},nie=function(e){var n=[],r=[];return e.forEach(function(i,a){var o=!!i.scopeParent,s=o?i.scopeParent:i,l=w1e(s,o),c=o?nie(i.candidates):s;l===0?o?n.push.apply(n,c):n.push(s):r.push({documentOrder:a,tabIndex:l,item:i,isScope:o,content:c})}),r.sort(P1e).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},kS=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Q0([e],n.includeContainer,{filter:JC.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:Y1e}):r=Kre(e,n.includeContainer,JC.bind(null,n)),nie(r)},A1e=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Q0([e],n.includeContainer,{filter:KC.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=Kre(e,n.includeContainer,KC.bind(null,n)),r},rie=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return rp.call(e,$0)===!1?!1:JC(n,e)};const dv=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function iie(t,e){const n=kS(t,dv()),r=n.length;if(r===0)return;const i=Js(dr(t)),a=n.indexOf(i),o=a===-1?e===1?0:r-1:a+e;return n[o]}function aie(t){return iie(dr(t).body,1)||t}function oie(t){return iie(dr(t).body,-1)||t}function cy(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!ln(n,r)}function q1e(t){kS(t,dv()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function U8(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const fQ=null;class Z1e{constructor(){Wn(this,"callbacks",[]);Wn(this,"callbacksCount",0);Wn(this,"nextId",1);Wn(this,"startId",1);Wn(this,"isScheduled",!1);Wn(this,"tick",e=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let a=0;a<n.length;a+=1)(i=n[a])==null||i.call(n,e)})}request(e){const n=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(e){const n=e-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const dQ=new Z1e;class el{constructor(){Wn(this,"currentId",fQ);Wn(this,"cancel",()=>{this.currentId!==fQ&&(dQ.cancel(this.currentId),this.currentId=fQ)});Wn(this,"disposeEffect",()=>this.cancel)}static create(){return new el}static request(e){return dQ.request(e)}static cancel(e){return dQ.cancel(e)}request(e){this.cancel(),this.currentId=dQ.request(()=>{this.currentId=fQ,e()})}}function Wq(){const t=yo(el.create).current;return Zq(t.disposeEffect),t}function sc(t){return t==null?t:"current"in t?t.current:t}let Ny=(function(t){return t.startingStyle="data-starting-style",t.endingStyle="data-ending-style",t})({});const V1e={[Ny.startingStyle]:""},U1e={[Ny.endingStyle]:""},Mq={transitionStatus(t){return t==="starting"?V1e:t==="ending"?U1e:null}};function N1e(t,e=!1,n=!0){const r=Wq();return tn((i,a=null)=>{r.cancel();function o(){Pl.flushSync(i)}const s=sc(t);if(s==null)return;const l=s;if(typeof l.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let f=function(){const p=Ny.startingStyle;if(!l.hasAttribute(p)){r.request(h);return}const y=new MutationObserver(()=>{l.hasAttribute(p)||(y.disconnect(),h())});y.observe(l,{attributes:!0,attributeFilter:[p]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},h=function(){Promise.all(l.getAnimations().map(p=>p.finished)).then(()=>{a!=null&&a.aborted||o()}).catch(()=>{const p=l.getAnimations();if(n){if(a!=null&&a.aborted)return;o()}else p.length>0&&p.some(y=>y.pending||y.playState!=="finished")&&h()})};var c=f,u=h;if(e){f();return}r.request(h)}})}function Iq(t){const{enabled:e=!0,open:n,ref:r,onComplete:i}=t,a=tn(i),o=N1e(r,n,!1);_.useEffect(()=>{if(!e)return;const s=new AbortController;return o(a,s.signal),()=>{s.abort()}},[e,n,a,o])}function W1e(t,e=!1,n=!1){const[r,i]=_.useState(t&&e?"idle":void 0),[a,o]=_.useState(t);return t&&!a&&(o(!0),i("starting")),!t&&a&&r!=="ending"&&!n&&i("ending"),!t&&!a&&r==="ending"&&i(void 0),qt(()=>{if(!t&&a&&r!=="ending"&&n){const s=el.request(()=>{i("ending")});return()=>{el.cancel(s)}}},[t,a,r,n]),qt(()=>{if(!t||e)return;const s=el.request(()=>{i(void 0)});return()=>{el.cancel(s)}},[e,t]),qt(()=>{if(!t||!e)return;t&&a&&r!=="idle"&&i("starting");const s=el.request(()=>{i("idle")});return()=>{el.cancel(s)}},[e,t,a,i,r]),_.useMemo(()=>({mounted:a,setMounted:o,transitionStatus:r}),[a,r])}function M1e({controlled:t,default:e,name:n,state:r="value"}){const{current:i}=_.useRef(t!==void 0),[a,o]=_.useState(e),s=i?t:a,l=_.useCallback(c=>{i||o(c)},[]);return[s,l]}function I1e(t={}){const{id:e,implicit:n=!1,controlRef:r}=t,{controlId:i,registerControlId:a}=Zre(),o=fv(e),s=n?i:void 0,l=yo(()=>Symbol("labelable-control")),c=_.useRef(!1),u=_.useRef(e!=null),f=tn(()=>{!c.current||a===Ra||(c.current=!1,a(l.current,void 0))});return qt(()=>{if(a===Ra)return;let h;if(n){const p=r==null?void 0:r.current;jn(p)&&p.closest("label")!=null?h=e??null:h=s??o}else if(e!=null)u.current=!0,h=e;else if(u.current)h=o;else{f();return}if(h===void 0){f();return}c.current=!0,a(l.current,h)},[e,r,s,a,n,o,l,f]),_.useEffect(()=>f,[f]),i??o}function D1e(t){const{enabled:e=!0,value:n,id:r,name:i,controlRef:a,commit:o}=t,{formRef:s}=K0e(),{invalid:l,markedDirtyRef:c,validityData:u,setValidityData:f}=qre(),h=tn(t.getValue);qt(()=>{if(!e)return;let p=n;p===void 0&&(p=h()),u.initialValue===null&&p!==null&&f(y=>({...y,initialValue:p}))},[e,f,n,u.initialValue,h]),qt(()=>{!e||!r||s.current.fields.set(r,{getValue:h,name:i,controlRef:a,validityData:n1e(u,l),validate(p=!0){let y=n;y===void 0&&(y=h()),c.current=!0,p?Pl.flushSync(()=>o(y)):o(y)}})},[o,a,e,s,h,r,l,c,i,u,n]),qt(()=>{const p=s.current.fields;return()=>{r&&p.delete(r)}},[s,r])}const Dq="none",Wy="trigger-press",us="trigger-hover",kb="trigger-focus",sie="outside-press",L1e="close-press",lie="focus-out",Lq="escape-key",G1e="disabled",cie="imperative-action";function or(t,e,n,r){let i=!1,a=!1;const o=Ii;return{reason:t,event:e??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}const B1e=_.forwardRef(function(e,n){const{render:r,className:i,id:a,name:o,value:s,disabled:l=!1,onValueChange:c,defaultValue:u,autoFocus:f=!1,...h}=e,{state:p,name:y,disabled:v,setTouched:$,setDirty:x,validityData:S,setFocused:b,setFilled:T,validationMode:w,validation:P}=qre(),k=v||l,R=y??o,E={...p,disabled:k},{labelId:C}=Zre(),z=I1e({id:a});qt(()=>{var D;const Z=s!=null;(D=P.inputRef.current)!=null&&D.value||Z&&s!==""?T(!0):Z&&s===""&&T(!1)},[P.inputRef,T,s]);const Y=_.useRef(null);qt(()=>{f&&Y.current===Js(dr(Y.current))&&b(!0)},[f,b]);const[W]=M1e({controlled:s,default:u,name:"FieldControl",state:"value"}),A=s!==void 0,q=A?W:void 0;return D1e({id:z,name:R,commit:P.commit,value:q,getValue:()=>{var Z;return(Z=P.inputRef.current)==null?void 0:Z.value},controlRef:P.inputRef}),ha("input",e,{ref:[n,Y],state:E,props:[{id:z,disabled:k,name:R,ref:P.inputRef,"aria-labelledby":C,autoFocus:f,...A?{value:q}:{defaultValue:u},onChange(Z){const D=Z.currentTarget.value;c==null||c(D,or(Dq,Z.nativeEvent)),x(D!==S.initialValue),T(D!=="")},onFocus(){b(!0)},onBlur(Z){$(!0),b(!1),w==="onBlur"&&P.commit(Z.currentTarget.value)},onKeyDown(Z){Z.currentTarget.tagName==="INPUT"&&Z.key==="Enter"&&($(!0),P.commit(Z.currentTarget.value))}},P.getInputValidationProps(),h],stateAttributesMapping:B0e})}),F1e=_.forwardRef(function(e,n){return m.jsx(B1e,{ref:n,...e})});function H1e({className:t,type:e,...n}){return m.jsx(F1e,{type:e,"data-slot":"input",className:jr("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),...n})}function K1e({onAdd:t}){const[e,n]=_.useState(""),[r,i]=_.useState(!1),a=async o=>{if(o.preventDefault(),!!e.trim()){i(!0);try{await t(e.trim()),n("")}catch{}finally{i(!1)}}};return m.jsx("form",{onSubmit:a,className:"w-full",children:m.jsxs("div",{className:"flex gap-2",children:[m.jsxs("div",{className:"relative flex-1",children:[m.jsx(zve,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),m.jsx(H1e,{type:"text",value:e,onChange:o=>n(o.target.value),placeholder:"Paste repository path...",className:"pl-10"})]}),m.jsxs(xn,{type:"submit",disabled:r||!e.trim(),children:[r?m.jsx(yn,{className:"h-4 w-4 animate-spin"}):m.jsx(Yne,{className:"h-4 w-4"}),"Add Repository"]})]})})}function J1e({repos:t,onDelete:e}){const n=(r,i)=>{r.preventDefault(),r.stopPropagation();const a=i.lastAnalyzed?`Delete "${i.name}"? This will remove all analyses, violations, and chat history.`:`Delete "${i.name}"?`;confirm(a)&&e(i.id)};return t.length===0?m.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border py-16",children:[m.jsx(Lh,{className:"mb-4 h-12 w-12 text-muted-foreground"}),m.jsx("p",{className:"text-lg font-medium text-foreground",children:"No repositories yet"}),m.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add a repository path above to get started"})]}):m.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:t.map(r=>m.jsxs(Dh,{to:`/repos/${r.id}`,className:"group relative flex flex-col rounded-xl border border-border bg-card p-4 ring-1 ring-foreground/10 transition-all hover:shadow-md hover:ring-primary/30",children:[m.jsx("button",{onClick:i=>n(i,r),className:"absolute right-3 top-3 rounded-md p-1 text-muted-foreground/50 opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100","aria-label":"Delete repository",children:m.jsx(Pq,{className:"h-3.5 w-3.5"})}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-lg bg-primary/10",children:m.jsx(Lh,{className:"h-5 w-5 text-primary"})}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:r.name}),m.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:r.path})]})]}),m.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[r.lastAnalyzed?m.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[m.jsx(gS,{className:"h-3 w-3"}),m.jsxs("span",{children:["Analyzed"," ",new Date(r.lastAnalyzed).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}):m.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"Not analyzed yet"}),m.jsx(Qve,{className:"h-3.5 w-3.5 text-muted-foreground/50 transition-transform group-hover:translate-x-0.5 group-hover:text-primary"})]})]},r.id))})}function eSe(){const[t,e]=_.useState([]),[n,r]=_.useState(!0),[i,a]=_.useState(null),o=_.useCallback(async()=>{r(!0),a(null);try{const u=await Nbe();e(u)}catch(u){a(u instanceof Error?u.message:"Failed to fetch repos")}finally{r(!1)}},[]);_.useEffect(()=>{o()},[o]);const s=_.useCallback(async u=>{try{const f=await Wbe(u);return e(h=>[...h,f]),f}catch(f){const h=f instanceof Error?f.message:"Failed to add repo";throw a(h),f}},[]),l=_.useCallback(async u=>{try{await Mbe(u),e(f=>f.filter(h=>h.id!==u))}catch(f){const h=f instanceof Error?f.message:"Failed to delete repo";throw a(h),f}},[]),c=_.useCallback(async(u,f)=>{try{return await vre(u,f)}catch(h){const p=h instanceof Error?h.message:"Failed to start analysis";throw a(p),h}},[]);return{repos:t,isLoading:n,error:i,addRepo:s,deleteRepo:l,analyzeRepo:c,refetch:o}}const tSe=Eq("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function uy({className:t,variant:e,...n}){return m.jsx("div",{"data-slot":"alert",role:"alert",className:jr(tSe({variant:e}),t),...n})}function N8({className:t,...e}){return m.jsx("div",{"data-slot":"alert-title",className:jr("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",t),...e})}function Oy({className:t,...e}){return m.jsx("div",{"data-slot":"alert-description",className:jr("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",t),...e})}function nSe(){const{repos:t,isLoading:e,error:n,addRepo:r,deleteRepo:i}=eSe(),a=async o=>{try{await i(o)}catch{}};return m.jsxs("div",{className:"flex min-h-screen flex-col",children:[m.jsx(qq,{}),m.jsxs("main",{className:"mx-auto w-full max-w-5xl flex-1 px-4 py-8",children:[m.jsxs("div",{className:"mb-8 text-center",children:[m.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"TrueCourse"}),m.jsx("p",{className:"mt-2 text-muted-foreground",children:"Visualize and understand your codebase architecture"})]}),m.jsxs("div",{className:"mb-8 space-y-5",children:[m.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-lg border border-border bg-card p-6",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this from your project directory:"}),m.jsx("code",{className:"rounded-md bg-muted px-4 py-2.5 font-mono text-sm text-foreground select-all",children:"npx truecourse add"})]}),m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"h-px flex-1 bg-border"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"or add manually"}),m.jsx("div",{className:"h-px flex-1 bg-border"})]}),m.jsx(K1e,{onAdd:r})]}),n&&m.jsx(uy,{variant:"destructive",className:"mb-6",children:m.jsx(Oy,{children:n})}),e?m.jsx("div",{className:"flex items-center justify-center py-16",children:m.jsx(yn,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m.jsx(J1e,{repos:t,onDelete:a})]})]})}function rSe({section:t,activeTab:e,onTabChange:n,children:r,defaultWidth:i=350,minWidth:a=260,badgeCounts:o,tabWarnings:s}){var S;const[l,c]=_.useState(i),[u,f]=_.useState(800),h=_.useRef(!1),p=Y0e(t),y=_.useMemo(()=>new Set(p.filter(b=>b.noPanel).map(b=>b.id)),[p]);_.useEffect(()=>{const b=()=>Math.floor(window.innerWidth*.8);f(b());const T=()=>f(b());return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]);const v=_.useCallback(b=>{b.preventDefault(),h.current=!0;const T=b.clientX,w=l,P=R=>{if(!h.current)return;const E=R.clientX-T;c(Math.min(u,Math.max(a,w+E)))},k=()=>{h.current=!1,document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",k)},[l,a,u]),$=e!==null&&!y.has(e),x=e?((S=j0e(e))==null?void 0:S.label)??"":"";return m.jsxs("div",{className:"flex flex-shrink-0 h-full",children:[m.jsx("div",{className:"flex w-12 flex-col items-center gap-1 border-r border-border bg-card pt-2",children:p.map(b=>{const T=b.icon,w=e===b.id;return m.jsxs("button",{onClick:()=>n(w?null:b.id),className:`group relative flex h-10 w-10 items-center justify-center rounded-md transition-colors ${w?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"}`,"aria-label":b.label,children:[w&&m.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-0.5 rounded-r bg-primary"}),m.jsx(T,{className:"h-5 w-5"}),m.jsx("span",{className:"pointer-events-none absolute left-full ml-2 whitespace-nowrap rounded bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md border border-border opacity-0 group-hover:opacity-100 transition-opacity z-50",children:b.label}),(()=>{const P=o==null?void 0:o[b.id];return P==null?null:typeof P=="number"?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-[9px] font-bold text-primary-foreground",children:P}):null:P.newCount+P.resolvedCount>0?m.jsxs("span",{className:"absolute -right-1 -top-1 flex items-center gap-px rounded-full bg-card border border-border px-1 py-px",children:[P.newCount>0&&m.jsxs("span",{className:"text-[8px] font-bold text-red-400",children:["+",P.newCount]}),P.resolvedCount>0&&m.jsxs("span",{className:"text-[8px] font-bold text-emerald-400",children:["-",P.resolvedCount]})]}):null})()]},b.id)})}),$&&m.jsxs("aside",{className:"relative flex-shrink-0 border-r border-border bg-card",style:{width:l},children:[m.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-border px-3",children:[m.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:x}),(()=>{const b=e?s==null?void 0:s[e]:void 0;return b?m.jsx(tm,{align:"start",width:"wide",content:b,children:m.jsx("span",{className:"flex items-center text-amber-400",children:m.jsx(zi,{className:"h-3.5 w-3.5"})})}):null})(),(()=>{const b=e?o==null?void 0:o[e]:void 0;return b==null?null:typeof b=="number"?b>0?m.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:b}):null:b.newCount+b.resolvedCount>0?m.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium",children:[b.newCount>0&&m.jsxs("span",{className:"text-red-400",children:["+",b.newCount," new"]}),b.resolvedCount>0&&m.jsxs("span",{className:"text-emerald-400",children:["-",b.resolvedCount," resolved"]})]}):null})()]}),m.jsx("div",{className:"h-[calc(100%-40px)] overflow-hidden",children:r}),m.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:v})]})]})}const W8=["tab","mode","scopeService","scopeModule","file","flow","canonical","contract","drift"];function ez(t){return(t==null?void 0:t.get("section"))==="drift"?"drift":"analysis"}function M8(t){const e=(t==null?void 0:t.get("tab"))??null;return e==="violations"?"graphs":e==="analytics"?"home":e&&E0e().has(e)?e:t!=null&&t.get("flow")?"flows":t!=null&&t.get("file")?"files":t!=null&&t.get("canonical")?"spec":t!=null&&t.get("contract")?"contracts":t!=null&&t.get("drift")?"verify":DC(ez(t))}const uie=_.createContext(null);function iSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(()=>ez(e)),[a,o]=_.useState(()=>M8(e)),s=_.useCallback(u=>{i(u);const f=DC(u);o(f);const h=new URL(window.location.href);u==="drift"?h.searchParams.set("section","drift"):h.searchParams.delete("section");for(const p of W8)h.searchParams.delete(p);h.searchParams.delete("view"),f!=="home"&&h.searchParams.set("tab",f),n(h.pathname+h.search)},[n]),l=_.useCallback(u=>{o(u);const f=new URL(window.location.href);if(u&&u!=="home")f.searchParams.set("tab",u);else for(const h of W8)f.searchParams.delete(h);n(f.pathname+f.search)},[n]);_.useEffect(()=>{const u=ez(e),f=M8(e),p=C0e(f)===u?f:DC(u);i(u),o(p)},[e]);const c=_.useMemo(()=>({section:r,leftTab:a,setSection:s,setLeftTab:l}),[r,a,s,l]);return m.jsx(uie.Provider,{value:c,children:t})}function Oie(){const t=_.useContext(uie);if(!t)throw new Error("useNavigation must be used inside <NavigationProvider>");return t}const I8={services:"services",modules:"modules",functions:"methods"},D8={services:"services",modules:"modules",methods:"functions"},fie=_.createContext(null);function aSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(null),[a,o]=_.useState(()=>I8[(e==null?void 0:e.get("mode"))||""]||"services"),[s,l]=_.useState(()=>(e==null?void 0:e.get("scopeService"))||null),[c,u]=_.useState(()=>(e==null?void 0:e.get("scopeModule"))||null),[f,h]=_.useState(null),p=_.useCallback(S=>{l(S);const b=new URL(window.location.href);S?b.searchParams.set("scopeService",S):b.searchParams.delete("scopeService"),n(b.pathname+b.search)},[n]),y=_.useCallback(S=>{u(S);const b=new URL(window.location.href);S?b.searchParams.set("scopeModule",S):b.searchParams.delete("scopeModule"),n(b.pathname+b.search)},[n]),v=_.useCallback(S=>{o(S);const b=new URL(window.location.href);S==="services"?(b.searchParams.delete("mode"),b.searchParams.delete("scopeService"),b.searchParams.delete("scopeModule")):S==="modules"?(b.searchParams.set("mode","modules"),b.searchParams.delete("scopeModule"),s&&b.searchParams.set("scopeService",s)):(b.searchParams.set("mode",D8[S]),s&&b.searchParams.set("scopeService",s),c&&b.searchParams.set("scopeModule",c)),n(b.pathname+b.search)},[n,s,c]),$=_.useCallback((S,b,T)=>{const w=b??a;let P=s,k=c;w==="services"?(P=null,k=null):w==="modules"?((T==null?void 0:T.serviceId)!==void 0&&(P=T.serviceId??null),k=null):((T==null?void 0:T.serviceId)!==void 0&&(P=T.serviceId??null),(T==null?void 0:T.moduleId)!==void 0&&(k=T.moduleId??null)),o(w),l(P),u(k);const R=new URL(window.location.href);w==="services"?R.searchParams.delete("mode"):R.searchParams.set("mode",D8[w]),P?R.searchParams.set("scopeService",P):R.searchParams.delete("scopeService"),k?R.searchParams.set("scopeModule",k):R.searchParams.delete("scopeModule"),n(R.pathname+R.search),b&&b!==a?setTimeout(()=>h({nodeId:S,key:Date.now()}),500):h({nodeId:S,key:Date.now()})},[a,s,c,n]);_.useEffect(()=>{o(I8[(e==null?void 0:e.get("mode"))??""]??"services"),l((e==null?void 0:e.get("scopeService"))??null),u((e==null?void 0:e.get("scopeModule"))??null)},[e]);const x=_.useMemo(()=>({selectedService:r,setSelectedService:i,depthLevel:a,setDepthLevel:v,scopedServiceId:s,setScopedServiceId:p,scopedModuleId:c,setScopedModuleId:y,focusRequest:f,setFocusRequest:h,locateNode:$}),[r,a,v,s,p,c,y,f,$]);return m.jsx(fie.Provider,{value:x,children:t})}function oSe(){const t=_.useContext(fie);if(!t)throw new Error("useGraphView must be used inside <GraphViewProvider>");return t}const die=_.createContext(null);function sSe({children:t}){const[e]=uv(),n=uO(),{setLeftTab:r}=Oie(),i=(e==null?void 0:e.get("file"))||null,[a,o]=_.useState(()=>i?[{path:i,pinned:!0}]:[]),[s,l]=_.useState(i),c=_.useCallback(M=>{l(M);const V=new URL(window.location.href);M?V.searchParams.set("file",M):V.searchParams.delete("file"),n(V.pathname+V.search)},[n]),u=_.useCallback((M,V,I)=>{o(B=>B.find(K=>K.path===M)?B.map(K=>K.path===M?{...K,pinned:V||K.pinned,scrollToLine:I??K.scrollToLine}:K):V?[...B,{path:M,pinned:!0,scrollToLine:I}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{path:M,pinned:!1,scrollToLine:I}):[...B,{path:M,pinned:!1,scrollToLine:I}]),c(M),r("files")},[c,r]),f=_.useCallback(M=>{if(o(V=>V.filter(I=>I.path!==M)),s===M){const V=a.filter(I=>I.path!==M);c(V.length>0?V[V.length-1].path:null)}},[a,s,c]),h=(e==null?void 0:e.get("flow"))||null,[p,y]=_.useState(()=>h?[{id:h,name:"Flow",pinned:!0}]:[]),[v,$]=_.useState(h),x=_.useCallback(M=>{$(M);const V=new URL(window.location.href);M?(V.searchParams.set("flow",M),V.searchParams.delete("file")):V.searchParams.delete("flow"),n(V.pathname+V.search)},[n]),S=_.useCallback(M=>{if(y(V=>V.filter(I=>I.id!==M)),v===M){const V=p.filter(I=>I.id!==M);x(V.length>0?V[V.length-1].id:null)}},[p,v,x]),b=_.useCallback(M=>{M.length!==0&&y(V=>V.map(I=>{const B=M.find(L=>L.id===I.id);return B?{...I,name:B.name}:I}))},[]),[T,w]=_.useState([]),[P,k]=_.useState(null),R=_.useCallback(M=>{k(M)},[]),E=_.useCallback(M=>{if(w(V=>V.filter(I=>I.id!==M)),P===M){const V=T.filter(I=>I.id!==M);R(V.length>0?V[V.length-1].id:null)}},[T,P,R]),C=_.useCallback(()=>{c(null),x(null),R(null)},[c,x,R]),z=_.useCallback(M=>{c(M),x(null),R(null),M!==null&&r("files")},[c,x,R,r]),Y=_.useCallback(M=>{z(M)},[z]),W=_.useCallback(M=>{x(M),c(null),R(null),M!==null&&r("flows")},[x,c,R,r]),A=_.useCallback(M=>{R(M),c(null),x(null),M!==null&&r("databases")},[R,c,x,r]),q=_.useCallback((M,V,I)=>{y(B=>B.find(K=>K.id===M)?B.map(K=>K.id===M?{...K,name:V,pinned:I||K.pinned}:K):I?[...B,{id:M,name:V,pinned:!0}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{id:M,name:V,pinned:!1}):[...B,{id:M,name:V,pinned:!1}]),W(M)},[W]),N=_.useCallback((M,V,I)=>{w(B=>B.find(K=>K.id===M)?B.map(K=>K.id===M?{...K,pinned:I||K.pinned}:K):I?[...B,{id:M,name:V,pinned:!0}]:B.find(K=>!K.pinned)?B.map(K=>K.pinned?K:{id:M,name:V,pinned:!1}):[...B,{id:M,name:V,pinned:!1}]),A(M)},[A]),Z=_.useCallback(M=>{const V=M??"home";r(V),V==="flows"&&v===null&&p.length>0?x(p[p.length-1].id):V==="files"&&s===null&&a.length>0?c(a[a.length-1].path):V==="databases"&&P===null&&T.length>0&&R(T[T.length-1].id)},[r,v,p,x,s,a,c,P,T,R]);_.useEffect(()=>{l((e==null?void 0:e.get("file"))??null),$((e==null?void 0:e.get("flow"))??null)},[e]);const D=_.useMemo(()=>({openFiles:a,activeFilePath:s,setActiveFilePath:c,handleOpenFile:u,handleCloseFile:f,openFlows:p,activeFlowId:v,setActiveFlowId:x,handleOpenFlow:q,handleCloseFlow:S,syncFlowNames:b,openDatabases:T,activeDbId:P,setActiveDbId:R,handleOpenDatabase:N,handleCloseDatabase:E,clearActiveDetailView:C,showFileView:z,handleSelectTab:Y,showFlowView:W,showDatabaseView:A,handleLeftTabChange:Z}),[a,s,c,u,f,p,v,x,q,S,b,T,P,R,N,E,C,z,Y,W,A,Z]);return m.jsx(die.Provider,{value:D,children:t})}function lSe(){const t=_.useContext(die);if(!t)throw new Error("useOpenTabs must be used inside <OpenTabsProvider>");return t}const hie=_.createContext(null);function cSe({children:t}){const[e]=uv(),n=uO(),r=(e==null?void 0:e.get("canonical"))||null,i=(e==null?void 0:e.get("contract"))||null,[a,o]=_.useState(null),[s,l]=_.useState(r),[c,u]=_.useState(()=>r?[{path:r,pinned:!0}]:[]),f=_.useCallback(q=>{l(q);const N=new URL(window.location.href);q?N.searchParams.set("canonical",q):N.searchParams.delete("canonical"),n(N.pathname+N.search)},[n]),[h,p]=_.useState(i),[y,v]=_.useState(()=>i?[{path:i,pinned:!0}]:[]),$=_.useCallback(q=>{p(q);const N=new URL(window.location.href);q?N.searchParams.set("contract",q):N.searchParams.delete("contract"),n(N.pathname+N.search)},[n]),x=_.useCallback((q,N)=>{v(Z=>Z.find(V=>V.path===q)?Z.map(V=>V.path===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{path:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{path:q,pinned:!1}):[...Z,{path:q,pinned:!1}]),$(q)},[]),S=_.useCallback(q=>{if(v(N=>N.filter(Z=>Z.path!==q)),h===q){const N=y.filter(Z=>Z.path!==q);$(N.length>0?N[N.length-1].path:null)}},[y,h]),b=_.useCallback((q,N)=>{u(Z=>Z.find(V=>V.path===q)?Z.map(V=>V.path===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{path:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{path:q,pinned:!1}):[...Z,{path:q,pinned:!1}]),f(q),o(null)},[]),T=_.useCallback(q=>{o(q),q!==null&&f(null)},[]),w=_.useCallback(q=>{if(u(N=>N.filter(Z=>Z.path!==q)),s===q){const N=c.filter(Z=>Z.path!==q);f(N.length>0?N[N.length-1].path:null)}},[c,s]),P=(e==null?void 0:e.get("drift"))||null,[k,R]=_.useState(P),[E,C]=_.useState(()=>P?[{id:P,pinned:!0}]:[]),z=_.useCallback((q,N)=>{C(Z=>Z.find(V=>V.id===q)?Z.map(V=>V.id===q?{...V,pinned:N||V.pinned}:V):N?[...Z,{id:q,pinned:!0}]:Z.find(V=>!V.pinned)?Z.map(V=>V.pinned?V:{id:q,pinned:!1}):[...Z,{id:q,pinned:!1}]),R(q)},[]),Y=_.useCallback(q=>{if(C(N=>N.filter(Z=>Z.id!==q)),k===q){const N=E.filter(Z=>Z.id!==q);R(N.length>0?N[N.length-1].id:null)}},[E,k]),W=_.useCallback(q=>{if(q===null){C([]),R(null);return}C(N=>N.filter(Z=>q.has(Z.id))),R(N=>N&&q.has(N)?N:null)},[]);_.useEffect(()=>{l((e==null?void 0:e.get("canonical"))??null),p((e==null?void 0:e.get("contract"))??null),R((e==null?void 0:e.get("drift"))??null)},[e]),_.useEffect(()=>{const q=new URLSearchParams(window.location.search).get("drift");if((k??"")===(q??""))return;const N=new URL(window.location.href);k?N.searchParams.set("drift",k):N.searchParams.delete("drift"),n(N.pathname+N.search)},[k,n]);const A=_.useMemo(()=>({activeSpecConflictId:a,setActiveSpecConflictId:o,handleSelectSpecConflict:T,activeCanonicalPath:s,setActiveCanonicalPath:f,openCanonicalFiles:c,handleOpenCanonical:b,handleCloseCanonical:w,activeContractsPath:h,setActiveContractsPath:$,openContractsFiles:y,handleOpenContracts:x,handleCloseContracts:S,activeDriftId:k,setActiveDriftId:R,openDriftTabs:E,handleOpenDrift:z,handleCloseDrift:Y,reconcileDriftTabs:W}),[a,T,s,c,b,w,h,y,x,S,k,E,z,Y,W]);return m.jsx(hie.Provider,{value:A,children:t})}function uSe(){const t=_.useContext(hie);if(!t)throw new Error("useDriftView must be used inside <DriftViewProvider>");return t}const pie=_.createContext(null);function OSe({children:t}){const[e]=uv(),n=uO(),[r,i]=_.useState(()=>(e==null?void 0:e.get("view"))==="diff"),[a,o]=_.useState(null),[s,l]=_.useState(null),c=_.useCallback(f=>{i(f);const h=new URL(window.location.href);f?h.searchParams.set("view","diff"):h.searchParams.delete("view"),n(h.pathname+h.search)},[n]);_.useEffect(()=>{i((e==null?void 0:e.get("view"))==="diff")},[e]);const u=_.useMemo(()=>({isDiffMode:r,setIsDiffMode:c,selectedAnalysisId:a,setSelectedAnalysisId:o,selectedPath:s,setSelectedPath:l}),[r,c,a,s]);return m.jsx(pie.Provider,{value:u,children:t})}function fSe(){const t=_.useContext(pie);if(!t)throw new Error("useViewMode must be used inside <ViewModeProvider>");return t}const mie=_.createContext(null);function dSe({repoId:t,children:e}){const[n,r]=_.useState(null),[i,a]=_.useState(!0),[o,s]=_.useState(!1),[l,c]=_.useState(null),[u,f]=_.useState(null),[h,p]=_.useState(0);_.useEffect(()=>{let w=!1;return(async()=>{try{const P=await Q0e(t);!w&&P&&r(P)}catch(P){w||c(P.message)}finally{w||a(!1)}})(),()=>{w=!0}},[t]);const y=_.useCallback(async()=>{s(!0),c(null);try{const w=await O0e(t);r(w),p(P=>P+1)}catch(w){ah("Spec scan failed",w,c)}finally{s(!1)}},[t]),v=_.useCallback(async(w,P)=>{f(w.id);try{await S0e(t,{conflictId:w.id,resolution:P,candidateFingerprint:w.candidateFingerprint}),await y()}catch(k){ah("Saving decision failed",k,c)}finally{f(null)}},[t,y]),$=_.useCallback(async()=>{s(!0);try{await T0e(t,"all-defaults"),await y()}catch(w){ah("Accept all defaults failed",w,c)}finally{s(!1)}},[t,y]),x=_.useCallback(async w=>{f(w);try{await b0e(t,w),await y()}catch(P){ah("Revoking decision failed",P,c)}finally{f(null)}},[t,y]),S=_.useCallback(async(w,P,k)=>{s(!0);try{await P0e(t,{older:w,newer:P,note:k}),await y()}catch(R){ah("Marking supersession failed",R,c)}finally{s(!1)}},[t,y]),b=_.useCallback(async w=>{s(!0);try{await w0e(t,{path:w}),await y()}catch(P){ah("Including doc failed",P,c)}finally{s(!1)}},[t,y]),T=_.useMemo(()=>({scan:n,hydrating:i,loading:o,error:l,busyConflictId:u,canonicalVersion:h,refresh:y,resolveConflict:v,acceptAllDefaults:$,revokeDecision:x,markSuperseded:S,includeDoc:b}),[n,i,o,l,u,h,y,v,$,x,S,b]);return m.jsx(mie.Provider,{value:T,children:e})}function Mc(){const t=_.useContext(mie);if(!t)throw new Error("useSpec must be used inside <SpecProvider>");return t}function ah(t,e,n){const r=e instanceof Error?e.message:String(e);n(r),hc.error(t,{description:r})}function hSe({isGitRepo:t=!0}={}){const{scan:e,loading:n,refresh:r,acceptAllDefaults:i}=Mc(),a=((e==null?void 0:e.openConflicts.length)??0)>0,o=!e;return t?m.jsxs(m.Fragment,{children:[m.jsxs(xn,{size:"sm",variant:"outline",onClick:r,disabled:n,title:"Discover docs, extract claims, surface conflicts",children:[n?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(vS,{className:"mr-2 h-3.5 w-3.5"}),n?"Scanning...":"Scan"]}),m.jsxs(xn,{size:"sm",variant:"outline",onClick:i,disabled:o||!a||n,title:"Accept the engine's default pick on every open conflict (chains first, then content)",children:[m.jsx(Nne,{className:"mr-2 h-3.5 w-3.5"}),"Accept all defaults"]})]}):null}function pSe(){const{scan:t}=Mc(),e=t&&t.openConflicts.length===0?"Select a section from the canonical spec to view it.":"Select a conflict from the list to review its candidates, or pick a canonical section below.";return m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:e})})}function mSe({progress:t,onDismiss:e}){const n=t.step==="error";return m.jsxs("div",{className:`fixed bottom-4 left-1/2 z-40 w-80 -translate-x-1/2 rounded-lg border bg-card p-3 shadow-lg ${n?"border-destructive/50":"border-border"}`,children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:`text-[11px] font-medium ${n?"text-destructive":"text-foreground"}`,children:n?"Spec failed":"Running…"}),n&&m.jsx("button",{onClick:e,className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),n?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(i0,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.detail||"An error occurred"})]}):t.steps&&t.steps.length>0?m.jsx("div",{className:"space-y-1",children:t.steps.map(r=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 translate-y-px",children:[r.status==="done"&&m.jsx(Ff,{className:"h-3.5 w-3.5 text-emerald-500"}),r.status==="active"&&m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin text-primary"}),r.status==="error"&&m.jsx(i0,{className:"h-3.5 w-3.5 text-destructive"}),r.status==="pending"&&m.jsx("div",{className:"h-2.5 w-2.5 rounded-full border border-muted-foreground/30"})]}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsxs("span",{className:`text-[11px] leading-[18px] ${r.status==="active"?"font-medium text-foreground":r.status==="done"?"text-muted-foreground":r.status==="error"?"text-destructive":"text-muted-foreground/60"}`,children:[r.label,r.detail&&r.status!=="pending"&&m.jsx("span",{className:"ml-1.5 text-[10px] font-normal text-muted-foreground/70",children:r.detail})]})})]},r.key))}):m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(yn,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:t.detail||t.step})]})]})}function pl({icon:t,title:e,body:n}){return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[m.jsx(t,{className:"h-8 w-8 text-muted-foreground/60"}),m.jsxs("div",{children:[m.jsx("h3",{className:"text-sm font-semibold text-foreground",children:e}),m.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})]})}function gSe({tree:t,isLoading:e,error:n,activePath:r,validationIssues:i,onOpen:a}){if(e&&!t)return m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})});if(n)return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-4 text-center text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-5 w-5 text-destructive"}),m.jsx("span",{children:n})]});if(!t||!t.hasContracts)return m.jsx(pl,{icon:xq,title:"No contracts yet",body:m.jsxs(m.Fragment,{children:["Resolve all open conflicts in ",m.jsx("strong",{children:"Spec"}),", click"," ",m.jsx("strong",{children:"Apply"}),", then click ",m.jsx("strong",{children:"Generate"})," here to extract TC contracts."]})});const o=i??[],s=o.filter(c=>c.severity==="hard"),l=o.filter(c=>c.severity==="soft");return m.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[o.length>0&&m.jsx($Se,{hardIssues:s,softIssues:l}),m.jsx("div",{className:"flex-1 overflow-auto",children:t.modules.map(c=>m.jsx(ySe,{label:c.name,files:c.files,activePath:r,onOpen:a},c.name))})]})}function ySe({label:t,files:e,activePath:n,onOpen:r}){const[i,a]=_.useState(!0),o=e.some(s=>s.path===n);return m.jsxs("div",{children:[m.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:`sticky top-0 z-10 flex w-full items-center justify-between gap-2 border-b border-border bg-card px-4 py-1.5 text-left text-[10px] uppercase tracking-wider hover:text-foreground ${o?"text-foreground":"text-muted-foreground"}`,"aria-expanded":i,children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[i?m.jsx(qa,{className:"h-3 w-3 shrink-0"}):m.jsx(Wc,{className:"h-3 w-3 shrink-0"}),m.jsx(Lh,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:"truncate",children:t})]}),m.jsx("span",{children:e.length})]}),i&&e.map(s=>{const l=s.path===n,c=s.path.replace(/^[^/]+\//,"");return m.jsxs("button",{type:"button",onClick:()=>r(s.path,!1),onDoubleClick:()=>r(s.path,!0),className:`flex w-full items-center gap-2 border-b border-border/60 px-4 py-2 pl-9 text-left text-[13px] transition-colors ${l?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-muted/40 hover:text-foreground"}`,title:`${s.path} — click to preview, double-click to pin`,children:[m.jsx(xq,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:"truncate",children:c})]},s.path)})]})}function $Se({hardIssues:t,softIssues:e}){const[n,r]=_.useState(!0),i=t.length+e.length,a=t.length>0,o=a?"text-red-400":"text-amber-400",s=a?"border-red-500/30":"border-amber-500/30",l=a?"bg-red-500/5":"bg-amber-500/5";return m.jsxs("div",{className:`shrink-0 border-b ${s} ${l}`,children:[m.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:`flex w-full items-center justify-between px-4 py-1.5 text-[10px] uppercase tracking-wider ${o} hover:opacity-80`,"aria-expanded":n,children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[n?m.jsx(qa,{className:"h-3 w-3"}):m.jsx(Wc,{className:"h-3 w-3"}),m.jsx("span",{children:"Validation issues"})]}),m.jsx("span",{children:i})]}),n&&m.jsxs("ul",{className:"max-h-72 overflow-auto px-2 pb-2",children:[t.map((c,u)=>m.jsx(L8,{issue:c},`hard-${c.artifactKey}-${u}`)),e.map((c,u)=>m.jsx(L8,{issue:c},`soft-${c.artifactKey}-${u}`))]})]})}function L8({issue:t}){const[e,n]=_.useState(!1),r=t.severity==="hard"?"border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300":"border-amber-500/30 bg-amber-500/5 text-amber-800 dark:text-amber-200";return m.jsx("li",{className:`mt-1.5 rounded border ${r} px-2 py-1.5`,children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("span",{className:`mt-0.5 shrink-0 rounded px-1 py-0.5 text-[9px] uppercase tracking-wider ${t.severity==="hard"?"bg-red-500/20 text-red-700 dark:text-red-300":"bg-amber-500/20 text-amber-800 dark:text-amber-200"}`,children:t.severity}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:"truncate font-mono text-[11px] text-foreground",children:t.artifactKey}),t.tcSource&&m.jsx("button",{type:"button",onClick:()=>n(i=>!i),className:"shrink-0 text-[10px] text-muted-foreground hover:text-foreground",children:e?"hide":"source"})]}),m.jsx("div",{className:"mt-0.5 break-words text-[11px]",children:t.message}),e&&t.tcSource&&m.jsx("pre",{className:"mt-1 max-h-40 overflow-auto rounded bg-muted/40 p-2 font-mono text-[10px] text-muted-foreground",children:t.tcSource})]})]})})}let tz=[],gie=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?gie:tz).push(n=n+t[e])})();function vSe(t){if(t<768)return!1;for(let e=0,n=tz.length;;){let r=e+n>>1;if(t<tz[r])n=r;else if(t>=gie[r])e=r+1;else return!0;if(e==n)return!1}}function G8(t){return t>=127462&&t<=127487}const B8=8205;function xSe(t,e,n=!0,r=!0){return(n?yie:QSe)(t,e,r)}function yie(t,e,n){if(e==t.length)return e;e&&$ie(t.charCodeAt(e))&&vie(t.charCodeAt(e-1))&&e--;let r=bk(t,e);for(e+=F8(r);e<t.length;){let i=bk(t,e);if(r==B8||i==B8||n&&vSe(i))e+=F8(i),r=i;else if(G8(i)){let a=0,o=e-2;for(;o>=0&&G8(bk(t,o));)a++,o-=2;if(a%2==0)break;e+=2}else break}return e}function QSe(t,e,n){for(;e>0;){let r=yie(t,e-2,n);if(r<e)return r;e--}return 0}function bk(t,e){let n=t.charCodeAt(e);if(!vie(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return $ie(r)?(n-55296<<10)+(r-56320)+65536:n}function $ie(t){return t>=56320&&t<57344}function vie(t){return t>=55296&&t<56320}function F8(t){return t<65536?1:2}let qn=class xie{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=ip(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),rl.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=ip(this,e,n);let r=[];return this.decompose(e,n,r,0),rl.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new fy(this),a=new fy(e);for(let o=n,s=n;;){if(i.next(o),a.next(o),o=0,i.lineBreak!=a.lineBreak||i.done!=a.done||i.value!=a.value)return!1;if(s+=i.value.length,i.done||s>=r)return!0}}iter(e=1){return new fy(this,e)}iterRange(e,n=this.length){return new Qie(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new bie(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?xie.empty:e.length<=32?new Lr(e):rl.from(Lr.split(e,[]))}};class Lr extends qn{constructor(e,n=bSe(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let a=0;;a++){let o=this.text[a],s=i+o.length;if((n?r:s)>=e)return new SSe(i,s,r,o);i=s+1,r++}}decompose(e,n,r,i){let a=e<=0&&n>=this.length?this:new Lr(H8(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),s=_b(a.text,o.text.slice(),0,a.length);if(s.length<=32)r.push(new Lr(s,o.length+a.length));else{let l=s.length>>1;r.push(new Lr(s.slice(0,l)),new Lr(s.slice(l)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Lr))return super.replace(e,n,r);[e,n]=ip(this,e,n);let i=_b(this.text,_b(r.text,H8(this.text,0,e)),n),a=this.length+r.length-(n-e);return i.length<=32?new Lr(i,a):rl.from(Lr.split(i,[]),a)}sliceString(e,n=this.length,r=`
|
|
539
539
|
`){[e,n]=ip(this,e,n);let i="";for(let a=0,o=0;a<=n&&o<this.text.length;o++){let s=this.text[o],l=a+s.length;a>e&&o&&(i+=r),e<l&&n>a&&(i+=s.slice(Math.max(0,e-a),n-a)),a=l+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let a of e)r.push(a),i+=a.length+1,r.length==32&&(n.push(new Lr(r,i)),r=[],i=-1);return i>-1&&n.push(new Lr(r,i)),n}}class rl extends qn{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let a=0;;a++){let o=this.children[a],s=i+o.length,l=r+o.lines-1;if((n?l:s)>=e)return o.lineInner(e,n,r,i);i=s+1,r=l+1}}decompose(e,n,r,i){for(let a=0,o=0;o<=n&&a<this.children.length;a++){let s=this.children[a],l=o+s.length;if(e<=l&&n>=o){let c=i&((o<=e?1:0)|(l>=n?2:0));o>=e&&l<=n&&!c?r.push(s):s.decompose(e-o,n-o,r,c)}o=l+1}}replace(e,n,r){if([e,n]=ip(this,e,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e>=a&&n<=s){let l=o.replace(e-a,n-a,r),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new rl(u,this.length-(n-e)+r.length)}return super.replace(a,s,l)}a=s+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
|
|
540
540
|
`){[e,n]=ip(this,e,n);let i="";for(let a=0,o=0;a<this.children.length&&o<=n;a++){let s=this.children[a],l=o+s.length;o>e&&a&&(i+=r),e<l&&n>o&&(i+=s.sliceString(e-o,n-o,r)),o=l+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof rl))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let l=this.children[i],c=e.children[a];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let p of e)r+=p.lines;if(r<32){let p=[];for(let y of e)y.flatten(p);return new Lr(p,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],l=0,c=-1,u=[];function f(p){let y;if(p.lines>a&&p instanceof rl)for(let v of p.children)f(v);else p.lines>o&&(l>o||!l)?(h(),s.push(p)):p instanceof Lr&&l&&(y=u[u.length-1])instanceof Lr&&p.lines+y.lines<=32?(l+=p.lines,c+=p.length+1,u[u.length-1]=new Lr(y.text.concat(p.text),y.length+1+p.length)):(l+p.lines>i&&h(),l+=p.lines,c+=p.length+1,u.push(p))}function h(){l!=0&&(s.push(u.length==1?u[0]:rl.from(u,c)),c=-1,l=u.length=0)}for(let p of e)f(p);return h(),s.length==1?s[0]:new rl(s,n)}}qn.empty=new Lr([""],0);function bSe(t){let e=-1;for(let n of t)e+=n.length+1;return e}function _b(t,e,n=0,r=1e9){for(let i=0,a=0,o=!0;a<t.length&&i<=r;a++){let s=t[a],l=i+s.length;l>=n&&(l>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(e[e.length-1]+=s,o=!1):e.push(s)),i=l+1}return e}function H8(t,e,n){return _b(t,[""],e,n)}class fy{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof Lr?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],a=this.offsets[r],o=a>>1,s=i instanceof Lr?i.text.length:i.children.length;if(o==(n>0?s:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
541
541
|
`,this;e--}else if(i instanceof Lr){let l=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof Lr?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Qie{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new fy(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class bie{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(qn.prototype[Symbol.iterator]=function(){return this.iter()},fy.prototype[Symbol.iterator]=Qie.prototype[Symbol.iterator]=bie.prototype[Symbol.iterator]=function(){return this});let SSe=class{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}};function ip(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function hs(t,e,n=!0,r=!0){return xSe(t,e,n,r)}function wSe(t){return t>=56320&&t<57344}function PSe(t){return t>=55296&&t<56320}function TSe(t,e){let n=t.charCodeAt(e);if(!PSe(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return wSe(r)?(n-55296<<10)+(r-56320)+65536:n}function kSe(t){return t<65536?1:2}const nz=/\r\n?|\n/;var ra=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ra||(ra={}));class wc{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let a=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,a),i+=a):i+=o,r+=a}}iterChangedRanges(e,n=!1){rz(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new wc(e)}composeDesc(e){return this.empty?e:e.empty?this:Sie(this,e)}mapDesc(e,n=!1){return e.empty?this:iz(this,e,n)}mapPos(e,n=-1,r=ra.Simple){let i=0,a=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],l=this.sections[o++],c=i+s;if(l<0){if(c>e)return a+(e-i);a+=s}else{if(r!=ra.Simple&&c>=e&&(r==ra.TrackDel&&i<e&&c>e||r==ra.TrackBefore&&i<e||r==ra.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!s)return e==i||n<0?a:a+l;a+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return a}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let a=this.sections[r++],o=this.sections[r++],s=i+a;if(o>=0&&i<=n&&s>=e)return i<e&&s>n?"cover":!0;i=s}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new wc(e)}static create(e){return new wc(e)}}class wi extends wc{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return rz(this,(n,r,i,a,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return iz(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,a=0;i<n.length;i+=2){let o=n[i],s=n[i+1];if(s>=0){n[i]=s,n[i+1]=o;let l=i>>1;for(;r.length<l;)r.push(qn.empty);r.push(o?e.slice(a,a+o):qn.empty)}a+=o}return new wi(n,r)}compose(e){return this.empty?e:e.empty?this:Sie(this,e,!0)}map(e,n=!1){return e.empty?this:iz(this,e,n,!0)}iterChanges(e,n=!1){rz(this,e,n)}get desc(){return wc.create(this.sections)}filter(e){let n=[],r=[],i=[],a=new My(this);e:for(let o=0,s=0;;){let l=o==e.length?1e9:e[o++];for(;s<l||s==l&&a.len==0;){if(a.done)break e;let u=Math.min(a.len,l-s);Wi(i,u,-1);let f=a.ins==-1?-1:a.off==0?a.ins:0;Wi(n,u,f),f>0&&Mu(r,n,a.text),a.forward(u),s+=u}let c=e[o++];for(;s<c;){if(a.done)break e;let u=Math.min(a.len,c-s);Wi(n,u,-1),Wi(i,u,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(u),s+=u}}return{changes:new wi(n,r),filtered:wc.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],a=[],o=0,s=null;function l(u=!1){if(!u&&!i.length)return;o<n&&Wi(i,n-o,-1);let f=new wi(i,a);s=s?s.compose(f.map(s)):f,i=[],a=[],o=0}function c(u){if(Array.isArray(u))for(let f of u)c(f);else if(u instanceof wi){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),s=s?s.compose(u.map(s)):u}else{let{from:f,to:h=f,insert:p}=u;if(f>h||f<0||h>n)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${n})`);let y=p?typeof p=="string"?qn.of(p.split(r||nz)):p:qn.empty,v=y.length;if(f==h&&v==0)return;f<o&&l(),f>o&&Wi(i,f-o,-1),Wi(i,h-f,v),Mu(a,i,y),o=h}}return c(e),l(!s),s}static empty(e){return new wi(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i];if(typeof a=="number")n.push(a,-1);else{if(!Array.isArray(a)||typeof a[0]!="number"||a.some((o,s)=>s&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length<i;)r.push(qn.empty);r[i]=qn.of(a.slice(1)),n.push(a[0],r[i].length)}}}return new wi(n,r)}static createSet(e,n){return new wi(e,n)}}function Wi(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function Mu(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(qn.empty);t.push(n)}}function rz(t,e,n){let r=t.inserted;for(let i=0,a=0,o=0;o<t.sections.length;){let s=t.sections[o++],l=t.sections[o++];if(l<0)i+=s,a+=s;else{let c=i,u=a,f=qn.empty;for(;c+=s,u+=l,l&&r&&(f=f.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)s=t.sections[o++],l=t.sections[o++];e(i,c,a,u,f),i=c,a=u}}}function iz(t,e,n,r=!1){let i=[],a=r?[]:null,o=new My(t),s=new My(e);for(let l=-1;;){if(o.done&&s.len||s.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&s.ins==-1){let c=Math.min(o.len,s.len);Wi(i,c,-1),o.forward(c),s.forward(c)}else if(s.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let c=s.len;for(Wi(i,s.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(Wi(i,0,o.ins),a&&Mu(a,i,o.text),l=o.i),o.forward(u),c-=u}s.next()}else if(o.ins>=0){let c=0,u=o.len;for(;u;)if(s.ins==-1){let f=Math.min(u,s.len);c+=f,u-=f,s.forward(f)}else if(s.ins==0&&s.len<u)u-=s.len,s.next();else break;Wi(i,c,l<o.i?o.ins:0),a&&l<o.i&&Mu(a,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&s.done)return a?wi.createSet(i,a):wc.create(i);throw new Error("Mismatched change set lengths")}}}function Sie(t,e,n=!1){let r=[],i=n?[]:null,a=new My(t),o=new My(e);for(let s=!1;;){if(a.done&&o.done)return i?wi.createSet(r,i):wc.create(r);if(a.ins==0)Wi(r,a.len,0,s),a.next();else if(o.len==0&&!o.done)Wi(r,0,o.ins,s),i&&Mu(i,r,o.text),o.next();else{if(a.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(a.len2,o.len),c=r.length;if(a.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;Wi(r,l,u,s),i&&u&&Mu(i,r,o.text)}else o.ins==-1?(Wi(r,a.off?0:a.len,l,s),i&&Mu(i,r,a.textBit(l))):(Wi(r,a.off?0:a.len,o.off?0:o.ins,s),i&&!o.off&&Mu(i,r,o.text));s=(a.ins>l||o.ins>=0&&o.len>l)&&(s||r.length>c),a.forward2(l),o.forward(l)}}}}class My{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?qn.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?qn.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class mf{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new mf(r,i,this.flags)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ie.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ie.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ie.range(e.anchor,e.head)}static create(e,n,r){return new mf(e,n,r)}}class Ie{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ie.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Ie([this.main],0)}addRange(e,n=!0){return Ie.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,Ie.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ie(e.ranges.map(n=>mf.fromJSON(n)),e.main)}static single(e,n=e){return new Ie([Ie.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let a=e[i];if(a.empty?a.from<=r:a.from<r)return Ie.normalized(e.slice(),n);r=a.to}return new Ie(e,n)}static cursor(e,n=0,r,i){return mf.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i,a){let o=(r??16777215)<<6|(i==null?7:Math.min(6,i));return!a&&e!=n&&(a=n<e?1:-1),n<e?mf.create(n,e,48|o):mf.create(e,n,(a?a<0?8:16:0)|o)}static normalized(e,n=0){let r=e[n];e.sort((i,a)=>i.from-a.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let a=e[i],o=e[i-1];if(a.empty?a.from<=o.to:a.from<o.to){let s=o.from,l=Math.max(a.to,o.to);i<=n&&n--,e.splice(--i,2,a.anchor>a.head?Ie.range(l,s):Ie.range(s,l))}}return new Ie(e,n)}}function wie(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Gq=0;class dt{constructor(e,n,r,i,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=Gq++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new dt(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Bq),!!e.static,e.enables)}of(e){return new Xb([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xb(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xb(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Bq(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Xb{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=Gq++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,a=this.id,o=e[a]>>1,s=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:(((n=e[f.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||az(f,u)){let p=r(f);if(s?!K8(p,f.values[o],i):!i(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,h)=>{let p,y=h.config.address[a];if(y!=null){let v=S0(h,y);if(this.dependencies.every($=>$ instanceof dt?h.facet($)===f.facet($):$ instanceof Ic?h.field($,!1)==f.field($,!1):!0)||(s?K8(p=r(f),v,i):i(p=r(f),v)))return f.values[o]=v,0}else p=r(f);return f.values[o]=p,1}}}}function K8(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function az(t,e){let n=!1;for(let r of e)dy(t,r)&1&&(n=!0);return n}function _Se(t,e,n){let r=n.map(l=>t[l.id]),i=n.map(l=>l.type),a=r.filter(l=>!(l&1)),o=t[e.id]>>1;function s(l){let c=[];for(let u=0;u<r.length;u++){let f=S0(l,r[u]);if(i[u]==2)for(let h of f)c.push(h);else c.push(f)}return e.combine(c)}return{create(l){for(let c of r)dy(l,c);return l.values[o]=s(l),1},update(l,c){if(!az(l,a))return 0;let u=s(l);return e.compare(u,l.values[o])?0:(l.values[o]=u,1)},reconfigure(l,c){let u=az(l,r),f=c.config.facets[e.id],h=c.facet(e);if(f&&!u&&Bq(n,f))return l.values[o]=h,0;let p=s(l);return e.compare(p,h)?(l.values[o]=h,0):(l.values[o]=p,1)}}}const hQ=dt.define({static:!0});class Ic{constructor(e,n,r,i,a){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=a,this.provides=void 0}static define(e){let n=new Ic(Gq++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(hQ).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let a=r.values[n],o=this.updateF(a,i);return this.compareF(a,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let a=r.facet(hQ),o=i.facet(hQ),s;return(s=a.find(l=>l.field==this))&&s!=o.find(l=>l.field==this)?(r.values[n]=s.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,hQ.of({field:this,create:e})]}get extension(){return this}}const ff={lowest:4,low:3,default:2,high:1,highest:0};function bg(t){return e=>new Pie(e,t)}const hv={highest:bg(ff.highest),high:bg(ff.high),default:bg(ff.default),low:bg(ff.low),lowest:bg(ff.lowest)};class Pie{constructor(e,n){this.inner=e,this.prec=n}}class pv{of(e){return new oz(this,e)}reconfigure(e){return pv.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class oz{constructor(e,n){this.compartment=e,this.inner=n}}class b0{constructor(e,n,r,i,a,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=a,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],a=Object.create(null),o=new Map;for(let h of XSe(e,n,o))h instanceof Ic?i.push(h):(a[h.facet.id]||(a[h.facet.id]=[])).push(h);let s=Object.create(null),l=[],c=[];for(let h of i)s[h.id]=c.length<<1,c.push(p=>h.slot(p));let u=r==null?void 0:r.config.facets;for(let h in a){let p=a[h],y=p[0].facet,v=u&&u[h]||[];if(p.every($=>$.type==0))if(s[y.id]=l.length<<1|1,Bq(v,p))l.push(r.facet(y));else{let $=y.combine(p.map(x=>x.value));l.push(r&&y.compare($,r.facet(y))?r.facet(y):$)}else{for(let $ of p)$.type==0?(s[$.id]=l.length<<1|1,l.push($.value)):(s[$.id]=c.length<<1,c.push(x=>$.dynamicSlot(x)));s[y.id]=c.length<<1,c.push($=>_Se($,y,p))}}let f=c.map(h=>h(s));return new b0(e,o,f,s,l,a)}}function XSe(t,e,n){let r=[[],[],[],[],[]],i=new Map;function a(o,s){let l=i.get(o);if(l!=null){if(l<=s)return;let c=r[l].indexOf(o);c>-1&&r[l].splice(c,1),o instanceof oz&&n.delete(o.compartment)}if(i.set(o,s),Array.isArray(o))for(let c of o)a(c,s);else if(o instanceof oz){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;n.set(o.compartment,c),a(c,s)}else if(o instanceof Pie)a(o.inner,o.prec);else if(o instanceof Ic)r[s].push(o),o.provides&&a(o.provides,s);else if(o instanceof Xb)r[s].push(o),o.facet.extensions&&a(o.facet.extensions,ff.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(c,s)}}return a(t,ff.default),r.reduce((o,s)=>o.concat(s))}function dy(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function S0(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const Tie=dt.define(),sz=dt.define({combine:t=>t.some(e=>e),static:!0}),kie=dt.define({combine:t=>t.length?t[0]:void 0,static:!0}),_ie=dt.define(),Xie=dt.define(),Rie=dt.define(),jie=dt.define({combine:t=>t.length?t[0]:!1});class Kf{constructor(e,n){this.type=e,this.value=n}static define(){return new RSe}}class RSe{of(e){return new Kf(this,e)}}class jSe{constructor(e){this.map=e}of(e){return new Vr(this,e)}}class Vr{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Vr(this.type,n)}is(e){return this.type==e}static define(e={}){return new jSe(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let a=i.map(n);a&&r.push(a)}return r}}Vr.reconfigure=Vr.define();Vr.appendConfig=Vr.define();class Ai{constructor(e,n,r,i,a,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&wie(r,n.newLength),a.some(s=>s.type==Ai.time)||(this.annotations=a.concat(Ai.time.of(Date.now())))}static create(e,n,r,i,a,o){return new Ai(e,n,r,i,a,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Ai.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Ai.time=Kf.define();Ai.userEvent=Kf.define();Ai.addToHistory=Kf.define();Ai.remote=Kf.define();function ESe(t,e){let n=[];for(let r=0,i=0;;){let a,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))a=t[r++],o=t[r++];else if(i<e.length)a=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Eie(t,e,n){var r;let i,a,o;return n?(i=e.changes,a=wi.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),a=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(a):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:Vr.mapEffects(t.effects,i).concat(Vr.mapEffects(e.effects,a)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function lz(t,e,n){let r=e.selection,i=Xh(e.annotations);return e.userEvent&&(i=i.concat(Ai.userEvent.of(e.userEvent))),{changes:e.changes instanceof wi?e.changes:wi.of(e.changes||[],n,t.facet(kie)),selection:r&&(r instanceof Ie?r:Ie.single(r.anchor,r.head)),effects:Xh(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function Cie(t,e,n){let r=lz(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let a=1;a<e.length;a++){e[a].filter===!1&&(n=!1);let o=!!e[a].sequential;r=Eie(r,lz(t,e[a],o?r.changes.newLength:t.doc.length),o)}let i=Ai.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return zSe(n?CSe(i):i)}function CSe(t){let e=t.startState,n=!0;for(let i of e.facet(_ie)){let a=i(t);if(a===!1){n=!1;break}Array.isArray(a)&&(n=n===!0?a:ESe(n,a))}if(n!==!0){let i,a;if(n===!1)a=t.changes.invertedDesc,i=wi.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,a=o.filtered.mapDesc(o.changes).invertedDesc}t=Ai.create(e,i,t.selection&&t.selection.map(a),Vr.mapEffects(t.effects,a),t.annotations,t.scrollIntoView)}let r=e.facet(Xie);for(let i=r.length-1;i>=0;i--){let a=r[i](t);a instanceof Ai?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof Ai?t=a[0]:t=Cie(e,Xh(a),!1)}return t}function zSe(t){let e=t.startState,n=e.facet(Rie),r=t;for(let i=n.length-1;i>=0;i--){let a=n[i](t);a&&Object.keys(a).length&&(r=Eie(r,lz(e,a,t.changes.newLength),!0))}return r==t?t:Ai.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const YSe=[];function Xh(t){return t==null?YSe:Array.isArray(t)?t:[t]}var gc=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(gc||(gc={}));const ASe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let cz;try{cz=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function qSe(t){if(cz)return cz.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||ASe.test(n)))return!0}return!1}function ZSe(t){return e=>{if(!/\S/.test(e))return gc.Space;if(qSe(e))return gc.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return gc.Word;return gc.Other}}class An{constructor(e,n,r,i,a,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=a,o&&(o._state=this);for(let s=0;s<this.config.dynamicSlots.length;s++)dy(this,s<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return dy(this,r),S0(this,r)}update(...e){return Cie(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let s of e.effects)s.is(pv.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,c)=>i.set(c,l)),n=null),i.set(s.value.compartment,s.value.extension)):s.is(Vr.reconfigure)?(n=null,r=s.value):s.is(Vr.appendConfig)&&(n=null,r=Xh(r).concat(s.value));let a;n?a=e.startState.values.slice():(n=b0.resolve(r,i,this),a=new An(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(sz)?e.newSelection:e.newSelection.asSingle();new An(n,e.newDoc,o,a,(s,l)=>l.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ie.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),a=[r.range],o=Xh(r.effects);for(let s=1;s<n.ranges.length;s++){let l=e(n.ranges[s]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<s;h++)a[h]=a[h].map(u);let f=i.mapDesc(c,!0);a.push(l.range.map(f)),i=i.compose(u),o=Vr.mapEffects(o,u).concat(Vr.mapEffects(Xh(l.effects),f))}return{changes:i,selection:Ie.create(a,n.mainIndex),effects:o}}changes(e=[]){return e instanceof wi?e:wi.of(e,this.doc.length,this.facet(An.lineSeparator))}toText(e){return qn.of(e.split(this.facet(An.lineSeparator)||nz))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(dy(this,n),S0(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof Ic&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let a in r)if(Object.prototype.hasOwnProperty.call(e,a)){let o=r[a],s=e[a];i.push(o.init(l=>o.spec.fromJSON(s,l)))}}return An.create({doc:e.doc,selection:Ie.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=b0.resolve(e.extensions||[],new Map),r=e.doc instanceof qn?e.doc:qn.of((e.doc||"").split(n.staticFacet(An.lineSeparator)||nz)),i=e.selection?e.selection instanceof Ie?e.selection:Ie.single(e.selection.anchor,e.selection.head):Ie.single(0);return wie(i,r.length),n.staticFacet(sz)||(i=i.asSingle()),new An(n,r,i,n.dynamicSlots.map(()=>null),(a,o)=>o.create(a),null)}get tabSize(){return this.facet(An.tabSize)}get lineBreak(){return this.facet(An.lineSeparator)||`
|
|
@@ -701,7 +701,7 @@ ${n.map(([a,o])=>{var l;const s=((l=o.theme)==null?void 0:l[r])||o.color;return
|
|
|
701
701
|
`)}
|
|
702
702
|
}
|
|
703
703
|
`).join(`
|
|
704
|
-
`)}}):null},Rv=Ks;function jv({active:t,payload:e,className:n,indicator:r="dot",hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:l,formatter:c,color:u,nameKey:f,labelKey:h}){const{config:p}=POe(),y=_.useMemo(()=>{var T;if(i||!(e!=null&&e.length))return null;const[$]=e,x=`${h||($==null?void 0:$.dataKey)||($==null?void 0:$.name)||"value"}`,S=XA(p,$,x),b=!h&&typeof o=="string"?((T=p[o])==null?void 0:T.label)||o:S==null?void 0:S.label;return s?m.jsx("div",{className:jr("font-medium",l),children:s(b,e)}):b?m.jsx("div",{className:jr("font-medium",l),children:b}):null},[o,s,e,i,l,p,h]);if(!t||!(e!=null&&e.length))return null;const v=e.length===1&&r!=="dot";return m.jsxs("div",{className:jr("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",n),children:[v?null:y,m.jsx("div",{className:"grid gap-1.5",children:e.filter($=>$.type!=="none").map(($,x)=>{const S=`${f||$.name||$.dataKey||"value"}`,b=XA(p,$,S),T=u||$.payload.fill||$.color;return m.jsx("div",{className:jr("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",r==="dot"&&"items-center"),children:c&&($==null?void 0:$.value)!==void 0&&$.name?c($.value,$.name,$,x,$.payload):m.jsxs(m.Fragment,{children:[b!=null&&b.icon?m.jsx(b.icon,{}):!a&&m.jsx("div",{className:jr("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":r==="dot","w-1":r==="line","w-0 border-[1.5px] border-dashed bg-transparent":r==="dashed","my-0.5":v&&r==="dashed"}),style:{"--color-bg":T,"--color-border":T}}),m.jsxs("div",{className:jr("flex flex-1 justify-between leading-none",v?"items-end":"items-center"),children:[m.jsxs("div",{className:"grid gap-1.5",children:[v?y:null,m.jsx("span",{className:"text-muted-foreground",children:(b==null?void 0:b.label)||$.name})]}),$.value&&m.jsx("span",{className:"font-mono font-medium text-foreground tabular-nums",children:$.value.toLocaleString()})]})]})},$.dataKey)})})]})}const lLe=Tf;function cLe({className:t,hideIcon:e=!1,payload:n,verticalAlign:r="bottom",nameKey:i}){const{config:a}=POe();return n!=null&&n.length?m.jsx("div",{className:jr("flex items-center justify-center gap-4",r==="top"?"pb-3":"pt-3",t),children:n.filter(o=>o.type!=="none").map(o=>{const s=`${i||o.dataKey||"value"}`,l=XA(a,o,s);return m.jsxs("div",{className:jr("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[l!=null&&l.icon&&!e?m.jsx(l.icon,{}):m.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:o.color}}),l==null?void 0:l.label]},o.value)})}):null}function XA(t,e,n){if(typeof e!="object"||e===null)return;const r="payload"in e&&typeof e.payload=="object"&&e.payload!==null?e.payload:void 0;let i=n;return n in e&&typeof e[n]=="string"?i=e[n]:r&&n in r&&typeof r[n]=="string"&&(i=r[n]),i in t?t[i]:t[n]}function fa({className:t,size:e="default",...n}){return m.jsx("div",{"data-slot":"card","data-size":e,className:jr("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),...n})}function ho({className:t,...e}){return m.jsx("div",{"data-slot":"card-header",className:jr("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),...e})}function po({className:t,...e}){return m.jsx("div",{"data-slot":"card-title",className:jr("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),...e})}function da({className:t,...e}){return m.jsx("div",{"data-slot":"card-content",className:jr("px-4 group-data-[size=sm]/card:px-3",t),...e})}const uLe=["critical","high","medium","low","info"],yh={critical:"#dc2626",high:"#ef4444",medium:"#f97316",low:"#f59e0b",info:"#3b82f6"},OLe={count:{label:"Violations"},critical:{label:"Critical",color:yh.critical},high:{label:"High",color:yh.high},medium:{label:"Medium",color:yh.medium},low:{label:"Low",color:yh.low},info:{label:"Info",color:yh.info}};function FV({data:t,activeSeverity:e,onSeverityClick:n}){const{bySeverity:r}=t,i=uLe.filter(o=>(r[o]??0)>0).map(o=>({severity:o.charAt(0).toUpperCase()+o.slice(1),severityKey:o,count:r[o]??0,fill:yh[o]}));if(i.length===0)return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Severity"})}),m.jsx(da,{children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No violations to display."})})]});const a=o=>{o.severityKey&&(n==null||n(o.severityKey))};return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Severity"})}),m.jsx(da,{children:m.jsx(Xv,{config:OLe,className:"aspect-[2/1] w-full max-h-[250px]",children:m.jsxs(N9e,{data:i,margin:{top:4,right:4,bottom:0,left:0},children:[m.jsx(Ew,{vertical:!1}),m.jsx(od,{dataKey:"severity",tickLine:!1,axisLine:!1,tickMargin:8}),m.jsx(sd,{tickLine:!1,axisLine:!1,tickMargin:8,allowDecimals:!1,width:32}),m.jsx(Rv,{content:m.jsx(jv,{})}),m.jsx(ad,{dataKey:"count",radius:[4,4,0,0],onClick:n?a:void 0,style:n?{cursor:"pointer"}:void 0,isAnimationActive:!1,children:i.map(o=>m.jsx(ym,{fill:o.fill,opacity:!e||e===o.severityKey?1:.35},o.severityKey))})]})})})]})}const F2=Math.PI/180,cH=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function fLe(t){const e={};return Object.keys(t).forEach((n,r)=>{e[n]={label:WS(n),color:cH[r%cH.length]}}),e}function dLe(t){const e=t;return m.jsx($w,{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius+10,startAngle:e.startAngle,endAngle:e.endAngle,fill:e.fill})}function hLe({byKind:t,activeKind:e,onKindClick:n}){const r=_.useMemo(()=>Object.entries(t).filter(([,l])=>l>0).sort((l,c)=>c[1]-l[1]).map(([l,c])=>({name:l,value:c})),[t]),i=_.useMemo(()=>fLe(t),[t]),a=_.useMemo(()=>r.reduce((l,c)=>l+c.value,0),[r]);if(r.length===0)return null;const o=e?r.findIndex(l=>l.name===e):-1,s=l=>{const c=l,u=o>=0&&c.index===o,f=(c.outerRadius+(u?10:0))*1.18,h=c.cx+f*Math.cos(-c.midAngle*F2),p=c.cy+f*Math.sin(-c.midAngle*F2),y=Math.cos(-c.midAngle*F2)>=0?"start":"end",v=c.percent!==void 0?` ${(c.percent*100).toFixed(0)}%`:"",$=c.name?WS(c.name):"";return m.jsxs("text",{x:h,y:p,textAnchor:y,dominantBaseline:"central",className:u?"fill-foreground text-xs font-medium":"fill-muted-foreground text-[10px]",children:[$,v]})};return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Artifact Kind"})}),m.jsx(da,{children:m.jsx(Xv,{config:i,className:`aspect-square w-full max-h-[250px] ${n?"[&_.recharts-pie]:cursor-pointer":""}`,children:m.jsxs(pOe,{children:[m.jsx(Rv,{content:m.jsx(jv,{nameKey:"name"})}),m.jsxs(Xl,{data:r,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:"40%",outerRadius:"70%",paddingAngle:2,label:s,labelLine:!1,activeIndex:o>=0?o:-1,activeShape:dLe,onClick:n?l=>l.name&&n(l.name):void 0,isAnimationActive:!1,children:[r.map((l,c)=>m.jsx(ym,{fill:`var(--color-${l.name})`,opacity:o<0||c===o?1:.45},l.name)),m.jsx(ti,{value:a,position:"center",className:"fill-foreground text-lg font-bold"})]})]})})})]})}function pLe({byFile:t,activeFile:e,onFileClick:n}){const r=Object.entries(t).map(([i,a])=>({filePath:i,count:a})).sort((i,a)=>a.count-i.count).slice(0,10);return r.length===0?null:m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"Top Files"})}),m.jsx(da,{className:"px-0",children:m.jsx("table",{className:"w-full text-sm",children:m.jsx("tbody",{children:r.map((i,a)=>{const o=i.filePath.split("/").pop()||i.filePath,s=e===i.filePath;return m.jsxs("tr",{className:`border-b border-border/50 transition-colors ${n?"cursor-pointer hover:bg-muted/50":""} ${s?"bg-accent/50":""}`,onClick:()=>n==null?void 0:n(i.filePath),title:i.filePath,children:[m.jsx("td",{className:"px-4 py-1.5 text-xs text-muted-foreground",children:a+1}),m.jsx("td",{className:"px-2 py-1.5",children:m.jsx("span",{className:"block max-w-[220px] truncate",title:i.filePath,children:o})}),m.jsx("td",{className:"px-4 py-1.5 text-right font-mono tabular-nums",children:i.count})]},i.filePath)})})})})]})}const mLe={drifts:{label:"Drifts",color:"var(--chart-1)"}};function gLe(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function yLe({history:t}){const e=t.runs.map(r=>({drifts:r.driftCount,dateLabel:gLe(r.verifiedAt)}));if(e.length===0)return null;const n=e.length>=2?e[e.length-1].drifts-e[e.length-2].drifts:0;return m.jsxs(fa,{children:[m.jsxs(ho,{className:"flex flex-row items-center justify-between pb-2",children:[m.jsx(po,{className:"text-sm font-medium",children:"Drift Trend"}),m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n>0&&m.jsxs(m.Fragment,{children:[m.jsx(Tq,{className:"h-3.5 w-3.5 text-red-400"})," +",n]}),n<0&&m.jsxs(m.Fragment,{children:[m.jsx(Une,{className:"h-3.5 w-3.5 text-green-400"})," ",n]}),n===0&&m.jsxs(m.Fragment,{children:[m.jsx(Ene,{className:"h-3.5 w-3.5"})," No change"]})]})]}),m.jsx(da,{children:e.length===1?m.jsxs("div",{className:"flex flex-col items-center gap-1 py-6 text-center",children:[m.jsx("p",{className:"text-2xl font-bold",children:e[0].drifts}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"Drifts in your first verify run — run more to see the trend."})]}):m.jsx(Xv,{config:mLe,className:"w-full",style:{aspectRatio:"auto",height:200},children:m.jsxs(SOe,{data:e,margin:{top:4,right:4,bottom:0,left:0},children:[m.jsx(Ew,{vertical:!1}),m.jsx(od,{dataKey:"dateLabel",tickLine:!1,axisLine:!1,tickMargin:8}),m.jsx(sd,{tickLine:!1,axisLine:!1,tickMargin:8,allowDecimals:!1,width:32}),m.jsx(Rv,{content:m.jsx(jv,{})}),m.jsx($s,{dataKey:"drifts",type:"monotone",fill:"var(--color-drifts)",fillOpacity:.15,stroke:"var(--color-drifts)",strokeWidth:2,isAnimationActive:!1})]})})})]})}const $Le="pointer-events-none absolute left-1/2 top-full mt-1.5 -translate-x-1/2 whitespace-nowrap rounded bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md border border-border opacity-0 group-hover:opacity-100 transition-opacity z-50";function af({icon:t,iconClass:e,value:n,label:r,tooltip:i}){return m.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-1.5 rounded-md border border-border bg-muted/30 px-2.5 py-1",children:[m.jsx(t,{className:`h-3.5 w-3.5 shrink-0 ${e}`}),m.jsx("span",{className:"text-xs font-semibold",children:n}),m.jsx("span",{className:"text-[10px] text-muted-foreground",children:r}),m.jsx("span",{className:$Le,children:i})]})}function vLe(t){const e={},n={},r={};for(const i of t){e[i.severity]=(e[i.severity]??0)+1;const a=vv(i);n[a]=(n[a]??0)+1,i.filePath&&(r[i.filePath]=(r[i.filePath]??0)+1)}return{bySeverity:e,byKind:n,byFile:r}}function xLe({state:t,diff:e,history:n,mode:r,isDiffing:i,filters:a,onToggleSeverity:o,onToggleKind:s,onToggleFile:l}){if(!t)return m.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-muted-foreground",children:"No verify run yet."});const c=r==="diff",u=c?(e==null?void 0:e.added)??[]:t.drifts,{bySeverity:f,byKind:h,byFile:p}=vLe(u),y=t.unresolvedRefs.length;return c&&!e?m.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:m.jsx("div",{className:"flex flex-1 items-center justify-center p-4",children:m.jsxs("div",{className:"text-center text-xs text-muted-foreground",children:[m.jsx(yS,{className:"mx-auto mb-2 h-6 w-6 opacity-60"}),i?"Computing diff…":m.jsxs(m.Fragment,{children:["Click ",m.jsx("span",{className:"font-medium text-foreground",children:"Verify"})," to compute the diff against the committed baseline."]})]})})}):m.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:m.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-3",children:[y>0&&m.jsx(tm,{align:"start",width:"wide",content:"Some artifacts the spec mentions weren't extracted into contracts. Drifts against them won't be detected.",children:m.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs text-amber-700 dark:text-amber-300",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsxs("span",{children:[y," unresolved reference",y===1?"":"s"]})]})}),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex flex-wrap items-center gap-2",children:c&&e?m.jsxs(m.Fragment,{children:[m.jsx(af,{icon:Pne,iconClass:"text-rose-400",value:e.summary.added,label:"new",tooltip:"Drifts introduced by your uncommitted changes"}),m.jsx(af,{icon:vq,iconClass:"text-green-400",value:e.summary.resolved,label:"resolved",tooltip:"Baseline drifts your changes have fixed"}),m.jsx(af,{icon:r0,iconClass:"text-blue-400",value:e.summary.unchanged,label:"unchanged",tooltip:"Baseline drifts your changes haven't touched"}),m.jsx(af,{icon:Ju,iconClass:"text-blue-400",value:e.changedFiles.length,label:"files",tooltip:"Files changed in your working tree"})]}):m.jsxs(m.Fragment,{children:[m.jsx(af,{icon:Wo,iconClass:t.drifts.length>0?"text-yellow-400":"text-muted-foreground",value:t.drifts.length,label:"drifts",tooltip:"Drifts detected against the contracts"}),m.jsx(af,{icon:bne,iconClass:"text-muted-foreground",value:t.artifactCount,label:"artifacts",tooltip:"Artifacts checked from the contracts"}),m.jsx(af,{icon:r0,iconClass:"text-blue-400",value:t.extractedOperationCount,label:"operations",tooltip:"Operations extracted from the code"})]})}),!c&&m.jsx(yLe,{history:n}),m.jsx(hLe,{byKind:h,activeKind:a.kind,onKindClick:s}),m.jsx(FV,{data:{byCategory:{},bySeverity:f,total:u.length},activeSeverity:a.severity,onSeverityClick:o}),m.jsx(pLe,{byFile:p,activeFile:a.file,onFileClick:l})]})]})})}const QLe={critical:"text-red-500 dark:text-red-500",high:"text-red-600 dark:text-red-400",medium:"text-orange-600 dark:text-orange-400",low:"text-amber-600 dark:text-amber-400",info:"text-gray-500 dark:text-gray-400"},bLe=["critical","high","medium","low","info"],SLe={critical:"bg-red-500",high:"bg-red-400",medium:"bg-orange-400",low:"bg-amber-400",info:"bg-gray-400"};function wLe({counts:t}){if(!t)return m.jsx("span",{className:"text-muted-foreground",children:"0"});const e=bLe.filter(r=>t[r]&&t[r]>0).map(r=>({severity:r,count:t[r]})),n=e.reduce((r,i)=>r+i.count,0);return n===0?m.jsx("span",{className:"text-muted-foreground",children:"0"}):m.jsxs("div",{className:"flex flex-col gap-1 min-w-[60px]",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"text-xs font-medium",children:n}),m.jsx("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.map(({severity:r,count:i})=>m.jsx("span",{className:QLe[r],title:`${r}: ${i}`,children:i},r))})]}),m.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-muted",children:e.map(({severity:r,count:i})=>m.jsx("div",{className:`${SLe[r]} h-full`,style:{width:`${i/n*100}%`},title:`${r}: ${i}`},r))})]})}function PLe(t){const e=new Date(t);return Number.isNaN(e.getTime())?{date:t,time:""}:{date:e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),time:e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}}function TLe({history:t,selectedRunId:e,onViewRun:n,onDeleteRun:r}){const[i,a]=_.useState(null),o=[...t.runs].reverse();return o.length===0?m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground",children:[m.jsx(Bu,{className:"h-8 w-8 opacity-50"}),m.jsx("p",{children:"No verify runs yet. Run Verify to see results here."})]}):m.jsxs("div",{className:"h-full overflow-auto p-4",children:[m.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[m.jsx("h2",{className:"text-lg font-semibold",children:"Runs"}),m.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," total"]})]}),m.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:m.jsxs("table",{className:"w-full text-sm",children:[m.jsx("thead",{children:m.jsxs("tr",{className:"border-b border-border bg-muted/50 text-left text-xs text-muted-foreground",children:[m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Date"}),m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Branch"}),m.jsx("th",{className:"px-4 py-2.5 font-medium text-center",children:"Artifacts"}),m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Drifts"}),m.jsx("th",{className:"px-4 py-2.5 font-medium text-center",children:"Actions"})]})}),m.jsx("tbody",{children:o.map((s,l)=>{const c=l===0,u=e?e===s.id:c,{date:f,time:h}=PLe(s.verifiedAt);return m.jsxs("tr",{className:`border-b border-border/50 transition-colors cursor-pointer ${u?"bg-primary/10":"hover:bg-accent/30"}`,onClick:()=>n(c?null:s.id),children:[m.jsx("td",{className:"px-4 py-2.5",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsx("span",{className:"text-xs font-medium",children:f}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:h})]}),c&&m.jsx("span",{className:"rounded bg-primary/20 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"latest"})]})}),m.jsxs("td",{className:"px-4 py-2.5",children:[s.branch?m.jsx("span",{className:"font-mono text-xs",children:s.branch}):m.jsx("span",{className:"text-xs text-muted-foreground",children:"-"}),s.commitHash&&m.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:s.commitHash.slice(0,7)})]}),m.jsx("td",{className:"px-4 py-2.5 text-center text-xs",children:s.artifactCount}),m.jsx("td",{className:"px-4 py-2.5 text-xs",children:m.jsx(wLe,{counts:s.bySeverity})}),m.jsx("td",{className:"px-4 py-2.5",children:m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("button",{className:"rounded p-1.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete run",disabled:i===s.id,onClick:async p=>{if(p.stopPropagation(),!!confirm("Delete this verify run?")){a(s.id);try{await r(s.id)}finally{a(null)}}},children:i===s.id?m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Pq,{className:"h-3.5 w-3.5"})})})})]},s.id)})})]})})]})}function kLe({isRunning:t,onRun:e,stale:n=!1,diffMode:r,onToggleDiff:i,isGitRepo:a,runItems:o,selectedRunId:s,onSelectRun:l,viewingHistory:c}){const u=n&&!t;return m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(kre,{items:o,selectedId:s,onSelect:l}),a&&!c&&m.jsx(Tre,{diffMode:r,onToggle:i,subject:{verb:"verifies",plural:"drifts"}}),!c&&m.jsx(tm,{align:"end",width:"narrow",content:n?"Contracts have changed since the last Verify. Click to re-check code against the new contracts.":null,children:m.jsxs(xn,{size:"sm",onClick:e,disabled:t,className:"relative",children:[t?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(vS,{className:"mr-2 h-3.5 w-3.5"}),t?"Verifying...":"Verify",u&&m.jsx("span",{"aria-label":"unverified changes",className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-400 ring-2 ring-background"})]})})]})}const _Le={critical:"bg-red-500/20 text-red-700 dark:text-red-300 border-red-500/40",high:"bg-red-500/15 text-red-700 dark:text-red-300 border-red-500/30",medium:"bg-amber-500/15 text-amber-700 dark:text-amber-300 border-amber-500/30",low:"bg-amber-500/10 text-amber-800 dark:text-amber-200 border-amber-500/20",info:"bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-500/30"};function XLe({drift:t,onClose:e,onOpenFile:n}){var a;const r=((a=t.artifactRef)==null?void 0:a.identity)??null,i=_Le[t.severity];return m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-card px-6 py-3",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[m.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wider ${i}`,children:t.severity}),m.jsx(VZ,{kind:vv(t)}),m.jsx("h2",{className:"truncate font-mono text-sm",children:t.obligationKey})]}),e&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:e,title:"Close drift",children:m.jsx(Rr,{className:"h-4 w-4"})})]}),m.jsx("div",{className:"flex-1 overflow-auto px-6 py-4",children:m.jsxs("div",{className:"space-y-4",children:[r&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Artifact"}),m.jsx("div",{className:"font-mono text-sm text-foreground",children:r})]}),m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"What's wrong"}),m.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message})]}),t.filePath&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Where in the code"}),m.jsxs("button",{type:"button",onClick:()=>t.filePath&&(n==null?void 0:n(t.filePath,t.lineStart??void 0)),disabled:!n,className:"block w-full break-all text-left font-mono text-xs text-primary hover:underline disabled:cursor-default disabled:no-underline disabled:text-foreground",children:[t.filePath,t.lineStart!=null&&`:${t.lineStart}`,t.lineEnd!=null&&t.lineEnd!==t.lineStart&&`–${t.lineEnd}`]})]}),t.specSide!==void 0&&t.specSide!==null&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Spec expectation"}),m.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted/20 p-3 font-mono text-[11px] text-foreground",children:JSON.stringify(t.specSide,null,2)})]}),t.codeSide!==void 0&&t.codeSide!==null&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Code observation"}),m.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted/20 p-3 font-mono text-[11px] text-foreground",children:JSON.stringify(t.codeSide,null,2)})]})]})})]})}function RLe(){return m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:"Select a drift from the list to inspect it."})})}function jLe(t){const[e,n]=_.useState(null),[r,i]=_.useState(null),[a,o]=_.useState({runs:[]}),[s,l]=_.useState(!1),[c,u]=_.useState(!1),[f,h]=_.useState(!1),[p,y]=_.useState(null),v=_.useCallback(async()=>{if(t){l(!0),y(null);try{const[S,b,T]=await Promise.all([m0e(t),y0e(t),R8(t)]);n(S),i(b),o(T)}catch(S){y(S instanceof Error?S.message:"Failed to load verify state")}finally{l(!1)}}},[t]),$=_.useCallback(async()=>{if(t){u(!0),y(null);try{const S=await g0e(t);n(S),i(null),R8(t).then(o).catch(()=>{})}catch(S){const b=S instanceof Error?S.message:"Verify failed";y(b),hc.error("Verify failed",{description:b})}finally{u(!1)}}},[t]),x=_.useCallback(async()=>{if(t){h(!0);try{const S=await $0e(t);i(S)}catch(S){const b=S instanceof Error?S.message:"Verify diff failed";hc.error("Verify diff failed",{description:b})}finally{h(!1)}}},[t]);return _.useEffect(()=>{v()},[v]),{state:e,diff:r,history:a,isLoading:s,isRunning:c,isDiffing:f,error:p,refetch:v,run:$,runDiff:x}}function ELe(t){const[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){n(!0),o(null);try{const l=await k0e(t);i(l)}catch(l){const c=l instanceof Error?l.message:"Generate failed";o(c),hc.error("Generate failed",{description:c})}finally{n(!1)}}},[t]);return{generating:e,result:r,error:a,run:s}}function CLe(t){const[e,n]=_.useState(!1),[r,i]=_.useState(!1),a=_.useCallback(async()=>{if(t)try{const o=await _0e(t);n(o.contractsStale),i(o.verifyStale)}catch{}},[t]);return _.useEffect(()=>{a()},[a]),{contractsStale:e,verifyStale:r,refetch:a}}function zLe({isGenerating:t,onGenerate:e,stale:n=!1}){const r=n&&!t;return m.jsx(tm,{align:"end",width:"narrow",content:n?"Canonical spec has changed since the last Generate. Click to re-extract TC contracts.":null,children:m.jsxs(xn,{size:"sm",onClick:e,disabled:t,className:"relative",children:[t?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(Nne,{className:"mr-2 h-3.5 w-3.5"}),t?"Generating...":"Generate",r&&m.jsx("span",{"aria-label":"ungenerated changes",className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-400 ring-2 ring-background"})]})})}function YLe({result:t}){const e=_.useRef(null);return _.useEffect(()=>{if(!t||t===e.current)return;if(e.current=t,"error"in t.il){hc.error("Generate failed",{description:t.il.error});return}if("skipped"in t.il){hc.warning("Generate skipped",{description:t.il.skipped});return}const n=t.il.validationIssues??[],r=t.il.written,i=n.filter(s=>s.severity==="hard").length;if(n.length===0){hc.success("Generated",{description:`Wrote ${r} TC contract${r===1?"":"s"}.`});return}const a=i>0?"Generated with errors":"Generated with warnings",o=i>0?`${i} error${i===1?"":"s"} blocked writing — see Contracts panel.`:`Wrote ${r} contract${r===1?"":"s"} · ${n.length} warning${n.length===1?"":"s"} — see Contracts panel.`;i>0?hc.error(a,{description:o}):hc.warning(a,{description:o})},[t]),null}const uH=["overview","auth","endpoints","data","effects","errors"];function ALe(t,e){const n=uH.indexOf(t),r=uH.indexOf(e);return n===-1&&r===-1?t.localeCompare(e):n===-1?1:r===-1?-1:n-r}function qLe({activeConflictId:t,onSelectConflict:e}){var l;const{scan:n,hydrating:r}=Mc();if(r)return m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})});if(!n)return m.jsx(pl,{icon:EC,title:"No scan yet",body:m.jsxs(m.Fragment,{children:["Click ",m.jsx("strong",{children:"Scan"})," on the Spec tab to start recording decisions."]})});const i=n.decidedConflicts;if(i.length===0)return m.jsx(pl,{icon:EC,title:"No decisions yet",body:"Resolve conflicts in the Spec tab and they'll show up here as a revokable ledger."});const a=[],o=new Map;for(const c of i){if((l=c.conflict.candidates[0])==null?void 0:l.claim.id.startsWith("version-chain:")){a.push(c);continue}const f=o.get(c.conflict.topic)??[];f.push(c),o.set(c.conflict.topic,f)}const s=[...o.keys()].sort(ALe);for(const c of s)o.set(c,(o.get(c)??[]).sort((u,f)=>u.conflict.subject.localeCompare(f.conflict.subject)));return m.jsx("div",{className:"flex h-full flex-col",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[a.length>0&&m.jsx(OH,{title:"Version chains",count:a.length,children:a.map(c=>m.jsx(fH,{entry:c,active:c.decision.conflictId===t,onSelect:()=>e(c.decision.conflictId)},c.decision.conflictId))}),s.map(c=>m.jsx(OH,{title:c,count:(o.get(c)??[]).length,children:(o.get(c)??[]).map(u=>m.jsx(fH,{entry:u,active:u.decision.conflictId===t,onSelect:()=>e(u.decision.conflictId)},u.decision.conflictId))},c))]})})}function OH({title:t,count:e,children:n}){return m.jsxs("div",{children:[m.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/80 px-4 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[m.jsx("span",{children:t}),m.jsx("span",{children:e})]}),n]})}function fH({entry:t,active:e,onSelect:n}){const{conflict:r,decision:i}=t,a=ZLe(t),o=i.resolution.kind==="custom";return m.jsx("div",{onClick:n,className:`flex cursor-pointer items-start gap-3 border-b border-border/60 px-4 py-2.5 text-xs transition-colors ${e?"bg-primary/10 text-foreground":"hover:bg-muted/40"}`,children:m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate font-medium text-foreground",children:r.subject}),m.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-muted-foreground",children:[m.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${o?"bg-blue-500/15 text-blue-700 dark:text-blue-300":"bg-muted/60 text-muted-foreground"}`,children:o?"custom":"picked"}),m.jsx("span",{className:"truncate",children:a})]}),i.note&&m.jsx("div",{className:"mt-1 text-[11px] italic text-muted-foreground",children:i.note}),m.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground/70",title:new Date(i.resolvedAt).toLocaleString(),children:VLe(i.resolvedAt)})]})})}function ZLe({conflict:t,decision:e}){if(e.resolution.kind==="custom")return dH(e.resolution.content,140);const n=e.resolution.candidateIndex,r=t.candidates[n];if(!r)return`candidate #${n}`;const i=r.claim.content;return i==null?`candidate #${n}`:dH(typeof i=="string"?i:JSON.stringify(i),140)}function dH(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"…"}function VLe(t){const e=new Date(t).getTime();if(Number.isNaN(e))return t;const n=Math.round((Date.now()-e)/1e3);if(n<5)return"just now";if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r}m ago`;const i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function ci(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=ci(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var ULe={value:()=>{}};function Yw(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Nb(n)}function Nb(t){this._=t}function NLe(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Nb.prototype=Yw.prototype={constructor:Nb,on:function(t,e){var n=this._,r=NLe(t+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(t=r[a]).type)&&(i=WLe(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++a<o;)if(i=(t=r[a]).type)n[i]=hH(n[i],t.name,e);else if(e==null)for(i in n)n[i]=hH(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Nb(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=this._[t],r=0,i=a.length;r<i;++r)a[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};function WLe(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function hH(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ULe,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var RA="http://www.w3.org/1999/xhtml";const pH={svg:"http://www.w3.org/2000/svg",xhtml:RA,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Aw(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),pH.hasOwnProperty(e)?{space:pH[e],local:t}:t}function MLe(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===RA&&e.documentElement.namespaceURI===RA?e.createElement(t):e.createElementNS(n,t)}}function ILe(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function TOe(t){var e=Aw(t);return(e.local?ILe:MLe)(e)}function DLe(){}function HV(t){return t==null?DLe:function(){return this.querySelector(t)}}function LLe(t){typeof t!="function"&&(t=HV(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=new Array(o),l,c,u=0;u<o;++u)(l=a[u])&&(c=t.call(l,l.__data__,u,a))&&("__data__"in l&&(c.__data__=l.__data__),s[u]=c);return new mo(r,this._parents)}function GLe(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function BLe(){return[]}function kOe(t){return t==null?BLe:function(){return this.querySelectorAll(t)}}function FLe(t){return function(){return GLe(t.apply(this,arguments))}}function HLe(t){typeof t=="function"?t=FLe(t):t=kOe(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o=e[a],s=o.length,l,c=0;c<s;++c)(l=o[c])&&(r.push(t.call(l,l.__data__,c,o)),i.push(l));return new mo(r,i)}function _Oe(t){return function(){return this.matches(t)}}function XOe(t){return function(e){return e.matches(t)}}var KLe=Array.prototype.find;function JLe(t){return function(){return KLe.call(this.children,t)}}function eGe(){return this.firstElementChild}function tGe(t){return this.select(t==null?eGe:JLe(typeof t=="function"?t:XOe(t)))}var nGe=Array.prototype.filter;function rGe(){return Array.from(this.children)}function iGe(t){return function(){return nGe.call(this.children,t)}}function aGe(t){return this.selectAll(t==null?rGe:iGe(typeof t=="function"?t:XOe(t)))}function oGe(t){typeof t!="function"&&(t=_Oe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=[],l,c=0;c<o;++c)(l=a[c])&&t.call(l,l.__data__,c,a)&&s.push(l);return new mo(r,this._parents)}function ROe(t){return new Array(t.length)}function sGe(){return new mo(this._enter||this._groups.map(ROe),this._parents)}function G1(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}G1.prototype={constructor:G1,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function lGe(t){return function(){return t}}function cGe(t,e,n,r,i,a){for(var o=0,s,l=e.length,c=a.length;o<c;++o)(s=e[o])?(s.__data__=a[o],r[o]=s):n[o]=new G1(t,a[o]);for(;o<l;++o)(s=e[o])&&(i[o]=s)}function uGe(t,e,n,r,i,a,o){var s,l,c=new Map,u=e.length,f=a.length,h=new Array(u),p;for(s=0;s<u;++s)(l=e[s])&&(h[s]=p=o.call(l,l.__data__,s,e)+"",c.has(p)?i[s]=l:c.set(p,l));for(s=0;s<f;++s)p=o.call(t,a[s],s,a)+"",(l=c.get(p))?(r[s]=l,l.__data__=a[s],c.delete(p)):n[s]=new G1(t,a[s]);for(s=0;s<u;++s)(l=e[s])&&c.get(h[s])===l&&(i[s]=l)}function OGe(t){return t.__data__}function fGe(t,e){if(!arguments.length)return Array.from(this,OGe);var n=e?uGe:cGe,r=this._parents,i=this._groups;typeof t!="function"&&(t=lGe(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),c=0;c<a;++c){var u=r[c],f=i[c],h=f.length,p=dGe(t.call(u,u&&u.__data__,c,r)),y=p.length,v=s[c]=new Array(y),$=o[c]=new Array(y),x=l[c]=new Array(h);n(u,f,v,$,x,p,e);for(var S=0,b=0,T,w;S<y;++S)if(T=v[S]){for(S>=b&&(b=S+1);!(w=$[b])&&++b<y;);T._next=w||null}}return o=new mo(o,r),o._enter=s,o._exit=l,o}function dGe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function hGe(){return new mo(this._exit||this._groups.map(ROe),this._parents)}function pGe(t,e,n){var r=this.enter(),i=this,a=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function mGe(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),l=0;l<o;++l)for(var c=n[l],u=r[l],f=c.length,h=s[l]=new Array(f),p,y=0;y<f;++y)(p=c[y]||u[y])&&(h[y]=p);for(;l<i;++l)s[l]=n[l];return new mo(s,this._parents)}function gGe(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function yGe(t){t||(t=$Ge);function e(f,h){return f&&h?t(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,l=i[a]=new Array(s),c,u=0;u<s;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new mo(i,this._parents).order()}function $Ge(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function vGe(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function xGe(){return Array.from(this)}function QGe(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function bGe(){let t=0;for(const e of this)++t;return t}function SGe(){return!this.node()}function wGe(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&t.call(s,s.__data__,a,i);return this}function PGe(t){return function(){this.removeAttribute(t)}}function TGe(t){return function(){this.removeAttributeNS(t.space,t.local)}}function kGe(t,e){return function(){this.setAttribute(t,e)}}function _Ge(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function XGe(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function RGe(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function jGe(t,e){var n=Aw(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?TGe:PGe:typeof e=="function"?n.local?RGe:XGe:n.local?_Ge:kGe)(n,e))}function jOe(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function EGe(t){return function(){this.style.removeProperty(t)}}function CGe(t,e,n){return function(){this.style.setProperty(t,e,n)}}function zGe(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function YGe(t,e,n){return arguments.length>1?this.each((e==null?EGe:typeof e=="function"?zGe:CGe)(t,e,n??"")):Up(this.node(),t)}function Up(t,e){return t.style.getPropertyValue(e)||jOe(t).getComputedStyle(t,null).getPropertyValue(e)}function AGe(t){return function(){delete this[t]}}function qGe(t,e){return function(){this[t]=e}}function ZGe(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function VGe(t,e){return arguments.length>1?this.each((e==null?AGe:typeof e=="function"?ZGe:qGe)(t,e)):this.node()[t]}function EOe(t){return t.trim().split(/^|\s+/)}function KV(t){return t.classList||new COe(t)}function COe(t){this._node=t,this._names=EOe(t.getAttribute("class")||"")}COe.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function zOe(t,e){for(var n=KV(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function YOe(t,e){for(var n=KV(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function UGe(t){return function(){zOe(this,t)}}function NGe(t){return function(){YOe(this,t)}}function WGe(t,e){return function(){(e.apply(this,arguments)?zOe:YOe)(this,t)}}function MGe(t,e){var n=EOe(t+"");if(arguments.length<2){for(var r=KV(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?WGe:e?UGe:NGe)(n,e))}function IGe(){this.textContent=""}function DGe(t){return function(){this.textContent=t}}function LGe(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function GGe(t){return arguments.length?this.each(t==null?IGe:(typeof t=="function"?LGe:DGe)(t)):this.node().textContent}function BGe(){this.innerHTML=""}function FGe(t){return function(){this.innerHTML=t}}function HGe(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function KGe(t){return arguments.length?this.each(t==null?BGe:(typeof t=="function"?HGe:FGe)(t)):this.node().innerHTML}function JGe(){this.nextSibling&&this.parentNode.appendChild(this)}function eBe(){return this.each(JGe)}function tBe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nBe(){return this.each(tBe)}function rBe(t){var e=typeof t=="function"?t:TOe(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function iBe(){return null}function aBe(t,e){var n=typeof t=="function"?t:TOe(t),r=e==null?iBe:typeof e=="function"?e:HV(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function oBe(){var t=this.parentNode;t&&t.removeChild(this)}function sBe(){return this.each(oBe)}function lBe(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function cBe(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function uBe(t){return this.select(t?cBe:lBe)}function OBe(t){return arguments.length?this.property("__data__",t):this.node().__data__}function fBe(t){return function(e){t.call(this,e,this.__data__)}}function dBe(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function hBe(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,a;n<i;++n)a=e[n],(!t.type||a.type===t.type)&&a.name===t.name?this.removeEventListener(a.type,a.listener,a.options):e[++r]=a;++r?e.length=r:delete this.__on}}}function pBe(t,e,n){return function(){var r=this.__on,i,a=fBe(e);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=e;return}}this.addEventListener(t.type,a,n),i={type:t.type,name:t.name,value:e,listener:a,options:n},r?r.push(i):this.__on=[i]}}function mBe(t,e,n){var r=dBe(t+""),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,u;l<c;++l)for(i=0,u=s[l];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=e?pBe:hBe,i=0;i<a;++i)this.each(s(r[i],e,n));return this}function AOe(t,e,n){var r=jOe(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function gBe(t,e){return function(){return AOe(this,t,e)}}function yBe(t,e){return function(){return AOe(this,t,e.apply(this,arguments))}}function $Be(t,e){return this.each((typeof e=="function"?yBe:gBe)(t,e))}function*vBe(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var qOe=[null];function mo(t,e){this._groups=t,this._parents=e}function Ev(){return new mo([[document.documentElement]],qOe)}function xBe(){return this}mo.prototype=Ev.prototype={constructor:mo,select:LLe,selectAll:HLe,selectChild:tGe,selectChildren:aGe,filter:oGe,data:fGe,enter:sGe,exit:hGe,join:pGe,merge:mGe,selection:xBe,order:gGe,sort:yGe,call:vGe,nodes:xGe,node:QGe,size:bGe,empty:SGe,each:wGe,attr:jGe,style:YGe,property:VGe,classed:MGe,text:GGe,html:KGe,raise:eBe,lower:nBe,append:rBe,insert:aBe,remove:sBe,clone:uBe,datum:OBe,on:mBe,dispatch:$Be,[Symbol.iterator]:vBe};function oo(t){return typeof t=="string"?new mo([[document.querySelector(t)]],[document.documentElement]):new mo([[t]],qOe)}function QBe(t){let e;for(;e=t.sourceEvent;)t=e;return t}function ls(t,e){if(t=QBe(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const bBe={passive:!1},W$={capture:!0,passive:!1};function H2(t){t.stopImmediatePropagation()}function Vh(t){t.preventDefault(),t.stopImmediatePropagation()}function ZOe(t){var e=t.document.documentElement,n=oo(t).on("dragstart.drag",Vh,W$);"onselectstart"in e?n.on("selectstart.drag",Vh,W$):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function VOe(t,e){var n=t.document.documentElement,r=oo(t).on("dragstart.drag",null);e&&(r.on("click.drag",Vh,W$),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const GQ=t=>()=>t;function jA(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}jA.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function SBe(t){return!t.ctrlKey&&!t.button}function wBe(){return this.parentNode}function PBe(t,e){return e??{x:t.x,y:t.y}}function TBe(){return navigator.maxTouchPoints||"ontouchstart"in this}function UOe(){var t=SBe,e=wBe,n=PBe,r=TBe,i={},a=Yw("start","drag","end"),o=0,s,l,c,u,f=0;function h(T){T.on("mousedown.drag",p).filter(r).on("touchstart.drag",$).on("touchmove.drag",x,bBe).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(T,w){if(!(u||!t.call(this,T,w))){var P=b(this,e.call(this,T,w),T,w,"mouse");P&&(oo(T.view).on("mousemove.drag",y,W$).on("mouseup.drag",v,W$),ZOe(T.view),H2(T),c=!1,s=T.clientX,l=T.clientY,P("start",T))}}function y(T){if(Vh(T),!c){var w=T.clientX-s,P=T.clientY-l;c=w*w+P*P>f}i.mouse("drag",T)}function v(T){oo(T.view).on("mousemove.drag mouseup.drag",null),VOe(T.view,c),Vh(T),i.mouse("end",T)}function $(T,w){if(t.call(this,T,w)){var P=T.changedTouches,k=e.call(this,T,w),R=P.length,E,C;for(E=0;E<R;++E)(C=b(this,k,T,w,P[E].identifier,P[E]))&&(H2(T),C("start",T,P[E]))}}function x(T){var w=T.changedTouches,P=w.length,k,R;for(k=0;k<P;++k)(R=i[w[k].identifier])&&(Vh(T),R("drag",T,w[k]))}function S(T){var w=T.changedTouches,P=w.length,k,R;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<P;++k)(R=i[w[k].identifier])&&(H2(T),R("end",T,w[k]))}function b(T,w,P,k,R,E){var C=a.copy(),z=ls(E||P,w),Y,W,A;if((A=n.call(T,new jA("beforestart",{sourceEvent:P,target:h,identifier:R,active:o,x:z[0],y:z[1],dx:0,dy:0,dispatch:C}),k))!=null)return Y=A.x-z[0]||0,W=A.y-z[1]||0,function q(N,Z,D){var M=z,V;switch(N){case"start":i[R]=q,V=o++;break;case"end":delete i[R],--o;case"drag":z=ls(D||Z,w),V=o;break}C.call(N,T,new jA(N,{sourceEvent:Z,subject:A,target:h,identifier:R,active:V,x:z[0]+Y,y:z[1]+W,dx:z[0]-M[0],dy:z[1]-M[1],dispatch:C}),k)}}return h.filter=function(T){return arguments.length?(t=typeof T=="function"?T:GQ(!!T),h):t},h.container=function(T){return arguments.length?(e=typeof T=="function"?T:GQ(T),h):e},h.subject=function(T){return arguments.length?(n=typeof T=="function"?T:GQ(T),h):n},h.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:GQ(!!T),h):r},h.on=function(){var T=a.on.apply(a,arguments);return T===a?h:T},h.clickDistance=function(T){return arguments.length?(f=(T=+T)*T,h):Math.sqrt(f)},h}var Np=0,iy=0,Zg=0,NOe=1e3,B1,ay,F1=0,Mf=0,qw=0,M$=typeof performance=="object"&&performance.now?performance:Date,WOe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function JV(){return Mf||(WOe(kBe),Mf=M$.now()+qw)}function kBe(){Mf=0}function H1(){this._call=this._time=this._next=null}H1.prototype=MOe.prototype={constructor:H1,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?JV():+n)+(e==null?0:+e),!this._next&&ay!==this&&(ay?ay._next=this:B1=this,ay=this),this._call=t,this._time=n,EA()},stop:function(){this._call&&(this._call=null,this._time=1/0,EA())}};function MOe(t,e,n){var r=new H1;return r.restart(t,e,n),r}function _Be(){JV(),++Np;for(var t=B1,e;t;)(e=Mf-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Np}function mH(){Mf=(F1=M$.now())+qw,Np=iy=0;try{_Be()}finally{Np=0,RBe(),Mf=0}}function XBe(){var t=M$.now(),e=t-F1;e>NOe&&(qw-=e,F1=t)}function RBe(){for(var t,e=B1,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:B1=n);ay=t,EA(r)}function EA(t){if(!Np){iy&&(iy=clearTimeout(iy));var e=t-Mf;e>24?(t<1/0&&(iy=setTimeout(mH,t-M$.now()-qw)),Zg&&(Zg=clearInterval(Zg))):(Zg||(F1=M$.now(),Zg=setInterval(XBe,NOe)),Np=1,WOe(mH))}}function gH(t,e,n){var r=new H1;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var jBe=Yw("start","end","cancel","interrupt"),EBe=[],IOe=0,yH=1,CA=2,Wb=3,$H=4,zA=5,Mb=6;function Zw(t,e,n,r,i,a){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;CBe(t,n,{name:e,index:r,group:i,on:jBe,tween:EBe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:IOe})}function eU(t,e){var n=js(t,e);if(n.state>IOe)throw new Error("too late; already scheduled");return n}function Rl(t,e){var n=js(t,e);if(n.state>Wb)throw new Error("too late; already running");return n}function js(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function CBe(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=MOe(a,0,n.time);function a(c){n.state=yH,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,f,h,p;if(n.state!==yH)return l();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Wb)return gH(o);p.state===$H?(p.state=Mb,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=Mb,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(gH(function(){n.state===Wb&&(n.state=$H,n.timer.restart(s,n.delay,n.time),s(c))}),n.state=CA,n.on.call("start",t,t.__data__,n.index,n.group),n.state===CA){for(n.state=Wb,i=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(i[++f]=p);i.length=f+1}}function s(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=zA,1),f=-1,h=i.length;++f<h;)i[f].call(t,u);n.state===zA&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Mb,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Ib(t,e){var n=t.__transition,r,i,a=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((r=n[o]).name!==e){a=!1;continue}i=r.state>CA&&r.state<zA,r.state=Mb,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[o]}a&&delete t.__transition}}function zBe(t){return this.each(function(){Ib(this,t)})}function YBe(t,e){var n,r;return function(){var i=Rl(this,t),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===e){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ABe(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var a=Rl(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===e){i[l]=s;break}l===c&&i.push(s)}a.tween=i}}function qBe(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=js(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===t)return o.value;return null}return this.each((e==null?YBe:ABe)(n,t,e))}function tU(t,e,n){var r=t._id;return t.each(function(){var i=Rl(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return js(i,r).value[e]}}function DOe(t,e){var n;return(typeof e=="number"?Os:e instanceof Vf?u1:(n=Vf(e))?(e=n,u1):Ble)(t,e)}function ZBe(t){return function(){this.removeAttribute(t)}}function VBe(t){return function(){this.removeAttributeNS(t.space,t.local)}}function UBe(t,e,n){var r,i=n+"",a;return function(){var o=this.getAttribute(t);return o===i?null:o===r?a:a=e(r=o,n)}}function NBe(t,e,n){var r,i=n+"",a;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===r?a:a=e(r=o,n)}}function WBe(t,e,n){var r,i,a;return function(){var o,s=n(this),l;return s==null?void this.removeAttribute(t):(o=this.getAttribute(t),l=s+"",o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s)))}}function MBe(t,e,n){var r,i,a;return function(){var o,s=n(this),l;return s==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),l=s+"",o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s)))}}function IBe(t,e){var n=Aw(t),r=n==="transform"?dUe:DOe;return this.attrTween(t,typeof e=="function"?(n.local?MBe:WBe)(n,r,tU(this,"attr."+t,e)):e==null?(n.local?VBe:ZBe)(n):(n.local?NBe:UBe)(n,r,e))}function DBe(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function LBe(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function GBe(t,e){var n,r;function i(){var a=e.apply(this,arguments);return a!==r&&(n=(r=a)&&LBe(t,a)),n}return i._value=e,i}function BBe(t,e){var n,r;function i(){var a=e.apply(this,arguments);return a!==r&&(n=(r=a)&&DBe(t,a)),n}return i._value=e,i}function FBe(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Aw(t);return this.tween(n,(r.local?GBe:BBe)(r,e))}function HBe(t,e){return function(){eU(this,t).delay=+e.apply(this,arguments)}}function KBe(t,e){return e=+e,function(){eU(this,t).delay=e}}function JBe(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?HBe:KBe)(e,t)):js(this.node(),e).delay}function eFe(t,e){return function(){Rl(this,t).duration=+e.apply(this,arguments)}}function tFe(t,e){return e=+e,function(){Rl(this,t).duration=e}}function nFe(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?eFe:tFe)(e,t)):js(this.node(),e).duration}function rFe(t,e){if(typeof e!="function")throw new Error;return function(){Rl(this,t).ease=e}}function iFe(t){var e=this._id;return arguments.length?this.each(rFe(e,t)):js(this.node(),e).ease}function aFe(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Rl(this,t).ease=n}}function oFe(t){if(typeof t!="function")throw new Error;return this.each(aFe(this._id,t))}function sFe(t){typeof t!="function"&&(t=_Oe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=[],l,c=0;c<o;++c)(l=a[c])&&t.call(l,l.__data__,c,a)&&s.push(l);return new Nc(r,this._parents,this._name,this._id)}function lFe(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l=e[s],c=n[s],u=l.length,f=o[s]=new Array(u),h,p=0;p<u;++p)(h=l[p]||c[p])&&(f[p]=h);for(;s<r;++s)o[s]=e[s];return new Nc(o,this._parents,this._name,this._id)}function cFe(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function uFe(t,e,n){var r,i,a=cFe(e)?eU:Rl;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}function OFe(t,e){var n=this._id;return arguments.length<2?js(this.node(),n).on.on(t):this.each(uFe(n,t,e))}function fFe(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function dFe(){return this.on("end.remove",fFe(this._id))}function hFe(t){var e=this._name,n=this._id;typeof t!="function"&&(t=HV(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s=r[o],l=s.length,c=a[o]=new Array(l),u,f,h=0;h<l;++h)(u=s[h])&&(f=t.call(u,u.__data__,h,s))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,Zw(c[h],e,n,h,c,js(u,n)));return new Nc(a,this._parents,e,n)}function pFe(t){var e=this._name,n=this._id;typeof t!="function"&&(t=kOe(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l=r[s],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var h=t.call(u,u.__data__,f,l),p,y=js(u,n),v=0,$=h.length;v<$;++v)(p=h[v])&&Zw(p,e,n,v,h,y);a.push(h),o.push(u)}return new Nc(a,o,e,n)}var mFe=Ev.prototype.constructor;function gFe(){return new mFe(this._groups,this._parents)}function yFe(t,e){var n,r,i;return function(){var a=Up(this,t),o=(this.style.removeProperty(t),Up(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}function LOe(t){return function(){this.style.removeProperty(t)}}function $Fe(t,e,n){var r,i=n+"",a;return function(){var o=Up(this,t);return o===i?null:o===r?a:a=e(r=o,n)}}function vFe(t,e,n){var r,i,a;return function(){var o=Up(this,t),s=n(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(t),Up(this,t))),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}function xFe(t,e){var n,r,i,a="style."+e,o="end."+a,s;return function(){var l=Rl(this,t),c=l.on,u=l.value[a]==null?s||(s=LOe(e)):void 0;(c!==n||i!==u)&&(r=(n=c).copy()).on(o,i=u),l.on=r}}function QFe(t,e,n){var r=(t+="")=="transform"?fUe:DOe;return e==null?this.styleTween(t,yFe(t,r)).on("end.style."+t,LOe(t)):typeof e=="function"?this.styleTween(t,vFe(t,r,tU(this,"style."+t,e))).each(xFe(this._id,t)):this.styleTween(t,$Fe(t,r,e),n).on("end.style."+t,null)}function bFe(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function SFe(t,e,n){var r,i;function a(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&bFe(t,o,n)),r}return a._value=e,a}function wFe(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,SFe(t,e,n??""))}function PFe(t){return function(){this.textContent=t}}function TFe(t){return function(){var e=t(this);this.textContent=e??""}}function kFe(t){return this.tween("text",typeof t=="function"?TFe(tU(this,"text",t)):PFe(t==null?"":t+""))}function _Fe(t){return function(e){this.textContent=t.call(this,e)}}function XFe(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&_Fe(i)),e}return r._value=t,r}function RFe(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,XFe(t))}function jFe(){for(var t=this._name,e=this._id,n=GOe(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,l,c=0;c<s;++c)if(l=o[c]){var u=js(l,e);Zw(l,t,n,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Nc(r,this._parents,t,n)}function EFe(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},l={value:function(){--i===0&&a()}};n.each(function(){var c=Rl(this,r),u=c.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),c.on=e}),i===0&&a()})}var CFe=0;function Nc(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function GOe(){return++CFe}var oc=Ev.prototype;Nc.prototype={constructor:Nc,select:hFe,selectAll:pFe,selectChild:oc.selectChild,selectChildren:oc.selectChildren,filter:sFe,merge:lFe,selection:gFe,transition:jFe,call:oc.call,nodes:oc.nodes,node:oc.node,size:oc.size,empty:oc.empty,each:oc.each,on:OFe,attr:IBe,attrTween:FBe,style:QFe,styleTween:wFe,text:kFe,textTween:RFe,remove:dFe,tween:qBe,delay:JBe,duration:nFe,ease:iFe,easeVarying:oFe,end:EFe,[Symbol.iterator]:oc[Symbol.iterator]};function zFe(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var YFe={time:null,delay:0,duration:250,ease:zFe};function AFe(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function qFe(t){var e,n;t instanceof Nc?(e=t._id,t=t._name):(e=GOe(),(n=YFe).time=JV(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,l,c=0;c<s;++c)(l=o[c])&&Zw(l,t,e,c,o,n||AFe(l,e));return new Nc(r,this._parents,t,e)}Ev.prototype.interrupt=zBe;Ev.prototype.transition=qFe;const BQ=t=>()=>t;function ZFe(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function xc(t,e,n){this.k=t,this.x=e,this.y=n}xc.prototype={constructor:xc,scale:function(t){return t===1?this:new xc(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new xc(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vw=new xc(1,0,0);BOe.prototype=xc.prototype;function BOe(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vw;return t.__zoom}function K2(t){t.stopImmediatePropagation()}function Vg(t){t.preventDefault(),t.stopImmediatePropagation()}function VFe(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function UFe(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function vH(){return this.__zoom||Vw}function NFe(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function WFe(){return navigator.maxTouchPoints||"ontouchstart"in this}function MFe(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function FOe(){var t=VFe,e=UFe,n=MFe,r=NFe,i=WFe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,l=Vb,c=Yw("start","zoom","end"),u,f,h,p=500,y=150,v=0,$=10;function x(A){A.property("__zoom",vH).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",C).filter(i).on("touchstart.zoom",z).on("touchmove.zoom",Y).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(A,q,N,Z){var D=A.selection?A.selection():A;D.property("__zoom",vH),A!==D?w(A,q,N,Z):D.interrupt().each(function(){P(this,arguments).event(Z).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},x.scaleBy=function(A,q,N,Z){x.scaleTo(A,function(){var D=this.__zoom.k,M=typeof q=="function"?q.apply(this,arguments):q;return D*M},N,Z)},x.scaleTo=function(A,q,N,Z){x.transform(A,function(){var D=e.apply(this,arguments),M=this.__zoom,V=N==null?T(D):typeof N=="function"?N.apply(this,arguments):N,I=M.invert(V),B=typeof q=="function"?q.apply(this,arguments):q;return n(b(S(M,B),V,I),D,o)},N,Z)},x.translateBy=function(A,q,N,Z){x.transform(A,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof N=="function"?N.apply(this,arguments):N),e.apply(this,arguments),o)},null,Z)},x.translateTo=function(A,q,N,Z,D){x.transform(A,function(){var M=e.apply(this,arguments),V=this.__zoom,I=Z==null?T(M):typeof Z=="function"?Z.apply(this,arguments):Z;return n(Vw.translate(I[0],I[1]).scale(V.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof N=="function"?-N.apply(this,arguments):-N),M,o)},Z,D)};function S(A,q){return q=Math.max(a[0],Math.min(a[1],q)),q===A.k?A:new xc(q,A.x,A.y)}function b(A,q,N){var Z=q[0]-N[0]*A.k,D=q[1]-N[1]*A.k;return Z===A.x&&D===A.y?A:new xc(A.k,Z,D)}function T(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function w(A,q,N,Z){A.on("start.zoom",function(){P(this,arguments).event(Z).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(Z).end()}).tween("zoom",function(){var D=this,M=arguments,V=P(D,M).event(Z),I=e.apply(D,M),B=N==null?T(I):typeof N=="function"?N.apply(D,M):N,L=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),J=D.__zoom,K=typeof q=="function"?q.apply(D,M):q,H=l(J.invert(B).concat(L/J.k),K.invert(B).concat(L/K.k));return function(re){if(re===1)re=K;else{var F=H(re),te=L/F[2];re=new xc(te,B[0]-F[0]*te,B[1]-F[1]*te)}V.zoom(null,re)}})}function P(A,q,N){return!N&&A.__zooming||new k(A,q)}function k(A,q){this.that=A,this.args=q,this.active=0,this.sourceEvent=null,this.extent=e.apply(A,q),this.taps=0}k.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,q){return this.mouse&&A!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var q=oo(this.that).datum();c.call(A,this.that,new ZFe(A,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:c}),q)}};function R(A,...q){if(!t.apply(this,arguments))return;var N=P(this,q).event(A),Z=this.__zoom,D=Math.max(a[0],Math.min(a[1],Z.k*Math.pow(2,r.apply(this,arguments)))),M=ls(A);if(N.wheel)(N.mouse[0][0]!==M[0]||N.mouse[0][1]!==M[1])&&(N.mouse[1]=Z.invert(N.mouse[0]=M)),clearTimeout(N.wheel);else{if(Z.k===D)return;N.mouse=[M,Z.invert(M)],Ib(this),N.start()}Vg(A),N.wheel=setTimeout(V,y),N.zoom("mouse",n(b(S(Z,D),N.mouse[0],N.mouse[1]),N.extent,o));function V(){N.wheel=null,N.end()}}function E(A,...q){if(h||!t.apply(this,arguments))return;var N=A.currentTarget,Z=P(this,q,!0).event(A),D=oo(A.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",L,!0),M=ls(A,N),V=A.clientX,I=A.clientY;ZOe(A.view),K2(A),Z.mouse=[M,this.__zoom.invert(M)],Ib(this),Z.start();function B(J){if(Vg(J),!Z.moved){var K=J.clientX-V,H=J.clientY-I;Z.moved=K*K+H*H>v}Z.event(J).zoom("mouse",n(b(Z.that.__zoom,Z.mouse[0]=ls(J,N),Z.mouse[1]),Z.extent,o))}function L(J){D.on("mousemove.zoom mouseup.zoom",null),VOe(J.view,Z.moved),Vg(J),Z.event(J).end()}}function C(A,...q){if(t.apply(this,arguments)){var N=this.__zoom,Z=ls(A.changedTouches?A.changedTouches[0]:A,this),D=N.invert(Z),M=N.k*(A.shiftKey?.5:2),V=n(b(S(N,M),Z,D),e.apply(this,q),o);Vg(A),s>0?oo(this).transition().duration(s).call(w,V,Z,A):oo(this).call(x.transform,V,Z,A)}}function z(A,...q){if(t.apply(this,arguments)){var N=A.touches,Z=N.length,D=P(this,q,A.changedTouches.length===Z).event(A),M,V,I,B;for(K2(A),V=0;V<Z;++V)I=N[V],B=ls(I,this),B=[B,this.__zoom.invert(B),I.identifier],D.touch0?!D.touch1&&D.touch0[2]!==B[2]&&(D.touch1=B,D.taps=0):(D.touch0=B,M=!0,D.taps=1+!!u);u&&(u=clearTimeout(u)),M&&(D.taps<2&&(f=B[0],u=setTimeout(function(){u=null},p)),Ib(this),D.start())}}function Y(A,...q){if(this.__zooming){var N=P(this,q).event(A),Z=A.changedTouches,D=Z.length,M,V,I,B;for(Vg(A),M=0;M<D;++M)V=Z[M],I=ls(V,this),N.touch0&&N.touch0[2]===V.identifier?N.touch0[0]=I:N.touch1&&N.touch1[2]===V.identifier&&(N.touch1[0]=I);if(V=N.that.__zoom,N.touch1){var L=N.touch0[0],J=N.touch0[1],K=N.touch1[0],H=N.touch1[1],re=(re=K[0]-L[0])*re+(re=K[1]-L[1])*re,F=(F=H[0]-J[0])*F+(F=H[1]-J[1])*F;V=S(V,Math.sqrt(re/F)),I=[(L[0]+K[0])/2,(L[1]+K[1])/2],B=[(J[0]+H[0])/2,(J[1]+H[1])/2]}else if(N.touch0)I=N.touch0[0],B=N.touch0[1];else return;N.zoom("touch",n(b(V,I,B),N.extent,o))}}function W(A,...q){if(this.__zooming){var N=P(this,q).event(A),Z=A.changedTouches,D=Z.length,M,V;for(K2(A),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),M=0;M<D;++M)V=Z[M],N.touch0&&N.touch0[2]===V.identifier?delete N.touch0:N.touch1&&N.touch1[2]===V.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(V=ls(V,this),Math.hypot(f[0]-V[0],f[1]-V[1])<$)){var I=oo(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return x.wheelDelta=function(A){return arguments.length?(r=typeof A=="function"?A:BQ(+A),x):r},x.filter=function(A){return arguments.length?(t=typeof A=="function"?A:BQ(!!A),x):t},x.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:BQ(!!A),x):i},x.extent=function(A){return arguments.length?(e=typeof A=="function"?A:BQ([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),x):e},x.scaleExtent=function(A){return arguments.length?(a[0]=+A[0],a[1]=+A[1],x):[a[0],a[1]]},x.translateExtent=function(A){return arguments.length?(o[0][0]=+A[0][0],o[1][0]=+A[1][0],o[0][1]=+A[0][1],o[1][1]=+A[1][1],x):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},x.constrain=function(A){return arguments.length?(n=A,x):n},x.duration=function(A){return arguments.length?(s=+A,x):s},x.interpolate=function(A){return arguments.length?(l=A,x):l},x.on=function(){var A=c.on.apply(c,arguments);return A===c?x:A},x.clickDistance=function(A){return arguments.length?(v=(A=+A)*A,x):Math.sqrt(v)},x.tapDistance=function(A){return arguments.length?($=+A,x):$},x}const Ss={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},I$=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],HOe=["Enter"," ","Escape"],KOe={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Wp;(function(t){t.Strict="strict",t.Loose="loose"})(Wp||(Wp={}));var Xf;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Xf||(Xf={}));var D$;(function(t){t.Partial="partial",t.Full="full"})(D$||(D$={}));const JOe={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Wu;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Wu||(Wu={}));var K1;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(K1||(K1={}));var Ce;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Ce||(Ce={}));const xH={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top};function IFe(t,e){if(!t&&!e)return!0;if(!t||!e||t.size!==e.size)return!1;if(!t.size&&!e.size)return!0;for(const n of t.keys())if(!e.has(n))return!1;return!0}function QH(t,e,n){if(!n)return;const r=[];t.forEach((i,a)=>{e!=null&&e.has(a)||r.push(i)}),r.length&&n(r)}function efe(t){return t===null?null:t?"valid":"invalid"}const tfe=t=>"id"in t&&"source"in t&&"target"in t,DFe=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),nU=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Cv=(t,e=[0,0])=>{const{width:n,height:r}=Bc(t),i=t.origin??e,a=n*i[0],o=r*i[1];return{x:t.position.x-a,y:t.position.y-o}},LFe=(t,e={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,i)=>{const a=typeof i=="string";let o=!e.nodeLookup&&!a?i:void 0;e.nodeLookup&&(o=a?e.nodeLookup.get(i):nU(i)?i:e.nodeLookup.get(i.id));const s=o?J1(o,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Uw(r,s)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nw(n)},zv=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return t.forEach(i=>{(e.filter===void 0||e.filter(i))&&(n=Uw(n,J1(i)),r=!0)}),r?Nw(n):{x:0,y:0,width:0,height:0}},rU=(t,e,[n,r,i]=[0,0,1],a=!1,o=!1)=>{const s={...Av(e,[n,r,i]),width:e.width/i,height:e.height/i},l=[];for(const c of t.values()){const{measured:u,selectable:f=!0,hidden:h=!1}=c;if(o&&!f||h)continue;const p=u.width??c.width??c.initialWidth??null,y=u.height??c.height??c.initialHeight??null,v=L$(s,Ip(c)),$=(p??0)*(y??0),x=a&&v>0;(!c.internals.handleBounds||x||v>=$||c.dragging)&&l.push(c)}return l},GFe=(t,e)=>{const n=new Set;return t.forEach(r=>{n.add(r.id)}),e.filter(r=>n.has(r.source)||n.has(r.target))};function BFe(t,e){const n=new Map,r=e!=null&&e.nodes?new Set(e.nodes.map(i=>i.id)):null;return t.forEach(i=>{i.measured.width&&i.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function FFe({nodes:t,width:e,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(t.size===0)return Promise.resolve(!0);const s=BFe(t,o),l=zv(s),c=iU(l,e,n,(o==null?void 0:o.minZoom)??i,(o==null?void 0:o.maxZoom)??a,(o==null?void 0:o.padding)??.1);return await r.setViewport(c,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),Promise.resolve(!0)}function nfe({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){const o=n.get(t),s=o.parentId?n.get(o.parentId):void 0,{x:l,y:c}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r;let f=o.extent||i;if(o.extent==="parent"&&!o.expandParent)if(!s)a==null||a("005",Ss.error005());else{const p=s.measured.width,y=s.measured.height;p&&y&&(f=[[l,c],[l+p,c+y]])}else s&&Dp(o.extent)&&(f=[[o.extent[0][0]+l,o.extent[0][1]+c],[o.extent[1][0]+l,o.extent[1][1]+c]]);const h=Dp(f)?If(e,f,o.measured):e;return(o.measured.width===void 0||o.measured.height===void 0)&&(a==null||a("015",Ss.error015())),{position:{x:h.x-l+(o.measured.width??0)*u[0],y:h.y-c+(o.measured.height??0)*u[1]},positionAbsolute:h}}async function HFe({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:i}){const a=new Set(t.map(h=>h.id)),o=[];for(const h of n){if(h.deletable===!1)continue;const p=a.has(h.id),y=!p&&h.parentId&&o.find(v=>v.id===h.parentId);(p||y)&&o.push(h)}const s=new Set(e.map(h=>h.id)),l=r.filter(h=>h.deletable!==!1),u=GFe(o,l);for(const h of l)s.has(h.id)&&!u.find(y=>y.id===h.id)&&u.push(h);if(!i)return{edges:u,nodes:o};const f=await i({nodes:o,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:o}:{edges:[],nodes:[]}:f}const Mp=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),If=(t={x:0,y:0},e,n)=>({x:Mp(t.x,e[0][0],e[1][0]-((n==null?void 0:n.width)??0)),y:Mp(t.y,e[0][1],e[1][1]-((n==null?void 0:n.height)??0))});function rfe(t,e,n){const{width:r,height:i}=Bc(n),{x:a,y:o}=n.internals.positionAbsolute;return If(t,[[a,o],[a+r,o+i]],e)}const bH=(t,e,n)=>t<e?Mp(Math.abs(t-e),1,e)/e:t>n?-Mp(Math.abs(t-n),1,e)/e:0,ife=(t,e,n=15,r=40)=>{const i=bH(t.x,r,e.width-r)*n,a=bH(t.y,r,e.height-r)*n;return[i,a]},Uw=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),YA=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),Nw=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Ip=(t,e=[0,0])=>{var i,a;const{x:n,y:r}=nU(t)?t.internals.positionAbsolute:Cv(t,e);return{x:n,y:r,width:((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0,height:((a=t.measured)==null?void 0:a.height)??t.height??t.initialHeight??0}},J1=(t,e=[0,0])=>{var i,a;const{x:n,y:r}=nU(t)?t.internals.positionAbsolute:Cv(t,e);return{x:n,y:r,x2:n+(((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0),y2:r+(((a=t.measured)==null?void 0:a.height)??t.height??t.initialHeight??0)}},afe=(t,e)=>Nw(Uw(YA(t),YA(e))),L$=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},SH=t=>ms(t.width)&&ms(t.height)&&ms(t.x)&&ms(t.y),ms=t=>!isNaN(t)&&isFinite(t),KFe=(t,e)=>{},Yv=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),Av=({x:t,y:e},[n,r,i],a=!1,o=[1,1])=>{const s={x:(t-n)/i,y:(e-r)/i};return a?Yv(s,o):s},eS=({x:t,y:e},[n,r,i])=>({x:t*i+n,y:e*i+r});function Oh(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function JFe(t,e,n){if(typeof t=="string"||typeof t=="number"){const r=Oh(t,n),i=Oh(t,e);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof t=="object"){const r=Oh(t.top??t.y??0,n),i=Oh(t.bottom??t.y??0,n),a=Oh(t.left??t.x??0,e),o=Oh(t.right??t.x??0,e);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function eHe(t,e,n,r,i,a){const{x:o,y:s}=eS(t,[e,n,r]),{x:l,y:c}=eS({x:t.x+t.width,y:t.y+t.height},[e,n,r]),u=i-l,f=a-c;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(f)}}const iU=(t,e,n,r,i,a)=>{const o=JFe(a,e,n),s=(e-o.x)/t.width,l=(n-o.y)/t.height,c=Math.min(s,l),u=Mp(c,r,i),f=t.x+t.width/2,h=t.y+t.height/2,p=e/2-f*u,y=n/2-h*u,v=eHe(t,p,y,u,e,n),$={left:Math.min(v.left-o.left,0),top:Math.min(v.top-o.top,0),right:Math.min(v.right-o.right,0),bottom:Math.min(v.bottom-o.bottom,0)};return{x:p-$.left+$.right,y:y-$.top+$.bottom,zoom:u}},G$=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Dp(t){return t!=null&&t!=="parent"}function Bc(t){var e,n;return{width:((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function ofe(t){var e,n;return(((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function sfe(t,e={width:0,height:0},n,r,i){const a={...t},o=r.get(n);if(o){const s=o.origin||i;a.x+=o.internals.positionAbsolute.x-(e.width??0)*s[0],a.y+=o.internals.positionAbsolute.y-(e.height??0)*s[1]}return a}function wH(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function tHe(){let t,e;return{promise:new Promise((r,i)=>{t=r,e=i}),resolve:t,reject:e}}function nHe(t){return{...KOe,...t||{}}}function ky(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:a,y:o}=gs(t),s=Av({x:a-((i==null?void 0:i.left)??0),y:o-((i==null?void 0:i.top)??0)},r),{x:l,y:c}=n?Yv(s,e):s;return{xSnapped:l,ySnapped:c,...s}}const aU=t=>({width:t.offsetWidth,height:t.offsetHeight}),lfe=t=>{var e;return((e=t==null?void 0:t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},rHe=["INPUT","SELECT","TEXTAREA"];function cfe(t){var r,i;const e=((i=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:i[0])||t.target;return(e==null?void 0:e.nodeType)!==1?!1:rHe.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}const ufe=t=>"clientX"in t,gs=(t,e)=>{var a,o;const n=ufe(t),r=n?t.clientX:(a=t.touches)==null?void 0:a[0].clientX,i=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:i-((e==null?void 0:e.top)??0)}},PH=(t,e,n,r,i)=>{const a=e.querySelectorAll(`.${t}`);return!a||!a.length?null:Array.from(a).map(o=>{const s=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:t,nodeId:i,position:o.getAttribute("data-handlepos"),x:(s.left-n.left)/r,y:(s.top-n.top)/r,...aU(o)}})};function Ofe({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){const l=t*.125+i*.375+o*.375+n*.125,c=e*.125+a*.375+s*.375+r*.125,u=Math.abs(l-t),f=Math.abs(c-e);return[l,c,u,f]}function FQ(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function TH({pos:t,x1:e,y1:n,x2:r,y2:i,c:a}){switch(t){case Ce.Left:return[e-FQ(e-r,a),n];case Ce.Right:return[e+FQ(r-e,a),n];case Ce.Top:return[e,n-FQ(n-i,a)];case Ce.Bottom:return[e,n+FQ(i-n,a)]}}function Qm({sourceX:t,sourceY:e,sourcePosition:n=Ce.Bottom,targetX:r,targetY:i,targetPosition:a=Ce.Top,curvature:o=.25}){const[s,l]=TH({pos:n,x1:t,y1:e,x2:r,y2:i,c:o}),[c,u]=TH({pos:a,x1:r,y1:i,x2:t,y2:e,c:o}),[f,h,p,y]=Ofe({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${e} C${s},${l} ${c},${u} ${r},${i}`,f,h,p,y]}function ffe({sourceX:t,sourceY:e,targetX:n,targetY:r}){const i=Math.abs(n-t)/2,a=n<t?n+i:n-i,o=Math.abs(r-e)/2,s=r<e?r+o:r-o;return[a,s,i,o]}function iHe({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const o=i&&n?r+1e3:r,s=Math.max(t.parentId||i&&t.selected?t.internals.z:0,e.parentId||i&&e.selected?e.internals.z:0);return o+s}function aHe({sourceNode:t,targetNode:e,width:n,height:r,transform:i}){const a=Uw(J1(t),J1(e));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const o={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return L$(o,Nw(a))>0}const oHe=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,sHe=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),lHe=(t,e,n={})=>{if(!t.source||!t.target)return e;const r=n.getEdgeId||oHe;let i;return tfe(t)?i={...t}:i={...t,id:r(t)},sHe(i,e)?e:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,e.concat(i))};function oU({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[i,a,o,s]=ffe({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,i,a,o,s]}const kH={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},cHe=({source:t,sourcePosition:e=Ce.Bottom,target:n})=>e===Ce.Left||e===Ce.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},_H=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function uHe({source:t,sourcePosition:e=Ce.Bottom,target:n,targetPosition:r=Ce.Top,center:i,offset:a,stepPosition:o}){const s=kH[e],l=kH[r],c={x:t.x+s.x*a,y:t.y+s.y*a},u={x:n.x+l.x*a,y:n.y+l.y*a},f=cHe({source:c,sourcePosition:e,target:u}),h=f.x!==0?"x":"y",p=f[h];let y=[],v,$;const x={x:0,y:0},S={x:0,y:0},[,,b,T]=ffe({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(s[h]*l[h]===-1){h==="x"?(v=i.x??c.x+(u.x-c.x)*o,$=i.y??(c.y+u.y)/2):(v=i.x??(c.x+u.x)/2,$=i.y??c.y+(u.y-c.y)*o);const P=[{x:v,y:c.y},{x:v,y:u.y}],k=[{x:c.x,y:$},{x:u.x,y:$}];s[h]===p?y=h==="x"?P:k:y=h==="x"?k:P}else{const P=[{x:c.x,y:u.y}],k=[{x:u.x,y:c.y}];if(h==="x"?y=s.x===p?k:P:y=s.y===p?P:k,e===r){const Y=Math.abs(t[h]-n[h]);if(Y<=a){const W=Math.min(a-1,a-Y);s[h]===p?x[h]=(c[h]>t[h]?-1:1)*W:S[h]=(u[h]>n[h]?-1:1)*W}}if(e!==r){const Y=h==="x"?"y":"x",W=s[h]===l[Y],A=c[Y]>u[Y],q=c[Y]<u[Y];(s[h]===1&&(!W&&A||W&&q)||s[h]!==1&&(!W&&q||W&&A))&&(y=h==="x"?P:k)}const R={x:c.x+x.x,y:c.y+x.y},E={x:u.x+S.x,y:u.y+S.y},C=Math.max(Math.abs(R.x-y[0].x),Math.abs(E.x-y[0].x)),z=Math.max(Math.abs(R.y-y[0].y),Math.abs(E.y-y[0].y));C>=z?(v=(R.x+E.x)/2,$=y[0].y):(v=y[0].x,$=(R.y+E.y)/2)}return[[t,{x:c.x+x.x,y:c.y+x.y},...y,{x:u.x+S.x,y:u.y+S.y},n],v,$,b,T]}function OHe(t,e,n,r){const i=Math.min(_H(t,e)/2,_H(e,n)/2,r),{x:a,y:o}=e;if(t.x===a&&a===n.x||t.y===o&&o===n.y)return`L${a} ${o}`;if(t.y===o){const c=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${a+i*c},${o}Q ${a},${o} ${a},${o+i*u}`}const s=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${a},${o+i*l}Q ${a},${o} ${a+i*s},${o}`}function Lp({sourceX:t,sourceY:e,sourcePosition:n=Ce.Bottom,targetX:r,targetY:i,targetPosition:a=Ce.Top,borderRadius:o=5,centerX:s,centerY:l,offset:c=20,stepPosition:u=.5}){const[f,h,p,y,v]=uHe({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:l},offset:c,stepPosition:u});return[f.reduce((x,S,b)=>{let T="";return b>0&&b<f.length-1?T=OHe(f[b-1],S,f[b+1],o):T=`${b===0?"M":"L"}${S.x} ${S.y}`,x+=T,x},""),h,p,y,v]}function XH(t){var e;return t&&!!(t.internals.handleBounds||(e=t.handles)!=null&&e.length)&&!!(t.measured.width||t.width||t.initialWidth)}function fHe(t){var f;const{sourceNode:e,targetNode:n}=t;if(!XH(e)||!XH(n))return null;const r=e.internals.handleBounds||RH(e.handles),i=n.internals.handleBounds||RH(n.handles),a=jH((r==null?void 0:r.source)??[],t.sourceHandle),o=jH(t.connectionMode===Wp.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),t.targetHandle);if(!a||!o)return(f=t.onError)==null||f.call(t,"008",Ss.error008(a?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const s=(a==null?void 0:a.position)||Ce.Bottom,l=(o==null?void 0:o.position)||Ce.Top,c=Df(e,a,s),u=Df(n,o,l);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:l}}function RH(t){if(!t)return null;const e=[],n=[];for(const r of t)r.width=r.width??1,r.height=r.height??1,r.type==="source"?e.push(r):r.type==="target"&&n.push(r);return{source:e,target:n}}function Df(t,e,n=Ce.Left,r=!1){const i=((e==null?void 0:e.x)??0)+t.internals.positionAbsolute.x,a=((e==null?void 0:e.y)??0)+t.internals.positionAbsolute.y,{width:o,height:s}=e??Bc(t);if(r)return{x:i+o/2,y:a+s/2};switch((e==null?void 0:e.position)??n){case Ce.Top:return{x:i+o/2,y:a};case Ce.Right:return{x:i+o,y:a+s/2};case Ce.Bottom:return{x:i+o/2,y:a+s};case Ce.Left:return{x:i,y:a+s/2}}}function jH(t,e){return t&&(e?t.find(n=>n.id===e):t[0])||null}function AA(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`:""}function dHe(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const a=new Set;return t.reduce((o,s)=>([s.markerStart||r,s.markerEnd||i].forEach(l=>{if(l&&typeof l=="object"){const c=AA(l,e);a.has(c)||(o.push({id:c,color:l.color||n,...l}),a.add(c))}}),o),[]).sort((o,s)=>o.id.localeCompare(s.id))}const dfe=1e3,hHe=10,sU={nodeOrigin:[0,0],nodeExtent:I$,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},pHe={...sU,checkEquality:!0};function lU(t,e){const n={...t};for(const r in e)e[r]!==void 0&&(n[r]=e[r]);return n}function mHe(t,e,n){const r=lU(sU,n);for(const i of t.values())if(i.parentId)uU(i,t,e,r);else{const a=Cv(i,r.nodeOrigin),o=Dp(i.extent)?i.extent:r.nodeExtent,s=If(a,o,Bc(i));i.internals.positionAbsolute=s}}function gHe(t,e){if(!t.handles)return t.measured?e==null?void 0:e.internals.handleBounds:void 0;const n=[],r=[];for(const i of t.handles){const a={id:i.id,width:i.width??1,height:i.height??1,nodeId:t.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(a):i.type==="target"&&r.push(a)}return{source:n,target:r}}function cU(t){return t==="manual"}function qA(t,e,n,r={}){var c,u;const i=lU(pHe,r),a={i:0},o=new Map(e),s=i!=null&&i.elevateNodesOnSelect&&!cU(i.zIndexMode)?dfe:0;let l=t.length>0;e.clear(),n.clear();for(const f of t){let h=o.get(f.id);if(i.checkEquality&&f===(h==null?void 0:h.internals.userNode))e.set(f.id,h);else{const p=Cv(f,i.nodeOrigin),y=Dp(f.extent)?f.extent:i.nodeExtent,v=If(p,y,Bc(f));h={...i.defaults,...f,measured:{width:(c=f.measured)==null?void 0:c.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:v,handleBounds:gHe(f,h),z:hfe(f,s,i.zIndexMode),userNode:f}},e.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),f.parentId&&uU(h,e,n,r,a)}return l}function yHe(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function uU(t,e,n,r,i){const{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:l}=lU(sU,r),c=t.parentId,u=e.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}yHe(t,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*hHe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);const f=a&&!cU(l)?dfe:0,{x:h,y:p,z:y}=$He(t,u,o,s,f,l),{positionAbsolute:v}=t.internals,$=h!==v.x||p!==v.y;($||y!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:$?{x:h,y:p}:v,z:y}})}function hfe(t,e,n){const r=ms(t.zIndex)?t.zIndex:0;return cU(n)?r:r+(t.selected?e:0)}function $He(t,e,n,r,i,a){const{x:o,y:s}=e.internals.positionAbsolute,l=Bc(t),c=Cv(t,n),u=Dp(t.extent)?If(c,t.extent,l):c;let f=If({x:o+u.x,y:s+u.y},r,l);t.extent==="parent"&&(f=rfe(f,l,e));const h=hfe(t,i,a),p=e.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function OU(t,e,n,r=[0,0]){var o;const i=[],a=new Map;for(const s of t){const l=e.get(s.parentId);if(!l)continue;const c=((o=a.get(s.parentId))==null?void 0:o.expandedRect)??Ip(l),u=afe(c,s.rect);a.set(s.parentId,{expandedRect:u,parent:l})}return a.size>0&&a.forEach(({expandedRect:s,parent:l},c)=>{var b;const u=l.internals.positionAbsolute,f=Bc(l),h=l.origin??r,p=s.x<u.x?Math.round(Math.abs(u.x-s.x)):0,y=s.y<u.y?Math.round(Math.abs(u.y-s.y)):0,v=Math.max(f.width,Math.round(s.width)),$=Math.max(f.height,Math.round(s.height)),x=(v-f.width)*h[0],S=($-f.height)*h[1];(p>0||y>0||x||S)&&(i.push({id:c,type:"position",position:{x:l.position.x-p+x,y:l.position.y-y+S}}),(b=n.get(c))==null||b.forEach(T=>{t.some(w=>w.id===T.id)||i.push({id:T.id,type:"position",position:{x:T.position.x+p,y:T.position.y+y}})})),(f.width<s.width||f.height<s.height||p||y)&&i.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?h[0]*p-x:0),height:$+(y?h[1]*y-S:0)}})}),i}function vHe(t,e,n,r,i,a,o){const s=r==null?void 0:r.querySelector(".xyflow__viewport");let l=!1;if(!s)return{changes:[],updatedInternals:l};const c=[],u=window.getComputedStyle(s),{m22:f}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const p of t.values()){const y=e.get(p.id);if(!y)continue;if(y.hidden){e.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),l=!0;continue}const v=aU(p.nodeElement),$=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&($||!y.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),b=Dp(y.extent)?y.extent:a;let{positionAbsolute:T}=y.internals;y.parentId&&y.extent==="parent"?T=rfe(T,v,e.get(y.parentId)):b&&(T=If(T,b,v));const w={...y,measured:v,internals:{...y.internals,positionAbsolute:T,handleBounds:{source:PH("source",p.nodeElement,S,f,y.id),target:PH("target",p.nodeElement,S,f,y.id)}}};e.set(y.id,w),y.parentId&&uU(w,e,n,{nodeOrigin:i,zIndexMode:o}),l=!0,$&&(c.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&h.push({id:y.id,parentId:y.parentId,rect:Ip(w,i)}))}}if(h.length>0){const p=OU(h,e,n,i);c.push(...p)}return{changes:c,updatedInternals:l}}async function xHe({delta:t,panZoom:e,transform:n,translateExtent:r,width:i,height:a}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);const o=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function EH(t,e,n,r,i,a){let o=i;const s=r.get(o)||new Map;r.set(o,s.set(n,e)),o=`${i}-${t}`;const l=r.get(o)||new Map;if(r.set(o,l.set(n,e)),a){o=`${i}-${t}-${a}`;const c=r.get(o)||new Map;r.set(o,c.set(n,e))}}function pfe(t,e,n){t.clear(),e.clear();for(const r of n){const{source:i,target:a,sourceHandle:o=null,targetHandle:s=null}=r,l={edgeId:r.id,source:i,target:a,sourceHandle:o,targetHandle:s},c=`${i}-${o}--${a}-${s}`,u=`${a}-${s}--${i}-${o}`;EH("source",l,u,t,i,o),EH("target",l,c,t,a,s),e.set(r.id,r)}}function mfe(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return n?n.selected?!0:mfe(n,e):!1}function CH(t,e,n){var i;let r=t;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,e))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function QHe(t,e,n,r){const i=new Map;for(const[a,o]of t)if((o.selected||o.id===r)&&(!o.parentId||!mfe(o,t))&&(o.draggable||e&&typeof o.draggable>"u")){const s=t.get(a);s&&i.set(a,{id:a,position:s.position||{x:0,y:0},distance:{x:n.x-s.internals.positionAbsolute.x,y:n.y-s.internals.positionAbsolute.y},extent:s.extent,parentId:s.parentId,origin:s.origin,expandParent:s.expandParent,internals:{positionAbsolute:s.internals.positionAbsolute||{x:0,y:0}},measured:{width:s.measured.width??0,height:s.measured.height??0}})}return i}function J2({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){var o,s,l;const i=[];for(const[c,u]of e){const f=(o=n.get(c))==null?void 0:o.internals.userNode;f&&i.push({...f,position:u.position,dragging:r})}if(!t)return[i[0],i];const a=(s=n.get(t))==null?void 0:s.internals.userNode;return[a?{...a,position:((l=e.get(t))==null?void 0:l.position)||a.position,dragging:r}:i[0],i]}function bHe({dragItems:t,snapGrid:e,x:n,y:r}){const i=t.values().next().value;if(!i)return null;const a={x:n-i.distance.x,y:r-i.distance.y},o=Yv(a,e);return{x:o.x-a.x,y:o.y-a.y}}function SHe({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,l=!1,c={x:0,y:0},u=null,f=!1,h=null,p=!1,y=!1,v=null;function $({noDragClassName:S,handleSelector:b,domNode:T,isSelectable:w,nodeId:P,nodeClickDistance:k=0}){h=oo(T);function R({x:Y,y:W}){const{nodeLookup:A,nodeExtent:q,snapGrid:N,snapToGrid:Z,nodeOrigin:D,onNodeDrag:M,onSelectionDrag:V,onError:I,updateNodePositions:B}=e();a={x:Y,y:W};let L=!1;const J=s.size>1,K=J&&q?YA(zv(s)):null,H=J&&Z?bHe({dragItems:s,snapGrid:N,x:Y,y:W}):null;for(const[re,F]of s){if(!A.has(re))continue;let te={x:Y-F.distance.x,y:W-F.distance.y};Z&&(te=H?{x:Math.round(te.x+H.x),y:Math.round(te.y+H.y)}:Yv(te,N));let ie=null;if(J&&q&&!F.extent&&K){const{positionAbsolute:ue}=F.internals,Oe=ue.x-K.x+q[0][0],de=ue.x+F.measured.width-K.x2+q[1][0],xe=ue.y-K.y+q[0][1],Qe=ue.y+F.measured.height-K.y2+q[1][1];ie=[[Oe,xe],[de,Qe]]}const{position:se,positionAbsolute:ae}=nfe({nodeId:re,nextPosition:te,nodeLookup:A,nodeExtent:ie||q,nodeOrigin:D,onError:I});L=L||F.position.x!==se.x||F.position.y!==se.y,F.position=se,F.internals.positionAbsolute=ae}if(y=y||L,!!L&&(B(s,!0),v&&(r||M||!P&&V))){const[re,F]=J2({nodeId:P,dragItems:s,nodeLookup:A});r==null||r(v,s,re,F),M==null||M(v,re,F),P||V==null||V(v,F)}}async function E(){if(!u)return;const{transform:Y,panBy:W,autoPanSpeed:A,autoPanOnNodeDrag:q}=e();if(!q){l=!1,cancelAnimationFrame(o);return}const[N,Z]=ife(c,u,A);(N!==0||Z!==0)&&(a.x=(a.x??0)-N/Y[2],a.y=(a.y??0)-Z/Y[2],await W({x:N,y:Z})&&R(a)),o=requestAnimationFrame(E)}function C(Y){var J;const{nodeLookup:W,multiSelectionActive:A,nodesDraggable:q,transform:N,snapGrid:Z,snapToGrid:D,selectNodesOnDrag:M,onNodeDragStart:V,onSelectionDragStart:I,unselectNodesAndEdges:B}=e();f=!0,(!M||!w)&&!A&&P&&((J=W.get(P))!=null&&J.selected||B()),w&&M&&P&&(t==null||t(P));const L=ky(Y.sourceEvent,{transform:N,snapGrid:Z,snapToGrid:D,containerBounds:u});if(a=L,s=QHe(W,q,L,P),s.size>0&&(n||V||!P&&I)){const[K,H]=J2({nodeId:P,dragItems:s,nodeLookup:W});n==null||n(Y.sourceEvent,s,K,H),V==null||V(Y.sourceEvent,K,H),P||I==null||I(Y.sourceEvent,H)}}const z=UOe().clickDistance(k).on("start",Y=>{const{domNode:W,nodeDragThreshold:A,transform:q,snapGrid:N,snapToGrid:Z}=e();u=(W==null?void 0:W.getBoundingClientRect())||null,p=!1,y=!1,v=Y.sourceEvent,A===0&&C(Y),a=ky(Y.sourceEvent,{transform:q,snapGrid:N,snapToGrid:Z,containerBounds:u}),c=gs(Y.sourceEvent,u)}).on("drag",Y=>{const{autoPanOnNodeDrag:W,transform:A,snapGrid:q,snapToGrid:N,nodeDragThreshold:Z,nodeLookup:D}=e(),M=ky(Y.sourceEvent,{transform:A,snapGrid:q,snapToGrid:N,containerBounds:u});if(v=Y.sourceEvent,(Y.sourceEvent.type==="touchmove"&&Y.sourceEvent.touches.length>1||P&&!D.has(P))&&(p=!0),!p){if(!l&&W&&f&&(l=!0,E()),!f){const V=gs(Y.sourceEvent,u),I=V.x-c.x,B=V.y-c.y;Math.sqrt(I*I+B*B)>Z&&C(Y)}(a.x!==M.xSnapped||a.y!==M.ySnapped)&&s&&f&&(c=gs(Y.sourceEvent,u),R(M))}}).on("end",Y=>{if(!(!f||p)&&(l=!1,f=!1,cancelAnimationFrame(o),s.size>0)){const{nodeLookup:W,updateNodePositions:A,onNodeDragStop:q,onSelectionDragStop:N}=e();if(y&&(A(s,!1),y=!1),i||q||!P&&N){const[Z,D]=J2({nodeId:P,dragItems:s,nodeLookup:W,dragging:!1});i==null||i(Y.sourceEvent,s,Z,D),q==null||q(Y.sourceEvent,Z,D),P||N==null||N(Y.sourceEvent,D)}}}).filter(Y=>{const W=Y.target;return!Y.button&&(!S||!CH(W,`.${S}`,T))&&(!b||CH(W,b,T))});h.call(z)}function x(){h==null||h.on(".drag",null)}return{update:$,destroy:x}}function wHe(t,e,n){const r=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const a of e.values())L$(i,Ip(a))>0&&r.push(a);return r}const PHe=250;function THe(t,e,n,r){var s,l;let i=[],a=1/0;const o=wHe(t,n,e+PHe);for(const c of o){const u=[...((s=c.internals.handleBounds)==null?void 0:s.source)??[],...((l=c.internals.handleBounds)==null?void 0:l.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=Df(c,f,f.position,!0),y=Math.sqrt(Math.pow(h-t.x,2)+Math.pow(p-t.y,2));y>e||(y<a?(i=[{...f,x:h,y:p}],a=y):y===a&&i.push({...f,x:h,y:p}))}}if(!i.length)return null;if(i.length>1){const c=r.type==="source"?"target":"source";return i.find(u=>u.type===c)??i[0]}return i[0]}function gfe(t,e,n,r,i,a=!1){var c,u,f;const o=r.get(t);if(!o)return null;const s=i==="strict"?(c=o.internals.handleBounds)==null?void 0:c[e]:[...((u=o.internals.handleBounds)==null?void 0:u.source)??[],...((f=o.internals.handleBounds)==null?void 0:f.target)??[]],l=(n?s==null?void 0:s.find(h=>h.id===n):s==null?void 0:s[0])??null;return l&&a?{...l,...Df(o,l,l.position,!0)}:l}function yfe(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function kHe(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}const $fe=()=>!0;function _He(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:f,panBy:h,cancelConnection:p,onConnectStart:y,onConnect:v,onConnectEnd:$,isValidConnection:x=$fe,onReconnectEnd:S,updateConnection:b,getTransform:T,getFromHandle:w,autoPanSpeed:P,dragThreshold:k=1,handleDomNode:R}){const E=lfe(t.target);let C=0,z;const{x:Y,y:W}=gs(t),A=yfe(a,R),q=s==null?void 0:s.getBoundingClientRect();let N=!1;if(!q||!A)return;const Z=gfe(i,A,r,l,e);if(!Z)return;let D=gs(t,q),M=!1,V=null,I=!1,B=null;function L(){if(!u||!q)return;const[se,ae]=ife(D,q,P);h({x:se,y:ae}),C=requestAnimationFrame(L)}const J={...Z,nodeId:i,type:A,position:Z.position},K=l.get(i);let re={inProgress:!0,isValid:null,from:Df(K,J,Ce.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:K,to:D,toHandle:null,toPosition:xH[J.position],toNode:null,pointer:D};function F(){N=!0,b(re),y==null||y(t,{nodeId:i,handleId:r,handleType:A})}k===0&&F();function te(se){if(!N){const{x:Qe,y:Re}=gs(se),Le=Qe-Y,Ne=Re-W;if(!(Le*Le+Ne*Ne>k*k))return;F()}if(!w()||!J){ie(se);return}const ae=T();D=gs(se,q),z=THe(Av(D,ae,!1,[1,1]),n,l,J),M||(L(),M=!0);const ue=vfe(se,{handle:z,connectionMode:e,fromNodeId:i,fromHandleId:r,fromType:o?"target":"source",isValidConnection:x,doc:E,lib:c,flowId:f,nodeLookup:l});B=ue.handleDomNode,V=ue.connection,I=kHe(!!z,ue.isValid);const Oe=l.get(i),de=Oe?Df(Oe,J,Ce.Left,!0):re.from,xe={...re,from:de,isValid:I,to:ue.toHandle&&I?eS({x:ue.toHandle.x,y:ue.toHandle.y},ae):D,toHandle:ue.toHandle,toPosition:I&&ue.toHandle?ue.toHandle.position:xH[J.position],toNode:ue.toHandle?l.get(ue.toHandle.nodeId):null,pointer:D};b(xe),re=xe}function ie(se){if(!("touches"in se&&se.touches.length>0)){if(N){(z||B)&&V&&I&&(v==null||v(V));const{inProgress:ae,...ue}=re,Oe={...ue,toPosition:re.toHandle?re.toPosition:null};$==null||$(se,Oe),a&&(S==null||S(se,Oe))}p(),cancelAnimationFrame(C),M=!1,I=!1,V=null,B=null,E.removeEventListener("mousemove",te),E.removeEventListener("mouseup",ie),E.removeEventListener("touchmove",te),E.removeEventListener("touchend",ie)}}E.addEventListener("mousemove",te),E.addEventListener("mouseup",ie),E.addEventListener("touchmove",te),E.addEventListener("touchend",ie)}function vfe(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:l,isValidConnection:c=$fe,nodeLookup:u}){const f=a==="target",h=e?o.querySelector(`.${s}-flow__handle[data-id="${l}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:p,y}=gs(t),v=o.elementFromPoint(p,y),$=v!=null&&v.classList.contains(`${s}-flow__handle`)?v:h,x={handleDomNode:$,isValid:!1,connection:null,toHandle:null};if($){const S=yfe(void 0,$),b=$.getAttribute("data-nodeid"),T=$.getAttribute("data-handleid"),w=$.classList.contains("connectable"),P=$.classList.contains("connectableend");if(!b||!S)return x;const k={source:f?b:r,sourceHandle:f?T:i,target:f?r:b,targetHandle:f?i:T};x.connection=k;const E=w&&P&&(n===Wp.Strict?f&&S==="source"||!f&&S==="target":b!==r||T!==i);x.isValid=E&&c(k),x.toHandle=gfe(b,S,T,u,n,!0)}return x}const ZA={onPointerDown:_He,isValid:vfe};function XHe({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){const i=oo(t);function a({translateExtent:s,width:l,height:c,zoomStep:u=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const y=b=>{if(b.sourceEvent.type!=="wheel"||!e)return;const T=n(),w=b.sourceEvent.ctrlKey&&G$()?10:1,P=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*u,k=T[2]*Math.pow(2,P*w);e.scaleTo(k)};let v=[0,0];const $=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(v=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},x=b=>{const T=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!e)return;const w=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],P=[w[0]-v[0],w[1]-v[1]];v=w;const k=r()*Math.max(T[2],Math.log(T[2]))*(p?-1:1),R={x:T[0]-P[0]*k,y:T[1]-P[1]*k},E=[[0,0],[l,c]];e.setViewportConstrained({x:R.x,y:R.y,zoom:T[2]},E,s)},S=FOe().on("start",$).on("zoom",f?x:null).on("zoom.wheel",h?y:null);i.call(S,{})}function o(){i.on("zoom",null)}return{update:a,destroy:o,pointer:ls}}const Ww=t=>({x:t.x,y:t.y,zoom:t.k}),ej=({x:t,y:e,zoom:n})=>Vw.translate(t,e).scale(n),Th=(t,e)=>t.target.closest(`.${e}`),xfe=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),RHe=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,tj=(t,e=0,n=RHe,r=()=>{})=>{const i=typeof e=="number"&&e>0;return i||r(),i?t.transition().duration(e).ease(n).on("end",r):t},Qfe=t=>{const e=t.ctrlKey&&G$()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};function jHe({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:l,onPanZoomEnd:c}){return u=>{if(Th(u,e))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&o){const $=ls(u),x=Qfe(u),S=f*Math.pow(2,x);r.scaleTo(n,S,$,u);return}const h=u.deltaMode===1?20:1;let p=i===Xf.Vertical?0:u.deltaX*h,y=i===Xf.Horizontal?0:u.deltaY*h;!G$()&&u.shiftKey&&i!==Xf.Vertical&&(p=u.deltaY*h,y=0),r.translateBy(n,-(p/f)*a,-(y/f)*a,{internal:!0});const v=Ww(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?(l==null||l(u,v),t.panScrollTimeout=setTimeout(()=>{c==null||c(u,v),t.isPanScrolling=!1},150)):(t.isPanScrolling=!0,s==null||s(u,v))}}function EHe({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,i){const a=r.type==="wheel",o=!e&&a&&!r.ctrlKey,s=Th(r,t);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function CHe({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{var a,o,s;if((a=r.sourceEvent)!=null&&a.internal)return;const i=Ww(r.transform);t.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=i,((s=r.sourceEvent)==null?void 0:s.type)==="mousedown"&&e(!0),n&&(n==null||n(r.sourceEvent,i))}}function zHe({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{var o,s;t.usedRightMouseButton=!!(n&&xfe(e,t.mouseButton??0)),(o=a.sourceEvent)!=null&&o.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!((s=a.sourceEvent)!=null&&s.internal)&&(i==null||i(a.sourceEvent,Ww(a.transform)))}}function YHe({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{var s;if(!((s=o.sourceEvent)!=null&&s.internal)&&(t.isZoomingOrPanning=!1,a&&xfe(e,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),t.usedRightMouseButton=!1,r(!1),i)){const l=Ww(o.transform);t.prevViewport=l,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i==null||i(o.sourceEvent,l)},n?150:0)}}}function AHe({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:l,lib:c,connectionInProgress:u}){return f=>{var $;const h=t||e,p=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Th(f,`${c}-flow__node`)||Th(f,`${c}-flow__edge`)))return!0;if(!r&&!h&&!i&&!a&&!n||o||u&&!y||Th(f,s)&&y||Th(f,l)&&(!y||i&&y&&!t)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&(($=f.touches)==null?void 0:$.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!p&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function qHe({domNode:t,minZoom:e,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=t.getBoundingClientRect(),f=FOe().scaleExtent([e,n]).translateExtent(r),h=oo(t).call(f);S({x:i.x,y:i.y,zoom:Mp(i.zoom,e,n)},[[0,0],[u.width,u.height]],r);const p=h.on("wheel.zoom"),y=h.on("dblclick.zoom");f.wheelDelta(Qfe);function v(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).transform(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function $({noWheelClassName:z,noPanClassName:Y,onPaneContextMenu:W,userSelectionActive:A,panOnScroll:q,panOnDrag:N,panOnScrollMode:Z,panOnScrollSpeed:D,preventScrolling:M,zoomOnPinch:V,zoomOnScroll:I,zoomOnDoubleClick:B,zoomActivationKeyPressed:L,lib:J,onTransformChange:K,connectionInProgress:H,paneClickDistance:re,selectionOnDrag:F}){A&&!c.isZoomingOrPanning&&x();const te=q&&!L&&!A;f.clickDistance(F?1/0:!ms(re)||re<0?0:re);const ie=te?jHe({zoomPanValues:c,noWheelClassName:z,d3Selection:h,d3Zoom:f,panOnScrollMode:Z,panOnScrollSpeed:D,zoomOnPinch:V,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):EHe({noWheelClassName:z,preventScrolling:M,d3ZoomHandler:p});if(h.on("wheel.zoom",ie,{passive:!1}),!A){const ae=CHe({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:o});f.on("start",ae);const ue=zHe({zoomPanValues:c,panOnDrag:N,onPaneContextMenu:!!W,onPanZoom:a,onTransformChange:K});f.on("zoom",ue);const Oe=YHe({zoomPanValues:c,panOnDrag:N,panOnScroll:q,onPaneContextMenu:W,onPanZoomEnd:s,onDraggingChange:l});f.on("end",Oe)}const se=AHe({zoomActivationKeyPressed:L,panOnDrag:N,zoomOnScroll:I,panOnScroll:q,zoomOnDoubleClick:B,zoomOnPinch:V,userSelectionActive:A,noPanClassName:Y,noWheelClassName:z,lib:J,connectionInProgress:H});f.filter(se),B?h.on("dblclick.zoom",y):h.on("dblclick.zoom",null)}function x(){f.on("zoom",null)}async function S(z,Y,W){const A=ej(z),q=f==null?void 0:f.constrain()(A,Y,W);return q&&await v(q),new Promise(N=>N(q))}async function b(z,Y){const W=ej(z);return await v(W,Y),new Promise(A=>A(W))}function T(z){if(h){const Y=ej(z),W=h.property("__zoom");(W.k!==z.zoom||W.x!==z.x||W.y!==z.y)&&(f==null||f.transform(h,Y,null,{sync:!0}))}}function w(){const z=h?BOe(h.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function P(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).scaleTo(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function k(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).scaleBy(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function R(z){f==null||f.scaleExtent(z)}function E(z){f==null||f.translateExtent(z)}function C(z){const Y=!ms(z)||z<0?0:z;f==null||f.clickDistance(Y)}return{update:$,destroy:x,setViewport:b,setViewportConstrained:S,getViewport:w,scaleTo:P,scaleBy:k,setScaleExtent:R,setTranslateExtent:E,syncViewport:T,setClickDistance:C}}var Gp;(function(t){t.Line="line",t.Handle="handle"})(Gp||(Gp={}));function ZHe({width:t,prevWidth:e,height:n,prevHeight:r,affectsX:i,affectsY:a}){const o=t-e,s=n-r,l=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(l[0]=l[0]*-1),s&&a&&(l[1]=l[1]*-1),l}function zH(t){const e=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),r=t.includes("left"),i=t.includes("top");return{isHorizontal:e,isVertical:n,affectsX:r,affectsY:i}}function Xu(t,e){return Math.max(0,e-t)}function Ru(t,e){return Math.max(0,t-e)}function HQ(t,e,n){return Math.max(0,e-t,t-n)}function YH(t,e){return t?!e:e}function VHe(t,e,n,r,i,a,o,s){let{affectsX:l,affectsY:c}=e;const{isHorizontal:u,isVertical:f}=e,h=u&&f,{xSnapped:p,ySnapped:y}=n,{minWidth:v,maxWidth:$,minHeight:x,maxHeight:S}=r,{x:b,y:T,width:w,height:P,aspectRatio:k}=t;let R=Math.floor(u?p-t.pointerX:0),E=Math.floor(f?y-t.pointerY:0);const C=w+(l?-R:R),z=P+(c?-E:E),Y=-a[0]*w,W=-a[1]*P;let A=HQ(C,v,$),q=HQ(z,x,S);if(o){let D=0,M=0;l&&R<0?D=Xu(b+R+Y,o[0][0]):!l&&R>0&&(D=Ru(b+C+Y,o[1][0])),c&&E<0?M=Xu(T+E+W,o[0][1]):!c&&E>0&&(M=Ru(T+z+W,o[1][1])),A=Math.max(A,D),q=Math.max(q,M)}if(s){let D=0,M=0;l&&R>0?D=Ru(b+R,s[0][0]):!l&&R<0&&(D=Xu(b+C,s[1][0])),c&&E>0?M=Ru(T+E,s[0][1]):!c&&E<0&&(M=Xu(T+z,s[1][1])),A=Math.max(A,D),q=Math.max(q,M)}if(i){if(u){const D=HQ(C/k,x,S)*k;if(A=Math.max(A,D),o){let M=0;!l&&!c||l&&!c&&h?M=Ru(T+W+C/k,o[1][1])*k:M=Xu(T+W+(l?R:-R)/k,o[0][1])*k,A=Math.max(A,M)}if(s){let M=0;!l&&!c||l&&!c&&h?M=Xu(T+C/k,s[1][1])*k:M=Ru(T+(l?R:-R)/k,s[0][1])*k,A=Math.max(A,M)}}if(f){const D=HQ(z*k,v,$)/k;if(q=Math.max(q,D),o){let M=0;!l&&!c||c&&!l&&h?M=Ru(b+z*k+Y,o[1][0])/k:M=Xu(b+(c?E:-E)*k+Y,o[0][0])/k,q=Math.max(q,M)}if(s){let M=0;!l&&!c||c&&!l&&h?M=Xu(b+z*k,s[1][0])/k:M=Ru(b+(c?E:-E)*k,s[0][0])/k,q=Math.max(q,M)}}}E=E+(E<0?q:-q),R=R+(R<0?A:-A),i&&(h?C>z*k?E=(YH(l,c)?-R:R)/k:R=(YH(l,c)?-E:E)*k:u?(E=R/k,c=l):(R=E*k,l=c));const N=l?b+R:b,Z=c?T+E:T;return{width:w+(l?-R:R),height:P+(c?-E:E),x:a[0]*R*(l?-1:1)+N,y:a[1]*E*(c?-1:1)+Z}}const bfe={width:0,height:0,x:0,y:0},UHe={...bfe,pointerX:0,pointerY:0,aspectRatio:1};function NHe(t){return[[0,0],[t.measured.width,t.measured.height]]}function WHe(t,e,n){const r=e.position.x+t.position.x,i=e.position.y+t.position.y,a=t.measured.width??0,o=t.measured.height??0,s=n[0]*a,l=n[1]*o;return[[r-s,i-l],[r+a-s,i+o-l]]}function MHe({domNode:t,nodeId:e,getStoreItems:n,onChange:r,onEnd:i}){const a=oo(t);let o={controlDirection:zH("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:y,onResizeEnd:v,shouldResize:$}){let x={...bfe},S={...UHe};o={boundaries:u,resizeDirection:h,keepAspectRatio:f,controlDirection:zH(c)};let b,T=null,w=[],P,k,R,E=!1;const C=UOe().on("start",z=>{const{nodeLookup:Y,transform:W,snapGrid:A,snapToGrid:q,nodeOrigin:N,paneDomNode:Z}=n();if(b=Y.get(e),!b)return;T=(Z==null?void 0:Z.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:M}=ky(z.sourceEvent,{transform:W,snapGrid:A,snapToGrid:q,containerBounds:T});x={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},S={...x,pointerX:D,pointerY:M,aspectRatio:x.width/x.height},P=void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(P=Y.get(b.parentId),k=P&&b.extent==="parent"?NHe(P):void 0),w=[],R=void 0;for(const[V,I]of Y)if(I.parentId===e&&(w.push({id:V,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const B=WHe(I,b,I.origin??N);R?R=[[Math.min(B[0][0],R[0][0]),Math.min(B[0][1],R[0][1])],[Math.max(B[1][0],R[1][0]),Math.max(B[1][1],R[1][1])]]:R=B}p==null||p(z,{...x})}).on("drag",z=>{const{transform:Y,snapGrid:W,snapToGrid:A,nodeOrigin:q}=n(),N=ky(z.sourceEvent,{transform:Y,snapGrid:W,snapToGrid:A,containerBounds:T}),Z=[];if(!b)return;const{x:D,y:M,width:V,height:I}=x,B={},L=b.origin??q,{width:J,height:K,x:H,y:re}=VHe(S,o.controlDirection,N,o.boundaries,o.keepAspectRatio,L,k,R),F=J!==V,te=K!==I,ie=H!==D&&F,se=re!==M&&te;if(!ie&&!se&&!F&&!te)return;if((ie||se||L[0]===1||L[1]===1)&&(B.x=ie?H:x.x,B.y=se?re:x.y,x.x=B.x,x.y=B.y,w.length>0)){const de=H-D,xe=re-M;for(const Qe of w)Qe.position={x:Qe.position.x-de+L[0]*(J-V),y:Qe.position.y-xe+L[1]*(K-I)},Z.push(Qe)}if((F||te)&&(B.width=F&&(!o.resizeDirection||o.resizeDirection==="horizontal")?J:x.width,B.height=te&&(!o.resizeDirection||o.resizeDirection==="vertical")?K:x.height,x.width=B.width,x.height=B.height),P&&b.expandParent){const de=L[0]*(B.width??0);B.x&&B.x<de&&(x.x=de,S.x=S.x-(B.x-de));const xe=L[1]*(B.height??0);B.y&&B.y<xe&&(x.y=xe,S.y=S.y-(B.y-xe))}const ae=ZHe({width:x.width,prevWidth:V,height:x.height,prevHeight:I,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),ue={...x,direction:ae};($==null?void 0:$(z,ue))!==!1&&(E=!0,y==null||y(z,ue),r(B,Z))}).on("end",z=>{E&&(v==null||v(z,{...x}),i==null||i({...x}),E=!1)});a.call(C)}function l(){a.on(".drag",null)}return{update:s,destroy:l}}var nj={exports:{}},rj={},ij={exports:{}},aj={};/**
|
|
704
|
+
`)}}):null},Rv=Ks;function jv({active:t,payload:e,className:n,indicator:r="dot",hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:l,formatter:c,color:u,nameKey:f,labelKey:h}){const{config:p}=POe(),y=_.useMemo(()=>{var T;if(i||!(e!=null&&e.length))return null;const[$]=e,x=`${h||($==null?void 0:$.dataKey)||($==null?void 0:$.name)||"value"}`,S=XA(p,$,x),b=!h&&typeof o=="string"?((T=p[o])==null?void 0:T.label)||o:S==null?void 0:S.label;return s?m.jsx("div",{className:jr("font-medium",l),children:s(b,e)}):b?m.jsx("div",{className:jr("font-medium",l),children:b}):null},[o,s,e,i,l,p,h]);if(!t||!(e!=null&&e.length))return null;const v=e.length===1&&r!=="dot";return m.jsxs("div",{className:jr("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",n),children:[v?null:y,m.jsx("div",{className:"grid gap-1.5",children:e.filter($=>$.type!=="none").map(($,x)=>{const S=`${f||$.name||$.dataKey||"value"}`,b=XA(p,$,S),T=u||$.payload.fill||$.color;return m.jsx("div",{className:jr("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",r==="dot"&&"items-center"),children:c&&($==null?void 0:$.value)!==void 0&&$.name?c($.value,$.name,$,x,$.payload):m.jsxs(m.Fragment,{children:[b!=null&&b.icon?m.jsx(b.icon,{}):!a&&m.jsx("div",{className:jr("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",{"h-2.5 w-2.5":r==="dot","w-1":r==="line","w-0 border-[1.5px] border-dashed bg-transparent":r==="dashed","my-0.5":v&&r==="dashed"}),style:{"--color-bg":T,"--color-border":T}}),m.jsxs("div",{className:jr("flex flex-1 justify-between leading-none",v?"items-end":"items-center"),children:[m.jsxs("div",{className:"grid gap-1.5",children:[v?y:null,m.jsx("span",{className:"text-muted-foreground",children:(b==null?void 0:b.label)||$.name})]}),$.value&&m.jsx("span",{className:"font-mono font-medium text-foreground tabular-nums",children:$.value.toLocaleString()})]})]})},$.dataKey)})})]})}const lLe=Tf;function cLe({className:t,hideIcon:e=!1,payload:n,verticalAlign:r="bottom",nameKey:i}){const{config:a}=POe();return n!=null&&n.length?m.jsx("div",{className:jr("flex items-center justify-center gap-4",r==="top"?"pb-3":"pt-3",t),children:n.filter(o=>o.type!=="none").map(o=>{const s=`${i||o.dataKey||"value"}`,l=XA(a,o,s);return m.jsxs("div",{className:jr("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[l!=null&&l.icon&&!e?m.jsx(l.icon,{}):m.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:o.color}}),l==null?void 0:l.label]},o.value)})}):null}function XA(t,e,n){if(typeof e!="object"||e===null)return;const r="payload"in e&&typeof e.payload=="object"&&e.payload!==null?e.payload:void 0;let i=n;return n in e&&typeof e[n]=="string"?i=e[n]:r&&n in r&&typeof r[n]=="string"&&(i=r[n]),i in t?t[i]:t[n]}function fa({className:t,size:e="default",...n}){return m.jsx("div",{"data-slot":"card","data-size":e,className:jr("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),...n})}function ho({className:t,...e}){return m.jsx("div",{"data-slot":"card-header",className:jr("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),...e})}function po({className:t,...e}){return m.jsx("div",{"data-slot":"card-title",className:jr("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),...e})}function da({className:t,...e}){return m.jsx("div",{"data-slot":"card-content",className:jr("px-4 group-data-[size=sm]/card:px-3",t),...e})}const uLe=["critical","high","medium","low","info"],yh={critical:"#dc2626",high:"#ef4444",medium:"#f97316",low:"#f59e0b",info:"#3b82f6"},OLe={count:{label:"Violations"},critical:{label:"Critical",color:yh.critical},high:{label:"High",color:yh.high},medium:{label:"Medium",color:yh.medium},low:{label:"Low",color:yh.low},info:{label:"Info",color:yh.info}};function FV({data:t,activeSeverity:e,onSeverityClick:n}){const{bySeverity:r}=t,i=uLe.filter(o=>(r[o]??0)>0).map(o=>({severity:o.charAt(0).toUpperCase()+o.slice(1),severityKey:o,count:r[o]??0,fill:yh[o]}));if(i.length===0)return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Severity"})}),m.jsx(da,{children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No violations to display."})})]});const a=o=>{o.severityKey&&(n==null||n(o.severityKey))};return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Severity"})}),m.jsx(da,{children:m.jsx(Xv,{config:OLe,className:"aspect-[2/1] w-full max-h-[250px]",children:m.jsxs(N9e,{data:i,margin:{top:4,right:4,bottom:0,left:0},children:[m.jsx(Ew,{vertical:!1}),m.jsx(od,{dataKey:"severity",tickLine:!1,axisLine:!1,tickMargin:8}),m.jsx(sd,{tickLine:!1,axisLine:!1,tickMargin:8,allowDecimals:!1,width:32}),m.jsx(Rv,{content:m.jsx(jv,{})}),m.jsx(ad,{dataKey:"count",radius:[4,4,0,0],onClick:n?a:void 0,style:n?{cursor:"pointer"}:void 0,isAnimationActive:!1,children:i.map(o=>m.jsx(ym,{fill:o.fill,opacity:!e||e===o.severityKey?1:.35},o.severityKey))})]})})})]})}const F2=Math.PI/180,cH=["var(--chart-1)","var(--chart-2)","var(--chart-3)","var(--chart-4)","var(--chart-5)"];function fLe(t){const e={};return Object.keys(t).forEach((n,r)=>{e[n]={label:WS(n),color:cH[r%cH.length]}}),e}function dLe(t){const e=t;return m.jsx($w,{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius+10,startAngle:e.startAngle,endAngle:e.endAngle,fill:e.fill})}function hLe({byKind:t,activeKind:e,onKindClick:n}){const r=_.useMemo(()=>Object.entries(t).filter(([,l])=>l>0).sort((l,c)=>c[1]-l[1]).map(([l,c])=>({name:l,value:c})),[t]),i=_.useMemo(()=>fLe(t),[t]),a=_.useMemo(()=>r.reduce((l,c)=>l+c.value,0),[r]);if(r.length===0)return null;const o=e?r.findIndex(l=>l.name===e):-1,s=l=>{const c=l,u=o>=0&&c.index===o,f=(c.outerRadius+(u?10:0))*1.18,h=c.cx+f*Math.cos(-c.midAngle*F2),p=c.cy+f*Math.sin(-c.midAngle*F2),y=Math.cos(-c.midAngle*F2)>=0?"start":"end",v=c.percent!==void 0?` ${(c.percent*100).toFixed(0)}%`:"",$=c.name?WS(c.name):"";return m.jsxs("text",{x:h,y:p,textAnchor:y,dominantBaseline:"central",className:u?"fill-foreground text-xs font-medium":"fill-muted-foreground text-[10px]",children:[$,v]})};return m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"By Artifact Kind"})}),m.jsx(da,{children:m.jsx(Xv,{config:i,className:`aspect-square w-full max-h-[250px] ${n?"[&_.recharts-pie]:cursor-pointer":""}`,children:m.jsxs(pOe,{children:[m.jsx(Rv,{content:m.jsx(jv,{nameKey:"name"})}),m.jsxs(Xl,{data:r,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:"40%",outerRadius:"70%",paddingAngle:2,label:s,labelLine:!1,activeIndex:o>=0?o:-1,activeShape:dLe,onClick:n?l=>l.name&&n(l.name):void 0,isAnimationActive:!1,children:[r.map((l,c)=>m.jsx(ym,{fill:`var(--color-${l.name})`,opacity:o<0||c===o?1:.45},l.name)),m.jsx(ti,{value:a,position:"center",className:"fill-foreground text-lg font-bold"})]})]})})})]})}function pLe({byFile:t,activeFile:e,onFileClick:n}){const r=Object.entries(t).map(([i,a])=>({filePath:i,count:a})).sort((i,a)=>a.count-i.count).slice(0,10);return r.length===0?null:m.jsxs(fa,{children:[m.jsx(ho,{children:m.jsx(po,{className:"text-sm font-medium",children:"Top Files"})}),m.jsx(da,{className:"px-0",children:m.jsx("table",{className:"w-full text-sm",children:m.jsx("tbody",{children:r.map((i,a)=>{const o=i.filePath.split("/").pop()||i.filePath,s=e===i.filePath;return m.jsxs("tr",{className:`border-b border-border/50 transition-colors ${n?"cursor-pointer hover:bg-muted/50":""} ${s?"bg-accent/50":""}`,onClick:()=>n==null?void 0:n(i.filePath),title:i.filePath,children:[m.jsx("td",{className:"px-4 py-1.5 text-xs text-muted-foreground",children:a+1}),m.jsx("td",{className:"px-2 py-1.5",children:m.jsx("span",{className:"block max-w-[220px] truncate",title:i.filePath,children:o})}),m.jsx("td",{className:"px-4 py-1.5 text-right font-mono tabular-nums",children:i.count})]},i.filePath)})})})})]})}const mLe={drifts:{label:"Drifts",color:"var(--chart-1)"}};function gLe(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function yLe({history:t}){const e=t.runs.map(r=>({drifts:r.driftCount,dateLabel:gLe(r.verifiedAt)}));if(e.length===0)return null;const n=e.length>=2?e[e.length-1].drifts-e[e.length-2].drifts:0;return m.jsxs(fa,{children:[m.jsxs(ho,{className:"flex flex-row items-center justify-between pb-2",children:[m.jsx(po,{className:"text-sm font-medium",children:"Drift Trend"}),m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n>0&&m.jsxs(m.Fragment,{children:[m.jsx(Tq,{className:"h-3.5 w-3.5 text-red-400"})," +",n]}),n<0&&m.jsxs(m.Fragment,{children:[m.jsx(Une,{className:"h-3.5 w-3.5 text-green-400"})," ",n]}),n===0&&m.jsxs(m.Fragment,{children:[m.jsx(Ene,{className:"h-3.5 w-3.5"})," No change"]})]})]}),m.jsx(da,{children:e.length===1?m.jsxs("div",{className:"flex flex-col items-center gap-1 py-6 text-center",children:[m.jsx("p",{className:"text-2xl font-bold",children:e[0].drifts}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"Drifts in your first verify run — run more to see the trend."})]}):m.jsx(Xv,{config:mLe,className:"w-full",style:{aspectRatio:"auto",height:200},children:m.jsxs(SOe,{data:e,margin:{top:4,right:4,bottom:0,left:0},children:[m.jsx(Ew,{vertical:!1}),m.jsx(od,{dataKey:"dateLabel",tickLine:!1,axisLine:!1,tickMargin:8}),m.jsx(sd,{tickLine:!1,axisLine:!1,tickMargin:8,allowDecimals:!1,width:32}),m.jsx(Rv,{content:m.jsx(jv,{})}),m.jsx($s,{dataKey:"drifts",type:"monotone",fill:"var(--color-drifts)",fillOpacity:.15,stroke:"var(--color-drifts)",strokeWidth:2,isAnimationActive:!1})]})})})]})}const $Le="pointer-events-none absolute left-1/2 top-full mt-1.5 -translate-x-1/2 whitespace-nowrap rounded bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md border border-border opacity-0 group-hover:opacity-100 transition-opacity z-50";function af({icon:t,iconClass:e,value:n,label:r,tooltip:i}){return m.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-1.5 rounded-md border border-border bg-muted/30 px-2.5 py-1",children:[m.jsx(t,{className:`h-3.5 w-3.5 shrink-0 ${e}`}),m.jsx("span",{className:"text-xs font-semibold",children:n}),m.jsx("span",{className:"text-[10px] text-muted-foreground",children:r}),m.jsx("span",{className:$Le,children:i})]})}function vLe(t){const e={},n={},r={};for(const i of t){e[i.severity]=(e[i.severity]??0)+1;const a=vv(i);n[a]=(n[a]??0)+1,i.filePath&&(r[i.filePath]=(r[i.filePath]??0)+1)}return{bySeverity:e,byKind:n,byFile:r}}function xLe({state:t,diff:e,history:n,mode:r,isDiffing:i,filters:a,onToggleSeverity:o,onToggleKind:s,onToggleFile:l}){if(!t)return m.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-muted-foreground",children:"No verify run yet."});const c=r==="diff",u=c?(e==null?void 0:e.added)??[]:t.drifts,{bySeverity:f,byKind:h,byFile:p}=vLe(u),y=t.unresolvedRefs.length;return c&&!e?m.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:m.jsx("div",{className:"flex flex-1 items-center justify-center p-4",children:m.jsxs("div",{className:"text-center text-xs text-muted-foreground",children:[m.jsx(yS,{className:"mx-auto mb-2 h-6 w-6 opacity-60"}),i?"Computing diff…":m.jsxs(m.Fragment,{children:["Click ",m.jsx("span",{className:"font-medium text-foreground",children:"Verify"})," to compute the diff against the committed baseline."]})]})})}):m.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:m.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-3",children:[y>0&&m.jsx(tm,{align:"start",width:"wide",content:"Some artifacts the spec mentions weren't extracted into contracts. Drifts against them won't be detected.",children:m.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs text-amber-700 dark:text-amber-300",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsxs("span",{children:[y," unresolved reference",y===1?"":"s"]})]})}),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex flex-wrap items-center gap-2",children:c&&e?m.jsxs(m.Fragment,{children:[m.jsx(af,{icon:Pne,iconClass:"text-rose-400",value:e.summary.added,label:"new",tooltip:"Drifts introduced by your uncommitted changes"}),m.jsx(af,{icon:vq,iconClass:"text-green-400",value:e.summary.resolved,label:"resolved",tooltip:"Baseline drifts your changes have fixed"}),m.jsx(af,{icon:r0,iconClass:"text-blue-400",value:e.summary.unchanged,label:"unchanged",tooltip:"Baseline drifts your changes haven't touched"}),m.jsx(af,{icon:Ju,iconClass:"text-blue-400",value:e.changedFiles.length,label:"files",tooltip:"Files changed in your working tree"})]}):m.jsxs(m.Fragment,{children:[m.jsx(af,{icon:Wo,iconClass:t.drifts.length>0?"text-yellow-400":"text-muted-foreground",value:t.drifts.length,label:"drifts",tooltip:"Drifts detected against the contracts"}),m.jsx(af,{icon:bne,iconClass:"text-muted-foreground",value:t.artifactCount,label:"artifacts",tooltip:"Artifacts checked from the contracts"}),m.jsx(af,{icon:r0,iconClass:"text-blue-400",value:t.extractedOperationCount,label:"operations",tooltip:"Operations extracted from the code"})]})}),!c&&m.jsx(yLe,{history:n}),m.jsx(hLe,{byKind:h,activeKind:a.kind,onKindClick:s}),m.jsx(FV,{data:{byCategory:{},bySeverity:f,total:u.length},activeSeverity:a.severity,onSeverityClick:o}),m.jsx(pLe,{byFile:p,activeFile:a.file,onFileClick:l})]})]})})}const QLe={critical:"text-red-500 dark:text-red-500",high:"text-red-600 dark:text-red-400",medium:"text-orange-600 dark:text-orange-400",low:"text-amber-600 dark:text-amber-400",info:"text-gray-500 dark:text-gray-400"},bLe=["critical","high","medium","low","info"],SLe={critical:"bg-red-500",high:"bg-red-400",medium:"bg-orange-400",low:"bg-amber-400",info:"bg-gray-400"};function wLe({counts:t}){if(!t)return m.jsx("span",{className:"text-muted-foreground",children:"0"});const e=bLe.filter(r=>t[r]&&t[r]>0).map(r=>({severity:r,count:t[r]})),n=e.reduce((r,i)=>r+i.count,0);return n===0?m.jsx("span",{className:"text-muted-foreground",children:"0"}):m.jsxs("div",{className:"flex flex-col gap-1 min-w-[60px]",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"text-xs font-medium",children:n}),m.jsx("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:e.map(({severity:r,count:i})=>m.jsx("span",{className:QLe[r],title:`${r}: ${i}`,children:i},r))})]}),m.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-muted",children:e.map(({severity:r,count:i})=>m.jsx("div",{className:`${SLe[r]} h-full`,style:{width:`${i/n*100}%`},title:`${r}: ${i}`},r))})]})}function PLe(t){const e=new Date(t);return Number.isNaN(e.getTime())?{date:t,time:""}:{date:e.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),time:e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}}function TLe({history:t,selectedRunId:e,onViewRun:n,onDeleteRun:r}){const[i,a]=_.useState(null),o=[...t.runs].reverse();return o.length===0?m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground",children:[m.jsx(Bu,{className:"h-8 w-8 opacity-50"}),m.jsx("p",{children:"No verify runs yet. Run Verify to see results here."})]}):m.jsxs("div",{className:"h-full overflow-auto p-4",children:[m.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[m.jsx("h2",{className:"text-lg font-semibold",children:"Runs"}),m.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," total"]})]}),m.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:m.jsxs("table",{className:"w-full text-sm",children:[m.jsx("thead",{children:m.jsxs("tr",{className:"border-b border-border bg-muted/50 text-left text-xs text-muted-foreground",children:[m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Date"}),m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Branch"}),m.jsx("th",{className:"px-4 py-2.5 font-medium text-center",children:"Artifacts"}),m.jsx("th",{className:"px-4 py-2.5 font-medium",children:"Drifts"}),m.jsx("th",{className:"px-4 py-2.5 font-medium text-center",children:"Actions"})]})}),m.jsx("tbody",{children:o.map((s,l)=>{const c=l===0,u=e?e===s.id:c,{date:f,time:h}=PLe(s.verifiedAt);return m.jsxs("tr",{className:`border-b border-border/50 transition-colors cursor-pointer ${u?"bg-primary/10":"hover:bg-accent/30"}`,onClick:()=>n(c?null:s.id),children:[m.jsx("td",{className:"px-4 py-2.5",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"flex flex-col",children:[m.jsx("span",{className:"text-xs font-medium",children:f}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:h})]}),c&&m.jsx("span",{className:"rounded bg-primary/20 px-1.5 py-0.5 text-[10px] font-medium text-primary",children:"latest"})]})}),m.jsxs("td",{className:"px-4 py-2.5",children:[s.branch?m.jsx("span",{className:"font-mono text-xs",children:s.branch}):m.jsx("span",{className:"text-xs text-muted-foreground",children:"-"}),s.commitHash&&m.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:s.commitHash.slice(0,7)})]}),m.jsx("td",{className:"px-4 py-2.5 text-center text-xs",children:s.artifactCount}),m.jsx("td",{className:"px-4 py-2.5 text-xs",children:m.jsx(wLe,{counts:s.bySeverity})}),m.jsx("td",{className:"px-4 py-2.5",children:m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("button",{className:"rounded p-1.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete run",disabled:i===s.id,onClick:async p=>{if(p.stopPropagation(),!!confirm("Delete this verify run?")){a(s.id);try{await r(s.id)}finally{a(null)}}},children:i===s.id?m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin"}):m.jsx(Pq,{className:"h-3.5 w-3.5"})})})})]},s.id)})})]})})]})}function kLe({isRunning:t,onRun:e,stale:n=!1,diffMode:r,onToggleDiff:i,isGitRepo:a,runItems:o,selectedRunId:s,onSelectRun:l,viewingHistory:c}){const u=n&&!t;return m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(kre,{items:o,selectedId:s,onSelect:l}),a&&!c&&m.jsx(Tre,{diffMode:r,onToggle:i,subject:{verb:"verifies",plural:"drifts"}}),a&&!c&&m.jsx(tm,{align:"end",width:"narrow",content:n?"Contracts have changed since the last Verify. Click to re-check code against the new contracts.":null,children:m.jsxs(xn,{size:"sm",onClick:e,disabled:t,className:"relative",children:[t?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(vS,{className:"mr-2 h-3.5 w-3.5"}),t?"Verifying...":"Verify",u&&m.jsx("span",{"aria-label":"unverified changes",className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-400 ring-2 ring-background"})]})})]})}const _Le={critical:"bg-red-500/20 text-red-700 dark:text-red-300 border-red-500/40",high:"bg-red-500/15 text-red-700 dark:text-red-300 border-red-500/30",medium:"bg-amber-500/15 text-amber-700 dark:text-amber-300 border-amber-500/30",low:"bg-amber-500/10 text-amber-800 dark:text-amber-200 border-amber-500/20",info:"bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-500/30"};function XLe({drift:t,onClose:e,onOpenFile:n}){var a;const r=((a=t.artifactRef)==null?void 0:a.identity)??null,i=_Le[t.severity];return m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-card px-6 py-3",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[m.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wider ${i}`,children:t.severity}),m.jsx(VZ,{kind:vv(t)}),m.jsx("h2",{className:"truncate font-mono text-sm",children:t.obligationKey})]}),e&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:e,title:"Close drift",children:m.jsx(Rr,{className:"h-4 w-4"})})]}),m.jsx("div",{className:"flex-1 overflow-auto px-6 py-4",children:m.jsxs("div",{className:"space-y-4",children:[r&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Artifact"}),m.jsx("div",{className:"font-mono text-sm text-foreground",children:r})]}),m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"What's wrong"}),m.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:t.message})]}),t.filePath&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Where in the code"}),m.jsxs("button",{type:"button",onClick:()=>t.filePath&&(n==null?void 0:n(t.filePath,t.lineStart??void 0)),disabled:!n,className:"block w-full break-all text-left font-mono text-xs text-primary hover:underline disabled:cursor-default disabled:no-underline disabled:text-foreground",children:[t.filePath,t.lineStart!=null&&`:${t.lineStart}`,t.lineEnd!=null&&t.lineEnd!==t.lineStart&&`–${t.lineEnd}`]})]}),t.specSide!==void 0&&t.specSide!==null&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Spec expectation"}),m.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted/20 p-3 font-mono text-[11px] text-foreground",children:JSON.stringify(t.specSide,null,2)})]}),t.codeSide!==void 0&&t.codeSide!==null&&m.jsxs("div",{children:[m.jsx("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Code observation"}),m.jsx("pre",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-all rounded border border-border bg-muted/20 p-3 font-mono text-[11px] text-foreground",children:JSON.stringify(t.codeSide,null,2)})]})]})})]})}function RLe(){return m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:"Select a drift from the list to inspect it."})})}function jLe(t){const[e,n]=_.useState(null),[r,i]=_.useState(null),[a,o]=_.useState({runs:[]}),[s,l]=_.useState(!1),[c,u]=_.useState(!1),[f,h]=_.useState(!1),[p,y]=_.useState(null),v=_.useCallback(async()=>{if(t){l(!0),y(null);try{const[S,b,T]=await Promise.all([m0e(t),y0e(t),R8(t)]);n(S),i(b),o(T)}catch(S){y(S instanceof Error?S.message:"Failed to load verify state")}finally{l(!1)}}},[t]),$=_.useCallback(async()=>{if(t){u(!0),y(null);try{const S=await g0e(t);n(S),i(null),R8(t).then(o).catch(()=>{})}catch(S){const b=S instanceof Error?S.message:"Verify failed";y(b),hc.error("Verify failed",{description:b})}finally{u(!1)}}},[t]),x=_.useCallback(async()=>{if(t){h(!0);try{const S=await $0e(t);i(S)}catch(S){const b=S instanceof Error?S.message:"Verify diff failed";hc.error("Verify diff failed",{description:b})}finally{h(!1)}}},[t]);return _.useEffect(()=>{v()},[v]),{state:e,diff:r,history:a,isLoading:s,isRunning:c,isDiffing:f,error:p,refetch:v,run:$,runDiff:x}}function ELe(t){const[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){n(!0),o(null);try{const l=await k0e(t);i(l)}catch(l){const c=l instanceof Error?l.message:"Generate failed";o(c),hc.error("Generate failed",{description:c})}finally{n(!1)}}},[t]);return{generating:e,result:r,error:a,run:s}}function CLe(t){const[e,n]=_.useState(!1),[r,i]=_.useState(!1),a=_.useCallback(async()=>{if(t)try{const o=await _0e(t);n(o.contractsStale),i(o.verifyStale)}catch{}},[t]);return _.useEffect(()=>{a()},[a]),{contractsStale:e,verifyStale:r,refetch:a}}function zLe({isGenerating:t,onGenerate:e,stale:n=!1,isGitRepo:r=!0}){const i=n&&!t;return r?m.jsx(tm,{align:"end",width:"narrow",content:n?"Canonical spec has changed since the last Generate. Click to re-extract TC contracts.":null,children:m.jsxs(xn,{size:"sm",onClick:e,disabled:t,className:"relative",children:[t?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(Nne,{className:"mr-2 h-3.5 w-3.5"}),t?"Generating...":"Generate",i&&m.jsx("span",{"aria-label":"ungenerated changes",className:"absolute -right-1 -top-1 h-2 w-2 rounded-full bg-amber-400 ring-2 ring-background"})]})}):null}function YLe({result:t}){const e=_.useRef(null);return _.useEffect(()=>{if(!t||t===e.current)return;if(e.current=t,"error"in t.il){hc.error("Generate failed",{description:t.il.error});return}if("skipped"in t.il){hc.warning("Generate skipped",{description:t.il.skipped});return}const n=t.il.validationIssues??[],r=t.il.written,i=n.filter(s=>s.severity==="hard").length;if(n.length===0){hc.success("Generated",{description:`Wrote ${r} TC contract${r===1?"":"s"}.`});return}const a=i>0?"Generated with errors":"Generated with warnings",o=i>0?`${i} error${i===1?"":"s"} blocked writing — see Contracts panel.`:`Wrote ${r} contract${r===1?"":"s"} · ${n.length} warning${n.length===1?"":"s"} — see Contracts panel.`;i>0?hc.error(a,{description:o}):hc.warning(a,{description:o})},[t]),null}const uH=["overview","auth","endpoints","data","effects","errors"];function ALe(t,e){const n=uH.indexOf(t),r=uH.indexOf(e);return n===-1&&r===-1?t.localeCompare(e):n===-1?1:r===-1?-1:n-r}function qLe({activeConflictId:t,onSelectConflict:e}){var l;const{scan:n,hydrating:r}=Mc();if(r)return m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})});if(!n)return m.jsx(pl,{icon:EC,title:"No scan yet",body:m.jsxs(m.Fragment,{children:["Click ",m.jsx("strong",{children:"Scan"})," on the Spec tab to start recording decisions."]})});const i=n.decidedConflicts;if(i.length===0)return m.jsx(pl,{icon:EC,title:"No decisions yet",body:"Resolve conflicts in the Spec tab and they'll show up here as a revokable ledger."});const a=[],o=new Map;for(const c of i){if((l=c.conflict.candidates[0])==null?void 0:l.claim.id.startsWith("version-chain:")){a.push(c);continue}const f=o.get(c.conflict.topic)??[];f.push(c),o.set(c.conflict.topic,f)}const s=[...o.keys()].sort(ALe);for(const c of s)o.set(c,(o.get(c)??[]).sort((u,f)=>u.conflict.subject.localeCompare(f.conflict.subject)));return m.jsx("div",{className:"flex h-full flex-col",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[a.length>0&&m.jsx(OH,{title:"Version chains",count:a.length,children:a.map(c=>m.jsx(fH,{entry:c,active:c.decision.conflictId===t,onSelect:()=>e(c.decision.conflictId)},c.decision.conflictId))}),s.map(c=>m.jsx(OH,{title:c,count:(o.get(c)??[]).length,children:(o.get(c)??[]).map(u=>m.jsx(fH,{entry:u,active:u.decision.conflictId===t,onSelect:()=>e(u.decision.conflictId)},u.decision.conflictId))},c))]})})}function OH({title:t,count:e,children:n}){return m.jsxs("div",{children:[m.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/80 px-4 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:[m.jsx("span",{children:t}),m.jsx("span",{children:e})]}),n]})}function fH({entry:t,active:e,onSelect:n}){const{conflict:r,decision:i}=t,a=ZLe(t),o=i.resolution.kind==="custom";return m.jsx("div",{onClick:n,className:`flex cursor-pointer items-start gap-3 border-b border-border/60 px-4 py-2.5 text-xs transition-colors ${e?"bg-primary/10 text-foreground":"hover:bg-muted/40"}`,children:m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{className:"truncate font-medium text-foreground",children:r.subject}),m.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-muted-foreground",children:[m.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${o?"bg-blue-500/15 text-blue-700 dark:text-blue-300":"bg-muted/60 text-muted-foreground"}`,children:o?"custom":"picked"}),m.jsx("span",{className:"truncate",children:a})]}),i.note&&m.jsx("div",{className:"mt-1 text-[11px] italic text-muted-foreground",children:i.note}),m.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground/70",title:new Date(i.resolvedAt).toLocaleString(),children:VLe(i.resolvedAt)})]})})}function ZLe({conflict:t,decision:e}){if(e.resolution.kind==="custom")return dH(e.resolution.content,140);const n=e.resolution.candidateIndex,r=t.candidates[n];if(!r)return`candidate #${n}`;const i=r.claim.content;return i==null?`candidate #${n}`:dH(typeof i=="string"?i:JSON.stringify(i),140)}function dH(t,e){return t.length<=e?t:t.slice(0,e-1).trimEnd()+"…"}function VLe(t){const e=new Date(t).getTime();if(Number.isNaN(e))return t;const n=Math.round((Date.now()-e)/1e3);if(n<5)return"just now";if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r}m ago`;const i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function ci(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n=0,r;n<t.length;n++)(r=ci(t[n]))!==""&&(e+=(e&&" ")+r);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}var ULe={value:()=>{}};function Yw(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Nb(n)}function Nb(t){this._=t}function NLe(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Nb.prototype=Yw.prototype={constructor:Nb,on:function(t,e){var n=this._,r=NLe(t+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(t=r[a]).type)&&(i=WLe(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++a<o;)if(i=(t=r[a]).type)n[i]=hH(n[i],t.name,e);else if(e==null)for(i in n)n[i]=hH(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Nb(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(a=this._[t],r=0,i=a.length;r<i;++r)a[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,a=r.length;i<a;++i)r[i].value.apply(e,n)}};function WLe(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function hH(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ULe,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var RA="http://www.w3.org/1999/xhtml";const pH={svg:"http://www.w3.org/2000/svg",xhtml:RA,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Aw(t){var e=t+="",n=e.indexOf(":");return n>=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),pH.hasOwnProperty(e)?{space:pH[e],local:t}:t}function MLe(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===RA&&e.documentElement.namespaceURI===RA?e.createElement(t):e.createElementNS(n,t)}}function ILe(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function TOe(t){var e=Aw(t);return(e.local?ILe:MLe)(e)}function DLe(){}function HV(t){return t==null?DLe:function(){return this.querySelector(t)}}function LLe(t){typeof t!="function"&&(t=HV(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=new Array(o),l,c,u=0;u<o;++u)(l=a[u])&&(c=t.call(l,l.__data__,u,a))&&("__data__"in l&&(c.__data__=l.__data__),s[u]=c);return new mo(r,this._parents)}function GLe(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function BLe(){return[]}function kOe(t){return t==null?BLe:function(){return this.querySelectorAll(t)}}function FLe(t){return function(){return GLe(t.apply(this,arguments))}}function HLe(t){typeof t=="function"?t=FLe(t):t=kOe(t);for(var e=this._groups,n=e.length,r=[],i=[],a=0;a<n;++a)for(var o=e[a],s=o.length,l,c=0;c<s;++c)(l=o[c])&&(r.push(t.call(l,l.__data__,c,o)),i.push(l));return new mo(r,i)}function _Oe(t){return function(){return this.matches(t)}}function XOe(t){return function(e){return e.matches(t)}}var KLe=Array.prototype.find;function JLe(t){return function(){return KLe.call(this.children,t)}}function eGe(){return this.firstElementChild}function tGe(t){return this.select(t==null?eGe:JLe(typeof t=="function"?t:XOe(t)))}var nGe=Array.prototype.filter;function rGe(){return Array.from(this.children)}function iGe(t){return function(){return nGe.call(this.children,t)}}function aGe(t){return this.selectAll(t==null?rGe:iGe(typeof t=="function"?t:XOe(t)))}function oGe(t){typeof t!="function"&&(t=_Oe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=[],l,c=0;c<o;++c)(l=a[c])&&t.call(l,l.__data__,c,a)&&s.push(l);return new mo(r,this._parents)}function ROe(t){return new Array(t.length)}function sGe(){return new mo(this._enter||this._groups.map(ROe),this._parents)}function G1(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}G1.prototype={constructor:G1,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function lGe(t){return function(){return t}}function cGe(t,e,n,r,i,a){for(var o=0,s,l=e.length,c=a.length;o<c;++o)(s=e[o])?(s.__data__=a[o],r[o]=s):n[o]=new G1(t,a[o]);for(;o<l;++o)(s=e[o])&&(i[o]=s)}function uGe(t,e,n,r,i,a,o){var s,l,c=new Map,u=e.length,f=a.length,h=new Array(u),p;for(s=0;s<u;++s)(l=e[s])&&(h[s]=p=o.call(l,l.__data__,s,e)+"",c.has(p)?i[s]=l:c.set(p,l));for(s=0;s<f;++s)p=o.call(t,a[s],s,a)+"",(l=c.get(p))?(r[s]=l,l.__data__=a[s],c.delete(p)):n[s]=new G1(t,a[s]);for(s=0;s<u;++s)(l=e[s])&&c.get(h[s])===l&&(i[s]=l)}function OGe(t){return t.__data__}function fGe(t,e){if(!arguments.length)return Array.from(this,OGe);var n=e?uGe:cGe,r=this._parents,i=this._groups;typeof t!="function"&&(t=lGe(t));for(var a=i.length,o=new Array(a),s=new Array(a),l=new Array(a),c=0;c<a;++c){var u=r[c],f=i[c],h=f.length,p=dGe(t.call(u,u&&u.__data__,c,r)),y=p.length,v=s[c]=new Array(y),$=o[c]=new Array(y),x=l[c]=new Array(h);n(u,f,v,$,x,p,e);for(var S=0,b=0,T,w;S<y;++S)if(T=v[S]){for(S>=b&&(b=S+1);!(w=$[b])&&++b<y;);T._next=w||null}}return o=new mo(o,r),o._enter=s,o._exit=l,o}function dGe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function hGe(){return new mo(this._exit||this._groups.map(ROe),this._parents)}function pGe(t,e,n){var r=this.enter(),i=this,a=this.exit();return typeof t=="function"?(r=t(r),r&&(r=r.selection())):r=r.append(t+""),e!=null&&(i=e(i),i&&(i=i.selection())),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function mGe(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),l=0;l<o;++l)for(var c=n[l],u=r[l],f=c.length,h=s[l]=new Array(f),p,y=0;y<f;++y)(p=c[y]||u[y])&&(h[y]=p);for(;l<i;++l)s[l]=n[l];return new mo(s,this._parents)}function gGe(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r=t[e],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function yGe(t){t||(t=$Ge);function e(f,h){return f&&h?t(f.__data__,h.__data__):!f-!h}for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,l=i[a]=new Array(s),c,u=0;u<s;++u)(c=o[u])&&(l[u]=c);l.sort(e)}return new mo(i,this._parents).order()}function $Ge(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function vGe(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function xGe(){return Array.from(this)}function QGe(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function bGe(){let t=0;for(const e of this)++t;return t}function SGe(){return!this.node()}function wGe(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&t.call(s,s.__data__,a,i);return this}function PGe(t){return function(){this.removeAttribute(t)}}function TGe(t){return function(){this.removeAttributeNS(t.space,t.local)}}function kGe(t,e){return function(){this.setAttribute(t,e)}}function _Ge(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function XGe(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function RGe(t,e){return function(){var n=e.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function jGe(t,e){var n=Aw(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((e==null?n.local?TGe:PGe:typeof e=="function"?n.local?RGe:XGe:n.local?_Ge:kGe)(n,e))}function jOe(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function EGe(t){return function(){this.style.removeProperty(t)}}function CGe(t,e,n){return function(){this.style.setProperty(t,e,n)}}function zGe(t,e,n){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function YGe(t,e,n){return arguments.length>1?this.each((e==null?EGe:typeof e=="function"?zGe:CGe)(t,e,n??"")):Up(this.node(),t)}function Up(t,e){return t.style.getPropertyValue(e)||jOe(t).getComputedStyle(t,null).getPropertyValue(e)}function AGe(t){return function(){delete this[t]}}function qGe(t,e){return function(){this[t]=e}}function ZGe(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function VGe(t,e){return arguments.length>1?this.each((e==null?AGe:typeof e=="function"?ZGe:qGe)(t,e)):this.node()[t]}function EOe(t){return t.trim().split(/^|\s+/)}function KV(t){return t.classList||new COe(t)}function COe(t){this._node=t,this._names=EOe(t.getAttribute("class")||"")}COe.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function zOe(t,e){for(var n=KV(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function YOe(t,e){for(var n=KV(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function UGe(t){return function(){zOe(this,t)}}function NGe(t){return function(){YOe(this,t)}}function WGe(t,e){return function(){(e.apply(this,arguments)?zOe:YOe)(this,t)}}function MGe(t,e){var n=EOe(t+"");if(arguments.length<2){for(var r=KV(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof e=="function"?WGe:e?UGe:NGe)(n,e))}function IGe(){this.textContent=""}function DGe(t){return function(){this.textContent=t}}function LGe(t){return function(){var e=t.apply(this,arguments);this.textContent=e??""}}function GGe(t){return arguments.length?this.each(t==null?IGe:(typeof t=="function"?LGe:DGe)(t)):this.node().textContent}function BGe(){this.innerHTML=""}function FGe(t){return function(){this.innerHTML=t}}function HGe(t){return function(){var e=t.apply(this,arguments);this.innerHTML=e??""}}function KGe(t){return arguments.length?this.each(t==null?BGe:(typeof t=="function"?HGe:FGe)(t)):this.node().innerHTML}function JGe(){this.nextSibling&&this.parentNode.appendChild(this)}function eBe(){return this.each(JGe)}function tBe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nBe(){return this.each(tBe)}function rBe(t){var e=typeof t=="function"?t:TOe(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function iBe(){return null}function aBe(t,e){var n=typeof t=="function"?t:TOe(t),r=e==null?iBe:typeof e=="function"?e:HV(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function oBe(){var t=this.parentNode;t&&t.removeChild(this)}function sBe(){return this.each(oBe)}function lBe(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function cBe(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function uBe(t){return this.select(t?cBe:lBe)}function OBe(t){return arguments.length?this.property("__data__",t):this.node().__data__}function fBe(t){return function(e){t.call(this,e,this.__data__)}}function dBe(t){return t.trim().split(/^|\s+/).map(function(e){var n="",r=e.indexOf(".");return r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function hBe(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,a;n<i;++n)a=e[n],(!t.type||a.type===t.type)&&a.name===t.name?this.removeEventListener(a.type,a.listener,a.options):e[++r]=a;++r?e.length=r:delete this.__on}}}function pBe(t,e,n){return function(){var r=this.__on,i,a=fBe(e);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=e;return}}this.addEventListener(t.type,a,n),i={type:t.type,name:t.name,value:e,listener:a,options:n},r?r.push(i):this.__on=[i]}}function mBe(t,e,n){var r=dBe(t+""),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,u;l<c;++l)for(i=0,u=s[l];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=e?pBe:hBe,i=0;i<a;++i)this.each(s(r[i],e,n));return this}function AOe(t,e,n){var r=jOe(t),i=r.CustomEvent;typeof i=="function"?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}function gBe(t,e){return function(){return AOe(this,t,e)}}function yBe(t,e){return function(){return AOe(this,t,e.apply(this,arguments))}}function $Be(t,e){return this.each((typeof e=="function"?yBe:gBe)(t,e))}function*vBe(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var qOe=[null];function mo(t,e){this._groups=t,this._parents=e}function Ev(){return new mo([[document.documentElement]],qOe)}function xBe(){return this}mo.prototype=Ev.prototype={constructor:mo,select:LLe,selectAll:HLe,selectChild:tGe,selectChildren:aGe,filter:oGe,data:fGe,enter:sGe,exit:hGe,join:pGe,merge:mGe,selection:xBe,order:gGe,sort:yGe,call:vGe,nodes:xGe,node:QGe,size:bGe,empty:SGe,each:wGe,attr:jGe,style:YGe,property:VGe,classed:MGe,text:GGe,html:KGe,raise:eBe,lower:nBe,append:rBe,insert:aBe,remove:sBe,clone:uBe,datum:OBe,on:mBe,dispatch:$Be,[Symbol.iterator]:vBe};function oo(t){return typeof t=="string"?new mo([[document.querySelector(t)]],[document.documentElement]):new mo([[t]],qOe)}function QBe(t){let e;for(;e=t.sourceEvent;)t=e;return t}function ls(t,e){if(t=QBe(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const bBe={passive:!1},W$={capture:!0,passive:!1};function H2(t){t.stopImmediatePropagation()}function Vh(t){t.preventDefault(),t.stopImmediatePropagation()}function ZOe(t){var e=t.document.documentElement,n=oo(t).on("dragstart.drag",Vh,W$);"onselectstart"in e?n.on("selectstart.drag",Vh,W$):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function VOe(t,e){var n=t.document.documentElement,r=oo(t).on("dragstart.drag",null);e&&(r.on("click.drag",Vh,W$),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const GQ=t=>()=>t;function jA(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}jA.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function SBe(t){return!t.ctrlKey&&!t.button}function wBe(){return this.parentNode}function PBe(t,e){return e??{x:t.x,y:t.y}}function TBe(){return navigator.maxTouchPoints||"ontouchstart"in this}function UOe(){var t=SBe,e=wBe,n=PBe,r=TBe,i={},a=Yw("start","drag","end"),o=0,s,l,c,u,f=0;function h(T){T.on("mousedown.drag",p).filter(r).on("touchstart.drag",$).on("touchmove.drag",x,bBe).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(T,w){if(!(u||!t.call(this,T,w))){var P=b(this,e.call(this,T,w),T,w,"mouse");P&&(oo(T.view).on("mousemove.drag",y,W$).on("mouseup.drag",v,W$),ZOe(T.view),H2(T),c=!1,s=T.clientX,l=T.clientY,P("start",T))}}function y(T){if(Vh(T),!c){var w=T.clientX-s,P=T.clientY-l;c=w*w+P*P>f}i.mouse("drag",T)}function v(T){oo(T.view).on("mousemove.drag mouseup.drag",null),VOe(T.view,c),Vh(T),i.mouse("end",T)}function $(T,w){if(t.call(this,T,w)){var P=T.changedTouches,k=e.call(this,T,w),R=P.length,E,C;for(E=0;E<R;++E)(C=b(this,k,T,w,P[E].identifier,P[E]))&&(H2(T),C("start",T,P[E]))}}function x(T){var w=T.changedTouches,P=w.length,k,R;for(k=0;k<P;++k)(R=i[w[k].identifier])&&(Vh(T),R("drag",T,w[k]))}function S(T){var w=T.changedTouches,P=w.length,k,R;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),k=0;k<P;++k)(R=i[w[k].identifier])&&(H2(T),R("end",T,w[k]))}function b(T,w,P,k,R,E){var C=a.copy(),z=ls(E||P,w),Y,W,A;if((A=n.call(T,new jA("beforestart",{sourceEvent:P,target:h,identifier:R,active:o,x:z[0],y:z[1],dx:0,dy:0,dispatch:C}),k))!=null)return Y=A.x-z[0]||0,W=A.y-z[1]||0,function q(N,Z,D){var M=z,V;switch(N){case"start":i[R]=q,V=o++;break;case"end":delete i[R],--o;case"drag":z=ls(D||Z,w),V=o;break}C.call(N,T,new jA(N,{sourceEvent:Z,subject:A,target:h,identifier:R,active:V,x:z[0]+Y,y:z[1]+W,dx:z[0]-M[0],dy:z[1]-M[1],dispatch:C}),k)}}return h.filter=function(T){return arguments.length?(t=typeof T=="function"?T:GQ(!!T),h):t},h.container=function(T){return arguments.length?(e=typeof T=="function"?T:GQ(T),h):e},h.subject=function(T){return arguments.length?(n=typeof T=="function"?T:GQ(T),h):n},h.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:GQ(!!T),h):r},h.on=function(){var T=a.on.apply(a,arguments);return T===a?h:T},h.clickDistance=function(T){return arguments.length?(f=(T=+T)*T,h):Math.sqrt(f)},h}var Np=0,iy=0,Zg=0,NOe=1e3,B1,ay,F1=0,Mf=0,qw=0,M$=typeof performance=="object"&&performance.now?performance:Date,WOe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function JV(){return Mf||(WOe(kBe),Mf=M$.now()+qw)}function kBe(){Mf=0}function H1(){this._call=this._time=this._next=null}H1.prototype=MOe.prototype={constructor:H1,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?JV():+n)+(e==null?0:+e),!this._next&&ay!==this&&(ay?ay._next=this:B1=this,ay=this),this._call=t,this._time=n,EA()},stop:function(){this._call&&(this._call=null,this._time=1/0,EA())}};function MOe(t,e,n){var r=new H1;return r.restart(t,e,n),r}function _Be(){JV(),++Np;for(var t=B1,e;t;)(e=Mf-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Np}function mH(){Mf=(F1=M$.now())+qw,Np=iy=0;try{_Be()}finally{Np=0,RBe(),Mf=0}}function XBe(){var t=M$.now(),e=t-F1;e>NOe&&(qw-=e,F1=t)}function RBe(){for(var t,e=B1,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:B1=n);ay=t,EA(r)}function EA(t){if(!Np){iy&&(iy=clearTimeout(iy));var e=t-Mf;e>24?(t<1/0&&(iy=setTimeout(mH,t-M$.now()-qw)),Zg&&(Zg=clearInterval(Zg))):(Zg||(F1=M$.now(),Zg=setInterval(XBe,NOe)),Np=1,WOe(mH))}}function gH(t,e,n){var r=new H1;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var jBe=Yw("start","end","cancel","interrupt"),EBe=[],IOe=0,yH=1,CA=2,Wb=3,$H=4,zA=5,Mb=6;function Zw(t,e,n,r,i,a){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;CBe(t,n,{name:e,index:r,group:i,on:jBe,tween:EBe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:IOe})}function eU(t,e){var n=js(t,e);if(n.state>IOe)throw new Error("too late; already scheduled");return n}function Rl(t,e){var n=js(t,e);if(n.state>Wb)throw new Error("too late; already running");return n}function js(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function CBe(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=MOe(a,0,n.time);function a(c){n.state=yH,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,f,h,p;if(n.state!==yH)return l();for(u in r)if(p=r[u],p.name===n.name){if(p.state===Wb)return gH(o);p.state===$H?(p.state=Mb,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete r[u]):+u<e&&(p.state=Mb,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete r[u])}if(gH(function(){n.state===Wb&&(n.state=$H,n.timer.restart(s,n.delay,n.time),s(c))}),n.state=CA,n.on.call("start",t,t.__data__,n.index,n.group),n.state===CA){for(n.state=Wb,i=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(p=n.tween[u].value.call(t,t.__data__,n.index,n.group))&&(i[++f]=p);i.length=f+1}}function s(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=zA,1),f=-1,h=i.length;++f<h;)i[f].call(t,u);n.state===zA&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){n.state=Mb,n.timer.stop(),delete r[e];for(var c in r)return;delete t.__transition}}function Ib(t,e){var n=t.__transition,r,i,a=!0,o;if(n){e=e==null?null:e+"";for(o in n){if((r=n[o]).name!==e){a=!1;continue}i=r.state>CA&&r.state<zA,r.state=Mb,r.timer.stop(),r.on.call(i?"interrupt":"cancel",t,t.__data__,r.index,r.group),delete n[o]}a&&delete t.__transition}}function zBe(t){return this.each(function(){Ib(this,t)})}function YBe(t,e){var n,r;return function(){var i=Rl(this,t),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===e){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ABe(t,e,n){var r,i;if(typeof n!="function")throw new Error;return function(){var a=Rl(this,t),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:e,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===e){i[l]=s;break}l===c&&i.push(s)}a.tween=i}}function qBe(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r=js(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===t)return o.value;return null}return this.each((e==null?YBe:ABe)(n,t,e))}function tU(t,e,n){var r=t._id;return t.each(function(){var i=Rl(this,r);(i.value||(i.value={}))[e]=n.apply(this,arguments)}),function(i){return js(i,r).value[e]}}function DOe(t,e){var n;return(typeof e=="number"?Os:e instanceof Vf?u1:(n=Vf(e))?(e=n,u1):Ble)(t,e)}function ZBe(t){return function(){this.removeAttribute(t)}}function VBe(t){return function(){this.removeAttributeNS(t.space,t.local)}}function UBe(t,e,n){var r,i=n+"",a;return function(){var o=this.getAttribute(t);return o===i?null:o===r?a:a=e(r=o,n)}}function NBe(t,e,n){var r,i=n+"",a;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===r?a:a=e(r=o,n)}}function WBe(t,e,n){var r,i,a;return function(){var o,s=n(this),l;return s==null?void this.removeAttribute(t):(o=this.getAttribute(t),l=s+"",o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s)))}}function MBe(t,e,n){var r,i,a;return function(){var o,s=n(this),l;return s==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),l=s+"",o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s)))}}function IBe(t,e){var n=Aw(t),r=n==="transform"?dUe:DOe;return this.attrTween(t,typeof e=="function"?(n.local?MBe:WBe)(n,r,tU(this,"attr."+t,e)):e==null?(n.local?VBe:ZBe)(n):(n.local?NBe:UBe)(n,r,e))}function DBe(t,e){return function(n){this.setAttribute(t,e.call(this,n))}}function LBe(t,e){return function(n){this.setAttributeNS(t.space,t.local,e.call(this,n))}}function GBe(t,e){var n,r;function i(){var a=e.apply(this,arguments);return a!==r&&(n=(r=a)&&LBe(t,a)),n}return i._value=e,i}function BBe(t,e){var n,r;function i(){var a=e.apply(this,arguments);return a!==r&&(n=(r=a)&&DBe(t,a)),n}return i._value=e,i}function FBe(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;var r=Aw(t);return this.tween(n,(r.local?GBe:BBe)(r,e))}function HBe(t,e){return function(){eU(this,t).delay=+e.apply(this,arguments)}}function KBe(t,e){return e=+e,function(){eU(this,t).delay=e}}function JBe(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?HBe:KBe)(e,t)):js(this.node(),e).delay}function eFe(t,e){return function(){Rl(this,t).duration=+e.apply(this,arguments)}}function tFe(t,e){return e=+e,function(){Rl(this,t).duration=e}}function nFe(t){var e=this._id;return arguments.length?this.each((typeof t=="function"?eFe:tFe)(e,t)):js(this.node(),e).duration}function rFe(t,e){if(typeof e!="function")throw new Error;return function(){Rl(this,t).ease=e}}function iFe(t){var e=this._id;return arguments.length?this.each(rFe(e,t)):js(this.node(),e).ease}function aFe(t,e){return function(){var n=e.apply(this,arguments);if(typeof n!="function")throw new Error;Rl(this,t).ease=n}}function oFe(t){if(typeof t!="function")throw new Error;return this.each(aFe(this._id,t))}function sFe(t){typeof t!="function"&&(t=_Oe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i)for(var a=e[i],o=a.length,s=r[i]=[],l,c=0;c<o;++c)(l=a[c])&&t.call(l,l.__data__,c,a)&&s.push(l);return new Nc(r,this._parents,this._name,this._id)}function lFe(t){if(t._id!==this._id)throw new Error;for(var e=this._groups,n=t._groups,r=e.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var l=e[s],c=n[s],u=l.length,f=o[s]=new Array(u),h,p=0;p<u;++p)(h=l[p]||c[p])&&(f[p]=h);for(;s<r;++s)o[s]=e[s];return new Nc(o,this._parents,this._name,this._id)}function cFe(t){return(t+"").trim().split(/^|\s+/).every(function(e){var n=e.indexOf(".");return n>=0&&(e=e.slice(0,n)),!e||e==="start"})}function uFe(t,e,n){var r,i,a=cFe(e)?eU:Rl;return function(){var o=a(this,t),s=o.on;s!==r&&(i=(r=s).copy()).on(e,n),o.on=i}}function OFe(t,e){var n=this._id;return arguments.length<2?js(this.node(),n).on.on(t):this.each(uFe(n,t,e))}function fFe(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function dFe(){return this.on("end.remove",fFe(this._id))}function hFe(t){var e=this._name,n=this._id;typeof t!="function"&&(t=HV(t));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s=r[o],l=s.length,c=a[o]=new Array(l),u,f,h=0;h<l;++h)(u=s[h])&&(f=t.call(u,u.__data__,h,s))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,Zw(c[h],e,n,h,c,js(u,n)));return new Nc(a,this._parents,e,n)}function pFe(t){var e=this._name,n=this._id;typeof t!="function"&&(t=kOe(t));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var l=r[s],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var h=t.call(u,u.__data__,f,l),p,y=js(u,n),v=0,$=h.length;v<$;++v)(p=h[v])&&Zw(p,e,n,v,h,y);a.push(h),o.push(u)}return new Nc(a,o,e,n)}var mFe=Ev.prototype.constructor;function gFe(){return new mFe(this._groups,this._parents)}function yFe(t,e){var n,r,i;return function(){var a=Up(this,t),o=(this.style.removeProperty(t),Up(this,t));return a===o?null:a===n&&o===r?i:i=e(n=a,r=o)}}function LOe(t){return function(){this.style.removeProperty(t)}}function $Fe(t,e,n){var r,i=n+"",a;return function(){var o=Up(this,t);return o===i?null:o===r?a:a=e(r=o,n)}}function vFe(t,e,n){var r,i,a;return function(){var o=Up(this,t),s=n(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(t),Up(this,t))),o===l?null:o===r&&l===i?a:(i=l,a=e(r=o,s))}}function xFe(t,e){var n,r,i,a="style."+e,o="end."+a,s;return function(){var l=Rl(this,t),c=l.on,u=l.value[a]==null?s||(s=LOe(e)):void 0;(c!==n||i!==u)&&(r=(n=c).copy()).on(o,i=u),l.on=r}}function QFe(t,e,n){var r=(t+="")=="transform"?fUe:DOe;return e==null?this.styleTween(t,yFe(t,r)).on("end.style."+t,LOe(t)):typeof e=="function"?this.styleTween(t,vFe(t,r,tU(this,"style."+t,e))).each(xFe(this._id,t)):this.styleTween(t,$Fe(t,r,e),n).on("end.style."+t,null)}function bFe(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}function SFe(t,e,n){var r,i;function a(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&bFe(t,o,n)),r}return a._value=e,a}function wFe(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,SFe(t,e,n??""))}function PFe(t){return function(){this.textContent=t}}function TFe(t){return function(){var e=t(this);this.textContent=e??""}}function kFe(t){return this.tween("text",typeof t=="function"?TFe(tU(this,"text",t)):PFe(t==null?"":t+""))}function _Fe(t){return function(e){this.textContent=t.call(this,e)}}function XFe(t){var e,n;function r(){var i=t.apply(this,arguments);return i!==n&&(e=(n=i)&&_Fe(i)),e}return r._value=t,r}function RFe(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;return this.tween(e,XFe(t))}function jFe(){for(var t=this._name,e=this._id,n=GOe(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,l,c=0;c<s;++c)if(l=o[c]){var u=js(l,e);Zw(l,t,n,c,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Nc(r,this._parents,t,n)}function EFe(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},l={value:function(){--i===0&&a()}};n.each(function(){var c=Rl(this,r),u=c.on;u!==t&&(e=(t=u).copy(),e._.cancel.push(s),e._.interrupt.push(s),e._.end.push(l)),c.on=e}),i===0&&a()})}var CFe=0;function Nc(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function GOe(){return++CFe}var oc=Ev.prototype;Nc.prototype={constructor:Nc,select:hFe,selectAll:pFe,selectChild:oc.selectChild,selectChildren:oc.selectChildren,filter:sFe,merge:lFe,selection:gFe,transition:jFe,call:oc.call,nodes:oc.nodes,node:oc.node,size:oc.size,empty:oc.empty,each:oc.each,on:OFe,attr:IBe,attrTween:FBe,style:QFe,styleTween:wFe,text:kFe,textTween:RFe,remove:dFe,tween:qBe,delay:JBe,duration:nFe,ease:iFe,easeVarying:oFe,end:EFe,[Symbol.iterator]:oc[Symbol.iterator]};function zFe(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var YFe={time:null,delay:0,duration:250,ease:zFe};function AFe(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw new Error(`transition ${e} not found`);return n}function qFe(t){var e,n;t instanceof Nc?(e=t._id,t=t._name):(e=GOe(),(n=YFe).time=JV(),t=t==null?null:t+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,l,c=0;c<s;++c)(l=o[c])&&Zw(l,t,e,c,o,n||AFe(l,e));return new Nc(r,this._parents,t,e)}Ev.prototype.interrupt=zBe;Ev.prototype.transition=qFe;const BQ=t=>()=>t;function ZFe(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function xc(t,e,n){this.k=t,this.x=e,this.y=n}xc.prototype={constructor:xc,scale:function(t){return t===1?this:new xc(this.k*t,this.x,this.y)},translate:function(t,e){return t===0&e===0?this:new xc(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vw=new xc(1,0,0);BOe.prototype=xc.prototype;function BOe(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vw;return t.__zoom}function K2(t){t.stopImmediatePropagation()}function Vg(t){t.preventDefault(),t.stopImmediatePropagation()}function VFe(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function UFe(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function vH(){return this.__zoom||Vw}function NFe(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function WFe(){return navigator.maxTouchPoints||"ontouchstart"in this}function MFe(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],a=t.invertY(e[0][1])-n[0][1],o=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function FOe(){var t=VFe,e=UFe,n=MFe,r=NFe,i=WFe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,l=Vb,c=Yw("start","zoom","end"),u,f,h,p=500,y=150,v=0,$=10;function x(A){A.property("__zoom",vH).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",C).filter(i).on("touchstart.zoom",z).on("touchmove.zoom",Y).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(A,q,N,Z){var D=A.selection?A.selection():A;D.property("__zoom",vH),A!==D?w(A,q,N,Z):D.interrupt().each(function(){P(this,arguments).event(Z).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},x.scaleBy=function(A,q,N,Z){x.scaleTo(A,function(){var D=this.__zoom.k,M=typeof q=="function"?q.apply(this,arguments):q;return D*M},N,Z)},x.scaleTo=function(A,q,N,Z){x.transform(A,function(){var D=e.apply(this,arguments),M=this.__zoom,V=N==null?T(D):typeof N=="function"?N.apply(this,arguments):N,I=M.invert(V),B=typeof q=="function"?q.apply(this,arguments):q;return n(b(S(M,B),V,I),D,o)},N,Z)},x.translateBy=function(A,q,N,Z){x.transform(A,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof N=="function"?N.apply(this,arguments):N),e.apply(this,arguments),o)},null,Z)},x.translateTo=function(A,q,N,Z,D){x.transform(A,function(){var M=e.apply(this,arguments),V=this.__zoom,I=Z==null?T(M):typeof Z=="function"?Z.apply(this,arguments):Z;return n(Vw.translate(I[0],I[1]).scale(V.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof N=="function"?-N.apply(this,arguments):-N),M,o)},Z,D)};function S(A,q){return q=Math.max(a[0],Math.min(a[1],q)),q===A.k?A:new xc(q,A.x,A.y)}function b(A,q,N){var Z=q[0]-N[0]*A.k,D=q[1]-N[1]*A.k;return Z===A.x&&D===A.y?A:new xc(A.k,Z,D)}function T(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function w(A,q,N,Z){A.on("start.zoom",function(){P(this,arguments).event(Z).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(Z).end()}).tween("zoom",function(){var D=this,M=arguments,V=P(D,M).event(Z),I=e.apply(D,M),B=N==null?T(I):typeof N=="function"?N.apply(D,M):N,L=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),J=D.__zoom,K=typeof q=="function"?q.apply(D,M):q,H=l(J.invert(B).concat(L/J.k),K.invert(B).concat(L/K.k));return function(re){if(re===1)re=K;else{var F=H(re),te=L/F[2];re=new xc(te,B[0]-F[0]*te,B[1]-F[1]*te)}V.zoom(null,re)}})}function P(A,q,N){return!N&&A.__zooming||new k(A,q)}function k(A,q){this.that=A,this.args=q,this.active=0,this.sourceEvent=null,this.extent=e.apply(A,q),this.taps=0}k.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,q){return this.mouse&&A!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var q=oo(this.that).datum();c.call(A,this.that,new ZFe(A,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:c}),q)}};function R(A,...q){if(!t.apply(this,arguments))return;var N=P(this,q).event(A),Z=this.__zoom,D=Math.max(a[0],Math.min(a[1],Z.k*Math.pow(2,r.apply(this,arguments)))),M=ls(A);if(N.wheel)(N.mouse[0][0]!==M[0]||N.mouse[0][1]!==M[1])&&(N.mouse[1]=Z.invert(N.mouse[0]=M)),clearTimeout(N.wheel);else{if(Z.k===D)return;N.mouse=[M,Z.invert(M)],Ib(this),N.start()}Vg(A),N.wheel=setTimeout(V,y),N.zoom("mouse",n(b(S(Z,D),N.mouse[0],N.mouse[1]),N.extent,o));function V(){N.wheel=null,N.end()}}function E(A,...q){if(h||!t.apply(this,arguments))return;var N=A.currentTarget,Z=P(this,q,!0).event(A),D=oo(A.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",L,!0),M=ls(A,N),V=A.clientX,I=A.clientY;ZOe(A.view),K2(A),Z.mouse=[M,this.__zoom.invert(M)],Ib(this),Z.start();function B(J){if(Vg(J),!Z.moved){var K=J.clientX-V,H=J.clientY-I;Z.moved=K*K+H*H>v}Z.event(J).zoom("mouse",n(b(Z.that.__zoom,Z.mouse[0]=ls(J,N),Z.mouse[1]),Z.extent,o))}function L(J){D.on("mousemove.zoom mouseup.zoom",null),VOe(J.view,Z.moved),Vg(J),Z.event(J).end()}}function C(A,...q){if(t.apply(this,arguments)){var N=this.__zoom,Z=ls(A.changedTouches?A.changedTouches[0]:A,this),D=N.invert(Z),M=N.k*(A.shiftKey?.5:2),V=n(b(S(N,M),Z,D),e.apply(this,q),o);Vg(A),s>0?oo(this).transition().duration(s).call(w,V,Z,A):oo(this).call(x.transform,V,Z,A)}}function z(A,...q){if(t.apply(this,arguments)){var N=A.touches,Z=N.length,D=P(this,q,A.changedTouches.length===Z).event(A),M,V,I,B;for(K2(A),V=0;V<Z;++V)I=N[V],B=ls(I,this),B=[B,this.__zoom.invert(B),I.identifier],D.touch0?!D.touch1&&D.touch0[2]!==B[2]&&(D.touch1=B,D.taps=0):(D.touch0=B,M=!0,D.taps=1+!!u);u&&(u=clearTimeout(u)),M&&(D.taps<2&&(f=B[0],u=setTimeout(function(){u=null},p)),Ib(this),D.start())}}function Y(A,...q){if(this.__zooming){var N=P(this,q).event(A),Z=A.changedTouches,D=Z.length,M,V,I,B;for(Vg(A),M=0;M<D;++M)V=Z[M],I=ls(V,this),N.touch0&&N.touch0[2]===V.identifier?N.touch0[0]=I:N.touch1&&N.touch1[2]===V.identifier&&(N.touch1[0]=I);if(V=N.that.__zoom,N.touch1){var L=N.touch0[0],J=N.touch0[1],K=N.touch1[0],H=N.touch1[1],re=(re=K[0]-L[0])*re+(re=K[1]-L[1])*re,F=(F=H[0]-J[0])*F+(F=H[1]-J[1])*F;V=S(V,Math.sqrt(re/F)),I=[(L[0]+K[0])/2,(L[1]+K[1])/2],B=[(J[0]+H[0])/2,(J[1]+H[1])/2]}else if(N.touch0)I=N.touch0[0],B=N.touch0[1];else return;N.zoom("touch",n(b(V,I,B),N.extent,o))}}function W(A,...q){if(this.__zooming){var N=P(this,q).event(A),Z=A.changedTouches,D=Z.length,M,V;for(K2(A),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),M=0;M<D;++M)V=Z[M],N.touch0&&N.touch0[2]===V.identifier?delete N.touch0:N.touch1&&N.touch1[2]===V.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(V=ls(V,this),Math.hypot(f[0]-V[0],f[1]-V[1])<$)){var I=oo(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return x.wheelDelta=function(A){return arguments.length?(r=typeof A=="function"?A:BQ(+A),x):r},x.filter=function(A){return arguments.length?(t=typeof A=="function"?A:BQ(!!A),x):t},x.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:BQ(!!A),x):i},x.extent=function(A){return arguments.length?(e=typeof A=="function"?A:BQ([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),x):e},x.scaleExtent=function(A){return arguments.length?(a[0]=+A[0],a[1]=+A[1],x):[a[0],a[1]]},x.translateExtent=function(A){return arguments.length?(o[0][0]=+A[0][0],o[1][0]=+A[1][0],o[0][1]=+A[0][1],o[1][1]=+A[1][1],x):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},x.constrain=function(A){return arguments.length?(n=A,x):n},x.duration=function(A){return arguments.length?(s=+A,x):s},x.interpolate=function(A){return arguments.length?(l=A,x):l},x.on=function(){var A=c.on.apply(c,arguments);return A===c?x:A},x.clickDistance=function(A){return arguments.length?(v=(A=+A)*A,x):Math.sqrt(v)},x.tapDistance=function(A){return arguments.length?($=+A,x):$},x}const Ss={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},I$=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],HOe=["Enter"," ","Escape"],KOe={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Wp;(function(t){t.Strict="strict",t.Loose="loose"})(Wp||(Wp={}));var Xf;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Xf||(Xf={}));var D$;(function(t){t.Partial="partial",t.Full="full"})(D$||(D$={}));const JOe={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Wu;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Wu||(Wu={}));var K1;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(K1||(K1={}));var Ce;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Ce||(Ce={}));const xH={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top};function IFe(t,e){if(!t&&!e)return!0;if(!t||!e||t.size!==e.size)return!1;if(!t.size&&!e.size)return!0;for(const n of t.keys())if(!e.has(n))return!1;return!0}function QH(t,e,n){if(!n)return;const r=[];t.forEach((i,a)=>{e!=null&&e.has(a)||r.push(i)}),r.length&&n(r)}function efe(t){return t===null?null:t?"valid":"invalid"}const tfe=t=>"id"in t&&"source"in t&&"target"in t,DFe=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),nU=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Cv=(t,e=[0,0])=>{const{width:n,height:r}=Bc(t),i=t.origin??e,a=n*i[0],o=r*i[1];return{x:t.position.x-a,y:t.position.y-o}},LFe=(t,e={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((r,i)=>{const a=typeof i=="string";let o=!e.nodeLookup&&!a?i:void 0;e.nodeLookup&&(o=a?e.nodeLookup.get(i):nU(i)?i:e.nodeLookup.get(i.id));const s=o?J1(o,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Uw(r,s)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nw(n)},zv=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return t.forEach(i=>{(e.filter===void 0||e.filter(i))&&(n=Uw(n,J1(i)),r=!0)}),r?Nw(n):{x:0,y:0,width:0,height:0}},rU=(t,e,[n,r,i]=[0,0,1],a=!1,o=!1)=>{const s={...Av(e,[n,r,i]),width:e.width/i,height:e.height/i},l=[];for(const c of t.values()){const{measured:u,selectable:f=!0,hidden:h=!1}=c;if(o&&!f||h)continue;const p=u.width??c.width??c.initialWidth??null,y=u.height??c.height??c.initialHeight??null,v=L$(s,Ip(c)),$=(p??0)*(y??0),x=a&&v>0;(!c.internals.handleBounds||x||v>=$||c.dragging)&&l.push(c)}return l},GFe=(t,e)=>{const n=new Set;return t.forEach(r=>{n.add(r.id)}),e.filter(r=>n.has(r.source)||n.has(r.target))};function BFe(t,e){const n=new Map,r=e!=null&&e.nodes?new Set(e.nodes.map(i=>i.id)):null;return t.forEach(i=>{i.measured.width&&i.measured.height&&((e==null?void 0:e.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function FFe({nodes:t,width:e,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(t.size===0)return Promise.resolve(!0);const s=BFe(t,o),l=zv(s),c=iU(l,e,n,(o==null?void 0:o.minZoom)??i,(o==null?void 0:o.maxZoom)??a,(o==null?void 0:o.padding)??.1);return await r.setViewport(c,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),Promise.resolve(!0)}function nfe({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){const o=n.get(t),s=o.parentId?n.get(o.parentId):void 0,{x:l,y:c}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r;let f=o.extent||i;if(o.extent==="parent"&&!o.expandParent)if(!s)a==null||a("005",Ss.error005());else{const p=s.measured.width,y=s.measured.height;p&&y&&(f=[[l,c],[l+p,c+y]])}else s&&Dp(o.extent)&&(f=[[o.extent[0][0]+l,o.extent[0][1]+c],[o.extent[1][0]+l,o.extent[1][1]+c]]);const h=Dp(f)?If(e,f,o.measured):e;return(o.measured.width===void 0||o.measured.height===void 0)&&(a==null||a("015",Ss.error015())),{position:{x:h.x-l+(o.measured.width??0)*u[0],y:h.y-c+(o.measured.height??0)*u[1]},positionAbsolute:h}}async function HFe({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:i}){const a=new Set(t.map(h=>h.id)),o=[];for(const h of n){if(h.deletable===!1)continue;const p=a.has(h.id),y=!p&&h.parentId&&o.find(v=>v.id===h.parentId);(p||y)&&o.push(h)}const s=new Set(e.map(h=>h.id)),l=r.filter(h=>h.deletable!==!1),u=GFe(o,l);for(const h of l)s.has(h.id)&&!u.find(y=>y.id===h.id)&&u.push(h);if(!i)return{edges:u,nodes:o};const f=await i({nodes:o,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:o}:{edges:[],nodes:[]}:f}const Mp=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),If=(t={x:0,y:0},e,n)=>({x:Mp(t.x,e[0][0],e[1][0]-((n==null?void 0:n.width)??0)),y:Mp(t.y,e[0][1],e[1][1]-((n==null?void 0:n.height)??0))});function rfe(t,e,n){const{width:r,height:i}=Bc(n),{x:a,y:o}=n.internals.positionAbsolute;return If(t,[[a,o],[a+r,o+i]],e)}const bH=(t,e,n)=>t<e?Mp(Math.abs(t-e),1,e)/e:t>n?-Mp(Math.abs(t-n),1,e)/e:0,ife=(t,e,n=15,r=40)=>{const i=bH(t.x,r,e.width-r)*n,a=bH(t.y,r,e.height-r)*n;return[i,a]},Uw=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),YA=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),Nw=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),Ip=(t,e=[0,0])=>{var i,a;const{x:n,y:r}=nU(t)?t.internals.positionAbsolute:Cv(t,e);return{x:n,y:r,width:((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0,height:((a=t.measured)==null?void 0:a.height)??t.height??t.initialHeight??0}},J1=(t,e=[0,0])=>{var i,a;const{x:n,y:r}=nU(t)?t.internals.positionAbsolute:Cv(t,e);return{x:n,y:r,x2:n+(((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0),y2:r+(((a=t.measured)==null?void 0:a.height)??t.height??t.initialHeight??0)}},afe=(t,e)=>Nw(Uw(YA(t),YA(e))),L$=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*r)},SH=t=>ms(t.width)&&ms(t.height)&&ms(t.x)&&ms(t.y),ms=t=>!isNaN(t)&&isFinite(t),KFe=(t,e)=>{},Yv=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),Av=({x:t,y:e},[n,r,i],a=!1,o=[1,1])=>{const s={x:(t-n)/i,y:(e-r)/i};return a?Yv(s,o):s},eS=({x:t,y:e},[n,r,i])=>({x:t*i+n,y:e*i+r});function Oh(t,e){if(typeof t=="number")return Math.floor((e-e/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function JFe(t,e,n){if(typeof t=="string"||typeof t=="number"){const r=Oh(t,n),i=Oh(t,e);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof t=="object"){const r=Oh(t.top??t.y??0,n),i=Oh(t.bottom??t.y??0,n),a=Oh(t.left??t.x??0,e),o=Oh(t.right??t.x??0,e);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function eHe(t,e,n,r,i,a){const{x:o,y:s}=eS(t,[e,n,r]),{x:l,y:c}=eS({x:t.x+t.width,y:t.y+t.height},[e,n,r]),u=i-l,f=a-c;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(f)}}const iU=(t,e,n,r,i,a)=>{const o=JFe(a,e,n),s=(e-o.x)/t.width,l=(n-o.y)/t.height,c=Math.min(s,l),u=Mp(c,r,i),f=t.x+t.width/2,h=t.y+t.height/2,p=e/2-f*u,y=n/2-h*u,v=eHe(t,p,y,u,e,n),$={left:Math.min(v.left-o.left,0),top:Math.min(v.top-o.top,0),right:Math.min(v.right-o.right,0),bottom:Math.min(v.bottom-o.bottom,0)};return{x:p-$.left+$.right,y:y-$.top+$.bottom,zoom:u}},G$=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Dp(t){return t!=null&&t!=="parent"}function Bc(t){var e,n;return{width:((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function ofe(t){var e,n;return(((e=t.measured)==null?void 0:e.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function sfe(t,e={width:0,height:0},n,r,i){const a={...t},o=r.get(n);if(o){const s=o.origin||i;a.x+=o.internals.positionAbsolute.x-(e.width??0)*s[0],a.y+=o.internals.positionAbsolute.y-(e.height??0)*s[1]}return a}function wH(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function tHe(){let t,e;return{promise:new Promise((r,i)=>{t=r,e=i}),resolve:t,reject:e}}function nHe(t){return{...KOe,...t||{}}}function ky(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:a,y:o}=gs(t),s=Av({x:a-((i==null?void 0:i.left)??0),y:o-((i==null?void 0:i.top)??0)},r),{x:l,y:c}=n?Yv(s,e):s;return{xSnapped:l,ySnapped:c,...s}}const aU=t=>({width:t.offsetWidth,height:t.offsetHeight}),lfe=t=>{var e;return((e=t==null?void 0:t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},rHe=["INPUT","SELECT","TEXTAREA"];function cfe(t){var r,i;const e=((i=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:i[0])||t.target;return(e==null?void 0:e.nodeType)!==1?!1:rHe.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey")}const ufe=t=>"clientX"in t,gs=(t,e)=>{var a,o;const n=ufe(t),r=n?t.clientX:(a=t.touches)==null?void 0:a[0].clientX,i=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:i-((e==null?void 0:e.top)??0)}},PH=(t,e,n,r,i)=>{const a=e.querySelectorAll(`.${t}`);return!a||!a.length?null:Array.from(a).map(o=>{const s=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:t,nodeId:i,position:o.getAttribute("data-handlepos"),x:(s.left-n.left)/r,y:(s.top-n.top)/r,...aU(o)}})};function Ofe({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){const l=t*.125+i*.375+o*.375+n*.125,c=e*.125+a*.375+s*.375+r*.125,u=Math.abs(l-t),f=Math.abs(c-e);return[l,c,u,f]}function FQ(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function TH({pos:t,x1:e,y1:n,x2:r,y2:i,c:a}){switch(t){case Ce.Left:return[e-FQ(e-r,a),n];case Ce.Right:return[e+FQ(r-e,a),n];case Ce.Top:return[e,n-FQ(n-i,a)];case Ce.Bottom:return[e,n+FQ(i-n,a)]}}function Qm({sourceX:t,sourceY:e,sourcePosition:n=Ce.Bottom,targetX:r,targetY:i,targetPosition:a=Ce.Top,curvature:o=.25}){const[s,l]=TH({pos:n,x1:t,y1:e,x2:r,y2:i,c:o}),[c,u]=TH({pos:a,x1:r,y1:i,x2:t,y2:e,c:o}),[f,h,p,y]=Ofe({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${t},${e} C${s},${l} ${c},${u} ${r},${i}`,f,h,p,y]}function ffe({sourceX:t,sourceY:e,targetX:n,targetY:r}){const i=Math.abs(n-t)/2,a=n<t?n+i:n-i,o=Math.abs(r-e)/2,s=r<e?r+o:r-o;return[a,s,i,o]}function iHe({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const o=i&&n?r+1e3:r,s=Math.max(t.parentId||i&&t.selected?t.internals.z:0,e.parentId||i&&e.selected?e.internals.z:0);return o+s}function aHe({sourceNode:t,targetNode:e,width:n,height:r,transform:i}){const a=Uw(J1(t),J1(e));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const o={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return L$(o,Nw(a))>0}const oHe=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,sHe=(t,e)=>e.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),lHe=(t,e,n={})=>{if(!t.source||!t.target)return e;const r=n.getEdgeId||oHe;let i;return tfe(t)?i={...t}:i={...t,id:r(t)},sHe(i,e)?e:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,e.concat(i))};function oU({sourceX:t,sourceY:e,targetX:n,targetY:r}){const[i,a,o,s]=ffe({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,i,a,o,s]}const kH={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},cHe=({source:t,sourcePosition:e=Ce.Bottom,target:n})=>e===Ce.Left||e===Ce.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},_H=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function uHe({source:t,sourcePosition:e=Ce.Bottom,target:n,targetPosition:r=Ce.Top,center:i,offset:a,stepPosition:o}){const s=kH[e],l=kH[r],c={x:t.x+s.x*a,y:t.y+s.y*a},u={x:n.x+l.x*a,y:n.y+l.y*a},f=cHe({source:c,sourcePosition:e,target:u}),h=f.x!==0?"x":"y",p=f[h];let y=[],v,$;const x={x:0,y:0},S={x:0,y:0},[,,b,T]=ffe({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(s[h]*l[h]===-1){h==="x"?(v=i.x??c.x+(u.x-c.x)*o,$=i.y??(c.y+u.y)/2):(v=i.x??(c.x+u.x)/2,$=i.y??c.y+(u.y-c.y)*o);const P=[{x:v,y:c.y},{x:v,y:u.y}],k=[{x:c.x,y:$},{x:u.x,y:$}];s[h]===p?y=h==="x"?P:k:y=h==="x"?k:P}else{const P=[{x:c.x,y:u.y}],k=[{x:u.x,y:c.y}];if(h==="x"?y=s.x===p?k:P:y=s.y===p?P:k,e===r){const Y=Math.abs(t[h]-n[h]);if(Y<=a){const W=Math.min(a-1,a-Y);s[h]===p?x[h]=(c[h]>t[h]?-1:1)*W:S[h]=(u[h]>n[h]?-1:1)*W}}if(e!==r){const Y=h==="x"?"y":"x",W=s[h]===l[Y],A=c[Y]>u[Y],q=c[Y]<u[Y];(s[h]===1&&(!W&&A||W&&q)||s[h]!==1&&(!W&&q||W&&A))&&(y=h==="x"?P:k)}const R={x:c.x+x.x,y:c.y+x.y},E={x:u.x+S.x,y:u.y+S.y},C=Math.max(Math.abs(R.x-y[0].x),Math.abs(E.x-y[0].x)),z=Math.max(Math.abs(R.y-y[0].y),Math.abs(E.y-y[0].y));C>=z?(v=(R.x+E.x)/2,$=y[0].y):(v=y[0].x,$=(R.y+E.y)/2)}return[[t,{x:c.x+x.x,y:c.y+x.y},...y,{x:u.x+S.x,y:u.y+S.y},n],v,$,b,T]}function OHe(t,e,n,r){const i=Math.min(_H(t,e)/2,_H(e,n)/2,r),{x:a,y:o}=e;if(t.x===a&&a===n.x||t.y===o&&o===n.y)return`L${a} ${o}`;if(t.y===o){const c=t.x<n.x?-1:1,u=t.y<n.y?1:-1;return`L ${a+i*c},${o}Q ${a},${o} ${a},${o+i*u}`}const s=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${a},${o+i*l}Q ${a},${o} ${a+i*s},${o}`}function Lp({sourceX:t,sourceY:e,sourcePosition:n=Ce.Bottom,targetX:r,targetY:i,targetPosition:a=Ce.Top,borderRadius:o=5,centerX:s,centerY:l,offset:c=20,stepPosition:u=.5}){const[f,h,p,y,v]=uHe({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:l},offset:c,stepPosition:u});return[f.reduce((x,S,b)=>{let T="";return b>0&&b<f.length-1?T=OHe(f[b-1],S,f[b+1],o):T=`${b===0?"M":"L"}${S.x} ${S.y}`,x+=T,x},""),h,p,y,v]}function XH(t){var e;return t&&!!(t.internals.handleBounds||(e=t.handles)!=null&&e.length)&&!!(t.measured.width||t.width||t.initialWidth)}function fHe(t){var f;const{sourceNode:e,targetNode:n}=t;if(!XH(e)||!XH(n))return null;const r=e.internals.handleBounds||RH(e.handles),i=n.internals.handleBounds||RH(n.handles),a=jH((r==null?void 0:r.source)??[],t.sourceHandle),o=jH(t.connectionMode===Wp.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),t.targetHandle);if(!a||!o)return(f=t.onError)==null||f.call(t,"008",Ss.error008(a?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const s=(a==null?void 0:a.position)||Ce.Bottom,l=(o==null?void 0:o.position)||Ce.Top,c=Df(e,a,s),u=Df(n,o,l);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:l}}function RH(t){if(!t)return null;const e=[],n=[];for(const r of t)r.width=r.width??1,r.height=r.height??1,r.type==="source"?e.push(r):r.type==="target"&&n.push(r);return{source:e,target:n}}function Df(t,e,n=Ce.Left,r=!1){const i=((e==null?void 0:e.x)??0)+t.internals.positionAbsolute.x,a=((e==null?void 0:e.y)??0)+t.internals.positionAbsolute.y,{width:o,height:s}=e??Bc(t);if(r)return{x:i+o/2,y:a+s/2};switch((e==null?void 0:e.position)??n){case Ce.Top:return{x:i+o/2,y:a};case Ce.Right:return{x:i+o,y:a+s/2};case Ce.Bottom:return{x:i+o/2,y:a+s};case Ce.Left:return{x:i,y:a+s/2}}}function jH(t,e){return t&&(e?t.find(n=>n.id===e):t[0])||null}function AA(t,e){return t?typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`:""}function dHe(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const a=new Set;return t.reduce((o,s)=>([s.markerStart||r,s.markerEnd||i].forEach(l=>{if(l&&typeof l=="object"){const c=AA(l,e);a.has(c)||(o.push({id:c,color:l.color||n,...l}),a.add(c))}}),o),[]).sort((o,s)=>o.id.localeCompare(s.id))}const dfe=1e3,hHe=10,sU={nodeOrigin:[0,0],nodeExtent:I$,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},pHe={...sU,checkEquality:!0};function lU(t,e){const n={...t};for(const r in e)e[r]!==void 0&&(n[r]=e[r]);return n}function mHe(t,e,n){const r=lU(sU,n);for(const i of t.values())if(i.parentId)uU(i,t,e,r);else{const a=Cv(i,r.nodeOrigin),o=Dp(i.extent)?i.extent:r.nodeExtent,s=If(a,o,Bc(i));i.internals.positionAbsolute=s}}function gHe(t,e){if(!t.handles)return t.measured?e==null?void 0:e.internals.handleBounds:void 0;const n=[],r=[];for(const i of t.handles){const a={id:i.id,width:i.width??1,height:i.height??1,nodeId:t.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(a):i.type==="target"&&r.push(a)}return{source:n,target:r}}function cU(t){return t==="manual"}function qA(t,e,n,r={}){var c,u;const i=lU(pHe,r),a={i:0},o=new Map(e),s=i!=null&&i.elevateNodesOnSelect&&!cU(i.zIndexMode)?dfe:0;let l=t.length>0;e.clear(),n.clear();for(const f of t){let h=o.get(f.id);if(i.checkEquality&&f===(h==null?void 0:h.internals.userNode))e.set(f.id,h);else{const p=Cv(f,i.nodeOrigin),y=Dp(f.extent)?f.extent:i.nodeExtent,v=If(p,y,Bc(f));h={...i.defaults,...f,measured:{width:(c=f.measured)==null?void 0:c.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:v,handleBounds:gHe(f,h),z:hfe(f,s,i.zIndexMode),userNode:f}},e.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),f.parentId&&uU(h,e,n,r,a)}return l}function yHe(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}function uU(t,e,n,r,i){const{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:l}=lU(sU,r),c=t.parentId,u=e.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}yHe(t,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*hHe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);const f=a&&!cU(l)?dfe:0,{x:h,y:p,z:y}=$He(t,u,o,s,f,l),{positionAbsolute:v}=t.internals,$=h!==v.x||p!==v.y;($||y!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:$?{x:h,y:p}:v,z:y}})}function hfe(t,e,n){const r=ms(t.zIndex)?t.zIndex:0;return cU(n)?r:r+(t.selected?e:0)}function $He(t,e,n,r,i,a){const{x:o,y:s}=e.internals.positionAbsolute,l=Bc(t),c=Cv(t,n),u=Dp(t.extent)?If(c,t.extent,l):c;let f=If({x:o+u.x,y:s+u.y},r,l);t.extent==="parent"&&(f=rfe(f,l,e));const h=hfe(t,i,a),p=e.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}function OU(t,e,n,r=[0,0]){var o;const i=[],a=new Map;for(const s of t){const l=e.get(s.parentId);if(!l)continue;const c=((o=a.get(s.parentId))==null?void 0:o.expandedRect)??Ip(l),u=afe(c,s.rect);a.set(s.parentId,{expandedRect:u,parent:l})}return a.size>0&&a.forEach(({expandedRect:s,parent:l},c)=>{var b;const u=l.internals.positionAbsolute,f=Bc(l),h=l.origin??r,p=s.x<u.x?Math.round(Math.abs(u.x-s.x)):0,y=s.y<u.y?Math.round(Math.abs(u.y-s.y)):0,v=Math.max(f.width,Math.round(s.width)),$=Math.max(f.height,Math.round(s.height)),x=(v-f.width)*h[0],S=($-f.height)*h[1];(p>0||y>0||x||S)&&(i.push({id:c,type:"position",position:{x:l.position.x-p+x,y:l.position.y-y+S}}),(b=n.get(c))==null||b.forEach(T=>{t.some(w=>w.id===T.id)||i.push({id:T.id,type:"position",position:{x:T.position.x+p,y:T.position.y+y}})})),(f.width<s.width||f.height<s.height||p||y)&&i.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?h[0]*p-x:0),height:$+(y?h[1]*y-S:0)}})}),i}function vHe(t,e,n,r,i,a,o){const s=r==null?void 0:r.querySelector(".xyflow__viewport");let l=!1;if(!s)return{changes:[],updatedInternals:l};const c=[],u=window.getComputedStyle(s),{m22:f}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const p of t.values()){const y=e.get(p.id);if(!y)continue;if(y.hidden){e.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),l=!0;continue}const v=aU(p.nodeElement),$=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&($||!y.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),b=Dp(y.extent)?y.extent:a;let{positionAbsolute:T}=y.internals;y.parentId&&y.extent==="parent"?T=rfe(T,v,e.get(y.parentId)):b&&(T=If(T,b,v));const w={...y,measured:v,internals:{...y.internals,positionAbsolute:T,handleBounds:{source:PH("source",p.nodeElement,S,f,y.id),target:PH("target",p.nodeElement,S,f,y.id)}}};e.set(y.id,w),y.parentId&&uU(w,e,n,{nodeOrigin:i,zIndexMode:o}),l=!0,$&&(c.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&h.push({id:y.id,parentId:y.parentId,rect:Ip(w,i)}))}}if(h.length>0){const p=OU(h,e,n,i);c.push(...p)}return{changes:c,updatedInternals:l}}async function xHe({delta:t,panZoom:e,transform:n,translateExtent:r,width:i,height:a}){if(!e||!t.x&&!t.y)return Promise.resolve(!1);const o=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function EH(t,e,n,r,i,a){let o=i;const s=r.get(o)||new Map;r.set(o,s.set(n,e)),o=`${i}-${t}`;const l=r.get(o)||new Map;if(r.set(o,l.set(n,e)),a){o=`${i}-${t}-${a}`;const c=r.get(o)||new Map;r.set(o,c.set(n,e))}}function pfe(t,e,n){t.clear(),e.clear();for(const r of n){const{source:i,target:a,sourceHandle:o=null,targetHandle:s=null}=r,l={edgeId:r.id,source:i,target:a,sourceHandle:o,targetHandle:s},c=`${i}-${o}--${a}-${s}`,u=`${a}-${s}--${i}-${o}`;EH("source",l,u,t,i,o),EH("target",l,c,t,a,s),e.set(r.id,r)}}function mfe(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return n?n.selected?!0:mfe(n,e):!1}function CH(t,e,n){var i;let r=t;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,e))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function QHe(t,e,n,r){const i=new Map;for(const[a,o]of t)if((o.selected||o.id===r)&&(!o.parentId||!mfe(o,t))&&(o.draggable||e&&typeof o.draggable>"u")){const s=t.get(a);s&&i.set(a,{id:a,position:s.position||{x:0,y:0},distance:{x:n.x-s.internals.positionAbsolute.x,y:n.y-s.internals.positionAbsolute.y},extent:s.extent,parentId:s.parentId,origin:s.origin,expandParent:s.expandParent,internals:{positionAbsolute:s.internals.positionAbsolute||{x:0,y:0}},measured:{width:s.measured.width??0,height:s.measured.height??0}})}return i}function J2({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){var o,s,l;const i=[];for(const[c,u]of e){const f=(o=n.get(c))==null?void 0:o.internals.userNode;f&&i.push({...f,position:u.position,dragging:r})}if(!t)return[i[0],i];const a=(s=n.get(t))==null?void 0:s.internals.userNode;return[a?{...a,position:((l=e.get(t))==null?void 0:l.position)||a.position,dragging:r}:i[0],i]}function bHe({dragItems:t,snapGrid:e,x:n,y:r}){const i=t.values().next().value;if(!i)return null;const a={x:n-i.distance.x,y:r-i.distance.y},o=Yv(a,e);return{x:o.x-a.x,y:o.y-a.y}}function SHe({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,l=!1,c={x:0,y:0},u=null,f=!1,h=null,p=!1,y=!1,v=null;function $({noDragClassName:S,handleSelector:b,domNode:T,isSelectable:w,nodeId:P,nodeClickDistance:k=0}){h=oo(T);function R({x:Y,y:W}){const{nodeLookup:A,nodeExtent:q,snapGrid:N,snapToGrid:Z,nodeOrigin:D,onNodeDrag:M,onSelectionDrag:V,onError:I,updateNodePositions:B}=e();a={x:Y,y:W};let L=!1;const J=s.size>1,K=J&&q?YA(zv(s)):null,H=J&&Z?bHe({dragItems:s,snapGrid:N,x:Y,y:W}):null;for(const[re,F]of s){if(!A.has(re))continue;let te={x:Y-F.distance.x,y:W-F.distance.y};Z&&(te=H?{x:Math.round(te.x+H.x),y:Math.round(te.y+H.y)}:Yv(te,N));let ie=null;if(J&&q&&!F.extent&&K){const{positionAbsolute:ue}=F.internals,Oe=ue.x-K.x+q[0][0],de=ue.x+F.measured.width-K.x2+q[1][0],xe=ue.y-K.y+q[0][1],Qe=ue.y+F.measured.height-K.y2+q[1][1];ie=[[Oe,xe],[de,Qe]]}const{position:se,positionAbsolute:ae}=nfe({nodeId:re,nextPosition:te,nodeLookup:A,nodeExtent:ie||q,nodeOrigin:D,onError:I});L=L||F.position.x!==se.x||F.position.y!==se.y,F.position=se,F.internals.positionAbsolute=ae}if(y=y||L,!!L&&(B(s,!0),v&&(r||M||!P&&V))){const[re,F]=J2({nodeId:P,dragItems:s,nodeLookup:A});r==null||r(v,s,re,F),M==null||M(v,re,F),P||V==null||V(v,F)}}async function E(){if(!u)return;const{transform:Y,panBy:W,autoPanSpeed:A,autoPanOnNodeDrag:q}=e();if(!q){l=!1,cancelAnimationFrame(o);return}const[N,Z]=ife(c,u,A);(N!==0||Z!==0)&&(a.x=(a.x??0)-N/Y[2],a.y=(a.y??0)-Z/Y[2],await W({x:N,y:Z})&&R(a)),o=requestAnimationFrame(E)}function C(Y){var J;const{nodeLookup:W,multiSelectionActive:A,nodesDraggable:q,transform:N,snapGrid:Z,snapToGrid:D,selectNodesOnDrag:M,onNodeDragStart:V,onSelectionDragStart:I,unselectNodesAndEdges:B}=e();f=!0,(!M||!w)&&!A&&P&&((J=W.get(P))!=null&&J.selected||B()),w&&M&&P&&(t==null||t(P));const L=ky(Y.sourceEvent,{transform:N,snapGrid:Z,snapToGrid:D,containerBounds:u});if(a=L,s=QHe(W,q,L,P),s.size>0&&(n||V||!P&&I)){const[K,H]=J2({nodeId:P,dragItems:s,nodeLookup:W});n==null||n(Y.sourceEvent,s,K,H),V==null||V(Y.sourceEvent,K,H),P||I==null||I(Y.sourceEvent,H)}}const z=UOe().clickDistance(k).on("start",Y=>{const{domNode:W,nodeDragThreshold:A,transform:q,snapGrid:N,snapToGrid:Z}=e();u=(W==null?void 0:W.getBoundingClientRect())||null,p=!1,y=!1,v=Y.sourceEvent,A===0&&C(Y),a=ky(Y.sourceEvent,{transform:q,snapGrid:N,snapToGrid:Z,containerBounds:u}),c=gs(Y.sourceEvent,u)}).on("drag",Y=>{const{autoPanOnNodeDrag:W,transform:A,snapGrid:q,snapToGrid:N,nodeDragThreshold:Z,nodeLookup:D}=e(),M=ky(Y.sourceEvent,{transform:A,snapGrid:q,snapToGrid:N,containerBounds:u});if(v=Y.sourceEvent,(Y.sourceEvent.type==="touchmove"&&Y.sourceEvent.touches.length>1||P&&!D.has(P))&&(p=!0),!p){if(!l&&W&&f&&(l=!0,E()),!f){const V=gs(Y.sourceEvent,u),I=V.x-c.x,B=V.y-c.y;Math.sqrt(I*I+B*B)>Z&&C(Y)}(a.x!==M.xSnapped||a.y!==M.ySnapped)&&s&&f&&(c=gs(Y.sourceEvent,u),R(M))}}).on("end",Y=>{if(!(!f||p)&&(l=!1,f=!1,cancelAnimationFrame(o),s.size>0)){const{nodeLookup:W,updateNodePositions:A,onNodeDragStop:q,onSelectionDragStop:N}=e();if(y&&(A(s,!1),y=!1),i||q||!P&&N){const[Z,D]=J2({nodeId:P,dragItems:s,nodeLookup:W,dragging:!1});i==null||i(Y.sourceEvent,s,Z,D),q==null||q(Y.sourceEvent,Z,D),P||N==null||N(Y.sourceEvent,D)}}}).filter(Y=>{const W=Y.target;return!Y.button&&(!S||!CH(W,`.${S}`,T))&&(!b||CH(W,b,T))});h.call(z)}function x(){h==null||h.on(".drag",null)}return{update:$,destroy:x}}function wHe(t,e,n){const r=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const a of e.values())L$(i,Ip(a))>0&&r.push(a);return r}const PHe=250;function THe(t,e,n,r){var s,l;let i=[],a=1/0;const o=wHe(t,n,e+PHe);for(const c of o){const u=[...((s=c.internals.handleBounds)==null?void 0:s.source)??[],...((l=c.internals.handleBounds)==null?void 0:l.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=Df(c,f,f.position,!0),y=Math.sqrt(Math.pow(h-t.x,2)+Math.pow(p-t.y,2));y>e||(y<a?(i=[{...f,x:h,y:p}],a=y):y===a&&i.push({...f,x:h,y:p}))}}if(!i.length)return null;if(i.length>1){const c=r.type==="source"?"target":"source";return i.find(u=>u.type===c)??i[0]}return i[0]}function gfe(t,e,n,r,i,a=!1){var c,u,f;const o=r.get(t);if(!o)return null;const s=i==="strict"?(c=o.internals.handleBounds)==null?void 0:c[e]:[...((u=o.internals.handleBounds)==null?void 0:u.source)??[],...((f=o.internals.handleBounds)==null?void 0:f.target)??[]],l=(n?s==null?void 0:s.find(h=>h.id===n):s==null?void 0:s[0])??null;return l&&a?{...l,...Df(o,l,l.position,!0)}:l}function yfe(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function kHe(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}const $fe=()=>!0;function _He(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:f,panBy:h,cancelConnection:p,onConnectStart:y,onConnect:v,onConnectEnd:$,isValidConnection:x=$fe,onReconnectEnd:S,updateConnection:b,getTransform:T,getFromHandle:w,autoPanSpeed:P,dragThreshold:k=1,handleDomNode:R}){const E=lfe(t.target);let C=0,z;const{x:Y,y:W}=gs(t),A=yfe(a,R),q=s==null?void 0:s.getBoundingClientRect();let N=!1;if(!q||!A)return;const Z=gfe(i,A,r,l,e);if(!Z)return;let D=gs(t,q),M=!1,V=null,I=!1,B=null;function L(){if(!u||!q)return;const[se,ae]=ife(D,q,P);h({x:se,y:ae}),C=requestAnimationFrame(L)}const J={...Z,nodeId:i,type:A,position:Z.position},K=l.get(i);let re={inProgress:!0,isValid:null,from:Df(K,J,Ce.Left,!0),fromHandle:J,fromPosition:J.position,fromNode:K,to:D,toHandle:null,toPosition:xH[J.position],toNode:null,pointer:D};function F(){N=!0,b(re),y==null||y(t,{nodeId:i,handleId:r,handleType:A})}k===0&&F();function te(se){if(!N){const{x:Qe,y:Re}=gs(se),Le=Qe-Y,Ne=Re-W;if(!(Le*Le+Ne*Ne>k*k))return;F()}if(!w()||!J){ie(se);return}const ae=T();D=gs(se,q),z=THe(Av(D,ae,!1,[1,1]),n,l,J),M||(L(),M=!0);const ue=vfe(se,{handle:z,connectionMode:e,fromNodeId:i,fromHandleId:r,fromType:o?"target":"source",isValidConnection:x,doc:E,lib:c,flowId:f,nodeLookup:l});B=ue.handleDomNode,V=ue.connection,I=kHe(!!z,ue.isValid);const Oe=l.get(i),de=Oe?Df(Oe,J,Ce.Left,!0):re.from,xe={...re,from:de,isValid:I,to:ue.toHandle&&I?eS({x:ue.toHandle.x,y:ue.toHandle.y},ae):D,toHandle:ue.toHandle,toPosition:I&&ue.toHandle?ue.toHandle.position:xH[J.position],toNode:ue.toHandle?l.get(ue.toHandle.nodeId):null,pointer:D};b(xe),re=xe}function ie(se){if(!("touches"in se&&se.touches.length>0)){if(N){(z||B)&&V&&I&&(v==null||v(V));const{inProgress:ae,...ue}=re,Oe={...ue,toPosition:re.toHandle?re.toPosition:null};$==null||$(se,Oe),a&&(S==null||S(se,Oe))}p(),cancelAnimationFrame(C),M=!1,I=!1,V=null,B=null,E.removeEventListener("mousemove",te),E.removeEventListener("mouseup",ie),E.removeEventListener("touchmove",te),E.removeEventListener("touchend",ie)}}E.addEventListener("mousemove",te),E.addEventListener("mouseup",ie),E.addEventListener("touchmove",te),E.addEventListener("touchend",ie)}function vfe(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:l,isValidConnection:c=$fe,nodeLookup:u}){const f=a==="target",h=e?o.querySelector(`.${s}-flow__handle[data-id="${l}-${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`):null,{x:p,y}=gs(t),v=o.elementFromPoint(p,y),$=v!=null&&v.classList.contains(`${s}-flow__handle`)?v:h,x={handleDomNode:$,isValid:!1,connection:null,toHandle:null};if($){const S=yfe(void 0,$),b=$.getAttribute("data-nodeid"),T=$.getAttribute("data-handleid"),w=$.classList.contains("connectable"),P=$.classList.contains("connectableend");if(!b||!S)return x;const k={source:f?b:r,sourceHandle:f?T:i,target:f?r:b,targetHandle:f?i:T};x.connection=k;const E=w&&P&&(n===Wp.Strict?f&&S==="source"||!f&&S==="target":b!==r||T!==i);x.isValid=E&&c(k),x.toHandle=gfe(b,S,T,u,n,!0)}return x}const ZA={onPointerDown:_He,isValid:vfe};function XHe({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){const i=oo(t);function a({translateExtent:s,width:l,height:c,zoomStep:u=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const y=b=>{if(b.sourceEvent.type!=="wheel"||!e)return;const T=n(),w=b.sourceEvent.ctrlKey&&G$()?10:1,P=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*u,k=T[2]*Math.pow(2,P*w);e.scaleTo(k)};let v=[0,0];const $=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(v=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},x=b=>{const T=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!e)return;const w=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],P=[w[0]-v[0],w[1]-v[1]];v=w;const k=r()*Math.max(T[2],Math.log(T[2]))*(p?-1:1),R={x:T[0]-P[0]*k,y:T[1]-P[1]*k},E=[[0,0],[l,c]];e.setViewportConstrained({x:R.x,y:R.y,zoom:T[2]},E,s)},S=FOe().on("start",$).on("zoom",f?x:null).on("zoom.wheel",h?y:null);i.call(S,{})}function o(){i.on("zoom",null)}return{update:a,destroy:o,pointer:ls}}const Ww=t=>({x:t.x,y:t.y,zoom:t.k}),ej=({x:t,y:e,zoom:n})=>Vw.translate(t,e).scale(n),Th=(t,e)=>t.target.closest(`.${e}`),xfe=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),RHe=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,tj=(t,e=0,n=RHe,r=()=>{})=>{const i=typeof e=="number"&&e>0;return i||r(),i?t.transition().duration(e).ease(n).on("end",r):t},Qfe=t=>{const e=t.ctrlKey&&G$()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e};function jHe({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:l,onPanZoomEnd:c}){return u=>{if(Th(u,e))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&o){const $=ls(u),x=Qfe(u),S=f*Math.pow(2,x);r.scaleTo(n,S,$,u);return}const h=u.deltaMode===1?20:1;let p=i===Xf.Vertical?0:u.deltaX*h,y=i===Xf.Horizontal?0:u.deltaY*h;!G$()&&u.shiftKey&&i!==Xf.Vertical&&(p=u.deltaY*h,y=0),r.translateBy(n,-(p/f)*a,-(y/f)*a,{internal:!0});const v=Ww(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?(l==null||l(u,v),t.panScrollTimeout=setTimeout(()=>{c==null||c(u,v),t.isPanScrolling=!1},150)):(t.isPanScrolling=!0,s==null||s(u,v))}}function EHe({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,i){const a=r.type==="wheel",o=!e&&a&&!r.ctrlKey,s=Th(r,t);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function CHe({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{var a,o,s;if((a=r.sourceEvent)!=null&&a.internal)return;const i=Ww(r.transform);t.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=i,((s=r.sourceEvent)==null?void 0:s.type)==="mousedown"&&e(!0),n&&(n==null||n(r.sourceEvent,i))}}function zHe({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{var o,s;t.usedRightMouseButton=!!(n&&xfe(e,t.mouseButton??0)),(o=a.sourceEvent)!=null&&o.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!((s=a.sourceEvent)!=null&&s.internal)&&(i==null||i(a.sourceEvent,Ww(a.transform)))}}function YHe({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{var s;if(!((s=o.sourceEvent)!=null&&s.internal)&&(t.isZoomingOrPanning=!1,a&&xfe(e,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),t.usedRightMouseButton=!1,r(!1),i)){const l=Ww(o.transform);t.prevViewport=l,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i==null||i(o.sourceEvent,l)},n?150:0)}}}function AHe({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:l,lib:c,connectionInProgress:u}){return f=>{var $;const h=t||e,p=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Th(f,`${c}-flow__node`)||Th(f,`${c}-flow__edge`)))return!0;if(!r&&!h&&!i&&!a&&!n||o||u&&!y||Th(f,s)&&y||Th(f,l)&&(!y||i&&y&&!t)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&(($=f.touches)==null?void 0:$.length)>1)return f.preventDefault(),!1;if(!h&&!i&&!p&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function qHe({domNode:t,minZoom:e,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=t.getBoundingClientRect(),f=FOe().scaleExtent([e,n]).translateExtent(r),h=oo(t).call(f);S({x:i.x,y:i.y,zoom:Mp(i.zoom,e,n)},[[0,0],[u.width,u.height]],r);const p=h.on("wheel.zoom"),y=h.on("dblclick.zoom");f.wheelDelta(Qfe);function v(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).transform(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function $({noWheelClassName:z,noPanClassName:Y,onPaneContextMenu:W,userSelectionActive:A,panOnScroll:q,panOnDrag:N,panOnScrollMode:Z,panOnScrollSpeed:D,preventScrolling:M,zoomOnPinch:V,zoomOnScroll:I,zoomOnDoubleClick:B,zoomActivationKeyPressed:L,lib:J,onTransformChange:K,connectionInProgress:H,paneClickDistance:re,selectionOnDrag:F}){A&&!c.isZoomingOrPanning&&x();const te=q&&!L&&!A;f.clickDistance(F?1/0:!ms(re)||re<0?0:re);const ie=te?jHe({zoomPanValues:c,noWheelClassName:z,d3Selection:h,d3Zoom:f,panOnScrollMode:Z,panOnScrollSpeed:D,zoomOnPinch:V,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):EHe({noWheelClassName:z,preventScrolling:M,d3ZoomHandler:p});if(h.on("wheel.zoom",ie,{passive:!1}),!A){const ae=CHe({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:o});f.on("start",ae);const ue=zHe({zoomPanValues:c,panOnDrag:N,onPaneContextMenu:!!W,onPanZoom:a,onTransformChange:K});f.on("zoom",ue);const Oe=YHe({zoomPanValues:c,panOnDrag:N,panOnScroll:q,onPaneContextMenu:W,onPanZoomEnd:s,onDraggingChange:l});f.on("end",Oe)}const se=AHe({zoomActivationKeyPressed:L,panOnDrag:N,zoomOnScroll:I,panOnScroll:q,zoomOnDoubleClick:B,zoomOnPinch:V,userSelectionActive:A,noPanClassName:Y,noWheelClassName:z,lib:J,connectionInProgress:H});f.filter(se),B?h.on("dblclick.zoom",y):h.on("dblclick.zoom",null)}function x(){f.on("zoom",null)}async function S(z,Y,W){const A=ej(z),q=f==null?void 0:f.constrain()(A,Y,W);return q&&await v(q),new Promise(N=>N(q))}async function b(z,Y){const W=ej(z);return await v(W,Y),new Promise(A=>A(W))}function T(z){if(h){const Y=ej(z),W=h.property("__zoom");(W.k!==z.zoom||W.x!==z.x||W.y!==z.y)&&(f==null||f.transform(h,Y,null,{sync:!0}))}}function w(){const z=h?BOe(h.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function P(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).scaleTo(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function k(z,Y){return h?new Promise(W=>{f==null||f.interpolate((Y==null?void 0:Y.interpolate)==="linear"?_c:Vb).scaleBy(tj(h,Y==null?void 0:Y.duration,Y==null?void 0:Y.ease,()=>W(!0)),z)}):Promise.resolve(!1)}function R(z){f==null||f.scaleExtent(z)}function E(z){f==null||f.translateExtent(z)}function C(z){const Y=!ms(z)||z<0?0:z;f==null||f.clickDistance(Y)}return{update:$,destroy:x,setViewport:b,setViewportConstrained:S,getViewport:w,scaleTo:P,scaleBy:k,setScaleExtent:R,setTranslateExtent:E,syncViewport:T,setClickDistance:C}}var Gp;(function(t){t.Line="line",t.Handle="handle"})(Gp||(Gp={}));function ZHe({width:t,prevWidth:e,height:n,prevHeight:r,affectsX:i,affectsY:a}){const o=t-e,s=n-r,l=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(l[0]=l[0]*-1),s&&a&&(l[1]=l[1]*-1),l}function zH(t){const e=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),r=t.includes("left"),i=t.includes("top");return{isHorizontal:e,isVertical:n,affectsX:r,affectsY:i}}function Xu(t,e){return Math.max(0,e-t)}function Ru(t,e){return Math.max(0,t-e)}function HQ(t,e,n){return Math.max(0,e-t,t-n)}function YH(t,e){return t?!e:e}function VHe(t,e,n,r,i,a,o,s){let{affectsX:l,affectsY:c}=e;const{isHorizontal:u,isVertical:f}=e,h=u&&f,{xSnapped:p,ySnapped:y}=n,{minWidth:v,maxWidth:$,minHeight:x,maxHeight:S}=r,{x:b,y:T,width:w,height:P,aspectRatio:k}=t;let R=Math.floor(u?p-t.pointerX:0),E=Math.floor(f?y-t.pointerY:0);const C=w+(l?-R:R),z=P+(c?-E:E),Y=-a[0]*w,W=-a[1]*P;let A=HQ(C,v,$),q=HQ(z,x,S);if(o){let D=0,M=0;l&&R<0?D=Xu(b+R+Y,o[0][0]):!l&&R>0&&(D=Ru(b+C+Y,o[1][0])),c&&E<0?M=Xu(T+E+W,o[0][1]):!c&&E>0&&(M=Ru(T+z+W,o[1][1])),A=Math.max(A,D),q=Math.max(q,M)}if(s){let D=0,M=0;l&&R>0?D=Ru(b+R,s[0][0]):!l&&R<0&&(D=Xu(b+C,s[1][0])),c&&E>0?M=Ru(T+E,s[0][1]):!c&&E<0&&(M=Xu(T+z,s[1][1])),A=Math.max(A,D),q=Math.max(q,M)}if(i){if(u){const D=HQ(C/k,x,S)*k;if(A=Math.max(A,D),o){let M=0;!l&&!c||l&&!c&&h?M=Ru(T+W+C/k,o[1][1])*k:M=Xu(T+W+(l?R:-R)/k,o[0][1])*k,A=Math.max(A,M)}if(s){let M=0;!l&&!c||l&&!c&&h?M=Xu(T+C/k,s[1][1])*k:M=Ru(T+(l?R:-R)/k,s[0][1])*k,A=Math.max(A,M)}}if(f){const D=HQ(z*k,v,$)/k;if(q=Math.max(q,D),o){let M=0;!l&&!c||c&&!l&&h?M=Ru(b+z*k+Y,o[1][0])/k:M=Xu(b+(c?E:-E)*k+Y,o[0][0])/k,q=Math.max(q,M)}if(s){let M=0;!l&&!c||c&&!l&&h?M=Xu(b+z*k,s[1][0])/k:M=Ru(b+(c?E:-E)*k,s[0][0])/k,q=Math.max(q,M)}}}E=E+(E<0?q:-q),R=R+(R<0?A:-A),i&&(h?C>z*k?E=(YH(l,c)?-R:R)/k:R=(YH(l,c)?-E:E)*k:u?(E=R/k,c=l):(R=E*k,l=c));const N=l?b+R:b,Z=c?T+E:T;return{width:w+(l?-R:R),height:P+(c?-E:E),x:a[0]*R*(l?-1:1)+N,y:a[1]*E*(c?-1:1)+Z}}const bfe={width:0,height:0,x:0,y:0},UHe={...bfe,pointerX:0,pointerY:0,aspectRatio:1};function NHe(t){return[[0,0],[t.measured.width,t.measured.height]]}function WHe(t,e,n){const r=e.position.x+t.position.x,i=e.position.y+t.position.y,a=t.measured.width??0,o=t.measured.height??0,s=n[0]*a,l=n[1]*o;return[[r-s,i-l],[r+a-s,i+o-l]]}function MHe({domNode:t,nodeId:e,getStoreItems:n,onChange:r,onEnd:i}){const a=oo(t);let o={controlDirection:zH("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:h,onResizeStart:p,onResize:y,onResizeEnd:v,shouldResize:$}){let x={...bfe},S={...UHe};o={boundaries:u,resizeDirection:h,keepAspectRatio:f,controlDirection:zH(c)};let b,T=null,w=[],P,k,R,E=!1;const C=UOe().on("start",z=>{const{nodeLookup:Y,transform:W,snapGrid:A,snapToGrid:q,nodeOrigin:N,paneDomNode:Z}=n();if(b=Y.get(e),!b)return;T=(Z==null?void 0:Z.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:M}=ky(z.sourceEvent,{transform:W,snapGrid:A,snapToGrid:q,containerBounds:T});x={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},S={...x,pointerX:D,pointerY:M,aspectRatio:x.width/x.height},P=void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(P=Y.get(b.parentId),k=P&&b.extent==="parent"?NHe(P):void 0),w=[],R=void 0;for(const[V,I]of Y)if(I.parentId===e&&(w.push({id:V,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const B=WHe(I,b,I.origin??N);R?R=[[Math.min(B[0][0],R[0][0]),Math.min(B[0][1],R[0][1])],[Math.max(B[1][0],R[1][0]),Math.max(B[1][1],R[1][1])]]:R=B}p==null||p(z,{...x})}).on("drag",z=>{const{transform:Y,snapGrid:W,snapToGrid:A,nodeOrigin:q}=n(),N=ky(z.sourceEvent,{transform:Y,snapGrid:W,snapToGrid:A,containerBounds:T}),Z=[];if(!b)return;const{x:D,y:M,width:V,height:I}=x,B={},L=b.origin??q,{width:J,height:K,x:H,y:re}=VHe(S,o.controlDirection,N,o.boundaries,o.keepAspectRatio,L,k,R),F=J!==V,te=K!==I,ie=H!==D&&F,se=re!==M&&te;if(!ie&&!se&&!F&&!te)return;if((ie||se||L[0]===1||L[1]===1)&&(B.x=ie?H:x.x,B.y=se?re:x.y,x.x=B.x,x.y=B.y,w.length>0)){const de=H-D,xe=re-M;for(const Qe of w)Qe.position={x:Qe.position.x-de+L[0]*(J-V),y:Qe.position.y-xe+L[1]*(K-I)},Z.push(Qe)}if((F||te)&&(B.width=F&&(!o.resizeDirection||o.resizeDirection==="horizontal")?J:x.width,B.height=te&&(!o.resizeDirection||o.resizeDirection==="vertical")?K:x.height,x.width=B.width,x.height=B.height),P&&b.expandParent){const de=L[0]*(B.width??0);B.x&&B.x<de&&(x.x=de,S.x=S.x-(B.x-de));const xe=L[1]*(B.height??0);B.y&&B.y<xe&&(x.y=xe,S.y=S.y-(B.y-xe))}const ae=ZHe({width:x.width,prevWidth:V,height:x.height,prevHeight:I,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),ue={...x,direction:ae};($==null?void 0:$(z,ue))!==!1&&(E=!0,y==null||y(z,ue),r(B,Z))}).on("end",z=>{E&&(v==null||v(z,{...x}),i==null||i({...x}),E=!1)});a.call(C)}function l(){a.on(".drag",null)}return{update:s,destroy:l}}var nj={exports:{}},rj={},ij={exports:{}},aj={};/**
|
|
705
705
|
* @license React
|
|
706
706
|
* use-sync-external-store-shim.production.js
|
|
707
707
|
*
|
|
@@ -762,4 +762,4 @@ ${n.map(([a,o])=>{var l;const s=((l=o.theme)==null?void 0:l[r])||o.color;return
|
|
|
762
762
|
`))+1))}const o="#".repeat(i),s=n.enter("headingAtx"),l=n.enter("phrasing");a.move(o+" ");let c=n.containerPhrasing(t,{before:"# ",after:`
|
|
763
763
|
`,...a.current()});return/^[\t ]/.test(c)&&(c=ov(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),s(),c}zpe.peek=pdt;function zpe(t){return t.value||""}function pdt(){return"<"}Ype.peek=mdt;function Ype(t,e,n,r){const i=JU(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let s=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(t.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),s(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(s=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(s=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":")",...l.current()}))),s(),t.title&&(s=n.enter(`title${a}`),c+=l.move(" "+i),c+=l.move(n.safe(t.title,{before:c,after:i,...l.current()})),c+=l.move(i),s()),c+=l.move(")"),o(),c}function mdt(){return"!"}Ape.peek=gdt;function Ape(t,e,n,r){const i=t.referenceType,a=n.enter("imageReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("![");const c=n.safe(t.alt,{before:l,after:"]",...s.current()});l+=s.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(t),{before:l,after:"]",...s.current()});return o(),n.stack=u,a(),i==="full"||!c||c!==f?l+=s.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function gdt(){return"!"}qpe.peek=ydt;function qpe(t,e,n){let r=t.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const o=n.unsafe[a],s=n.compilePattern(o);let l;if(o.atBreak)for(;l=s.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function ydt(){return"`"}function Zpe(t,e){const n=MU(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Vpe.peek=$dt;function Vpe(t,e,n,r){const i=JU(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let s,l;if(Zpe(t,n)){const u=n.stack;n.stack=[],s=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(t,{before:f,after:">",...o.current()})),f+=o.move(">"),s(),n.stack=u,f}s=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(t,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(t.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(t.url,{before:c,after:t.title?" ":")",...o.current()}))),l(),t.title&&(l=n.enter(`title${a}`),c+=o.move(" "+i),c+=o.move(n.safe(t.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),s(),c}function $dt(t,e,n){return Zpe(t,n)?"<":"["}Upe.peek=vdt;function Upe(t,e,n,r){const i=t.referenceType,a=n.enter("linkReference");let o=n.enter("label");const s=n.createTracker(r);let l=s.move("[");const c=n.containerPhrasing(t,{before:l,after:"]",...s.current()});l+=s.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(t),{before:l,after:"]",...s.current()});return o(),n.stack=u,a(),i==="full"||!c||c!==f?l+=s.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=s.move("]"),l}function vdt(){return"["}function eN(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function xdt(t){const e=eN(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Qdt(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function Npe(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function bdt(t,e,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=t.ordered?Qdt(n):eN(n);const s=t.ordered?o==="."?")":".":xdt(n);let l=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){const u=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),Npe(n)===o&&u){let f=-1;for(;++f<t.children.length;){const h=t.children[f];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=s),n.bulletCurrent=o;const c=n.containerFlow(t,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),c}function Sdt(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function wdt(t,e,n,r){const i=Sdt(n);let a=n.bulletCurrent||eN(n);e&&e.type==="list"&&e.ordered&&(a=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,s.current()),u);return l(),c;function u(f,h,p){return h?(p?"":" ".repeat(o))+f:(p?a:a+" ".repeat(o-a.length))+f}}function Pdt(t,e,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(t,r);return a(),i(),o}const Tdt=aP(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function kdt(t,e,n,r){return(t.children.some(function(o){return Tdt(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function _dt(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Wpe.peek=Xdt;function Wpe(t,e,n,r){const i=_dt(n),a=n.enter("strong"),o=n.createTracker(r),s=o.move(i+i);let l=o.move(n.containerPhrasing(t,{after:i,before:s,...o.current()}));const c=l.charCodeAt(0),u=fS(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=ov(c)+l.slice(1));const f=l.charCodeAt(l.length-1),h=fS(r.after.charCodeAt(0),f,i);h.inside&&(l=l.slice(0,-1)+ov(f));const p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},s+l+p}function Xdt(t,e,n){return n.options.strong||"*"}function Rdt(t,e,n,r){return n.safe(t.value,r)}function jdt(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Edt(t,e,n){const r=(Npe(n)+(n.options.ruleSpaces?" ":"")).repeat(jdt(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Mpe={blockquote:ndt,break:Ute,code:ldt,definition:udt,emphasis:Cpe,hardBreak:Ute,heading:hdt,html:zpe,image:Ype,imageReference:Ape,inlineCode:qpe,link:Vpe,linkReference:Upe,list:bdt,listItem:wdt,paragraph:Pdt,root:kdt,strong:Wpe,text:Rdt,thematicBreak:Edt};function Cdt(){return{enter:{table:zdt,tableData:Nte,tableHeader:Nte,tableRow:Adt},exit:{codeText:qdt,table:Ydt,tableData:SC,tableHeader:SC,tableRow:SC}}}function zdt(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function Ydt(t){this.exit(t),this.data.inTable=void 0}function Adt(t){this.enter({type:"tableRow",children:[]},t)}function SC(t){this.exit(t)}function Nte(t){this.enter({type:"tableCell",children:[]},t)}function qdt(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Zdt));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function Zdt(t,e){return e==="|"?e:t}function Vdt(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
764
764
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:l,tableRow:s}};function o(p,y,v,$){return c(u(p,v,$),p.align)}function s(p,y,v,$){const x=f(p,v,$),S=c([x]);return S.slice(0,S.indexOf(`
|
|
765
|
-
`))}function l(p,y,v,$){const x=v.enter("tableCell"),S=v.enter("phrasing"),b=v.containerPhrasing(p,{...$,before:a,after:a});return S(),x(),b}function c(p,y){return edt(p,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function u(p,y,v){const $=p.children;let x=-1;const S=[],b=y.enter("table");for(;++x<$.length;)S[x]=f($[x],y,v);return b(),S}function f(p,y,v){const $=p.children;let x=-1;const S=[],b=y.enter("tableRow");for(;++x<$.length;)S[x]=l($[x],p,y,v);return b(),S}function h(p,y,v){let $=Mpe.inlineCode(p,y,v);return v.stack.includes("tableCell")&&($=$.replace(/\|/g,"\\$&")),$}}function Udt(){return{exit:{taskListCheckValueChecked:Wte,taskListCheckValueUnchecked:Wte,paragraph:Wdt}}}function Ndt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Mdt}}}function Wte(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Wdt(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function Mdt(t,e,n,r){const i=t.children[0],a=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=Mpe.listItem(t,e,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function Idt(){return[bft(),Mft(),Gft(),Cdt(),Udt()]}function Ddt(t){return{extensions:[Sft(),Ift(t),Bft(),Vdt(t),Ndt()]}}const Ldt={tokenize:Jdt,partial:!0},Ipe={tokenize:eht,partial:!0},Dpe={tokenize:tht,partial:!0},Lpe={tokenize:nht,partial:!0},Gdt={tokenize:rht,partial:!0},Gpe={name:"wwwAutolink",tokenize:Hdt,previous:Fpe},Bpe={name:"protocolAutolink",tokenize:Kdt,previous:Hpe},Fc={name:"emailAutolink",tokenize:Fdt,previous:Kpe},El={};function Bdt(){return{text:El}}let of=48;for(;of<123;)El[of]=Fc,of++,of===58?of=65:of===91&&(of=97);El[43]=Fc;El[45]=Fc;El[46]=Fc;El[95]=Fc;El[72]=[Fc,Bpe];El[104]=[Fc,Bpe];El[87]=[Fc,Gpe];El[119]=[Fc,Gpe];function Fdt(t,e,n){const r=this;let i,a;return o;function o(f){return!sq(f)||!Kpe.call(r,r.previous)||tN(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(f))}function s(f){return sq(f)?(t.consume(f),s):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(Gdt,u,c)(f):f===45||f===95||Gi(f)?(a=!0,t.consume(f),l):u(f)}function c(f){return t.consume(f),i=!0,l}function u(f){return a&&i&&ia(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function Hdt(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Fpe.call(r,r.previous)||tN(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Ldt,t.attempt(Ipe,t.attempt(Dpe,a),n),n)(o))}function a(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function Kdt(t,e,n){const r=this;let i="",a=!1;return o;function o(f){return(f===72||f===104)&&Hpe.call(r,r.previous)&&!tN(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),s):n(f)}function s(f){if(ia(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),s;if(f===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),a?c:(a=!0,l)):n(f)}function c(f){return f===null||cS(f)||Jn(f)||Bf(f)||nP(f)?n(f):t.attempt(Ipe,t.attempt(Dpe,u),n)(f)}function u(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function Jdt(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),a):n(o)}function a(o){return o===null?n(o):e(o)}}function eht(t,e,n){let r,i,a;return o;function o(c){return c===46||c===95?t.check(Lpe,l,s)(c):c===null||Jn(c)||Bf(c)||c!==45&&nP(c)?l(c):(a=!0,t.consume(c),o)}function s(c){return c===95?r=!0:(i=r,r=void 0),t.consume(c),o}function l(c){return i||r||!a?n(c):e(c)}}function tht(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(Lpe,e,a)(o):o===null||Jn(o)||Bf(o)?e(o):(t.consume(o),i)}function a(o){return o===41&&r++,t.consume(o),i}}function nht(t,e,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),r):s===38?(t.consume(s),a):s===93?(t.consume(s),i):s===60||s===null||Jn(s)||Bf(s)?e(s):n(s)}function i(s){return s===null||s===40||s===91||Jn(s)||Bf(s)?e(s):r(s)}function a(s){return ia(s)?o(s):n(s)}function o(s){return s===59?(t.consume(s),r):ia(s)?(t.consume(s),o):n(s)}}function rht(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return Gi(a)?n(a):e(a)}}function Fpe(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Jn(t)}function Hpe(t){return!ia(t)}function Kpe(t){return!(t===47||sq(t))}function sq(t){return t===43||t===45||t===46||t===95||Gi(t)}function tN(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const iht={tokenize:fht,partial:!0};function aht(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cht,continuation:{tokenize:uht},exit:Oht}},text:{91:{name:"gfmFootnoteCall",tokenize:lht},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:oht,resolveTo:sht}}}}function oht(t,e,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const c=xs(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function sht(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",o,e],["exit",o,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...s),t}function lht(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(f){if(a>999||f===93&&!o||f===null||f===91||Jn(f))return n(f);if(f===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(xs(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return Jn(f)||(o=!0),a++,t.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(t.consume(f),a++,c):c(f)}}function cht(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(y)}function u(y){if(o>999||y===93&&!s||y===null||y===91||Jn(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return a=xs(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Jn(y)||(s=!0),o++,t.consume(y),y===92?f:u}function f(y){return y===91||y===92||y===93?(t.consume(y),o++,u):u(y)}function h(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(a)||i.push(a),gn(t,p,"gfmFootnoteDefinitionWhitespace")):n(y)}function p(y){return e(y)}}function uht(t,e,n){return t.check(Iv,e,t.attempt(iht,e,n))}function Oht(t){t.exit("gfmFootnoteDefinition")}function fht(t,e,n){const r=this;return gn(t,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(a):n(a)}}function dht(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",u,s],["enter",o[c][1],s],["exit",o[c][1],s],["enter",f,s]],p=s.parser.constructs.insideSpan.null;p&&Oo(h,h.length,0,rP(p,o.slice(c+1,l),s)),Oo(h,h.length,0,[["exit",f,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",u,s]]),Oo(o,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const c=this.previous,u=this.events;let f=0;return h;function h(y){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),p(y))}function p(y){const v=Bp(c);if(y===126)return f>1?l(y):(o.consume(y),f++,p);if(f<2&&!n)return l(y);const $=o.exit("strikethroughSequenceTemporary"),x=Bp(y);return $._open=!x||x===2&&!!v,$._close=!v||v===2&&!!x,s(y)}}}class hht{constructor(){this.map=[]}add(e,n,r){pht(this,e,n,r)}consume(e){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const a of i)e.push(a);i=r.pop()}this.map.length=0}}function pht(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function mht(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function ght(){return{flow:{null:{name:"table",tokenize:yht,resolveAll:$ht}}}}function yht(t,e,n){const r=this;let i=0,a=0,o;return s;function s(C){let z=r.events.length-1;for(;z>-1;){const A=r.events[z][1].type;if(A==="lineEnding"||A==="linePrefix")z--;else break}const Y=z>-1?r.events[z][1].type:null,W=Y==="tableHead"||Y==="tableRow"?P:l;return W===P&&r.parser.lazy[r.now().line]?n(C):W(C)}function l(C){return t.enter("tableHead"),t.enter("tableRow"),c(C)}function c(C){return C===124||(o=!0,a+=1),u(C)}function u(C){return C===null?n(C):pt(C)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),p):n(C):nn(C)?gn(t,u,"whitespace")(C):(a+=1,o&&(o=!1,i+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),f(C)))}function f(C){return C===null||C===124||Jn(C)?(t.exit("data"),u(C)):(t.consume(C),C===92?h:f)}function h(C){return C===92||C===124?(t.consume(C),f):f(C)}function p(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(t.enter("tableDelimiterRow"),o=!1,nn(C)?gn(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):y(C))}function y(C){return C===45||C===58?$(C):C===124?(o=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),v):w(C)}function v(C){return nn(C)?gn(t,$,"whitespace")(C):$(C)}function $(C){return C===58?(a+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),x):C===45?(a+=1,x(C)):C===null||pt(C)?T(C):w(C)}function x(C){return C===45?(t.enter("tableDelimiterFiller"),S(C)):w(C)}function S(C){return C===45?(t.consume(C),S):C===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(C))}function b(C){return nn(C)?gn(t,T,"whitespace")(C):T(C)}function T(C){return C===124?y(C):C===null||pt(C)?!o||i!==a?w(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(C)):w(C)}function w(C){return n(C)}function P(C){return t.enter("tableRow"),k(C)}function k(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),k):C===null||pt(C)?(t.exit("tableRow"),e(C)):nn(C)?gn(t,k,"whitespace")(C):(t.enter("data"),R(C))}function R(C){return C===null||C===124||Jn(C)?(t.exit("data"),k(C)):(t.consume(C),C===92?E:R)}function E(C){return C===92||C===124?(t.consume(C),R):R(C)}}function $ht(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,c,u,f;const h=new hht;for(;++n<t.length;){const p=t[n],y=p[1];p[0]==="enter"?y.type==="tableHead"?(s=!1,l!==0&&(Mte(h,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",c,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,f=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",u,e]])),i=y.type==="tableDelimiterRow"?2:u?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=vb(h,e,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=vb(h,e,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):y.type==="tableHead"?(s=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],f=vb(h,e,a,i,n,f)):o[1]!==0&&(f=vb(h,e,o,i,n,f)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Mte(h,e,l,c,u),h.consume(e.events),n=-1;++n<e.events.length;){const p=e.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=mht(e.events,n))}return t}function vb(t,e,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},$h(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const l=$h(e.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",a,e]]),n[2]!==0){const c=$h(e.events,n[2]),u=$h(e.events,n[3]),f={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const h=e.events[n[2]],p=e.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(a.end=Object.assign({},$h(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function Mte(t,e,n,r,i){const a=[],o=$h(e.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,e])),r.end=Object.assign({},o),a.push(["exit",r,e]),t.add(n+1,0,a)}function $h(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const vht={name:"tasklistCheck",tokenize:Qht};function xht(){return{text:{91:vht}}}function Qht(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),a)}function a(l){return Jn(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):n(l)}function s(l){return pt(l)?e(l):nn(l)?t.check({tokenize:bht},e,n)(l):n(l)}}function bht(t,e,n){return gn(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Sht(t){return cpe([Bdt(),aht(),dht(t),ght(),xht()])}const wht={};function Pht(t){const e=this,n=t||wht,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Sht(n)),a.push(Idt()),o.push(Ddt(n))}const Jpe=_.createContext(void 0);function Lv(t){const e=_.useContext(Jpe);if(e===void 0&&!t)throw new Error(_s(72));return e}const Tht={...zhe,disabled:Bt(t=>t.disabled),instantType:Bt(t=>t.instantType),isInstantPhase:Bt(t=>t.isInstantPhase),trackCursorAxis:Bt(t=>t.trackCursorAxis),disableHoverablePopup:Bt(t=>t.disableHoverablePopup),lastOpenChangeReason:Bt(t=>t.openChangeReason),closeOnClick:Bt(t=>t.closeOnClick),closeDelay:Bt(t=>t.closeDelay),hasViewport:Bt(t=>t.hasViewport)};class nN extends jU{constructor(n){super({...kht(),...n},{popupRef:_.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new tP},Tht);Wn(this,"setOpen",(n,r)=>{var c,u;const i=r.reason,a=i===us,o=n&&i===kb,s=!n&&(i===Wy||i===Lq);if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},(u=(c=this.context).onOpenChange)==null||u.call(c,n,r),r.isCanceled)return;const l=()=>{var p;const f={open:n,openChangeReason:i};o?f.instantType="focus":s?f.instantType="dismiss":i===us&&(f.instantType=void 0);const h=((p=r.trigger)==null?void 0:p.id)??null;(h||n)&&(f.activeTriggerId=h,f.activeTriggerElement=r.trigger??null),this.update(f)};a?Pl.flushSync(l):l()})}static useStore(n,r){const i=yo(()=>new nN(r)).current,a=n??i,o=Yhe({popupStore:a,onOpenChange:a.setOpen});return a.state.floatingRootContext=o,a}}function kht(){return{...Che(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,hasViewport:!1}}const _ht=_he(function(e){const{disabled:n=!1,defaultOpen:r=!1,open:i,disableHoverablePopup:a=!1,trackCursorAxis:o="none",actionsRef:s,onOpenChange:l,onOpenChangeComplete:c,handle:u,triggerId:f,defaultTriggerId:h=null,children:p}=e,y=nN.useStore(u==null?void 0:u.store,{open:r,openProp:i,activeTriggerId:h,triggerIdProp:f});Ihe(()=>{i===void 0&&y.state.open===!1&&r===!0&&y.update({open:!0,activeTriggerId:h})}),y.useControlledProp("openProp",i),y.useControlledProp("triggerIdProp",f),y.useContextCallback("onOpenChange",l),y.useContextCallback("onOpenChangeComplete",c);const v=y.useState("open"),$=!n&&v,x=y.useState("activeTriggerId"),S=y.useState("payload");y.useSyncedValues({trackCursorAxis:o,disableHoverablePopup:a}),qt(()=>{v&&n&&y.setOpen(!1,or(G1e))},[v,n,y]),y.useSyncedValue("disabled",n),jhe(y);const{forceUnmount:b,transitionStatus:T}=Ehe($,y),w=y.useState("isInstantPhase"),P=y.useState("instantType"),k=y.useState("lastOpenChangeReason"),R=_.useRef(null);qt(()=>{T==="ending"&&k===Dq||T!=="ending"&&w?(P!=="delay"&&(R.current=P),y.set("instantType","delay")):R.current!==null&&(y.set("instantType",R.current),R.current=null)},[T,w,k,P,y]),qt(()=>{$&&x==null&&y.set("payload",void 0)},[y,x,$]);const E=_.useCallback(()=>{y.setOpen(!1,Xht(y,cie))},[y]);_.useImperativeHandle(s,()=>({unmount:b,close:E}),[b,E]);const C=y.useState("floatingRootContext"),z=ghe(C,{enabled:!n,referencePress:()=>y.select("closeOnClick")}),Y=Mit(C,{enabled:!n&&o!=="none",axis:o==="none"?void 0:o}),{getReferenceProps:W,getFloatingProps:A,getTriggerProps:q}=YU([z,Y]),N=_.useMemo(()=>W(),[W]),Z=_.useMemo(()=>q(),[q]),D=_.useMemo(()=>A(),[A]);return y.useSyncedValues({activeTriggerProps:N,inactiveTriggerProps:Z,popupProps:D}),m.jsx(Jpe.Provider,{value:y,children:typeof p=="function"?p({payload:S}):p})});function Xht(t,e){const n=or(e);return n.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},n}const eme=_.createContext(void 0);function Rht(){return _.useContext(eme)}let jht=(function(t){return t[t.popupOpen=che.popupOpen]="popupOpen",t.triggerDisabled="data-trigger-disabled",t})({});const Eht=600,Cht=Kat(function(e,n){const{className:r,render:i,handle:a,payload:o,disabled:s,delay:l,closeOnClick:c=!0,closeDelay:u,id:f,...h}=e,p=Lv(!0),y=(a==null?void 0:a.store)??p;if(!y)throw new Error(_s(82));const v=fv(f),$=y.useState("isTriggerActive",v),x=y.useState("isOpenedByTrigger",v),S=y.useState("floatingRootContext"),b=_.useRef(null),T=l??Eht,w=u??0,{registerTrigger:P,isMountedByThisTrigger:k}=Rhe(v,b,y,{payload:o,closeOnClick:c,closeDelay:w}),R=Rht(),{delayRef:E,isInstantPhase:C,hasProvider:z}=Pit(S,{open:x});y.useSyncedValue("isInstantPhase",C);const Y=y.useState("disabled"),W=s??Y,A=y.useState("trackCursorAxis"),q=y.useState("disableHoverablePopup"),N=got(S,{enabled:!W,mouseOnly:!0,move:!1,handleClose:!q&&A!=="both"?Qot():null,restMs(){const I=R==null?void 0:R.delay,B=typeof E.current=="object"?E.current.open:void 0;let L=T;return z&&(B!==0?L=l??I??T:L=0),L},delay(){const I=typeof E.current=="object"?E.current.close:void 0;let B=w;return u==null&&z&&(B=I),{close:B}},triggerElementRef:b,isActiveTrigger:$}),Z=Oot(S,{enabled:!W}).reference,D={open:x},M=y.useState("triggerProps",k);return ha("button",e,{state:D,ref:[n,P,b],props:[N,Z,M,{onPointerDown(){y.set("closeOnClick",c)},id:v,[jht.triggerDisabled]:W?"":void 0},h],stateAttributesMapping:uhe})}),tme=_.createContext(void 0);function zht(){const t=_.useContext(tme);if(t===void 0)throw new Error(_s(70));return t}const Yht=_.forwardRef(function(e,n){const{children:r,container:i,className:a,render:o,...s}=e,{portalNode:l,portalSubtree:c}=mhe({container:i,ref:n,componentProps:e,elementProps:s});return!c&&!l?null:m.jsxs(_.Fragment,{children:[c,l&&Pl.createPortal(r,l)]})}),Aht=_.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e;return Lv().useState("mounted")||r?m.jsx(tme.Provider,{value:r,children:m.jsx(Yht,{ref:n,...i})}):null}),nme=_.createContext(void 0);function rme(){const t=_.useContext(nme);if(t===void 0)throw new Error(_s(71));return t}const qht=_.createContext(void 0);function Zht(){const t=_.useContext(qht);return(t==null?void 0:t.direction)??"ltr"}const Vht=t=>({name:"arrow",options:t,async fn(e){var M,V;const{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:l}=e,{element:c,padding:u=0,offsetParent:f="real"}=Yc(t,e)||{};if(c==null)return{};const h=Fre(u),p={x:n,y:r},y=Nq(i),v=Uq(y),$=await o.getDimensions(c),x=y==="y",S=x?"top":"left",b=x?"bottom":"right",T=x?"clientHeight":"clientWidth",w=a.reference[v]+a.reference[y]-p[y]-a.floating[v],P=p[y]-a.reference[y],k=f==="real"?await((M=o.getOffsetParent)==null?void 0:M.call(o,c)):s.floating;let R=s.floating[T]||a.floating[v];(!R||!await((V=o.isElement)==null?void 0:V.call(o,k)))&&(R=s.floating[T]||a.floating[v]);const E=w/2-P/2,C=R/2-$[v]/2-1,z=Math.min(h[S],C),Y=Math.min(h[b],C),W=z,A=R-$[v]-Y,q=R/2-$[v]/2+E,N=FC(W,q,A),Z=!l.arrow&&hO(i)!=null&&q!==N&&a.reference[v]/2-(q<W?z:Y)-$[v]/2<0,D=Z?q<W?q-W:q-A:0;return{[y]:p[y]+D,data:{[y]:N,centerOffset:q-N-D,...Z&&{alignmentOffset:D}},reset:Z}}}),Uht=(t,e)=>({...Vht(t),options:[t,e]}),Nht={name:"hide",async fn(t){var s;const{width:e,height:n,x:r,y:i}=t.rects.reference,a=e===0&&n===0&&r===0&&i===0;return{data:{referenceHidden:((s=(await Cat().fn(t)).data)==null?void 0:s.referenceHidden)||a}}}},Hb={sideX:"left",sideY:"top"},Wht={name:"adaptiveOrigin",async fn(t){var S,b;const{x:e,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=t,l=ai(i),c=l.getComputedStyle(i);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:e,y:n,data:Hb};const f=await((S=a.getOffsetParent)==null?void 0:S.call(a,i));let h={width:0,height:0};if(o==="fixed"&&(l!=null&&l.visualViewport))h={width:l.visualViewport.width,height:l.visualViewport.height};else if(f===l){const T=dr(i);h={width:T.documentElement.clientWidth,height:T.documentElement.clientHeight}}else await((b=a.isElement)==null?void 0:b.call(a,f))&&(h=await a.getDimensions(f));const p=Ca(s);let y=e,v=n;p==="left"&&(y=h.width-(e+r.width)),p==="top"&&(v=h.height-(n+r.height));const $=p==="left"?"right":Hb.sideX,x=p==="top"?"bottom":Hb.sideY;return{x:y,y:v,data:{sideX:$,sideY:x}}}};function ime(t,e,n){const r=t==="inline-start"||t==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[e]}function Ite(t,e,n){const{rects:r,placement:i}=t;return{side:ime(e,Ca(i),n),align:hO(i)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Mht(t){var ui,gr;const{anchor:e,positionMethod:n="absolute",side:r="bottom",sideOffset:i=0,align:a="center",alignOffset:o=0,collisionBoundary:s,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:f=!1,keepMounted:h=!1,floatingRootContext:p,mounted:y,collisionAvoidance:v,shiftCrossAxis:$=!1,nodeId:x,adaptiveOrigin:S,lazyFlip:b=!1,externalTree:T}=t,[w,P]=_.useState(null);!y&&w!==null&&P(null);const k=v.side||"flip",R=v.align||"flip",E=v.fallbackAxisSide||"end",C=typeof e=="function"?e:void 0,z=tn(C),Y=C?z:e,W=Ol(e),q=Zht()==="rtl",N=w||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":q?"left":"right","inline-start":q?"right":"left"}[r],Z=a==="center"?N:`${N}-${a}`;let D=l;const M=1,V=r==="bottom"?M:0,I=r==="top"?M:0,B=r==="right"?M:0,L=r==="left"?M:0;typeof D=="number"?D={top:D+V,right:D+L,bottom:D+I,left:D+B}:D&&(D={top:(D.top||0)+V,right:(D.right||0)+L,bottom:(D.bottom||0)+I,left:(D.left||0)+B});const J={boundary:s==="clipping-ancestors"?"clippingAncestors":s,padding:D},K=_.useRef(null),H=Ol(i),re=Ol(o),ie=[_at(Tt=>{const _t=Ite(Tt,r,q),Er=typeof H.current=="function"?H.current(_t):H.current,lr=typeof re.current=="function"?re.current(_t):re.current;return{mainAxis:Er,crossAxis:lr,alignmentAxis:lr}},[typeof i!="function"?i:0,typeof o!="function"?o:0,q,r])],se=R==="none"&&k!=="shift",ae=!se&&(c||$||k==="shift"),ue=k==="none"?null:jat({...J,padding:{top:D.top+M,right:D.right+M,bottom:D.bottom+M,left:D.left+M},mainAxis:!$&&k==="flip",crossAxis:R==="flip"?"alignment":!1,fallbackAxisSideDirection:E}),Oe=se?null:Xat(Tt=>{const _t=dr(Tt.elements.floating).documentElement;return{...J,rootBoundary:$?{x:0,y:0,width:_t.clientWidth,height:_t.clientHeight}:void 0,mainAxis:R!=="none",crossAxis:ae,limiter:c||$?void 0:Rat(Er=>{if(!K.current)return{};const{width:lr,height:yr}=K.current.getBoundingClientRect(),et=zo(Ca(Er.placement)),Dt=et==="y"?lr:yr,Cn=et==="y"?D.left+D.right:D.top+D.bottom;return{offset:Dt/2+Cn/2}})}},[J,c,$,D,R]);k==="shift"||R==="shift"||a==="center"?ie.push(Oe,ue):ie.push(ue,Oe),ie.push(Eat({...J,apply({elements:{floating:Tt},availableWidth:_t,availableHeight:Er,rects:lr}){const yr=Tt.style;yr.setProperty("--available-width",`${_t}px`),yr.setProperty("--available-height",`${Er}px`);const et=window.devicePixelRatio||1,{x:Dt,y:Cn,width:Vn,height:cr}=lr.reference,dn=(Math.round((Dt+Vn)*et)-Math.round(Dt*et))/et,_n=(Math.round((Cn+cr)*et)-Math.round(Cn*et))/et;yr.setProperty("--anchor-width",`${dn}px`),yr.setProperty("--anchor-height",`${_n}px`)}}),Uht(()=>({element:K.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Tt){var er,fi,$a;const{elements:_t,middlewareData:Er,placement:lr,rects:yr,y:et}=Tt,Dt=Ca(lr),Cn=zo(Dt),Vn=K.current,cr=((er=Er.arrow)==null?void 0:er.x)||0,dn=((fi=Er.arrow)==null?void 0:fi.y)||0,_n=(Vn==null?void 0:Vn.clientWidth)||0,Va=(Vn==null?void 0:Vn.clientHeight)||0,Ht=cr+_n/2,Mr=dn+Va/2,vo=Math.abs((($a=Er.shift)==null?void 0:$a.y)||0),$r=yr.reference.height/2,Ua=typeof i=="function"?i(Ite(Tt,r,q)):i,Cl=vo>Ua,Oi={top:`${Ht}px calc(100% + ${Ua}px)`,bottom:`${Ht}px ${-Ua}px`,left:`calc(100% + ${Ua}px) ${Mr}px`,right:`${-Ua}px ${Mr}px`}[Dt],_r=`${Ht}px ${yr.reference.y+$r-et}px`;return _t.floating.style.setProperty("--transform-origin",ae&&Cn==="y"&&Cl?_r:Oi),{}}},Nht,S),qt(()=>{!y&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[y,p]);const de=_.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<"u",layoutShift:!f&&typeof IntersectionObserver<"u"}),[f]),{refs:xe,elements:Qe,x:Re,y:Le,middlewareData:Ne,update:ve,placement:Se,context:ke,isPositioned:we,floatingStyles:Ge}=uot({rootContext:p,placement:Z,middleware:ie,strategy:n,whileElementsMounted:h?void 0:(...Tt)=>Aee(...Tt,de),nodeId:x,externalTree:T}),{sideX:ce,sideY:$e}=Ne.adaptiveOrigin||Hb,Ee=we?n:"fixed",De=_.useMemo(()=>{const Tt=S?{position:Ee,[ce]:Re,[$e]:Le}:{position:Ee,...Ge};return we||(Tt.opacity=0),Tt},[S,Ee,ce,Re,$e,Le,Ge,we]),He=_.useRef(null);qt(()=>{if(!y)return;const Tt=W.current,_t=typeof Tt=="function"?Tt():Tt,lr=(Dte(_t)?_t.current:_t)||null||null;lr!==He.current&&(xe.setPositionReference(lr),He.current=lr)},[y,xe,Y,W]),_.useEffect(()=>{if(!y)return;const Tt=W.current;typeof Tt!="function"&&Dte(Tt)&&Tt.current!==He.current&&(xe.setPositionReference(Tt.current),He.current=Tt.current)},[y,xe,Y,W]),_.useEffect(()=>{if(h&&y&&Qe.domReference&&Qe.floating)return Aee(Qe.domReference,Qe.floating,ve,de)},[h,y,Qe,ve,de]);const at=Ca(Se),wt=ime(r,at,q),jt=hO(Se)||"center",Pt=!!((ui=Ne.hide)!=null&&ui.referenceHidden);qt(()=>{b&&y&&we&&P(at)},[b,y,we,at]);const kn=_.useMemo(()=>{var Tt,_t;return{position:"absolute",top:(Tt=Ne.arrow)==null?void 0:Tt.y,left:(_t=Ne.arrow)==null?void 0:_t.x}},[Ne.arrow]),It=((gr=Ne.arrow)==null?void 0:gr.centerOffset)!==0;return _.useMemo(()=>({positionerStyles:De,arrowStyles:kn,arrowRef:K,arrowUncentered:It,side:wt,align:jt,physicalSide:at,anchorHidden:Pt,refs:xe,context:ke,isPositioned:we,update:ve}),[De,kn,K,It,wt,jt,at,Pt,xe,ke,we,ve])}function Dte(t){return t!=null&&"current"in t}function ame(t){return t==="starting"?kxe:Ii}const Iht=_.forwardRef(function(e,n){const{render:r,className:i,anchor:a,positionMethod:o="absolute",side:s="top",align:l="center",sideOffset:c=0,alignOffset:u=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:p=5,sticky:y=!1,disableAnchorTracking:v=!1,collisionAvoidance:$=_xe,...x}=e,S=Lv(),b=zht(),T=S.useState("open"),w=S.useState("mounted"),P=S.useState("trackCursorAxis"),k=S.useState("disableHoverablePopup"),R=S.useState("floatingRootContext"),E=S.useState("instantType"),C=S.useState("transitionStatus"),z=S.useState("hasViewport"),Y=Mht({anchor:a,positionMethod:o,floatingRootContext:R,mounted:w,side:s,sideOffset:c,align:l,alignOffset:u,collisionBoundary:f,collisionPadding:h,sticky:y,arrowPadding:p,disableAnchorTracking:v,keepMounted:b,collisionAvoidance:$,adaptiveOrigin:z?Wht:void 0}),W=_.useMemo(()=>{const Z={};return(!T||P==="both"||k)&&(Z.pointerEvents="none"),{role:"presentation",hidden:!w,style:{...Y.positionerStyles,...Z}}},[T,P,k,w,Y.positionerStyles]),A=_.useMemo(()=>({open:T,side:Y.side,align:Y.align,anchorHidden:Y.anchorHidden,instant:P!=="none"?"tracking-cursor":E}),[T,Y.side,Y.align,Y.anchorHidden,P,E]),q=_.useMemo(()=>({...A,arrowRef:Y.arrowRef,arrowStyles:Y.arrowStyles,arrowUncentered:Y.arrowUncentered}),[A,Y.arrowRef,Y.arrowStyles,Y.arrowUncentered]),N=ha("div",e,{state:A,props:[W,ame(C),x],ref:[n,S.useStateSetter("positionerElement")],stateAttributesMapping:Nv});return m.jsx(nme.Provider,{value:q,children:N})}),Dht={...Nv,...Mq},Lht=_.forwardRef(function(e,n){const{className:r,render:i,...a}=e,o=Lv(),{side:s,align:l}=rme(),c=o.useState("open"),u=o.useState("instantType"),f=o.useState("transitionStatus"),h=o.useState("popupProps"),p=o.useState("floatingRootContext");Iq({open:c,ref:o.context.popupRef,onComplete(){var S,b;c&&((b=(S=o.context).onOpenChangeComplete)==null||b.call(S,!0))}});const y=o.useState("disabled"),v=o.useState("closeDelay");return pot(p,{enabled:!y,closeDelay:v}),ha("div",e,{state:{open:c,side:s,align:l,instant:u,transitionStatus:f},ref:[n,o.context.popupRef,o.useStateSetter("popupElement")],props:[h,ame(f),a],stateAttributesMapping:Dht})}),Ght=_.forwardRef(function(e,n){const{className:r,render:i,...a}=e,s=Lv().useState("instantType"),{open:l,arrowRef:c,side:u,align:f,arrowUncentered:h,arrowStyles:p}=rme();return ha("div",e,{state:{open:l,side:u,align:f,uncentered:h,instant:s},ref:[n,c],props:[{style:p,"aria-hidden":!0},a],stateAttributesMapping:Nv})}),Bht=function(e){const{delay:n,closeDelay:r,timeout:i=400}=e,a=_.useMemo(()=>({delay:n,closeDelay:r}),[n,r]),o=_.useMemo(()=>({open:n,close:r}),[n,r]);return m.jsx(eme.Provider,{value:a,children:m.jsx(wit,{delay:o,timeoutMs:i,children:e.children})})};function Fht({delay:t=0,...e}){return m.jsx(Bht,{"data-slot":"tooltip-provider",delay:t,...e})}function Hht({...t}){return m.jsx(_ht,{"data-slot":"tooltip",...t})}function Kht({...t}){return m.jsx(Cht,{"data-slot":"tooltip-trigger",...t})}function Jht({className:t,side:e="top",sideOffset:n=4,align:r="center",alignOffset:i=0,children:a,...o}){return m.jsx(Aht,{children:m.jsx(Iht,{align:r,alignOffset:i,side:e,sideOffset:n,className:"isolate z-50",children:m.jsxs(Lht,{"data-slot":"tooltip-content",className:jr("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...o,children:[a,m.jsx(Ght,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}function ept({conflictId:t,onClose:e}){var z;const{scan:n,busyConflictId:r,resolveConflict:i,revokeDecision:a,markSuperseded:o}=Mc(),s=n==null?void 0:n.openConflicts.find(Y=>Y.id===t),l=n==null?void 0:n.decidedConflicts.find(Y=>Y.conflict.id===t),c=s??(l==null?void 0:l.conflict),u=l==null?void 0:l.decision,f=!!u,h=!!((z=c==null?void 0:c.candidates[0])!=null&&z.claim.id.startsWith("version-chain:")),p=(u==null?void 0:u.resolution.kind)==="pick"?u.resolution.candidateIndex:(c==null?void 0:c.defaultPick)??0,[y,v]=_.useState(p);_.useEffect(()=>{v(p)},[c==null?void 0:c.id]),_.useEffect(()=>{n&&!c&&e&&e()},[n,c,e]);const[$,x]=_.useState(!1),[S,b]=_.useState("");if(_.useEffect(()=>{x(!1),b("")},[c==null?void 0:c.id]),!c)return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-6 w-6"}),m.jsx("span",{children:"Conflict not found. It may have been resolved."})]});const T=r===c.id,w=c.candidates[y]??c.candidates[0],P=y===c.defaultPick,k=()=>i(c,{kind:"pick",candidateIndex:y}),R=()=>i(c,{kind:"custom",content:"merge-both"}),E=()=>i(c,{kind:"custom",content:S.trim()}),C=()=>a(c.id);return m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsx(tpt,{conflict:c,isVersionChain:h,decision:u,onClose:e}),m.jsxs("div",{className:"flex flex-1 min-h-0",children:[m.jsx(rpt,{conflict:c,selectedIndex:y,onSelect:v,isVersionChain:h}),m.jsx("div",{className:"flex flex-1 min-w-0 flex-col",children:m.jsxs("div",{className:"flex-1 overflow-auto px-5 py-3",children:[m.jsx(ipt,{candidate:w,conflict:c,isVersionChain:h,isDefault:P}),$&&m.jsxs("div",{className:"mt-4 rounded border border-dashed border-border p-3",children:[m.jsx("textarea",{value:S,onChange:Y=>b(Y.target.value),placeholder:"Enter the authoritative answer in your own words…",className:"w-full resize-none rounded border border-border bg-background p-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",rows:5}),m.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[m.jsx(xn,{size:"sm",variant:"ghost",onClick:()=>{x(!1),b("")},children:"Cancel"}),m.jsx(xn,{size:"sm",disabled:T||!S.trim(),onClick:E,children:"Save custom answer"})]})]})]})})]}),m.jsx(lpt,{conflict:c,selectedIndex:y,isVersionChain:h,isDefault:P,isDecided:f,busy:T,customMode:$,onPick:k,onMarkSuperseded:o,onKeepAll:R,onOpenCustom:()=>x(!0),onRevoke:C})]})}function tpt({conflict:t,isVersionChain:e,decision:n,onClose:r}){const i=e?t.subject.replace(/^version chain:\s*/,""):t.subject;return m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-card px-5 py-3",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e?m.jsx(bq,{className:"h-5 w-5 shrink-0 text-amber-400"}):m.jsx(Ju,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider ${e?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:e?"version chain":t.topic}),e&&m.jsx(npt,{conflict:t})]}),m.jsx("h2",{className:"truncate text-base font-semibold",children:i}),m.jsxs("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:[t.candidates.length," candidates"]}),n&&m.jsx("span",{className:"ml-2 shrink-0 rounded bg-emerald-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-emerald-700 dark:text-emerald-300",title:`Decided ${new Date(n.resolvedAt).toLocaleString()}`,children:"decided"})]}),r&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:r,title:"Close detail view",children:m.jsx(Rr,{className:"h-4 w-4"})})]})}function npt({conflict:t}){var r,i;const e=(i=(r=t.candidates[0])==null?void 0:r.claim.content)==null?void 0:i.detectedFrom,n=e==="filename"?"filenames follow a v1/v2 pattern":e==="llm"?"the LLM judged one doc to be a successor of the other based on content (no filename versioning was present)":"a versioning relationship was detected";return m.jsx(Fht,{delay:150,children:m.jsxs(Hht,{children:[m.jsx(Kht,{className:"inline-flex items-center justify-center rounded p-0.5 text-amber-700/80 hover:text-amber-900 dark:text-amber-300/80 dark:hover:text-amber-200 hover:bg-amber-500/10 transition-colors","aria-label":"About version chain conflicts",children:m.jsx(Vve,{className:"h-3.5 w-3.5"})}),m.jsx(Jht,{side:"bottom",align:"start",className:"max-w-sm whitespace-normal text-left leading-relaxed",children:m.jsxs("p",{children:["These docs describe overlapping specs and ",n,". Pick which doc is the current source of truth — claims from the others get dropped. Or keep all docs to merge them as independent sources."]})})]})})}function rpt({conflict:t,selectedIndex:e,onSelect:n,isVersionChain:r}){return m.jsxs("aside",{className:"flex w-60 shrink-0 flex-col gap-1 overflow-y-auto border-r border-border bg-card/40 p-2",children:[m.jsxs("div",{className:"px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:["Candidates · ",t.candidates.length]}),t.candidates.map((i,a)=>{const o=a===e,s=a===t.defaultPick,l=r?a===0?"older":a===t.candidates.length-1?"current":"middle":i.weight,c=i.claim.content,u=(c==null?void 0:c.file)??i.claim.provenance.file,f=u.split("/").pop()??u,h=u.includes("/")?u.slice(0,u.lastIndexOf("/")):"",p=r?(c==null?void 0:c.claimCount)!=null?`${c.claimCount} claims`:null:`:${i.claim.provenance.line}`,y=i.claim.metadata.docKind,v=i.claim.metadata.status,$=i.claim.kind;return m.jsxs("button",{type:"button",onClick:()=>n(a),title:u,className:`flex flex-col items-start gap-1 rounded border px-2.5 py-2 text-left text-xs transition-colors ${o?"border-primary bg-primary/10 text-foreground":"border-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground"}`,children:[m.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:f}),s&&m.jsx(Ff,{className:"h-3 w-3 shrink-0 text-primary","aria-label":"recommended"})]}),h&&m.jsxs("div",{className:"w-full truncate font-mono text-[10px] text-muted-foreground/70",children:[h,"/"]}),m.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1 text-[10px]",children:[m.jsx("span",{className:"rounded bg-muted px-1 py-0.5 uppercase tracking-wider text-muted-foreground",children:l}),y&&y!=="unknown"&&m.jsx("span",{className:"rounded bg-muted px-1 py-0.5 uppercase tracking-wider text-muted-foreground",children:y}),v&&v!=="shipped"&&m.jsx("span",{className:`rounded px-1 py-0.5 uppercase tracking-wider ${v==="deferred"||v==="out-of-scope"||v==="deprecated"?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-muted text-muted-foreground"}`,title:`Lifecycle status: ${v}`,children:v}),$==="constraint"&&m.jsx("span",{className:"rounded bg-sky-500/15 px-1 py-0.5 uppercase tracking-wider text-sky-700 dark:text-sky-300",title:"This claim narrows the subject (e.g. adding 403 responses to existing endpoints) rather than defining it from scratch.",children:"constraint"}),p&&m.jsx("span",{className:"ml-auto text-muted-foreground",children:p})]})]},i.index)})]})}function ipt({candidate:t,conflict:e,isVersionChain:n,isDefault:r}){return n?m.jsx(apt,{candidate:t,conflict:e,isDefault:r}):m.jsx(opt,{candidate:t,conflict:e,isDefault:r})}function apt({candidate:t,conflict:e,isDefault:n}){const r=t.claim.content,i=(r==null?void 0:r.file)??t.claim.provenance.file,a=(r==null?void 0:r.claimCount)??0,o=(r==null?void 0:r.topics)??{},s=t.claim.metadata.lastTouched,l=t.claim.metadata.docKind,c=t.index===0?"older version":t.index===e.candidates.length-1?"current version":"middle version";return m.jsxs("div",{children:[m.jsx(sme,{file:i,role:c,docKind:l,isDefault:n,meta:m.jsxs(m.Fragment,{children:[m.jsxs("span",{children:[m.jsx("span",{className:"font-medium text-foreground",children:a})," claims extracted"]}),m.jsxs("span",{children:["Last touched ",m.jsx("span",{className:"text-foreground",children:upt(s)})]})]})}),Object.keys(o).length>0&&m.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:Object.entries(o).sort((u,f)=>f[1]-u[1]).map(([u,f])=>m.jsxs("span",{className:"rounded bg-muted/60 px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[u," ",m.jsx("span",{className:"text-foreground",children:f})]},u))}),m.jsx(ome,{candidate:t,conflict:e}),e.explanation&&m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"What differs"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-foreground",children:e.explanation})]}),m.jsx(lme,{source:t.claim.provenance.quote})]})}function opt({candidate:t,conflict:e,isDefault:n}){return m.jsxs("div",{children:[m.jsx(sme,{file:`${t.claim.provenance.file}:${t.claim.provenance.line}`,role:t.weight,docKind:t.claim.metadata.docKind,isDefault:n}),n&&m.jsxs("div",{className:"mt-2 rounded border border-primary/30 bg-primary/5 px-3 py-1.5 text-xs text-muted-foreground",children:[m.jsx("span",{className:"font-medium text-primary",children:"Recommended by engine."})," ",spt(t,e)]}),m.jsx(ome,{candidate:t,conflict:e}),e.explanation&&m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"What differs"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-foreground",children:e.explanation})]}),m.jsx(lme,{source:t.claim.provenance.quote})]})}function spt(t,e){const n=[],r=t.claim.metadata.docKind,i=e.candidates.filter(u=>u.index!==t.index),a=new Set(i.map(u=>u.claim.metadata.docKind));if(r&&r!=="unknown"){const u=[...a].filter(f=>Lte(r)>Lte(f));u.length>0&&n.push(`higher-authority doc kind (${r} beats ${u.join(", ")})`)}const s=e.candidates.map(u=>u.claim.metadata.lastTouched).reduce((u,f)=>u>f?u:f);t.claim.metadata.lastTouched===s&&n.push("newest source");const l=dS(t.claim.content),c=Math.max(...e.candidates.map(u=>dS(u.claim.content)));return l===c&&l>0&&n.push("most structurally complete"),n.length>0?n.join(" · "):"no other candidate ranks higher"}function Lte(t){return t==="adr"||t==="rfc"?4:t==="prd"||t==="spec"?3:t==="design-note"||t==="runbook"?2:t==="readme"?1:0}function dS(t){if(t==null)return 0;if(typeof t!="object")return 1;if(Array.isArray(t))return t.reduce((n,r)=>n+dS(r),0);let e=0;for(const n of Object.values(t))e+=dS(n);return e}function ome({candidate:t,conflict:e}){const n=e.resolverVerdict;return!n||n.pick!==t.index?null:m.jsxs("div",{className:"mt-2 rounded border border-violet-500/30 bg-violet-500/5 px-3 py-1.5 text-xs text-muted-foreground",children:[m.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300",children:"Resolver suggests"}),m.jsx("span",{className:"ml-1.5 rounded bg-violet-500/15 px-1 py-0.5 text-[10px] uppercase tracking-wider text-violet-700 dark:text-violet-300",children:n.confidence}),m.jsxs("span",{className:"ml-1.5",children:["— ",n.reasoning]})]})}function sme({file:t,role:e,docKind:n,isDefault:r,meta:i}){return m.jsxs("div",{children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.jsx("span",{className:"font-mono text-sm text-foreground",children:t}),m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:e}),n&&n!=="unknown"&&m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:n}),r&&m.jsx("span",{className:"rounded bg-primary/20 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-primary",children:"recommended"})]}),i&&m.jsx("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:i})]})}function lme({source:t}){return m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Doc preview"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-muted-foreground",children:m.jsx(cpt,{source:t})})]})}function lpt({conflict:t,selectedIndex:e,isVersionChain:n,isDefault:r,isDecided:i,busy:a,customMode:o,onPick:s,onKeepAll:l,onOpenCustom:c,onRevoke:u,onMarkSuperseded:f}){const[h,p]=_.useState(!1),y=t.candidates[e],v=(y==null?void 0:y.claim.provenance.file)??"",$=new Set([v]),x=[];if(y)for(const b of t.candidates){const T=b.claim.provenance.file;$.has(T)||($.add(T),x.push({file:T,weight:b.weight}))}const S=!n&&!i&&x.length>0;return m.jsxs("div",{className:"relative flex shrink-0 items-center gap-2 border-t border-border bg-card px-5 py-3",children:[i&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:u,disabled:a,className:"text-destructive hover:text-destructive",title:"Revoke this decision — the conflict will re-open",children:"Revoke decision"}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n?m.jsx(xn,{size:"sm",variant:"outline",onClick:l,disabled:a,title:"Keep all docs — claims from every version flow through unfiltered",children:"Keep all docs"}):!o&&m.jsxs(m.Fragment,{children:[S&&m.jsx(tm,{side:"top",align:"end",width:"wide",content:m.jsxs(m.Fragment,{children:["Mark ",m.jsx("span",{className:"font-mono",children:v})," as an older version of one of the other docs in this conflict. Claims from this doc are dropped from the corpus and every conflict caused by the same supersession clears in one action."]}),children:m.jsx(xn,{size:"sm",variant:"outline",onClick:()=>p(b=>!b),disabled:a,children:"Mark superseded by →"})}),m.jsx(xn,{size:"sm",variant:"outline",onClick:c,disabled:a,children:"Write custom answer"})]}),m.jsxs(xn,{size:"sm",onClick:s,disabled:a,children:[a?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(Ff,{className:"mr-2 h-3.5 w-3.5"}),i?n?"Use this version instead":"Change to this candidate":n?"Use this version":"Pick this candidate",!i&&r&&m.jsx("span",{className:"ml-1.5 text-[10px] opacity-70",children:"(recommended)"})]})]}),h&&S&&m.jsxs("div",{className:"absolute bottom-full right-6 mb-2 w-[min(28rem,90vw)] rounded border border-border bg-popover p-3 shadow-lg",children:[m.jsxs("div",{className:"mb-2 text-[11px] text-muted-foreground",children:["Mark ",m.jsx("span",{className:"font-mono text-foreground",children:v})," as superseded by:"]}),m.jsx("ul",{className:"flex flex-col gap-1",children:x.map(b=>m.jsx("li",{children:m.jsxs("button",{type:"button",disabled:a,onClick:async()=>{p(!1),await f(v,b.file)},className:"flex w-full items-center justify-between gap-2 rounded border border-border bg-background px-2 py-1.5 text-left text-xs hover:border-primary hover:bg-primary/5",children:[m.jsx("span",{className:"truncate font-mono",children:b.file}),m.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:b.weight})]})},b.file))}),m.jsx("div",{className:"mt-2 flex justify-end",children:m.jsx(xn,{size:"sm",variant:"ghost",onClick:()=>p(!1),disabled:a,children:"Cancel"})})]}),m.jsxs("span",{className:"sr-only",children:[t.candidates.length," candidates total"]})]})}function cpt({source:t}){return m.jsx(dft,{remarkPlugins:[Pht],components:{h1:({children:e})=>m.jsx("div",{className:"mb-1 text-sm font-semibold text-foreground",children:e}),h2:({children:e})=>m.jsx("div",{className:"mb-1 text-sm font-semibold text-foreground",children:e}),h3:({children:e})=>m.jsx("div",{className:"mb-1 text-xs font-semibold text-foreground",children:e}),h4:({children:e})=>m.jsx("div",{className:"mb-1 text-xs font-semibold text-foreground",children:e}),p:({children:e})=>m.jsx("p",{className:"mb-1 last:mb-0",children:e}),ul:({children:e})=>m.jsx("ul",{className:"mb-1 list-disc pl-4 last:mb-0",children:e}),ol:({children:e})=>m.jsx("ol",{className:"mb-1 list-decimal pl-4 last:mb-0",children:e}),li:({children:e})=>m.jsx("li",{className:"mb-0.5",children:e}),code:({children:e})=>m.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:e}),pre:({children:e})=>m.jsx("pre",{className:"my-1 overflow-auto rounded bg-muted p-2 font-mono text-[11px] text-foreground",children:e}),strong:({children:e})=>m.jsx("strong",{className:"font-semibold text-foreground",children:e}),em:({children:e})=>m.jsx("em",{className:"italic",children:e}),a:({children:e,href:n})=>m.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:e}),blockquote:({children:e})=>m.jsx("blockquote",{className:"my-1 border-l-2 border-border pl-2 italic",children:e}),table:({children:e})=>m.jsx("div",{className:"my-1.5 overflow-x-auto",children:m.jsx("table",{className:"w-full border-collapse text-[11px]",children:e})}),thead:({children:e})=>m.jsx("thead",{className:"border-b border-border bg-muted/40",children:e}),tbody:({children:e})=>m.jsx("tbody",{children:e}),tr:({children:e})=>m.jsx("tr",{className:"border-b border-border/40 last:border-0",children:e}),th:({children:e})=>m.jsx("th",{className:"px-2 py-1 text-left font-semibold text-foreground",children:e}),td:({children:e})=>m.jsx("td",{className:"px-2 py-1 align-top",children:e})},children:t})}function upt(t){const e=new Date(t).getTime();if(Number.isNaN(e))return t;const n=Math.round((Date.now()-e)/1e3);if(n<5)return"just now";if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r} min${r===1?"":"s"} ago`;const i=Math.round(r/60);if(i<24)return`${i} hour${i===1?"":"s"} ago`;const a=Math.round(i/24);return`${a} day${a===1?"":"s"} ago`}function Opt({repoId:t,filePath:e}){const[n,r]=_.useState(null),[i,a]=_.useState(!0),[o,s]=_.useState(null),{canonicalVersion:l}=Mc(),[c,u]=hpt(e);return _.useEffect(()=>{let f=!1;return a(!0),s(null),r(null),!c||!u?(s("Invalid section path."),a(!1),()=>{f=!0}):(d0e(t,c,u).then(h=>{f||r(h)}).catch(h=>{f||s(h.message)}).finally(()=>{f||a(!1)}),()=>{f=!0})},[t,c,u,l]),m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsx(Rse,{filePath:e}),m.jsx("div",{className:"flex-1 overflow-auto px-6 py-4",children:i?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o?m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-5 w-5 text-destructive"}),m.jsx("span",{children:o})]}):n?m.jsx(fpt,{section:n}):null})]})}function fpt({section:t}){const e=t.manifest,n=typeof e.status=="string"?e.status:null,r=typeof e.description=="string"?e.description:null;return m.jsxs("div",{className:"text-sm text-foreground",children:[m.jsxs("h1",{className:"mb-2 text-xl font-bold",children:[t.module," — ",t.topic]}),m.jsxs("div",{className:"mb-4 text-xs text-muted-foreground",children:[n&&m.jsxs("span",{className:"mr-3",children:["status: ",n]}),m.jsxs("span",{children:[t.claims.length," claim",t.claims.length===1?"":"s"]})]}),r&&m.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:r}),t.claims.length===0?m.jsx("p",{className:"text-sm text-muted-foreground",children:"No claims in this section."}):t.claims.map(i=>m.jsx(dpt,{claim:i},i.id))]})}function dpt({claim:t}){return m.jsxs("div",{className:"mb-4 rounded border border-border bg-card/40 p-3",children:[m.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[m.jsx("span",{className:"font-mono text-sm font-semibold",children:t.subject}),t.metadata.status&&m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.metadata.status}),t.kind==="constraint"&&m.jsx("span",{className:"rounded bg-sky-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-sky-600 dark:text-sky-300",children:"constraint"})]}),m.jsx("pre",{className:"my-2 overflow-auto rounded border border-border/60 bg-muted/30 p-2 font-mono text-[11px] text-foreground",children:JSON.stringify(t.content,null,2)}),m.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Source: ",m.jsxs("span",{className:"font-mono",children:[t.provenance.file,":",t.provenance.line]})]})]})}function hpt(t){const e=t.indexOf("/");return e===-1?[t,""]:[t.slice(0,e),t.slice(e+1)]}function ppt(t){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){i(!0),o(null);try{const l=await h0e(t);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load contracts")}finally{i(!1)}}},[t]);return _.useEffect(()=>{s()},[s]),{tree:e,isLoading:r,error:a,refetch:s}}function mpt(t){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){i(!0),o(null);try{const l=await f0e(t);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load canonical spec")}finally{i(!1)}}},[t]);return _.useEffect(()=>{s()},[s]),{tree:e,isLoading:r,error:a,refetch:s}}const wl=Object.create(null);wl.open="0";wl.close="1";wl.ping="2";wl.pong="3";wl.message="4";wl.upgrade="5";wl.noop="6";const Kb=Object.create(null);Object.keys(wl).forEach(t=>{Kb[wl[t]]=t});const lq={type:"error",data:"parser error"},cme=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ume=typeof ArrayBuffer=="function",Ome=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,rN=({type:t,data:e},n,r)=>cme&&e instanceof Blob?n?r(e):Gte(e,r):ume&&(e instanceof ArrayBuffer||Ome(e))?n?r(e):Gte(new Blob([e]),r):r(wl[t]+(e||"")),Gte=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function Bte(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let wC;function gpt(t,e){if(cme&&t.data instanceof Blob)return t.data.arrayBuffer().then(Bte).then(e);if(ume&&(t.data instanceof ArrayBuffer||Ome(t.data)))return e(Bte(t.data));rN(t,!1,n=>{wC||(wC=new TextEncoder),e(wC.encode(n))})}const Fte="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",oy=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Fte.length;t++)oy[Fte.charCodeAt(t)]=t;const ypt=t=>{let e=t.length*.75,n=t.length,r,i=0,a,o,s,l;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const c=new ArrayBuffer(e),u=new Uint8Array(c);for(r=0;r<n;r+=4)a=oy[t.charCodeAt(r)],o=oy[t.charCodeAt(r+1)],s=oy[t.charCodeAt(r+2)],l=oy[t.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|l&63;return c},$pt=typeof ArrayBuffer=="function",iN=(t,e)=>{if(typeof t!="string")return{type:"message",data:fme(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:vpt(t.substring(1),e)}:Kb[n]?t.length>1?{type:Kb[n],data:t.substring(1)}:{type:Kb[n]}:lq},vpt=(t,e)=>{if($pt){const n=ypt(t);return fme(n,e)}else return{base64:!0,data:t}},fme=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},dme="",xpt=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((a,o)=>{rN(a,!1,s=>{r[o]=s,++i===n&&e(r.join(dme))})})},Qpt=(t,e)=>{const n=t.split(dme),r=[];for(let i=0;i<n.length;i++){const a=iN(n[i],e);if(r.push(a),a.type==="error")break}return r};function bpt(){return new TransformStream({transform(t,e){gpt(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const a=new DataView(i.buffer);a.setUint8(0,126),a.setUint16(1,r)}else{i=new Uint8Array(9);const a=new DataView(i.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let PC;function xb(t){return t.reduce((e,n)=>e+n.length,0)}function Qb(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Spt(t,e){PC||(PC=new TextDecoder);const n=[];let r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(xb(n)<1)break;const l=Qb(n,1);a=(l[0]&128)===128,i=l[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(xb(n)<2)break;const l=Qb(n,2);i=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(xb(n)<8)break;const l=Qb(n,8),c=new DataView(l.buffer,l.byteOffset,l.length),u=c.getUint32(0);if(u>Math.pow(2,21)-1){s.enqueue(lq);break}i=u*Math.pow(2,32)+c.getUint32(4),r=3}else{if(xb(n)<i)break;const l=Qb(n,i);s.enqueue(iN(a?l:PC.decode(l),e)),r=0}if(i===0||i>t){s.enqueue(lq);break}}}})}const hme=4;function ii(t){if(t)return wpt(t)}function wpt(t){for(var e in ii.prototype)t[e]=ii.prototype[e];return t}ii.prototype.on=ii.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};ii.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};ii.prototype.off=ii.prototype.removeListener=ii.prototype.removeAllListeners=ii.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};ii.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this};ii.prototype.emitReserved=ii.prototype.emit;ii.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ii.prototype.hasListeners=function(t){return!!this.listeners(t).length};const sP=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Eo=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Ppt="arraybuffer";function pme(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const Tpt=Eo.setTimeout,kpt=Eo.clearTimeout;function lP(t,e){e.useNativeTimers?(t.setTimeoutFn=Tpt.bind(Eo),t.clearTimeoutFn=kpt.bind(Eo)):(t.setTimeoutFn=Eo.setTimeout.bind(Eo),t.clearTimeoutFn=Eo.clearTimeout.bind(Eo))}const _pt=1.33;function Xpt(t){return typeof t=="string"?Rpt(t):Math.ceil((t.byteLength||t.size)*_pt)}function Rpt(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function mme(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function jpt(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function Ept(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let a=n[r].split("=");e[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return e}class Cpt extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class aN extends ii{constructor(e){super(),this.writable=!1,lP(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new Cpt(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=iN(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=jpt(e);return n.length?"?"+n:""}}class zpt extends aN{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Qpt(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,xpt(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=mme()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let gme=!1;try{gme=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ypt=gme;function Apt(){}class qpt extends zpt{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class vl extends ii{constructor(e,n,r){super(),this.createRequest=e,lP(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=pme(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=vl.requestsCount++,vl.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Apt,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete vl.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}vl.requestsCount=0;vl.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Hte);else if(typeof addEventListener=="function"){const t="onpagehide"in Eo?"pagehide":"unload";addEventListener(t,Hte,!1)}}function Hte(){for(let t in vl.requests)vl.requests.hasOwnProperty(t)&&vl.requests[t].abort()}const Zpt=(function(){const t=yme({xdomain:!1});return t&&t.responseType!==null})();class Vpt extends qpt{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=Zpt&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new vl(yme,this.uri(),e)}}function yme(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Ypt))return new XMLHttpRequest}catch{}if(!e)try{return new Eo[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const $me=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Upt extends aN{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=$me?{}:pme(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;rN(r,this.supportsBinary,a=>{try{this.doWrite(r,a)}catch{}i&&sP(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=mme()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const TC=Eo.WebSocket||Eo.MozWebSocket;class Npt extends Upt{createSocket(e,n,r){return $me?new TC(e,n,r):n?new TC(e,n):new TC(e)}doWrite(e,n){this.ws.send(n)}}class Wpt extends aN{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=Spt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=bpt();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const a=()=>{r.read().then(({done:s,value:l})=>{s||(this.onPacket(l),a())}).catch(s=>{})};a();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this._writer.write(r).then(()=>{i&&sP(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Mpt={websocket:Npt,webtransport:Wpt,polling:Vpt},Ipt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Dpt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function cq(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=Ipt.exec(t||""),a={},o=14;for(;o--;)a[Dpt[o]]=i[o]||"";return n!=-1&&r!=-1&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=Lpt(a,a.path),a.queryKey=Gpt(a,a.query),a}function Lpt(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Gpt(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,a){i&&(n[i]=a)}),n}const uq=typeof addEventListener=="function"&&typeof removeEventListener=="function",Jb=[];uq&&addEventListener("offline",()=>{Jb.forEach(t=>t())},!1);class Ku extends ii{constructor(e,n){if(super(),this.binaryType=Ppt,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=cq(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=cq(n.host).host);lP(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ept(this.opts.query)),uq&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Jb.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=hme,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ku.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ku.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=Xpt(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,sP(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const a={type:e,data:n,options:r};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(Ku.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),uq&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Jb.indexOf(this._offlineEventListener);r!==-1&&Jb.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ku.protocol=hme;class Bpt extends Ku{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;Ku.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ku.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function a(){r||(r=!0,u(),n.close(),n=null)}const o=f=>{const h=new Error("probe error: "+f);h.transport=n.name,a(),this.emitReserved("upgradeError",h)};function s(){o("transport closed")}function l(){o("socket closed")}function c(f){n&&f.name!==n.name&&a()}const u=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",s),this.off("close",l),this.off("upgrading",c)};n.once("open",i),n.once("error",o),n.once("close",s),this.once("close",l),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let Fpt=class extends Bpt{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>Mpt[i]).filter(i=>!!i)),super(e,r)}};function Hpt(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=cq(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const a=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+a+":"+r.port+e,r.href=r.protocol+"://"+a+(n&&n.port===r.port?"":":"+r.port),r}const Kpt=typeof ArrayBuffer=="function",Jpt=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,vme=Object.prototype.toString,emt=typeof Blob=="function"||typeof Blob<"u"&&vme.call(Blob)==="[object BlobConstructor]",tmt=typeof File=="function"||typeof File<"u"&&vme.call(File)==="[object FileConstructor]";function oN(t){return Kpt&&(t instanceof ArrayBuffer||Jpt(t))||emt&&t instanceof Blob||tmt&&t instanceof File}function e0(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(e0(t[n]))return!0;return!1}if(oN(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return e0(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e0(t[n]))return!0;return!1}function nmt(t){const e=[],n=t.data,r=t;return r.data=Oq(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Oq(t,e){if(!t)return t;if(oN(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Oq(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Oq(t[r],e));return n}return t}function rmt(t,e){return t.data=fq(t.data,e),delete t.attachments,t}function fq(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=fq(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=fq(t[n],e));return t}const imt=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var cn;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(cn||(cn={}));class amt{constructor(e){this.replacer=e}encode(e){return(e.type===cn.EVENT||e.type===cn.ACK)&&e0(e)?this.encodeAsBinary({type:e.type===cn.EVENT?cn.BINARY_EVENT:cn.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===cn.BINARY_EVENT||e.type===cn.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=nmt(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class sN extends ii{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===cn.BINARY_EVENT;r||n.type===cn.BINARY_ACK?(n.type=r?cn.EVENT:cn.ACK,this.reconstructor=new omt(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(oN(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(cn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===cn.BINARY_EVENT||r.type===cn.BINARY_ACK){const a=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(a,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");const s=Number(o);if(!smt(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=s}if(e.charAt(n+1)==="/"){const a=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(a,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const a=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}r.id=Number(e.substring(a,n+1))}if(e.charAt(++n)){const a=this.tryParse(e.substr(n));if(sN.isPayloadValid(r.type,a))r.data=a;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case cn.CONNECT:return Kte(n);case cn.DISCONNECT:return n===void 0;case cn.CONNECT_ERROR:return typeof n=="string"||Kte(n);case cn.EVENT:case cn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&imt.indexOf(n[0])===-1);case cn.ACK:case cn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class omt{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=rmt(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const smt=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function Kte(t){return Object.prototype.toString.call(t)==="[object Object]"}const lmt=Object.freeze(Object.defineProperty({__proto__:null,Decoder:sN,Encoder:amt,get PacketType(){return cn}},Symbol.toStringTag,{value:"Module"}));function cs(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const cmt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class xme extends ii{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[cs(e,"open",this.onopen.bind(this)),cs(e,"packet",this.onpacket.bind(this)),cs(e,"error",this.onerror.bind(this)),cs(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,i,a;if(cmt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:cn.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const u=this.ids++,f=n.pop();this._registerAckCallback(u,f),o.id=u}const s=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,l=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===e&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},i),o=(...s)=>{this.io.clearTimeoutFn(a),n.apply(this,s)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...n){return new Promise((r,i)=>{const a=(o,s)=>o?i(o):r(s);a.withError=!0,n.push(a),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...a)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...a)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:cn.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case cn.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case cn.EVENT:case cn.BINARY_EVENT:this.onevent(e);break;case cn.ACK:case cn.BINARY_ACK:this.onack(e);break;case cn.DISCONNECT:this.ondisconnect();break;case cn.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:cn.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:cn.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function Tm(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Tm.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Tm.prototype.reset=function(){this.attempts=0};Tm.prototype.setMin=function(t){this.ms=t};Tm.prototype.setMax=function(t){this.max=t};Tm.prototype.setJitter=function(t){this.jitter=t};class dq extends ii{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,lP(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Tm({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||lmt;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Fpt(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=cs(n,"open",function(){r.onopen(),e&&e()}),a=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),e?e(s):this.maybeReconnectOnOpen()},o=cs(n,"error",a);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{i(),a(new Error("timeout")),n.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(cs(e,"ping",this.onping.bind(this)),cs(e,"data",this.ondata.bind(this)),cs(e,"error",this.onerror.bind(this)),cs(e,"close",this.onclose.bind(this)),cs(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){sP(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new xme(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Gg={};function t0(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=Hpt(t,e.path||"/socket.io"),r=n.source,i=n.id,a=n.path,o=Gg[i]&&a in Gg[i].nsps,s=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return s?l=new dq(r,e):(Gg[i]||(Gg[i]=new dq(r,e)),l=Gg[i]),n.query&&!e.query&&(e.query=n.queryKey),l.socket(n.path,e)}Object.assign(t0,{Manager:dq,Socket:xme,io:t0,connect:t0});const umt=ly()||(typeof window<"u"?window.location.origin:"");let Pf=null;function lN(){return Pf||(Pf=t0(umt,{autoConnect:!1,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,reconnectionDelayMax:5e3,transports:["websocket","polling"]})),Pf}function kC(){const t=lN();return t.connected||t.connect(),t}function Omt(){Pf!=null&&Pf.connected&&Pf.disconnect()}function Jte(t){const e=lN();e.connected&&e.emit("joinRepo",t)}function fmt(t){const e=lN();e.connected&&e.emit("leaveRepo",t)}function dmt(t){const[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),[s,l]=_.useState(null),[c,u]=_.useState(null),f=_.useRef(new Map);_.useEffect(()=>{const x=kC();function S(){n(!0),t&&Jte(t)}function b(){n(!1)}function T(R){if(R.step==="error"){i({...R,step:"error"});return}R.percent>=100?i(null):i(R)}function w(R){var E;i(null),(E=f.current.get("analysis:complete"))==null||E.forEach(C=>C(R))}function P(R){if(R.step==="error"){o({...R,step:"error"});return}R.percent>=100?o(null):o(R)}function k(R){var E;o(null),(E=f.current.get("spec:complete"))==null||E.forEach(C=>C(R))}return x.on("connect",S),x.on("disconnect",b),x.on("analysis:progress",T),x.on("analysis:complete",w),x.on("spec:progress",P),x.on("spec:complete",k),x.on("files:changed",R=>{var E;(E=f.current.get("files:changed"))==null||E.forEach(C=>C(R))}),x.on("violations:ready",R=>{var E;i(null),(E=f.current.get("violations:ready"))==null||E.forEach(C=>C(R))}),x.on("analysis:canceled",R=>{var E;i(null),l(null),u(null),(E=f.current.get("analysis:canceled"))==null||E.forEach(C=>C(R))}),x.on("analysis:llm-estimate",R=>{l(R)}),x.on("analysis:llm-resolved",()=>{l(null)}),x.on("analysis:stash-confirm-request",R=>{u(R)}),x.connected&&t&&Jte(t),()=>{t&&fmt(t),x.off("connect",S),x.off("disconnect",b),x.off("analysis:progress",T),x.off("analysis:complete",w),x.off("spec:progress",P),x.off("spec:complete",k),Omt()}},[t]);const h=_.useCallback((x,S)=>{const b=f.current.get(x)||[];return b.push(S),f.current.set(x,b),()=>{const T=f.current.get(x)||[];f.current.set(x,T.filter(w=>w!==S))}},[]),p=_.useCallback(()=>i(null),[]),y=_.useCallback(()=>o(null),[]),v=_.useCallback((x,S)=>{kC().emit("analysis:llm-proceed",{repoId:x,proceed:S}),l(null)},[]),$=_.useCallback((x,S)=>{kC().emit("analysis:stash-confirm-response",{repoId:x,choice:S}),u(null)},[]);return{isConnected:e,analysisProgress:r,specProgress:a,clearProgress:p,clearSpecProgress:y,onEvent:h,llmEstimate:s,respondToLlmEstimate:v,stashConfirm:c,respondToStashConfirm:$}}function hmt(t,e,n,r={}){const{enabled:i=!0}=r,[a,o]=_.useState([]),[s,l]=_.useState(!0),[c,u]=_.useState(null),f=_.useCallback(async()=>{if(!(!t||!i)){l(!0),u(null);try{const p=await xre(t,n);o(p)}catch(p){u(p instanceof Error?p.message:"Failed to fetch violations")}finally{l(!1)}}},[t,n,i]);return _.useEffect(()=>{f()},[f]),{violations:_.useMemo(()=>{const p={critical:0,high:1,medium:2,low:3,info:4};return[...a].sort((v,$)=>{const x=(p[v.severity]??5)-(p[$.severity]??5);return x!==0?x:new Date($.createdAt).getTime()-new Date(v.createdAt).getTime()})},[a,e]),allViolations:a,isLoading:s,error:c,refetch:f}}function pmt(t,e){const[n,r]=_.useState(null),[i,a]=_.useState(!1),[o,s]=_.useState(null),l=_.useCallback(async()=>{if(!e){s("Socket event stream not available; cannot run diff check.");return}a(!0),s(null),r(null);const f=[],h=new Promise((p,y)=>{f.push(e("analysis:complete",v=>{v.repoId===t&&p("completed")})),f.push(e("analysis:canceled",v=>{v.repoId===t&&p("canceled")})),f.push(e("analysis:progress",v=>{const $=v;$.repoId===t&&$.step==="error"&&y(new Error($.detail??"Diff check failed"))}))});try{if(await t0e(t),await h==="canceled")s("Diff check cancelled"),r(null);else{const y=await X8(t);r(y)}}catch(p){p instanceof em&&p.status===400?s("Switch to Normal mode and run an analysis first"):s(p instanceof Error?p.message:"Diff check failed"),r(null)}finally{f.forEach(p=>p()),a(!1)}},[t,e]),c=_.useCallback(async()=>{s(null);try{const f=await X8(t);r(f)}catch(f){s(f instanceof Error?f.message:"Failed to load diff check"),r(null)}},[t]),u=_.useCallback(()=>{r(null),s(null)},[]);return{diffResult:n,isChecking:i,error:o,run:l,load:c,clear:u}}function mmt(t){const[e,n]=_.useState([]),[r,i]=_.useState(!0),a=_.useCallback(async()=>{if(t){i(!0);try{const o=await Ibe(t);n(o)}catch{}finally{i(!1)}}},[t]);return _.useEffect(()=>{a()},[a]),{analyses:e,isLoading:r,refetch:a}}function gmt(t,e,n={}){const{enabled:r=!0}=n,[i,a]=_.useState(null),[o,s]=_.useState(!1),l=_.useCallback(async()=>{if(!(!t||!r)){s(!0);try{const c=await bre(t,e);a(c)}catch{a(null)}finally{s(!1)}}},[t,e,r]);return _.useEffect(()=>{l()},[l]),{summary:i,isLoading:o,refetch:l}}function ymt(t,e={}){const{enabled:n=!0,analysisId:r}=e,[i,a]=_.useState([]),[o,s]=_.useState({}),[l,c]=_.useState(!0),[u,f]=_.useState(null),h=_.useCallback(async()=>{if(t){if(!n){c(!1);return}c(!0),f(null);try{const p=await i0e(t,r);a(p.flows),s(p.severities)}catch(p){f(p instanceof Error?p.message:"Failed to fetch flows")}finally{c(!1)}}},[t,n,r]);return _.useEffect(()=>{h()},[h]),{flows:i,severities:o,isLoading:l,error:u,refetch:h}}function $mt(){return m.jsx(iSe,{children:m.jsx(aSe,{children:m.jsx(sSe,{children:m.jsx(cSe,{children:m.jsx(OSe,{children:m.jsx(vmt,{})})})})})})}function vmt(){var Kv,Jv,kd,ex;const{repoId:t=""}=Bye(),{section:e,leftTab:n,setSection:r,setLeftTab:i}=Oie(),{selectedService:a,setSelectedService:o,depthLevel:s,setDepthLevel:l,scopedServiceId:c,setScopedServiceId:u,scopedModuleId:f,setScopedModuleId:h,focusRequest:p,locateNode:y}=oSe(),{isDiffMode:v,setIsDiffMode:$,selectedAnalysisId:x,setSelectedAnalysisId:S,selectedPath:b,setSelectedPath:T}=fSe(),[w,P]=_.useState(null),[k,R]=_.useState(!1),{openFiles:E,activeFilePath:C,handleOpenFile:z,handleCloseFile:Y,openFlows:W,activeFlowId:A,handleOpenFlow:q,handleCloseFlow:N,syncFlowNames:Z,openDatabases:D,activeDbId:M,handleOpenDatabase:V,handleCloseDatabase:I,handleSelectTab:B,showFlowView:L,showDatabaseView:J,handleLeftTabChange:K}=lSe(),{activeSpecConflictId:H,setActiveSpecConflictId:re,handleSelectSpecConflict:F,activeCanonicalPath:te,setActiveCanonicalPath:ie,openCanonicalFiles:se,handleOpenCanonical:ae,handleCloseCanonical:ue,activeContractsPath:Oe,setActiveContractsPath:de,openContractsFiles:xe,handleOpenContracts:Qe,handleCloseContracts:Re,activeDriftId:Le,setActiveDriftId:Ne,openDriftTabs:ve,handleOpenDrift:Se,handleCloseDrift:ke,reconcileDriftTabs:we}=uSe(),Ge=w==null?void 0:w.defaultBranch,{isConnected:ce,analysisProgress:$e,specProgress:Ee,clearProgress:De,clearSpecProgress:He,onEvent:at,llmEstimate:wt,respondToLlmEstimate:jt,stashConfirm:Pt,respondToStashConfirm:kn}=dmt(t);_.useEffect(()=>{if(!Pt)return;const he=Ze=>{Ze.key==="Escape"&&kn(Pt.repoId,"cancel")};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[Pt,kn]),_.useEffect(()=>{if(!wt)return;const he=Ze=>{Ze.key==="Escape"&&jt(wt.repoId,!1)};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[wt,jt]);const{violations:It,allViolations:ui,isLoading:gr,refetch:Tt}=hmt(t,void 0,x??void 0,{enabled:n==="home"}),{diffResult:_t,isChecking:Er,error:lr,run:yr,load:et}=pmt(t,at),Dt=v&&!_t,Cn=Dt?[]:It,Vn=Dt?[]:ui,{analyses:cr,refetch:dn}=mmt(t),_n=v&&(_t!=null&&_t.diffAnalysisId)?_t.diffAnalysisId:x??void 0,Va=n==="graphs"||n==="files"||n==="databases",{nodes:Ht,edges:Mr,savedCollapsedIds:vo,scopes:$r,isLoading:Ua,error:Cl,refetch:Oi}=Iet(t,{branch:Ge,level:s,analysisId:_n,scopedServiceId:c,scopedModuleId:f,enabled:Va});_.useEffect(()=>{s==="modules"&&!c&&$r.services.length===1&&u($r.services[0].id)},[s,c,$r.services,u]),_.useEffect(()=>{if(s!=="methods"||f)return;const he=c?$r.modules.filter(Ze=>Ze.serviceId===c):$r.modules;he.length===1&&h(he[0].id)},[s,f,c,$r.modules,h]);const{summary:_r,refetch:er}=gmt(t,_n,{enabled:n==="files"}),fi=Dt?void 0:_r,{flows:$a,severities:fd,isLoading:km,refetch:zl}=ymt(t,{enabled:n==="flows",analysisId:_n}),Yl=Dt?{}:fd,{tree:wO,isLoading:Es,error:Cs,refetch:Fo}=ppt(t),{tree:zs,isLoading:Cr,error:dd,refetch:PO}=mpt(t),{state:va,diff:Ti,history:Hc,isLoading:TO,isRunning:hd,isDiffing:kO,error:Kc,refetch:Ho,run:Na,runDiff:qi}=jLe(t),{generating:pd,result:Al,run:Ys}=ELe(t),{contractsStale:md,verifyStale:ql,refetch:gd}=CLe(t),[ki,Wa]=_.useState({severity:null,kind:null,file:null}),yd=_.useCallback(he=>Wa(Ze=>({...Ze,severity:Ze.severity===he?null:he})),[]),_O=_.useCallback(he=>Wa(Ze=>({...Ze,kind:Ze.kind===he?null:he})),[]),Ko=_.useCallback(he=>Wa(Ze=>({...Ze,file:Ze.file===he?null:he})),[]),Gv=_.useCallback(he=>Wa(Ze=>({...Ze,[he]:null})),[]),[$d,Jc]=_.useState(560),_m=_.useRef(!1),Bv=_.useCallback(he=>{he.preventDefault(),_m.current=!0;const Ze=he.clientX,We=$d,Kt=Xr=>{if(!_m.current)return;const tr=Xr.clientX-Ze;Jc(Math.min(800,Math.max(320,We+tr)))},kt=()=>{_m.current=!1,document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",kt)};document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",kt)},[$d]),[As,Zl]=_.useState(null),[cP,Xm]=_.useState(null);_.useEffect(()=>{if(!As||!t){Xm(null);return}let he=!1;return v0e(t,As).then(Ze=>{he||Xm(Ze)}).catch(()=>{he||Xm(null)}),()=>{he=!0}},[As,t]);const qs=!!As,ea=qs?cP:va,XO=v&&!qs,vd=_.useMemo(()=>[...Hc.runs].reverse().map(he=>{const Ze=new Date(he.verifiedAt);return{id:he.id,label:Number.isNaN(Ze.getTime())?he.verifiedAt:`${Ze.toLocaleDateString()} ${Ze.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}}),[Hc]),Vl=qs?((Kv=vd.find(he=>he.id===As))==null?void 0:Kv.label)??null:null,eu=_.useCallback(he=>{Zl(he),i("verify")},[i]),Fv=_.useCallback(async he=>{await x0e(t,he),Zl(Ze=>Ze===he?null:Ze),await Ho()},[t,Ho]);_.useEffect(()=>{we(va?new Set(va.drifts.map(he=>he.id)):null),Wa({severity:null,kind:null,file:null}),Zl(null)},[va,we]);const tu=!!x,Rm=x?cr.find(he=>he.id===x):null,[Zs,Jo]=_.useState(null);_.useEffect(()=>{t&&T8(t).then(he=>{var We;P(he);const Ze=(We=he.latestAnalysis)==null?void 0:We.status;Ze==="running"?R(!0):Ze==="cancelling"&&(R(!0),nu(!0))}).catch(he=>{Jo(he instanceof Error?he.message:"Failed to load repository")})},[t]),_.useEffect(()=>{v&&et()},[]),_.useEffect(()=>{$e&&!k&&!v&&R(!0)},[$e,k,v]),_.useEffect(()=>{const he=at("analysis:complete",()=>{R(!1),nu(!1),Oi(),dn(),er(),zl(),T8(t).then(P).catch(()=>{})}),Ze=at("analysis:canceled",()=>{R(!1),nu(!1)});return()=>{he(),Ze()}},[at,Oi,dn,er,zl,t]),_.useEffect(()=>at("spec:complete",Ze=>{const We=Ze;(We==null?void 0:We.kind)==="scan"?PO():(We==null?void 0:We.kind)==="generate"?Fo():(We==null?void 0:We.kind)==="verify"&&Ho(),((We==null?void 0:We.kind)==="scan"||(We==null?void 0:We.kind)==="generate"||(We==null?void 0:We.kind)==="verify")&&gd()}),[at,PO,Fo,Ho,gd]),_.useEffect(()=>at("violations:ready",()=>{R(!1),Tt(),er()}),[at,Tt,er]);const[xd,Ul]=_.useState(null),[es,nu]=_.useState(!1),Qd=async()=>{if(v)yr();else try{R(!0),Ul(null),await vre(t),Oi(),dn(),Tt(),er(),zl()}catch(he){R(!1),Ul(he instanceof Error?he.message:"Analysis failed")}},bd=_.useCallback(he=>{var Ze;if(o(he),he){const We=Ht.find(Kt=>Kt.id===he);if(We&&We.type==="database"){const Kt=((Ze=We.data)==null?void 0:Ze.label)??"Database";V(he,Kt,!0);return}}},[Ht,V]),RO=_.useCallback(()=>{$(!0),et()},[$,et]),jO=_.useCallback(()=>{$(!1)},[$]),jm=_.useMemo(()=>{if(!v||!_t)return Ht;const he=new Set(_t.affectedNodeIds.services),Ze=new Set(_t.affectedNodeIds.layers),We=new Set(_t.affectedNodeIds.modules),Kt=new Set(_t.affectedNodeIds.methods),kt=new Map,Xr=new Map,tr=new Map,Xn=new Map,xa=new Map,zO=new Map;for(const ut of _t.newViolations){if(ut.targetServiceName&&kt.set(ut.targetServiceName,(kt.get(ut.targetServiceName)||0)+1),ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}`;tr.set(Yr,(tr.get(Yr)||0)+1)}if(ut.targetMethodName&&ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}::${ut.targetMethodName}`;Xn.set(Yr,(Xn.get(Yr)||0)+1)}}for(const ut of _t.resolvedViolations||[]){if(ut.targetServiceName&&Xr.set(ut.targetServiceName,(Xr.get(ut.targetServiceName)||0)+1),ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}`;xa.set(Yr,(xa.get(Yr)||0)+1)}if(ut.targetMethodName&&ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}::${ut.targetMethodName}`;zO.set(Yr,(zO.get(Yr)||0)+1)}}const tx=ut=>{let Yr=ut;for(;;){const Vs=Yr.parentId;if(!Vs)return"";const Zi=Ht.find(Vi=>Vi.id===Vs);if(!Zi)return"";if(Zi.type==="serviceGroup")return Zi.data.label;Yr=Zi}};return Ht.map(ut=>{const Yr=ut.data,Vs=Yr.label;if(ut.type==="service"||ut.type==="serviceGroup"){const Zi=Vs,Vi=he.has(Zi);return{...ut,data:{...Yr,diffBadge:Vi?{newCount:kt.get(Zi)||0,resolvedCount:Xr.get(Zi)||0}:void 0},style:Vi?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="layer"){const Zi=ut.parentId,Vi=Zi?Ht.find(_d=>_d.id===Zi):void 0,Cm=`${Vi?Vi.data.label:""}::${Vs}`,iu=Ze.has(Cm);return{...ut,data:{...Yr,diffBadge:iu?{newCount:0,resolvedCount:0}:void 0},style:iu?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="module"){const Vi=`${tx(ut)}::${Vs}`,ru=We.has(Vi);return{...ut,data:{...Yr,diffBadge:ru?{newCount:tr.get(Vi)||0,resolvedCount:xa.get(Vi)||0}:void 0},style:ru?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="method"){const Zi=tx(ut),Vi=ut.parentId,ru=Vi?Ht.find(OP=>OP.id===Vi):void 0,Cm=ru?ru.data.label:"",iu=`${Zi}::${Cm}::${Vs}`,_d=Kt.has(iu);return{...ut,data:{...Yr,diffBadge:_d?{newCount:Xn.get(iu)||0,resolvedCount:zO.get(iu)||0}:void 0},style:_d?ut.style:{...ut.style,opacity:.4}}}return{...ut,style:{...ut.style,opacity:.4}}})},[Ht,v,_t]),zr=_.useCallback((he,Ze)=>{if(!he||!Ze)return!1;if(he.includes(Ze))return!0;const We=he.split("/");for(let Kt=We.length-1;Kt>=1;Kt--){const kt=We.slice(Kt).join("/");if(Ze.startsWith(kt+"/")||Ze===kt)return!0}return!1},[]),ts=_.useMemo(()=>{const he=v?jm:Ht;if(!b)return he;const Ze=new Map;for(const kt of he){const Xr=kt.parentId;Xr&&Ze.set(kt.id,Xr)}const We=new Set;for(const kt of he){const Xr=kt.data;let tr=!1;if(kt.type==="module"||kt.type==="method"){const Xn=Xr.filePath||Xr.rootPath||"";zr(Xn,b)&&(tr=!0)}else if(kt.type==="layer"){const Xn=Xr.filePaths;Xn!=null&&Xn.some(xa=>zr(xa,b))&&(tr=!0)}else if(kt.type==="serviceGroup"){const Xn=Xr.rootPath||"";zr(Xn,b)&&(tr=!0)}else if(kt.type==="service"){const Xn=Xr.serviceInfo,xa=(Xn==null?void 0:Xn.rootPath)||"";zr(xa,b)&&(tr=!0)}if(tr){We.add(kt.id);let Xn=Ze.get(kt.id);for(;Xn;)We.add(Xn),Xn=Ze.get(Xn)}}let Kt=!0;for(;Kt;){Kt=!1;for(const kt of he){if(We.has(kt.id))continue;const Xr=Ze.get(kt.id);if(!Xr||!We.has(Xr))continue;const tr=kt.data;if(kt.type==="module"||kt.type==="method"){const Xn=tr.filePath||tr.rootPath||"";zr(Xn,b)&&(We.add(kt.id),Kt=!0)}else if(kt.type==="layer"){const Xn=tr.filePaths;Xn!=null&&Xn.some(xa=>zr(xa,b))&&(We.add(kt.id),Kt=!0)}}}return he.map(kt=>We.has(kt.id)?kt:{...kt,style:{...kt.style,opacity:.15}})},[Ht,jm,v,b,zr]),Sd=_.useMemo(()=>{var Ze;if(!b)return null;const he=new Set;for(const We of ts)((Ze=We.style)==null?void 0:Ze.opacity)!==.15&&he.add(We.id);return he},[ts,b]);if(_.useMemo(()=>{const he=new Map;for(const Ze of Ht){const We=Ze.data;let Kt=We.filePath||We.rootPath;if(!Kt&&Ze.type==="service"){const kt=We.serviceInfo;Kt=(kt==null?void 0:kt.rootPath)||""}Kt&&he.set(Ze.id,Kt)}return he},[Ht]),!t)return m.jsx(c$e,{to:"/",replace:!0});const EO=_.useCallback((he,Ze,We)=>{i("graphs"),y(he,Ze,We)},[i,y]),wd=C!==null&&n==="files",Pd=A!==null&&n==="flows",Em=M!==null&&n==="databases",CO=H!==null&&(n==="spec"||n==="decisions"),Td=te!==null&&n==="spec",Hv=Oe!==null&&n==="contracts",uP=(w==null?void 0:w.lastAnalyzed)!=null;return _.useEffect(()=>{Z($a)},[$a,Z]),m.jsx(dSe,{repoId:t,children:m.jsxs("div",{className:"flex h-screen flex-col",children:[m.jsx(qq,{repoName:w==null?void 0:w.name,currentBranch:Ge,onAnalyze:e!=="analysis"||tu||Zs||(w==null?void 0:w.isGitRepo)===!1?void 0:Qd,isAnalyzing:k||Er,showBack:!0,backHref:"/",isDiffMode:v,onEnterDiffMode:e!=="analysis"||tu?void 0:RO,onExitDiffMode:e!=="analysis"||tu?void 0:jO,analyses:cr,selectedAnalysisId:x,onSelectAnalysis:S,currentAnalysisId:_n||(v||(Jv=cr==null?void 0:cr[0])==null?void 0:Jv.id),dashboardSection:e,onDashboardSectionChange:r,sectionActions:n==="spec"?m.jsx(hSe,{}):n==="contracts"?m.jsx(zLe,{isGenerating:pd,onGenerate:Ys,stale:md}):n==="verify"?m.jsx(kLe,{isRunning:v?kO:hd,onRun:v?qi:Na,stale:ql,diffMode:v,onToggleDiff:$,isGitRepo:(w==null?void 0:w.isGitRepo)!==!1,runItems:vd,selectedRunId:As,onSelectRun:Zl,viewingHistory:qs}):null}),!wd&&tu&&Rm&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsxs("span",{children:["Viewing analysis from"," ",new Date(Rm.createdAt).toLocaleString([],{dateStyle:"medium",timeStyle:"short"})," ","— not the latest"]}),m.jsx("button",{className:"underline hover:text-amber-400 transition-colors",onClick:()=>S(null),children:"Return to latest"})]}),v&&(_t==null?void 0:_t.diffAnalysisId)&&m.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:m.jsx("span",{children:"Showing working tree state (uncommitted changes)"})}),n==="verify"&&qs&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsxs("span",{children:["Viewing verify run",Vl?` from ${Vl}`:""," — not the latest"]}),m.jsx("button",{className:"underline hover:text-amber-400 transition-colors",onClick:()=>Zl(null),children:"Return to latest"})]}),Zs&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-destructive/10 border-b border-destructive/30 px-4 py-1.5 text-xs text-destructive",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{children:Zs})]}),!Zs&&(w==null?void 0:w.isGitRepo)===!1&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{children:"This directory is not a git repository — branch switching and history are unavailable."})]}),m.jsx(YLe,{result:Al}),m.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m.jsxs(rSe,{section:e,activeTab:n,onTabChange:K,badgeCounts:{home:Vn.length,flows:$a.length,databases:Ht.filter(he=>he.type==="database").length,analyses:cr.length},children:[n==="flows"&&m.jsx(fst,{flows:$a,isLoading:km,onSelectFlow:q,activeFlowId:A,flowSeverities:Yl}),n==="databases"&&m.jsx(Cst,{repoId:t,branch:Ge,analysisId:_n,activeDbId:M,onSelectDatabase:V}),n==="files"&&m.jsx(cst,{repoId:t,selectedPath:b,onOpenFile:z,violationCounts:fi==null?void 0:fi.byFile,violationSeverities:fi==null?void 0:fi.highestSeverityByFile,revealPath:C,isDiffMode:v,onSelectPath:he=>{if(T(he),!he){bd(null);return}let Ze=null;for(const We of Ht){if(We.type!=="service"&&We.type!=="serviceGroup")continue;const Kt=We.data;let kt="";if(We.type==="service"){const tr=Kt.serviceInfo;kt=(tr==null?void 0:tr.rootPath)||""}else kt=Kt.rootPath||"";if(!kt)continue;const Xr=kt.split("/");for(let tr=Xr.length-1;tr>=0;tr--){const Xn=Xr.slice(tr).join("/");if(he.startsWith(Xn)||he.startsWith(Xn+"/")){const xa=Xr.length-tr;(!Ze||xa>Ze.depth)&&(Ze={id:We.id,depth:xa});break}}}bd((Ze==null?void 0:Ze.id)??null)}}),n==="spec"&&m.jsx(Hst,{canonicalTree:zs,canonicalLoading:Cr,canonicalError:dd,activeConflictId:H,onSelectConflict:F,activeCanonicalPath:te,onOpenCanonicalFile:ae}),n==="contracts"&&m.jsx(gSe,{tree:wO,isLoading:Es,error:Cs,activePath:Oe,validationIssues:Al&&"il"in Al&&"validationIssues"in Al.il?Al.il.validationIssues:void 0,onOpen:Qe}),n==="decisions"&&m.jsx(qLe,{activeConflictId:H,onSelectConflict:F})]}),m.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(n==="files"||n==="flows"||n==="databases")&&(E.length>0||W.length>0||D.length>0)||n==="spec"&&se.length>0||n==="contracts"&&xe.length>0?m.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-card text-xs overflow-x-auto",children:[E.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=C===he.path;return m.jsxs("div",{onClick:()=>B(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),Y(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)}),W.map(he=>{const Ze=A===he.id&&!wd;return m.jsxs("div",{onClick:()=>L(he.id),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${Ze?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.name,children:[m.jsx(Wne,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:he.name}),m.jsx("button",{onClick:We=>{We.stopPropagation(),N(he.id)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${Ze?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.id)}),D.map(he=>{const Ze=M===he.id&&!wd&&!Pd;return m.jsxs("div",{onClick:()=>J(he.id),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${Ze?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.name,children:[m.jsx(xl,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:he.name}),m.jsx("button",{onClick:We=>{We.stopPropagation(),I(he.id)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${Ze?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.id)}),n==="spec"&&se.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=te===he.path;return m.jsxs("div",{onClick:()=>ie(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx(Ju,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),ue(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)}),n==="contracts"&&xe.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=Oe===he.path;return m.jsxs("div",{onClick:()=>de(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx(Ju,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),Re(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)})]}):null,m.jsx("div",{className:"relative flex-1 overflow-hidden",children:wd&&C?m.jsx(Est,{repoId:t,filePath:C,analysisId:_n,scrollToLine:(kd=E.find(he=>he.path===C))==null?void 0:kd.scrollToLine,isDiffMode:v,onClose:()=>Y(C)}):Pd&&A?m.jsx(jst,{repoId:t,flowId:A,analysisId:_n,canEnrich:!v&&!x}):Em&&M?m.jsx(ohe,{repoId:t,databaseId:M,analysisId:_n,violations:Cn,isTab:!0}):Td&&te?m.jsx(Opt,{repoId:t,filePath:te}):CO&&H?m.jsx(ept,{conflictId:H,onClose:()=>re(null)}):n==="spec"?m.jsx(pSe,{}):Hv&&Oe?m.jsx(jze,{repoId:t,filePath:Oe}):n==="contracts"?m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:"Select a contract file from the list to view it."})}):n==="verify"?(()=>{const he=(XO?[...(Ti==null?void 0:Ti.added)??[],...(Ti==null?void 0:Ti.resolved)??[]]:(ea==null?void 0:ea.drifts)??[]).find(Ze=>Ze.id===Le)??null;return m.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[m.jsxs("aside",{style:{width:$d},className:"relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-card",children:[m.jsx(xLe,{state:ea,diff:Ti,history:Hc,mode:XO?"diff":"current",isDiffing:kO,filters:ki,onToggleSeverity:yd,onToggleKind:_O,onToggleFile:Ko}),m.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:Bv})]}),m.jsx("div",{className:"w-[380px] shrink-0 overflow-hidden border-r border-border",children:m.jsx(Cze,{state:ea,diff:Ti,mode:XO?"diff":"current",isLoading:TO,isDiffing:kO,error:Kc,activeDriftId:Le,filters:ki,onClearFilter:Gv,onOpenDrift:Se})}),m.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:he?m.jsx(XLe,{drift:he,onClose:()=>ke(he.id),onOpenFile:(Ze,We)=>{r("analysis"),z(Ze,!0,We)}}):m.jsx(RLe,{})})]})})():n==="runs"?m.jsx(TLe,{history:Hc,selectedRunId:As,onViewRun:eu,onDeleteRun:Fv}):n==="decisions"?m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{className:"max-w-md",children:"Every conflict you've resolved in the Spec tab lives in the ledger on the left. Revoke a decision to re-open its conflict — your other candidates are preserved."})}):n==="analyses"?m.jsx(Mst,{analyses:cr,isLoading:!1,currentAnalysisId:_n||(v||(ex=cr==null?void 0:cr[0])==null?void 0:ex.id),selectedAnalysisId:x,onSelectAnalysis:S,onDeleteAnalysis:async he=>{await Lbe(t,he),S(null),dn(),Tt(),Oi(),er(),zl(),v&&et()},repoId:t}):n==="home"?w==null?m.jsx("div",{className:"flex h-full w-full items-center justify-center",children:m.jsx(yn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):m.jsx(ast,{repoId:t,branch:Ge,analysisId:_n,hasAnalysis:uP,violations:Cn,violationsLoading:gr,isDiffMode:v,diffResult:_t,onLocateNode:EO,onOpenFile:z,onRefreshAfterDisable:Tt},w.lastAnalyzed??"unanalyzed"):n==="graphs"?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"absolute right-3 top-2 z-20 flex items-center gap-1.5 rounded-full bg-card px-2 py-1 text-[10px] shadow-sm border border-border",children:ce?m.jsxs(m.Fragment,{children:[m.jsx(exe,{className:"h-3 w-3 text-emerald-500"}),m.jsx("span",{className:"text-emerald-500",children:"Live"})]}):m.jsxs(m.Fragment,{children:[m.jsx(Jve,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"text-muted-foreground",children:"Offline"})]})}),Ua?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3",children:[m.jsx(yn,{className:"h-10 w-10 animate-spin text-primary"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."})]})}):Cl&&!k?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[m.jsx(zi,{className:"h-10 w-10 text-destructive"}),m.jsxs(uy,{variant:"destructive",className:"max-w-sm",children:[m.jsx(N8,{children:"Failed to load graph"}),m.jsx(Oy,{children:Cl})]}),m.jsx(xn,{onClick:()=>Oi(),className:"mt-2",children:"Retry"})]})}):Ht.length===0&&Ht.length===0&&!(s==="modules"&&!c)&&!(s==="methods"&&!f)?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[m.jsx(zi,{className:"h-10 w-10 text-muted-foreground"}),m.jsxs(uy,{className:"max-w-sm",children:[m.jsx(N8,{children:"No graph data"}),m.jsx(Oy,{children:"Run an analysis to generate the architecture graph"})]}),v&&lr&&m.jsxs(uy,{className:"mt-3 max-w-sm border-amber-500/30 text-amber-500",children:[m.jsx(zi,{className:"h-4 w-4"}),m.jsx(Oy,{className:"text-amber-500/90",children:lr})]})]})}):m.jsx(m.Fragment,{children:m.jsx(dnt,{initialNodes:ts,initialEdges:Mr,onNodeSelect:bd,selectedNodeId:a,repoId:t,branch:Ge,onRefetch:Oi,depthLevel:s,onDepthChange:l,focusNodeId:(p==null?void 0:p.nodeId)??null,focusKey:(p==null?void 0:p.key)??0,isDiffMode:v,diffResult:_t,isDiffChecking:Er,hasProgressBar:!!$e,onEnterDiffMode:RO,onExitDiffMode:jO,highlightedNodeIds:Sd,savedCollapsedIds:vo,scopes:$r,scopedServiceId:c,scopedModuleId:f,onScopedServiceChange:u,onScopedModuleChange:he=>{if(h(he),he){const Ze=$r.modules.find(We=>We.id===he);Ze&&Ze.serviceId&&Ze.serviceId!==c&&u(Ze.serviceId)}}})})]}):m.jsx("div",{className:"flex h-full items-center justify-center text-center",children:m.jsx("p",{className:"max-w-xs text-sm text-muted-foreground",children:n==="files"?"Pick a file from the tree to preview it here.":n==="flows"?"Pick a flow to view its sequence diagram here.":n==="databases"?"Pick a database to view its schema here.":null})})})]})]}),xd&&m.jsxs("div",{className:"fixed bottom-4 left-1/2 z-40 w-96 -translate-x-1/2 rounded-lg border border-destructive/50 bg-card p-3 shadow-lg",children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:"text-[11px] font-medium text-destructive",children:"Analysis failed"}),m.jsx("button",{onClick:()=>Ul(null),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:xd})]})]}),Pt&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>kn(Pt.repoId,"cancel"),role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"w-96 rounded-lg border border-border bg-card p-4 shadow-lg",onClick:he=>he.stopPropagation(),children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:"Stash pending changes?"}),m.jsx("button",{onClick:()=>kn(Pt.repoId,"cancel"),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Cancel",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsxs("p",{className:"mb-4 text-[11px] text-muted-foreground",children:["Your repository has ",Pt.modifiedCount," modified and"," ",Pt.untrackedCount," untracked file(s)."]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{className:"rounded-md bg-primary px-3 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",onClick:()=>kn(Pt.repoId,"stash"),children:"Stash and analyze committed state"}),m.jsx("button",{className:"rounded-md border border-border px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent",onClick:()=>kn(Pt.repoId,"no-stash"),children:"Don't stash — analyze working tree as-is"})]})]})}),wt&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>jt(wt.repoId,!1),role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"w-96 rounded-lg border border-border bg-card p-4 shadow-lg",onClick:he=>he.stopPropagation(),children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:"Run LLM rules?"}),m.jsx("button",{onClick:()=>jt(wt.repoId,!1),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Skip",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:(()=>{const he=wt.estimate.tiers.reduce((We,Kt)=>We+Kt.ruleCount,0);return`${wt.estimate.tiers.reduce((We,Kt)=>We+Kt.fileCount,0)} files, ${he} rules (~${Math.round(wt.estimate.totalEstimatedTokens/1e3)}k tokens).`})()}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{className:"rounded-md bg-primary px-3 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",onClick:()=>jt(wt.repoId,!0),children:"Run LLM rules"}),m.jsx("button",{className:"rounded-md border border-border px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent",onClick:()=>jt(wt.repoId,!1),children:"Skip — deterministic rules only"})]})]})}),$e&&m.jsxs("div",{className:`fixed bottom-4 left-1/2 z-40 w-80 -translate-x-1/2 rounded-lg border bg-card p-3 shadow-lg ${$e.step==="error"?"border-destructive/50":"border-border"}`,children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:`text-[11px] font-medium ${$e.step==="error"?"text-destructive":"text-foreground"}`,children:$e.step==="error"?"Analysis failed":es?"Cancelling...":"Analyzing..."}),$e.step==="error"?m.jsx("button",{onClick:()=>{De(),R(!1)},className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})}):es?m.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] text-amber-500",children:"Cancelling..."}):m.jsx("button",{onClick:()=>{t&&(Gbe(t).catch(()=>{}),nu(!0))},className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground",children:"Cancel"})]}),$e.step==="error"?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(i0,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:$e.detail||"An error occurred"})]}):$e.steps&&$e.steps.length>0?m.jsx("div",{className:"space-y-1",children:$e.steps.map(he=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 translate-y-px",children:[he.status==="done"&&m.jsx(Ff,{className:"h-3.5 w-3.5 text-emerald-500"}),he.status==="active"&&m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin text-primary"}),he.status==="error"&&m.jsx(i0,{className:"h-3.5 w-3.5 text-destructive"}),he.status==="pending"&&m.jsx("div",{className:"h-2.5 w-2.5 rounded-full border border-muted-foreground/30"})]}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsxs("span",{className:`text-[11px] leading-[18px] ${he.status==="active"?"font-medium text-foreground":he.status==="done"?"text-muted-foreground":he.status==="error"?"text-destructive":"text-muted-foreground/60"}`,children:[he.label,he.detail&&he.status!=="pending"&&m.jsx("span",{className:"ml-1.5 text-[10px] font-normal text-muted-foreground/70",children:he.detail})]})})]},he.key))}):m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(yn,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:$e.detail||$e.step})]})]}),Ee&&m.jsx(mSe,{progress:Ee,onDismiss:He})]})})}function ene({children:t}){return m.jsxs("div",{className:"flex min-h-screen flex-col",children:[m.jsx(qq,{}),m.jsx("main",{className:"flex-1 overflow-auto",children:t})]})}function xmt(){const{routes:t,homeComponent:e}=Xre(),n=_.useMemo(()=>t.map(i=>({path:i.path,Component:_.lazy(()=>i.load())})),[t]),r=_.useMemo(()=>e?_.lazy(()=>e()):null,[e]);return m.jsxs(O$e,{children:[m.jsx(bb,{path:"/",element:r?m.jsx(ene,{children:m.jsx(_.Suspense,{children:m.jsx(r,{})})}):m.jsx(nSe,{})}),m.jsx(bb,{path:"/repos/:repoId",element:m.jsx(_.Suspense,{children:m.jsx($mt,{})})}),n.map(({path:i,Component:a})=>m.jsx(bb,{path:i,element:m.jsx(ene,{children:m.jsx(_.Suspense,{children:m.jsx(a,{})})})},i))]})}function Qmt(){const t=Ere();return m.jsx(X0e,{children:m.jsx(U0e,{children:m.jsx(M0e,{children:m.jsx(Y$e,{children:m.jsxs(I0e,{children:[m.jsx(xmt,{}),m.jsx(yve,{position:"bottom-center",theme:t?"dark":"light",closeButton:!0,toastOptions:{unstyled:!0,duration:1e4,classNames:{toast:"font-sans w-full flex items-start gap-3 rounded-md border px-4 py-3 text-sm shadow-lg bg-popover text-popover-foreground border-border",title:"font-semibold leading-tight",description:"mt-0.5 text-xs leading-snug opacity-90",actionButton:"rounded-md bg-primary px-2 py-1 text-xs text-primary-foreground hover:opacity-90",cancelButton:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted",closeButton:"absolute right-1.5 top-1.5 rounded p-0.5 text-muted-foreground hover:bg-muted",success:"!text-emerald-700 dark:!text-emerald-300",error:"!text-red-700 dark:!text-red-300",warning:"!text-amber-700 dark:!text-amber-300",info:"!text-blue-700 dark:!text-blue-300"}}})]})})})})})}fye.createRoot(document.getElementById("root")).render(m.jsx(_.StrictMode,{children:m.jsx(Qmt,{})}));
|
|
765
|
+
`))}function l(p,y,v,$){const x=v.enter("tableCell"),S=v.enter("phrasing"),b=v.containerPhrasing(p,{...$,before:a,after:a});return S(),x(),b}function c(p,y){return edt(p,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function u(p,y,v){const $=p.children;let x=-1;const S=[],b=y.enter("table");for(;++x<$.length;)S[x]=f($[x],y,v);return b(),S}function f(p,y,v){const $=p.children;let x=-1;const S=[],b=y.enter("tableRow");for(;++x<$.length;)S[x]=l($[x],p,y,v);return b(),S}function h(p,y,v){let $=Mpe.inlineCode(p,y,v);return v.stack.includes("tableCell")&&($=$.replace(/\|/g,"\\$&")),$}}function Udt(){return{exit:{taskListCheckValueChecked:Wte,taskListCheckValueUnchecked:Wte,paragraph:Wdt}}}function Ndt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Mdt}}}function Wte(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Wdt(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function Mdt(t,e,n,r){const i=t.children[0],a=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let l=Mpe.listItem(t,e,n,{...r,...s.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function Idt(){return[bft(),Mft(),Gft(),Cdt(),Udt()]}function Ddt(t){return{extensions:[Sft(),Ift(t),Bft(),Vdt(t),Ndt()]}}const Ldt={tokenize:Jdt,partial:!0},Ipe={tokenize:eht,partial:!0},Dpe={tokenize:tht,partial:!0},Lpe={tokenize:nht,partial:!0},Gdt={tokenize:rht,partial:!0},Gpe={name:"wwwAutolink",tokenize:Hdt,previous:Fpe},Bpe={name:"protocolAutolink",tokenize:Kdt,previous:Hpe},Fc={name:"emailAutolink",tokenize:Fdt,previous:Kpe},El={};function Bdt(){return{text:El}}let of=48;for(;of<123;)El[of]=Fc,of++,of===58?of=65:of===91&&(of=97);El[43]=Fc;El[45]=Fc;El[46]=Fc;El[95]=Fc;El[72]=[Fc,Bpe];El[104]=[Fc,Bpe];El[87]=[Fc,Gpe];El[119]=[Fc,Gpe];function Fdt(t,e,n){const r=this;let i,a;return o;function o(f){return!sq(f)||!Kpe.call(r,r.previous)||tN(r.events)?n(f):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),s(f))}function s(f){return sq(f)?(t.consume(f),s):f===64?(t.consume(f),l):n(f)}function l(f){return f===46?t.check(Gdt,u,c)(f):f===45||f===95||Gi(f)?(a=!0,t.consume(f),l):u(f)}function c(f){return t.consume(f),i=!0,l}function u(f){return a&&i&&ia(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(f)):n(f)}}function Hdt(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Fpe.call(r,r.previous)||tN(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(Ldt,t.attempt(Ipe,t.attempt(Dpe,a),n),n)(o))}function a(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function Kdt(t,e,n){const r=this;let i="",a=!1;return o;function o(f){return(f===72||f===104)&&Hpe.call(r,r.previous)&&!tN(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),t.consume(f),s):n(f)}function s(f){if(ia(f)&&i.length<5)return i+=String.fromCodePoint(f),t.consume(f),s;if(f===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(f),l}return n(f)}function l(f){return f===47?(t.consume(f),a?c:(a=!0,l)):n(f)}function c(f){return f===null||cS(f)||Jn(f)||Bf(f)||nP(f)?n(f):t.attempt(Ipe,t.attempt(Dpe,u),n)(f)}function u(f){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(f)}}function Jdt(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),a):n(o)}function a(o){return o===null?n(o):e(o)}}function eht(t,e,n){let r,i,a;return o;function o(c){return c===46||c===95?t.check(Lpe,l,s)(c):c===null||Jn(c)||Bf(c)||c!==45&&nP(c)?l(c):(a=!0,t.consume(c),o)}function s(c){return c===95?r=!0:(i=r,r=void 0),t.consume(c),o}function l(c){return i||r||!a?n(c):e(c)}}function tht(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(Lpe,e,a)(o):o===null||Jn(o)||Bf(o)?e(o):(t.consume(o),i)}function a(o){return o===41&&r++,t.consume(o),i}}function nht(t,e,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(t.consume(s),r):s===38?(t.consume(s),a):s===93?(t.consume(s),i):s===60||s===null||Jn(s)||Bf(s)?e(s):n(s)}function i(s){return s===null||s===40||s===91||Jn(s)||Bf(s)?e(s):r(s)}function a(s){return ia(s)?o(s):n(s)}function o(s){return s===59?(t.consume(s),r):ia(s)?(t.consume(s),o):n(s)}}function rht(t,e,n){return r;function r(a){return t.consume(a),i}function i(a){return Gi(a)?n(a):e(a)}}function Fpe(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Jn(t)}function Hpe(t){return!ia(t)}function Kpe(t){return!(t===47||sq(t))}function sq(t){return t===43||t===45||t===46||t===95||Gi(t)}function tN(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const iht={tokenize:fht,partial:!0};function aht(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cht,continuation:{tokenize:uht},exit:Oht}},text:{91:{name:"gfmFootnoteCall",tokenize:lht},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:oht,resolveTo:sht}}}}function oht(t,e,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return n(l);const c=xs(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!a.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function sht(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",a,e],["enter",o,e],["exit",o,e],["exit",a,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...s),t}function lht(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(f){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(t.enter("gfmFootnoteCallMarker"),t.consume(f),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(f){if(a>999||f===93&&!o||f===null||f===91||Jn(f))return n(f);if(f===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(xs(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(f),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(f)}return Jn(f)||(o=!0),a++,t.consume(f),f===92?u:c}function u(f){return f===91||f===92||f===93?(t.consume(f),a++,c):c(f)}}function cht(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(y)}function u(y){if(o>999||y===93&&!s||y===null||y===91||Jn(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return a=xs(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Jn(y)||(s=!0),o++,t.consume(y),y===92?f:u}function f(y){return y===91||y===92||y===93?(t.consume(y),o++,u):u(y)}function h(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(a)||i.push(a),gn(t,p,"gfmFootnoteDefinitionWhitespace")):n(y)}function p(y){return e(y)}}function uht(t,e,n){return t.check(Iv,e,t.attempt(iht,e,n))}function Oht(t){t.exit("gfmFootnoteDefinition")}function fht(t,e,n){const r=this;return gn(t,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(a):n(a)}}function dht(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",u,s],["enter",o[c][1],s],["exit",o[c][1],s],["enter",f,s]],p=s.parser.constructs.insideSpan.null;p&&Oo(h,h.length,0,rP(p,o.slice(c+1,l),s)),Oo(h,h.length,0,[["exit",f,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",u,s]]),Oo(o,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function a(o,s,l){const c=this.previous,u=this.events;let f=0;return h;function h(y){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),p(y))}function p(y){const v=Bp(c);if(y===126)return f>1?l(y):(o.consume(y),f++,p);if(f<2&&!n)return l(y);const $=o.exit("strikethroughSequenceTemporary"),x=Bp(y);return $._open=!x||x===2&&!!v,$._close=!v||v===2&&!!x,s(y)}}}class hht{constructor(){this.map=[]}add(e,n,r){pht(this,e,n,r)}consume(e){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const a of i)e.push(a);i=r.pop()}this.map.length=0}}function pht(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function mht(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function ght(){return{flow:{null:{name:"table",tokenize:yht,resolveAll:$ht}}}}function yht(t,e,n){const r=this;let i=0,a=0,o;return s;function s(C){let z=r.events.length-1;for(;z>-1;){const A=r.events[z][1].type;if(A==="lineEnding"||A==="linePrefix")z--;else break}const Y=z>-1?r.events[z][1].type:null,W=Y==="tableHead"||Y==="tableRow"?P:l;return W===P&&r.parser.lazy[r.now().line]?n(C):W(C)}function l(C){return t.enter("tableHead"),t.enter("tableRow"),c(C)}function c(C){return C===124||(o=!0,a+=1),u(C)}function u(C){return C===null?n(C):pt(C)?a>1?(a=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),p):n(C):nn(C)?gn(t,u,"whitespace")(C):(a+=1,o&&(o=!1,i+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),f(C)))}function f(C){return C===null||C===124||Jn(C)?(t.exit("data"),u(C)):(t.consume(C),C===92?h:f)}function h(C){return C===92||C===124?(t.consume(C),f):f(C)}function p(C){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(C):(t.enter("tableDelimiterRow"),o=!1,nn(C)?gn(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):y(C))}function y(C){return C===45||C===58?$(C):C===124?(o=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),v):w(C)}function v(C){return nn(C)?gn(t,$,"whitespace")(C):$(C)}function $(C){return C===58?(a+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),x):C===45?(a+=1,x(C)):C===null||pt(C)?T(C):w(C)}function x(C){return C===45?(t.enter("tableDelimiterFiller"),S(C)):w(C)}function S(C){return C===45?(t.consume(C),S):C===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(C))}function b(C){return nn(C)?gn(t,T,"whitespace")(C):T(C)}function T(C){return C===124?y(C):C===null||pt(C)?!o||i!==a?w(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(C)):w(C)}function w(C){return n(C)}function P(C){return t.enter("tableRow"),k(C)}function k(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),k):C===null||pt(C)?(t.exit("tableRow"),e(C)):nn(C)?gn(t,k,"whitespace")(C):(t.enter("data"),R(C))}function R(C){return C===null||C===124||Jn(C)?(t.exit("data"),k(C)):(t.consume(C),C===92?E:R)}function E(C){return C===92||C===124?(t.consume(C),R):R(C)}}function $ht(t,e){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,c,u,f;const h=new hht;for(;++n<t.length;){const p=t[n],y=p[1];p[0]==="enter"?y.type==="tableHead"?(s=!1,l!==0&&(Mte(h,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",c,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,f=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",u,e]])),i=y.type==="tableDelimiterRow"?2:u?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],f=vb(h,e,a,i,void 0,f),a=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],f=vb(h,e,a,i,void 0,f)),a=o,o=[a[1],n,0,0])):y.type==="tableHead"?(s=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,a[1]!==0?(o[0]=o[1],f=vb(h,e,a,i,n,f)):o[1]!==0&&(f=vb(h,e,o,i,n,f)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Mte(h,e,l,c,u),h.consume(e.events),n=-1;++n<e.events.length;){const p=e.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=mht(e.events,n))}return t}function vb(t,e,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},$h(e.events,n[0])),t.add(n[0],0,[["exit",a,e]]));const l=$h(e.events,n[1]);if(a={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",a,e]]),n[2]!==0){const c=$h(e.events,n[2]),u=$h(e.events,n[3]),f={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",f,e]]),r!==2){const h=e.events[n[2]],p=e.events[n[3]];if(h[1].end=Object.assign({},p[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",f,e]])}return i!==void 0&&(a.end=Object.assign({},$h(e.events,i)),t.add(i,0,[["exit",a,e]]),a=void 0),a}function Mte(t,e,n,r,i){const a=[],o=$h(e.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,e])),r.end=Object.assign({},o),a.push(["exit",r,e]),t.add(n+1,0,a)}function $h(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const vht={name:"tasklistCheck",tokenize:Qht};function xht(){return{text:{91:vht}}}function Qht(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),a)}function a(l){return Jn(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),s):n(l)}function s(l){return pt(l)?e(l):nn(l)?t.check({tokenize:bht},e,n)(l):n(l)}}function bht(t,e,n){return gn(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Sht(t){return cpe([Bdt(),aht(),dht(t),ght(),xht()])}const wht={};function Pht(t){const e=this,n=t||wht,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Sht(n)),a.push(Idt()),o.push(Ddt(n))}const Jpe=_.createContext(void 0);function Lv(t){const e=_.useContext(Jpe);if(e===void 0&&!t)throw new Error(_s(72));return e}const Tht={...zhe,disabled:Bt(t=>t.disabled),instantType:Bt(t=>t.instantType),isInstantPhase:Bt(t=>t.isInstantPhase),trackCursorAxis:Bt(t=>t.trackCursorAxis),disableHoverablePopup:Bt(t=>t.disableHoverablePopup),lastOpenChangeReason:Bt(t=>t.openChangeReason),closeOnClick:Bt(t=>t.closeOnClick),closeDelay:Bt(t=>t.closeDelay),hasViewport:Bt(t=>t.hasViewport)};class nN extends jU{constructor(n){super({...kht(),...n},{popupRef:_.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new tP},Tht);Wn(this,"setOpen",(n,r)=>{var c,u;const i=r.reason,a=i===us,o=n&&i===kb,s=!n&&(i===Wy||i===Lq);if(r.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},(u=(c=this.context).onOpenChange)==null||u.call(c,n,r),r.isCanceled)return;const l=()=>{var p;const f={open:n,openChangeReason:i};o?f.instantType="focus":s?f.instantType="dismiss":i===us&&(f.instantType=void 0);const h=((p=r.trigger)==null?void 0:p.id)??null;(h||n)&&(f.activeTriggerId=h,f.activeTriggerElement=r.trigger??null),this.update(f)};a?Pl.flushSync(l):l()})}static useStore(n,r){const i=yo(()=>new nN(r)).current,a=n??i,o=Yhe({popupStore:a,onOpenChange:a.setOpen});return a.state.floatingRootContext=o,a}}function kht(){return{...Che(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,hasViewport:!1}}const _ht=_he(function(e){const{disabled:n=!1,defaultOpen:r=!1,open:i,disableHoverablePopup:a=!1,trackCursorAxis:o="none",actionsRef:s,onOpenChange:l,onOpenChangeComplete:c,handle:u,triggerId:f,defaultTriggerId:h=null,children:p}=e,y=nN.useStore(u==null?void 0:u.store,{open:r,openProp:i,activeTriggerId:h,triggerIdProp:f});Ihe(()=>{i===void 0&&y.state.open===!1&&r===!0&&y.update({open:!0,activeTriggerId:h})}),y.useControlledProp("openProp",i),y.useControlledProp("triggerIdProp",f),y.useContextCallback("onOpenChange",l),y.useContextCallback("onOpenChangeComplete",c);const v=y.useState("open"),$=!n&&v,x=y.useState("activeTriggerId"),S=y.useState("payload");y.useSyncedValues({trackCursorAxis:o,disableHoverablePopup:a}),qt(()=>{v&&n&&y.setOpen(!1,or(G1e))},[v,n,y]),y.useSyncedValue("disabled",n),jhe(y);const{forceUnmount:b,transitionStatus:T}=Ehe($,y),w=y.useState("isInstantPhase"),P=y.useState("instantType"),k=y.useState("lastOpenChangeReason"),R=_.useRef(null);qt(()=>{T==="ending"&&k===Dq||T!=="ending"&&w?(P!=="delay"&&(R.current=P),y.set("instantType","delay")):R.current!==null&&(y.set("instantType",R.current),R.current=null)},[T,w,k,P,y]),qt(()=>{$&&x==null&&y.set("payload",void 0)},[y,x,$]);const E=_.useCallback(()=>{y.setOpen(!1,Xht(y,cie))},[y]);_.useImperativeHandle(s,()=>({unmount:b,close:E}),[b,E]);const C=y.useState("floatingRootContext"),z=ghe(C,{enabled:!n,referencePress:()=>y.select("closeOnClick")}),Y=Mit(C,{enabled:!n&&o!=="none",axis:o==="none"?void 0:o}),{getReferenceProps:W,getFloatingProps:A,getTriggerProps:q}=YU([z,Y]),N=_.useMemo(()=>W(),[W]),Z=_.useMemo(()=>q(),[q]),D=_.useMemo(()=>A(),[A]);return y.useSyncedValues({activeTriggerProps:N,inactiveTriggerProps:Z,popupProps:D}),m.jsx(Jpe.Provider,{value:y,children:typeof p=="function"?p({payload:S}):p})});function Xht(t,e){const n=or(e);return n.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},n}const eme=_.createContext(void 0);function Rht(){return _.useContext(eme)}let jht=(function(t){return t[t.popupOpen=che.popupOpen]="popupOpen",t.triggerDisabled="data-trigger-disabled",t})({});const Eht=600,Cht=Kat(function(e,n){const{className:r,render:i,handle:a,payload:o,disabled:s,delay:l,closeOnClick:c=!0,closeDelay:u,id:f,...h}=e,p=Lv(!0),y=(a==null?void 0:a.store)??p;if(!y)throw new Error(_s(82));const v=fv(f),$=y.useState("isTriggerActive",v),x=y.useState("isOpenedByTrigger",v),S=y.useState("floatingRootContext"),b=_.useRef(null),T=l??Eht,w=u??0,{registerTrigger:P,isMountedByThisTrigger:k}=Rhe(v,b,y,{payload:o,closeOnClick:c,closeDelay:w}),R=Rht(),{delayRef:E,isInstantPhase:C,hasProvider:z}=Pit(S,{open:x});y.useSyncedValue("isInstantPhase",C);const Y=y.useState("disabled"),W=s??Y,A=y.useState("trackCursorAxis"),q=y.useState("disableHoverablePopup"),N=got(S,{enabled:!W,mouseOnly:!0,move:!1,handleClose:!q&&A!=="both"?Qot():null,restMs(){const I=R==null?void 0:R.delay,B=typeof E.current=="object"?E.current.open:void 0;let L=T;return z&&(B!==0?L=l??I??T:L=0),L},delay(){const I=typeof E.current=="object"?E.current.close:void 0;let B=w;return u==null&&z&&(B=I),{close:B}},triggerElementRef:b,isActiveTrigger:$}),Z=Oot(S,{enabled:!W}).reference,D={open:x},M=y.useState("triggerProps",k);return ha("button",e,{state:D,ref:[n,P,b],props:[N,Z,M,{onPointerDown(){y.set("closeOnClick",c)},id:v,[jht.triggerDisabled]:W?"":void 0},h],stateAttributesMapping:uhe})}),tme=_.createContext(void 0);function zht(){const t=_.useContext(tme);if(t===void 0)throw new Error(_s(70));return t}const Yht=_.forwardRef(function(e,n){const{children:r,container:i,className:a,render:o,...s}=e,{portalNode:l,portalSubtree:c}=mhe({container:i,ref:n,componentProps:e,elementProps:s});return!c&&!l?null:m.jsxs(_.Fragment,{children:[c,l&&Pl.createPortal(r,l)]})}),Aht=_.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e;return Lv().useState("mounted")||r?m.jsx(tme.Provider,{value:r,children:m.jsx(Yht,{ref:n,...i})}):null}),nme=_.createContext(void 0);function rme(){const t=_.useContext(nme);if(t===void 0)throw new Error(_s(71));return t}const qht=_.createContext(void 0);function Zht(){const t=_.useContext(qht);return(t==null?void 0:t.direction)??"ltr"}const Vht=t=>({name:"arrow",options:t,async fn(e){var M,V;const{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:l}=e,{element:c,padding:u=0,offsetParent:f="real"}=Yc(t,e)||{};if(c==null)return{};const h=Fre(u),p={x:n,y:r},y=Nq(i),v=Uq(y),$=await o.getDimensions(c),x=y==="y",S=x?"top":"left",b=x?"bottom":"right",T=x?"clientHeight":"clientWidth",w=a.reference[v]+a.reference[y]-p[y]-a.floating[v],P=p[y]-a.reference[y],k=f==="real"?await((M=o.getOffsetParent)==null?void 0:M.call(o,c)):s.floating;let R=s.floating[T]||a.floating[v];(!R||!await((V=o.isElement)==null?void 0:V.call(o,k)))&&(R=s.floating[T]||a.floating[v]);const E=w/2-P/2,C=R/2-$[v]/2-1,z=Math.min(h[S],C),Y=Math.min(h[b],C),W=z,A=R-$[v]-Y,q=R/2-$[v]/2+E,N=FC(W,q,A),Z=!l.arrow&&hO(i)!=null&&q!==N&&a.reference[v]/2-(q<W?z:Y)-$[v]/2<0,D=Z?q<W?q-W:q-A:0;return{[y]:p[y]+D,data:{[y]:N,centerOffset:q-N-D,...Z&&{alignmentOffset:D}},reset:Z}}}),Uht=(t,e)=>({...Vht(t),options:[t,e]}),Nht={name:"hide",async fn(t){var s;const{width:e,height:n,x:r,y:i}=t.rects.reference,a=e===0&&n===0&&r===0&&i===0;return{data:{referenceHidden:((s=(await Cat().fn(t)).data)==null?void 0:s.referenceHidden)||a}}}},Hb={sideX:"left",sideY:"top"},Wht={name:"adaptiveOrigin",async fn(t){var S,b;const{x:e,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=t,l=ai(i),c=l.getComputedStyle(i);if(!(c.transitionDuration!=="0s"&&c.transitionDuration!==""))return{x:e,y:n,data:Hb};const f=await((S=a.getOffsetParent)==null?void 0:S.call(a,i));let h={width:0,height:0};if(o==="fixed"&&(l!=null&&l.visualViewport))h={width:l.visualViewport.width,height:l.visualViewport.height};else if(f===l){const T=dr(i);h={width:T.documentElement.clientWidth,height:T.documentElement.clientHeight}}else await((b=a.isElement)==null?void 0:b.call(a,f))&&(h=await a.getDimensions(f));const p=Ca(s);let y=e,v=n;p==="left"&&(y=h.width-(e+r.width)),p==="top"&&(v=h.height-(n+r.height));const $=p==="left"?"right":Hb.sideX,x=p==="top"?"bottom":Hb.sideY;return{x:y,y:v,data:{sideX:$,sideY:x}}}};function ime(t,e,n){const r=t==="inline-start"||t==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[e]}function Ite(t,e,n){const{rects:r,placement:i}=t;return{side:ime(e,Ca(i),n),align:hO(i)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Mht(t){var ui,gr;const{anchor:e,positionMethod:n="absolute",side:r="bottom",sideOffset:i=0,align:a="center",alignOffset:o=0,collisionBoundary:s,collisionPadding:l=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:f=!1,keepMounted:h=!1,floatingRootContext:p,mounted:y,collisionAvoidance:v,shiftCrossAxis:$=!1,nodeId:x,adaptiveOrigin:S,lazyFlip:b=!1,externalTree:T}=t,[w,P]=_.useState(null);!y&&w!==null&&P(null);const k=v.side||"flip",R=v.align||"flip",E=v.fallbackAxisSide||"end",C=typeof e=="function"?e:void 0,z=tn(C),Y=C?z:e,W=Ol(e),q=Zht()==="rtl",N=w||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":q?"left":"right","inline-start":q?"right":"left"}[r],Z=a==="center"?N:`${N}-${a}`;let D=l;const M=1,V=r==="bottom"?M:0,I=r==="top"?M:0,B=r==="right"?M:0,L=r==="left"?M:0;typeof D=="number"?D={top:D+V,right:D+L,bottom:D+I,left:D+B}:D&&(D={top:(D.top||0)+V,right:(D.right||0)+L,bottom:(D.bottom||0)+I,left:(D.left||0)+B});const J={boundary:s==="clipping-ancestors"?"clippingAncestors":s,padding:D},K=_.useRef(null),H=Ol(i),re=Ol(o),ie=[_at(Tt=>{const _t=Ite(Tt,r,q),Er=typeof H.current=="function"?H.current(_t):H.current,lr=typeof re.current=="function"?re.current(_t):re.current;return{mainAxis:Er,crossAxis:lr,alignmentAxis:lr}},[typeof i!="function"?i:0,typeof o!="function"?o:0,q,r])],se=R==="none"&&k!=="shift",ae=!se&&(c||$||k==="shift"),ue=k==="none"?null:jat({...J,padding:{top:D.top+M,right:D.right+M,bottom:D.bottom+M,left:D.left+M},mainAxis:!$&&k==="flip",crossAxis:R==="flip"?"alignment":!1,fallbackAxisSideDirection:E}),Oe=se?null:Xat(Tt=>{const _t=dr(Tt.elements.floating).documentElement;return{...J,rootBoundary:$?{x:0,y:0,width:_t.clientWidth,height:_t.clientHeight}:void 0,mainAxis:R!=="none",crossAxis:ae,limiter:c||$?void 0:Rat(Er=>{if(!K.current)return{};const{width:lr,height:yr}=K.current.getBoundingClientRect(),et=zo(Ca(Er.placement)),Dt=et==="y"?lr:yr,Cn=et==="y"?D.left+D.right:D.top+D.bottom;return{offset:Dt/2+Cn/2}})}},[J,c,$,D,R]);k==="shift"||R==="shift"||a==="center"?ie.push(Oe,ue):ie.push(ue,Oe),ie.push(Eat({...J,apply({elements:{floating:Tt},availableWidth:_t,availableHeight:Er,rects:lr}){const yr=Tt.style;yr.setProperty("--available-width",`${_t}px`),yr.setProperty("--available-height",`${Er}px`);const et=window.devicePixelRatio||1,{x:Dt,y:Cn,width:Vn,height:cr}=lr.reference,dn=(Math.round((Dt+Vn)*et)-Math.round(Dt*et))/et,_n=(Math.round((Cn+cr)*et)-Math.round(Cn*et))/et;yr.setProperty("--anchor-width",`${dn}px`),yr.setProperty("--anchor-height",`${_n}px`)}}),Uht(()=>({element:K.current||document.createElement("div"),padding:u,offsetParent:"floating"}),[u]),{name:"transformOrigin",fn(Tt){var er,fi,$a;const{elements:_t,middlewareData:Er,placement:lr,rects:yr,y:et}=Tt,Dt=Ca(lr),Cn=zo(Dt),Vn=K.current,cr=((er=Er.arrow)==null?void 0:er.x)||0,dn=((fi=Er.arrow)==null?void 0:fi.y)||0,_n=(Vn==null?void 0:Vn.clientWidth)||0,Va=(Vn==null?void 0:Vn.clientHeight)||0,Ht=cr+_n/2,Mr=dn+Va/2,vo=Math.abs((($a=Er.shift)==null?void 0:$a.y)||0),$r=yr.reference.height/2,Ua=typeof i=="function"?i(Ite(Tt,r,q)):i,Cl=vo>Ua,Oi={top:`${Ht}px calc(100% + ${Ua}px)`,bottom:`${Ht}px ${-Ua}px`,left:`calc(100% + ${Ua}px) ${Mr}px`,right:`${-Ua}px ${Mr}px`}[Dt],_r=`${Ht}px ${yr.reference.y+$r-et}px`;return _t.floating.style.setProperty("--transform-origin",ae&&Cn==="y"&&Cl?_r:Oi),{}}},Nht,S),qt(()=>{!y&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[y,p]);const de=_.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<"u",layoutShift:!f&&typeof IntersectionObserver<"u"}),[f]),{refs:xe,elements:Qe,x:Re,y:Le,middlewareData:Ne,update:ve,placement:Se,context:ke,isPositioned:we,floatingStyles:Ge}=uot({rootContext:p,placement:Z,middleware:ie,strategy:n,whileElementsMounted:h?void 0:(...Tt)=>Aee(...Tt,de),nodeId:x,externalTree:T}),{sideX:ce,sideY:$e}=Ne.adaptiveOrigin||Hb,Ee=we?n:"fixed",De=_.useMemo(()=>{const Tt=S?{position:Ee,[ce]:Re,[$e]:Le}:{position:Ee,...Ge};return we||(Tt.opacity=0),Tt},[S,Ee,ce,Re,$e,Le,Ge,we]),He=_.useRef(null);qt(()=>{if(!y)return;const Tt=W.current,_t=typeof Tt=="function"?Tt():Tt,lr=(Dte(_t)?_t.current:_t)||null||null;lr!==He.current&&(xe.setPositionReference(lr),He.current=lr)},[y,xe,Y,W]),_.useEffect(()=>{if(!y)return;const Tt=W.current;typeof Tt!="function"&&Dte(Tt)&&Tt.current!==He.current&&(xe.setPositionReference(Tt.current),He.current=Tt.current)},[y,xe,Y,W]),_.useEffect(()=>{if(h&&y&&Qe.domReference&&Qe.floating)return Aee(Qe.domReference,Qe.floating,ve,de)},[h,y,Qe,ve,de]);const at=Ca(Se),wt=ime(r,at,q),jt=hO(Se)||"center",Pt=!!((ui=Ne.hide)!=null&&ui.referenceHidden);qt(()=>{b&&y&&we&&P(at)},[b,y,we,at]);const kn=_.useMemo(()=>{var Tt,_t;return{position:"absolute",top:(Tt=Ne.arrow)==null?void 0:Tt.y,left:(_t=Ne.arrow)==null?void 0:_t.x}},[Ne.arrow]),It=((gr=Ne.arrow)==null?void 0:gr.centerOffset)!==0;return _.useMemo(()=>({positionerStyles:De,arrowStyles:kn,arrowRef:K,arrowUncentered:It,side:wt,align:jt,physicalSide:at,anchorHidden:Pt,refs:xe,context:ke,isPositioned:we,update:ve}),[De,kn,K,It,wt,jt,at,Pt,xe,ke,we,ve])}function Dte(t){return t!=null&&"current"in t}function ame(t){return t==="starting"?kxe:Ii}const Iht=_.forwardRef(function(e,n){const{render:r,className:i,anchor:a,positionMethod:o="absolute",side:s="top",align:l="center",sideOffset:c=0,alignOffset:u=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:p=5,sticky:y=!1,disableAnchorTracking:v=!1,collisionAvoidance:$=_xe,...x}=e,S=Lv(),b=zht(),T=S.useState("open"),w=S.useState("mounted"),P=S.useState("trackCursorAxis"),k=S.useState("disableHoverablePopup"),R=S.useState("floatingRootContext"),E=S.useState("instantType"),C=S.useState("transitionStatus"),z=S.useState("hasViewport"),Y=Mht({anchor:a,positionMethod:o,floatingRootContext:R,mounted:w,side:s,sideOffset:c,align:l,alignOffset:u,collisionBoundary:f,collisionPadding:h,sticky:y,arrowPadding:p,disableAnchorTracking:v,keepMounted:b,collisionAvoidance:$,adaptiveOrigin:z?Wht:void 0}),W=_.useMemo(()=>{const Z={};return(!T||P==="both"||k)&&(Z.pointerEvents="none"),{role:"presentation",hidden:!w,style:{...Y.positionerStyles,...Z}}},[T,P,k,w,Y.positionerStyles]),A=_.useMemo(()=>({open:T,side:Y.side,align:Y.align,anchorHidden:Y.anchorHidden,instant:P!=="none"?"tracking-cursor":E}),[T,Y.side,Y.align,Y.anchorHidden,P,E]),q=_.useMemo(()=>({...A,arrowRef:Y.arrowRef,arrowStyles:Y.arrowStyles,arrowUncentered:Y.arrowUncentered}),[A,Y.arrowRef,Y.arrowStyles,Y.arrowUncentered]),N=ha("div",e,{state:A,props:[W,ame(C),x],ref:[n,S.useStateSetter("positionerElement")],stateAttributesMapping:Nv});return m.jsx(nme.Provider,{value:q,children:N})}),Dht={...Nv,...Mq},Lht=_.forwardRef(function(e,n){const{className:r,render:i,...a}=e,o=Lv(),{side:s,align:l}=rme(),c=o.useState("open"),u=o.useState("instantType"),f=o.useState("transitionStatus"),h=o.useState("popupProps"),p=o.useState("floatingRootContext");Iq({open:c,ref:o.context.popupRef,onComplete(){var S,b;c&&((b=(S=o.context).onOpenChangeComplete)==null||b.call(S,!0))}});const y=o.useState("disabled"),v=o.useState("closeDelay");return pot(p,{enabled:!y,closeDelay:v}),ha("div",e,{state:{open:c,side:s,align:l,instant:u,transitionStatus:f},ref:[n,o.context.popupRef,o.useStateSetter("popupElement")],props:[h,ame(f),a],stateAttributesMapping:Dht})}),Ght=_.forwardRef(function(e,n){const{className:r,render:i,...a}=e,s=Lv().useState("instantType"),{open:l,arrowRef:c,side:u,align:f,arrowUncentered:h,arrowStyles:p}=rme();return ha("div",e,{state:{open:l,side:u,align:f,uncentered:h,instant:s},ref:[n,c],props:[{style:p,"aria-hidden":!0},a],stateAttributesMapping:Nv})}),Bht=function(e){const{delay:n,closeDelay:r,timeout:i=400}=e,a=_.useMemo(()=>({delay:n,closeDelay:r}),[n,r]),o=_.useMemo(()=>({open:n,close:r}),[n,r]);return m.jsx(eme.Provider,{value:a,children:m.jsx(wit,{delay:o,timeoutMs:i,children:e.children})})};function Fht({delay:t=0,...e}){return m.jsx(Bht,{"data-slot":"tooltip-provider",delay:t,...e})}function Hht({...t}){return m.jsx(_ht,{"data-slot":"tooltip",...t})}function Kht({...t}){return m.jsx(Cht,{"data-slot":"tooltip-trigger",...t})}function Jht({className:t,side:e="top",sideOffset:n=4,align:r="center",alignOffset:i=0,children:a,...o}){return m.jsx(Aht,{children:m.jsx(Iht,{align:r,alignOffset:i,side:e,sideOffset:n,className:"isolate z-50",children:m.jsxs(Lht,{"data-slot":"tooltip-content",className:jr("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",t),...o,children:[a,m.jsx(Ght,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}function ept({conflictId:t,onClose:e}){var z;const{scan:n,busyConflictId:r,resolveConflict:i,revokeDecision:a,markSuperseded:o}=Mc(),s=n==null?void 0:n.openConflicts.find(Y=>Y.id===t),l=n==null?void 0:n.decidedConflicts.find(Y=>Y.conflict.id===t),c=s??(l==null?void 0:l.conflict),u=l==null?void 0:l.decision,f=!!u,h=!!((z=c==null?void 0:c.candidates[0])!=null&&z.claim.id.startsWith("version-chain:")),p=(u==null?void 0:u.resolution.kind)==="pick"?u.resolution.candidateIndex:(c==null?void 0:c.defaultPick)??0,[y,v]=_.useState(p);_.useEffect(()=>{v(p)},[c==null?void 0:c.id]),_.useEffect(()=>{n&&!c&&e&&e()},[n,c,e]);const[$,x]=_.useState(!1),[S,b]=_.useState("");if(_.useEffect(()=>{x(!1),b("")},[c==null?void 0:c.id]),!c)return m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-6 w-6"}),m.jsx("span",{children:"Conflict not found. It may have been resolved."})]});const T=r===c.id,w=c.candidates[y]??c.candidates[0],P=y===c.defaultPick,k=()=>i(c,{kind:"pick",candidateIndex:y}),R=()=>i(c,{kind:"custom",content:"merge-both"}),E=()=>i(c,{kind:"custom",content:S.trim()}),C=()=>a(c.id);return m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsx(tpt,{conflict:c,isVersionChain:h,decision:u,onClose:e}),m.jsxs("div",{className:"flex flex-1 min-h-0",children:[m.jsx(rpt,{conflict:c,selectedIndex:y,onSelect:v,isVersionChain:h}),m.jsx("div",{className:"flex flex-1 min-w-0 flex-col",children:m.jsxs("div",{className:"flex-1 overflow-auto px-5 py-3",children:[m.jsx(ipt,{candidate:w,conflict:c,isVersionChain:h,isDefault:P}),$&&m.jsxs("div",{className:"mt-4 rounded border border-dashed border-border p-3",children:[m.jsx("textarea",{value:S,onChange:Y=>b(Y.target.value),placeholder:"Enter the authoritative answer in your own words…",className:"w-full resize-none rounded border border-border bg-background p-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",rows:5}),m.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[m.jsx(xn,{size:"sm",variant:"ghost",onClick:()=>{x(!1),b("")},children:"Cancel"}),m.jsx(xn,{size:"sm",disabled:T||!S.trim(),onClick:E,children:"Save custom answer"})]})]})]})})]}),m.jsx(lpt,{conflict:c,selectedIndex:y,isVersionChain:h,isDefault:P,isDecided:f,busy:T,customMode:$,onPick:k,onMarkSuperseded:o,onKeepAll:R,onOpenCustom:()=>x(!0),onRevoke:C})]})}function tpt({conflict:t,isVersionChain:e,decision:n,onClose:r}){const i=e?t.subject.replace(/^version chain:\s*/,""):t.subject;return m.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border bg-card px-5 py-3",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e?m.jsx(bq,{className:"h-5 w-5 shrink-0 text-amber-400"}):m.jsx(Ju,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider ${e?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:e?"version chain":t.topic}),e&&m.jsx(npt,{conflict:t})]}),m.jsx("h2",{className:"truncate text-base font-semibold",children:i}),m.jsxs("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:[t.candidates.length," candidates"]}),n&&m.jsx("span",{className:"ml-2 shrink-0 rounded bg-emerald-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-emerald-700 dark:text-emerald-300",title:`Decided ${new Date(n.resolvedAt).toLocaleString()}`,children:"decided"})]}),r&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:r,title:"Close detail view",children:m.jsx(Rr,{className:"h-4 w-4"})})]})}function npt({conflict:t}){var r,i;const e=(i=(r=t.candidates[0])==null?void 0:r.claim.content)==null?void 0:i.detectedFrom,n=e==="filename"?"filenames follow a v1/v2 pattern":e==="llm"?"the LLM judged one doc to be a successor of the other based on content (no filename versioning was present)":"a versioning relationship was detected";return m.jsx(Fht,{delay:150,children:m.jsxs(Hht,{children:[m.jsx(Kht,{className:"inline-flex items-center justify-center rounded p-0.5 text-amber-700/80 hover:text-amber-900 dark:text-amber-300/80 dark:hover:text-amber-200 hover:bg-amber-500/10 transition-colors","aria-label":"About version chain conflicts",children:m.jsx(Vve,{className:"h-3.5 w-3.5"})}),m.jsx(Jht,{side:"bottom",align:"start",className:"max-w-sm whitespace-normal text-left leading-relaxed",children:m.jsxs("p",{children:["These docs describe overlapping specs and ",n,". Pick which doc is the current source of truth — claims from the others get dropped. Or keep all docs to merge them as independent sources."]})})]})})}function rpt({conflict:t,selectedIndex:e,onSelect:n,isVersionChain:r}){return m.jsxs("aside",{className:"flex w-60 shrink-0 flex-col gap-1 overflow-y-auto border-r border-border bg-card/40 p-2",children:[m.jsxs("div",{className:"px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:["Candidates · ",t.candidates.length]}),t.candidates.map((i,a)=>{const o=a===e,s=a===t.defaultPick,l=r?a===0?"older":a===t.candidates.length-1?"current":"middle":i.weight,c=i.claim.content,u=(c==null?void 0:c.file)??i.claim.provenance.file,f=u.split("/").pop()??u,h=u.includes("/")?u.slice(0,u.lastIndexOf("/")):"",p=r?(c==null?void 0:c.claimCount)!=null?`${c.claimCount} claims`:null:`:${i.claim.provenance.line}`,y=i.claim.metadata.docKind,v=i.claim.metadata.status,$=i.claim.kind;return m.jsxs("button",{type:"button",onClick:()=>n(a),title:u,className:`flex flex-col items-start gap-1 rounded border px-2.5 py-2 text-left text-xs transition-colors ${o?"border-primary bg-primary/10 text-foreground":"border-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground"}`,children:[m.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:f}),s&&m.jsx(Ff,{className:"h-3 w-3 shrink-0 text-primary","aria-label":"recommended"})]}),h&&m.jsxs("div",{className:"w-full truncate font-mono text-[10px] text-muted-foreground/70",children:[h,"/"]}),m.jsxs("div",{className:"flex w-full flex-wrap items-center gap-1 text-[10px]",children:[m.jsx("span",{className:"rounded bg-muted px-1 py-0.5 uppercase tracking-wider text-muted-foreground",children:l}),y&&y!=="unknown"&&m.jsx("span",{className:"rounded bg-muted px-1 py-0.5 uppercase tracking-wider text-muted-foreground",children:y}),v&&v!=="shipped"&&m.jsx("span",{className:`rounded px-1 py-0.5 uppercase tracking-wider ${v==="deferred"||v==="out-of-scope"||v==="deprecated"?"bg-amber-500/15 text-amber-700 dark:text-amber-300":"bg-muted text-muted-foreground"}`,title:`Lifecycle status: ${v}`,children:v}),$==="constraint"&&m.jsx("span",{className:"rounded bg-sky-500/15 px-1 py-0.5 uppercase tracking-wider text-sky-700 dark:text-sky-300",title:"This claim narrows the subject (e.g. adding 403 responses to existing endpoints) rather than defining it from scratch.",children:"constraint"}),p&&m.jsx("span",{className:"ml-auto text-muted-foreground",children:p})]})]},i.index)})]})}function ipt({candidate:t,conflict:e,isVersionChain:n,isDefault:r}){return n?m.jsx(apt,{candidate:t,conflict:e,isDefault:r}):m.jsx(opt,{candidate:t,conflict:e,isDefault:r})}function apt({candidate:t,conflict:e,isDefault:n}){const r=t.claim.content,i=(r==null?void 0:r.file)??t.claim.provenance.file,a=(r==null?void 0:r.claimCount)??0,o=(r==null?void 0:r.topics)??{},s=t.claim.metadata.lastTouched,l=t.claim.metadata.docKind,c=t.index===0?"older version":t.index===e.candidates.length-1?"current version":"middle version";return m.jsxs("div",{children:[m.jsx(sme,{file:i,role:c,docKind:l,isDefault:n,meta:m.jsxs(m.Fragment,{children:[m.jsxs("span",{children:[m.jsx("span",{className:"font-medium text-foreground",children:a})," claims extracted"]}),m.jsxs("span",{children:["Last touched ",m.jsx("span",{className:"text-foreground",children:upt(s)})]})]})}),Object.keys(o).length>0&&m.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:Object.entries(o).sort((u,f)=>f[1]-u[1]).map(([u,f])=>m.jsxs("span",{className:"rounded bg-muted/60 px-1.5 py-0.5 text-[11px] text-muted-foreground",children:[u," ",m.jsx("span",{className:"text-foreground",children:f})]},u))}),m.jsx(ome,{candidate:t,conflict:e}),e.explanation&&m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"What differs"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-foreground",children:e.explanation})]}),m.jsx(lme,{source:t.claim.provenance.quote})]})}function opt({candidate:t,conflict:e,isDefault:n}){return m.jsxs("div",{children:[m.jsx(sme,{file:`${t.claim.provenance.file}:${t.claim.provenance.line}`,role:t.weight,docKind:t.claim.metadata.docKind,isDefault:n}),n&&m.jsxs("div",{className:"mt-2 rounded border border-primary/30 bg-primary/5 px-3 py-1.5 text-xs text-muted-foreground",children:[m.jsx("span",{className:"font-medium text-primary",children:"Recommended by engine."})," ",spt(t,e)]}),m.jsx(ome,{candidate:t,conflict:e}),e.explanation&&m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"What differs"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-foreground",children:e.explanation})]}),m.jsx(lme,{source:t.claim.provenance.quote})]})}function spt(t,e){const n=[],r=t.claim.metadata.docKind,i=e.candidates.filter(u=>u.index!==t.index),a=new Set(i.map(u=>u.claim.metadata.docKind));if(r&&r!=="unknown"){const u=[...a].filter(f=>Lte(r)>Lte(f));u.length>0&&n.push(`higher-authority doc kind (${r} beats ${u.join(", ")})`)}const s=e.candidates.map(u=>u.claim.metadata.lastTouched).reduce((u,f)=>u>f?u:f);t.claim.metadata.lastTouched===s&&n.push("newest source");const l=dS(t.claim.content),c=Math.max(...e.candidates.map(u=>dS(u.claim.content)));return l===c&&l>0&&n.push("most structurally complete"),n.length>0?n.join(" · "):"no other candidate ranks higher"}function Lte(t){return t==="adr"||t==="rfc"?4:t==="prd"||t==="spec"?3:t==="design-note"||t==="runbook"?2:t==="readme"?1:0}function dS(t){if(t==null)return 0;if(typeof t!="object")return 1;if(Array.isArray(t))return t.reduce((n,r)=>n+dS(r),0);let e=0;for(const n of Object.values(t))e+=dS(n);return e}function ome({candidate:t,conflict:e}){const n=e.resolverVerdict;return!n||n.pick!==t.index?null:m.jsxs("div",{className:"mt-2 rounded border border-violet-500/30 bg-violet-500/5 px-3 py-1.5 text-xs text-muted-foreground",children:[m.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300",children:"Resolver suggests"}),m.jsx("span",{className:"ml-1.5 rounded bg-violet-500/15 px-1 py-0.5 text-[10px] uppercase tracking-wider text-violet-700 dark:text-violet-300",children:n.confidence}),m.jsxs("span",{className:"ml-1.5",children:["— ",n.reasoning]})]})}function sme({file:t,role:e,docKind:n,isDefault:r,meta:i}){return m.jsxs("div",{children:[m.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m.jsx("span",{className:"font-mono text-sm text-foreground",children:t}),m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:e}),n&&n!=="unknown"&&m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:n}),r&&m.jsx("span",{className:"rounded bg-primary/20 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-primary",children:"recommended"})]}),i&&m.jsx("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:i})]})}function lme({source:t}){return m.jsxs("div",{className:"mt-3",children:[m.jsx("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:"Doc preview"}),m.jsx("div",{className:"rounded border border-border bg-muted/30 p-3 text-sm leading-relaxed text-muted-foreground",children:m.jsx(cpt,{source:t})})]})}function lpt({conflict:t,selectedIndex:e,isVersionChain:n,isDefault:r,isDecided:i,busy:a,customMode:o,onPick:s,onKeepAll:l,onOpenCustom:c,onRevoke:u,onMarkSuperseded:f}){const[h,p]=_.useState(!1),y=t.candidates[e],v=(y==null?void 0:y.claim.provenance.file)??"",$=new Set([v]),x=[];if(y)for(const b of t.candidates){const T=b.claim.provenance.file;$.has(T)||($.add(T),x.push({file:T,weight:b.weight}))}const S=!n&&!i&&x.length>0;return m.jsxs("div",{className:"relative flex shrink-0 items-center gap-2 border-t border-border bg-card px-5 py-3",children:[i&&m.jsx(xn,{size:"sm",variant:"ghost",onClick:u,disabled:a,className:"text-destructive hover:text-destructive",title:"Revoke this decision — the conflict will re-open",children:"Revoke decision"}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n?m.jsx(xn,{size:"sm",variant:"outline",onClick:l,disabled:a,title:"Keep all docs — claims from every version flow through unfiltered",children:"Keep all docs"}):!o&&m.jsxs(m.Fragment,{children:[S&&m.jsx(tm,{side:"top",align:"end",width:"wide",content:m.jsxs(m.Fragment,{children:["Mark ",m.jsx("span",{className:"font-mono",children:v})," as an older version of one of the other docs in this conflict. Claims from this doc are dropped from the corpus and every conflict caused by the same supersession clears in one action."]}),children:m.jsx(xn,{size:"sm",variant:"outline",onClick:()=>p(b=>!b),disabled:a,children:"Mark superseded by →"})}),m.jsx(xn,{size:"sm",variant:"outline",onClick:c,disabled:a,children:"Write custom answer"})]}),m.jsxs(xn,{size:"sm",onClick:s,disabled:a,children:[a?m.jsx(yn,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):m.jsx(Ff,{className:"mr-2 h-3.5 w-3.5"}),i?n?"Use this version instead":"Change to this candidate":n?"Use this version":"Pick this candidate",!i&&r&&m.jsx("span",{className:"ml-1.5 text-[10px] opacity-70",children:"(recommended)"})]})]}),h&&S&&m.jsxs("div",{className:"absolute bottom-full right-6 mb-2 w-[min(28rem,90vw)] rounded border border-border bg-popover p-3 shadow-lg",children:[m.jsxs("div",{className:"mb-2 text-[11px] text-muted-foreground",children:["Mark ",m.jsx("span",{className:"font-mono text-foreground",children:v})," as superseded by:"]}),m.jsx("ul",{className:"flex flex-col gap-1",children:x.map(b=>m.jsx("li",{children:m.jsxs("button",{type:"button",disabled:a,onClick:async()=>{p(!1),await f(v,b.file)},className:"flex w-full items-center justify-between gap-2 rounded border border-border bg-background px-2 py-1.5 text-left text-xs hover:border-primary hover:bg-primary/5",children:[m.jsx("span",{className:"truncate font-mono",children:b.file}),m.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:b.weight})]})},b.file))}),m.jsx("div",{className:"mt-2 flex justify-end",children:m.jsx(xn,{size:"sm",variant:"ghost",onClick:()=>p(!1),disabled:a,children:"Cancel"})})]}),m.jsxs("span",{className:"sr-only",children:[t.candidates.length," candidates total"]})]})}function cpt({source:t}){return m.jsx(dft,{remarkPlugins:[Pht],components:{h1:({children:e})=>m.jsx("div",{className:"mb-1 text-sm font-semibold text-foreground",children:e}),h2:({children:e})=>m.jsx("div",{className:"mb-1 text-sm font-semibold text-foreground",children:e}),h3:({children:e})=>m.jsx("div",{className:"mb-1 text-xs font-semibold text-foreground",children:e}),h4:({children:e})=>m.jsx("div",{className:"mb-1 text-xs font-semibold text-foreground",children:e}),p:({children:e})=>m.jsx("p",{className:"mb-1 last:mb-0",children:e}),ul:({children:e})=>m.jsx("ul",{className:"mb-1 list-disc pl-4 last:mb-0",children:e}),ol:({children:e})=>m.jsx("ol",{className:"mb-1 list-decimal pl-4 last:mb-0",children:e}),li:({children:e})=>m.jsx("li",{className:"mb-0.5",children:e}),code:({children:e})=>m.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:e}),pre:({children:e})=>m.jsx("pre",{className:"my-1 overflow-auto rounded bg-muted p-2 font-mono text-[11px] text-foreground",children:e}),strong:({children:e})=>m.jsx("strong",{className:"font-semibold text-foreground",children:e}),em:({children:e})=>m.jsx("em",{className:"italic",children:e}),a:({children:e,href:n})=>m.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:e}),blockquote:({children:e})=>m.jsx("blockquote",{className:"my-1 border-l-2 border-border pl-2 italic",children:e}),table:({children:e})=>m.jsx("div",{className:"my-1.5 overflow-x-auto",children:m.jsx("table",{className:"w-full border-collapse text-[11px]",children:e})}),thead:({children:e})=>m.jsx("thead",{className:"border-b border-border bg-muted/40",children:e}),tbody:({children:e})=>m.jsx("tbody",{children:e}),tr:({children:e})=>m.jsx("tr",{className:"border-b border-border/40 last:border-0",children:e}),th:({children:e})=>m.jsx("th",{className:"px-2 py-1 text-left font-semibold text-foreground",children:e}),td:({children:e})=>m.jsx("td",{className:"px-2 py-1 align-top",children:e})},children:t})}function upt(t){const e=new Date(t).getTime();if(Number.isNaN(e))return t;const n=Math.round((Date.now()-e)/1e3);if(n<5)return"just now";if(n<60)return`${n}s ago`;const r=Math.round(n/60);if(r<60)return`${r} min${r===1?"":"s"} ago`;const i=Math.round(r/60);if(i<24)return`${i} hour${i===1?"":"s"} ago`;const a=Math.round(i/24);return`${a} day${a===1?"":"s"} ago`}function Opt({repoId:t,filePath:e}){const[n,r]=_.useState(null),[i,a]=_.useState(!0),[o,s]=_.useState(null),{canonicalVersion:l}=Mc(),[c,u]=hpt(e);return _.useEffect(()=>{let f=!1;return a(!0),s(null),r(null),!c||!u?(s("Invalid section path."),a(!1),()=>{f=!0}):(d0e(t,c,u).then(h=>{f||r(h)}).catch(h=>{f||s(h.message)}).finally(()=>{f||a(!1)}),()=>{f=!0})},[t,c,u,l]),m.jsxs("div",{className:"flex h-full flex-col bg-background",children:[m.jsx(Rse,{filePath:e}),m.jsx("div",{className:"flex-1 overflow-auto px-6 py-4",children:i?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(yn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o?m.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-sm text-muted-foreground",children:[m.jsx(zi,{className:"h-5 w-5 text-destructive"}),m.jsx("span",{children:o})]}):n?m.jsx(fpt,{section:n}):null})]})}function fpt({section:t}){const e=t.manifest,n=typeof e.status=="string"?e.status:null,r=typeof e.description=="string"?e.description:null;return m.jsxs("div",{className:"text-sm text-foreground",children:[m.jsxs("h1",{className:"mb-2 text-xl font-bold",children:[t.module," — ",t.topic]}),m.jsxs("div",{className:"mb-4 text-xs text-muted-foreground",children:[n&&m.jsxs("span",{className:"mr-3",children:["status: ",n]}),m.jsxs("span",{children:[t.claims.length," claim",t.claims.length===1?"":"s"]})]}),r&&m.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:r}),t.claims.length===0?m.jsx("p",{className:"text-sm text-muted-foreground",children:"No claims in this section."}):t.claims.map(i=>m.jsx(dpt,{claim:i},i.id))]})}function dpt({claim:t}){return m.jsxs("div",{className:"mb-4 rounded border border-border bg-card/40 p-3",children:[m.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[m.jsx("span",{className:"font-mono text-sm font-semibold",children:t.subject}),t.metadata.status&&m.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.metadata.status}),t.kind==="constraint"&&m.jsx("span",{className:"rounded bg-sky-500/15 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-sky-600 dark:text-sky-300",children:"constraint"})]}),m.jsx("pre",{className:"my-2 overflow-auto rounded border border-border/60 bg-muted/30 p-2 font-mono text-[11px] text-foreground",children:JSON.stringify(t.content,null,2)}),m.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Source: ",m.jsxs("span",{className:"font-mono",children:[t.provenance.file,":",t.provenance.line]})]})]})}function hpt(t){const e=t.indexOf("/");return e===-1?[t,""]:[t.slice(0,e),t.slice(e+1)]}function ppt(t){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){i(!0),o(null);try{const l=await h0e(t);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load contracts")}finally{i(!1)}}},[t]);return _.useEffect(()=>{s()},[s]),{tree:e,isLoading:r,error:a,refetch:s}}function mpt(t){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(null),s=_.useCallback(async()=>{if(t){i(!0),o(null);try{const l=await f0e(t);n(l)}catch(l){o(l instanceof Error?l.message:"Failed to load canonical spec")}finally{i(!1)}}},[t]);return _.useEffect(()=>{s()},[s]),{tree:e,isLoading:r,error:a,refetch:s}}const wl=Object.create(null);wl.open="0";wl.close="1";wl.ping="2";wl.pong="3";wl.message="4";wl.upgrade="5";wl.noop="6";const Kb=Object.create(null);Object.keys(wl).forEach(t=>{Kb[wl[t]]=t});const lq={type:"error",data:"parser error"},cme=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ume=typeof ArrayBuffer=="function",Ome=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,rN=({type:t,data:e},n,r)=>cme&&e instanceof Blob?n?r(e):Gte(e,r):ume&&(e instanceof ArrayBuffer||Ome(e))?n?r(e):Gte(new Blob([e]),r):r(wl[t]+(e||"")),Gte=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function Bte(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let wC;function gpt(t,e){if(cme&&t.data instanceof Blob)return t.data.arrayBuffer().then(Bte).then(e);if(ume&&(t.data instanceof ArrayBuffer||Ome(t.data)))return e(Bte(t.data));rN(t,!1,n=>{wC||(wC=new TextEncoder),e(wC.encode(n))})}const Fte="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",oy=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Fte.length;t++)oy[Fte.charCodeAt(t)]=t;const ypt=t=>{let e=t.length*.75,n=t.length,r,i=0,a,o,s,l;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const c=new ArrayBuffer(e),u=new Uint8Array(c);for(r=0;r<n;r+=4)a=oy[t.charCodeAt(r)],o=oy[t.charCodeAt(r+1)],s=oy[t.charCodeAt(r+2)],l=oy[t.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|l&63;return c},$pt=typeof ArrayBuffer=="function",iN=(t,e)=>{if(typeof t!="string")return{type:"message",data:fme(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:vpt(t.substring(1),e)}:Kb[n]?t.length>1?{type:Kb[n],data:t.substring(1)}:{type:Kb[n]}:lq},vpt=(t,e)=>{if($pt){const n=ypt(t);return fme(n,e)}else return{base64:!0,data:t}},fme=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},dme="",xpt=(t,e)=>{const n=t.length,r=new Array(n);let i=0;t.forEach((a,o)=>{rN(a,!1,s=>{r[o]=s,++i===n&&e(r.join(dme))})})},Qpt=(t,e)=>{const n=t.split(dme),r=[];for(let i=0;i<n.length;i++){const a=iN(n[i],e);if(r.push(a),a.type==="error")break}return r};function bpt(){return new TransformStream({transform(t,e){gpt(t,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const a=new DataView(i.buffer);a.setUint8(0,126),a.setUint16(1,r)}else{i=new Uint8Array(9);const a=new DataView(i.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(n)})}})}let PC;function xb(t){return t.reduce((e,n)=>e+n.length,0)}function Qb(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let i=0;i<e;i++)n[i]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function Spt(t,e){PC||(PC=new TextDecoder);const n=[];let r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(xb(n)<1)break;const l=Qb(n,1);a=(l[0]&128)===128,i=l[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(xb(n)<2)break;const l=Qb(n,2);i=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(xb(n)<8)break;const l=Qb(n,8),c=new DataView(l.buffer,l.byteOffset,l.length),u=c.getUint32(0);if(u>Math.pow(2,21)-1){s.enqueue(lq);break}i=u*Math.pow(2,32)+c.getUint32(4),r=3}else{if(xb(n)<i)break;const l=Qb(n,i);s.enqueue(iN(a?l:PC.decode(l),e)),r=0}if(i===0||i>t){s.enqueue(lq);break}}}})}const hme=4;function ii(t){if(t)return wpt(t)}function wpt(t){for(var e in ii.prototype)t[e]=ii.prototype[e];return t}ii.prototype.on=ii.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};ii.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};ii.prototype.off=ii.prototype.removeListener=ii.prototype.removeAllListeners=ii.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===e||r.fn===e){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+t],this};ii.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,e)}return this};ii.prototype.emitReserved=ii.prototype.emit;ii.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};ii.prototype.hasListeners=function(t){return!!this.listeners(t).length};const sP=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Eo=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Ppt="arraybuffer";function pme(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const Tpt=Eo.setTimeout,kpt=Eo.clearTimeout;function lP(t,e){e.useNativeTimers?(t.setTimeoutFn=Tpt.bind(Eo),t.clearTimeoutFn=kpt.bind(Eo)):(t.setTimeoutFn=Eo.setTimeout.bind(Eo),t.clearTimeoutFn=Eo.clearTimeout.bind(Eo))}const _pt=1.33;function Xpt(t){return typeof t=="string"?Rpt(t):Math.ceil((t.byteLength||t.size)*_pt)}function Rpt(t){let e=0,n=0;for(let r=0,i=t.length;r<i;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function mme(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function jpt(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function Ept(t){let e={},n=t.split("&");for(let r=0,i=n.length;r<i;r++){let a=n[r].split("=");e[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return e}class Cpt extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class aN extends ii{constructor(e){super(),this.writable=!1,lP(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new Cpt(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=iN(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=jpt(e);return n.length?"?"+n:""}}class zpt extends aN{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Qpt(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,xpt(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=mme()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let gme=!1;try{gme=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ypt=gme;function Apt(){}class qpt extends zpt{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(i,a)=>{this.onError("xhr post error",i,a)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}class vl extends ii{constructor(e,n,r){super(),this.createRequest=e,lP(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=pme(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=vl.requestsCount++,vl.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Apt,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete vl.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}vl.requestsCount=0;vl.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Hte);else if(typeof addEventListener=="function"){const t="onpagehide"in Eo?"pagehide":"unload";addEventListener(t,Hte,!1)}}function Hte(){for(let t in vl.requests)vl.requests.hasOwnProperty(t)&&vl.requests[t].abort()}const Zpt=(function(){const t=yme({xdomain:!1});return t&&t.responseType!==null})();class Vpt extends qpt{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=Zpt&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new vl(yme,this.uri(),e)}}function yme(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Ypt))return new XMLHttpRequest}catch{}if(!e)try{return new Eo[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const $me=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Upt extends aN{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=$me?{}:pme(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;rN(r,this.supportsBinary,a=>{try{this.doWrite(r,a)}catch{}i&&sP(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=mme()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const TC=Eo.WebSocket||Eo.MozWebSocket;class Npt extends Upt{createSocket(e,n,r){return $me?new TC(e,n,r):n?new TC(e,n):new TC(e)}doWrite(e,n){this.ws.send(n)}}class Wpt extends aN{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=Spt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),i=bpt();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const a=()=>{r.read().then(({done:s,value:l})=>{s||(this.onPacket(l),a())}).catch(s=>{})};a();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],i=n===e.length-1;this._writer.write(r).then(()=>{i&&sP(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Mpt={websocket:Npt,webtransport:Wpt,polling:Vpt},Ipt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Dpt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function cq(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let i=Ipt.exec(t||""),a={},o=14;for(;o--;)a[Dpt[o]]=i[o]||"";return n!=-1&&r!=-1&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=Lpt(a,a.path),a.queryKey=Gpt(a,a.query),a}function Lpt(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Gpt(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,a){i&&(n[i]=a)}),n}const uq=typeof addEventListener=="function"&&typeof removeEventListener=="function",Jb=[];uq&&addEventListener("offline",()=>{Jb.forEach(t=>t())},!1);class Ku extends ii{constructor(e,n){if(super(),this.binaryType=Ppt,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=cq(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=cq(n.host).host);lP(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ept(this.opts.query)),uq&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Jb.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=hme,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Ku.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ku.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(n+=Xpt(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,sP(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const a={type:e,data:n,options:r};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(Ku.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),uq&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Jb.indexOf(this._offlineEventListener);r!==-1&&Jb.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ku.protocol=hme;class Bpt extends Ku{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;Ku.priorWebsocketSuccess=!1;const i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ku.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function a(){r||(r=!0,u(),n.close(),n=null)}const o=f=>{const h=new Error("probe error: "+f);h.transport=n.name,a(),this.emitReserved("upgradeError",h)};function s(){o("transport closed")}function l(){o("socket closed")}function c(f){n&&f.name!==n.name&&a()}const u=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",s),this.off("close",l),this.off("upgrading",c)};n.once("open",i),n.once("error",o),n.once("close",s),this.once("close",l),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let Fpt=class extends Bpt{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>Mpt[i]).filter(i=>!!i)),super(e,r)}};function Hpt(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=cq(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const a=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+a+":"+r.port+e,r.href=r.protocol+"://"+a+(n&&n.port===r.port?"":":"+r.port),r}const Kpt=typeof ArrayBuffer=="function",Jpt=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,vme=Object.prototype.toString,emt=typeof Blob=="function"||typeof Blob<"u"&&vme.call(Blob)==="[object BlobConstructor]",tmt=typeof File=="function"||typeof File<"u"&&vme.call(File)==="[object FileConstructor]";function oN(t){return Kpt&&(t instanceof ArrayBuffer||Jpt(t))||emt&&t instanceof Blob||tmt&&t instanceof File}function e0(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(e0(t[n]))return!0;return!1}if(oN(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return e0(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e0(t[n]))return!0;return!1}function nmt(t){const e=[],n=t.data,r=t;return r.data=Oq(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Oq(t,e){if(!t)return t;if(oN(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Oq(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Oq(t[r],e));return n}return t}function rmt(t,e){return t.data=fq(t.data,e),delete t.attachments,t}function fq(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=fq(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=fq(t[n],e));return t}const imt=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var cn;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(cn||(cn={}));class amt{constructor(e){this.replacer=e}encode(e){return(e.type===cn.EVENT||e.type===cn.ACK)&&e0(e)?this.encodeAsBinary({type:e.type===cn.EVENT?cn.BINARY_EVENT:cn.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===cn.BINARY_EVENT||e.type===cn.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=nmt(e),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}}class sN extends ii{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===cn.BINARY_EVENT;r||n.type===cn.BINARY_ACK?(n.type=r?cn.EVENT:cn.ACK,this.reconstructor=new omt(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(oN(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(cn[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===cn.BINARY_EVENT||r.type===cn.BINARY_ACK){const a=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(a,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");const s=Number(o);if(!smt(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");r.attachments=s}if(e.charAt(n+1)==="/"){const a=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(a,n)}else r.nsp="/";const i=e.charAt(n+1);if(i!==""&&Number(i)==i){const a=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}r.id=Number(e.substring(a,n+1))}if(e.charAt(++n)){const a=this.tryParse(e.substr(n));if(sN.isPayloadValid(r.type,a))r.data=a;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case cn.CONNECT:return Kte(n);case cn.DISCONNECT:return n===void 0;case cn.CONNECT_ERROR:return typeof n=="string"||Kte(n);case cn.EVENT:case cn.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&imt.indexOf(n[0])===-1);case cn.ACK:case cn.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class omt{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=rmt(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const smt=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};function Kte(t){return Object.prototype.toString.call(t)==="[object Object]"}const lmt=Object.freeze(Object.defineProperty({__proto__:null,Decoder:sN,Encoder:amt,get PacketType(){return cn}},Symbol.toStringTag,{value:"Module"}));function cs(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const cmt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class xme extends ii{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[cs(e,"open",this.onopen.bind(this)),cs(e,"packet",this.onpacket.bind(this)),cs(e,"error",this.onerror.bind(this)),cs(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,i,a;if(cmt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:cn.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const u=this.ids++,f=n.pop();this._registerAckCallback(u,f),o.id=u}const s=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,l=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,n){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[e]=n;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===e&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},i),o=(...s)=>{this.io.clearTimeoutFn(a),n.apply(this,s)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...n){return new Promise((r,i)=>{const a=(o,s)=>o?i(o):r(s);a.withError=!0,n.push(a),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...a)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...a)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:cn.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case cn.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case cn.EVENT:case cn.BINARY_EVENT:this.onevent(e);break;case cn.ACK:case cn.BINARY_ACK:this.onack(e);break;case cn.DISCONNECT:this.ondisconnect();break;case cn.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...i){r||(r=!0,n.packet({type:cn.ACK,id:e,data:i}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:cn.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function Tm(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Tm.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Tm.prototype.reset=function(){this.attempts=0};Tm.prototype.setMin=function(t){this.ms=t};Tm.prototype.setMax=function(t){this.max=t};Tm.prototype.setJitter=function(t){this.jitter=t};class dq extends ii{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,lP(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Tm({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const i=n.parser||lmt;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Fpt(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=cs(n,"open",function(){r.onopen(),e&&e()}),a=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),e?e(s):this.maybeReconnectOnOpen()},o=cs(n,"error",a);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{i(),a(new Error("timeout")),n.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(cs(e,"ping",this.onping.bind(this)),cs(e,"data",this.ondata.bind(this)),cs(e,"error",this.onerror.bind(this)),cs(e,"close",this.onclose.bind(this)),cs(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){sP(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new xme(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Gg={};function t0(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=Hpt(t,e.path||"/socket.io"),r=n.source,i=n.id,a=n.path,o=Gg[i]&&a in Gg[i].nsps,s=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let l;return s?l=new dq(r,e):(Gg[i]||(Gg[i]=new dq(r,e)),l=Gg[i]),n.query&&!e.query&&(e.query=n.queryKey),l.socket(n.path,e)}Object.assign(t0,{Manager:dq,Socket:xme,io:t0,connect:t0});const umt=ly()||(typeof window<"u"?window.location.origin:"");let Pf=null;function lN(){return Pf||(Pf=t0(umt,{autoConnect:!1,reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,reconnectionDelayMax:5e3,transports:["websocket","polling"]})),Pf}function kC(){const t=lN();return t.connected||t.connect(),t}function Omt(){Pf!=null&&Pf.connected&&Pf.disconnect()}function Jte(t){const e=lN();e.connected&&e.emit("joinRepo",t)}function fmt(t){const e=lN();e.connected&&e.emit("leaveRepo",t)}function dmt(t){const[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),[s,l]=_.useState(null),[c,u]=_.useState(null),f=_.useRef(new Map);_.useEffect(()=>{const x=kC();function S(){n(!0),t&&Jte(t)}function b(){n(!1)}function T(R){if(R.step==="error"){i({...R,step:"error"});return}R.percent>=100?i(null):i(R)}function w(R){var E;i(null),(E=f.current.get("analysis:complete"))==null||E.forEach(C=>C(R))}function P(R){if(R.step==="error"){o({...R,step:"error"});return}R.percent>=100?o(null):o(R)}function k(R){var E;o(null),(E=f.current.get("spec:complete"))==null||E.forEach(C=>C(R))}return x.on("connect",S),x.on("disconnect",b),x.on("analysis:progress",T),x.on("analysis:complete",w),x.on("spec:progress",P),x.on("spec:complete",k),x.on("files:changed",R=>{var E;(E=f.current.get("files:changed"))==null||E.forEach(C=>C(R))}),x.on("violations:ready",R=>{var E;i(null),(E=f.current.get("violations:ready"))==null||E.forEach(C=>C(R))}),x.on("analysis:canceled",R=>{var E;i(null),l(null),u(null),(E=f.current.get("analysis:canceled"))==null||E.forEach(C=>C(R))}),x.on("analysis:llm-estimate",R=>{l(R)}),x.on("analysis:llm-resolved",()=>{l(null)}),x.on("analysis:stash-confirm-request",R=>{u(R)}),x.connected&&t&&Jte(t),()=>{t&&fmt(t),x.off("connect",S),x.off("disconnect",b),x.off("analysis:progress",T),x.off("analysis:complete",w),x.off("spec:progress",P),x.off("spec:complete",k),Omt()}},[t]);const h=_.useCallback((x,S)=>{const b=f.current.get(x)||[];return b.push(S),f.current.set(x,b),()=>{const T=f.current.get(x)||[];f.current.set(x,T.filter(w=>w!==S))}},[]),p=_.useCallback(()=>i(null),[]),y=_.useCallback(()=>o(null),[]),v=_.useCallback((x,S)=>{kC().emit("analysis:llm-proceed",{repoId:x,proceed:S}),l(null)},[]),$=_.useCallback((x,S)=>{kC().emit("analysis:stash-confirm-response",{repoId:x,choice:S}),u(null)},[]);return{isConnected:e,analysisProgress:r,specProgress:a,clearProgress:p,clearSpecProgress:y,onEvent:h,llmEstimate:s,respondToLlmEstimate:v,stashConfirm:c,respondToStashConfirm:$}}function hmt(t,e,n,r={}){const{enabled:i=!0}=r,[a,o]=_.useState([]),[s,l]=_.useState(!0),[c,u]=_.useState(null),f=_.useCallback(async()=>{if(!(!t||!i)){l(!0),u(null);try{const p=await xre(t,n);o(p)}catch(p){u(p instanceof Error?p.message:"Failed to fetch violations")}finally{l(!1)}}},[t,n,i]);return _.useEffect(()=>{f()},[f]),{violations:_.useMemo(()=>{const p={critical:0,high:1,medium:2,low:3,info:4};return[...a].sort((v,$)=>{const x=(p[v.severity]??5)-(p[$.severity]??5);return x!==0?x:new Date($.createdAt).getTime()-new Date(v.createdAt).getTime()})},[a,e]),allViolations:a,isLoading:s,error:c,refetch:f}}function pmt(t,e){const[n,r]=_.useState(null),[i,a]=_.useState(!1),[o,s]=_.useState(null),l=_.useCallback(async()=>{if(!e){s("Socket event stream not available; cannot run diff check.");return}a(!0),s(null),r(null);const f=[],h=new Promise((p,y)=>{f.push(e("analysis:complete",v=>{v.repoId===t&&p("completed")})),f.push(e("analysis:canceled",v=>{v.repoId===t&&p("canceled")})),f.push(e("analysis:progress",v=>{const $=v;$.repoId===t&&$.step==="error"&&y(new Error($.detail??"Diff check failed"))}))});try{if(await t0e(t),await h==="canceled")s("Diff check cancelled"),r(null);else{const y=await X8(t);r(y)}}catch(p){p instanceof em&&p.status===400?s("Switch to Normal mode and run an analysis first"):s(p instanceof Error?p.message:"Diff check failed"),r(null)}finally{f.forEach(p=>p()),a(!1)}},[t,e]),c=_.useCallback(async()=>{s(null);try{const f=await X8(t);r(f)}catch(f){s(f instanceof Error?f.message:"Failed to load diff check"),r(null)}},[t]),u=_.useCallback(()=>{r(null),s(null)},[]);return{diffResult:n,isChecking:i,error:o,run:l,load:c,clear:u}}function mmt(t){const[e,n]=_.useState([]),[r,i]=_.useState(!0),a=_.useCallback(async()=>{if(t){i(!0);try{const o=await Ibe(t);n(o)}catch{}finally{i(!1)}}},[t]);return _.useEffect(()=>{a()},[a]),{analyses:e,isLoading:r,refetch:a}}function gmt(t,e,n={}){const{enabled:r=!0}=n,[i,a]=_.useState(null),[o,s]=_.useState(!1),l=_.useCallback(async()=>{if(!(!t||!r)){s(!0);try{const c=await bre(t,e);a(c)}catch{a(null)}finally{s(!1)}}},[t,e,r]);return _.useEffect(()=>{l()},[l]),{summary:i,isLoading:o,refetch:l}}function ymt(t,e={}){const{enabled:n=!0,analysisId:r}=e,[i,a]=_.useState([]),[o,s]=_.useState({}),[l,c]=_.useState(!0),[u,f]=_.useState(null),h=_.useCallback(async()=>{if(t){if(!n){c(!1);return}c(!0),f(null);try{const p=await i0e(t,r);a(p.flows),s(p.severities)}catch(p){f(p instanceof Error?p.message:"Failed to fetch flows")}finally{c(!1)}}},[t,n,r]);return _.useEffect(()=>{h()},[h]),{flows:i,severities:o,isLoading:l,error:u,refetch:h}}function $mt(){return m.jsx(iSe,{children:m.jsx(aSe,{children:m.jsx(sSe,{children:m.jsx(cSe,{children:m.jsx(OSe,{children:m.jsx(vmt,{})})})})})})}function vmt(){var Kv,Jv,kd,ex;const{repoId:t=""}=Bye(),{section:e,leftTab:n,setSection:r,setLeftTab:i}=Oie(),{selectedService:a,setSelectedService:o,depthLevel:s,setDepthLevel:l,scopedServiceId:c,setScopedServiceId:u,scopedModuleId:f,setScopedModuleId:h,focusRequest:p,locateNode:y}=oSe(),{isDiffMode:v,setIsDiffMode:$,selectedAnalysisId:x,setSelectedAnalysisId:S,selectedPath:b,setSelectedPath:T}=fSe(),[w,P]=_.useState(null),[k,R]=_.useState(!1),{openFiles:E,activeFilePath:C,handleOpenFile:z,handleCloseFile:Y,openFlows:W,activeFlowId:A,handleOpenFlow:q,handleCloseFlow:N,syncFlowNames:Z,openDatabases:D,activeDbId:M,handleOpenDatabase:V,handleCloseDatabase:I,handleSelectTab:B,showFlowView:L,showDatabaseView:J,handleLeftTabChange:K}=lSe(),{activeSpecConflictId:H,setActiveSpecConflictId:re,handleSelectSpecConflict:F,activeCanonicalPath:te,setActiveCanonicalPath:ie,openCanonicalFiles:se,handleOpenCanonical:ae,handleCloseCanonical:ue,activeContractsPath:Oe,setActiveContractsPath:de,openContractsFiles:xe,handleOpenContracts:Qe,handleCloseContracts:Re,activeDriftId:Le,setActiveDriftId:Ne,openDriftTabs:ve,handleOpenDrift:Se,handleCloseDrift:ke,reconcileDriftTabs:we}=uSe(),Ge=w==null?void 0:w.defaultBranch,{isConnected:ce,analysisProgress:$e,specProgress:Ee,clearProgress:De,clearSpecProgress:He,onEvent:at,llmEstimate:wt,respondToLlmEstimate:jt,stashConfirm:Pt,respondToStashConfirm:kn}=dmt(t);_.useEffect(()=>{if(!Pt)return;const he=Ze=>{Ze.key==="Escape"&&kn(Pt.repoId,"cancel")};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[Pt,kn]),_.useEffect(()=>{if(!wt)return;const he=Ze=>{Ze.key==="Escape"&&jt(wt.repoId,!1)};return document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)},[wt,jt]);const{violations:It,allViolations:ui,isLoading:gr,refetch:Tt}=hmt(t,void 0,x??void 0,{enabled:n==="home"}),{diffResult:_t,isChecking:Er,error:lr,run:yr,load:et}=pmt(t,at),Dt=v&&!_t,Cn=Dt?[]:It,Vn=Dt?[]:ui,{analyses:cr,refetch:dn}=mmt(t),_n=v&&(_t!=null&&_t.diffAnalysisId)?_t.diffAnalysisId:x??void 0,Va=n==="graphs"||n==="files"||n==="databases",{nodes:Ht,edges:Mr,savedCollapsedIds:vo,scopes:$r,isLoading:Ua,error:Cl,refetch:Oi}=Iet(t,{branch:Ge,level:s,analysisId:_n,scopedServiceId:c,scopedModuleId:f,enabled:Va});_.useEffect(()=>{s==="modules"&&!c&&$r.services.length===1&&u($r.services[0].id)},[s,c,$r.services,u]),_.useEffect(()=>{if(s!=="methods"||f)return;const he=c?$r.modules.filter(Ze=>Ze.serviceId===c):$r.modules;he.length===1&&h(he[0].id)},[s,f,c,$r.modules,h]);const{summary:_r,refetch:er}=gmt(t,_n,{enabled:n==="files"}),fi=Dt?void 0:_r,{flows:$a,severities:fd,isLoading:km,refetch:zl}=ymt(t,{enabled:n==="flows",analysisId:_n}),Yl=Dt?{}:fd,{tree:wO,isLoading:Es,error:Cs,refetch:Fo}=ppt(t),{tree:zs,isLoading:Cr,error:dd,refetch:PO}=mpt(t),{state:va,diff:Ti,history:Hc,isLoading:TO,isRunning:hd,isDiffing:kO,error:Kc,refetch:Ho,run:Na,runDiff:qi}=jLe(t),{generating:pd,result:Al,run:Ys}=ELe(t),{contractsStale:md,verifyStale:ql,refetch:gd}=CLe(t),[ki,Wa]=_.useState({severity:null,kind:null,file:null}),yd=_.useCallback(he=>Wa(Ze=>({...Ze,severity:Ze.severity===he?null:he})),[]),_O=_.useCallback(he=>Wa(Ze=>({...Ze,kind:Ze.kind===he?null:he})),[]),Ko=_.useCallback(he=>Wa(Ze=>({...Ze,file:Ze.file===he?null:he})),[]),Gv=_.useCallback(he=>Wa(Ze=>({...Ze,[he]:null})),[]),[$d,Jc]=_.useState(560),_m=_.useRef(!1),Bv=_.useCallback(he=>{he.preventDefault(),_m.current=!0;const Ze=he.clientX,We=$d,Kt=Xr=>{if(!_m.current)return;const tr=Xr.clientX-Ze;Jc(Math.min(800,Math.max(320,We+tr)))},kt=()=>{_m.current=!1,document.removeEventListener("mousemove",Kt),document.removeEventListener("mouseup",kt)};document.addEventListener("mousemove",Kt),document.addEventListener("mouseup",kt)},[$d]),[As,Zl]=_.useState(null),[cP,Xm]=_.useState(null);_.useEffect(()=>{if(!As||!t){Xm(null);return}let he=!1;return v0e(t,As).then(Ze=>{he||Xm(Ze)}).catch(()=>{he||Xm(null)}),()=>{he=!0}},[As,t]);const qs=!!As,ea=qs?cP:va,XO=v&&!qs,vd=_.useMemo(()=>[...Hc.runs].reverse().map(he=>{const Ze=new Date(he.verifiedAt);return{id:he.id,label:Number.isNaN(Ze.getTime())?he.verifiedAt:`${Ze.toLocaleDateString()} ${Ze.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}}),[Hc]),Vl=qs?((Kv=vd.find(he=>he.id===As))==null?void 0:Kv.label)??null:null,eu=_.useCallback(he=>{Zl(he),i("verify")},[i]),Fv=_.useCallback(async he=>{await x0e(t,he),Zl(Ze=>Ze===he?null:Ze),await Ho()},[t,Ho]);_.useEffect(()=>{we(va?new Set(va.drifts.map(he=>he.id)):null),Wa({severity:null,kind:null,file:null}),Zl(null)},[va,we]);const tu=!!x,Rm=x?cr.find(he=>he.id===x):null,[Zs,Jo]=_.useState(null);_.useEffect(()=>{t&&T8(t).then(he=>{var We;P(he);const Ze=(We=he.latestAnalysis)==null?void 0:We.status;Ze==="running"?R(!0):Ze==="cancelling"&&(R(!0),nu(!0))}).catch(he=>{Jo(he instanceof Error?he.message:"Failed to load repository")})},[t]),_.useEffect(()=>{v&&et()},[]),_.useEffect(()=>{$e&&!k&&!v&&R(!0)},[$e,k,v]),_.useEffect(()=>{const he=at("analysis:complete",()=>{R(!1),nu(!1),Oi(),dn(),er(),zl(),T8(t).then(P).catch(()=>{})}),Ze=at("analysis:canceled",()=>{R(!1),nu(!1)});return()=>{he(),Ze()}},[at,Oi,dn,er,zl,t]),_.useEffect(()=>at("spec:complete",Ze=>{const We=Ze;(We==null?void 0:We.kind)==="scan"?PO():(We==null?void 0:We.kind)==="generate"?Fo():(We==null?void 0:We.kind)==="verify"&&Ho(),((We==null?void 0:We.kind)==="scan"||(We==null?void 0:We.kind)==="generate"||(We==null?void 0:We.kind)==="verify")&&gd()}),[at,PO,Fo,Ho,gd]),_.useEffect(()=>at("violations:ready",()=>{R(!1),Tt(),er()}),[at,Tt,er]);const[xd,Ul]=_.useState(null),[es,nu]=_.useState(!1),Qd=async()=>{if(v)yr();else try{R(!0),Ul(null),await vre(t),Oi(),dn(),Tt(),er(),zl()}catch(he){R(!1),Ul(he instanceof Error?he.message:"Analysis failed")}},bd=_.useCallback(he=>{var Ze;if(o(he),he){const We=Ht.find(Kt=>Kt.id===he);if(We&&We.type==="database"){const Kt=((Ze=We.data)==null?void 0:Ze.label)??"Database";V(he,Kt,!0);return}}},[Ht,V]),RO=_.useCallback(()=>{$(!0),et()},[$,et]),jO=_.useCallback(()=>{$(!1)},[$]),jm=_.useMemo(()=>{if(!v||!_t)return Ht;const he=new Set(_t.affectedNodeIds.services),Ze=new Set(_t.affectedNodeIds.layers),We=new Set(_t.affectedNodeIds.modules),Kt=new Set(_t.affectedNodeIds.methods),kt=new Map,Xr=new Map,tr=new Map,Xn=new Map,xa=new Map,zO=new Map;for(const ut of _t.newViolations){if(ut.targetServiceName&&kt.set(ut.targetServiceName,(kt.get(ut.targetServiceName)||0)+1),ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}`;tr.set(Yr,(tr.get(Yr)||0)+1)}if(ut.targetMethodName&&ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}::${ut.targetMethodName}`;Xn.set(Yr,(Xn.get(Yr)||0)+1)}}for(const ut of _t.resolvedViolations||[]){if(ut.targetServiceName&&Xr.set(ut.targetServiceName,(Xr.get(ut.targetServiceName)||0)+1),ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}`;xa.set(Yr,(xa.get(Yr)||0)+1)}if(ut.targetMethodName&&ut.targetModuleName&&ut.targetServiceName){const Yr=`${ut.targetServiceName}::${ut.targetModuleName}::${ut.targetMethodName}`;zO.set(Yr,(zO.get(Yr)||0)+1)}}const tx=ut=>{let Yr=ut;for(;;){const Vs=Yr.parentId;if(!Vs)return"";const Zi=Ht.find(Vi=>Vi.id===Vs);if(!Zi)return"";if(Zi.type==="serviceGroup")return Zi.data.label;Yr=Zi}};return Ht.map(ut=>{const Yr=ut.data,Vs=Yr.label;if(ut.type==="service"||ut.type==="serviceGroup"){const Zi=Vs,Vi=he.has(Zi);return{...ut,data:{...Yr,diffBadge:Vi?{newCount:kt.get(Zi)||0,resolvedCount:Xr.get(Zi)||0}:void 0},style:Vi?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="layer"){const Zi=ut.parentId,Vi=Zi?Ht.find(_d=>_d.id===Zi):void 0,Cm=`${Vi?Vi.data.label:""}::${Vs}`,iu=Ze.has(Cm);return{...ut,data:{...Yr,diffBadge:iu?{newCount:0,resolvedCount:0}:void 0},style:iu?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="module"){const Vi=`${tx(ut)}::${Vs}`,ru=We.has(Vi);return{...ut,data:{...Yr,diffBadge:ru?{newCount:tr.get(Vi)||0,resolvedCount:xa.get(Vi)||0}:void 0},style:ru?ut.style:{...ut.style,opacity:.4}}}if(ut.type==="method"){const Zi=tx(ut),Vi=ut.parentId,ru=Vi?Ht.find(OP=>OP.id===Vi):void 0,Cm=ru?ru.data.label:"",iu=`${Zi}::${Cm}::${Vs}`,_d=Kt.has(iu);return{...ut,data:{...Yr,diffBadge:_d?{newCount:Xn.get(iu)||0,resolvedCount:zO.get(iu)||0}:void 0},style:_d?ut.style:{...ut.style,opacity:.4}}}return{...ut,style:{...ut.style,opacity:.4}}})},[Ht,v,_t]),zr=_.useCallback((he,Ze)=>{if(!he||!Ze)return!1;if(he.includes(Ze))return!0;const We=he.split("/");for(let Kt=We.length-1;Kt>=1;Kt--){const kt=We.slice(Kt).join("/");if(Ze.startsWith(kt+"/")||Ze===kt)return!0}return!1},[]),ts=_.useMemo(()=>{const he=v?jm:Ht;if(!b)return he;const Ze=new Map;for(const kt of he){const Xr=kt.parentId;Xr&&Ze.set(kt.id,Xr)}const We=new Set;for(const kt of he){const Xr=kt.data;let tr=!1;if(kt.type==="module"||kt.type==="method"){const Xn=Xr.filePath||Xr.rootPath||"";zr(Xn,b)&&(tr=!0)}else if(kt.type==="layer"){const Xn=Xr.filePaths;Xn!=null&&Xn.some(xa=>zr(xa,b))&&(tr=!0)}else if(kt.type==="serviceGroup"){const Xn=Xr.rootPath||"";zr(Xn,b)&&(tr=!0)}else if(kt.type==="service"){const Xn=Xr.serviceInfo,xa=(Xn==null?void 0:Xn.rootPath)||"";zr(xa,b)&&(tr=!0)}if(tr){We.add(kt.id);let Xn=Ze.get(kt.id);for(;Xn;)We.add(Xn),Xn=Ze.get(Xn)}}let Kt=!0;for(;Kt;){Kt=!1;for(const kt of he){if(We.has(kt.id))continue;const Xr=Ze.get(kt.id);if(!Xr||!We.has(Xr))continue;const tr=kt.data;if(kt.type==="module"||kt.type==="method"){const Xn=tr.filePath||tr.rootPath||"";zr(Xn,b)&&(We.add(kt.id),Kt=!0)}else if(kt.type==="layer"){const Xn=tr.filePaths;Xn!=null&&Xn.some(xa=>zr(xa,b))&&(We.add(kt.id),Kt=!0)}}}return he.map(kt=>We.has(kt.id)?kt:{...kt,style:{...kt.style,opacity:.15}})},[Ht,jm,v,b,zr]),Sd=_.useMemo(()=>{var Ze;if(!b)return null;const he=new Set;for(const We of ts)((Ze=We.style)==null?void 0:Ze.opacity)!==.15&&he.add(We.id);return he},[ts,b]);if(_.useMemo(()=>{const he=new Map;for(const Ze of Ht){const We=Ze.data;let Kt=We.filePath||We.rootPath;if(!Kt&&Ze.type==="service"){const kt=We.serviceInfo;Kt=(kt==null?void 0:kt.rootPath)||""}Kt&&he.set(Ze.id,Kt)}return he},[Ht]),!t)return m.jsx(c$e,{to:"/",replace:!0});const EO=_.useCallback((he,Ze,We)=>{i("graphs"),y(he,Ze,We)},[i,y]),wd=C!==null&&n==="files",Pd=A!==null&&n==="flows",Em=M!==null&&n==="databases",CO=H!==null&&(n==="spec"||n==="decisions"),Td=te!==null&&n==="spec",Hv=Oe!==null&&n==="contracts",uP=(w==null?void 0:w.lastAnalyzed)!=null;return _.useEffect(()=>{Z($a)},[$a,Z]),m.jsx(dSe,{repoId:t,children:m.jsxs("div",{className:"flex h-screen flex-col",children:[m.jsx(qq,{repoName:w==null?void 0:w.name,currentBranch:Ge,onAnalyze:e!=="analysis"||tu||Zs||(w==null?void 0:w.isGitRepo)===!1?void 0:Qd,isAnalyzing:k||Er,showBack:!0,backHref:"/",isDiffMode:v,onEnterDiffMode:e!=="analysis"||tu||(w==null?void 0:w.isGitRepo)===!1?void 0:RO,onExitDiffMode:e!=="analysis"||tu||(w==null?void 0:w.isGitRepo)===!1?void 0:jO,analyses:cr,selectedAnalysisId:x,onSelectAnalysis:S,currentAnalysisId:_n||(v||(Jv=cr==null?void 0:cr[0])==null?void 0:Jv.id),dashboardSection:e,onDashboardSectionChange:r,sectionActions:n==="spec"?m.jsx(hSe,{isGitRepo:(w==null?void 0:w.isGitRepo)!==!1}):n==="contracts"?m.jsx(zLe,{isGenerating:pd,onGenerate:Ys,stale:md,isGitRepo:(w==null?void 0:w.isGitRepo)!==!1}):n==="verify"?m.jsx(kLe,{isRunning:v?kO:hd,onRun:v?qi:Na,stale:ql,diffMode:v,onToggleDiff:$,isGitRepo:(w==null?void 0:w.isGitRepo)!==!1,runItems:vd,selectedRunId:As,onSelectRun:Zl,viewingHistory:qs}):null}),!wd&&tu&&Rm&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsxs("span",{children:["Viewing analysis from"," ",new Date(Rm.createdAt).toLocaleString([],{dateStyle:"medium",timeStyle:"short"})," ","— not the latest"]}),m.jsx("button",{className:"underline hover:text-amber-400 transition-colors",onClick:()=>S(null),children:"Return to latest"})]}),v&&(_t==null?void 0:_t.diffAnalysisId)&&m.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:m.jsx("span",{children:"Showing working tree state (uncommitted changes)"})}),n==="verify"&&qs&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsxs("span",{children:["Viewing verify run",Vl?` from ${Vl}`:""," — not the latest"]}),m.jsx("button",{className:"underline hover:text-amber-400 transition-colors",onClick:()=>Zl(null),children:"Return to latest"})]}),Zs&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-destructive/10 border-b border-destructive/30 px-4 py-1.5 text-xs text-destructive",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{children:Zs})]}),!Zs&&(w==null?void 0:w.isGitRepo)===!1&&m.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-2 bg-amber-500/10 border-b border-amber-500/30 px-4 py-1.5 text-xs text-amber-500",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0"}),m.jsx("span",{children:"This directory is not a git repository — analyze, spec scan, contract generation, and verify are unavailable (TrueCourse needs git for commit-anchored baselines, diff, and history)."})]}),m.jsx(YLe,{result:Al}),m.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m.jsxs(rSe,{section:e,activeTab:n,onTabChange:K,badgeCounts:{home:Vn.length,flows:$a.length,databases:Ht.filter(he=>he.type==="database").length,analyses:cr.length},children:[n==="flows"&&m.jsx(fst,{flows:$a,isLoading:km,onSelectFlow:q,activeFlowId:A,flowSeverities:Yl}),n==="databases"&&m.jsx(Cst,{repoId:t,branch:Ge,analysisId:_n,activeDbId:M,onSelectDatabase:V}),n==="files"&&m.jsx(cst,{repoId:t,selectedPath:b,onOpenFile:z,violationCounts:fi==null?void 0:fi.byFile,violationSeverities:fi==null?void 0:fi.highestSeverityByFile,revealPath:C,isDiffMode:v,onSelectPath:he=>{if(T(he),!he){bd(null);return}let Ze=null;for(const We of Ht){if(We.type!=="service"&&We.type!=="serviceGroup")continue;const Kt=We.data;let kt="";if(We.type==="service"){const tr=Kt.serviceInfo;kt=(tr==null?void 0:tr.rootPath)||""}else kt=Kt.rootPath||"";if(!kt)continue;const Xr=kt.split("/");for(let tr=Xr.length-1;tr>=0;tr--){const Xn=Xr.slice(tr).join("/");if(he.startsWith(Xn)||he.startsWith(Xn+"/")){const xa=Xr.length-tr;(!Ze||xa>Ze.depth)&&(Ze={id:We.id,depth:xa});break}}}bd((Ze==null?void 0:Ze.id)??null)}}),n==="spec"&&m.jsx(Hst,{canonicalTree:zs,canonicalLoading:Cr,canonicalError:dd,activeConflictId:H,onSelectConflict:F,activeCanonicalPath:te,onOpenCanonicalFile:ae}),n==="contracts"&&m.jsx(gSe,{tree:wO,isLoading:Es,error:Cs,activePath:Oe,validationIssues:Al&&"il"in Al&&"validationIssues"in Al.il?Al.il.validationIssues:void 0,onOpen:Qe}),n==="decisions"&&m.jsx(qLe,{activeConflictId:H,onSelectConflict:F})]}),m.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(n==="files"||n==="flows"||n==="databases")&&(E.length>0||W.length>0||D.length>0)||n==="spec"&&se.length>0||n==="contracts"&&xe.length>0?m.jsxs("div",{className:"flex shrink-0 items-center border-b border-border bg-card text-xs overflow-x-auto",children:[E.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=C===he.path;return m.jsxs("div",{onClick:()=>B(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),Y(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)}),W.map(he=>{const Ze=A===he.id&&!wd;return m.jsxs("div",{onClick:()=>L(he.id),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${Ze?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.name,children:[m.jsx(Wne,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:he.name}),m.jsx("button",{onClick:We=>{We.stopPropagation(),N(he.id)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${Ze?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.id)}),D.map(he=>{const Ze=M===he.id&&!wd&&!Pd;return m.jsxs("div",{onClick:()=>J(he.id),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${Ze?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.name,children:[m.jsx(xl,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:he.name}),m.jsx("button",{onClick:We=>{We.stopPropagation(),I(he.id)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${Ze?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.id)}),n==="spec"&&se.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=te===he.path;return m.jsxs("div",{onClick:()=>ie(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx(Ju,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),ue(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)}),n==="contracts"&&xe.map(he=>{const Ze=he.path.split("/").pop()||he.path,We=Oe===he.path;return m.jsxs("div",{onClick:()=>de(he.path),className:`group shrink-0 flex items-center gap-1 px-3 py-1.5 border-r border-border cursor-pointer transition-colors ${We?"bg-background text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:he.path,children:[m.jsx(Ju,{className:"h-3 w-3 shrink-0"}),m.jsx("span",{className:he.pinned?"font-medium":"italic",children:Ze}),m.jsx("button",{onClick:Kt=>{Kt.stopPropagation(),Re(he.path)},className:`rounded p-0.5 hover:bg-muted transition-opacity ${We?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:m.jsx(Rr,{className:"h-3 w-3"})})]},he.path)})]}):null,m.jsx("div",{className:"relative flex-1 overflow-hidden",children:wd&&C?m.jsx(Est,{repoId:t,filePath:C,analysisId:_n,scrollToLine:(kd=E.find(he=>he.path===C))==null?void 0:kd.scrollToLine,isDiffMode:v,onClose:()=>Y(C)}):Pd&&A?m.jsx(jst,{repoId:t,flowId:A,analysisId:_n,canEnrich:!v&&!x}):Em&&M?m.jsx(ohe,{repoId:t,databaseId:M,analysisId:_n,violations:Cn,isTab:!0}):Td&&te?m.jsx(Opt,{repoId:t,filePath:te}):CO&&H?m.jsx(ept,{conflictId:H,onClose:()=>re(null)}):n==="spec"?m.jsx(pSe,{}):Hv&&Oe?m.jsx(jze,{repoId:t,filePath:Oe}):n==="contracts"?m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{children:"Select a contract file from the list to view it."})}):n==="verify"?(()=>{const he=(XO?[...(Ti==null?void 0:Ti.added)??[],...(Ti==null?void 0:Ti.resolved)??[]]:(ea==null?void 0:ea.drifts)??[]).find(Ze=>Ze.id===Le)??null;return m.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[m.jsxs("aside",{style:{width:$d},className:"relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-card",children:[m.jsx(xLe,{state:ea,diff:Ti,history:Hc,mode:XO?"diff":"current",isDiffing:kO,filters:ki,onToggleSeverity:yd,onToggleKind:_O,onToggleFile:Ko}),m.jsx("div",{className:"absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize hover:bg-primary/30 active:bg-primary/50",onMouseDown:Bv})]}),m.jsx("div",{className:"w-[380px] shrink-0 overflow-hidden border-r border-border",children:m.jsx(Cze,{state:ea,diff:Ti,mode:XO?"diff":"current",isLoading:TO,isDiffing:kO,error:Kc,activeDriftId:Le,filters:ki,onClearFilter:Gv,onOpenDrift:Se})}),m.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:he?m.jsx(XLe,{drift:he,onClose:()=>ke(he.id),onOpenFile:(Ze,We)=>{r("analysis"),z(Ze,!0,We)}}):m.jsx(RLe,{})})]})})():n==="runs"?m.jsx(TLe,{history:Hc,selectedRunId:As,onViewRun:eu,onDeleteRun:Fv}):n==="decisions"?m.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:m.jsx("p",{className:"max-w-md",children:"Every conflict you've resolved in the Spec tab lives in the ledger on the left. Revoke a decision to re-open its conflict — your other candidates are preserved."})}):n==="analyses"?m.jsx(Mst,{analyses:cr,isLoading:!1,currentAnalysisId:_n||(v||(ex=cr==null?void 0:cr[0])==null?void 0:ex.id),selectedAnalysisId:x,onSelectAnalysis:S,onDeleteAnalysis:async he=>{await Lbe(t,he),S(null),dn(),Tt(),Oi(),er(),zl(),v&&et()},repoId:t}):n==="home"?w==null?m.jsx("div",{className:"flex h-full w-full items-center justify-center",children:m.jsx(yn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):m.jsx(ast,{repoId:t,branch:Ge,analysisId:_n,hasAnalysis:uP,violations:Cn,violationsLoading:gr,isDiffMode:v,diffResult:_t,onLocateNode:EO,onOpenFile:z,onRefreshAfterDisable:Tt},w.lastAnalyzed??"unanalyzed"):n==="graphs"?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"absolute right-3 top-2 z-20 flex items-center gap-1.5 rounded-full bg-card px-2 py-1 text-[10px] shadow-sm border border-border",children:ce?m.jsxs(m.Fragment,{children:[m.jsx(exe,{className:"h-3 w-3 text-emerald-500"}),m.jsx("span",{className:"text-emerald-500",children:"Live"})]}):m.jsxs(m.Fragment,{children:[m.jsx(Jve,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"text-muted-foreground",children:"Offline"})]})}),Ua?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3",children:[m.jsx(yn,{className:"h-10 w-10 animate-spin text-primary"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."})]})}):Cl&&!k?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[m.jsx(zi,{className:"h-10 w-10 text-destructive"}),m.jsxs(uy,{variant:"destructive",className:"max-w-sm",children:[m.jsx(N8,{children:"Failed to load graph"}),m.jsx(Oy,{children:Cl})]}),m.jsx(xn,{onClick:()=>Oi(),className:"mt-2",children:"Retry"})]})}):Ht.length===0&&Ht.length===0&&!(s==="modules"&&!c)&&!(s==="methods"&&!f)?m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[m.jsx(zi,{className:"h-10 w-10 text-muted-foreground"}),m.jsxs(uy,{className:"max-w-sm",children:[m.jsx(N8,{children:"No graph data"}),m.jsx(Oy,{children:"Run an analysis to generate the architecture graph"})]}),v&&lr&&m.jsxs(uy,{className:"mt-3 max-w-sm border-amber-500/30 text-amber-500",children:[m.jsx(zi,{className:"h-4 w-4"}),m.jsx(Oy,{className:"text-amber-500/90",children:lr})]})]})}):m.jsx(m.Fragment,{children:m.jsx(dnt,{initialNodes:ts,initialEdges:Mr,onNodeSelect:bd,selectedNodeId:a,repoId:t,branch:Ge,onRefetch:Oi,depthLevel:s,onDepthChange:l,focusNodeId:(p==null?void 0:p.nodeId)??null,focusKey:(p==null?void 0:p.key)??0,isDiffMode:v,diffResult:_t,isDiffChecking:Er,hasProgressBar:!!$e,onEnterDiffMode:RO,onExitDiffMode:jO,highlightedNodeIds:Sd,savedCollapsedIds:vo,scopes:$r,scopedServiceId:c,scopedModuleId:f,onScopedServiceChange:u,onScopedModuleChange:he=>{if(h(he),he){const Ze=$r.modules.find(We=>We.id===he);Ze&&Ze.serviceId&&Ze.serviceId!==c&&u(Ze.serviceId)}}})})]}):m.jsx("div",{className:"flex h-full items-center justify-center text-center",children:m.jsx("p",{className:"max-w-xs text-sm text-muted-foreground",children:n==="files"?"Pick a file from the tree to preview it here.":n==="flows"?"Pick a flow to view its sequence diagram here.":n==="databases"?"Pick a database to view its schema here.":null})})})]})]}),xd&&m.jsxs("div",{className:"fixed bottom-4 left-1/2 z-40 w-96 -translate-x-1/2 rounded-lg border border-destructive/50 bg-card p-3 shadow-lg",children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:"text-[11px] font-medium text-destructive",children:"Analysis failed"}),m.jsx("button",{onClick:()=>Ul(null),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(zi,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:xd})]})]}),Pt&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>kn(Pt.repoId,"cancel"),role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"w-96 rounded-lg border border-border bg-card p-4 shadow-lg",onClick:he=>he.stopPropagation(),children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:"Stash pending changes?"}),m.jsx("button",{onClick:()=>kn(Pt.repoId,"cancel"),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Cancel",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsxs("p",{className:"mb-4 text-[11px] text-muted-foreground",children:["Your repository has ",Pt.modifiedCount," modified and"," ",Pt.untrackedCount," untracked file(s)."]}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{className:"rounded-md bg-primary px-3 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",onClick:()=>kn(Pt.repoId,"stash"),children:"Stash and analyze committed state"}),m.jsx("button",{className:"rounded-md border border-border px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent",onClick:()=>kn(Pt.repoId,"no-stash"),children:"Don't stash — analyze working tree as-is"})]})]})}),wt&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>jt(wt.repoId,!1),role:"dialog","aria-modal":"true",children:m.jsxs("div",{className:"w-96 rounded-lg border border-border bg-card p-4 shadow-lg",onClick:he=>he.stopPropagation(),children:[m.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:"Run LLM rules?"}),m.jsx("button",{onClick:()=>jt(wt.repoId,!1),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Skip",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})})]}),m.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:(()=>{const he=wt.estimate.tiers.reduce((We,Kt)=>We+Kt.ruleCount,0);return`${wt.estimate.tiers.reduce((We,Kt)=>We+Kt.fileCount,0)} files, ${he} rules (~${Math.round(wt.estimate.totalEstimatedTokens/1e3)}k tokens).`})()}),m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("button",{className:"rounded-md bg-primary px-3 py-1.5 text-[11px] font-medium text-primary-foreground hover:bg-primary/90",onClick:()=>jt(wt.repoId,!0),children:"Run LLM rules"}),m.jsx("button",{className:"rounded-md border border-border px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent",onClick:()=>jt(wt.repoId,!1),children:"Skip — deterministic rules only"})]})]})}),$e&&m.jsxs("div",{className:`fixed bottom-4 left-1/2 z-40 w-80 -translate-x-1/2 rounded-lg border bg-card p-3 shadow-lg ${$e.step==="error"?"border-destructive/50":"border-border"}`,children:[m.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[m.jsx("span",{className:`text-[11px] font-medium ${$e.step==="error"?"text-destructive":"text-foreground"}`,children:$e.step==="error"?"Analysis failed":es?"Cancelling...":"Analyzing..."}),$e.step==="error"?m.jsx("button",{onClick:()=>{De(),R(!1)},className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Dismiss",children:m.jsx(Rr,{className:"h-3.5 w-3.5"})}):es?m.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] text-amber-500",children:"Cancelling..."}):m.jsx("button",{onClick:()=>{t&&(Gbe(t).catch(()=>{}),nu(!0))},className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground",children:"Cancel"})]}),$e.step==="error"?m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(i0,{className:"h-3.5 w-3.5 shrink-0 translate-y-px text-destructive"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:$e.detail||"An error occurred"})]}):$e.steps&&$e.steps.length>0?m.jsx("div",{className:"space-y-1",children:$e.steps.map(he=>m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"shrink-0 translate-y-px",children:[he.status==="done"&&m.jsx(Ff,{className:"h-3.5 w-3.5 text-emerald-500"}),he.status==="active"&&m.jsx(yn,{className:"h-3.5 w-3.5 animate-spin text-primary"}),he.status==="error"&&m.jsx(i0,{className:"h-3.5 w-3.5 text-destructive"}),he.status==="pending"&&m.jsx("div",{className:"h-2.5 w-2.5 rounded-full border border-muted-foreground/30"})]}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsxs("span",{className:`text-[11px] leading-[18px] ${he.status==="active"?"font-medium text-foreground":he.status==="done"?"text-muted-foreground":he.status==="error"?"text-destructive":"text-muted-foreground/60"}`,children:[he.label,he.detail&&he.status!=="pending"&&m.jsx("span",{className:"ml-1.5 text-[10px] font-normal text-muted-foreground/70",children:he.detail})]})})]},he.key))}):m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(yn,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}),m.jsx("span",{className:"text-[11px] text-muted-foreground",children:$e.detail||$e.step})]})]}),Ee&&m.jsx(mSe,{progress:Ee,onDismiss:He})]})})}function ene({children:t}){return m.jsxs("div",{className:"flex min-h-screen flex-col",children:[m.jsx(qq,{}),m.jsx("main",{className:"flex-1 overflow-auto",children:t})]})}function xmt(){const{routes:t,homeComponent:e}=Xre(),n=_.useMemo(()=>t.map(i=>({path:i.path,Component:_.lazy(()=>i.load())})),[t]),r=_.useMemo(()=>e?_.lazy(()=>e()):null,[e]);return m.jsxs(O$e,{children:[m.jsx(bb,{path:"/",element:r?m.jsx(ene,{children:m.jsx(_.Suspense,{children:m.jsx(r,{})})}):m.jsx(nSe,{})}),m.jsx(bb,{path:"/repos/:repoId",element:m.jsx(_.Suspense,{children:m.jsx($mt,{})})}),n.map(({path:i,Component:a})=>m.jsx(bb,{path:i,element:m.jsx(ene,{children:m.jsx(_.Suspense,{children:m.jsx(a,{})})})},i))]})}function Qmt(){const t=Ere();return m.jsx(X0e,{children:m.jsx(U0e,{children:m.jsx(M0e,{children:m.jsx(Y$e,{children:m.jsxs(I0e,{children:[m.jsx(xmt,{}),m.jsx(yve,{position:"bottom-center",theme:t?"dark":"light",closeButton:!0,toastOptions:{unstyled:!0,duration:1e4,classNames:{toast:"font-sans w-full flex items-start gap-3 rounded-md border px-4 py-3 text-sm shadow-lg bg-popover text-popover-foreground border-border",title:"font-semibold leading-tight",description:"mt-0.5 text-xs leading-snug opacity-90",actionButton:"rounded-md bg-primary px-2 py-1 text-xs text-primary-foreground hover:opacity-90",cancelButton:"rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted",closeButton:"absolute right-1.5 top-1.5 rounded p-0.5 text-muted-foreground hover:bg-muted",success:"!text-emerald-700 dark:!text-emerald-300",error:"!text-red-700 dark:!text-red-300",warning:"!text-amber-700 dark:!text-amber-300",info:"!text-blue-700 dark:!text-blue-300"}}})]})})})})})}fye.createRoot(document.getElementById("root")).render(m.jsx(_.StrictMode,{children:m.jsx(Qmt,{})}));
|