onepipeline-ui 0.73.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -85,30 +85,30 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
85
85
|
newResult[${r}] = ${n}.value;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=zw,s=!Tw.jitless,c=s&&Bw.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?cD([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function dD(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!tT(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>iT(e,r,Ew())))}),t)}var fD=q(`$ZodUnion`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Pw(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Pw(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Pw(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>jw(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>dD(t,i,e,a)):dD(s,i,e,a)}}),pD=q(`$ZodDiscriminatedUnion`,(e,t)=>{fD.init(e,t);let n=e._zod.parse;Pw(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=kw(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!zw(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),mD=q(`$ZodIntersection`,(e,t)=>{CE.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>gD(e,t,n)):gD(e,i,a)}});function hD(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Vw(e)&&Vw(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=hD(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=hD(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gD(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),tT(e))return e;let r=hD(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var _D=q(`$ZodRecord`,(e,t)=>{CE.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Vw(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...nT(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...nT(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>iT(e,r,Ew())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...nT(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...nT(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),vD=q(`$ZodEnum`,(e,t)=>{CE.init(e,t);let n=Dw(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Uw.has(typeof e)).map(e=>typeof e==`string`?Ww(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),yD=q(`$ZodLiteral`,(e,t)=>{if(CE.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ww(e):e?Ww(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),bD=q(`$ZodTransform`,(e,t)=>{CE.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ww(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Cw;return n.value=i,n}});function xD(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var SD=q(`$ZodOptional`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Pw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jw(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>xD(t,e.value)):xD(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),CD=q(`$ZodNullable`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),Pw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jw(e.source)}|null)$`):void 0}),Pw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wD=q(`$ZodDefault`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>TD(e,t)):TD(r,t)}});function TD(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ED=q(`$ZodPrefault`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),DD=q(`$ZodNonOptional`,(e,t)=>{CE.init(e,t),Pw(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>OD(t,e)):OD(i,e)}});function OD(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var kD=q(`$ZodCatch`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>iT(e,n,Ew()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>iT(e,n,Ew()))},input:e.value}),e.issues=[]),e)}}),AD=q(`$ZodPipe`,(e,t)=>{CE.init(e,t),Pw(e._zod,`values`,()=>t.in._zod.values),Pw(e._zod,`optin`,()=>t.in._zod.optin),Pw(e._zod,`optout`,()=>t.out._zod.optout),Pw(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>jD(e,t.in,n)):jD(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jD(e,t.out,n)):jD(r,t.out,n)}});function jD(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var MD=q(`$ZodReadonly`,(e,t)=>{CE.init(e,t),Pw(e._zod,`propValues`,()=>t.innerType._zod.propValues),Pw(e._zod,`values`,()=>t.innerType._zod.values),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ND):ND(r)}});function ND(e){return e.value=Object.freeze(e.value),e}var PD=q(`$ZodLazy`,(e,t)=>{CE.init(e,t),Pw(e._zod,`innerType`,()=>t.getter()),Pw(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),Pw(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),Pw(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),Pw(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),FD=q(`$ZodCustom`,(e,t)=>{iE.init(e,t),CE.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ID(t,n,r,e));ID(i,n,r,e)}});function ID(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(oT(e))}}var LD=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function RD(){return new LD}var zD=RD();function BD(e,t){return new e({type:`string`,...J(t)})}function VD(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...J(t)})}function HD(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...J(t)})}function UD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...J(t)})}function WD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...J(t)})}function GD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...J(t)})}function KD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...J(t)})}function qD(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...J(t)})}function JD(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...J(t)})}function YD(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...J(t)})}function XD(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...J(t)})}function ZD(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...J(t)})}function QD(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...J(t)})}function $D(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...J(t)})}function eO(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...J(t)})}function tO(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...J(t)})}function nO(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...J(t)})}function rO(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...J(t)})}function iO(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...J(t)})}function aO(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...J(t)})}function oO(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...J(t)})}function sO(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...J(t)})}function cO(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...J(t)})}function lO(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...J(t)})}function uO(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...J(t)})}function dO(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...J(t)})}function fO(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...J(t)})}function pO(e,t){return new e({type:`number`,checks:[],...J(t)})}function mO(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...J(t)})}function hO(e,t){return new e({type:`boolean`,...J(t)})}function gO(e,t){return new e({type:`null`,...J(t)})}function _O(e){return new e({type:`unknown`})}function vO(e,t){return new e({type:`never`,...J(t)})}function yO(e,t){return new oE({check:`less_than`,...J(t),value:e,inclusive:!1})}function bO(e,t){return new oE({check:`less_than`,...J(t),value:e,inclusive:!0})}function xO(e,t){return new sE({check:`greater_than`,...J(t),value:e,inclusive:!1})}function SO(e,t){return new sE({check:`greater_than`,...J(t),value:e,inclusive:!0})}function CO(e,t){return new cE({check:`multiple_of`,...J(t),value:e})}function wO(e,t){return new uE({check:`max_length`,...J(t),maximum:e})}function TO(e,t){return new dE({check:`min_length`,...J(t),minimum:e})}function EO(e,t){return new fE({check:`length_equals`,...J(t),length:e})}function DO(e,t){return new mE({check:`string_format`,format:`regex`,...J(t),pattern:e})}function OO(e){return new hE({check:`string_format`,format:`lowercase`,...J(e)})}function kO(e){return new gE({check:`string_format`,format:`uppercase`,...J(e)})}function AO(e,t){return new _E({check:`string_format`,format:`includes`,...J(t),includes:e})}function jO(e,t){return new vE({check:`string_format`,format:`starts_with`,...J(t),prefix:e})}function MO(e,t){return new yE({check:`string_format`,format:`ends_with`,...J(t),suffix:e})}function NO(e){return new bE({check:`overwrite`,tx:e})}function PO(e){return NO(t=>t.normalize(e))}function FO(){return NO(e=>e.trim())}function IO(){return NO(e=>e.toLowerCase())}function LO(){return NO(e=>e.toUpperCase())}function RO(e,t,n){return new e({type:`array`,element:t,...J(n)})}function zO(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...J(n)})}function BO(e){let t=VO(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(oT(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(oT(r))}},e(n.value,n)));return t}function VO(e,t){let n=new iE({check:`custom`,...J(t)});return n._zod.check=e,n}var HO=q(`ZodISODateTime`,(e,t)=>{LE.init(e,t),pk.init(e,t)});function UO(e){return lO(HO,e)}var WO=q(`ZodISODate`,(e,t)=>{RE.init(e,t),pk.init(e,t)});function GO(e){return uO(WO,e)}var KO=q(`ZodISOTime`,(e,t)=>{zE.init(e,t),pk.init(e,t)});function qO(e){return dO(KO,e)}var JO=q(`ZodISODuration`,(e,t)=>{BE.init(e,t),pk.init(e,t)});function YO(e){return fO(JO,e)}var XO=(e,t)=>{cT.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>dT(e,t)},flatten:{value:t=>uT(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ow,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ow,2)}},isEmpty:{get(){return e.issues.length===0}}})};q(`ZodError`,XO);var ZO=q(`ZodError`,XO,{Parent:Error}),QO=fT(ZO),$O=pT(ZO),ek=mT(ZO),tk=gT(ZO),nk=vT(ZO),rk=yT(ZO),ik=bT(ZO),ak=xT(ZO),ok=ST(ZO),sk=CT(ZO),ck=wT(ZO),lk=TT(ZO),uk=q(`ZodType`,(e,t)=>(CE.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Iw(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>Gw(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>QO(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ek(e,t,n),e.parseAsync=async(t,n)=>$O(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>tk(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>nk(e,t,n),e.decode=(t,n)=>rk(e,t,n),e.encodeAsync=async(t,n)=>ik(e,t,n),e.decodeAsync=async(t,n)=>ak(e,t,n),e.safeEncode=(t,n)=>ok(e,t,n),e.safeDecode=(t,n)=>sk(e,t,n),e.safeEncodeAsync=async(t,n)=>ck(e,t,n),e.safeDecodeAsync=async(t,n)=>lk(e,t,n),e.refine=(t,n)=>e.check(OA(t,n)),e.superRefine=t=>e.check(kA(t)),e.overwrite=t=>e.check(NO(t)),e.optional=()=>uA(e),e.nullable=()=>fA(e),e.nullish=()=>uA(fA(e)),e.nonoptional=t=>vA(e,t),e.array=()=>X(e),e.or=t=>Zk([e,t]),e.and=t=>tA(e,t),e.transform=t=>SA(e,cA(t)),e.default=t=>mA(e,t),e.prefault=t=>gA(e,t),e.catch=t=>bA(e,t),e.pipe=t=>SA(e,t),e.readonly=()=>wA(e),e.describe=t=>{let n=e.clone();return zD.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return zD.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return zD.get(e);let n=e.clone();return zD.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),dk=q(`_ZodString`,(e,t)=>{wE.init(e,t),uk.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(DO(...t)),e.includes=(...t)=>e.check(AO(...t)),e.startsWith=(...t)=>e.check(jO(...t)),e.endsWith=(...t)=>e.check(MO(...t)),e.min=(...t)=>e.check(TO(...t)),e.max=(...t)=>e.check(wO(...t)),e.length=(...t)=>e.check(EO(...t)),e.nonempty=(...t)=>e.check(TO(1,...t)),e.lowercase=t=>e.check(OO(t)),e.uppercase=t=>e.check(kO(t)),e.trim=()=>e.check(FO()),e.normalize=(...t)=>e.check(PO(...t)),e.toLowerCase=()=>e.check(IO()),e.toUpperCase=()=>e.check(LO())}),fk=q(`ZodString`,(e,t)=>{wE.init(e,t),dk.init(e,t),e.email=t=>e.check(VD(mk,t)),e.url=t=>e.check(qD(_k,t)),e.jwt=t=>e.check(cO(Nk,t)),e.emoji=t=>e.check(JD(yk,t)),e.guid=t=>e.check(HD(hk,t)),e.uuid=t=>e.check(UD(gk,t)),e.uuidv4=t=>e.check(WD(gk,t)),e.uuidv6=t=>e.check(GD(gk,t)),e.uuidv7=t=>e.check(KD(gk,t)),e.nanoid=t=>e.check(YD(bk,t)),e.guid=t=>e.check(HD(hk,t)),e.cuid=t=>e.check(XD(xk,t)),e.cuid2=t=>e.check(ZD(Sk,t)),e.ulid=t=>e.check(QD(Ck,t)),e.base64=t=>e.check(aO(Ak,t)),e.base64url=t=>e.check(oO(jk,t)),e.xid=t=>e.check($D(wk,t)),e.ksuid=t=>e.check(eO(Tk,t)),e.ipv4=t=>e.check(tO(Ek,t)),e.ipv6=t=>e.check(nO(Dk,t)),e.cidrv4=t=>e.check(rO(Ok,t)),e.cidrv6=t=>e.check(iO(kk,t)),e.e164=t=>e.check(sO(Mk,t)),e.datetime=t=>e.check(UO(t)),e.date=t=>e.check(GO(t)),e.time=t=>e.check(qO(t)),e.duration=t=>e.check(YO(t))});function Y(e){return BD(fk,e)}var pk=q(`ZodStringFormat`,(e,t)=>{TE.init(e,t),dk.init(e,t)}),mk=q(`ZodEmail`,(e,t)=>{OE.init(e,t),pk.init(e,t)}),hk=q(`ZodGUID`,(e,t)=>{EE.init(e,t),pk.init(e,t)}),gk=q(`ZodUUID`,(e,t)=>{DE.init(e,t),pk.init(e,t)}),_k=q(`ZodURL`,(e,t)=>{kE.init(e,t),pk.init(e,t)});function vk(e){return qD(_k,e)}var yk=q(`ZodEmoji`,(e,t)=>{AE.init(e,t),pk.init(e,t)}),bk=q(`ZodNanoID`,(e,t)=>{jE.init(e,t),pk.init(e,t)}),xk=q(`ZodCUID`,(e,t)=>{ME.init(e,t),pk.init(e,t)}),Sk=q(`ZodCUID2`,(e,t)=>{NE.init(e,t),pk.init(e,t)}),Ck=q(`ZodULID`,(e,t)=>{PE.init(e,t),pk.init(e,t)}),wk=q(`ZodXID`,(e,t)=>{FE.init(e,t),pk.init(e,t)}),Tk=q(`ZodKSUID`,(e,t)=>{IE.init(e,t),pk.init(e,t)}),Ek=q(`ZodIPv4`,(e,t)=>{VE.init(e,t),pk.init(e,t)}),Dk=q(`ZodIPv6`,(e,t)=>{HE.init(e,t),pk.init(e,t)}),Ok=q(`ZodCIDRv4`,(e,t)=>{UE.init(e,t),pk.init(e,t)}),kk=q(`ZodCIDRv6`,(e,t)=>{WE.init(e,t),pk.init(e,t)}),Ak=q(`ZodBase64`,(e,t)=>{KE.init(e,t),pk.init(e,t)}),jk=q(`ZodBase64URL`,(e,t)=>{JE.init(e,t),pk.init(e,t)}),Mk=q(`ZodE164`,(e,t)=>{YE.init(e,t),pk.init(e,t)}),Nk=q(`ZodJWT`,(e,t)=>{ZE.init(e,t),pk.init(e,t)}),Pk=q(`ZodNumber`,(e,t)=>{QE.init(e,t),uk.init(e,t),e.gt=(t,n)=>e.check(xO(t,n)),e.gte=(t,n)=>e.check(SO(t,n)),e.min=(t,n)=>e.check(SO(t,n)),e.lt=(t,n)=>e.check(yO(t,n)),e.lte=(t,n)=>e.check(bO(t,n)),e.max=(t,n)=>e.check(bO(t,n)),e.int=t=>e.check(Lk(t)),e.safe=t=>e.check(Lk(t)),e.positive=t=>e.check(xO(0,t)),e.nonnegative=t=>e.check(SO(0,t)),e.negative=t=>e.check(yO(0,t)),e.nonpositive=t=>e.check(bO(0,t)),e.multipleOf=(t,n)=>e.check(CO(t,n)),e.step=(t,n)=>e.check(CO(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Fk(e){return pO(Pk,e)}var Ik=q(`ZodNumberFormat`,(e,t)=>{$E.init(e,t),Pk.init(e,t)});function Lk(e){return mO(Ik,e)}var Rk=q(`ZodBoolean`,(e,t)=>{eD.init(e,t),uk.init(e,t)});function zk(e){return hO(Rk,e)}var Bk=q(`ZodNull`,(e,t)=>{tD.init(e,t),uk.init(e,t)});function Vk(e){return gO(Bk,e)}var Hk=q(`ZodUnknown`,(e,t)=>{nD.init(e,t),uk.init(e,t)});function Uk(){return _O(Hk)}var Wk=q(`ZodNever`,(e,t)=>{rD.init(e,t),uk.init(e,t)});function Gk(e){return vO(Wk,e)}var Kk=q(`ZodArray`,(e,t)=>{aD.init(e,t),uk.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(TO(t,n)),e.nonempty=t=>e.check(TO(1,t)),e.max=(t,n)=>e.check(wO(t,n)),e.length=(t,n)=>e.check(EO(t,n)),e.unwrap=()=>e.element});function X(e,t){return RO(Kk,e,t)}var qk=q(`ZodObject`,(e,t)=>{uD.init(e,t),uk.init(e,t),Pw(e,`shape`,()=>t.shape),e.keyof=()=>aA(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Uk()}),e.loose=()=>e.clone({...e._zod.def,catchall:Uk()}),e.strict=()=>e.clone({...e._zod.def,catchall:Gk()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Xw(e,t),e.safeExtend=t=>Zw(e,t),e.merge=t=>Qw(e,t),e.pick=t=>Jw(e,t),e.omit=t=>Yw(e,t),e.partial=(...t)=>$w(lA,e,t[0]),e.required=(...t)=>eT(_A,e,t[0])});function Jk(e,t){return new qk({type:`object`,shape:e??{},...J(t)})}function Yk(e,t){return new qk({type:`object`,shape:e,catchall:Gk(),...J(t)})}var Xk=q(`ZodUnion`,(e,t)=>{fD.init(e,t),uk.init(e,t),e.options=t.options});function Zk(e,t){return new Xk({type:`union`,options:e,...J(t)})}var Qk=q(`ZodDiscriminatedUnion`,(e,t)=>{Xk.init(e,t),pD.init(e,t)});function $k(e,t,n){return new Qk({type:`union`,options:t,discriminator:e,...J(n)})}var eA=q(`ZodIntersection`,(e,t)=>{mD.init(e,t),uk.init(e,t)});function tA(e,t){return new eA({type:`intersection`,left:e,right:t})}var nA=q(`ZodRecord`,(e,t)=>{_D.init(e,t),uk.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function rA(e,t,n){return new nA({type:`record`,keyType:e,valueType:t,...J(n)})}var iA=q(`ZodEnum`,(e,t)=>{vD.init(e,t),uk.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new iA({...t,checks:[],...J(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new iA({...t,checks:[],...J(r),entries:i})}});function aA(e,t){return new iA({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...J(t)})}var oA=q(`ZodLiteral`,(e,t)=>{yD.init(e,t),uk.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Z(e,t){return new oA({type:`literal`,values:Array.isArray(e)?e:[e],...J(t)})}var sA=q(`ZodTransform`,(e,t)=>{bD.init(e,t),uk.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ww(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(oT(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(oT(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function cA(e){return new sA({type:`transform`,transform:e})}var lA=q(`ZodOptional`,(e,t)=>{SD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function uA(e){return new lA({type:`optional`,innerType:e})}var dA=q(`ZodNullable`,(e,t)=>{CD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function fA(e){return new dA({type:`nullable`,innerType:e})}var pA=q(`ZodDefault`,(e,t)=>{wD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mA(e,t){return new pA({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hw(t)}})}var hA=q(`ZodPrefault`,(e,t)=>{ED.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gA(e,t){return new hA({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hw(t)}})}var _A=q(`ZodNonOptional`,(e,t)=>{DD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function vA(e,t){return new _A({type:`nonoptional`,innerType:e,...J(t)})}var yA=q(`ZodCatch`,(e,t)=>{kD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bA(e,t){return new yA({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var xA=q(`ZodPipe`,(e,t)=>{AD.init(e,t),uk.init(e,t),e.in=t.in,e.out=t.out});function SA(e,t){return new xA({type:`pipe`,in:e,out:t})}var CA=q(`ZodReadonly`,(e,t)=>{MD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function wA(e){return new CA({type:`readonly`,innerType:e})}var TA=q(`ZodLazy`,(e,t)=>{PD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.getter()});function EA(e){return new TA({type:`lazy`,getter:e})}var DA=q(`ZodCustom`,(e,t)=>{FD.init(e,t),uk.init(e,t)});function OA(e,t={}){return zO(DA,e,t)}function kA(e){return BO(e)}function AA(e){let t=EA(()=>Zk([Y(e),Fk(),zk(),Vk(),X(t),rA(Y(),t)]));return t}var jA=_(),MA=[`urgent`,`high`,`medium`,`low`],NA={urgent:`Critical`,high:`High`,medium:`Medium`,low:`Low`},PA={list:`/api/human-items`,item:e=>`/api/human-items/${encodeURIComponent(e)}`,answer:e=>`/api/human-items/${encodeURIComponent(e)}/answer`,complete:e=>`/api/human-items/${encodeURIComponent(e)}/complete`,dismiss:e=>`/api/human-items/${encodeURIComponent(e)}/dismiss`,reopen:e=>`/api/human-items/${encodeURIComponent(e)}/reopen`,note:e=>`/api/human-items/${encodeURIComponent(e)}/note`},FA=Y().nullable(),IA=Y().regex(/\S/u),LA=Yk({session:Y(),run:FA,plan:FA}),RA=$k(`scope`,[Yk({scope:Z(`nothing`)}),Yk({scope:Z(`work`),run:Y(),node:Y()}),Yk({scope:Z(`plan`),plan:Y()}),Yk({scope:Z(`host`)})]),zA=Yk({actor:Y(),on_behalf_of:FA,text:FA,reason:FA});function BA(e){let{kind:t,state:n,resolution:r}=e;return t===`question`&&e.approval!==null?`approval is only valid on tasks`:n===`open`?r===null?void 0:`an open item has no resolution`:r===null?`a resolved item carries its resolution`:n===`answered`?t===`question`&&r.text!==null&&/\S/u.test(r.text)&&r.reason===null?void 0:`an answer is a question's, with text and no reason`:n===`completed`?t===`task`&&(r.text===null||/\S/u.test(r.text))&&r.reason===null?void 0:`a completion is a task's, with no reason and any comment not blank`:r.text===null?void 0:`a dismissal carries no text`}var VA=Yk({schema_version:Z(1),id:Y().min(1),dedup_key:Y(),kind:aA([`task`,`question`]),title:IA,body:IA,priority:aA(MA),owner:LA,block:RA,approval:Yk({board_copy:Y(),key:Y()}).nullable(),state:aA([`open`,`answered`,`completed`,`dismissed`]),resolution:zA.nullable(),tracker:Yk({task:Y(),url:vk()}).nullable(),created_at:Y(),updated_at:Y()}).superRefine((e,t)=>{let n=BA(e);n!==void 0&&t.addIssue({code:`custom`,message:n})}),HA=Yk({run:Y(),node:Y(),title:Y()}),UA=Yk({plan:Y(),count:Fk().int().nonnegative(),preview:X(HA).max(3)}),WA=Yk({total:Fk().int().nonnegative(),plans:X(UA)});function GA(e,t){return!(e.state===`open`&&e.block.scope!==`nothing`)&&(t.total!==0||t.plans.length>0)?`a non-blocking item reports nothing blocked`:new Set(t.plans.map(({plan:e})=>e)).size===t.plans.length?t.plans.some(({count:e,preview:t})=>t.length!==Math.min(e,3))?`a preview is the first three affected steps of its plan`:t.plans.reduce((e,{count:t})=>e+t,0)===t.total?void 0:`the blocked total is the plans' counts`:`a blocked plan appears twice`}var KA=Yk({available:zk(),reason:FA});function qA({dedup_key:e,block:t,owner:n}){return t.scope===`work`&&e===`run:${t.run}#${t.node}`&&n.run===t.run}function JA(e,{available:t,reason:n}){return(t?n!==null:n===null||!/\S/u.test(n))?`a reopen states a reason exactly when it is unavailable`:e.state===`open`||e.state===`answered`||qA(e)||e.resolution?.actor===`engine`?t?`this item's state cannot be reopened`:void 0:t||e.state===`completed`&&e.approval!==null?void 0:`nothing about this item's state refuses a reopen`}var YA=Yk({item:VA,blocked:WA,reopen:KA}).superRefine(({item:e,blocked:t,reopen:n},r)=>{let i=GA(e,t)??JA(e,n);i!==void 0&&r.addIssue({code:`custom`,message:i})});function XA(e){let{blocked:t,nodes:n}=e;if(n.length!==t.total)return`the steps are the blocked total`;if(new Set(n.map(({run:e,node:t})=>`${e}\u0000${t}`)).size!==n.length)return`a blocked step appears twice`;let r=0;for(let{count:e,preview:i}of t.plans){let t=n.slice(r,r+e);if(i.some((e,n)=>t[n]?.run!==e.run||t[n]?.node!==e.node))return`a preview is the first steps of its plan's group`;r+=e}}var ZA=Yk({item:VA,blocked:WA,nodes:X(HA),reopen:KA}).superRefine((e,t)=>{let n=GA(e.item,e.blocked)??JA(e.item,e.reopen)??XA(e);n!==void 0&&t.addIssue({code:`custom`,message:n})}),QA=Yk({item:YA,event_id:Y()}),$A=Yk({items:X(YA)}),ej=Yk({kind:aA([`task`,`question`]).nullable().optional(),blocking:zk().nullable().optional(),priority:aA(MA).nullable().optional(),state:aA([`open`,`answered`,`completed`,`dismissed`]).nullable().optional(),session:Y().nullable().optional(),run:Y().nullable().optional(),plan:Y().nullable().optional(),host:zk().nullable().optional()}),tj=Yk({type:Z(`human-items`),items:X(YA),detail:ZA.nullable()}),nj=Fk().finite().nonnegative(),rj=Fk().int().nonnegative(),ij=UO({offset:!0}),aj=Y().min(1).nullable(),Q=e=>Jk(e).catchall(Uk()),oj={runs:`/api/v2/runs`,run:e=>`/api/v2/runs/${encodeURIComponent(e)}`,timeline:e=>`/api/v2/runs/${encodeURIComponent(e)}/timeline`,conversation:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,artifact:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}`,events:`/api/v2/events`,projects:`/api/v2/projects`,project:e=>`/api/v2/projects/${encodeURIComponent(e)}`,channel:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel`,channelNext:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/next`,channelReply:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/reply`,channelSurface:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/surface`,attest:e=>`/api/v2/runs/${encodeURIComponent(e)}/attest`,stop:e=>`/api/v2/runs/${encodeURIComponent(e)}/stop`,shutdown:`/api/v2/shutdown`,unwatched:`/api/v2/unwatched`,host:`/api/v2/host`,status:e=>`/api/v2/runs/${encodeURIComponent(e)}/status`,results:e=>`/api/v2/runs/${encodeURIComponent(e)}/results`,goals:`/api/v2/goals`,runGoals:e=>`/api/v2/runs/${encodeURIComponent(e)}/goals`,transcript:e=>`/api/v2/runs/${encodeURIComponent(e)}/transcript`,telemetry:e=>`/api/v2/runs/${encodeURIComponent(e)}/telemetry`,agents:e=>`/api/v2/runs/${encodeURIComponent(e)}/agents`,nodeAgents:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}/agents`,projectAgents:e=>`/api/v2/projects/${encodeURIComponent(e)}/agents`,subscriptions:`/api/v2/subscriptions`,subscription:e=>`/api/v2/subscriptions/${encodeURIComponent(e)}`},sj={includeSettled:`include_settled`,includeConversations:`include_conversations`,runId:`run_id`,after:`after`,cursor:`cursor`,limit:`limit`,select:`select`,node:`node`,scope:`scope`,filter:`filter`,correlation:`correlation`,until:`until`,timeout:`timeout`,subscription:`subscription`,tick:`tick`},cj={run:`run`,node:`node`},lj={planner:`planner`,detailed:`detailed`},uj=aA([`complete`,`partial`,`legacy`]),dj=aA([`native`,`labelled`,`inferred`]),fj=Q({agent_model_ms:zk(),judge_model_ms:zk(),llmlint_model_ms:zk(),tool_ms:zk()}),pj=nj.nullable(),mj=rj.nullable(),hj=Q({agent_seconds:pj,judge_seconds:pj,llmlint_seconds:pj,gate_seconds:pj,publication_wait_seconds:pj,lock_wait_seconds:pj,setup_seconds:pj,scheduling_seconds:pj,wall_seconds:pj,agent_model_ms:mj,judge_model_ms:mj,llmlint_model_ms:mj,tool_ms:mj,idle_orchestration_ms:mj,unattributed_ms:mj,wall_ms:mj,fractions:Q({agent_model:pj,judge_model:pj,llmlint_model:pj,tool:pj,idle_orchestration:pj,lock_wait:pj,setup:pj,scheduling:pj})}),gj=Y().regex(/^[A-Za-z0-9_-]+$/,`a member name: letters, digits, hyphens and underscores`),_j=aA([`agent`,`judge`,`llmlint`]),vj=nj.nullable(),yj=Q({input_tokens:vj,output_tokens:vj,cache_read_tokens:vj,cache_write_tokens:vj,cost_usd:vj}),bj=Q({agent:yj,judge:yj,llmlint:yj,total:yj}),xj=Q({session_id:Y().min(1),history_id:Y().min(1).nullable().optional(),role:_j,agent_role:gj.optional(),turn_index:rj.nullable().optional(),started_at:ij.optional(),finished_at:ij.nullable().optional()}),Sj=rA(Y(),Uk()),Cj=aA([`agent`,`gate`,`checks`,`publication`,`timeout`,`provider`,`configuration`,`unknown`]),wj=aA([`agent`,`judge`,`llmlint`]),Tj=aA([`quota_at_launch`,`quota_mid_conversation`,`stale_session_resume`,`rate_limit`,`harness_exit`]),Ej=Q({side:wj.optional(),harness:Y().optional(),variant:Y().optional(),identity:Y().optional(),cause:Tj.optional(),raw_tail:Y().optional(),reset_time:Y().optional(),missing_session_id:Y().optional(),wait_seconds:Fk().nonnegative().optional(),failure_kind:Y().optional(),structured_error:Sj.optional(),judge_unrecorded:zk().optional()}).extend({class:Cj,detail:Y().optional()}),Dj=Q({node:Y().min(1),status:Y().min(1),outcome:Y().min(1).optional(),branch:Y().min(1).optional(),comparison_remote:Y().min(1).optional(),comparison_base:Y().min(1).optional(),checkpoint:Y().min(1).optional(),commit:Y().min(1).optional(),retry_lineage:Sj.optional(),gate_attestation:Sj.optional(),failure:Ej.optional(),timing:hj.optional(),usage:bj.optional(),sessions:X(xj),tool_commands:rA(Y(),rj).optional(),turns:rj,lint:rj,timing_quality:uj,linkage_quality:dj,timing_presence:fj}),Oj=Q({run_id:Y().min(1),state:Y().min(1),phase:Y().min(1),last_event:aj,last_progress_at:nj.optional(),timing:hj,nodes:X(Dj),providers:X(Sj).optional(),failure:Ej.optional(),check_rollup:Sj.optional(),usage:bj,timing_quality:uj,linkage_quality:dj,timing_presence:fj,sources:X(Y()),node_work_ms:Q({agent_model_ms:mj,judge_model_ms:mj,llmlint_model_ms:mj,tool_ms:mj,wall_ms:mj}),turns:rj,lint:rj,agent_count:rj.optional()}),kj=Q({schema_version:Zk([Y(),Fk()]).optional(),observed_at:Y().optional(),identities:X(Sj)}),Aj=Q({started_at:ij.optional(),launch_id:Y().min(1),launcher:aA([`claude-code`,`codex`,`unknown`]),session_key:Y().min(1).optional(),launcher_session_id:Y().min(1).optional()}),jj=Y().min(1),Mj=Q({labels:rA(Y(),Y()).optional(),group:Y().min(1).optional(),run_id:Y().min(1),state:Y().min(1),phase:Y().min(1),last_event:aj,last_progress_at:nj.optional(),timing_quality:uj,linkage_quality:dj,timing:hj,node_counts:rA(Y(),rj),launch:Aj.optional(),project:Y().min(1).optional(),project_name:Y().min(1).optional(),liveness:jj.optional(),unread_surfaces:rj.optional()}),Nj=Q({path:Y().min(1),reason:Y().min(1)}),Pj=Q({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:ij,runs:X(Mj),next_cursor:Y().min(1).optional(),unreadable:X(Nj).optional(),missing:X(Y().min(1)).optional(),provider_health:kj.optional()}),Fj=Q({id:Y().min(1),kind:aA([`agent`,`human`]).optional(),persona:Y().min(1).optional(),task:Y().min(1),deps:X(Y().min(1)).optional(),max_turns:rj.positive().optional(),expects_no_diff:zk().optional()}),Ij=Q({branch:Y().min(1),base_branch:Y().min(1),pr_base:Y().min(1),checkpoint:Y().min(1),completed_steps:X(Y()).optional(),pr:Y().nullable().optional(),mode:aA([`pause`,`retry`,`continue`]).optional(),attempts:rj.optional()}),Lj=Q({branch:Y().min(1),repo:Y().min(1).optional(),identity:Y().min(1).optional(),base_branch:Y().min(1).optional(),pr:Y().min(1).optional(),pr_base:Y().min(1).optional()}),Rj=X(Y()),zj=Fj.extend({task:Y().min(1).optional(),repo:Y().min(1).optional(),steps:X(Fj).min(1).optional(),session:Y().min(1).optional(),project_dir:Y().min(1).optional(),base_branch:Y().min(1).optional(),branch:Y().min(1).optional(),title:Y().min(1).optional(),verify_cmd:Y().min(1).optional(),skip_verify:zk().optional(),verify_via_ci:zk().optional(),merge_policy:aA([`auto`,`direct`,`none`]).optional(),workflow:aA([`local`,`remote`]).optional(),repo_type:aA([`single-owner`,`team`]).optional(),execution_checkout:Y().min(1).optional(),stack_bases:X(Lj).optional(),resume:Ij.optional(),sets:Rj.optional()}).superRefine((e,t)=>{e.steps===void 0&&e.task===void 0&&t.addIssue({code:`custom`,path:[`task`],message:"a plan task without `steps` must carry its own `task` prose"})}),Bj=Q({gate_log:Y().optional(),worker_report:Y().optional(),oneharness_session:Y().optional()}),Vj=Q({id:Y().min(1),kind:Y().min(1),persona:Y().nullable(),status:Y().min(1),telemetry:Sj.optional(),artifacts:Bj.optional()}),Hj=Q({ref:Y().min(1),task:Y(),unblocks:X(Y()),unblocks_publication:zk()}),Uj=Q({branch:Y().min(1),base_branch:Y().min(1),pr_base:Y(),checkpoint:Y().min(1),completed_steps:X(Y()),pr:Y().nullable(),mode:Y().optional()}),Wj=Q({identity:Y().min(1),target:Y().min(1),style:Y().min(1).optional(),version:Y().min(1)}),Gj=Q({producer:Y().min(1),target:Y().min(1)}),Kj=Q({kind:Y().optional(),status:Y().optional(),task:Y().optional(),unblocks:X(Y()).optional(),blocked_by:X(Y()).optional(),human_actions:X(Hj).optional(),completed:zk().optional(),exit_code:Fk().int().nullable().optional(),verdicts:X(Uk()).optional(),usage:Sj.optional(),telemetry:Sj.optional(),repo:Y().optional(),branch:Y().optional(),commit:Y().optional(),base_branch:Y().optional(),pr_base:Y().optional(),synthetic_stack_base:Y().nullable().optional(),stack_bases:X(Sj).optional(),repository_type:aA([`single-owner`,`team`]).nullable().optional(),repo_type:aA([`single-owner`,`team`]).nullable().optional(),publication_workflow:aA([`local`,`remote`]).nullable().optional(),workflow:aA([`local`,`remote`]).nullable().optional(),merge_policy:aA([`auto`,`direct`,`none`]).nullable().optional(),outcome:Y().optional(),ok:zk().optional(),pr:Y().nullable().optional(),release:Wj.nullable().optional(),awaiting:X(Gj).min(1).optional(),detail:Y().optional(),follow_ups:Y().nullable().optional(),steps:X(Vj).optional(),waiting_steps:X(Y()).optional(),resume:Uj.nullable().optional(),error:Y().nullable().optional(),retry_lineage:Sj.optional(),deferred_cleanup:X(Y()).optional(),artifacts:Bj.optional()}),qj=Q({ok:zk().optional(),state:Y().optional(),started_order:X(Y()).optional(),results:rA(Y(),Kj).optional(),schema_version:rj.optional()}),Jj=aA([`running`,`done`,`failed`,`waiting`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`]),Yj=aA([`pending`,`ready`,`running`,`waiting`,`blocked`,`skipped`,`done`,`not-completed`,`failed`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`,`unknown`]),Xj=Q({addressable:zk(),member:Y().min(1).optional(),reason:Y().min(1).optional()}).superRefine((e,t)=>{e.addressable===(e.reason!==void 0)&&t.addIssue({code:`custom`,path:[`reason`],message:`a reason is carried exactly when there is no turn to address`})}),Zj=Q({id:Y().min(1),kind:Y(),unblocks:X(Y().min(1))}),Qj=Q({run_id:Y().min(1),plan:Q({tasks:X(zj),schema_version:rj.optional(),concurrency:rj.positive().optional(),name:Y().min(1).optional(),goal:Q({id:Y().min(1),text:Y().min(1)}).optional()}),node_states:rA(Y(),Jj),node_status:rA(Y(),Yj),node_gated_by:rA(Y(),X(Y().min(1))),node_control:rA(Y(),Xj),node_results:rA(Y(),Kj),decisions:X(Zj),attestations:X(Y()),result:qj.nullable(),last_seq:rj,run_node_sets:Rj.optional()}).superRefine((e,t)=>{let n=new Set(e.plan.tasks.map(e=>e.id)),r=new Set(Object.keys(e.node_status));(n.size!==e.plan.tasks.length||n.size!==r.size||[...n].some(e=>!r.has(e)))&&t.addIssue({code:`custom`,path:[`node_status`],message:`must contain exactly one entry for every plan task`}),Object.entries(e.node_gated_by).find(([e,t])=>!n.has(e)||t.some(e=>!n.has(e)))&&t.addIssue({code:`custom`,path:[`node_gated_by`],message:`must name only nodes in this graph's plan`}),Object.keys(e.node_control).find(t=>e.node_status[t]!==`running`)!==void 0&&t.addIssue({code:`custom`,path:[`node_control`],message:`must name only nodes the run has in flight`})}),$j=Q({cacheReadTokens:vj.optional(),cacheWriteTokens:vj.optional(),costUsd:vj.optional(),inputTokens:vj.optional(),outputTokens:vj.optional()}),eM=Q({index:rj,input:Uk().optional(),kind:Y(),name:Y().nullable().optional(),output:Y().nullable().optional(),toolCallId:Y().min(1).optional(),output_truncated:Z(!0).optional(),input_truncated:Z(!0).optional()}),tM=Q({judge:Y(),kind:Y(),decision:Y(),reason:Y()}),nM=Q({assistant:Y().nullable(),durationMs:vj.optional(),failureKind:Y().nullable(),finishedAt:ij.nullable().optional(),harness:Y(),id:Y(),judges:X(tM).optional(),model:Y().nullable(),modelMs:vj.optional(),reasoning:Y().nullable(),startedAt:ij.nullable().optional(),status:Y(),timestamp:ij,toolMs:vj.optional(),tools:X(eM),unknown:Sj,usage:$j,user:Y()}),rM=Q({conversation:Q({canContinue:zk(),harnesses:X(Y()),id:Y().min(1),name:Y(),project:Y(),startedAt:ij,state:Y(),turns:X(nM)}),attribution:Q({runId:Y().optional(),nodeId:Y().optional(),stepId:Y().optional(),launchId:Y().optional(),launcher:aA([`claude-code`,`codex`,`unknown`]).optional(),transportRole:_j,agentRole:gj.optional(),parentConversationId:Y().optional(),persona:Y().optional(),finishedAt:ij.nullable().optional(),inferred:Z(!0).optional(),timing:hj.optional()})}),iM=Q({node:Y().optional(),conversations:X(rM)}),aM=Zk([X(rM),X(iM).transform(e=>e.flatMap(e=>e.conversations))]),oM=Q({name:Y(),state:Y(),status:Y().optional(),conclusion:Y().optional(),started_at:ij.optional(),completed_at:ij.optional(),required:zk(),requirement:Y().optional(),url:Y().url().nullable().optional()}),sM=Q({ok:zk(),output_tail:Y(),artifact_id:Y().min(1).optional()}),cM=Q({verification:Q({pre_push_hook:zk().optional(),required_checks:X(Y()).optional(),required_checks_status:Y().optional(),expected_gate:X(Y()).optional(),checks:X(oM).optional(),records:X(sM)}),publication:Q({pr_url:Y().url().optional(),branch:Y().optional(),branch_url:Y().url().optional(),merged:zk(),base_branch:Y().optional(),commit:Y().optional(),commit_url:Y().url().optional()}).optional()}),lM=X(Jk({event_id:Y().min(1),node:Y().min(1),step:Y().min(1).optional(),at:Fk().finite(),kind:Y(),name:Y(),detail:Y(),description:Y(),events:Fk().int().nonnegative()})),uM=Q({telemetry:Q({schema_version:rj}).optional(),api_version:Z(2),telemetry_schema_version:Z(27),observed_at:ij,run:Oj.extend({live_activity:lM.optional()}),graph:Qj.nullable(),conversations:aM,node_details:rA(Y(),cM).optional().default({}),launch:Aj.optional(),provider_health:kj.optional()}),dM=aA([`conversation`,`gate_log`,`worker_report`,`oneharness_session`,`pr`]),fM=aA([`run`,`node`,`step`,`dispatch`,`verification`,`publication`,`pr-drafting`,`conflict-resolution`,`human-wait`,`rollup`,`queued`]),pM=aA([`starting`,`dispatching`,`deciding`,`surfacing`,`waiting`,`settled`,`finished`]),mM=Q({kind:dM,value:Y().min(1)}),hM=Q({delivered:zk(),delivery:aA([`live`,`deferred`]).optional(),reached:aA([`queued`,`worker`,`supervisor`,`judged-with`,`carried`]).optional(),turn:aA([`interrupted`,`turn-end`]).optional(),member:Y().min(1).optional(),input_bytes:rj.optional(),reason:Y().min(1).optional(),node_id:Y().min(1).optional()}).superRefine((e,t)=>{e.delivered&&e.reason!==void 0&&t.addIssue({code:`custom`,path:[`reason`],message:`a delivered redirection carries no reason it did not land`}),e.delivery!==void 0&&e.delivered!==(e.delivery===`live`)&&t.addIssue({code:`custom`,path:[`delivery`],message:"`delivery` is `live` exactly when the running turn took the note"})}),gM=Q({dep:Y().min(1),identity:Y().min(1).optional(),target:Y().min(1).optional(),style:Y().min(1).optional(),action:Y().min(1).optional(),since:ij.optional(),waited_seconds:rj.optional(),last_answer:Y().min(1).optional()}),_M=Q({kind:Y().min(1).optional(),message:Y().min(1).optional(),source:Y().min(1).optional(),blocking:zk().optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a surface record carries at least one recorded fact`})}),vM=Q({name:Y().min(1).optional(),required:zk().optional(),requirement:Y().optional(),url:Y().nullable().optional(),state:Y().min(1).optional(),kind:Y().min(1).optional(),base:Y().min(1).optional(),awaited:X(Y().min(1)).optional(),grace_seconds:Fk().nonnegative().optional(),warned:zk().optional(),head:Y().min(1).optional(),verdict:Y().min(1).optional(),skipped:X(Y().min(1)).optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a review record carries at least one recorded fact`})}),yM=Q({identity:Y().min(1).optional(),target:Y().min(1).optional(),style:Y().min(1).optional(),version:Y().min(1).optional(),landing_commit:Y().min(1).optional(),actor:Y().min(1).optional(),superseded:zk().optional(),form:Y().min(1).optional(),outcome:Y().min(1).optional(),elapsed_ms:rj.optional(),dep:Y().min(1).optional(),delivery:Y().min(1).optional(),awaiting:X(gM).min(1).optional(),versions:X(Q({identity:Y().min(1),target:Y().min(1),version:Y().min(1)})).min(1).optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a release record carries at least one recorded fact`})}),bM=Q({id:Y().min(1),label:Y().min(1),order:rj,started_at:ij}),xM=Q({id:Y().min(1),stream:Y().min(1).optional(),seq:rj.optional(),journal_order:rj.optional(),record_id:Y().min(1).optional(),persona:Y().min(1).optional(),dispatch_id:Y().min(1).optional(),dispatch_group:bM.optional(),fields:rA(Y().min(1),AA()).optional(),kind:Y().min(1),at:ij,node_id:Y().min(1).optional(),step_id:Y().min(1).optional(),status:Y().min(1).optional(),author:Y().min(1).optional(),redirection:hM.optional(),release:yM.optional(),surface:_M.optional(),review:vM.optional(),reference:mM.optional(),description:Y().optional(),tool:Q({index:rj,tool_call_id:Y().min(1).optional(),turn:Y().min(1).optional()}).optional()}),SM=Q({started_at:ij,ended_at:ij}),CM=Q({kind:Y().min(1),blocking:X(Y().min(1)).min(1).optional(),ahead:X(Y().min(1)).min(1).optional(),limit:rj.optional(),reference:Y().min(1).optional(),awaiting:X(Y().min(1)).min(1).optional()}),wM=Q({id:Y().min(1),kind:fM,label:Y(),started_at:ij,ended_at:ij.nullable(),events:X(xM),parent_id:Y().min(1).optional(),node_id:Y().min(1).optional(),step_id:Y().min(1).optional(),status:Y().min(1).optional(),count:rj.optional(),total_duration_ms:rj.optional(),intervals:X(SM).optional(),harness_scope:Y().min(1).optional(),dispatch_attempt:Y().min(1).optional(),agent_role:gj.optional(),transport_role:_j.optional(),dispatch_id:Y().min(1).optional(),dispatch_group:bM.optional(),reference:mM.optional(),detail:Q({ok:zk().optional(),output_tail:Y().optional(),artifact_id:Y().optional()}).optional(),phase:pM.optional(),reasons:X(CM).min(1).optional()}).superRefine((e,t)=>{e.reasons!==void 0&&e.kind!==`queued`&&t.addIssue({code:`custom`,path:[`reasons`],message:`only a queued span carries the reasons a node was held`})}),TM=Q({id:Y().min(1),kind:dM,content:Y(),truncated:zk(),turns:X(nM).optional(),unavailable:Y().optional()}),EM=Q({api_version:Z(2),timeline_schema_version:Z(15),observed_at:ij,run_id:Y().min(1),spans:X(wM)}),DM=Q({error:Q({code:Y(),message:Y()})});Q({schema_version:Z(1),launch_id:Y().min(1),launcher:aA([`claude-code`,`codex`]),launcher_session_id:Y().min(1),started_at:ij,repository_identity:Y().min(1)});var OM=aA([`snapshot`,`run.changed`,`conversation.changed`,`activity.changed`,`run.removed`]),kM=Sj;function AM(e){let t=e.indexOf(`:`);if(t===-1)return!1;let n=e.slice(0,t),r=e.slice(t+1);return/^[a-z0-9][a-z0-9-]*$/u.test(n)&&r.length>0&&r.length<=128&&!r.startsWith(`.`)&&/^[A-Za-z0-9._-]+$/u.test(r)}var jM=Q({project:Y().min(1).nullable(),name:Y().min(1).nullable(),last_write_at:nj.nullable(),runs:X(Mj),agent_count:rj.optional()}),MM=Q({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:ij,projects:X(jM),unreadable:X(Nj).optional()}),NM=jM.extend({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:ij}),PM={api_version:Z(2),telemetry_schema_version:Z(27),observed_at:ij},FM=Q({id:rj,correlation:Y().min(1).optional(),kind:Y().min(1),message:Y(),source:Y().min(1),blocking:zk(),queued_at:nj,workstream:Y().min(1).optional(),abandoned:zk().optional()}),IM=aA([`worker`,`supervisor`,`both`]),LM=aA([`live`,`next`]),RM=aA([`detach`,`drop`]),zM=aA([`done`,`failed`]),BM=Q({sets:Rj.optional()}),VM=$k(`op`,[Jk({op:Z(`add`),node:zj}).strict(),Jk({op:Z(`drop`),id:Y().min(1),dependents:RM,reason:Y().min(1).optional()}).strict(),Jk({op:Z(`reparent`),id:Y().min(1),deps:X(Y().min(1))}).strict(),Jk({op:Z(`retry`),id:Y().min(1),node:zj}).strict(),Jk({op:Z(`cancel`),id:Y().min(1),reason:Y().min(1).optional()}).strict(),Jk({op:Z(`requeue`),id:Y().min(1),amend:BM.optional()}).strict(),Jk({op:Z(`set-node-sets`),id:Y().min(1),sets:Rj}).strict(),Jk({op:Z(`set-run-node-sets`),sets:Rj}).strict(),Jk({op:Z(`attest`),ref:Y().min(1)}).strict(),Jk({op:Z(`complete`),reason:Y().min(1)}).strict(),Jk({op:Z(`amend`),id:Y().min(1),text:Y().min(1)}).strict(),Jk({op:Z(`note`),id:Y().min(1),addressee:IM,text:Y().min(1),criterion:Y().min(1).optional(),deliver:LM.optional(),persist:zk().optional(),delivery_timeout_seconds:Fk().int().positive().optional()}).strict(),Jk({op:Z(`withdraw-note`),envelope:Y().min(1),index:Fk().int().nonnegative(),reason:Y().min(1)}).strict(),Jk({op:Z(`finding`),message:Y().min(1),blocking:zk().optional(),id:Y().min(1).optional()}).strict(),Jk({op:Z(`settle`),id:Y().min(1),outcome:zM,evidence:Y().min(1),landing:Y().min(1).optional(),release:Jk({target:Y().min(1),version:Y().min(1)}).strict().optional()}).strict(),Jk({op:Z(`rework`),id:Y().min(1),reason:Y().min(1),instruction:Y().min(1),comments:X(Jk({id:Y(),url:Y()}).strict()).optional(),title:Y().optional(),replacement:Y().optional()}).strict(),Jk({op:Z(`retitle`),id:Y().min(1),title:Y().min(1),reason:Y().min(1)}).strict(),Jk({op:Z(`review`)}).strict(),Jk({op:Z(`readjust`)}).strict(),Jk({op:Z(`decline`),id:Y().min(1),comments:X(Jk({id:Y(),url:Y()}).strict()),reason:Y().min(1)}).strict()]),HM=VM.options.map(e=>e.shape.op.value),UM=Jk({version:rj.optional(),author:Y().min(1).optional(),completion:zk().optional(),message:Y().optional(),reason:Y().optional(),commands:X(VM).optional()}).strict().superRefine((e,t)=>{e.commands!==void 0&&e.commands.length>0&&e.version!==3&&t.addIssue({code:`custom`,path:[`version`],message:`an edit envelope requires version 3`})}),WM=Q({id:rj,reply:Sj,at:nj,correlation:Y().min(1).optional()}),GM=Q({id:rj,author:Y().min(1).optional(),commands:X(Sj)}),KM=Q({op:Y().min(1).optional(),outcome:Y().min(1).optional(),reason:Y().optional()}),qM=Q({id:rj,applied:zk(),reason:Y().optional(),results:X(KM).optional()}),JM=Q({...PM,run_id:Y().min(1),surfaces:X(FM),waiting:X(FM),held:FM.nullable(),replies:X(WM),commands:X(GM),outcomes:X(qM)}),YM=aA([`surface`,`running`,`finished`]),XM=Q({...PM,run_id:Y().min(1),status:YM,surface:FM.nullable(),events:X(Sj)}),ZM=Q({...PM,run_id:Y().min(1),receipt:Q({reply:rj,state:Y().min(1),verdict:Y().min(1).optional(),commands:Y().min(1).optional()}),advice:X(Y())}),QM=Q({...PM,run_id:Y().min(1),surface:rj,state:Y().min(1)}),$M=Q({...PM,run_id:Y().min(1),stopped:zk(),owner:Y().min(1),forced:zk(),teardown:Y().min(1)}),eN=aA([`host`]);aA([`host`]);var tN=aA([`delivered`,`no-turn`,`failed`,`not-asked`]),nN=aA([`graceful`,`killed`,`still-running`]),rN=aA([`pushed`,`already-on-origin`,`no-remote`,`refused`]),iN=Q({...PM,scope:eN,root:Y(),grace_seconds:rj,forced:zk(),complete:zk(),runs:X(Q({run_id:Y().min(1),owner:Y().min(1),forced_over_owner:zk(),dispatches:X(Q({node:Y().min(1),pid:rj,interrupt:tN,detail:Y(),ended:nN,waited_ms:rj})),teardown:Y().min(1),branches:X(Q({identity:Y(),branch:Y(),result:rN,remote:Y().nullable(),commit:Y().nullable(),detail:Y()}))})),not_pushed:X(Q({identity:Y(),branch:Y()})),not_pushed_unread:Y().nullable(),rendered:Y()}),aN=Q({...PM,session_key:Y().min(1).optional(),reported:X(Q({run:Y().min(1),standing:Y().min(1),why_not_watched:Y()})),unresolved:X(Y())}),oN=Q({schema_version:Z(1),host:Y(),root:Y(),root_error:Y().nullable(),free_space:X(Q({roots:X(Q({role:Y(),path:Y().nullable(),measured_at:Y().nullable()})),free_bytes:rj.nullable(),total_bytes:rj.nullable(),error:Y().nullable()})),dispatches:X(Q({run:Y(),node:Y(),launcher:Y(),age_ms:nj.nullable(),proof:aA([`held`,`unproven`]),unproven:Y().nullable()})),gone:X(Q({run:Y(),node:Y(),reason:Y()})),skipped:X(Q({path:Y(),reason:Y()}))}),sN=Q({...PM,reading:oN.optional(),rendered:Y(),unreadable:X(Nj).optional()});Q({...PM,run_id:Y().min(1),rendered:Y()});var cN=Q({...PM,run_id:Y().min(1),liveness:jj,unread_surfaces:Q({count:rj,oldest_seconds:nj.nullable()}),node_status:rA(Y(),Y().min(1)),summary:Y(),rendered:Y()});Q({...PM,run_id:Y().min(1),node:Y().min(1).nullable().optional(),rendered:Y()}),Q({...PM,run_id:Y().min(1),telemetry:Q({schema_version:rj})});var lN=Q({history_id:Y().min(1),harness:Y().min(1),variant:Y().min(1).optional(),harness_id:Y().min(1),started:ij}),uN=Q({history_session:Y().min(1),name:Y().min(1),history_dir:Y().min(1),history_project:Y().min(1),history_file:Y().min(1),project:Y().min(1),started:ij,labels:rA(Y(),Y()),runs:X(lN),run_id:Y().min(1).optional()}),dN={...PM,sessions:X(uN),skipped:rj},fN=Q({...dN,run_id:Y().min(1),node:Y().min(1).optional()}),pN=Q({...dN,project:Y().min(1)}),mN=Y().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u),hN=Y().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:(0|[1-9][0-9]*)$/u),gN=Zk([Yk({type:Z(`sidebar`)}),Yk({type:Z(`detail`),run_id:Y().min(1),filter:Y().min(1).optional()}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`run`),filter:Y().min(1).optional()}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),filter:Y().min(1).optional()}),Yk({type:Z(`channel`),run_id:Y().min(1)}),Yk({type:Z(`human-items`),filter:ej.optional(),item:Y().min(1).optional()})]),_N=Yk({id:Y().min(1),name:Y(),group:Yk({project:Y(),name:Y()}).nullable(),kind:Y().nullable(),state:Y().min(1),nodes:Yk({total:rj,done:rj,failed:rj,running:rj}),updated_at:ij,started_at:ij.optional()});Object.keys(_N.shape);var vN=Zk([Yk({type:Z(`sidebar`)}),Yk({type:Z(`detail`),run_id:Y().min(1),detail:uM}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`run`),detail:uM,timeline:EM}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),detail:uM,timeline:EM}),Yk({type:Z(`channel`),run_id:Y().min(1),detail:uM,channel:JM}),tj]),yN=Yk({id:hN,sidebar:X(_N),visible:vN}),bN=X(Zk([Y(),rj])),xN=Zk([Yk({p:bN,v:Uk()}),Yk({p:bN,a:X(Uk())}),Yk({p:bN,d:Z(!0)})]),SN={id:hN,base:hN,subscription:mN},CN=aA([`unknown-cursor`,`stale-cursor`,`server-restarted`]),wN=Yk({...SN,type:Z(`reset`),reason:CN,snapshot:yN}),TN=Zk([wN,Yk({...SN,type:Z(`run.changed`),row:_N}),Yk({...SN,type:Z(`run.removed`),run_id:Y().min(1)}),Yk({...SN,type:Z(`detail.patch`),run_id:Y().min(1),ops:X(xN)}),Yk({...SN,type:Z(`timeline.patch`),run_id:Y().min(1),scope:Z(`run`),ops:X(xN)}),Yk({...SN,type:Z(`timeline.patch`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),ops:X(xN)}),Yk({...SN,type:Z(`channel.patch`),run_id:Y().min(1),ops:X(xN)}),Yk({...SN,type:Z(`human-items.patch`),ops:X(xN)})]),EN=[`reset`,`run.changed`,`run.removed`,`detail.patch`,`timeline.patch`,`channel.patch`,`human-items.patch`],DN=Yk({subscription:mN,view:gN,initial:Zk([Yk({type:Z(`snapshot`),snapshot:yN}),wN])});Yk({code:Z(`subscription-unavailable`),reason:aA([`expired`,`server-restarted`,`unknown`])});var ON=class extends Error{constructor(e){super(e),this.name=`PatchError`}};function kN(e,t){let n=e;for(let e of t)n=AN(n,e);return n}function AN(e,t){let n=t.p;if(`a`in t)return MN(e,n,e=>{if(!Array.isArray(e))throw new ON(`an append's path names an array`);return[...e,...t.a]});let r=n.at(-1);if(r===void 0)throw new ON(`the root is never replaced or deleted`);return MN(e,n.slice(0,-1),e=>{if(`v`in t){if(Array.isArray(e)&&typeof r==`number`){if(r>=e.length)throw new ON(`a set replaces an existing element`);let n=[...e];return n[r]=t.v,n}if(jN(e)&&typeof r==`string`)return{...e,[r]:t.v};throw new ON(`a set's path does not match its parent`)}if(jN(e)&&typeof r==`string`){if(!Object.hasOwn(e,r))throw new ON(`a deletion names an existing member`);let t={...e};return delete t[r],t}throw new ON(`a deletion names an object member`)})}function jN(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function MN(e,t,n){let[r,...i]=t;if(r===void 0)return n(e);if(Array.isArray(e)&&typeof r==`number`){if(r>=e.length)throw new ON(`an index on the path does not exist`);let t=[...e];return t[r]=MN(e[r],i,n),t}if(jN(e)&&typeof r==`string`){if(!Object.hasOwn(e,r))throw new ON(`a parent on the path does not exist`);return{...e,[r]:MN(e[r],i,n)}}throw new ON(`a path step does not match its parent`)}var NN=1e3;function PN(e){let t=e.lastIndexOf(`:`);return{epoch:e.slice(0,t),seq:BigInt(e.slice(t+1))}}var FN=class{#e;#t;#n;#r;#i;#a;#o;#s=!1;#c=!1;#l=0;#u;#d=()=>{this.#_(),this.#t.onDisconnected?.()};#f=()=>this.#g();#p=()=>this.close(!0);constructor(e,t){this.#e=e,this.#t=t,this.#n=t.view,this.#u=t.paused??!1,globalThis.addEventListener?.(`offline`,this.#d),globalThis.addEventListener?.(`online`,this.#f),globalThis.addEventListener?.(`pagehide`,this.#p),this.#m({})}get view(){return this.#n}change(e){this.#s||GN(e,this.#n)||(this.#n=e,this.#c=!1,this.#_(),this.#m(this.#r===void 0?{}:{replaces:this.#r}))}pause(){this.#u||(this.#u=!0,this.#_())}resume(){this.#u&&(this.#u=!1,this.#g())}close(e=!1){this.#s||(this.#s=!0,this.#l+=1,globalThis.removeEventListener?.(`offline`,this.#d),globalThis.removeEventListener?.(`online`,this.#f),globalThis.removeEventListener?.(`pagehide`,this.#p),this.#_(),this.#r!==void 0&&this.#e.retire(this.#r,e).catch(()=>void 0))}async#m(e){let t=++this.#l,n;try{n=await this.#e.subscribe({view:this.#n,...e})}catch(e){if(t!==this.#l)return;this.#t.onError?.(qN(e));return}if(t!==this.#l||this.#s){this.#e.retire(n.subscription).catch(()=>void 0);return}let r=WN(this.#n,n);if(r!==void 0){this.#b(Error(`The subscription answered ${r}`));return}this.#r=n.subscription;let i=n.initial;if(i.type===`snapshot`)this.#h(i.snapshot,{kind:`snapshot`});else if(i.subscription!==n.subscription||i.snapshot.id!==i.id){this.#b(Error(`A recreated subscription's reset is not its own snapshot`));return}else this.#h(i.snapshot,{kind:`reset`,reason:i.reason});this.#g()}#h(e,t){this.#i={sidebar:e.sidebar,visible:e.visible,applied:e.id},this.#t.onState(this.#i,t)}#g(){if(this.#s||this.#c||this.#u||this.#a!==void 0||this.#r===void 0||this.#i===void 0)return;this.#o!==void 0&&clearTimeout(this.#o),this.#o=void 0;let e=this.#e.url(oj.events);e.searchParams.set(sj.subscription,this.#r),e.searchParams.set(sj.after,this.#i.applied);let t=this.#e.open(e);this.#a=t;let n=!1;t.onopen=()=>{n&&this.#t.onConnected?.(),n=!0};for(let e of EN)t.addEventListener(e,n=>{this.#a===t&&n instanceof MessageEvent&&typeof n.data==`string`&&this.#y(n.data,e,n.lastEventId)});t.onerror=()=>{this.#a===t&&(this.#t.onDisconnected?.(),t.readyState===2&&(this.#a=void 0,this.#o=setTimeout(()=>{this.#o=void 0,!(this.#s||this.#c||this.#i===void 0)&&this.#m({resume:this.#i.applied})},NN)))}}#_(){this.#a?.close(),this.#a=void 0,this.#o!==void 0&&clearTimeout(this.#o),this.#o=void 0}#v(){this.#_(),this.#g()}#y(e,t,n){let r=this.#i;if(r===void 0||this.#c)return;let i;try{i=TN.parse(JSON.parse(e))}catch(e){this.#b(Error(`A frame failed contract validation: ${KN(e)}`));return}if(i.subscription!==this.#r)return;if(i.type!==t||i.id!==n){this.#b(Error(`A frame's SSE event or id is not the frame's own type and id`));return}let a=PN(r.applied),o=PN(i.id);if(o.epoch===a.epoch&&o.seq<=a.seq)return;if(i.type===`reset`){if(i.snapshot.id!==i.id){this.#b(Error(`A reset frame names a snapshot other than itself`));return}let e=UN(this.#n,i.snapshot);if(e!==void 0){this.#b(Error(`A reset frame re-sent ${e}`));return}this.#h(i.snapshot,{kind:`reset`,reason:i.reason});return}if(o.epoch!==a.epoch){this.#b(Error(`A frame names another server's epoch`));return}if(i.base!==r.applied){this.#v();return}let s;try{s={...IN(r,i,this.#n),applied:i.id}}catch(e){this.#b(Error(`A patch could not be applied: ${KN(e)}`));return}this.#i=s,this.#t.onState(s,{kind:`frame`,frame:i})}#b(e){this.#c=!0,this.#_(),this.#t.onError?.(e)}};function IN(e,t,n){switch(t.type){case`run.changed`:{let n=e.sidebar.findIndex(e=>e.id===t.row.id);return{sidebar:n===-1?[...e.sidebar,t.row]:e.sidebar.map((e,r)=>r===n?t.row:e),visible:e.visible}}case`run.removed`:return{sidebar:e.sidebar.filter(e=>e.id!==t.run_id),visible:e.visible};default:return{sidebar:e.sidebar,visible:RN(e.visible,t,n)}}}function LN(e,t,n,r){let i=e.safeParse(kN(t,n));if(!i.success)throw Error(`the patched ${r} failed contract validation`);return i.data}function RN(e,t,n){let r=e=>Error(`a ${t.type} for ${e} this tab does not show`);if(t.type===`human-items.patch`){if(e.type!==`human-items`)throw r(`human items`);let i=LN(tj,e,t.ops,`human items`);if(HN(n,i))throw Error(`a human-items.patch moved its detail to another item`);return i}if(e.type===`sidebar`||e.type===`human-items`||e.run_id!==t.run_id)throw r(`a run`);let i=n=>{if(n.run_id!==e.run_id)throw Error(`a ${t.type} moved its payload to another run`);return n};switch(t.type){case`detail.patch`:return{...e,detail:(()=>{let n=LN(uM,e.detail,t.ops,`detail`);return i(n.run),n})()};case`timeline.patch`:if(e.type!==`timeline`||e.scope!==t.scope)throw r(`a timeline`);if(t.scope===`node`&&(e.scope!==`node`||e.node!==t.node))throw r(`a node's timeline`);return{...e,timeline:i(LN(EM,e.timeline,t.ops,`timeline`))};case`channel.patch`:if(e.type!==`channel`)throw r(`a channel`);return{...e,channel:i(LN(JM,e.channel,t.ops,`channel`))}}}function zN(e){return[e.type,e.run_id,e.scope,e.node].join(`\0`)}function BN(e){return Array.isArray(e)?e.map(BN):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,BN(t)])):e}function VN(e){if(e!==void 0){if(typeof e!=`string`)return JSON.stringify(BN(e));if(!e.startsWith(`{`))return e;try{return JSON.stringify(BN(JSON.parse(e)))}catch{return e}}}function HN(e,t){return t.detail===null?!1:!(`item`in e)||t.detail.item.id!==e.item}function UN(e,t){let n=t.visible;if(zN(n)!==zN(e))return`the state of another view`;if(n.type===`human-items`)return HN(e,n)?`the detail of another item`:void 0;if(n.type!==`sidebar`)return[n.detail.run.run_id,`timeline`in n?n.timeline.run_id:n.run_id,`channel`in n?n.channel.run_id:n.run_id].every(e=>e===n.run_id)?void 0:`a payload of another run`}function WN(e,t){if(zN(t.view)!==zN(e))return`another view`;let n=e=>`filter`in e?e.filter:void 0;if(VN(n(t.view))!==VN(n(e)))return`another filter`;let r=e=>`item`in e?e.item:void 0;return r(t.view)===r(e)?UN(e,t.initial.snapshot):`another item`}function GN(e,t){return JSON.stringify(e)===JSON.stringify(t)}function KN(e){return e instanceof Error?e.message:String(e)}function qN(e){return e instanceof Error?e:Error(String(e))}var JN=class extends Error{status;code;constructor(e,t,n,r){super(e,r),this.status=t,this.code=n,this.name=`TelemetryClientError`}},YN=50,XN=class{#e;#t;#n;constructor(e,t={}){this.#e=new URL(e),this.#t=t.fetch??globalThis.fetch,this.#n=t.eventSource}async listRuns(e=!1,t,n=YN){let r=this.#r(oj.runs);return r.searchParams.set(sj.includeSettled,String(e)),r.searchParams.set(sj.limit,String(n)),t!==void 0&&r.searchParams.set(sj.cursor,t),this.#a(r,Pj.parse)}async selectRuns(e){if(e.length===0)throw new JN(`Invalid selection`);for(let t of e)if($N(t,`run ID`),t.includes(`,`))throw new JN(`Invalid run ID`);let t=this.#r(oj.runs);return t.searchParams.set(sj.select,e.join(`,`)),this.#a(t,Pj.parse)}async getRun(e,t={}){$N(e,`run ID`);let n=this.#r(oj.run(e));return t.includeConversations!==void 0&&n.searchParams.set(sj.includeConversations,String(t.includeConversations)),t.filter!==void 0&&n.searchParams.set(sj.filter,t.filter),this.#a(n,uM.parse)}async getTimeline(e,t,n){$N(e,`run ID`);let r=this.#r(oj.timeline(e));return n!==void 0&&r.searchParams.set(sj.filter,n),t===void 0?r.searchParams.set(sj.scope,cj.run):(r.searchParams.set(sj.scope,cj.node),r.searchParams.set(sj.node,t)),this.#a(r,EM.parse)}async getConversation(e,t){return $N(e,`run ID`),$N(t,`conversation ID`),this.#a(this.#r(oj.conversation(e,t)),rM.parse)}async getArtifact(e,t){return $N(e,`run ID`),$N(t,`artifact ID`),this.#a(this.#r(oj.artifact(e,t)),TM.parse)}subscribe(e){e.runId!==void 0&&$N(e.runId,`run ID`),e.after!==void 0&&$N(e.after,`cursor`);let t=this.#r(oj.events);e.runId!==void 0&&t.searchParams.set(sj.runId,e.runId),e.after!==void 0&&t.searchParams.set(sj.after,e.after),e.filter!==void 0&&t.searchParams.set(sj.filter,e.filter);let n=this.#i(t);for(let t of OM.options)n.addEventListener(t,n=>{try{let r=n,i=JSON.parse(r.data),a=t===`snapshot`?Pj.parse(i):kM.parse(i);e.onEvent({id:r.lastEventId,event:t,data:a})}catch(t){e.onError?.(t)}});return n.onerror=t=>e.onError?.(t),{close:()=>n.close()}}live(e){return new FN({subscribe:e=>this.createSubscription(e),retire:(e,t)=>this.retireSubscription(e,t),open:e=>this.#i(e),url:e=>this.#r(e)},e)}async createSubscription(e){return this.#a(this.#r(oj.subscriptions),DN.parse,QN(`POST`,e))}async retireSubscription(e,t=!1){$N(e,`subscription ID`);let n;try{n=await this.#t(this.#r(oj.subscription(e)),{method:`DELETE`,...t?{keepalive:t}:{}})}catch(e){throw new JN(`Telemetry request failed`,void 0,void 0,{cause:e})}if(!n.ok&&n.status!==204)throw new JN(`Retiring a subscription failed with status ${n.status}`,n.status)}async listProjects(){return this.#a(this.#r(oj.projects),MM.parse)}async getProject(e){return $N(e,`project ID`),this.#a(this.#r(oj.project(e)),NM.parse)}async getChannel(e){return $N(e,`run ID`),this.#a(this.#r(oj.channel(e)),JM.parse)}async claimNext(e,t){$N(e,`run ID`);let n=this.#r(oj.channelNext(e));return t!==void 0&&n.searchParams.set(sj.filter,t),this.#a(n,XM.parse,{method:`POST`})}async reply(e,t,n){$N(e,`run ID`);let r=this.#r(oj.channelReply(e));return n!==void 0&&r.searchParams.set(sj.correlation,n),this.#a(r,ZM.parse,{method:`POST`,headers:{"content-type":`application/json`},body:t})}async surface(e,t){return $N(e,`run ID`),this.#a(this.#r(oj.channelSurface(e)),QM.parse,QN(`POST`,t))}async attest(e,t){return $N(e,`run ID`),this.#a(this.#r(oj.attest(e)),ZM.parse,QN(`POST`,{reference:t}))}async stop(e,t=!1){return $N(e,`run ID`),this.#a(this.#r(oj.stop(e)),$M.parse,QN(`POST`,{force:t}))}async listHumanItems(e={}){let t=this.#r(PA.list);for(let[n,r]of Object.entries(e))r!=null&&t.searchParams.set(n,String(r));return this.#a(t,$A.parse)}async getHumanItem(e){return $N(e,`human-item ID`),this.#a(this.#r(PA.item(e)),ZA.parse)}async answerHumanItem(e,t){return $N(e,`human-item ID`),this.#a(this.#r(PA.answer(e)),QA.parse,QN(`POST`,{text:t}))}async completeHumanItem(e){return $N(e,`human-item ID`),this.#a(this.#r(PA.complete(e)),QA.parse,QN(`POST`,{}))}async dismissHumanItem(e,t){return $N(e,`human-item ID`),this.#a(this.#r(PA.dismiss(e)),QA.parse,QN(`POST`,t?.trim()?{reason:t}:{}))}async reopenHumanItem(e){return $N(e,`human-item ID`),this.#a(this.#r(PA.reopen(e)),QA.parse,QN(`POST`,{}))}async noteHumanItem(e,t){return $N(e,`human-item ID`),this.#a(this.#r(PA.note(e)),QA.parse,QN(`POST`,{text:t}))}async shutdown(e,t={}){return this.#a(this.#r(oj.shutdown),iN.parse,QN(`POST`,{scope:e,...ZN(t)}))}async unwatched(){return this.#a(this.#r(oj.unwatched),aN.parse)}async host(){return this.#a(this.#r(oj.host),sN.parse)}async getStatus(e){return $N(e,`run ID`),this.#a(this.#r(oj.status(e)),cN.parse)}async getAgents(e){return $N(e,`run ID`),this.#a(this.#r(oj.agents(e)),fN.parse)}async getNodeAgents(e,t){return $N(e,`run ID`),$N(t,`node ID`),this.#a(this.#r(oj.nodeAgents(e,t)),fN.parse)}async getProjectAgents(e){return $N(e,`project ID`),this.#a(this.#r(oj.projectAgents(e)),pN.parse)}#r(e){return new URL(e,this.#e)}#i(e){return(this.#n??(e=>{if(typeof EventSource>`u`)throw new JN(`EventSource is unavailable; provide an eventSource factory`);return new EventSource(e)}))(e.toString())}async#a(e,t,n){let r;try{r=await this.#t(e,n)}catch(e){throw new JN(`Telemetry request failed`,void 0,void 0,{cause:e})}let i=await r.json().catch(e=>{throw new JN(`Telemetry server returned invalid JSON`,r.status,void 0,{cause:e})});if(!r.ok){let e=DM.safeParse(i);throw new JN(e.success?e.data.error.message:`Telemetry request failed with status ${r.status}`,r.status,e.success?e.data.error.code:void 0)}try{return t(i)}catch(e){throw new JN(`Telemetry response failed contract validation`,r.status,void 0,{cause:e})}}};function ZN(e){let{grace:t,force:n=!1}=e;if(t===void 0)return{force:n};if(!Number.isSafeInteger(t)||t<0)throw new JN(`Invalid grace: whole seconds, 0 or more`);return{grace:t,force:n}}function QN(e,t){return{method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}}function $N(e,t){let n=[...e].some(e=>e.charCodeAt(0)<32);if(e.length===0||n||/[/?#]/u.test(e))throw new JN(`Invalid ${t}`)}function eP({outcome:e,label:t}){if(e===void 0)return null;if(e.kind===`refused`){let n=e.error,r=n instanceof JN?n.code:void 0,i=n instanceof JN?n.status:void 0;return(0,W.jsxs)(sa,{"aria-label":`${t} refused`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsxs)(ca,{children:[e.title,i!==void 0&&` · ${i}`,r!==void 0&&` ${r}`]}),(0,W.jsx)(la,{children:(0,W.jsx)(`pre`,{className:`verb-text`,children:n.message})})]})}return(0,W.jsxs)(sa,{"aria-label":`${t} receipt`,children:[(0,W.jsx)(Tt,{}),(0,W.jsx)(ca,{children:e.title}),(0,W.jsx)(la,{children:(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.payload,null,2)})})]})}async function tP(e,t){try{return{kind:`answered`,title:e,payload:await t()}}catch(t){return{kind:`refused`,title:e,error:t instanceof Error?t:Error(String(t))}}}var nP=365.2425,rP=6048e5,iP=864e5,aP=6e4,oP=36e5,sP=1e3,cP=525600,lP=43200,uP=1440,dP=3600*24;dP*7,dP*nP/12*3;var fP=Symbol.for(`constructDateFrom`);function pP(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&fP in e?e[fP](t):e instanceof Date?new e.constructor(t):new Date(t)}function mP(e,t){return pP(t||e,e)}var hP={};function gP(){return hP}function _P(e,t){let n=gP(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=mP(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function vP(e,t){return _P(e,{...t,weekStartsOn:1})}function yP(e,t){let n=mP(e,t?.in),r=n.getFullYear(),i=pP(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=vP(i),o=pP(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=vP(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function bP(e){let t=mP(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function xP(e,...t){let n=pP.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function SP(e,t){let n=mP(e,t?.in);return n.setHours(0,0,0,0),n}function CP(e,t,n){let[r,i]=xP(n?.in,e,t),a=SP(r),o=SP(i),s=+a-bP(a),c=+o-bP(o);return Math.round((s-c)/iP)}function wP(e,t){let n=yP(e,t),r=pP(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),vP(r)}function TP(e,t){let n=mP(e)-+mP(t);return n<0?-1:n>0?1:n}function EP(e){return pP(e,Date.now())}function DP(e,t,n){let[r,i]=xP(n?.in,e,t);return+SP(r)==+SP(i)}function OP(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function kP(e){return!(!OP(e)&&typeof e!=`number`||isNaN(+mP(e)))}function AP(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function jP(e,t){let n=mP(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var MP={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},NP=(e,t,n)=>{let r,i=MP[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function PP(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var FP={date:PP({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:PP({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:PP({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},IP={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},LP=(e,t,n,r)=>IP[e];function RP(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var zP={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:RP({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:RP({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:RP({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:RP({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:RP({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function BP(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?HP(s,e=>e.test(o)):VP(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function VP(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function HP(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function UP(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var WP={code:`en-US`,formatDistance:NP,formatLong:FP,formatRelative:LP,localize:zP,match:{ordinalNumber:UP({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:BP({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:BP({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:BP({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:BP({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:BP({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function GP(e,t){let n=mP(e,t?.in);return CP(n,jP(n))+1}function KP(e,t){let n=mP(e,t?.in),r=vP(n)-+wP(n);return Math.round(r/rP)+1}function qP(e,t){let n=mP(e,t?.in),r=n.getFullYear(),i=gP(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=pP(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=_P(o,t),c=pP(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=_P(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function JP(e,t){let n=gP(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=qP(e,t),a=pP(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),_P(a,t)}function YP(e,t){let n=mP(e,t?.in),r=_P(n,t)-+JP(n,t);return Math.round(r/rP)+1}function XP(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var ZP={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return XP(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):XP(n+1,2)},d(e,t){return XP(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return XP(e.getHours()%12||12,t.length)},H(e,t){return XP(e.getHours(),t.length)},m(e,t){return XP(e.getMinutes(),t.length)},s(e,t){return XP(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return XP(Math.trunc(r*10**(n-3)),t.length)}},QP={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},$P={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return ZP.y(e,t)},Y:function(e,t,n,r){let i=qP(e,r),a=i>0?i:1-i;return t===`YY`?XP(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):XP(a,t.length)},R:function(e,t){return XP(yP(e),t.length)},u:function(e,t){return XP(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return XP(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return XP(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return ZP.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return XP(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=YP(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):XP(i,t.length)},I:function(e,t,n){let r=KP(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):XP(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):ZP.d(e,t)},D:function(e,t,n){let r=GP(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):XP(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return XP(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return XP(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return XP(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?QP.noon:r===0?QP.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?QP.evening:r>=12?QP.afternoon:r>=4?QP.morning:QP.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return ZP.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):ZP.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):XP(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):XP(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):ZP.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):ZP.s(e,t)},S:function(e,t){return ZP.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return tF(r);case`XXXX`:case`XX`:return nF(r);default:return nF(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return tF(r);case`xxxx`:case`xx`:return nF(r);default:return nF(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+eF(r,`:`);default:return`GMT`+nF(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+eF(r,`:`);default:return`GMT`+nF(r,`:`)}},t:function(e,t,n){return XP(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return XP(+e,t.length)}};function eF(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+XP(a,2)}function tF(e,t){return e%60==0?(e>0?`-`:`+`)+XP(Math.abs(e)/60,2):nF(e,t)}function nF(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=XP(Math.trunc(r/60),2),a=XP(r%60,2);return n+i+t+a}var rF=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},iF=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},aF={p:iF,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return rF(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,rF(r,t)).replace(`{{time}}`,iF(i,t))}},oF=/^D+$/,sF=/^Y+$/,cF=[`D`,`DD`,`YY`,`YYYY`];function lF(e){return oF.test(e)}function uF(e){return sF.test(e)}function dF(e,t,n){let r=fF(e,t,n);if(console.warn(r),cF.includes(e))throw RangeError(r)}function fF(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var pF=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,mF=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,hF=/^'([^]*?)'?$/,gF=/''/g,_F=/[a-zA-Z]/;function vF(e,t,n){let r=gP(),i=n?.locale??r.locale??WP,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=mP(e,n?.in);if(!kP(s))throw RangeError(`Invalid time value`);let c=t.match(mF).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=aF[t];return n(e,i.formatLong)}return e}).join(``).match(pF).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:yF(e)};if($P[t])return{isToken:!0,value:e};if(t.match(_F))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&uF(a)||!n?.useAdditionalDayOfYearTokens&&lF(a))&&dF(a,t,String(e));let o=$P[a[0]];return o(s,a,i.localize,l)}).join(``)}function yF(e){let t=e.match(hF);return t?t[1].replace(gF,`'`):e}function bF(e,t,n){let r=gP(),i=n?.locale??r.locale??WP,a=TP(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=xP(n?.in,...a>0?[t,e]:[e,t]),l=AP(n?.roundingMethod??`round`),u=c.getTime()-s.getTime(),d=u/aP,f=(u-(bP(c)-bP(s)))/aP,p=n?.unit,m;if(m=p||(d<1?`second`:d<60?`minute`:d<1440?`hour`:f<43200?`day`:f<525600?`month`:`year`),m===`second`){let e=l(u/1e3);return i.formatDistance(`xSeconds`,e,o)}else if(m===`minute`){let e=l(d);return i.formatDistance(`xMinutes`,e,o)}else if(m===`hour`){let e=l(d/60);return i.formatDistance(`xHours`,e,o)}else if(m===`day`){let e=l(f/uP);return i.formatDistance(`xDays`,e,o)}else if(m===`month`){let e=l(f/lP);return e===12&&p!==`month`?i.formatDistance(`xYears`,1,o):i.formatDistance(`xMonths`,e,o)}else{let e=l(f/cP);return i.formatDistance(`xYears`,e,o)}}function xF(e,t){return bF(e,EP(e),t)}function SF(e){return Math.trunc(e*oP)}function CF(e,t,n){let[r,i]=xP(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function wF(e,t){return CF(pP(t?.in||e,e),EP(t?.in||e))}function TF(e,t){return DP(pP(t?.in||e,e),EP(t?.in||e))}function EF(e){let t=e/oP;return Math.trunc(t)}function DF(e){let t=e/aP;return Math.trunc(t)}function OF(e){let t=e/sP;return Math.trunc(t)}function kF(e){return Math.trunc(e*aP)}function AF(e,t){let n=()=>pP(t?.in,NaN),r=t?.additionalDigits??2,i=FF(e),a;if(i.date){let e=IF(i.date,r);a=LF(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=zF(i.time),isNaN(s)))return n();if(i.timezone){if(c=VF(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=mP(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return mP(o+s+c,t?.in)}var jF={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},MF=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,NF=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,PF=/^([+-])(\d{2})(?::?(\d{2}))?$/;function FF(e){let t={},n=e.split(jF.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],jF.timeZoneDelimiter.test(t.date)&&(t.date=e.split(jF.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=jF.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function IF(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function LF(e,t){if(t===null)return new Date(NaN);let n=e.match(MF);if(!n)return new Date(NaN);let r=!!n[4],i=RF(n[1]),a=RF(n[2])-1,o=RF(n[3]),s=RF(n[4]),c=RF(n[5])-1;if(r)return qF(t,s,c)?HF(t,s,c):new Date(NaN);{let e=new Date(0);return!GF(t,a,o)||!KF(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function RF(e){return e?parseInt(e):1}function zF(e){let t=e.match(NF);if(!t)return NaN;let n=BF(t[1]),r=BF(t[2]),i=BF(t[3]);return JF(n,r,i)?n*oP+r*aP+i*1e3:NaN}function BF(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function VF(e){if(e===`Z`)return 0;let t=e.match(PF);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return YF(r,i)?n*(r*oP+i*aP):NaN}function HF(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var UF=[31,null,31,30,31,30,31,31,30,31,30,31];function WF(e){return e%400==0||e%4==0&&e%100!=0}function GF(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(UF[t]||(WF(e)?29:28))}function KF(e,t){return t>=1&&t<=(WF(e)?366:365)}function qF(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function JF(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function YF(e,t){return t>=0&&t<=59}function XF(e){return e*sP}function ZF(e){let t=Math.max(0,Math.round(e));if(t<XF(1))return`${t}ms`;let n=EF(t),r=DF(t-SF(n)),i=OF(t-SF(n)-kF(r));return n>0?`${n}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`}function QF(e){return ZF(XF(e))}function $F(e){let t=AF(e);return kP(t)?t:void 0}function eI(e){let t=$F(e);return t===void 0?e:TF(t)?vF(t,`HH:mm:ss`):wF(t)?vF(t,`MMM d, HH:mm:ss`):vF(t,`MMM d yyyy, HH:mm:ss`)}function tI(e){let t=$F(e);return t===void 0?e:vF(t,`PPpp zzzz`)}function nI(e){return new Date(e).toISOString()}function rI(e){let t=$F(e);return t===void 0?e:xF(t,{addSuffix:!0})}function iI({at:e,className:t,relative:n=!1}){let r=$F(e);return r===void 0?(0,W.jsx)(`span`,{className:t,children:e}):(0,W.jsx)(`time`,{className:t,dateTime:r.toISOString(),title:tI(e),children:n?rI(e):eI(e)})}var aI={approve:`Approve`,reject:`Reject`,continue:`Continue`},oI=[`review`,`readjust`,`decline`,`withdraw-note`],sI=[`approve`,`reject`,`continue`,...HM.filter(e=>!oI.some(t=>t===e))];function cI(e){return sI.some(t=>t===e)}var lI={approve:[`message`,`reason`],reject:[`message`,`reason`],continue:[`message`],add:[`json`],drop:[`id`,`dependents`],reparent:[`id`,`deps`],retry:[`id`,`json`],rework:[`id`,`reason`,`instruction`,`comments`,`title`,`replacement`],retitle:[`id`,`title`,`reason`],cancel:[`id`,`reason`],requeue:[`id`,`json`],"set-node-sets":[`id`,`sets`],"set-run-node-sets":[`runSets`],attest:[`reference`],complete:[`reason`],amend:[`id`,`text`],note:[`id`,`addressee`,`text`,`criterion`,`deliver`,`persist`],finding:[`message`,`blocking`,`id`],settle:[`id`,`outcome`,`evidence`,`landing`]};function uI(e,t){let n=dI(e,t);if(`problem`in n)return n;let r=UM.safeParse(n.envelope);if(!r.success){let e=r.error.issues[0];return{problem:`${e?.path.join(`.`)||`envelope`}: ${e?.message??`not an envelope`}`}}return{envelope:r.data,bytes:JSON.stringify(r.data,null,2)}}function dI(e,t){let n=e=>{let n=t[e];return typeof n==`string`&&n.trim().length>0?n:void 0};switch(e){case`approve`:return{envelope:{completion:!0,...pI(`message`,n(`message`)),...pI(`reason`,n(`reason`))}};case`reject`:return{envelope:{completion:!1,...pI(`message`,n(`message`)),...pI(`reason`,n(`reason`))}};case`continue`:return{envelope:{message:n(`message`)??``}};default:{let r=fI(e,t,n);return`problem`in r?r:{envelope:{version:3,commands:[r.command]}}}}}function fI(e,t,n){let r=n(`id`);switch(e){case`add`:case`retry`:case`requeue`:{let t=n(`json`);if(t===void 0&&e!==`requeue`)return{problem:`node: a node mapping is required`};let i;if(t!==void 0)try{i=JSON.parse(t)}catch(t){return{problem:`${e===`requeue`?`amend`:`node`}: ${t instanceof Error?t.message:`not JSON`}`}}return e===`add`?{command:{op:e,node:i}}:e===`retry`?{command:{op:e,id:r,node:i}}:{command:{op:e,id:r,...pI(`amend`,i)}}}case`set-node-sets`:case`set-run-node-sets`:{let n=[...(e===`set-node-sets`?t.sets:t.runSets)??[]],i=n.findIndex(e=>e.trim().length===0);return i>=0?{problem:`sets.${i}: an override needs a PATH=VALUE`}:e===`set-node-sets`?{command:{op:e,id:r,sets:n}}:{command:{op:e,sets:n}}}case`drop`:return{command:{op:e,id:r,dependents:n(`dependents`)}};case`reparent`:return{command:{op:e,id:r,deps:(t.deps??``).split(`
|
|
89
|
-
`).map(e=>e.trim()).filter(e=>e.length>0)}};case`rework`:{let t,i=n(`comments`);if(i!==void 0)try{t=JSON.parse(i)}catch(e){return{problem:`comments: ${e instanceof Error?e.message:`not JSON`}`}}return{command:{op:e,id:r,reason:n(`reason`),instruction:n(`instruction`),...pI(`comments`,t),...pI(`title`,n(`title`)),...pI(`replacement`,n(`replacement`))}}}case`retitle`:return{command:{op:e,id:r,title:n(`title`),reason:n(`reason`)}};case`cancel`:return{command:{op:e,id:r,...pI(`reason`,n(`reason`))}};case`attest`:return{command:{op:e,ref:n(`reference`)}};case`complete`:return{command:{op:e,reason:n(`reason`)}};case`amend`:return{command:{op:e,id:r,text:n(`text`)}};case`note`:return{command:{op:e,id:r,addressee:n(`addressee`),text:n(`text`),...pI(`criterion`,n(`criterion`)),...pI(`deliver`,n(`deliver`)===`live`?void 0:n(`deliver`)),...t.persist===!1?{persist:!1}:{}}};case`finding`:return{command:{op:e,message:n(`message`),...t.blocking===!0?{blocking:!0}:{},...pI(`id`,r)}};case`settle`:return{command:{op:e,id:r,outcome:n(`outcome`),evidence:n(`evidence`),...pI(`landing`,n(`landing`))}};default:return{problem:`op: ${String(e)} is not an op`}}}function pI(e,t){let n={};return t!==void 0&&(n[e]=t),n}function mI(e){let t=e.op;return typeof t==`string`?t:`?`}function hI({legend:e,sets:t,onChange:n,current:r}){let i=(0,H.useId)(),a=(e,r)=>n(t.map((t,n)=>n===e?r:t)),o=(e,r)=>{let i=[...t],[a]=i.splice(e,1);a!==void 0&&i.splice(r,0,a),n(i)};return(0,W.jsxs)(`fieldset`,{"aria-describedby":`${i}-hint`,className:`sets-editor`,children:[(0,W.jsx)(`legend`,{children:e}),(0,W.jsx)(`p`,{className:`sets-hint`,id:`${i}-hint`,children:`One PATH=VALUE a row, applied in order — the whole list is replaced, and an empty list clears it.`}),t.length===0?(0,W.jsx)(`p`,{className:`sets-empty`,children:`No overrides: sends an empty list.`}):(0,W.jsx)(`ol`,{className:`sets-list`,children:t.map((e,r)=>{let i=r+1;return(0,W.jsxs)(`li`,{className:`sets-row`,children:[(0,W.jsx)(Tc,{"aria-label":`Override ${i}`,className:`sets-entry`,onChange:e=>a(r,e.target.value),placeholder:`members.worker.agent.model=VALUE`,spellCheck:!1,value:e}),(0,W.jsx)(Pa,{"aria-label":`Move override ${i} up`,disabled:r===0,onClick:()=>o(r,r-1),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(yt,{})}),(0,W.jsx)(Pa,{"aria-label":`Move override ${i} down`,disabled:r===t.length-1,onClick:()=>o(r,r+1),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(_t,{})}),(0,W.jsx)(Pa,{"aria-label":`Remove override ${i}`,onClick:()=>n(t.filter((e,t)=>t!==r)),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{})})]},r)})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{onClick:()=>n([...t,``]),size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Jt,{size:14}),` Add override`]}),(0,W.jsxs)(Pa,{disabled:r===void 0,onClick:()=>{r!==void 0&&n([...r])},size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Zt,{size:14}),` Load current list`]}),(0,W.jsx)(`span`,{className:`sets-current`,children:r===void 0?`No current list to load`:r.length===0?`Current list: none`:`Current list: ${r.join(` · `)}`})]})]})}function gI(e,t,n){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)();return{run:(0,H.useCallback)(async(...r)=>{i(!0);let a=await tP(typeof e==`string`?e:e(...r),()=>t(...r));return o(a),i(!1),a.kind===`answered`&&n?.(),a},[e,t,n]),pending:r,outcome:a}}function _I(e,t,n,r){let[i,a]=(0,H.useState)(`continue`),[o,s]=(0,H.useState)({}),[c,l]=(0,H.useState)(),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(``);return{shortcut:i,setShortcut:a,fields:o,setField:(0,H.useCallback)((e,t)=>s(n=>({...n,[e]:t})),[]),problem:c,compose:(0,H.useCallback)(()=>{let e=uI(i,{...n,...o});if(`problem`in e){l(e.problem);return}l(void 0),d(e.bytes)},[i,o,n]),envelope:u,setEnvelope:d,correlation:f,setCorrelation:p,send:gI(`Reply`,(0,H.useCallback)(()=>e.reply(t,u,f.trim()===``?void 0:f.trim()),[e,t,u,f]),r)}}var vI={message:`Message`,reason:`Reason`,instruction:`Instruction`,title:`Title`,replacement:`Replacement node id (optional)`,comments:`Review comments (JSON, optional)`,id:`Node id`,text:`Text`,addressee:`Addressee`,deliver:`Deliver`,persist:`Carry to the next dispatch if no turn takes it`,criterion:`Criterion (optional)`,dependents:`Dependents`,deps:`Dependencies, one per line`,reference:`Reference`,outcome:`Outcome`,evidence:`Evidence`,landing:`Landing (optional)`,blocking:`Blocking`,json:`Mapping (JSON)`,sets:`Node overrides`,runSets:`Run-wide overrides`},yI={addressee:IM.options,deliver:LM.options,dependents:RM.options,outcome:zM.options},bI=Object.fromEntries(Object.entries(yI).map(([e,t])=>[e,t[0]]));function xI({client:e,runId:t,onSent:n,overrides:r}){let i=(0,H.useId)(),{shortcut:a,setShortcut:o,fields:s,setField:c,problem:l,compose:u,envelope:d,setEnvelope:f,correlation:p,setCorrelation:m,send:h}=_I(e,t,bI,n);return(0,W.jsxs)(`section`,{"aria-labelledby":`${i}-heading`,className:`composer`,children:[(0,W.jsx)(`h3`,{id:`${i}-heading`,children:`Reply`}),(0,W.jsxs)(`div`,{className:`composer-shortcut`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-shortcut`,children:`Shortcut`}),(0,W.jsxs)(`select`,{className:`composer-select`,id:`${i}-shortcut`,onChange:e=>{let t=e.target.value;cI(t)&&o(t)},value:a,children:[(0,W.jsx)(`optgroup`,{label:`Verdict`,children:Object.entries(aI).map(([e,t])=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`optgroup`,{label:`Edit`,children:sI.filter(e=>!(e in aI)).map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,W.jsx)(`div`,{className:`composer-fields`,children:lI[a].map(e=>{let t=`${i}-${e}`,n=yI[e];if(e===`sets`||e===`runSets`){let t=typeof s.id==`string`?s.id.trim():``;return(0,W.jsx)(hI,{current:e===`runSets`?r?.run:r?.nodes.get(t),legend:`${vI[e]}, in order`,onChange:t=>c(e,t),sets:s[e]??[]},e)}if(e===`persist`||e===`blocking`)return(0,W.jsxs)(`div`,{className:`composer-check`,children:[(0,W.jsx)(`input`,{checked:e===`persist`?s.persist!==!1:s.blocking===!0,id:t,onChange:t=>c(e,t.target.checked),type:`checkbox`}),(0,W.jsx)(Oc,{htmlFor:t,children:vI[e]})]},e);let a=s[e],o=typeof a==`string`?a:``;return(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:t,children:vI[e]}),n===void 0?e===`message`||e===`text`||e===`json`||e===`deps`||e===`evidence`?(0,W.jsx)(Tp,{id:t,onChange:t=>c(e,t.target.value),rows:e===`json`?5:2,value:o}):(0,W.jsx)(Tc,{id:t,onChange:t=>c(e,t.target.value),value:o}):(0,W.jsx)(`select`,{className:`composer-select`,id:t,onChange:t=>c(e,t.target.value),value:o||n[0],children:n.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]},e)})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{onClick:u,size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(cn,{size:14}),` Compose envelope`]}),l!==void 0&&(0,W.jsx)(`p`,{"aria-label":`Envelope not composed`,className:`composer-problem`,role:`alert`,children:l})]}),(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-envelope`,children:`Envelope (sent as typed)`}),(0,W.jsx)(Tp,{className:`composer-envelope`,id:`${i}-envelope`,onChange:e=>f(e.target.value),rows:8,spellCheck:!1,value:d})]}),(0,W.jsxs)(`div`,{className:`composer-field composer-correlation`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-correlation`,children:`Correlation (optional)`}),(0,W.jsx)(Tc,{id:`${i}-correlation`,onChange:e=>m(e.target.value),value:p})]}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{disabled:h.pending||d.trim()===``,onClick:()=>void h.run(),size:`sm`,type:`button`,children:[(0,W.jsx)(en,{size:14}),` Send reply`]}),(0,W.jsx)(`span`,{"aria-live":`polite`,className:`run-list-status`,children:h.pending?`Sending…`:``})]}),(0,W.jsx)(eP,{label:`Reply`,outcome:h.outcome})]})}function SI(e){return(0,H.useMemo)(()=>{let t=new Set(e.surfaces.flatMap(e=>e.correlation?[e.correlation]:[]));return{exchanges:[...e.surfaces].reverse().map(t=>({surface:t,replies:e.replies.filter(e=>t.correlation!==void 0&&e.correlation===t.correlation)})),otherReplies:e.replies.filter(e=>!t.has(e.correlation??``))}},[e])}function CI({client:e,runId:t,filter:n,decisions:r,observedAt:i,channel:a,journalSeq:o,overrides:s}){let c=(0,H.useCallback)(()=>void 0,[]),l=gI(`Next`,(0,H.useCallback)(()=>e.claimNext(t,n),[e,t,n]),c);return(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`channel-view`,"data-journal-seq":o,children:[(0,W.jsxs)(`section`,{"aria-labelledby":`channel-queue-heading`,className:`channel-section`,children:[(0,W.jsxs)(`div`,{className:`section-heading channel-heading`,children:[(0,W.jsxs)(`h3`,{id:`channel-queue-heading`,children:[(0,W.jsx)(Ft,{size:15}),` Channel queue`]}),(0,W.jsx)(Pa,{disabled:l.pending,onClick:()=>void l.run(),size:`sm`,type:`button`,children:`Next`})]}),a===void 0?(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,W.jsx)(xf,{className:`h-2 w-48`}),`Loading channel…`]}):(0,W.jsx)(wI,{observedAt:i,queue:a}),(0,W.jsx)(eP,{label:`Next`,outcome:l.outcome})]}),(0,W.jsx)(OI,{client:e,decisions:r,onWrote:c,runId:t}),(0,W.jsx)(xI,{client:e,onSent:c,overrides:s,runId:t}),(0,W.jsx)(kI,{client:e,onRaised:c,runId:t})]})})}function wI({queue:e,observedAt:t}){let{exchanges:n,otherReplies:r}=SI(e);return(0,W.jsxs)(`div`,{className:`channel-queue`,children:[(0,W.jsxs)(`section`,{"aria-label":`Surfaces`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Conversation`}),e.surfaces.length===0&&(0,W.jsx)(`p`,{className:`channel-empty`,children:`No surfaces yet.`}),(0,W.jsx)(`ul`,{children:n.map(({surface:e,replies:n})=>(0,W.jsxs)(`li`,{"aria-label":`Surface ${e.id}`,children:[(0,W.jsx)(DI,{observedAt:t,surface:e}),n.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`Waiting for reply`}):n.map(e=>(0,W.jsx)(EI,{reply:e},e.id))]},e.id))})]}),(0,W.jsxs)(`section`,{"aria-label":`Replies`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Other replies`}),r.map(e=>(0,W.jsx)(EI,{reply:e},e.id))]}),(0,W.jsxs)(`section`,{"aria-label":`Queued commands`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Queued commands`}),e.commands.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`Nothing awaits the reconciler.`}):(0,W.jsx)(`ul`,{children:e.commands.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Fa,{className:`channel-card`,children:(0,W.jsx)(Ia,{children:(0,W.jsxs)(`div`,{className:`channel-card-head`,children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`envelope `,e.id]}),(0,W.jsx)(Ma,{variant:`secondary`,children:e.author??`planner`}),(0,W.jsx)(`span`,{children:e.commands.map(mI).join(`, `)})]})})})},e.id))})]}),(0,W.jsxs)(`section`,{"aria-label":`Command outcomes`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Command outcomes`}),e.outcomes.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`The reconciler has answered nothing yet.`}):(0,W.jsx)(`ul`,{children:e.outcomes.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Fa,{className:`channel-card`,children:(0,W.jsxs)(Ia,{children:[(0,W.jsxs)(`div`,{className:`channel-card-head`,children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`envelope `,e.id]}),(0,W.jsx)(Ma,{variant:e.applied?`default`:`destructive`,children:e.applied?`applied`:`not applied`})]}),e.reason!==void 0&&(0,W.jsx)(`pre`,{className:`verb-text`,children:e.reason}),e.results!==void 0&&e.results.length>0&&(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.results,null,2)})]})})},e.id))})]})]})}function TI({text:e,children:t,meta:n,label:r}){let i=e.split(/\r?\n/,1)[0];return(0,W.jsxs)(`details`,{"aria-label":r,className:`channel-message-details`,children:[(0,W.jsxs)(`summary`,{"aria-label":`${r}: ${i}`,children:[(0,W.jsx)(`span`,{className:`channel-message-meta`,children:n}),(0,W.jsxs)(`span`,{className:`channel-message-preview`,children:[i,`…`]})]}),(0,W.jsx)(`pre`,{className:`verb-text`,children:e}),t]})}function EI({reply:e}){let t=typeof e.reply.message==`string`?e.reply.message:`Reply without message`;return(0,W.jsx)(Fa,{className:`channel-card py-2`,children:(0,W.jsx)(Ia,{children:(0,W.jsx)(TI,{label:`Reply ${e.id} message`,text:t,meta:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`reply `,e.id]}),(0,W.jsx)(iI,{at:nI(e.at),relative:!0})]}),children:(0,W.jsxs)(`details`,{"aria-label":`Raw envelope for reply ${e.id}`,children:[(0,W.jsx)(`summary`,{children:`Raw envelope`}),(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.reply,null,2)})]})})})})}function DI({surface:e,observedAt:t}){let n=Math.max(0,(Date.parse(t)-e.queued_at)/1e3);return(0,W.jsx)(Fa,{className:`channel-card py-2`,children:(0,W.jsx)(Ia,{children:(0,W.jsx)(TI,{label:`Surface ${e.id} message`,text:e.message,meta:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ma,{children:e.kind}),(0,W.jsxs)(Ma,{variant:`secondary`,children:[`from `,e.source]}),e.blocking?(0,W.jsx)(Ma,{variant:`destructive`,children:`blocking`}):(0,W.jsx)(Ma,{variant:`outline`,children:`non-blocking`}),e.workstream!==void 0&&(0,W.jsxs)(Ma,{variant:`outline`,children:[`node `,e.workstream]}),(0,W.jsxs)(`span`,{className:`channel-age`,children:[`surface `,e.id,` · `,QF(n),` old`]})]})})})})}function OI({client:e,runId:t,decisions:n,onWrote:r}){let i=AI(e,t,r);return(0,W.jsxs)(`section`,{"aria-labelledby":`attest-heading`,className:`channel-section`,children:[(0,W.jsxs)(`h3`,{id:`attest-heading`,children:[(0,W.jsx)(bt,{size:15}),` Ready human actions`]}),n.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`No decision point is holding the graph.`}):(0,W.jsx)(`ul`,{className:`attest-list`,children:n.map(e=>(0,W.jsxs)(`li`,{className:`attest-row`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Ma,{variant:`outline`,children:e.kind}),` `,(0,W.jsx)(`span`,{className:`attest-reference`,children:e.id}),e.unblocks.length>0&&(0,W.jsxs)(`span`,{className:`channel-age`,children:[` `,`· unblocks `,e.unblocks.join(`, `)]})]}),(0,W.jsxs)(Pa,{disabled:i.pending,onClick:()=>void i.run(e.id),size:`sm`,type:`button`,variant:`outline`,children:[`Attest `,e.id]})]},e.id))}),(0,W.jsx)(eP,{label:`Attest`,outcome:i.outcome})]})}function kI({client:e,runId:t,onRaised:n}){let r=(0,H.useId)(),{kind:i,setKind:a,message:o,setMessage:s,raise:c}=jI(e,t,n);return(0,W.jsxs)(`section`,{"aria-labelledby":`${r}-heading`,className:`channel-section`,children:[(0,W.jsxs)(`h3`,{id:`${r}-heading`,children:[(0,W.jsx)(Ht,{size:15}),` Surface`]}),(0,W.jsxs)(`div`,{className:`composer-fields`,children:[(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${r}-kind`,children:`Kind`}),(0,W.jsx)(Tc,{id:`${r}-kind`,onChange:e=>a(e.target.value),placeholder:`finding`,value:i})]}),(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${r}-message`,children:`Message`}),(0,W.jsx)(Tp,{id:`${r}-message`,onChange:e=>s(e.target.value),rows:2,value:o})]})]}),(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{disabled:c.pending||i.trim()===``,onClick:()=>void c.run(),size:`sm`,type:`button`,variant:`outline`,children:`Raise surface`})}),(0,W.jsx)(eP,{label:`Surface`,outcome:c.outcome})]})}function AI(e,t,n){return gI(e=>`Attest ${e}`,(0,H.useCallback)(n=>e.attest(t,n),[e,t]),n)}function jI(e,t,n){let[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(``);return{kind:r,setKind:i,message:a,setMessage:o,raise:gI(`Surface`,(0,H.useCallback)(()=>e.surface(t,{kind:r,message:a}),[e,t,r,a]),(0,H.useCallback)(()=>{o(``),n()},[n]))}}function MI(e){return/\[[^\]]+\]/.exec(e)?.[0]}function NI({runId:e,control:t,ended:n}){let{stop:r,stopOpen:i,setStopOpen:a,forceOpen:o,setForceOpen:s,refusal:c}=PI(t),l=c===void 0?void 0:MI(c.message),u=r.outcome,d=r.pending,f=t.status.value?.liveness;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`run-actions`,children:[f!==void 0&&(0,W.jsx)(Ma,{"aria-label":`Liveness ${f}`,className:`run-actions-badge`,variant:`outline`,children:f}),!n&&(0,W.jsxs)(Pa,{"aria-label":`Stop`,disabled:d,onClick:()=>a(!0),size:`sm`,title:`Stop`,type:`button`,variant:`destructive`,children:[(0,W.jsx)(qt,{size:14}),(0,W.jsx)(`span`,{className:`run-action-label`,children:`Stop`})]})]}),(0,W.jsx)(gc,{onOpenChange:a,open:i,children:(0,W.jsxs)(bc,{children:[(0,W.jsxs)(xc,{children:[(0,W.jsxs)(Cc,{children:[`Stop `,e,`?`]}),(0,W.jsx)(wc,{children:`The run is stopped as the acting session. A run another session owns is refused, naming its owner.`})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsx)(Pa,{disabled:d,onClick:()=>void r.run(!1),type:`button`,variant:`destructive`,children:`Stop run`})]})]})}),(0,W.jsx)(gc,{onOpenChange:s,open:o,children:(0,W.jsxs)(bc,{children:[(0,W.jsxs)(xc,{children:[(0,W.jsxs)(Cc,{children:[`Force-stop `,e,l!==void 0&&`, overriding ${l}`,`?`]}),(0,W.jsxs)(wc,{children:[c?.message,` — `,`a forced stop is journalled forced with the owner it overrode.`]})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsxs)(Pa,{disabled:d,onClick:()=>void r.run(!0),type:`button`,variant:`destructive`,children:[`Force stop`,l!==void 0&&`, overriding ${l}`]})]})]})}),u!==void 0&&(0,W.jsxs)(`div`,{className:`run-outcomes`,children:[(0,W.jsx)(eP,{label:`Stop`,outcome:u}),c!==void 0&&(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{onClick:()=>s(!0),size:`sm`,type:`button`,variant:`destructive`,children:`Force stop…`})})]})]})}function PI(e){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=gI(e=>e?`Forced stop`:`Stop`,(0,H.useCallback)(async t=>{try{return await e.stop(t)}finally{n(!1),i(!1)}},[e.stop]));return{stop:a,stopOpen:t,setStopOpen:n,forceOpen:r,setForceOpen:i,refusal:a.outcome?.kind===`refused`&&a.outcome.error instanceof JN&&a.outcome.error.code===`not_owner`?a.outcome.error:void 0}}function FI(e,t,n){let[r,i]=(0,H.useState)({}),a=(0,H.useRef)({key:e});(0,H.useEffect)(()=>{a.current.key=e},[e]),(0,H.useEffect)(()=>{if(e===void 0)return;let n=a.current.out;if(n?.key===e){n.again=!0;return}let r=()=>{let n={key:e,again:!1};a.current.out=n;let o=t=>{a.current.out===n&&(a.current.out=void 0),a.current.key===e&&(t(),n.again&&r())};t().then(t=>o(()=>i({key:e,value:t}))).catch(t=>o(()=>i(n=>({...n.key===e?n:{},key:e,error:II(t)}))))};r()},[e,n]);let o=r.key===e?r:void 0;return{value:o?.value,error:o?.error,loading:e!==void 0&&o?.value===void 0&&o?.error===void 0}}function II(e){return e instanceof Error?e:Error(String(e))}function LI(e,t){let[n,r]=(0,H.useState)(0),i=(0,H.useCallback)(()=>r(e=>e+1),[]);return{status:FI(t,()=>e.getStatus(t??``),n),stop:(0,H.useCallback)(async n=>{try{return await e.stop(t??``,n)}finally{i()}},[e,t,i]),reread:i}}var RI=o(((e,t)=>{var n=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>void 0;_defaultEdgeLabelFn=()=>void 0;_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=!Object.hasOwn(e,`directed`)||e.directed,this._isMultigraph=Object.hasOwn(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.hasOwn(e,`compound`)?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!=`function`&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var n=arguments,r=this;return e.forEach(function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(var n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else if(e===`\0`)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,i(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!=`function`&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce(function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,i,s=!1,c=arguments[0];typeof c==`object`&&c&&`v`in c?(e=c.v,t=c.w,n=c.name,arguments.length===2&&(i=arguments[1],s=!0)):(e=c,t=arguments[1],n=arguments[3],arguments.length>2&&(i=arguments[2],s=!0)),e=``+e,t=``+t,n!==void 0&&(n=``+n);var l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=i),this;if(n!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[l]=s?i:this._defaultEdgeLabelFn(e,t,n);var u=o(this._isDirected,e,t,n);return e=u.v,t=u.w,Object.freeze(u),this._edgeObjs[l]=u,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][l]=u,this._out[e][l]=u,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){let e=this.edge(...arguments);return typeof e==`object`?e:{label:e}}hasEdge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[t],e),i(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.v===t):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.w===t):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};function r(e,t){e[t]?e[t]++:e[t]=1}function i(e,t){--e[t]||delete e[t]}function a(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}return i+``+a+``+(r===void 0?`\0`:r)}function o(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=n})),zI=o(((e,t)=>{t.exports=`2.2.4`})),BI=o(((e,t)=>{t.exports={Graph:RI(),version:zI()}})),VI=o(((e,t)=>{var n=RI();t.exports={write:r,read:o};function r(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:i(e),edges:a(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function i(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function a(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function o(e){var t=new n(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}})),HI=o(((e,t)=>{t.exports=n;function n(e){var t={},n=[],r;function i(n){Object.hasOwn(t,n)||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}})),UI=o(((e,t)=>{t.exports=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}}})),WI=o(((e,t)=>{var n=UI();t.exports=i;var r=()=>1;function i(e,t,n,i){return a(e,String(t),n||r,i||function(t){return e.outEdges(t)})}function a(e,t,r,i){var a={},o=new n,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<n.distance&&(n.distance=l,n.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var n=e===t?0:1/0;a[e]={distance:n},o.add(e,n)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}})),GI=o(((e,t)=>{var n=WI();t.exports=r;function r(e,t,r){return e.nodes().reduce(function(i,a){return i[a]=n(e,a,t,r),i},{})}})),KI=o(((e,t)=>{t.exports=n;function n(e){var t=0,n=[],r={},i=[];function a(o){var s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){Object.hasOwn(r,e)?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(o!==l);i.push(c)}}return e.nodes().forEach(function(e){Object.hasOwn(r,e)||a(e)}),i}})),qI=o(((e,t)=>{var n=KI();t.exports=r;function r(e){return n(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}})),JI=o(((e,t)=>{t.exports=r;var n=()=>1;function r(e,t,r){return i(e,t||n,r||function(t){return e.outEdges(t)})}function i(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}})),YI=o(((e,t)=>{function n(e){var t={},n={},i=[];function a(o){if(Object.hasOwn(n,o))throw new r;Object.hasOwn(t,o)||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(a),delete n[o],i.push(o))}if(e.sinks().forEach(a),Object.keys(t).length!==e.nodeCount())throw new r;return i}var r=class extends Error{constructor(){super(...arguments)}};t.exports=n,n.CycleException=r})),XI=o(((e,t)=>{var n=YI();t.exports=r;function r(e){try{n(e)}catch(e){if(e instanceof n.CycleException)return!1;throw e}return!0}})),ZI=o(((e,t)=>{t.exports=n;function n(e,t,n){Array.isArray(t)||(t=[t]);var a=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o=n===`post`?r:i,s=[],c={};return t.forEach(t=>{if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);o(t,a,c,s)}),s}function r(e,t,n,r){for(var i=[[e,!1]];i.length>0;){var o=i.pop();o[1]?r.push(o[0]):Object.hasOwn(n,o[0])||(n[o[0]]=!0,i.push([o[0],!0]),a(t(o[0]),e=>i.push([e,!1])))}}function i(e,t,n,r){for(var i=[e];i.length>0;){var o=i.pop();Object.hasOwn(n,o)||(n[o]=!0,r.push(o),a(t(o),e=>i.push(e)))}}function a(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}})),QI=o(((e,t)=>{var n=ZI();t.exports=r;function r(e,t){return n(e,t,`post`)}})),$I=o(((e,t)=>{var n=ZI();t.exports=r;function r(e,t){return n(e,t,`pre`)}})),eL=o(((e,t)=>{var n=RI(),r=UI();t.exports=i;function i(e,t){var i=new n,a={},o=new r,s;function c(e){var n=e.v===s?e.w:e.v,r=o.priority(n);if(r!==void 0){var i=t(e);i<r&&(a[n]=s,o.decrease(n,i))}}if(e.nodeCount()===0)return i;e.nodes().forEach(function(e){o.add(e,1/0),i.setNode(e)}),o.decrease(e.nodes()[0],0);for(var l=!1;o.size()>0;){if(s=o.removeMin(),Object.hasOwn(a,s))i.setEdge(s,a[s]);else if(l)throw Error(`Input graph is not connected: `+e);else l=!0;e.nodeEdges(s).forEach(c)}return i}})),tL=o(((e,t)=>{t.exports={components:HI(),dijkstra:WI(),dijkstraAll:GI(),findCycles:qI(),floydWarshall:JI(),isAcyclic:XI(),postorder:QI(),preorder:$I(),prim:eL(),tarjan:KI(),topsort:YI()}})),nL=o(((e,t)=>{var n=BI();t.exports={Graph:n.Graph,json:VI(),alg:tL(),version:n.version}})),rL=o(((e,t)=>{var n=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,i)),n=n._prev;return`[`+e.join(`, `)+`]`}};function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i(e,t){if(e!==`_next`&&e!==`_prev`)return t}t.exports=n})),iL=o(((e,t)=>{var n=nL().Graph,r=rL();t.exports=a;var i=()=>1;function a(e,t){if(e.nodeCount()<=1)return[];let n=c(e,t||i);return o(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))}function o(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)s(e,t,n,o);for(;o=i.dequeue();)s(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){r=r.concat(s(e,t,n,o,!0));break}}}return r}function s(e,t,n,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,l(t,n,s)}),e.outEdges(r.v).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,l(t,n,o)}),e.removeNode(r.v),a}function c(e,t){let i=new n,a=0,o=0;e.nodes().forEach(e=>{i.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let n=i.edge(e.v,e.w)||0,r=t(e),s=n+r;i.setEdge(e.v,e.w,s),o=Math.max(o,i.node(e.v).out+=r),a=Math.max(a,i.node(e.w).in+=r)});let s=u(o+a+3).map(()=>new r),c=a+1;return i.nodes().forEach(e=>{l(s,c,i.node(e))}),{graph:i,buckets:s,zeroIdx:c}}function l(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function u(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}})),aL=o(((e,t)=>{var n=nL().Graph;t.exports={addBorderNode:f,addDummyNode:r,applyWithChunking:h,asNonCompoundGraph:a,buildLayerMatrix:l,intersectRect:c,mapValues:w,maxRank:g,normalizeRanks:u,notime:y,partition:_,pick:C,predecessorWeights:s,range:S,removeEmptyRanks:d,simplify:i,successorWeights:o,time:v,uniqueId:x,zipObject:T};function r(e,t,n,r){for(var i=r;e.hasNode(i);)i=x(r);return n.dummy=t,e.setNode(i,n),i}function i(e){let t=new n().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function a(e){let t=new n({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function o(e){let t=e.nodes().map(t=>{let n={};return e.outEdges(t).forEach(t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function s(e){let t=e.nodes().map(t=>{let n={};return e.inEdges(t).forEach(t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function c(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function l(e){let t=S(g(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i][r.order]=n)}),t}function u(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=h(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function d(e){let t=e.nodes().map(t=>e.node(t).rank),n=h(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function f(e,t,n,i){let a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=i),r(e,`border`,a,t)}function p(e,t=m){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var m=65535;function h(e,t){if(t.length>m){let n=p(t);return e.apply(null,n.map(t=>e.apply(null,t)))}else return e.apply(null,t)}function g(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return h(Math.max,t)}function _(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function v(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function y(e,t){return t()}var b=0;function x(e){return e+(``+ ++b)}function S(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function C(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function w(e,t){let n=t;return typeof t==`string`&&(n=e=>e[t]),Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function T(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}})),oL=o(((e,t)=>{var n=iL(),r=aL().uniqueId;t.exports={run:i,undo:o};function i(e){(e.graph().acyclicer===`greedy`?n(e,t(e)):a(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,r(`rev`))});function t(e){return t=>e.edge(t).weight}}function a(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}})),sL=o(((e,t)=>{var n=aL();t.exports={run:r,undo:a};function r(e){e.graph().dummyChains=[],e.edges().forEach(t=>i(e,t))}function i(e,t){let r=t.v,i=e.node(r).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:t,rank:i},u=n.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(r,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),r=u;e.setEdge(r,a,{weight:c.weight},s)}function a(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}})),cL=o(((e,t)=>{var{applyWithChunking:n}=aL();t.exports={longestPath:r,slack:i};function r(e){var t={};function r(i){var a=e.node(i);if(Object.hasOwn(t,i))return a.rank;t[i]=!0;let o=e.outEdges(i).map(t=>t==null?1/0:r(t.w)-e.edge(t).minlen);var s=n(Math.min,o);return s===1/0&&(s=0),a.rank=s}e.sources().forEach(r)}function i(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}})),lL=o(((e,t)=>{var n=nL().Graph,r=cL().slack;t.exports=i;function i(e){var t=new n({directed:!1}),i=e.nodes()[0],c=e.nodeCount();t.setNode(i,{});for(var l,u;a(t,e)<c;)l=o(t,e),u=t.hasNode(l.v)?r(e,l):-r(e,l),s(t,e,u);return t}function a(e,t){function n(i){t.nodeEdges(i).forEach(a=>{var o=a.v,s=i===o?a.w:o;!e.hasNode(s)&&!r(t,a)&&(e.setNode(s,{}),e.setEdge(i,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function o(e,t){return t.edges().reduce((n,i)=>{let a=1/0;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=r(t,i)),a<n[0]?[a,i]:n},[1/0,null])[1]}function s(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}})),uL=o(((e,t)=>{var n=lL(),r=cL().slack,i=cL().longestPath,a=nL().alg.preorder,o=nL().alg.postorder,s=aL().simplify;t.exports=c,c.initLowLimValues=f,c.initCutValues=l,c.calcCutValue=d,c.leaveEdge=m,c.enterEdge=h,c.exchangeEdges=g;function c(e){e=s(e),i(e);var t=n(e);f(t),l(t,e);for(var r,a;r=m(t);)a=h(t,e,r),g(t,e,r,a)}function l(e,t){var n=o(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>u(e,t,n))}function u(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=d(e,t,n)}function d(e,t,n){var r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;return a||=(i=!1,t.edge(r,n)),o=a.weight,t.nodeEdges(n).forEach(a=>{var s=a.v===n,c=s?a.w:a.v;if(c!==r){var l=s===i,u=t.edge(a).weight;if(o+=l?u:-u,v(e,n,c)){var d=e.edge(n,c).cutvalue;o+=l?-d:d}}}),o}function f(e,t){arguments.length<2&&(t=e.nodes()[0]),p(e,{},1,t)}function p(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(i=>{Object.hasOwn(t,i)||(n=p(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function h(e,t,n){var i=n.v,a=n.w;t.hasEdge(i,a)||(i=n.w,a=n.v);var o=e.node(i),s=e.node(a),c=o,l=!1;return o.lim>s.lim&&(c=s,l=!0),t.edges().filter(t=>l===y(e,e.node(t.v),c)&&l!==y(e,e.node(t.w),c)).reduce((e,n)=>r(t,n)<r(t,e)?n:e)}function g(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),f(e),l(e,t),_(e,t)}function _(e,t){var n=a(e,e.nodes().find(e=>!t.node(e).parent));n=n.slice(1),n.forEach(n=>{var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function v(e,t,n){return e.hasEdge(t,n)}function y(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}})),dL=o(((e,t)=>{var n=cL().longestPath,r=lL(),i=uL();t.exports=a;function a(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case`network-simplex`:c(e);break;case`tight-tree`:s(e);break;case`longest-path`:o(e);break;case`none`:break;default:c(e)}}var o=n;function s(e){n(e),r(e)}function c(e){i(e)}})),fL=o(((e,t)=>{t.exports=n;function n(e){let t=i(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),a=i.edgeObj,o=r(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;for(;n!==a.w;){if(i=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRank<i.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(u=s[l+1]).minRank<=i.rank;)l++;u=s[l]}e.setParent(n,u),n=e.successors(n)[0]}})}function r(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c,l;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function i(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children().forEach(r),t}})),pL=o(((e,t)=>{var n=aL();t.exports={run:r,cleanup:s};function r(e){let t=n.addDummyNode(e,`root`,{},`_root`),r=a(e),s=Object.values(r),c=n.applyWithChunking(Math.max,s)-1,l=2*c+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=l);let u=o(e)+1;e.children().forEach(n=>i(e,t,l,u,c,r,n)),e.graph().nodeRankFactor=l}function i(e,t,r,a,o,s,c){let l=e.children(c);if(!l.length){c!==t&&e.setEdge(t,c,{weight:0,minlen:r});return}let u=n.addBorderNode(e,`_bt`),d=n.addBorderNode(e,`_bb`),f=e.node(c);e.setParent(u,c),f.borderTop=u,e.setParent(d,c),f.borderBottom=d,l.forEach(n=>{i(e,t,r,a,o,s,n);let l=e.node(n),f=l.borderTop?l.borderTop:n,p=l.borderBottom?l.borderBottom:n,m=l.borderTop?a:2*a,h=f===p?o-s[c]+1:1;e.setEdge(u,f,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,d,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(c)||e.setEdge(t,u,{weight:0,minlen:o+s[c]})}function a(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children().forEach(e=>n(e,1)),t}function o(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function s(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}})),mL=o(((e,t)=>{var n=aL();t.exports=r;function r(e){function t(n){let r=e.children(n),a=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(a,`minRank`)){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,r=a.maxRank+1;t<r;++t)i(e,`borderLeft`,`_bl`,n,a,t),i(e,`borderRight`,`_br`,n,a,t)}}e.children().forEach(t)}function i(e,t,r,i,a,o){let s={width:0,height:0,rank:o,borderType:t},c=a[t][o-1],l=n.addDummyNode(e,`border`,s,r);a[t][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}})),hL=o(((e,t)=>{t.exports={adjust:n,undo:r};function n(e){let t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&i(e)}function r(e){let t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&o(e),(t===`lr`||t===`rl`)&&(c(e),i(e))}function i(e){e.nodes().forEach(t=>a(e.node(t))),e.edges().forEach(t=>a(e.edge(t)))}function a(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.nodes().forEach(t=>s(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(s),Object.hasOwn(n,`y`)&&s(n)})}function s(e){e.y=-e.y}function c(e){e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(l),Object.hasOwn(n,`x`)&&l(n)})}function l(e){let t=e.x;e.x=e.y,e.y=t}})),gL=o(((e,t)=>{var n=aL();t.exports=r;function r(e){let t={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=n.applyWithChunking(Math.max,i),o=n.range(a+1).map(()=>[]);function s(n){if(t[n])return;t[n]=!0;let r=e.node(n);o[r.rank].push(n),e.successors(n).forEach(s)}return r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(s),o}})),_L=o(((e,t)=>{var n=aL().zipObject;t.exports=r;function r(e,t){let n=0;for(let r=1;r<t.length;++r)n+=i(e,t[r-1],t[r]);return n}function i(e,t,r){let i=n(r,r.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:i[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),o=1;for(;o<r.length;)o<<=1;let s=2*o-1;--o;let c=Array(s).fill(0),l=0;return a.forEach(e=>{let t=e.pos+o;c[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n}),l}})),vL=o(((e,t)=>{t.exports=n;function n(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:t}})}})),yL=o(((e,t)=>{var n=aL();t.exports=r;function r(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(n[e.w]))}),i(Object.values(n).filter(e=>!e.indegree))}function i(e){let t=[];function r(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&a(e,t)}}function i(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let n=e.pop();t.push(n),n.in.reverse().forEach(r(n)),n.out.forEach(i(n))}return t.filter(e=>!e.merged).map(e=>n.pick(e,[`vs`,`i`,`barycenter`,`weight`]))}function a(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}})),bL=o(((e,t)=>{var n=aL();t.exports=r;function r(e,t){let r=n.partition(e,e=>Object.hasOwn(e,`barycenter`)),o=r.lhs,s=r.rhs.sort((e,t)=>t.i-e.i),c=[],l=0,u=0,d=0;o.sort(a(!!t)),d=i(c,s,d),o.forEach(e=>{d+=e.vs.length,c.push(e.vs),l+=e.barycenter*e.weight,u+=e.weight,d=i(c,s,d)});let f={vs:c.flat(!0)};return u&&(f.barycenter=l/u,f.weight=u),f}function i(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function a(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}})),xL=o(((e,t)=>{var n=vL(),r=yL(),i=bL();t.exports=a;function a(e,t,c,l){let u=e.children(t),d=e.node(t),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(e=>e!==f&&e!==p));let h=n(e,u);h.forEach(t=>{if(e.children(t.v).length){let n=a(e,t.v,c,l);m[t.v]=n,Object.hasOwn(n,`barycenter`)&&s(t,n)}});let g=r(h,c);o(g,m);let _=i(g,l);if(f&&(_.vs=[f,_.vs,p].flat(!0),e.predecessors(f).length)){let t=e.node(e.predecessors(f)[0]),n=e.node(e.predecessors(p)[0]);Object.hasOwn(_,`barycenter`)||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+t.order+n.order)/(_.weight+2),_.weight+=2}return _}function o(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function s(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}})),SL=o(((e,t)=>{var n=nL().Graph,r=aL();t.exports=i;function i(e,t,r){let i=a(e),o=new n({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return e.nodes().forEach(n=>{let a=e.node(n),s=e.parent(n);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(o.setNode(n),o.setParent(n,s||i),e[r](n).forEach(t=>{let r=t.v===n?t.w:t.v,i=o.edge(r,n),a=i===void 0?0:i.weight;o.setEdge(r,n,{weight:e.edge(t).weight+a})}),Object.hasOwn(a,`minRank`)&&o.setNode(n,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),o}function a(e){for(var t;e.hasNode(t=r.uniqueId(`_root`)););return t}})),CL=o(((e,t)=>{t.exports=n;function n(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}})),wL=o(((e,t)=>{var n=gL(),r=_L(),i=xL(),a=SL(),o=CL(),s=nL().Graph,c=aL();t.exports=l;function l(e,t){if(t&&typeof t.customOrder==`function`){t.customOrder(e,l);return}let i=c.maxRank(e),a=u(e,c.range(1,i+1),`inEdges`),o=u(e,c.range(i-1,-1,-1),`outEdges`),s=n(e);if(f(e,s),t&&t.disableOptimalOrderHeuristic)return;let p=1/0,m;for(let t=0,n=0;n<4;++t,++n){d(t%2?a:o,t%4>=2),s=c.buildLayerMatrix(e);let i=r(e,s);i<p&&(n=0,m=Object.assign({},s),p=i)}f(e,m)}function u(e,t,n){return t.map(function(t){return a(e,t,n)})}function d(e,t){let n=new s;e.forEach(function(e){let r=e.graph().root,a=i(e,r,n,t);a.vs.forEach((t,n)=>e.node(t).order=n),o(e,n,a.vs)})}function f(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}})),TL=o(((e,t)=>{var n=nL().Graph,r=aL();t.exports={positionX:h,findType1Conflicts:i,findType2Conflicts:a,addConflict:s,hasConflict:c,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:m};function i(e,t){let n={};function r(t,r){let i=0,a=0,c=t.length,l=r[r.length-1];return r.forEach((t,u)=>{let d=o(e,t),f=d?e.node(d).order:c;(d||t===l)&&(r.slice(a,u+1).forEach(t=>{e.predecessors(t).forEach(r=>{let a=e.node(r),o=a.order;(o<i||f<o)&&!(a.dummy&&e.node(t).dummy)&&s(n,r,t)})}),a=u+1,i=f)}),r}return t.length&&t.reduce(r),n}function a(e,t){let n={};function i(t,i,a,o,c){let l;r.range(i,a).forEach(r=>{l=t[r],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let r=e.node(t);r.dummy&&(r.order<o||r.order>c)&&s(n,t,l)})})}function a(t,n){let r=-1,a,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);t.length&&(a=e.node(t[0]).order,i(n,o,c,r,a),o=c,r=a)}i(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(a),n}function o(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}function s(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function c(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function l(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s.length){s=s.sort((e,t)=>o[e]-o[t]);let r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){let r=s[l];a[e]===e&&t<o[r]&&!c(n,e,r)&&(a[r]=e,a[e]=i[e]=i[r],t=o[r])}}})}),{root:i,align:a}}function u(e,t,n,r,i){let a={},o=d(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes(),r=n.pop(),i={};for(;r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function l(e){a[e]=o.inEdges(e).reduce((e,t)=>Math.max(e,a[t.v]+o.edge(t)),0)}function u(t){let n=o.outEdges(t).reduce((e,t)=>Math.min(e,a[t.w]-o.edge(t)),1/0),r=e.node(t);n!==1/0&&r.borderType!==s&&(a[t]=Math.max(a[t],n))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),Object.keys(r).forEach(e=>a[e]=a[n[e]]),a}function d(e,t,r,i){let a=new n,o=e.graph(),s=g(o.nodesep,o.edgesep,i);return t.forEach(t=>{let n;t.forEach(t=>{let i=r[t];if(a.setNode(i),n){var o=r[n],c=a.edge(o,i);a.setEdge(o,i,Math.max(s(e,t,n),c||0))}n=t})}),a}function f(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=_(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function p(e,t){let n=Object.values(t),i=r.applyWithChunking(Math.min,n),a=r.applyWithChunking(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(o=>{let s=n+o,c=e[s];if(c===t)return;let l=Object.values(c),u=i-r.applyWithChunking(Math.min,l);o!==`l`&&(u=a-r.applyWithChunking(Math.max,l)),u&&(e[s]=r.mapValues(c,e=>e+u))})})}function m(e,t){return r.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map(e=>e[r]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}function h(e){let t=r.buildLayerMatrix(e),n=Object.assign(i(e,t),a(e,t)),o={},s;return[`u`,`d`].forEach(i=>{s=i===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(s=s.map(e=>Object.values(e).reverse()));let a=(i===`u`?e.predecessors:e.successors).bind(e),c=l(e,s,n,a),d=u(e,s,c.root,c.align,t===`r`);t===`r`&&(d=r.mapValues(d,e=>-e)),o[i+t]=d})}),p(o,f(e,o)),m(o,e.graph().align)}function g(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function _(e,t){return e.node(t).width}})),EL=o(((e,t)=>{var n=aL(),r=TL().positionX;t.exports=i;function i(e){e=n.asNonCompoundGraph(e),a(e),Object.entries(r(e)).forEach(([t,n])=>e.node(t).x=n)}function a(e){let t=n.buildLayerMatrix(e),r=e.graph().ranksep,i=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height;return t>r?t:r},0);t.forEach(t=>e.node(t).y=i+n/2),i+=n+r})}})),DL=o(((e,t)=>{var n=oL(),r=sL(),i=dL(),a=aL().normalizeRanks,o=fL(),s=aL().removeEmptyRanks,c=pL(),l=mL(),u=hL(),d=wL(),f=EL(),p=aL(),m=nL().Graph;t.exports=h;function h(e,t){let n=t&&t.debugTiming?p.time:p.notime;n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>E(e));n(` runLayout`,()=>g(r,n,t)),n(` updateInputGraph`,()=>_(e,r))})}function g(e,t,m){t(` makeSpaceForEdgeLabels`,()=>D(e)),t(` removeSelfEdges`,()=>I(e)),t(` acyclic`,()=>n.run(e)),t(` nestingGraph.run`,()=>c.run(e)),t(` rank`,()=>i(p.asNonCompoundGraph(e))),t(` injectEdgeLabelProxies`,()=>O(e)),t(` removeEmptyRanks`,()=>s(e)),t(` nestingGraph.cleanup`,()=>c.cleanup(e)),t(` normalizeRanks`,()=>a(e)),t(` assignRankMinMax`,()=>k(e)),t(` removeEdgeLabelProxies`,()=>A(e)),t(` normalize.run`,()=>r.run(e)),t(` parentDummyChains`,()=>o(e)),t(` addBorderSegments`,()=>l(e)),t(` order`,()=>d(e,m)),t(` insertSelfEdges`,()=>L(e)),t(` adjustCoordinateSystem`,()=>u.adjust(e)),t(` position`,()=>f(e)),t(` positionSelfEdges`,()=>ee(e)),t(` removeBorderNodes`,()=>F(e)),t(` normalize.undo`,()=>r.undo(e)),t(` fixupEdgeLabelCoords`,()=>N(e)),t(` undoCoordinateSystem`,()=>u.undo(e)),t(` translateGraph`,()=>j(e)),t(` assignNodeIntersects`,()=>M(e)),t(` reversePoints`,()=>P(e)),t(` acyclic.undo`,()=>n.undo(e))}function _(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var v=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],y={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},b=[`acyclicer`,`ranker`,`rankdir`,`align`],x=[`width`,`height`,`rank`],S={width:0,height:0},C=[`minlen`,`weight`,`width`,`height`,`labeloffset`],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},T=[`labelpos`];function E(e){let t=new m({multigraph:!0,compound:!0}),n=ne(e.graph());return t.setGraph(Object.assign({},y,te(n,v),p.pick(n,b))),e.nodes().forEach(n=>{let r=te(ne(e.node(n)),x);Object.keys(S).forEach(e=>{r[e]===void 0&&(r[e]=S[e])}),t.setNode(n,r),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let r=ne(e.edge(n));t.setEdge(n,Object.assign({},w,te(r,C),p.pick(r,T)))}),t}function D(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function O(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};p.addDummyNode(e,`edge-proxy`,r,`_ep`)}})}function k(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function A(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function j(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function M(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(p.intersectRect(r,a)),n.points.push(p.intersectRect(i,o))})}function N(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function P(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function F(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function I(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function L(e){p.buildLayerMatrix(e).forEach(t=>{var n=0;t.forEach((t,r)=>{var i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{p.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function ee(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function te(e,t){return p.mapValues(p.pick(e,t),Number)}function ne(e){var t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}})),OL=o(((e,t)=>{var n=aL(),r=nL().Graph;t.exports={debugOrdering:i};function i(e){let t=n.buildLayerMatrix(e),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{i.setNode(t,{label:t}),i.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>i.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let n=`layer`+t;i.setNode(n,{rank:`same`}),e.reduce((e,t)=>(i.setEdge(e,t,{style:`invis`}),t))}),i}})),kL=o(((e,t)=>{t.exports=`1.1.5`})),AL=l(o(((e,t)=>{t.exports={graphlib:nL(),layout:DL(),debug:OL(),util:{time:aL().time,notime:aL().notime},version:kL()}}))(),1),jL=[`pending`,`ready`,`running`,`waiting`,`blocked`,`skipped`,`done`,`not-completed`,`failed`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`,`unknown`],ML=200,NL=72,PL=80,FL=32,IL=20,LL=e=>NL+Math.max(0,Math.floor(e.lines??0))*IL,RL=new Set(jL),zL={pending:`neutral`,ready:`neutral`,running:`active`,waiting:`blocked`,blocked:`blocked`,skipped:`blocked`,done:`success`,"not-completed":`danger`,failed:`danger`,parked:`muted`,cancelled:`muted`,"complete-but-draft":`blocked`,"complete-but-held":`blocked`,unknown:`neutral`},BL=(e,t)=>e<t?-1:+(e>t);function VL(e){let t=[...e.nodes].sort((e,t)=>BL(e.id,t.id)),n=[...e.edges].sort((e,t)=>BL(e.id,t.id)),r=new Map(t.map(e=>[e.id,e]));if(r.size!==t.length)throw Error(`DAG node IDs must be unique`);for(let e of t)if(!RL.has(e.state))throw Error(`DAG node ${e.id} has unsupported state ${e.state}`);let i=new Map(t.map(e=>[e.id,0])),a=new Map(t.map(e=>[e.id,[]])),o=new Set;for(let e of n){if(o.has(e.id))throw Error(`DAG edge IDs must be unique`);if(o.add(e.id),!r.has(e.source)||!r.has(e.target))throw Error(`DAG edge ${e.id} has a missing endpoint`);if(e.source===e.target)throw Error(`DAG edge ${e.id} is a self-edge`);i.set(e.target,(i.get(e.target)??0)+1),a.get(e.source)?.push(e.target)}let s=new Map,c=t.filter(e=>i.get(e.id)===0).map(e=>e.id),l=0;for(;c.length>0;){let e=c;c=[];for(let t of e){l+=1;let e=s.get(t)??0;for(let n of a.get(t)??[]){s.set(n,Math.max(s.get(n)??0,e+1));let t=(i.get(n)??0)-1;i.set(n,t),t===0&&c.push(n)}}c.sort()}if(l!==t.length)throw Error(`DAG contains a cycle`);let u=new AL.default.graphlib.Graph({multigraph:!0});u.setGraph({rankdir:`LR`,ranksep:PL,nodesep:FL,marginx:0,marginy:0}),u.setDefaultEdgeLabel(()=>({}));for(let e of t)u.setNode(e.id,{width:ML,height:LL(e)});for(let e of n)u.setEdge(e.source,e.target,{},e.id);AL.default.layout(u);let d=new Map;for(let e of t){let t=s.get(e.id)??0,n=d.get(t)??[];n.push(e.id),d.set(t,n)}for(let e of d.values())e.sort((e,t)=>(u.node(e)?.y??0)-(u.node(t)?.y??0)||BL(e,t));let f=new Map;for(let e of d.values()){let t=0;for(let n of e){f.set(n,t);let e=r.get(n);t+=(e===void 0?NL:LL(e))+FL}}let p=t.map(e=>{let t=s.get(e.id)??0;return{...e,x:t*280,y:f.get(e.id)??0,width:ML,height:LL(e),style:zL[e.state]}}),m=new Map(p.map(e=>[e.id,e])),h=n.map(e=>{let t=m.get(e.source),n=m.get(e.target);if(!t||!n)throw Error(`DAG layout lost an edge endpoint`);let r={x:t.x+t.width,y:t.y+t.height/2},i={x:n.x,y:n.y+n.height/2},a=Math.round((r.x+i.x)/2);return{...e,points:[r,{x:a,y:r.y},{x:a,y:i.y},i]}});return{width:p.length===0?0:Math.max(...p.map(e=>e.x+e.width)),height:p.length===0?0:Math.max(...p.map(e=>e.y+e.height)),nodes:p,edges:h}}function HL(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=HL(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var UL={value:()=>{}};function WL(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new GL(n)}function GL(e){this._=e}function KL(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}GL.prototype=WL.prototype={constructor:GL,on:function(e,t){var n=this._,r=KL(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=qL(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=JL(n[i],e.name,t);else if(t==null)for(i in n)n[i]=JL(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new GL(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function qL(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function JL(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=UL,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var YL={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function XL(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),YL.hasOwnProperty(t)?{space:YL[t],local:e}:e}function ZL(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function QL(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $L(e){var t=XL(e);return(t.local?QL:ZL)(t)}function eR(){}function tR(e){return e==null?eR:function(){return this.querySelector(e)}}function nR(e){typeof e!=`function`&&(e=tR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Wz(r,this._parents)}function rR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function iR(){return[]}function aR(e){return e==null?iR:function(){return this.querySelectorAll(e)}}function oR(e){return function(){return rR(e.apply(this,arguments))}}function sR(e){e=typeof e==`function`?oR(e):aR(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Wz(r,i)}function cR(e){return function(){return this.matches(e)}}function lR(e){return function(t){return t.matches(e)}}var uR=Array.prototype.find;function dR(e){return function(){return uR.call(this.children,e)}}function fR(){return this.firstElementChild}function pR(e){return this.select(e==null?fR:dR(typeof e==`function`?e:lR(e)))}var mR=Array.prototype.filter;function hR(){return Array.from(this.children)}function gR(e){return function(){return mR.call(this.children,e)}}function _R(e){return this.selectAll(e==null?hR:gR(typeof e==`function`?e:lR(e)))}function vR(e){typeof e!=`function`&&(e=cR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Wz(r,this._parents)}function yR(e){return Array(e.length)}function bR(){return new Wz(this._enter||this._groups.map(yR),this._parents)}function xR(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}xR.prototype={constructor:xR,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function SR(e){return function(){return e}}function CR(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new xR(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function wR(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new xR(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function TR(e){return e.__data__}function ER(e,t){if(!arguments.length)return Array.from(this,TR);var n=t?wR:CR,r=this._parents,i=this._groups;typeof e!=`function`&&(e=SR(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=DR(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Wz(o,r),o._enter=s,o._exit=c,o}function DR(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function OR(){return new Wz(this._exit||this._groups.map(yR),this._parents)}function kR(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function AR(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Wz(s,this._parents)}function jR(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],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 MR(e){e||=NR;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Wz(i,this._parents).order()}function NR(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function PR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function FR(){return Array.from(this)}function IR(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function LR(){let e=0;for(let t of this)++e;return e}function RR(){return!this.node()}function zR(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function BR(e){return function(){this.removeAttribute(e)}}function VR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function HR(e,t){return function(){this.setAttribute(e,t)}}function UR(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function WR(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function GR(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function KR(e,t){var n=XL(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?VR:BR:typeof t==`function`?n.local?GR:WR:n.local?UR:HR)(n,t))}function qR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JR(e){return function(){this.style.removeProperty(e)}}function YR(e,t,n){return function(){this.style.setProperty(e,t,n)}}function XR(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ZR(e,t,n){return arguments.length>1?this.each((t==null?JR:typeof t==`function`?XR:YR)(e,t,n??``)):QR(this.node(),e)}function QR(e,t){return e.style.getPropertyValue(t)||qR(e).getComputedStyle(e,null).getPropertyValue(t)}function $R(e){return function(){delete this[e]}}function ez(e,t){return function(){this[e]=t}}function tz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function nz(e,t){return arguments.length>1?this.each((t==null?$R:typeof t==`function`?tz:ez)(e,t)):this.node()[e]}function rz(e){return e.trim().split(/^|\s+/)}function iz(e){return e.classList||new az(e)}function az(e){this._node=e,this._names=rz(e.getAttribute(`class`)||``)}az.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function oz(e,t){for(var n=iz(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function sz(e,t){for(var n=iz(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function cz(e){return function(){oz(this,e)}}function lz(e){return function(){sz(this,e)}}function uz(e,t){return function(){(t.apply(this,arguments)?oz:sz)(this,e)}}function dz(e,t){var n=rz(e+``);if(arguments.length<2){for(var r=iz(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?uz:t?cz:lz)(n,t))}function fz(){this.textContent=``}function pz(e){return function(){this.textContent=e}}function mz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function hz(e){return arguments.length?this.each(e==null?fz:(typeof e==`function`?mz:pz)(e)):this.node().textContent}function gz(){this.innerHTML=``}function _z(e){return function(){this.innerHTML=e}}function vz(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function yz(e){return arguments.length?this.each(e==null?gz:(typeof e==`function`?vz:_z)(e)):this.node().innerHTML}function bz(){this.nextSibling&&this.parentNode.appendChild(this)}function xz(){return this.each(bz)}function Sz(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cz(){return this.each(Sz)}function wz(e){var t=typeof e==`function`?e:$L(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Tz(){return null}function Ez(e,t){var n=typeof e==`function`?e:$L(e),r=t==null?Tz:typeof t==`function`?t:tR(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Dz(){var e=this.parentNode;e&&e.removeChild(this)}function Oz(){return this.each(Dz)}function kz(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Az(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jz(e){return this.select(e?Az:kz)}function Mz(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Nz(e){return function(t){e.call(this,t,this.__data__)}}function Pz(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Fz(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Iz(e,t,n){return function(){var r=this.__on,i,a=Nz(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Lz(e,t,n){var r=Pz(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Iz:Fz,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function Rz(e,t,n){var r=qR(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function zz(e,t){return function(){return Rz(this,e,t)}}function Bz(e,t){return function(){return Rz(this,e,t.apply(this,arguments))}}function Vz(e,t){return this.each((typeof t==`function`?Bz:zz)(e,t))}function*Hz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Uz=[null];function Wz(e,t){this._groups=e,this._parents=t}function Gz(){return new Wz([[document.documentElement]],Uz)}function Kz(){return this}Wz.prototype=Gz.prototype={constructor:Wz,select:nR,selectAll:sR,selectChild:pR,selectChildren:_R,filter:vR,data:ER,enter:bR,exit:OR,join:kR,merge:AR,selection:Kz,order:jR,sort:MR,call:PR,nodes:FR,node:IR,size:LR,empty:RR,each:zR,attr:KR,style:ZR,property:nz,classed:dz,text:hz,html:yz,raise:xz,lower:Cz,append:wz,insert:Ez,remove:Oz,clone:jz,datum:Mz,on:Lz,dispatch:Vz,[Symbol.iterator]:Hz};function qz(e){return typeof e==`string`?new Wz([[document.querySelector(e)]],[document.documentElement]):new Wz([[e]],Uz)}function Jz(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Yz(e,t){if(e=Jz(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Xz={passive:!1},Zz={capture:!0,passive:!1};function Qz(e){e.stopImmediatePropagation()}function $z(e){e.preventDefault(),e.stopImmediatePropagation()}function eB(e){var t=e.document.documentElement,n=qz(e).on(`dragstart.drag`,$z,Zz);`onselectstart`in t?n.on(`selectstart.drag`,$z,Zz):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function tB(e,t){var n=e.document.documentElement,r=qz(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,$z,Zz),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var nB=e=>()=>e;function rB(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}rB.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iB(e){return!e.ctrlKey&&!e.button}function aB(){return this.parentNode}function oB(e,t){return t??{x:e.x,y:e.y}}function sB(){return navigator.maxTouchPoints||`ontouchstart`in this}function cB(){var e=iB,t=aB,n=oB,r=sB,i={},a=WL(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Xz).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(qz(n.view).on(`mousemove.drag`,m,Zz).on(`mouseup.drag`,h,Zz),eB(n.view),Qz(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if($z(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){qz(e.view).on(`mousemove.drag mouseup.drag`,null),tB(e.view,l),$z(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(Qz(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&($z(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(Qz(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Yz(l||r,t),p,m,h;if((h=n.call(e,new rB(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Yz(l||a,t),_=o;break}u.call(r,e,new rB(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:nB(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:nB(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:nB(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:nB(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function lB(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function uB(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function dB(){}var fB=.7,pB=1/fB,mB=`\\s*([+-]?\\d+)\\s*`,hB=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,gB=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,_B=/^#([0-9a-f]{3,8})$/,vB=RegExp(`^rgb\\(${mB},${mB},${mB}\\)$`),yB=RegExp(`^rgb\\(${gB},${gB},${gB}\\)$`),bB=RegExp(`^rgba\\(${mB},${mB},${mB},${hB}\\)$`),xB=RegExp(`^rgba\\(${gB},${gB},${gB},${hB}\\)$`),SB=RegExp(`^hsl\\(${hB},${gB},${gB}\\)$`),CB=RegExp(`^hsla\\(${hB},${gB},${gB},${hB}\\)$`),wB={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};lB(dB,kB,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:TB,formatHex:TB,formatHex8:EB,formatHsl:DB,formatRgb:OB,toString:OB});function TB(){return this.rgb().formatHex()}function EB(){return this.rgb().formatHex8()}function DB(){return HB(this).formatHsl()}function OB(){return this.rgb().formatRgb()}function kB(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=_B.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?AB(t):n===3?new PB(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jB(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jB(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=vB.exec(e))?new PB(t[1],t[2],t[3],1):(t=yB.exec(e))?new PB(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bB.exec(e))?jB(t[1],t[2],t[3],t[4]):(t=xB.exec(e))?jB(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=SB.exec(e))?VB(t[1],t[2]/100,t[3]/100,1):(t=CB.exec(e))?VB(t[1],t[2]/100,t[3]/100,t[4]):wB.hasOwnProperty(e)?AB(wB[e]):e===`transparent`?new PB(NaN,NaN,NaN,0):null}function AB(e){return new PB(e>>16&255,e>>8&255,e&255,1)}function jB(e,t,n,r){return r<=0&&(e=t=n=NaN),new PB(e,t,n,r)}function MB(e){return e instanceof dB||(e=kB(e)),e?(e=e.rgb(),new PB(e.r,e.g,e.b,e.opacity)):new PB}function NB(e,t,n,r){return arguments.length===1?MB(e):new PB(e,t,n,r??1)}function PB(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}lB(PB,NB,uB(dB,{brighter(e){return e=e==null?pB:pB**+e,new PB(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fB:fB**+e,new PB(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new PB(zB(this.r),zB(this.g),zB(this.b),RB(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:FB,formatHex:FB,formatHex8:IB,formatRgb:LB,toString:LB}));function FB(){return`#${BB(this.r)}${BB(this.g)}${BB(this.b)}`}function IB(){return`#${BB(this.r)}${BB(this.g)}${BB(this.b)}${BB((isNaN(this.opacity)?1:this.opacity)*255)}`}function LB(){let e=RB(this.opacity);return`${e===1?`rgb(`:`rgba(`}${zB(this.r)}, ${zB(this.g)}, ${zB(this.b)}${e===1?`)`:`, ${e})`}`}function RB(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zB(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function BB(e){return e=zB(e),(e<16?`0`:``)+e.toString(16)}function VB(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new WB(e,t,n,r)}function HB(e){if(e instanceof WB)return new WB(e.h,e.s,e.l,e.opacity);if(e instanceof dB||(e=kB(e)),!e)return new WB;if(e instanceof WB)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new WB(o,s,c,e.opacity)}function UB(e,t,n,r){return arguments.length===1?HB(e):new WB(e,t,n,r??1)}function WB(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}lB(WB,UB,uB(dB,{brighter(e){return e=e==null?pB:pB**+e,new WB(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fB:fB**+e,new WB(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new PB(qB(e>=240?e-240:e+120,i,r),qB(e,i,r),qB(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new WB(GB(this.h),KB(this.s),KB(this.l),RB(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=RB(this.opacity);return`${e===1?`hsl(`:`hsla(`}${GB(this.h)}, ${KB(this.s)*100}%, ${KB(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function GB(e){return e=(e||0)%360,e<0?e+360:e}function KB(e){return Math.max(0,Math.min(1,e||0))}function qB(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var JB=e=>()=>e;function YB(e,t){return function(n){return e+n*t}}function XB(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function ZB(e){return(e=+e)==1?QB:function(t,n){return n-t?XB(t,n,e):JB(isNaN(t)?n:t)}}function QB(e,t){var n=t-e;return n?YB(e,n):JB(isNaN(e)?t:e)}var $B=(function e(t){var n=ZB(t);function r(e,t){var r=n((e=NB(e)).r,(t=NB(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=QB(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function eV(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function tV(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function nV(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=dV(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function rV(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function iV(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function aV(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=dV(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var oV=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,sV=new RegExp(oV.source,`g`);function cV(e){return function(){return e}}function lV(e){return function(t){return e(t)+``}}function uV(e,t){var n=oV.lastIndex=sV.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=oV.exec(e))&&(i=sV.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:iV(r,i)})),n=sV.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?lV(c[0].x):cV(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function dV(e,t){var n=typeof t,r;return t==null||n===`boolean`?JB(t):(n===`number`?iV:n===`string`?(r=kB(t))?(t=r,$B):uV:t instanceof kB?$B:t instanceof Date?rV:tV(t)?eV:Array.isArray(t)?nV:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?aV:iV)(e,t)}var fV=180/Math.PI,pV={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mV(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*fV,skewX:Math.atan(c)*fV,scaleX:o,scaleY:s}}var hV;function gV(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?pV:mV(t.a,t.b,t.c,t.d,t.e,t.f)}function _V(e){return e==null||(hV||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),hV.setAttribute(`transform`,e),!(e=hV.transform.baseVal.consolidate()))?pV:(e=e.matrix,mV(e.a,e.b,e.c,e.d,e.e,e.f))}function vV(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:iV(e,i)},{i:c-2,x:iV(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:iV(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:iV(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:iV(e,n)},{i:s-2,x:iV(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var yV=vV(gV,`px, `,`px)`,`deg)`),bV=vV(_V,`, `,`)`,`)`),xV=1e-12;function SV(e){return((e=Math.exp(e))+1/e)/2}function CV(e){return((e=Math.exp(e))-1/e)/2}function wV(e){return((e=Math.exp(2*e))-1)/(e+1)}var TV=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<xV)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=SV(y),c=s/(n*g)*(i*wV(t*r+y)-CV(y));return[a+c*d,o+c*f,s*i/SV(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),EV=0,DV=0,OV=0,kV=1e3,AV,jV,MV=0,NV=0,PV=0,FV=typeof performance==`object`&&performance.now?performance:Date,IV=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function LV(){return NV||=(IV(RV),FV.now()+PV)}function RV(){NV=0}function zV(){this._call=this._time=this._next=null}zV.prototype=BV.prototype={constructor:zV,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?LV():+n)+(t==null?0:+t),!this._next&&jV!==this&&(jV?jV._next=this:AV=this,jV=this),this._call=e,this._time=n,GV()},stop:function(){this._call&&(this._call=null,this._time=1/0,GV())}};function BV(e,t,n){var r=new zV;return r.restart(e,t,n),r}function VV(){LV(),++EV;for(var e=AV,t;e;)(t=NV-e._time)>=0&&e._call.call(void 0,t),e=e._next;--EV}function HV(){NV=(MV=FV.now())+PV,EV=DV=0;try{VV()}finally{EV=0,WV(),NV=0}}function UV(){var e=FV.now(),t=e-MV;t>kV&&(PV-=t,MV=e)}function WV(){for(var e,t=AV,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:AV=n);jV=e,GV(r)}function GV(e){EV||(DV&&=clearTimeout(DV),e-NV>24?(e<1/0&&(DV=setTimeout(HV,e-FV.now()-PV)),OV&&=clearInterval(OV)):(OV||=(MV=FV.now(),setInterval(UV,kV)),EV=1,IV(HV)))}function KV(e,t,n){var r=new zV;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var qV=WL(`start`,`end`,`cancel`,`interrupt`),JV=[];function YV(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;$V(e,n,{name:t,index:r,group:i,on:qV,tween:JV,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function XV(e,t){var n=QV(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function ZV(e,t){var n=QV(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function QV(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function $V(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=BV(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return KV(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(KV(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function eH(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function tH(e){return this.each(function(){eH(this,e)})}function nH(e,t){var n,r;return function(){var i=ZV(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function rH(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=ZV(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function iH(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=QV(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?nH:rH)(n,e,t))}function aH(e,t,n){var r=e._id;return e.each(function(){var e=ZV(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return QV(e,r).value[t]}}function oH(e,t){var n;return(typeof t==`number`?iV:t instanceof kB?$B:(n=kB(t))?(t=n,$B):uV)(e,t)}function sH(e){return function(){this.removeAttribute(e)}}function cH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lH(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function uH(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function dH(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function fH(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pH(e,t){var n=XL(e),r=n===`transform`?bV:oH;return this.attrTween(e,typeof t==`function`?(n.local?fH:dH)(n,r,aH(this,`attr.`+e,t)):t==null?(n.local?cH:sH)(n):(n.local?uH:lH)(n,r,t))}function mH(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function hH(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function gH(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hH(e,i)),n}return i._value=t,i}function _H(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&mH(e,i)),n}return i._value=t,i}function vH(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=XL(e);return this.tween(n,(r.local?gH:_H)(r,t))}function yH(e,t){return function(){XV(this,e).delay=+t.apply(this,arguments)}}function bH(e,t){return t=+t,function(){XV(this,e).delay=t}}function xH(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?yH:bH)(t,e)):QV(this.node(),t).delay}function SH(e,t){return function(){ZV(this,e).duration=+t.apply(this,arguments)}}function CH(e,t){return t=+t,function(){ZV(this,e).duration=t}}function wH(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?SH:CH)(t,e)):QV(this.node(),t).duration}function TH(e,t){if(typeof t!=`function`)throw Error();return function(){ZV(this,e).ease=t}}function EH(e){var t=this._id;return arguments.length?this.each(TH(t,e)):QV(this.node(),t).ease}function DH(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();ZV(this,e).ease=n}}function OH(e){if(typeof e!=`function`)throw Error();return this.each(DH(this._id,e))}function kH(e){typeof e!=`function`&&(e=cR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new iU(r,this._parents,this._name,this._id)}function AH(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new iU(o,this._parents,this._name,this._id)}function jH(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function MH(e,t,n){var r,i,a=jH(t)?XV:ZV;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function NH(e,t){var n=this._id;return arguments.length<2?QV(this.node(),n).on.on(e):this.each(MH(n,e,t))}function PH(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function FH(){return this.on(`end.remove`,PH(this._id))}function IH(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=tR(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,YV(l[f],t,n,f,l,QV(u,n)));return new iU(a,this._parents,t,n)}function LH(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=aR(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=QV(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&YV(p,t,n,h,f,m);a.push(f),o.push(u)}return new iU(a,o,t,n)}var RH=Gz.prototype.constructor;function zH(){return new RH(this._groups,this._parents)}function BH(e,t){var n,r,i;return function(){var a=QR(this,e),o=(this.style.removeProperty(e),QR(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function VH(e){return function(){this.style.removeProperty(e)}}function HH(e,t,n){var r,i=n+``,a;return function(){var o=QR(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function UH(e,t,n){var r,i,a;return function(){var o=QR(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),QR(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function WH(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=ZV(this,e),l=c.on,u=c.value[a]==null?s||=VH(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function GH(e,t,n){var r=(e+=``)==`transform`?yV:oH;return t==null?this.styleTween(e,BH(e,r)).on(`end.style.`+e,VH(e)):typeof t==`function`?this.styleTween(e,UH(e,r,aH(this,`style.`+e,t))).each(WH(this._id,e)):this.styleTween(e,HH(e,r,t),n).on(`end.style.`+e,null)}function KH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function qH(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&KH(e,a,n)),r}return a._value=t,a}function JH(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,qH(e,t,n??``))}function YH(e){return function(){this.textContent=e}}function XH(e){return function(){var t=e(this);this.textContent=t??``}}function ZH(e){return this.tween(`text`,typeof e==`function`?XH(aH(this,`text`,e)):YH(e==null?``:e+``))}function QH(e){return function(t){this.textContent=e.call(this,t)}}function $H(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&QH(r)),t}return r._value=e,r}function eU(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,$H(e))}function tU(){for(var e=this._name,t=this._id,n=oU(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=QV(c,t);YV(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new iU(r,this._parents,e,n)}function nU(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=ZV(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var rU=0;function iU(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function aU(e){return Gz().transition(e)}function oU(){return++rU}var sU=Gz.prototype;iU.prototype=aU.prototype={constructor:iU,select:IH,selectAll:LH,selectChild:sU.selectChild,selectChildren:sU.selectChildren,filter:kH,merge:AH,selection:zH,transition:tU,call:sU.call,nodes:sU.nodes,node:sU.node,size:sU.size,empty:sU.empty,each:sU.each,on:NH,attr:pH,attrTween:vH,style:GH,styleTween:JH,text:ZH,textTween:eU,remove:FH,tween:iH,delay:xH,duration:wH,ease:EH,easeVarying:OH,end:nU,[Symbol.iterator]:sU[Symbol.iterator]};function cU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lU={time:null,delay:0,duration:250,ease:cU};function uU(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function dU(e){var t,n;e instanceof iU?(t=e._id,e=e._name):(t=oU(),(n=lU).time=LV(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&YV(c,e,t,l,o,n||uU(c,t));return new iU(r,this._parents,e,t)}Gz.prototype.interrupt=tH,Gz.prototype.transition=dU;var fU=e=>()=>e;function pU(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function mU(e,t,n){this.k=e,this.x=t,this.y=n}mU.prototype={constructor:mU,scale:function(e){return e===1?this:new mU(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new mU(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var hU=new mU(1,0,0);gU.prototype=mU.prototype;function gU(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hU;return e.__zoom}function _U(e){e.stopImmediatePropagation()}function vU(e){e.preventDefault(),e.stopImmediatePropagation()}function yU(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function bU(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function xU(){return this.__zoom||hU}function SU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function CU(){return navigator.maxTouchPoints||`ontouchstart`in this}function wU(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.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 TU(){var e=yU,t=bU,n=wU,r=SU,i=CU,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=TV,l=WL(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,xU).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,xU),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(hU.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new mU(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new mU(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new mU(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=qz(this.that).datum();l.call(e,this.that,new pU(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Yz(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],eH(this),s.start();vU(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=qz(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Yz(t,i),l=t.clientX,u=t.clientY;eB(t.view),_U(t),a.mouse=[c,this.__zoom.invert(c)],eH(this),a.start();function d(e){if(vU(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Yz(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),tB(e.view,a.moved),vU(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Yz(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);vU(r),s>0?qz(this).transition().duration(s).call(x,d,c,r):qz(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(_U(t),s=0;s<i;++s)c=r[s],l=Yz(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),eH(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(vU(e),s=0;s<a;++s)c=i[s],l=Yz(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(_U(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.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&&(o=Yz(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=qz(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:fU(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:fU(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:fU(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:fU([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var EU={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.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:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The 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:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/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.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},DU=[[-1/0,-1/0],[1/0,1/0]],OU=[`Enter`,` `,`Escape`],kU={"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:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, 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`},AU;(function(e){e.Strict=`strict`,e.Loose=`loose`})(AU||={});var jU;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(jU||={});var MU;(function(e){e.Partial=`partial`,e.Full=`full`})(MU||={});var NU={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},PU;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(PU||={});var FU;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(FU||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var IU={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function LU(e){return e===null?null:e?`valid`:`invalid`}var RU=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,zU=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),BU=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),VU=(e,t=[0,0])=>{let{width:n,height:r}=xW(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},HU=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:rW(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):BU(n)?n:t.nodeLookup.get(n.id)),tW(e,i?aW(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),UU=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=tW(n,aW(e)),r=!0)}),r?rW(n):{x:0,y:0,width:0,height:0}},WU=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=sW(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},GU=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function KU(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=xW(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function qU({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=vW(UU(KU(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function JU({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,EU.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&bW(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=bW(d)?ZU(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,EU.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function YU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=GU(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var XU=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ZU=(e={x:0,y:0},t,n)=>({x:XU(e.x,t[0][0],t[1][0]-(n?.width??0)),y:XU(e.y,t[0][1],t[1][1]-(n?.height??0))});function QU(e,t,n){let{width:r,height:i}=xW(n),{x:a,y:o}=n.internals.positionAbsolute;return ZU(e,[[a,o],[a+r,o+i]],t)}var $U=(e,t,n)=>e<t?XU(Math.abs(e-t),1,t)/t:e>n?-XU(Math.abs(e-n),1,t)/t:0,eW=(e,t,n=15,r=40)=>[$U(e.x,r,t.width-r)*n,$U(e.y,r,t.height-r)*n],tW=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),nW=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),rW=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),iW=(e,t=[0,0])=>{let{x:n,y:r}=BU(e)?e.internals.positionAbsolute:VU(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},aW=(e,t=[0,0])=>{let{x:n,y:r}=BU(e)?e.internals.positionAbsolute:VU(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},oW=(e,t)=>rW(tW(nW(e),nW(t))),sW=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},cW=(e,t)=>sW(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),lW=e=>uW(e.width)&&uW(e.height)&&uW(e.x)&&uW(e.y),uW=e=>!isNaN(e)&&isFinite(e),dW=(e,t)=>(e,t)=>{},fW=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),pW=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?fW(s,o):s},mW=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function hW(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gW(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=hW(e,n),i=hW(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=hW(e.top??e.y??0,n),i=hW(e.bottom??e.y??0,n),a=hW(e.left??e.x??0,t),o=hW(e.right??e.x??0,t);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 _W(e,t,n,r,i,a){let{x:o,y:s}=mW(e,[t,n,r]),{x:c,y:l}=mW({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var vW=(e,t,n,r,i,a)=>{let o=gW(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=XU(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=_W(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},yW=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function bW(e){return e!=null&&e!==`parent`}function xW(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function SW(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function CW(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function wW(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function TW(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function EW(e){return{...kU,...e||{}}}function DW(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=NW(e),s=pW({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?fW(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var OW=e=>({width:e.offsetWidth,height:e.offsetHeight}),kW=e=>e?.getRootNode?.()||window?.document,AW=[`INPUT`,`SELECT`,`TEXTAREA`];function jW(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?AW.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var MW=e=>`clientX`in e,NW=(e,t)=>{let n=MW(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},PW=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...OW(t)}})};function FW({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function IW(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function LW({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-IW(t-r,a),n];case $.Right:return[t+IW(r-t,a),n];case $.Top:return[t,n-IW(n-i,a)];case $.Bottom:return[t,n+IW(i-n,a)]}}function RW({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=LW({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=LW({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=FW({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function zW({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function BW({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function VW({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=tW(aW(e),aW(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),cW({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},rW(a))>0}var HW=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,UW=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),WW=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,EU.error006()),t;let r=n.getEdgeId||HW,i;return i=RU(e)?{...e}:{...e,id:r(e)},UW(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function GW({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=zW({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var KW={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},qW=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},JW=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function YW({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=KW[t],c=KW[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=qW({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=zW({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function XW(e,t,n,r){let i=Math.min(JW(e,t)/2,JW(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function ZW({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=YW({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=XW(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function QW(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function $W(e){let{sourceNode:t,targetNode:n}=e;if(!QW(t)||!QW(n))return null;let r=t.internals.handleBounds||eG(t.handles),i=n.internals.handleBounds||eG(n.handles),a=nG(r?.source??[],e.sourceHandle),o=nG(e.connectionMode===AU.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,EU.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=tG(t,a,s),u=tG(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function eG(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function tG(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??xW(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function nG(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function rG(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function iG(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=rG(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var aG=1e3,oG=10,sG={nodeOrigin:[0,0],nodeExtent:DU,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},cG={...sG,checkEquality:!0};function lG(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function uG(e,t,n){let r=lG(sG,n);for(let n of e.values())if(n.parentId)hG(n,e,t,r);else{let e=ZU(VU(n,r.nodeOrigin),bW(n.extent)?n.extent:r.nodeExtent,xW(n));n.internals.positionAbsolute=e}}function dG(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function fG(e){return e===`manual`}function pG(e,t,n,r={}){let i=lG(cG,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!fG(i.zIndexMode)?aG:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=ZU(VU(u,i.nodeOrigin),bW(u.extent)?u.extent:i.nodeExtent,xW(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:dG(u,e),z:gG(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&hG(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mG(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function hG(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=lG(sG,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mG(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*oG),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=_G(e,u,o,s,a&&!fG(c)?aG:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function gG(e,t,n){let r=uW(e.zIndex)?e.zIndex:0;return fG(n)?r:r+(e.selected?t:0)}function _G(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=xW(e),l=VU(e,n),u=bW(e.extent)?ZU(l,e.extent,c):l,d=ZU({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=QU(d,c,t));let f=gG(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function vG(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=oW(a.get(n.parentId)?.expandedRect??iW(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=xW(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function yG(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=OW(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=bW(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=QU(h,s,n))}else m&&(h=ZU(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:PW(`source`,r.nodeElement,p,d,e.id),target:PW(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&hG(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:iW(g,i)}))}}if(f.length>0){let e=vG(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function bG({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function xG(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function SG(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;xG(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),xG(`target`,s,c,e,i,o),t.set(r.id,r)}}function CG(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:CG(n,t):!1}function wG(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function TG(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!CG(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function EG({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function DG({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=fW(a,t);return{x:o.x-a.x,y:o.y-a.y}}function OG({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=qz(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?nW(UU(s)):null,x=v&&l?DG({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:fW(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=JU({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=EG({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=eW(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=DW(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=TG(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=EG({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=cB().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=DW(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=NW(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=DW(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=NW(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=NW(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=EG({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!wG(t,`.${g}`,v))&&(!_||wG(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function kG(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())cW(i,iW(e))>0&&r.push(e);return r}var AG=250;function jG(e,t,n,r){let i=[],a=1/0,o=kG(e,n,t+AG);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=tG(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function MG(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...tG(o,c,c.position,!0)}:c}function NG(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function PG(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var FG=()=>!0;function IG(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=FG,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=kW(e.target),E=0,D,{x:O,y:k}=NW(e),A=NG(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=MG(i,A,r,c,t);if(!N)return;let P=NW(e,j),F=!1,I=null,L=!1,ee=null;function te(){if(!u||!j)return;let[e,t]=eW(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(te)}let ne={...N,nodeId:i,type:A,position:N.position},re=c.get(i),R={inProgress:!0,isValid:null,from:tG(re,ne,$.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:re,to:P,toHandle:null,toPosition:IU[ne.position],toNode:null,pointer:P};function ie(){M=!0,y(R),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ie();function ae(e){if(!M){let{x:t,y:n}=NW(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ie()}if(!x()||!ne){oe(e);return}let a=b();P=NW(e,j),D=jG(pW(P,a,!1,[1,1]),n,c,ne),F||=(te(),!0);let s=LG(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});ee=s.handleDomNode,I=s.connection,L=PG(!!D,s.isValid);let u=c.get(i),f=u?tG(u,ne,$.Left,!0):R.from,p={...R,from:f,isValid:L,to:s.toHandle&&L?mW({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:IU[ne.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),R=p}function oe(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||ee)&&I&&L&&h?.(I);let{inProgress:t,...n}=R,r={...n,toPosition:R.toHandle?R.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,ee=null,T.removeEventListener(`mousemove`,ae),T.removeEventListener(`mouseup`,oe),T.removeEventListener(`touchmove`,ae),T.removeEventListener(`touchend`,oe)}}T.addEventListener(`mousemove`,ae),T.addEventListener(`mouseup`,oe),T.addEventListener(`touchmove`,ae),T.addEventListener(`touchend`,oe)}function LG(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=FG,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=NW(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=NG(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===AU.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=MG(t,e,a,u,n,!0)}return _}var RG={onPointerDown:IG,isValid:LG};function zG({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=qz(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&yW()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=TU().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Yz}}var BG=e=>({x:e.x,y:e.y,zoom:e.k}),VG=({x:e,y:t,zoom:n})=>hU.translate(e,t).scale(n),HG=(e,t)=>e.target.closest(`.${t}`),UG=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),WG=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,GG=(e,t=0,n=WG,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},KG=e=>{let t=e.ctrlKey&&yW()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function qG({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(HG(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Yz(u),t=d*2**KG(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===jU.Vertical?0:u.deltaX*f,m=i===jU.Horizontal?0:u.deltaY*f;!yW()&&u.shiftKey&&i!==jU.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=BG(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function JG({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=HG(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function YG({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=BG(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function XG({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&UG(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,BG(a.transform))}}function ZG({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&UG(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=BG(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function QG({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(HG(d,`${l}-flow__node`)||HG(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||HG(d,s)&&m||HG(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function $G({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=TU().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=qz(e).call(f);y({x:i.x,y:i.y,zoom:XU(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(KG);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dV:TV).transform(GG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&v();let O=i&&!S&&!r;f.clickDistance(D?1/0:!uW(E)||E<0?0:E);let k=O?qG({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):JG({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,k,{passive:!1});let A=YG({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,A);let j=XG({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});f.on(`zoom`,j);let M=ZG({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,M);let N=QG({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});f.filter(N),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=VG(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=VG(e);return await g(n,t),n}function x(e){if(p){let t=VG(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?gU(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dV:TV).scaleTo(GG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?dV:TV).scaleBy(GG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!uW(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var eK;(function(e){e.Line=`line`,e.Handle=`handle`})(eK||={});function tK({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function nK(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function rK(e,t){return Math.max(0,t-e)}function iK(e,t){return Math.max(0,e-t)}function aK(e,t,n){return Math.max(0,t-e,e-n)}function oK(e,t){return e?!t:t}function sK(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=aK(E,h,g),j=aK(D,_,v);if(o){let e=0,t=0;c&&w<0?e=rK(y+w+O,o[0][0]):!c&&w>0&&(e=iK(y+E+O,o[1][0])),l&&T<0?t=rK(b+T+k,o[0][1]):!l&&T>0&&(t=iK(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=iK(y+w,s[0][0]):!c&&w<0&&(e=rK(y+E,s[1][0])),l&&T>0?t=iK(b+T,s[0][1]):!l&&T<0&&(t=rK(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=aK(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?iK(b+k+E/C,o[1][1])*C:rK(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?rK(b+E/C,s[1][1])*C:iK(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=aK(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?iK(y+D*C+O,o[1][0])/C:rK(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?rK(y+D*C,s[1][0])/C:iK(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(oK(c,l)?-w:w)/C:w=(oK(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var cK={width:0,height:0,x:0,y:0},lK={...cK,pointerX:0,pointerY:0,aspectRatio:1};function uK(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function dK({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=qz(e),o={controlDirection:nK(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...cK},h={...lK};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:nK(e)};let g,_=null,v=[],y,b,x,S=!1,C=cB().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=DW(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=bW(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=uK(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=DW(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=sK(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=tK({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var fK=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),pK=o(((e,t)=>{t.exports=fK()})),mK=o((e=>{var t=d(),n=pK();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),hK=l(o(((e,t)=>{t.exports=mK()}))(),1),gK=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},_K=e=>e?gK(e):gK,{useDebugValue:vK}=H.default,{useSyncExternalStoreWithSelector:yK}=hK.default,bK=e=>e;function xK(e,t=bK,n){let r=yK(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return vK(r),r}var SK=(e,t)=>{let n=_K(e),r=(e,r=t)=>xK(n,e,r);return Object.assign(r,n),r},CK=(e,t)=>e?SK(e,t):SK;function wK(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var TK=(0,H.createContext)(null),EK=TK.Provider,DK=EU.error001(`react`);function OK(e,t){let n=(0,H.useContext)(TK);if(n===null)throw Error(DK);return xK(n,e,t)}function kK(){let e=(0,H.useContext)(TK);if(e===null)throw Error(DK);return(0,H.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var AK={display:`none`},jK={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},MK=`react-flow__node-desc`,NK=`react-flow__edge-desc`,PK=`react-flow__aria-live`,FK=e=>e.ariaLiveMessage,IK=e=>e.ariaLabelConfig;function LK({rfId:e}){let t=OK(FK);return(0,W.jsx)(`div`,{id:`${PK}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:jK,children:t})}function RK({rfId:e,disableKeyboardA11y:t}){let n=OK(IK);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{id:`${MK}-${e}`,style:AK,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,W.jsx)(`div`,{id:`${NK}-${e}`,style:AK,children:n[`edge.a11yDescription.default`]}),!t&&(0,W.jsx)(LK,{rfId:e})]})}var zK=(0,H.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,W.jsx)(`div`,{className:HL([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));zK.displayName=`Panel`;var BK=`https://reactflow.dev?utm_source=attribution`;function VK({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,W.jsx)(zK,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${BK}`,children:(0,W.jsx)(`a`,{href:BK,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var HK=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},UK=e=>e.id;function WK(e,t){return wK(e.selectedNodes.map(UK),t.selectedNodes.map(UK))&&wK(e.selectedEdges.map(UK),t.selectedEdges.map(UK))}function GK({onSelectionChange:e}){let t=kK(),{selectedNodes:n,selectedEdges:r}=OK(HK,WK);return(0,H.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var KK=e=>!!e.onSelectionChangeHandlers;function qK({onSelectionChange:e}){let t=OK(KK);return e||t?(0,W.jsx)(GK,{onSelectionChange:e}):null}var JK=[0,0],YK={x:0,y:0,zoom:1},XK=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],ZK=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),QK={translateExtent:DU,nodeOrigin:JK,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function $K(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=OK(ZK,wK),l=kK();(0,H.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=QK,s()}),[]);let u=(0,H.useRef)(QK);return(0,H.useEffect)(()=>{for(let s of XK){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:EW(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},XK.map(t=>e[t])),null}function eq(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function tq(e){let[t,n]=(0,H.useState)(e===`system`?null:e);return(0,H.useEffect)(()=>{if(e!==`system`){n(e);return}let t=eq(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?eq()?.matches?`dark`:`light`:t}var nq=typeof document<`u`?document:null;function rq(e=null,t={target:nq,actInsideInputWithModifier:!0}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(!1),a=(0,H.useRef)(new Set([])),[o,s]=(0,H.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
|
|
88
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=zw,s=!Tw.jitless,c=s&&Bw.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?cD([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function dD(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!tT(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>iT(e,r,Ew())))}),t)}var fD=q(`$ZodUnion`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Pw(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Pw(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Pw(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>jw(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>dD(t,i,e,a)):dD(s,i,e,a)}}),pD=q(`$ZodDiscriminatedUnion`,(e,t)=>{fD.init(e,t);let n=e._zod.parse;Pw(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=kw(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!zw(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),mD=q(`$ZodIntersection`,(e,t)=>{CE.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>gD(e,t,n)):gD(e,i,a)}});function hD(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Vw(e)&&Vw(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=hD(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=hD(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function gD(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),tT(e))return e;let r=hD(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var _D=q(`$ZodRecord`,(e,t)=>{CE.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Vw(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...nT(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...nT(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>iT(e,r,Ew())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...nT(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...nT(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),vD=q(`$ZodEnum`,(e,t)=>{CE.init(e,t);let n=Dw(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Uw.has(typeof e)).map(e=>typeof e==`string`?Ww(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),yD=q(`$ZodLiteral`,(e,t)=>{if(CE.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ww(e):e?Ww(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),bD=q(`$ZodTransform`,(e,t)=>{CE.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ww(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Cw;return n.value=i,n}});function xD(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var SD=q(`$ZodOptional`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Pw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jw(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>xD(t,e.value)):xD(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),CD=q(`$ZodNullable`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),Pw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${jw(e.source)}|null)$`):void 0}),Pw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wD=q(`$ZodDefault`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>TD(e,t)):TD(r,t)}});function TD(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ED=q(`$ZodPrefault`,(e,t)=>{CE.init(e,t),e._zod.optin=`optional`,Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),DD=q(`$ZodNonOptional`,(e,t)=>{CE.init(e,t),Pw(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>OD(t,e)):OD(i,e)}});function OD(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var kD=q(`$ZodCatch`,(e,t)=>{CE.init(e,t),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),Pw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>iT(e,n,Ew()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>iT(e,n,Ew()))},input:e.value}),e.issues=[]),e)}}),AD=q(`$ZodPipe`,(e,t)=>{CE.init(e,t),Pw(e._zod,`values`,()=>t.in._zod.values),Pw(e._zod,`optin`,()=>t.in._zod.optin),Pw(e._zod,`optout`,()=>t.out._zod.optout),Pw(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>jD(e,t.in,n)):jD(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jD(e,t.out,n)):jD(r,t.out,n)}});function jD(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var MD=q(`$ZodReadonly`,(e,t)=>{CE.init(e,t),Pw(e._zod,`propValues`,()=>t.innerType._zod.propValues),Pw(e._zod,`values`,()=>t.innerType._zod.values),Pw(e._zod,`optin`,()=>t.innerType._zod.optin),Pw(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ND):ND(r)}});function ND(e){return e.value=Object.freeze(e.value),e}var PD=q(`$ZodLazy`,(e,t)=>{CE.init(e,t),Pw(e._zod,`innerType`,()=>t.getter()),Pw(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),Pw(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),Pw(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),Pw(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),FD=q(`$ZodCustom`,(e,t)=>{iE.init(e,t),CE.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ID(t,n,r,e));ID(i,n,r,e)}});function ID(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(oT(e))}}var LD=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function RD(){return new LD}var zD=RD();function BD(e,t){return new e({type:`string`,...J(t)})}function VD(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...J(t)})}function HD(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...J(t)})}function UD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...J(t)})}function WD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...J(t)})}function GD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...J(t)})}function KD(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...J(t)})}function qD(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...J(t)})}function JD(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...J(t)})}function YD(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...J(t)})}function XD(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...J(t)})}function ZD(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...J(t)})}function QD(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...J(t)})}function $D(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...J(t)})}function eO(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...J(t)})}function tO(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...J(t)})}function nO(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...J(t)})}function rO(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...J(t)})}function iO(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...J(t)})}function aO(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...J(t)})}function oO(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...J(t)})}function sO(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...J(t)})}function cO(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...J(t)})}function lO(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...J(t)})}function uO(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...J(t)})}function dO(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...J(t)})}function fO(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...J(t)})}function pO(e,t){return new e({type:`number`,checks:[],...J(t)})}function mO(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...J(t)})}function hO(e,t){return new e({type:`boolean`,...J(t)})}function gO(e,t){return new e({type:`null`,...J(t)})}function _O(e){return new e({type:`unknown`})}function vO(e,t){return new e({type:`never`,...J(t)})}function yO(e,t){return new oE({check:`less_than`,...J(t),value:e,inclusive:!1})}function bO(e,t){return new oE({check:`less_than`,...J(t),value:e,inclusive:!0})}function xO(e,t){return new sE({check:`greater_than`,...J(t),value:e,inclusive:!1})}function SO(e,t){return new sE({check:`greater_than`,...J(t),value:e,inclusive:!0})}function CO(e,t){return new cE({check:`multiple_of`,...J(t),value:e})}function wO(e,t){return new uE({check:`max_length`,...J(t),maximum:e})}function TO(e,t){return new dE({check:`min_length`,...J(t),minimum:e})}function EO(e,t){return new fE({check:`length_equals`,...J(t),length:e})}function DO(e,t){return new mE({check:`string_format`,format:`regex`,...J(t),pattern:e})}function OO(e){return new hE({check:`string_format`,format:`lowercase`,...J(e)})}function kO(e){return new gE({check:`string_format`,format:`uppercase`,...J(e)})}function AO(e,t){return new _E({check:`string_format`,format:`includes`,...J(t),includes:e})}function jO(e,t){return new vE({check:`string_format`,format:`starts_with`,...J(t),prefix:e})}function MO(e,t){return new yE({check:`string_format`,format:`ends_with`,...J(t),suffix:e})}function NO(e){return new bE({check:`overwrite`,tx:e})}function PO(e){return NO(t=>t.normalize(e))}function FO(){return NO(e=>e.trim())}function IO(){return NO(e=>e.toLowerCase())}function LO(){return NO(e=>e.toUpperCase())}function RO(e,t,n){return new e({type:`array`,element:t,...J(n)})}function zO(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...J(n)})}function BO(e){let t=VO(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(oT(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(oT(r))}},e(n.value,n)));return t}function VO(e,t){let n=new iE({check:`custom`,...J(t)});return n._zod.check=e,n}var HO=q(`ZodISODateTime`,(e,t)=>{LE.init(e,t),pk.init(e,t)});function UO(e){return lO(HO,e)}var WO=q(`ZodISODate`,(e,t)=>{RE.init(e,t),pk.init(e,t)});function GO(e){return uO(WO,e)}var KO=q(`ZodISOTime`,(e,t)=>{zE.init(e,t),pk.init(e,t)});function qO(e){return dO(KO,e)}var JO=q(`ZodISODuration`,(e,t)=>{BE.init(e,t),pk.init(e,t)});function YO(e){return fO(JO,e)}var XO=(e,t)=>{cT.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>dT(e,t)},flatten:{value:t=>uT(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ow,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ow,2)}},isEmpty:{get(){return e.issues.length===0}}})};q(`ZodError`,XO);var ZO=q(`ZodError`,XO,{Parent:Error}),QO=fT(ZO),$O=pT(ZO),ek=mT(ZO),tk=gT(ZO),nk=vT(ZO),rk=yT(ZO),ik=bT(ZO),ak=xT(ZO),ok=ST(ZO),sk=CT(ZO),ck=wT(ZO),lk=TT(ZO),uk=q(`ZodType`,(e,t)=>(CE.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Iw(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>Gw(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>QO(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ek(e,t,n),e.parseAsync=async(t,n)=>$O(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>tk(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>nk(e,t,n),e.decode=(t,n)=>rk(e,t,n),e.encodeAsync=async(t,n)=>ik(e,t,n),e.decodeAsync=async(t,n)=>ak(e,t,n),e.safeEncode=(t,n)=>ok(e,t,n),e.safeDecode=(t,n)=>sk(e,t,n),e.safeEncodeAsync=async(t,n)=>ck(e,t,n),e.safeDecodeAsync=async(t,n)=>lk(e,t,n),e.refine=(t,n)=>e.check(OA(t,n)),e.superRefine=t=>e.check(kA(t)),e.overwrite=t=>e.check(NO(t)),e.optional=()=>uA(e),e.nullable=()=>fA(e),e.nullish=()=>uA(fA(e)),e.nonoptional=t=>vA(e,t),e.array=()=>X(e),e.or=t=>Zk([e,t]),e.and=t=>tA(e,t),e.transform=t=>SA(e,cA(t)),e.default=t=>mA(e,t),e.prefault=t=>gA(e,t),e.catch=t=>bA(e,t),e.pipe=t=>SA(e,t),e.readonly=()=>wA(e),e.describe=t=>{let n=e.clone();return zD.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return zD.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return zD.get(e);let n=e.clone();return zD.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),dk=q(`_ZodString`,(e,t)=>{wE.init(e,t),uk.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(DO(...t)),e.includes=(...t)=>e.check(AO(...t)),e.startsWith=(...t)=>e.check(jO(...t)),e.endsWith=(...t)=>e.check(MO(...t)),e.min=(...t)=>e.check(TO(...t)),e.max=(...t)=>e.check(wO(...t)),e.length=(...t)=>e.check(EO(...t)),e.nonempty=(...t)=>e.check(TO(1,...t)),e.lowercase=t=>e.check(OO(t)),e.uppercase=t=>e.check(kO(t)),e.trim=()=>e.check(FO()),e.normalize=(...t)=>e.check(PO(...t)),e.toLowerCase=()=>e.check(IO()),e.toUpperCase=()=>e.check(LO())}),fk=q(`ZodString`,(e,t)=>{wE.init(e,t),dk.init(e,t),e.email=t=>e.check(VD(mk,t)),e.url=t=>e.check(qD(_k,t)),e.jwt=t=>e.check(cO(Nk,t)),e.emoji=t=>e.check(JD(yk,t)),e.guid=t=>e.check(HD(hk,t)),e.uuid=t=>e.check(UD(gk,t)),e.uuidv4=t=>e.check(WD(gk,t)),e.uuidv6=t=>e.check(GD(gk,t)),e.uuidv7=t=>e.check(KD(gk,t)),e.nanoid=t=>e.check(YD(bk,t)),e.guid=t=>e.check(HD(hk,t)),e.cuid=t=>e.check(XD(xk,t)),e.cuid2=t=>e.check(ZD(Sk,t)),e.ulid=t=>e.check(QD(Ck,t)),e.base64=t=>e.check(aO(Ak,t)),e.base64url=t=>e.check(oO(jk,t)),e.xid=t=>e.check($D(wk,t)),e.ksuid=t=>e.check(eO(Tk,t)),e.ipv4=t=>e.check(tO(Ek,t)),e.ipv6=t=>e.check(nO(Dk,t)),e.cidrv4=t=>e.check(rO(Ok,t)),e.cidrv6=t=>e.check(iO(kk,t)),e.e164=t=>e.check(sO(Mk,t)),e.datetime=t=>e.check(UO(t)),e.date=t=>e.check(GO(t)),e.time=t=>e.check(qO(t)),e.duration=t=>e.check(YO(t))});function Y(e){return BD(fk,e)}var pk=q(`ZodStringFormat`,(e,t)=>{TE.init(e,t),dk.init(e,t)}),mk=q(`ZodEmail`,(e,t)=>{OE.init(e,t),pk.init(e,t)}),hk=q(`ZodGUID`,(e,t)=>{EE.init(e,t),pk.init(e,t)}),gk=q(`ZodUUID`,(e,t)=>{DE.init(e,t),pk.init(e,t)}),_k=q(`ZodURL`,(e,t)=>{kE.init(e,t),pk.init(e,t)});function vk(e){return qD(_k,e)}var yk=q(`ZodEmoji`,(e,t)=>{AE.init(e,t),pk.init(e,t)}),bk=q(`ZodNanoID`,(e,t)=>{jE.init(e,t),pk.init(e,t)}),xk=q(`ZodCUID`,(e,t)=>{ME.init(e,t),pk.init(e,t)}),Sk=q(`ZodCUID2`,(e,t)=>{NE.init(e,t),pk.init(e,t)}),Ck=q(`ZodULID`,(e,t)=>{PE.init(e,t),pk.init(e,t)}),wk=q(`ZodXID`,(e,t)=>{FE.init(e,t),pk.init(e,t)}),Tk=q(`ZodKSUID`,(e,t)=>{IE.init(e,t),pk.init(e,t)}),Ek=q(`ZodIPv4`,(e,t)=>{VE.init(e,t),pk.init(e,t)}),Dk=q(`ZodIPv6`,(e,t)=>{HE.init(e,t),pk.init(e,t)}),Ok=q(`ZodCIDRv4`,(e,t)=>{UE.init(e,t),pk.init(e,t)}),kk=q(`ZodCIDRv6`,(e,t)=>{WE.init(e,t),pk.init(e,t)}),Ak=q(`ZodBase64`,(e,t)=>{KE.init(e,t),pk.init(e,t)}),jk=q(`ZodBase64URL`,(e,t)=>{JE.init(e,t),pk.init(e,t)}),Mk=q(`ZodE164`,(e,t)=>{YE.init(e,t),pk.init(e,t)}),Nk=q(`ZodJWT`,(e,t)=>{ZE.init(e,t),pk.init(e,t)}),Pk=q(`ZodNumber`,(e,t)=>{QE.init(e,t),uk.init(e,t),e.gt=(t,n)=>e.check(xO(t,n)),e.gte=(t,n)=>e.check(SO(t,n)),e.min=(t,n)=>e.check(SO(t,n)),e.lt=(t,n)=>e.check(yO(t,n)),e.lte=(t,n)=>e.check(bO(t,n)),e.max=(t,n)=>e.check(bO(t,n)),e.int=t=>e.check(Lk(t)),e.safe=t=>e.check(Lk(t)),e.positive=t=>e.check(xO(0,t)),e.nonnegative=t=>e.check(SO(0,t)),e.negative=t=>e.check(yO(0,t)),e.nonpositive=t=>e.check(bO(0,t)),e.multipleOf=(t,n)=>e.check(CO(t,n)),e.step=(t,n)=>e.check(CO(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Fk(e){return pO(Pk,e)}var Ik=q(`ZodNumberFormat`,(e,t)=>{$E.init(e,t),Pk.init(e,t)});function Lk(e){return mO(Ik,e)}var Rk=q(`ZodBoolean`,(e,t)=>{eD.init(e,t),uk.init(e,t)});function zk(e){return hO(Rk,e)}var Bk=q(`ZodNull`,(e,t)=>{tD.init(e,t),uk.init(e,t)});function Vk(e){return gO(Bk,e)}var Hk=q(`ZodUnknown`,(e,t)=>{nD.init(e,t),uk.init(e,t)});function Uk(){return _O(Hk)}var Wk=q(`ZodNever`,(e,t)=>{rD.init(e,t),uk.init(e,t)});function Gk(e){return vO(Wk,e)}var Kk=q(`ZodArray`,(e,t)=>{aD.init(e,t),uk.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(TO(t,n)),e.nonempty=t=>e.check(TO(1,t)),e.max=(t,n)=>e.check(wO(t,n)),e.length=(t,n)=>e.check(EO(t,n)),e.unwrap=()=>e.element});function X(e,t){return RO(Kk,e,t)}var qk=q(`ZodObject`,(e,t)=>{uD.init(e,t),uk.init(e,t),Pw(e,`shape`,()=>t.shape),e.keyof=()=>aA(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Uk()}),e.loose=()=>e.clone({...e._zod.def,catchall:Uk()}),e.strict=()=>e.clone({...e._zod.def,catchall:Gk()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Xw(e,t),e.safeExtend=t=>Zw(e,t),e.merge=t=>Qw(e,t),e.pick=t=>Jw(e,t),e.omit=t=>Yw(e,t),e.partial=(...t)=>$w(lA,e,t[0]),e.required=(...t)=>eT(_A,e,t[0])});function Jk(e,t){return new qk({type:`object`,shape:e??{},...J(t)})}function Yk(e,t){return new qk({type:`object`,shape:e,catchall:Gk(),...J(t)})}var Xk=q(`ZodUnion`,(e,t)=>{fD.init(e,t),uk.init(e,t),e.options=t.options});function Zk(e,t){return new Xk({type:`union`,options:e,...J(t)})}var Qk=q(`ZodDiscriminatedUnion`,(e,t)=>{Xk.init(e,t),pD.init(e,t)});function $k(e,t,n){return new Qk({type:`union`,options:t,discriminator:e,...J(n)})}var eA=q(`ZodIntersection`,(e,t)=>{mD.init(e,t),uk.init(e,t)});function tA(e,t){return new eA({type:`intersection`,left:e,right:t})}var nA=q(`ZodRecord`,(e,t)=>{_D.init(e,t),uk.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function rA(e,t,n){return new nA({type:`record`,keyType:e,valueType:t,...J(n)})}var iA=q(`ZodEnum`,(e,t)=>{vD.init(e,t),uk.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new iA({...t,checks:[],...J(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new iA({...t,checks:[],...J(r),entries:i})}});function aA(e,t){return new iA({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...J(t)})}var oA=q(`ZodLiteral`,(e,t)=>{yD.init(e,t),uk.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Z(e,t){return new oA({type:`literal`,values:Array.isArray(e)?e:[e],...J(t)})}var sA=q(`ZodTransform`,(e,t)=>{bD.init(e,t),uk.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ww(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(oT(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(oT(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function cA(e){return new sA({type:`transform`,transform:e})}var lA=q(`ZodOptional`,(e,t)=>{SD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function uA(e){return new lA({type:`optional`,innerType:e})}var dA=q(`ZodNullable`,(e,t)=>{CD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function fA(e){return new dA({type:`nullable`,innerType:e})}var pA=q(`ZodDefault`,(e,t)=>{wD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function mA(e,t){return new pA({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hw(t)}})}var hA=q(`ZodPrefault`,(e,t)=>{ED.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gA(e,t){return new hA({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Hw(t)}})}var _A=q(`ZodNonOptional`,(e,t)=>{DD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function vA(e,t){return new _A({type:`nonoptional`,innerType:e,...J(t)})}var yA=q(`ZodCatch`,(e,t)=>{kD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bA(e,t){return new yA({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var xA=q(`ZodPipe`,(e,t)=>{AD.init(e,t),uk.init(e,t),e.in=t.in,e.out=t.out});function SA(e,t){return new xA({type:`pipe`,in:e,out:t})}var CA=q(`ZodReadonly`,(e,t)=>{MD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.innerType});function wA(e){return new CA({type:`readonly`,innerType:e})}var TA=q(`ZodLazy`,(e,t)=>{PD.init(e,t),uk.init(e,t),e.unwrap=()=>e._zod.def.getter()});function EA(e){return new TA({type:`lazy`,getter:e})}var DA=q(`ZodCustom`,(e,t)=>{FD.init(e,t),uk.init(e,t)});function OA(e,t={}){return zO(DA,e,t)}function kA(e){return BO(e)}function AA(e){let t=EA(()=>Zk([Y(e),Fk(),zk(),Vk(),X(t),rA(Y(),t)]));return t}var jA=_(),MA=[`urgent`,`high`,`medium`,`low`],NA={urgent:`Critical`,high:`High`,medium:`Medium`,low:`Low`},PA={list:`/api/human-items`,item:e=>`/api/human-items/${encodeURIComponent(e)}`,answer:e=>`/api/human-items/${encodeURIComponent(e)}/answer`,complete:e=>`/api/human-items/${encodeURIComponent(e)}/complete`,dismiss:e=>`/api/human-items/${encodeURIComponent(e)}/dismiss`,reopen:e=>`/api/human-items/${encodeURIComponent(e)}/reopen`,note:e=>`/api/human-items/${encodeURIComponent(e)}/note`},FA=Y().nullable(),IA=Y().regex(/\S/u),LA=Yk({session:Y(),run:FA,plan:FA}),RA=$k(`scope`,[Yk({scope:Z(`nothing`)}),Yk({scope:Z(`work`),run:Y(),node:Y()}),Yk({scope:Z(`plan`),plan:Y()}),Yk({scope:Z(`host`)})]),zA=Yk({actor:Y(),on_behalf_of:FA,text:FA,choice:FA.optional(),reason:FA}),BA=Yk({id:Y().regex(/^[a-z0-9][a-z0-9-]*$/u).max(64),title:Y().regex(/^(?=.*\S)[^\n\r]{1,80}$/u),description:IA});function VA(e){let{kind:t,state:n,resolution:r}=e,i=(e.choices??[]).map(({id:e})=>e);if(t===`task`&&i.length>0)return`choices are only valid on questions`;if(new Set(i).size!==i.length)return`a choice id is repeated`;if(t===`question`&&e.approval!==null)return`approval is only valid on tasks`;if(n===`open`)return r===null?void 0:`an open item has no resolution`;if(r===null)return`a resolved item carries its resolution`;let a=r.choice??null;return a!==null&&(n!==`answered`||!i.includes(a))?`a resolution's choice is one its answered question offers`:n===`answered`?t===`question`&&(r.text===null?a!==null:/\S/u.test(r.text))&&r.reason===null?void 0:`an answer is a question's, with text or a choice and no reason`:n===`completed`?t===`task`&&(r.text===null||/\S/u.test(r.text))&&r.reason===null?void 0:`a completion is a task's, with no reason and any comment not blank`:r.text===null?void 0:`a dismissal carries no text`}var HA=Yk({schema_version:Z(1),id:Y().min(1),dedup_key:Y(),kind:aA([`task`,`question`]),title:IA,body:IA,choices:X(BA).max(6).optional(),priority:aA(MA),owner:LA,block:RA,approval:Yk({board_copy:Y(),key:Y()}).nullable(),state:aA([`open`,`answered`,`completed`,`dismissed`]),resolution:zA.nullable(),tracker:Yk({task:Y(),url:vk()}).nullable(),created_at:Y(),updated_at:Y()}).superRefine((e,t)=>{let n=VA(e);n!==void 0&&t.addIssue({code:`custom`,message:n})}),UA=Yk({run:Y(),node:Y(),title:Y()}),WA=Yk({plan:Y(),count:Fk().int().nonnegative(),preview:X(UA).max(3)}),GA=Yk({total:Fk().int().nonnegative(),plans:X(WA)});function KA(e,t){return!(e.state===`open`&&e.block.scope!==`nothing`)&&(t.total!==0||t.plans.length>0)?`a non-blocking item reports nothing blocked`:new Set(t.plans.map(({plan:e})=>e)).size===t.plans.length?t.plans.some(({count:e,preview:t})=>t.length!==Math.min(e,3))?`a preview is the first three affected steps of its plan`:t.plans.reduce((e,{count:t})=>e+t,0)===t.total?void 0:`the blocked total is the plans' counts`:`a blocked plan appears twice`}var qA=Yk({available:zk(),reason:FA});function JA({dedup_key:e,block:t,owner:n}){return t.scope===`work`&&e===`run:${t.run}#${t.node}`&&n.run===t.run}function YA(e,{available:t,reason:n}){return(t?n!==null:n===null||!/\S/u.test(n))?`a reopen states a reason exactly when it is unavailable`:e.state===`open`||e.state===`answered`||JA(e)||e.resolution?.actor===`engine`?t?`this item's state cannot be reopened`:void 0:t||e.state===`completed`&&e.approval!==null?void 0:`nothing about this item's state refuses a reopen`}var XA=Yk({item:HA,blocked:GA,reopen:qA}).superRefine(({item:e,blocked:t,reopen:n},r)=>{let i=KA(e,t)??YA(e,n);i!==void 0&&r.addIssue({code:`custom`,message:i})});function ZA(e){let{blocked:t,nodes:n}=e;if(n.length!==t.total)return`the steps are the blocked total`;if(new Set(n.map(({run:e,node:t})=>`${e}\u0000${t}`)).size!==n.length)return`a blocked step appears twice`;let r=0;for(let{count:e,preview:i}of t.plans){let t=n.slice(r,r+e);if(i.some((e,n)=>t[n]?.run!==e.run||t[n]?.node!==e.node))return`a preview is the first steps of its plan's group`;r+=e}}var QA=Yk({item:HA,blocked:GA,nodes:X(UA),reopen:qA}).superRefine((e,t)=>{let n=KA(e.item,e.blocked)??YA(e.item,e.reopen)??ZA(e);n!==void 0&&t.addIssue({code:`custom`,message:n})}),$A=Yk({item:XA,event_id:Y()}),ej=Yk({items:X(XA)}),tj=Yk({kind:aA([`task`,`question`]).nullable().optional(),blocking:zk().nullable().optional(),priority:aA(MA).nullable().optional(),state:aA([`open`,`answered`,`completed`,`dismissed`]).nullable().optional(),session:Y().nullable().optional(),run:Y().nullable().optional(),plan:Y().nullable().optional(),host:zk().nullable().optional()}),nj=Yk({type:Z(`human-items`),items:X(XA),detail:QA.nullable()}),rj=Fk().finite().nonnegative(),ij=Fk().int().nonnegative(),aj=UO({offset:!0}),oj=Y().min(1).nullable(),Q=e=>Jk(e).catchall(Uk()),sj={runs:`/api/v2/runs`,run:e=>`/api/v2/runs/${encodeURIComponent(e)}`,timeline:e=>`/api/v2/runs/${encodeURIComponent(e)}/timeline`,conversation:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,artifact:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}`,events:`/api/v2/events`,projects:`/api/v2/projects`,project:e=>`/api/v2/projects/${encodeURIComponent(e)}`,channel:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel`,channelNext:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/next`,channelReply:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/reply`,channelSurface:e=>`/api/v2/runs/${encodeURIComponent(e)}/channel/surface`,attest:e=>`/api/v2/runs/${encodeURIComponent(e)}/attest`,stop:e=>`/api/v2/runs/${encodeURIComponent(e)}/stop`,shutdown:`/api/v2/shutdown`,unwatched:`/api/v2/unwatched`,host:`/api/v2/host`,status:e=>`/api/v2/runs/${encodeURIComponent(e)}/status`,results:e=>`/api/v2/runs/${encodeURIComponent(e)}/results`,goals:`/api/v2/goals`,runGoals:e=>`/api/v2/runs/${encodeURIComponent(e)}/goals`,transcript:e=>`/api/v2/runs/${encodeURIComponent(e)}/transcript`,telemetry:e=>`/api/v2/runs/${encodeURIComponent(e)}/telemetry`,agents:e=>`/api/v2/runs/${encodeURIComponent(e)}/agents`,nodeAgents:(e,t)=>`/api/v2/runs/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}/agents`,projectAgents:e=>`/api/v2/projects/${encodeURIComponent(e)}/agents`,subscriptions:`/api/v2/subscriptions`,subscription:e=>`/api/v2/subscriptions/${encodeURIComponent(e)}`},cj={includeSettled:`include_settled`,includeConversations:`include_conversations`,runId:`run_id`,after:`after`,cursor:`cursor`,limit:`limit`,select:`select`,node:`node`,scope:`scope`,filter:`filter`,correlation:`correlation`,until:`until`,timeout:`timeout`,subscription:`subscription`,tick:`tick`},lj={run:`run`,node:`node`},uj={planner:`planner`,detailed:`detailed`},dj=aA([`complete`,`partial`,`legacy`]),fj=aA([`native`,`labelled`,`inferred`]),pj=Q({agent_model_ms:zk(),judge_model_ms:zk(),llmlint_model_ms:zk(),tool_ms:zk()}),mj=rj.nullable(),hj=ij.nullable(),gj=Q({agent_seconds:mj,judge_seconds:mj,llmlint_seconds:mj,gate_seconds:mj,publication_wait_seconds:mj,lock_wait_seconds:mj,setup_seconds:mj,scheduling_seconds:mj,wall_seconds:mj,agent_model_ms:hj,judge_model_ms:hj,llmlint_model_ms:hj,tool_ms:hj,idle_orchestration_ms:hj,unattributed_ms:hj,wall_ms:hj,fractions:Q({agent_model:mj,judge_model:mj,llmlint_model:mj,tool:mj,idle_orchestration:mj,lock_wait:mj,setup:mj,scheduling:mj})}),_j=Y().regex(/^[A-Za-z0-9_-]+$/,`a member name: letters, digits, hyphens and underscores`),vj=aA([`agent`,`judge`,`llmlint`]),yj=rj.nullable(),bj=Q({input_tokens:yj,output_tokens:yj,cache_read_tokens:yj,cache_write_tokens:yj,cost_usd:yj}),xj=Q({agent:bj,judge:bj,llmlint:bj,total:bj}),Sj=Q({session_id:Y().min(1),history_id:Y().min(1).nullable().optional(),role:vj,agent_role:_j.optional(),turn_index:ij.nullable().optional(),started_at:aj.optional(),finished_at:aj.nullable().optional()}),Cj=rA(Y(),Uk()),wj=aA([`agent`,`gate`,`checks`,`publication`,`timeout`,`provider`,`configuration`,`unknown`]),Tj=aA([`agent`,`judge`,`llmlint`]),Ej=aA([`quota_at_launch`,`quota_mid_conversation`,`stale_session_resume`,`rate_limit`,`harness_exit`]),Dj=Q({side:Tj.optional(),harness:Y().optional(),variant:Y().optional(),identity:Y().optional(),cause:Ej.optional(),raw_tail:Y().optional(),reset_time:Y().optional(),missing_session_id:Y().optional(),wait_seconds:Fk().nonnegative().optional(),failure_kind:Y().optional(),structured_error:Cj.optional(),judge_unrecorded:zk().optional()}).extend({class:wj,detail:Y().optional()}),Oj=Q({node:Y().min(1),status:Y().min(1),outcome:Y().min(1).optional(),branch:Y().min(1).optional(),comparison_remote:Y().min(1).optional(),comparison_base:Y().min(1).optional(),checkpoint:Y().min(1).optional(),commit:Y().min(1).optional(),retry_lineage:Cj.optional(),gate_attestation:Cj.optional(),failure:Dj.optional(),timing:gj.optional(),usage:xj.optional(),sessions:X(Sj),tool_commands:rA(Y(),ij).optional(),turns:ij,lint:ij,timing_quality:dj,linkage_quality:fj,timing_presence:pj}),kj=Q({run_id:Y().min(1),state:Y().min(1),phase:Y().min(1),last_event:oj,last_progress_at:rj.optional(),timing:gj,nodes:X(Oj),providers:X(Cj).optional(),failure:Dj.optional(),check_rollup:Cj.optional(),usage:xj,timing_quality:dj,linkage_quality:fj,timing_presence:pj,sources:X(Y()),node_work_ms:Q({agent_model_ms:hj,judge_model_ms:hj,llmlint_model_ms:hj,tool_ms:hj,wall_ms:hj}),turns:ij,lint:ij,agent_count:ij.optional()}),Aj=Q({schema_version:Zk([Y(),Fk()]).optional(),observed_at:Y().optional(),identities:X(Cj)}),jj=Q({started_at:aj.optional(),launch_id:Y().min(1),launcher:aA([`claude-code`,`codex`,`unknown`]),session_key:Y().min(1).optional(),launcher_session_id:Y().min(1).optional()}),Mj=Y().min(1),Nj=Q({labels:rA(Y(),Y()).optional(),group:Y().min(1).optional(),run_id:Y().min(1),state:Y().min(1),phase:Y().min(1),last_event:oj,last_progress_at:rj.optional(),timing_quality:dj,linkage_quality:fj,timing:gj,node_counts:rA(Y(),ij),launch:jj.optional(),project:Y().min(1).optional(),project_name:Y().min(1).optional(),liveness:Mj.optional(),unread_surfaces:ij.optional()}),Pj=Q({path:Y().min(1),reason:Y().min(1)}),Fj=Q({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:aj,runs:X(Nj),next_cursor:Y().min(1).optional(),unreadable:X(Pj).optional(),missing:X(Y().min(1)).optional(),provider_health:Aj.optional()}),Ij=Q({id:Y().min(1),kind:aA([`agent`,`human`]).optional(),persona:Y().min(1).optional(),task:Y().min(1),deps:X(Y().min(1)).optional(),max_turns:ij.positive().optional(),expects_no_diff:zk().optional()}),Lj=Q({branch:Y().min(1),base_branch:Y().min(1),pr_base:Y().min(1),checkpoint:Y().min(1),completed_steps:X(Y()).optional(),pr:Y().nullable().optional(),mode:aA([`pause`,`retry`,`continue`]).optional(),attempts:ij.optional()}),Rj=Q({branch:Y().min(1),repo:Y().min(1).optional(),identity:Y().min(1).optional(),base_branch:Y().min(1).optional(),pr:Y().min(1).optional(),pr_base:Y().min(1).optional()}),zj=X(Y()),Bj=Ij.extend({task:Y().min(1).optional(),repo:Y().min(1).optional(),steps:X(Ij).min(1).optional(),session:Y().min(1).optional(),project_dir:Y().min(1).optional(),base_branch:Y().min(1).optional(),branch:Y().min(1).optional(),title:Y().min(1).optional(),verify_cmd:Y().min(1).optional(),skip_verify:zk().optional(),verify_via_ci:zk().optional(),merge_policy:aA([`auto`,`direct`,`none`]).optional(),workflow:aA([`local`,`remote`]).optional(),repo_type:aA([`single-owner`,`team`]).optional(),execution_checkout:Y().min(1).optional(),stack_bases:X(Rj).optional(),resume:Lj.optional(),sets:zj.optional()}).superRefine((e,t)=>{e.steps===void 0&&e.task===void 0&&t.addIssue({code:`custom`,path:[`task`],message:"a plan task without `steps` must carry its own `task` prose"})}),Vj=Q({gate_log:Y().optional(),worker_report:Y().optional(),oneharness_session:Y().optional()}),Hj=Q({id:Y().min(1),kind:Y().min(1),persona:Y().nullable(),status:Y().min(1),telemetry:Cj.optional(),artifacts:Vj.optional()}),Uj=Q({ref:Y().min(1),task:Y(),unblocks:X(Y()),unblocks_publication:zk()}),Wj=Q({branch:Y().min(1),base_branch:Y().min(1),pr_base:Y(),checkpoint:Y().min(1),completed_steps:X(Y()),pr:Y().nullable(),mode:Y().optional()}),Gj=Q({identity:Y().min(1),target:Y().min(1),style:Y().min(1).optional(),version:Y().min(1)}),Kj=Q({producer:Y().min(1),target:Y().min(1)}),qj=Q({kind:Y().optional(),status:Y().optional(),task:Y().optional(),unblocks:X(Y()).optional(),blocked_by:X(Y()).optional(),human_actions:X(Uj).optional(),completed:zk().optional(),exit_code:Fk().int().nullable().optional(),verdicts:X(Uk()).optional(),usage:Cj.optional(),telemetry:Cj.optional(),repo:Y().optional(),branch:Y().optional(),commit:Y().optional(),base_branch:Y().optional(),pr_base:Y().optional(),synthetic_stack_base:Y().nullable().optional(),stack_bases:X(Cj).optional(),repository_type:aA([`single-owner`,`team`]).nullable().optional(),repo_type:aA([`single-owner`,`team`]).nullable().optional(),publication_workflow:aA([`local`,`remote`]).nullable().optional(),workflow:aA([`local`,`remote`]).nullable().optional(),merge_policy:aA([`auto`,`direct`,`none`]).nullable().optional(),outcome:Y().optional(),ok:zk().optional(),pr:Y().nullable().optional(),release:Gj.nullable().optional(),awaiting:X(Kj).min(1).optional(),detail:Y().optional(),follow_ups:Y().nullable().optional(),steps:X(Hj).optional(),waiting_steps:X(Y()).optional(),resume:Wj.nullable().optional(),error:Y().nullable().optional(),retry_lineage:Cj.optional(),deferred_cleanup:X(Y()).optional(),artifacts:Vj.optional()}),Jj=Q({ok:zk().optional(),state:Y().optional(),started_order:X(Y()).optional(),results:rA(Y(),qj).optional(),schema_version:ij.optional()}),Yj=aA([`running`,`done`,`failed`,`waiting`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`]),Xj=aA([`pending`,`ready`,`running`,`waiting`,`blocked`,`skipped`,`done`,`not-completed`,`failed`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`,`unknown`]),Zj=Q({addressable:zk(),member:Y().min(1).optional(),reason:Y().min(1).optional()}).superRefine((e,t)=>{e.addressable===(e.reason!==void 0)&&t.addIssue({code:`custom`,path:[`reason`],message:`a reason is carried exactly when there is no turn to address`})}),Qj=Q({id:Y().min(1),kind:Y(),unblocks:X(Y().min(1))}),$j=Q({run_id:Y().min(1),plan:Q({tasks:X(Bj),schema_version:ij.optional(),concurrency:ij.positive().optional(),name:Y().min(1).optional(),goal:Q({id:Y().min(1),text:Y().min(1)}).optional()}),node_states:rA(Y(),Yj),node_status:rA(Y(),Xj),node_gated_by:rA(Y(),X(Y().min(1))),node_control:rA(Y(),Zj),node_results:rA(Y(),qj),decisions:X(Qj),attestations:X(Y()),result:Jj.nullable(),last_seq:ij,run_node_sets:zj.optional()}).superRefine((e,t)=>{let n=new Set(e.plan.tasks.map(e=>e.id)),r=new Set(Object.keys(e.node_status));(n.size!==e.plan.tasks.length||n.size!==r.size||[...n].some(e=>!r.has(e)))&&t.addIssue({code:`custom`,path:[`node_status`],message:`must contain exactly one entry for every plan task`}),Object.entries(e.node_gated_by).find(([e,t])=>!n.has(e)||t.some(e=>!n.has(e)))&&t.addIssue({code:`custom`,path:[`node_gated_by`],message:`must name only nodes in this graph's plan`}),Object.keys(e.node_control).find(t=>e.node_status[t]!==`running`)!==void 0&&t.addIssue({code:`custom`,path:[`node_control`],message:`must name only nodes the run has in flight`})}),eM=Q({cacheReadTokens:yj.optional(),cacheWriteTokens:yj.optional(),costUsd:yj.optional(),inputTokens:yj.optional(),outputTokens:yj.optional()}),tM=Q({index:ij,input:Uk().optional(),kind:Y(),name:Y().nullable().optional(),output:Y().nullable().optional(),toolCallId:Y().min(1).optional(),output_truncated:Z(!0).optional(),input_truncated:Z(!0).optional()}),nM=Q({judge:Y(),kind:Y(),decision:Y(),reason:Y()}),rM=Q({assistant:Y().nullable(),durationMs:yj.optional(),failureKind:Y().nullable(),finishedAt:aj.nullable().optional(),harness:Y(),id:Y(),judges:X(nM).optional(),model:Y().nullable(),modelMs:yj.optional(),reasoning:Y().nullable(),startedAt:aj.nullable().optional(),status:Y(),timestamp:aj,toolMs:yj.optional(),tools:X(tM),unknown:Cj,usage:eM,user:Y()}),iM=Q({conversation:Q({canContinue:zk(),harnesses:X(Y()),id:Y().min(1),name:Y(),project:Y(),startedAt:aj,state:Y(),turns:X(rM)}),attribution:Q({runId:Y().optional(),nodeId:Y().optional(),stepId:Y().optional(),launchId:Y().optional(),launcher:aA([`claude-code`,`codex`,`unknown`]).optional(),transportRole:vj,agentRole:_j.optional(),parentConversationId:Y().optional(),persona:Y().optional(),finishedAt:aj.nullable().optional(),inferred:Z(!0).optional(),timing:gj.optional()})}),aM=Q({node:Y().optional(),conversations:X(iM)}),oM=Zk([X(iM),X(aM).transform(e=>e.flatMap(e=>e.conversations))]),sM=Q({name:Y(),state:Y(),status:Y().optional(),conclusion:Y().optional(),started_at:aj.optional(),completed_at:aj.optional(),required:zk(),requirement:Y().optional(),url:Y().url().nullable().optional()}),cM=Q({ok:zk(),output_tail:Y(),artifact_id:Y().min(1).optional()}),lM=Q({verification:Q({pre_push_hook:zk().optional(),required_checks:X(Y()).optional(),required_checks_status:Y().optional(),expected_gate:X(Y()).optional(),checks:X(sM).optional(),records:X(cM)}),publication:Q({pr_url:Y().url().optional(),branch:Y().optional(),branch_url:Y().url().optional(),merged:zk(),base_branch:Y().optional(),commit:Y().optional(),commit_url:Y().url().optional()}).optional()}),uM=X(Jk({event_id:Y().min(1),node:Y().min(1),step:Y().min(1).optional(),at:Fk().finite(),kind:Y(),name:Y(),detail:Y(),description:Y(),events:Fk().int().nonnegative()})),dM=Q({telemetry:Q({schema_version:ij}).optional(),api_version:Z(2),telemetry_schema_version:Z(27),observed_at:aj,run:kj.extend({live_activity:uM.optional()}),graph:$j.nullable(),conversations:oM,node_details:rA(Y(),lM).optional().default({}),launch:jj.optional(),provider_health:Aj.optional()}),fM=aA([`conversation`,`gate_log`,`worker_report`,`oneharness_session`,`pr`]),pM=aA([`run`,`node`,`step`,`dispatch`,`verification`,`publication`,`pr-drafting`,`conflict-resolution`,`human-wait`,`rollup`,`queued`]),mM=aA([`starting`,`dispatching`,`deciding`,`surfacing`,`waiting`,`settled`,`finished`]),hM=Q({kind:fM,value:Y().min(1)}),gM=Q({delivered:zk(),delivery:aA([`live`,`deferred`]).optional(),reached:aA([`queued`,`worker`,`supervisor`,`judged-with`,`carried`]).optional(),turn:aA([`interrupted`,`turn-end`]).optional(),member:Y().min(1).optional(),input_bytes:ij.optional(),reason:Y().min(1).optional(),node_id:Y().min(1).optional()}).superRefine((e,t)=>{e.delivered&&e.reason!==void 0&&t.addIssue({code:`custom`,path:[`reason`],message:`a delivered redirection carries no reason it did not land`}),e.delivery!==void 0&&e.delivered!==(e.delivery===`live`)&&t.addIssue({code:`custom`,path:[`delivery`],message:"`delivery` is `live` exactly when the running turn took the note"})}),_M=Q({dep:Y().min(1),identity:Y().min(1).optional(),target:Y().min(1).optional(),style:Y().min(1).optional(),action:Y().min(1).optional(),since:aj.optional(),waited_seconds:ij.optional(),last_answer:Y().min(1).optional()}),vM=Q({kind:Y().min(1).optional(),message:Y().min(1).optional(),source:Y().min(1).optional(),blocking:zk().optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a surface record carries at least one recorded fact`})}),yM=Q({name:Y().min(1).optional(),required:zk().optional(),requirement:Y().optional(),url:Y().nullable().optional(),state:Y().min(1).optional(),kind:Y().min(1).optional(),base:Y().min(1).optional(),awaited:X(Y().min(1)).optional(),grace_seconds:Fk().nonnegative().optional(),warned:zk().optional(),head:Y().min(1).optional(),verdict:Y().min(1).optional(),skipped:X(Y().min(1)).optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a review record carries at least one recorded fact`})}),bM=Q({identity:Y().min(1).optional(),target:Y().min(1).optional(),style:Y().min(1).optional(),version:Y().min(1).optional(),landing_commit:Y().min(1).optional(),actor:Y().min(1).optional(),superseded:zk().optional(),form:Y().min(1).optional(),outcome:Y().min(1).optional(),elapsed_ms:ij.optional(),dep:Y().min(1).optional(),delivery:Y().min(1).optional(),awaiting:X(_M).min(1).optional(),versions:X(Q({identity:Y().min(1),target:Y().min(1),version:Y().min(1)})).min(1).optional()}).superRefine((e,t)=>{Object.values(e).every(e=>e===void 0)&&t.addIssue({code:`custom`,message:`a release record carries at least one recorded fact`})}),xM=Q({id:Y().min(1),label:Y().min(1),order:ij,started_at:aj}),SM=Q({id:Y().min(1),stream:Y().min(1).optional(),seq:ij.optional(),journal_order:ij.optional(),record_id:Y().min(1).optional(),persona:Y().min(1).optional(),dispatch_id:Y().min(1).optional(),dispatch_group:xM.optional(),fields:rA(Y().min(1),AA()).optional(),kind:Y().min(1),at:aj,node_id:Y().min(1).optional(),step_id:Y().min(1).optional(),status:Y().min(1).optional(),author:Y().min(1).optional(),redirection:gM.optional(),release:bM.optional(),surface:vM.optional(),review:yM.optional(),reference:hM.optional(),description:Y().optional(),tool:Q({index:ij,tool_call_id:Y().min(1).optional(),turn:Y().min(1).optional()}).optional()}),CM=Q({started_at:aj,ended_at:aj}),wM=Q({kind:Y().min(1),blocking:X(Y().min(1)).min(1).optional(),ahead:X(Y().min(1)).min(1).optional(),limit:ij.optional(),reference:Y().min(1).optional(),awaiting:X(Y().min(1)).min(1).optional()}),TM=Q({id:Y().min(1),kind:pM,label:Y(),started_at:aj,ended_at:aj.nullable(),events:X(SM),parent_id:Y().min(1).optional(),node_id:Y().min(1).optional(),step_id:Y().min(1).optional(),status:Y().min(1).optional(),count:ij.optional(),total_duration_ms:ij.optional(),intervals:X(CM).optional(),harness_scope:Y().min(1).optional(),dispatch_attempt:Y().min(1).optional(),agent_role:_j.optional(),transport_role:vj.optional(),dispatch_id:Y().min(1).optional(),dispatch_group:xM.optional(),reference:hM.optional(),detail:Q({ok:zk().optional(),output_tail:Y().optional(),artifact_id:Y().optional()}).optional(),phase:mM.optional(),reasons:X(wM).min(1).optional()}).superRefine((e,t)=>{e.reasons!==void 0&&e.kind!==`queued`&&t.addIssue({code:`custom`,path:[`reasons`],message:`only a queued span carries the reasons a node was held`})}),EM=Q({id:Y().min(1),kind:fM,content:Y(),truncated:zk(),turns:X(rM).optional(),unavailable:Y().optional()}),DM=Q({api_version:Z(2),timeline_schema_version:Z(15),observed_at:aj,run_id:Y().min(1),spans:X(TM)}),OM=Q({error:Q({code:Y(),message:Y()})});Q({schema_version:Z(1),launch_id:Y().min(1),launcher:aA([`claude-code`,`codex`]),launcher_session_id:Y().min(1),started_at:aj,repository_identity:Y().min(1)});var kM=aA([`snapshot`,`run.changed`,`conversation.changed`,`activity.changed`,`run.removed`]),AM=Cj;function jM(e){let t=e.indexOf(`:`);if(t===-1)return!1;let n=e.slice(0,t),r=e.slice(t+1);return/^[a-z0-9][a-z0-9-]*$/u.test(n)&&r.length>0&&r.length<=128&&!r.startsWith(`.`)&&/^[A-Za-z0-9._-]+$/u.test(r)}var MM=Q({project:Y().min(1).nullable(),name:Y().min(1).nullable(),last_write_at:rj.nullable(),runs:X(Nj),agent_count:ij.optional()}),NM=Q({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:aj,projects:X(MM),unreadable:X(Pj).optional()}),PM=MM.extend({api_version:Z(2),telemetry_schema_version:Z(27),observed_at:aj}),FM={api_version:Z(2),telemetry_schema_version:Z(27),observed_at:aj},IM=Q({id:ij,correlation:Y().min(1).optional(),kind:Y().min(1),message:Y(),source:Y().min(1),blocking:zk(),queued_at:rj,workstream:Y().min(1).optional(),abandoned:zk().optional()}),LM=aA([`worker`,`supervisor`,`both`]),RM=aA([`live`,`next`]),zM=aA([`detach`,`drop`]),BM=aA([`done`,`failed`]),VM=Q({sets:zj.optional()}),HM=$k(`op`,[Jk({op:Z(`add`),node:Bj}).strict(),Jk({op:Z(`drop`),id:Y().min(1),dependents:zM,reason:Y().min(1).optional()}).strict(),Jk({op:Z(`reparent`),id:Y().min(1),deps:X(Y().min(1))}).strict(),Jk({op:Z(`retry`),id:Y().min(1),node:Bj}).strict(),Jk({op:Z(`cancel`),id:Y().min(1),reason:Y().min(1).optional()}).strict(),Jk({op:Z(`requeue`),id:Y().min(1),amend:VM.optional()}).strict(),Jk({op:Z(`set-node-sets`),id:Y().min(1),sets:zj}).strict(),Jk({op:Z(`set-run-node-sets`),sets:zj}).strict(),Jk({op:Z(`attest`),ref:Y().min(1)}).strict(),Jk({op:Z(`complete`),reason:Y().min(1)}).strict(),Jk({op:Z(`amend`),id:Y().min(1),text:Y().min(1)}).strict(),Jk({op:Z(`note`),id:Y().min(1),addressee:LM,text:Y().min(1),criterion:Y().min(1).optional(),deliver:RM.optional(),persist:zk().optional(),delivery_timeout_seconds:Fk().int().positive().optional()}).strict(),Jk({op:Z(`withdraw-note`),envelope:Y().min(1),index:Fk().int().nonnegative(),reason:Y().min(1)}).strict(),Jk({op:Z(`finding`),message:Y().min(1),blocking:zk().optional(),id:Y().min(1).optional()}).strict(),Jk({op:Z(`settle`),id:Y().min(1),outcome:BM,evidence:Y().min(1),landing:Y().min(1).optional(),release:Jk({target:Y().min(1),version:Y().min(1)}).strict().optional()}).strict(),Jk({op:Z(`rework`),id:Y().min(1),reason:Y().min(1),instruction:Y().min(1),comments:X(Jk({id:Y(),url:Y()}).strict()).optional(),title:Y().optional(),replacement:Y().optional()}).strict(),Jk({op:Z(`retitle`),id:Y().min(1),title:Y().min(1),reason:Y().min(1)}).strict(),Jk({op:Z(`review`)}).strict(),Jk({op:Z(`readjust`)}).strict(),Jk({op:Z(`decline`),id:Y().min(1),comments:X(Jk({id:Y(),url:Y()}).strict()),reason:Y().min(1)}).strict()]),UM=HM.options.map(e=>e.shape.op.value),WM=Jk({version:ij.optional(),author:Y().min(1).optional(),completion:zk().optional(),message:Y().optional(),reason:Y().optional(),commands:X(HM).optional()}).strict().superRefine((e,t)=>{e.commands!==void 0&&e.commands.length>0&&e.version!==3&&t.addIssue({code:`custom`,path:[`version`],message:`an edit envelope requires version 3`})}),GM=Q({id:ij,reply:Cj,at:rj,correlation:Y().min(1).optional()}),KM=Q({id:ij,author:Y().min(1).optional(),commands:X(Cj)}),qM=Q({op:Y().min(1).optional(),outcome:Y().min(1).optional(),reason:Y().optional()}),JM=Q({id:ij,applied:zk(),reason:Y().optional(),results:X(qM).optional()}),YM=Q({...FM,run_id:Y().min(1),surfaces:X(IM),waiting:X(IM),held:IM.nullable(),replies:X(GM),commands:X(KM),outcomes:X(JM)}),XM=aA([`surface`,`running`,`finished`]),ZM=Q({...FM,run_id:Y().min(1),status:XM,surface:IM.nullable(),events:X(Cj)}),QM=Q({...FM,run_id:Y().min(1),receipt:Q({reply:ij,state:Y().min(1),verdict:Y().min(1).optional(),commands:Y().min(1).optional()}),advice:X(Y())}),$M=Q({...FM,run_id:Y().min(1),surface:ij,state:Y().min(1)}),eN=Q({...FM,run_id:Y().min(1),stopped:zk(),owner:Y().min(1),forced:zk(),teardown:Y().min(1)}),tN=aA([`host`]);aA([`host`]);var nN=aA([`delivered`,`no-turn`,`failed`,`not-asked`]),rN=aA([`graceful`,`killed`,`still-running`]),iN=aA([`pushed`,`already-on-origin`,`no-remote`,`refused`]),aN=Q({...FM,scope:tN,root:Y(),grace_seconds:ij,forced:zk(),complete:zk(),runs:X(Q({run_id:Y().min(1),owner:Y().min(1),forced_over_owner:zk(),dispatches:X(Q({node:Y().min(1),pid:ij,interrupt:nN,detail:Y(),ended:rN,waited_ms:ij})),teardown:Y().min(1),branches:X(Q({identity:Y(),branch:Y(),result:iN,remote:Y().nullable(),commit:Y().nullable(),detail:Y()}))})),not_pushed:X(Q({identity:Y(),branch:Y()})),not_pushed_unread:Y().nullable(),rendered:Y()}),oN=Q({...FM,session_key:Y().min(1).optional(),reported:X(Q({run:Y().min(1),standing:Y().min(1),why_not_watched:Y()})),unresolved:X(Y())}),sN=Q({schema_version:Z(1),host:Y(),root:Y(),root_error:Y().nullable(),free_space:X(Q({roots:X(Q({role:Y(),path:Y().nullable(),measured_at:Y().nullable()})),free_bytes:ij.nullable(),total_bytes:ij.nullable(),error:Y().nullable()})),dispatches:X(Q({run:Y(),node:Y(),launcher:Y(),age_ms:rj.nullable(),proof:aA([`held`,`unproven`]),unproven:Y().nullable()})),gone:X(Q({run:Y(),node:Y(),reason:Y()})),skipped:X(Q({path:Y(),reason:Y()}))}),cN=Q({...FM,reading:sN.optional(),rendered:Y(),unreadable:X(Pj).optional()});Q({...FM,run_id:Y().min(1),rendered:Y()});var lN=Q({...FM,run_id:Y().min(1),liveness:Mj,unread_surfaces:Q({count:ij,oldest_seconds:rj.nullable()}),node_status:rA(Y(),Y().min(1)),summary:Y(),rendered:Y()});Q({...FM,run_id:Y().min(1),node:Y().min(1).nullable().optional(),rendered:Y()}),Q({...FM,run_id:Y().min(1),telemetry:Q({schema_version:ij})});var uN=Q({history_id:Y().min(1),harness:Y().min(1),variant:Y().min(1).optional(),harness_id:Y().min(1),started:aj}),dN=Q({history_session:Y().min(1),name:Y().min(1),history_dir:Y().min(1),history_project:Y().min(1),history_file:Y().min(1),project:Y().min(1),started:aj,labels:rA(Y(),Y()),runs:X(uN),run_id:Y().min(1).optional()}),fN={...FM,sessions:X(dN),skipped:ij},pN=Q({...fN,run_id:Y().min(1),node:Y().min(1).optional()}),mN=Q({...fN,project:Y().min(1)}),hN=Y().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u),gN=Y().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:(0|[1-9][0-9]*)$/u),_N=Zk([Yk({type:Z(`sidebar`)}),Yk({type:Z(`detail`),run_id:Y().min(1),filter:Y().min(1).optional()}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`run`),filter:Y().min(1).optional()}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),filter:Y().min(1).optional()}),Yk({type:Z(`channel`),run_id:Y().min(1)}),Yk({type:Z(`human-items`),filter:tj.optional(),item:Y().min(1).optional()})]),vN=Yk({id:Y().min(1),name:Y(),group:Yk({project:Y(),name:Y()}).nullable(),kind:Y().nullable(),state:Y().min(1),nodes:Yk({total:ij,done:ij,failed:ij,running:ij}),updated_at:aj,started_at:aj.optional()});Object.keys(vN.shape);var yN=Zk([Yk({type:Z(`sidebar`)}),Yk({type:Z(`detail`),run_id:Y().min(1),detail:dM}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`run`),detail:dM,timeline:DM}),Yk({type:Z(`timeline`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),detail:dM,timeline:DM}),Yk({type:Z(`channel`),run_id:Y().min(1),detail:dM,channel:YM}),nj]),bN=Yk({id:gN,sidebar:X(vN),visible:yN}),xN=X(Zk([Y(),ij])),SN=Zk([Yk({p:xN,v:Uk()}),Yk({p:xN,a:X(Uk())}),Yk({p:xN,d:Z(!0)})]),CN={id:gN,base:gN,subscription:hN},wN=aA([`unknown-cursor`,`stale-cursor`,`server-restarted`]),TN=Yk({...CN,type:Z(`reset`),reason:wN,snapshot:bN}),EN=Zk([TN,Yk({...CN,type:Z(`run.changed`),row:vN}),Yk({...CN,type:Z(`run.removed`),run_id:Y().min(1)}),Yk({...CN,type:Z(`detail.patch`),run_id:Y().min(1),ops:X(SN)}),Yk({...CN,type:Z(`timeline.patch`),run_id:Y().min(1),scope:Z(`run`),ops:X(SN)}),Yk({...CN,type:Z(`timeline.patch`),run_id:Y().min(1),scope:Z(`node`),node:Y().min(1),ops:X(SN)}),Yk({...CN,type:Z(`channel.patch`),run_id:Y().min(1),ops:X(SN)}),Yk({...CN,type:Z(`human-items.patch`),ops:X(SN)})]),DN=[`reset`,`run.changed`,`run.removed`,`detail.patch`,`timeline.patch`,`channel.patch`,`human-items.patch`],ON=Yk({subscription:hN,view:_N,initial:Zk([Yk({type:Z(`snapshot`),snapshot:bN}),TN])});Yk({code:Z(`subscription-unavailable`),reason:aA([`expired`,`server-restarted`,`unknown`])});var kN=class extends Error{constructor(e){super(e),this.name=`PatchError`}};function AN(e,t){let n=e;for(let e of t)n=jN(n,e);return n}function jN(e,t){let n=t.p;if(`a`in t)return NN(e,n,e=>{if(!Array.isArray(e))throw new kN(`an append's path names an array`);return[...e,...t.a]});let r=n.at(-1);if(r===void 0)throw new kN(`the root is never replaced or deleted`);return NN(e,n.slice(0,-1),e=>{if(`v`in t){if(Array.isArray(e)&&typeof r==`number`){if(r>=e.length)throw new kN(`a set replaces an existing element`);let n=[...e];return n[r]=t.v,n}if(MN(e)&&typeof r==`string`)return{...e,[r]:t.v};throw new kN(`a set's path does not match its parent`)}if(MN(e)&&typeof r==`string`){if(!Object.hasOwn(e,r))throw new kN(`a deletion names an existing member`);let t={...e};return delete t[r],t}throw new kN(`a deletion names an object member`)})}function MN(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function NN(e,t,n){let[r,...i]=t;if(r===void 0)return n(e);if(Array.isArray(e)&&typeof r==`number`){if(r>=e.length)throw new kN(`an index on the path does not exist`);let t=[...e];return t[r]=NN(e[r],i,n),t}if(MN(e)&&typeof r==`string`){if(!Object.hasOwn(e,r))throw new kN(`a parent on the path does not exist`);return{...e,[r]:NN(e[r],i,n)}}throw new kN(`a path step does not match its parent`)}var PN=1e3;function FN(e){let t=e.lastIndexOf(`:`);return{epoch:e.slice(0,t),seq:BigInt(e.slice(t+1))}}var IN=class{#e;#t;#n;#r;#i;#a;#o;#s=!1;#c=!1;#l=0;#u;#d=()=>{this.#_(),this.#t.onDisconnected?.()};#f=()=>this.#g();#p=()=>this.close(!0);constructor(e,t){this.#e=e,this.#t=t,this.#n=t.view,this.#u=t.paused??!1,globalThis.addEventListener?.(`offline`,this.#d),globalThis.addEventListener?.(`online`,this.#f),globalThis.addEventListener?.(`pagehide`,this.#p),this.#m({})}get view(){return this.#n}change(e){this.#s||KN(e,this.#n)||(this.#n=e,this.#c=!1,this.#_(),this.#m(this.#r===void 0?{}:{replaces:this.#r}))}pause(){this.#u||(this.#u=!0,this.#_())}resume(){this.#u&&(this.#u=!1,this.#g())}close(e=!1){this.#s||(this.#s=!0,this.#l+=1,globalThis.removeEventListener?.(`offline`,this.#d),globalThis.removeEventListener?.(`online`,this.#f),globalThis.removeEventListener?.(`pagehide`,this.#p),this.#_(),this.#r!==void 0&&this.#e.retire(this.#r,e).catch(()=>void 0))}async#m(e){let t=++this.#l,n;try{n=await this.#e.subscribe({view:this.#n,...e})}catch(e){if(t!==this.#l)return;this.#t.onError?.(JN(e));return}if(t!==this.#l||this.#s){this.#e.retire(n.subscription).catch(()=>void 0);return}let r=GN(this.#n,n);if(r!==void 0){this.#b(Error(`The subscription answered ${r}`));return}this.#r=n.subscription;let i=n.initial;if(i.type===`snapshot`)this.#h(i.snapshot,{kind:`snapshot`});else if(i.subscription!==n.subscription||i.snapshot.id!==i.id){this.#b(Error(`A recreated subscription's reset is not its own snapshot`));return}else this.#h(i.snapshot,{kind:`reset`,reason:i.reason});this.#g()}#h(e,t){this.#i={sidebar:e.sidebar,visible:e.visible,applied:e.id},this.#t.onState(this.#i,t)}#g(){if(this.#s||this.#c||this.#u||this.#a!==void 0||this.#r===void 0||this.#i===void 0)return;this.#o!==void 0&&clearTimeout(this.#o),this.#o=void 0;let e=this.#e.url(sj.events);e.searchParams.set(cj.subscription,this.#r),e.searchParams.set(cj.after,this.#i.applied);let t=this.#e.open(e);this.#a=t;let n=!1;t.onopen=()=>{n&&this.#t.onConnected?.(),n=!0};for(let e of DN)t.addEventListener(e,n=>{this.#a===t&&n instanceof MessageEvent&&typeof n.data==`string`&&this.#y(n.data,e,n.lastEventId)});t.onerror=()=>{this.#a===t&&(this.#t.onDisconnected?.(),t.readyState===2&&(this.#a=void 0,this.#o=setTimeout(()=>{this.#o=void 0,!(this.#s||this.#c||this.#i===void 0)&&this.#m({resume:this.#i.applied})},PN)))}}#_(){this.#a?.close(),this.#a=void 0,this.#o!==void 0&&clearTimeout(this.#o),this.#o=void 0}#v(){this.#_(),this.#g()}#y(e,t,n){let r=this.#i;if(r===void 0||this.#c)return;let i;try{i=EN.parse(JSON.parse(e))}catch(e){this.#b(Error(`A frame failed contract validation: ${qN(e)}`));return}if(i.subscription!==this.#r)return;if(i.type!==t||i.id!==n){this.#b(Error(`A frame's SSE event or id is not the frame's own type and id`));return}let a=FN(r.applied),o=FN(i.id);if(o.epoch===a.epoch&&o.seq<=a.seq)return;if(i.type===`reset`){if(i.snapshot.id!==i.id){this.#b(Error(`A reset frame names a snapshot other than itself`));return}let e=WN(this.#n,i.snapshot);if(e!==void 0){this.#b(Error(`A reset frame re-sent ${e}`));return}this.#h(i.snapshot,{kind:`reset`,reason:i.reason});return}if(o.epoch!==a.epoch){this.#b(Error(`A frame names another server's epoch`));return}if(i.base!==r.applied){this.#v();return}let s;try{s={...LN(r,i,this.#n),applied:i.id}}catch(e){this.#b(Error(`A patch could not be applied: ${qN(e)}`));return}this.#i=s,this.#t.onState(s,{kind:`frame`,frame:i})}#b(e){this.#c=!0,this.#_(),this.#t.onError?.(e)}};function LN(e,t,n){switch(t.type){case`run.changed`:{let n=e.sidebar.findIndex(e=>e.id===t.row.id);return{sidebar:n===-1?[...e.sidebar,t.row]:e.sidebar.map((e,r)=>r===n?t.row:e),visible:e.visible}}case`run.removed`:return{sidebar:e.sidebar.filter(e=>e.id!==t.run_id),visible:e.visible};default:return{sidebar:e.sidebar,visible:zN(e.visible,t,n)}}}function RN(e,t,n,r){let i=e.safeParse(AN(t,n));if(!i.success)throw Error(`the patched ${r} failed contract validation`);return i.data}function zN(e,t,n){let r=e=>Error(`a ${t.type} for ${e} this tab does not show`);if(t.type===`human-items.patch`){if(e.type!==`human-items`)throw r(`human items`);let i=RN(nj,e,t.ops,`human items`);if(UN(n,i))throw Error(`a human-items.patch moved its detail to another item`);return i}if(e.type===`sidebar`||e.type===`human-items`||e.run_id!==t.run_id)throw r(`a run`);let i=n=>{if(n.run_id!==e.run_id)throw Error(`a ${t.type} moved its payload to another run`);return n};switch(t.type){case`detail.patch`:return{...e,detail:(()=>{let n=RN(dM,e.detail,t.ops,`detail`);return i(n.run),n})()};case`timeline.patch`:if(e.type!==`timeline`||e.scope!==t.scope)throw r(`a timeline`);if(t.scope===`node`&&(e.scope!==`node`||e.node!==t.node))throw r(`a node's timeline`);return{...e,timeline:i(RN(DM,e.timeline,t.ops,`timeline`))};case`channel.patch`:if(e.type!==`channel`)throw r(`a channel`);return{...e,channel:i(RN(YM,e.channel,t.ops,`channel`))}}}function BN(e){return[e.type,e.run_id,e.scope,e.node].join(`\0`)}function VN(e){return Array.isArray(e)?e.map(VN):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,VN(t)])):e}function HN(e){if(e!==void 0){if(typeof e!=`string`)return JSON.stringify(VN(e));if(!e.startsWith(`{`))return e;try{return JSON.stringify(VN(JSON.parse(e)))}catch{return e}}}function UN(e,t){return t.detail===null?!1:!(`item`in e)||t.detail.item.id!==e.item}function WN(e,t){let n=t.visible;if(BN(n)!==BN(e))return`the state of another view`;if(n.type===`human-items`)return UN(e,n)?`the detail of another item`:void 0;if(n.type!==`sidebar`)return[n.detail.run.run_id,`timeline`in n?n.timeline.run_id:n.run_id,`channel`in n?n.channel.run_id:n.run_id].every(e=>e===n.run_id)?void 0:`a payload of another run`}function GN(e,t){if(BN(t.view)!==BN(e))return`another view`;let n=e=>`filter`in e?e.filter:void 0;if(HN(n(t.view))!==HN(n(e)))return`another filter`;let r=e=>`item`in e?e.item:void 0;return r(t.view)===r(e)?WN(e,t.initial.snapshot):`another item`}function KN(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qN(e){return e instanceof Error?e.message:String(e)}function JN(e){return e instanceof Error?e:Error(String(e))}var YN=class extends Error{status;code;constructor(e,t,n,r){super(e,r),this.status=t,this.code=n,this.name=`TelemetryClientError`}},XN=50,ZN=class{#e;#t;#n;constructor(e,t={}){this.#e=new URL(e),this.#t=t.fetch??globalThis.fetch,this.#n=t.eventSource}async listRuns(e=!1,t,n=XN){let r=this.#r(sj.runs);return r.searchParams.set(cj.includeSettled,String(e)),r.searchParams.set(cj.limit,String(n)),t!==void 0&&r.searchParams.set(cj.cursor,t),this.#a(r,Fj.parse)}async selectRuns(e){if(e.length===0)throw new YN(`Invalid selection`);for(let t of e)if(eP(t,`run ID`),t.includes(`,`))throw new YN(`Invalid run ID`);let t=this.#r(sj.runs);return t.searchParams.set(cj.select,e.join(`,`)),this.#a(t,Fj.parse)}async getRun(e,t={}){eP(e,`run ID`);let n=this.#r(sj.run(e));return t.includeConversations!==void 0&&n.searchParams.set(cj.includeConversations,String(t.includeConversations)),t.filter!==void 0&&n.searchParams.set(cj.filter,t.filter),this.#a(n,dM.parse)}async getTimeline(e,t,n){eP(e,`run ID`);let r=this.#r(sj.timeline(e));return n!==void 0&&r.searchParams.set(cj.filter,n),t===void 0?r.searchParams.set(cj.scope,lj.run):(r.searchParams.set(cj.scope,lj.node),r.searchParams.set(cj.node,t)),this.#a(r,DM.parse)}async getConversation(e,t){return eP(e,`run ID`),eP(t,`conversation ID`),this.#a(this.#r(sj.conversation(e,t)),iM.parse)}async getArtifact(e,t){return eP(e,`run ID`),eP(t,`artifact ID`),this.#a(this.#r(sj.artifact(e,t)),EM.parse)}subscribe(e){e.runId!==void 0&&eP(e.runId,`run ID`),e.after!==void 0&&eP(e.after,`cursor`);let t=this.#r(sj.events);e.runId!==void 0&&t.searchParams.set(cj.runId,e.runId),e.after!==void 0&&t.searchParams.set(cj.after,e.after),e.filter!==void 0&&t.searchParams.set(cj.filter,e.filter);let n=this.#i(t);for(let t of kM.options)n.addEventListener(t,n=>{try{let r=n,i=JSON.parse(r.data),a=t===`snapshot`?Fj.parse(i):AM.parse(i);e.onEvent({id:r.lastEventId,event:t,data:a})}catch(t){e.onError?.(t)}});return n.onerror=t=>e.onError?.(t),{close:()=>n.close()}}live(e){return new IN({subscribe:e=>this.createSubscription(e),retire:(e,t)=>this.retireSubscription(e,t),open:e=>this.#i(e),url:e=>this.#r(e)},e)}async createSubscription(e){return this.#a(this.#r(sj.subscriptions),ON.parse,$N(`POST`,e))}async retireSubscription(e,t=!1){eP(e,`subscription ID`);let n;try{n=await this.#t(this.#r(sj.subscription(e)),{method:`DELETE`,...t?{keepalive:t}:{}})}catch(e){throw new YN(`Telemetry request failed`,void 0,void 0,{cause:e})}if(!n.ok&&n.status!==204)throw new YN(`Retiring a subscription failed with status ${n.status}`,n.status)}async listProjects(){return this.#a(this.#r(sj.projects),NM.parse)}async getProject(e){return eP(e,`project ID`),this.#a(this.#r(sj.project(e)),PM.parse)}async getChannel(e){return eP(e,`run ID`),this.#a(this.#r(sj.channel(e)),YM.parse)}async claimNext(e,t){eP(e,`run ID`);let n=this.#r(sj.channelNext(e));return t!==void 0&&n.searchParams.set(cj.filter,t),this.#a(n,ZM.parse,{method:`POST`})}async reply(e,t,n){eP(e,`run ID`);let r=this.#r(sj.channelReply(e));return n!==void 0&&r.searchParams.set(cj.correlation,n),this.#a(r,QM.parse,{method:`POST`,headers:{"content-type":`application/json`},body:t})}async surface(e,t){return eP(e,`run ID`),this.#a(this.#r(sj.channelSurface(e)),$M.parse,$N(`POST`,t))}async attest(e,t){return eP(e,`run ID`),this.#a(this.#r(sj.attest(e)),QM.parse,$N(`POST`,{reference:t}))}async stop(e,t=!1){return eP(e,`run ID`),this.#a(this.#r(sj.stop(e)),eN.parse,$N(`POST`,{force:t}))}async listHumanItems(e={}){let t=this.#r(PA.list);for(let[n,r]of Object.entries(e))r!=null&&t.searchParams.set(n,String(r));return this.#a(t,ej.parse)}async getHumanItem(e){return eP(e,`human-item ID`),this.#a(this.#r(PA.item(e)),QA.parse)}async answerHumanItem(e,t){return eP(e,`human-item ID`),this.#a(this.#r(PA.answer(e)),$A.parse,$N(`POST`,{text:t}))}async completeHumanItem(e){return eP(e,`human-item ID`),this.#a(this.#r(PA.complete(e)),$A.parse,$N(`POST`,{}))}async dismissHumanItem(e,t){return eP(e,`human-item ID`),this.#a(this.#r(PA.dismiss(e)),$A.parse,$N(`POST`,t?.trim()?{reason:t}:{}))}async reopenHumanItem(e){return eP(e,`human-item ID`),this.#a(this.#r(PA.reopen(e)),$A.parse,$N(`POST`,{}))}async noteHumanItem(e,t){return eP(e,`human-item ID`),this.#a(this.#r(PA.note(e)),$A.parse,$N(`POST`,{text:t}))}async shutdown(e,t={}){return this.#a(this.#r(sj.shutdown),aN.parse,$N(`POST`,{scope:e,...QN(t)}))}async unwatched(){return this.#a(this.#r(sj.unwatched),oN.parse)}async host(){return this.#a(this.#r(sj.host),cN.parse)}async getStatus(e){return eP(e,`run ID`),this.#a(this.#r(sj.status(e)),lN.parse)}async getAgents(e){return eP(e,`run ID`),this.#a(this.#r(sj.agents(e)),pN.parse)}async getNodeAgents(e,t){return eP(e,`run ID`),eP(t,`node ID`),this.#a(this.#r(sj.nodeAgents(e,t)),pN.parse)}async getProjectAgents(e){return eP(e,`project ID`),this.#a(this.#r(sj.projectAgents(e)),mN.parse)}#r(e){return new URL(e,this.#e)}#i(e){return(this.#n??(e=>{if(typeof EventSource>`u`)throw new YN(`EventSource is unavailable; provide an eventSource factory`);return new EventSource(e)}))(e.toString())}async#a(e,t,n){let r;try{r=await this.#t(e,n)}catch(e){throw new YN(`Telemetry request failed`,void 0,void 0,{cause:e})}let i=await r.json().catch(e=>{throw new YN(`Telemetry server returned invalid JSON`,r.status,void 0,{cause:e})});if(!r.ok){let e=OM.safeParse(i);throw new YN(e.success?e.data.error.message:`Telemetry request failed with status ${r.status}`,r.status,e.success?e.data.error.code:void 0)}try{return t(i)}catch(e){throw new YN(`Telemetry response failed contract validation`,r.status,void 0,{cause:e})}}};function QN(e){let{grace:t,force:n=!1}=e;if(t===void 0)return{force:n};if(!Number.isSafeInteger(t)||t<0)throw new YN(`Invalid grace: whole seconds, 0 or more`);return{grace:t,force:n}}function $N(e,t){return{method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}}function eP(e,t){let n=[...e].some(e=>e.charCodeAt(0)<32);if(e.length===0||n||/[/?#]/u.test(e))throw new YN(`Invalid ${t}`)}function tP({outcome:e,label:t}){if(e===void 0)return null;if(e.kind===`refused`){let n=e.error,r=n instanceof YN?n.code:void 0,i=n instanceof YN?n.status:void 0;return(0,W.jsxs)(sa,{"aria-label":`${t} refused`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsxs)(ca,{children:[e.title,i!==void 0&&` · ${i}`,r!==void 0&&` ${r}`]}),(0,W.jsx)(la,{children:(0,W.jsx)(`pre`,{className:`verb-text`,children:n.message})})]})}return(0,W.jsxs)(sa,{"aria-label":`${t} receipt`,children:[(0,W.jsx)(Tt,{}),(0,W.jsx)(ca,{children:e.title}),(0,W.jsx)(la,{children:(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.payload,null,2)})})]})}async function nP(e,t){try{return{kind:`answered`,title:e,payload:await t()}}catch(t){return{kind:`refused`,title:e,error:t instanceof Error?t:Error(String(t))}}}var rP=365.2425,iP=6048e5,aP=864e5,oP=6e4,sP=36e5,cP=1e3,lP=525600,uP=43200,dP=1440,fP=3600*24;fP*7,fP*rP/12*3;var pP=Symbol.for(`constructDateFrom`);function mP(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&pP in e?e[pP](t):e instanceof Date?new e.constructor(t):new Date(t)}function hP(e,t){return mP(t||e,e)}var gP={};function _P(){return gP}function vP(e,t){let n=_P(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=hP(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function yP(e,t){return vP(e,{...t,weekStartsOn:1})}function bP(e,t){let n=hP(e,t?.in),r=n.getFullYear(),i=mP(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=yP(i),o=mP(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=yP(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function xP(e){let t=hP(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function SP(e,...t){let n=mP.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function CP(e,t){let n=hP(e,t?.in);return n.setHours(0,0,0,0),n}function wP(e,t,n){let[r,i]=SP(n?.in,e,t),a=CP(r),o=CP(i),s=+a-xP(a),c=+o-xP(o);return Math.round((s-c)/aP)}function TP(e,t){let n=bP(e,t),r=mP(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),yP(r)}function EP(e,t){let n=hP(e)-+hP(t);return n<0?-1:n>0?1:n}function DP(e){return mP(e,Date.now())}function OP(e,t,n){let[r,i]=SP(n?.in,e,t);return+CP(r)==+CP(i)}function kP(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function AP(e){return!(!kP(e)&&typeof e!=`number`||isNaN(+hP(e)))}function jP(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function MP(e,t){let n=hP(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var NP={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},PP=(e,t,n)=>{let r,i=NP[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function FP(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var IP={date:FP({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:FP({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:FP({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},LP={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},RP=(e,t,n,r)=>LP[e];function zP(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var BP={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:zP({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:zP({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:zP({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:zP({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:zP({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function VP(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?UP(s,e=>e.test(o)):HP(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function HP(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function UP(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function WP(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var GP={code:`en-US`,formatDistance:PP,formatLong:IP,formatRelative:RP,localize:BP,match:{ordinalNumber:WP({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:VP({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:VP({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:VP({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:VP({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:VP({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function KP(e,t){let n=hP(e,t?.in);return wP(n,MP(n))+1}function qP(e,t){let n=hP(e,t?.in),r=yP(n)-+TP(n);return Math.round(r/iP)+1}function JP(e,t){let n=hP(e,t?.in),r=n.getFullYear(),i=_P(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=mP(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=vP(o,t),c=mP(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=vP(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function YP(e,t){let n=_P(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=JP(e,t),a=mP(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),vP(a,t)}function XP(e,t){let n=hP(e,t?.in),r=vP(n,t)-+YP(n,t);return Math.round(r/iP)+1}function ZP(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var QP={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return ZP(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):ZP(n+1,2)},d(e,t){return ZP(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return ZP(e.getHours()%12||12,t.length)},H(e,t){return ZP(e.getHours(),t.length)},m(e,t){return ZP(e.getMinutes(),t.length)},s(e,t){return ZP(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return ZP(Math.trunc(r*10**(n-3)),t.length)}},$P={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},eF={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return QP.y(e,t)},Y:function(e,t,n,r){let i=JP(e,r),a=i>0?i:1-i;return t===`YY`?ZP(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):ZP(a,t.length)},R:function(e,t){return ZP(bP(e),t.length)},u:function(e,t){return ZP(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return ZP(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return ZP(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return QP.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return ZP(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=XP(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):ZP(i,t.length)},I:function(e,t,n){let r=qP(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):ZP(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):QP.d(e,t)},D:function(e,t,n){let r=KP(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):ZP(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return ZP(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return ZP(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return ZP(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?$P.noon:r===0?$P.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?$P.evening:r>=12?$P.afternoon:r>=4?$P.morning:$P.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return QP.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):QP.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):ZP(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):ZP(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):QP.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):QP.s(e,t)},S:function(e,t){return QP.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return nF(r);case`XXXX`:case`XX`:return rF(r);default:return rF(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return nF(r);case`xxxx`:case`xx`:return rF(r);default:return rF(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+tF(r,`:`);default:return`GMT`+rF(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+tF(r,`:`);default:return`GMT`+rF(r,`:`)}},t:function(e,t,n){return ZP(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return ZP(+e,t.length)}};function tF(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+ZP(a,2)}function nF(e,t){return e%60==0?(e>0?`-`:`+`)+ZP(Math.abs(e)/60,2):rF(e,t)}function rF(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=ZP(Math.trunc(r/60),2),a=ZP(r%60,2);return n+i+t+a}var iF=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},aF=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},oF={p:aF,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return iF(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,iF(r,t)).replace(`{{time}}`,aF(i,t))}},sF=/^D+$/,cF=/^Y+$/,lF=[`D`,`DD`,`YY`,`YYYY`];function uF(e){return sF.test(e)}function dF(e){return cF.test(e)}function fF(e,t,n){let r=pF(e,t,n);if(console.warn(r),lF.includes(e))throw RangeError(r)}function pF(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var mF=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,hF=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gF=/^'([^]*?)'?$/,_F=/''/g,vF=/[a-zA-Z]/;function yF(e,t,n){let r=_P(),i=n?.locale??r.locale??GP,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=hP(e,n?.in);if(!AP(s))throw RangeError(`Invalid time value`);let c=t.match(hF).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=oF[t];return n(e,i.formatLong)}return e}).join(``).match(mF).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:bF(e)};if(eF[t])return{isToken:!0,value:e};if(t.match(vF))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&dF(a)||!n?.useAdditionalDayOfYearTokens&&uF(a))&&fF(a,t,String(e));let o=eF[a[0]];return o(s,a,i.localize,l)}).join(``)}function bF(e){let t=e.match(gF);return t?t[1].replace(_F,`'`):e}function xF(e,t,n){let r=_P(),i=n?.locale??r.locale??GP,a=EP(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=SP(n?.in,...a>0?[t,e]:[e,t]),l=jP(n?.roundingMethod??`round`),u=c.getTime()-s.getTime(),d=u/oP,f=(u-(xP(c)-xP(s)))/oP,p=n?.unit,m;if(m=p||(d<1?`second`:d<60?`minute`:d<1440?`hour`:f<43200?`day`:f<525600?`month`:`year`),m===`second`){let e=l(u/1e3);return i.formatDistance(`xSeconds`,e,o)}else if(m===`minute`){let e=l(d);return i.formatDistance(`xMinutes`,e,o)}else if(m===`hour`){let e=l(d/60);return i.formatDistance(`xHours`,e,o)}else if(m===`day`){let e=l(f/dP);return i.formatDistance(`xDays`,e,o)}else if(m===`month`){let e=l(f/uP);return e===12&&p!==`month`?i.formatDistance(`xYears`,1,o):i.formatDistance(`xMonths`,e,o)}else{let e=l(f/lP);return i.formatDistance(`xYears`,e,o)}}function SF(e,t){return xF(e,DP(e),t)}function CF(e){return Math.trunc(e*sP)}function wF(e,t,n){let[r,i]=SP(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function TF(e,t){return wF(mP(t?.in||e,e),DP(t?.in||e))}function EF(e,t){return OP(mP(t?.in||e,e),DP(t?.in||e))}function DF(e){let t=e/sP;return Math.trunc(t)}function OF(e){let t=e/oP;return Math.trunc(t)}function kF(e){let t=e/cP;return Math.trunc(t)}function AF(e){return Math.trunc(e*oP)}function jF(e,t){let n=()=>mP(t?.in,NaN),r=t?.additionalDigits??2,i=IF(e),a;if(i.date){let e=LF(i.date,r);a=RF(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=BF(i.time),isNaN(s)))return n();if(i.timezone){if(c=HF(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=hP(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return hP(o+s+c,t?.in)}var MF={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},NF=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,PF=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,FF=/^([+-])(\d{2})(?::?(\d{2}))?$/;function IF(e){let t={},n=e.split(MF.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],MF.timeZoneDelimiter.test(t.date)&&(t.date=e.split(MF.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=MF.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function LF(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function RF(e,t){if(t===null)return new Date(NaN);let n=e.match(NF);if(!n)return new Date(NaN);let r=!!n[4],i=zF(n[1]),a=zF(n[2])-1,o=zF(n[3]),s=zF(n[4]),c=zF(n[5])-1;if(r)return JF(t,s,c)?UF(t,s,c):new Date(NaN);{let e=new Date(0);return!KF(t,a,o)||!qF(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function zF(e){return e?parseInt(e):1}function BF(e){let t=e.match(PF);if(!t)return NaN;let n=VF(t[1]),r=VF(t[2]),i=VF(t[3]);return YF(n,r,i)?n*sP+r*oP+i*1e3:NaN}function VF(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function HF(e){if(e===`Z`)return 0;let t=e.match(FF);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return XF(r,i)?n*(r*sP+i*oP):NaN}function UF(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var WF=[31,null,31,30,31,30,31,31,30,31,30,31];function GF(e){return e%400==0||e%4==0&&e%100!=0}function KF(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(WF[t]||(GF(e)?29:28))}function qF(e,t){return t>=1&&t<=(GF(e)?366:365)}function JF(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function YF(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function XF(e,t){return t>=0&&t<=59}function ZF(e){return e*cP}function QF(e){let t=Math.max(0,Math.round(e));if(t<ZF(1))return`${t}ms`;let n=DF(t),r=OF(t-CF(n)),i=kF(t-CF(n)-AF(r));return n>0?`${n}h ${r}m ${i}s`:r>0?`${r}m ${i}s`:`${i}s`}function $F(e){return QF(ZF(e))}function eI(e){let t=jF(e);return AP(t)?t:void 0}function tI(e){let t=eI(e);return t===void 0?e:EF(t)?yF(t,`HH:mm:ss`):TF(t)?yF(t,`MMM d, HH:mm:ss`):yF(t,`MMM d yyyy, HH:mm:ss`)}function nI(e){let t=eI(e);return t===void 0?e:yF(t,`PPpp zzzz`)}function rI(e){return new Date(e).toISOString()}function iI(e){let t=eI(e);return t===void 0?e:SF(t,{addSuffix:!0})}function aI({at:e,className:t,relative:n=!1}){let r=eI(e);return r===void 0?(0,W.jsx)(`span`,{className:t,children:e}):(0,W.jsx)(`time`,{className:t,dateTime:r.toISOString(),title:nI(e),children:n?iI(e):tI(e)})}var oI={approve:`Approve`,reject:`Reject`,continue:`Continue`},sI=[`review`,`readjust`,`decline`,`withdraw-note`],cI=[`approve`,`reject`,`continue`,...UM.filter(e=>!sI.some(t=>t===e))];function lI(e){return cI.some(t=>t===e)}var uI={approve:[`message`,`reason`],reject:[`message`,`reason`],continue:[`message`],add:[`json`],drop:[`id`,`dependents`],reparent:[`id`,`deps`],retry:[`id`,`json`],rework:[`id`,`reason`,`instruction`,`comments`,`title`,`replacement`],retitle:[`id`,`title`,`reason`],cancel:[`id`,`reason`],requeue:[`id`,`json`],"set-node-sets":[`id`,`sets`],"set-run-node-sets":[`runSets`],attest:[`reference`],complete:[`reason`],amend:[`id`,`text`],note:[`id`,`addressee`,`text`,`criterion`,`deliver`,`persist`],finding:[`message`,`blocking`,`id`],settle:[`id`,`outcome`,`evidence`,`landing`]};function dI(e,t){let n=fI(e,t);if(`problem`in n)return n;let r=WM.safeParse(n.envelope);if(!r.success){let e=r.error.issues[0];return{problem:`${e?.path.join(`.`)||`envelope`}: ${e?.message??`not an envelope`}`}}return{envelope:r.data,bytes:JSON.stringify(r.data,null,2)}}function fI(e,t){let n=e=>{let n=t[e];return typeof n==`string`&&n.trim().length>0?n:void 0};switch(e){case`approve`:return{envelope:{completion:!0,...mI(`message`,n(`message`)),...mI(`reason`,n(`reason`))}};case`reject`:return{envelope:{completion:!1,...mI(`message`,n(`message`)),...mI(`reason`,n(`reason`))}};case`continue`:return{envelope:{message:n(`message`)??``}};default:{let r=pI(e,t,n);return`problem`in r?r:{envelope:{version:3,commands:[r.command]}}}}}function pI(e,t,n){let r=n(`id`);switch(e){case`add`:case`retry`:case`requeue`:{let t=n(`json`);if(t===void 0&&e!==`requeue`)return{problem:`node: a node mapping is required`};let i;if(t!==void 0)try{i=JSON.parse(t)}catch(t){return{problem:`${e===`requeue`?`amend`:`node`}: ${t instanceof Error?t.message:`not JSON`}`}}return e===`add`?{command:{op:e,node:i}}:e===`retry`?{command:{op:e,id:r,node:i}}:{command:{op:e,id:r,...mI(`amend`,i)}}}case`set-node-sets`:case`set-run-node-sets`:{let n=[...(e===`set-node-sets`?t.sets:t.runSets)??[]],i=n.findIndex(e=>e.trim().length===0);return i>=0?{problem:`sets.${i}: an override needs a PATH=VALUE`}:e===`set-node-sets`?{command:{op:e,id:r,sets:n}}:{command:{op:e,sets:n}}}case`drop`:return{command:{op:e,id:r,dependents:n(`dependents`)}};case`reparent`:return{command:{op:e,id:r,deps:(t.deps??``).split(`
|
|
89
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}};case`rework`:{let t,i=n(`comments`);if(i!==void 0)try{t=JSON.parse(i)}catch(e){return{problem:`comments: ${e instanceof Error?e.message:`not JSON`}`}}return{command:{op:e,id:r,reason:n(`reason`),instruction:n(`instruction`),...mI(`comments`,t),...mI(`title`,n(`title`)),...mI(`replacement`,n(`replacement`))}}}case`retitle`:return{command:{op:e,id:r,title:n(`title`),reason:n(`reason`)}};case`cancel`:return{command:{op:e,id:r,...mI(`reason`,n(`reason`))}};case`attest`:return{command:{op:e,ref:n(`reference`)}};case`complete`:return{command:{op:e,reason:n(`reason`)}};case`amend`:return{command:{op:e,id:r,text:n(`text`)}};case`note`:return{command:{op:e,id:r,addressee:n(`addressee`),text:n(`text`),...mI(`criterion`,n(`criterion`)),...mI(`deliver`,n(`deliver`)===`live`?void 0:n(`deliver`)),...t.persist===!1?{persist:!1}:{}}};case`finding`:return{command:{op:e,message:n(`message`),...t.blocking===!0?{blocking:!0}:{},...mI(`id`,r)}};case`settle`:return{command:{op:e,id:r,outcome:n(`outcome`),evidence:n(`evidence`),...mI(`landing`,n(`landing`))}};default:return{problem:`op: ${String(e)} is not an op`}}}function mI(e,t){let n={};return t!==void 0&&(n[e]=t),n}function hI(e){let t=e.op;return typeof t==`string`?t:`?`}function gI({legend:e,sets:t,onChange:n,current:r}){let i=(0,H.useId)(),a=(e,r)=>n(t.map((t,n)=>n===e?r:t)),o=(e,r)=>{let i=[...t],[a]=i.splice(e,1);a!==void 0&&i.splice(r,0,a),n(i)};return(0,W.jsxs)(`fieldset`,{"aria-describedby":`${i}-hint`,className:`sets-editor`,children:[(0,W.jsx)(`legend`,{children:e}),(0,W.jsx)(`p`,{className:`sets-hint`,id:`${i}-hint`,children:`One PATH=VALUE a row, applied in order — the whole list is replaced, and an empty list clears it.`}),t.length===0?(0,W.jsx)(`p`,{className:`sets-empty`,children:`No overrides: sends an empty list.`}):(0,W.jsx)(`ol`,{className:`sets-list`,children:t.map((e,r)=>{let i=r+1;return(0,W.jsxs)(`li`,{className:`sets-row`,children:[(0,W.jsx)(Tc,{"aria-label":`Override ${i}`,className:`sets-entry`,onChange:e=>a(r,e.target.value),placeholder:`members.worker.agent.model=VALUE`,spellCheck:!1,value:e}),(0,W.jsx)(Pa,{"aria-label":`Move override ${i} up`,disabled:r===0,onClick:()=>o(r,r-1),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(yt,{})}),(0,W.jsx)(Pa,{"aria-label":`Move override ${i} down`,disabled:r===t.length-1,onClick:()=>o(r,r+1),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(_t,{})}),(0,W.jsx)(Pa,{"aria-label":`Remove override ${i}`,onClick:()=>n(t.filter((e,t)=>t!==r)),size:`icon`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{})})]},r)})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{onClick:()=>n([...t,``]),size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Jt,{size:14}),` Add override`]}),(0,W.jsxs)(Pa,{disabled:r===void 0,onClick:()=>{r!==void 0&&n([...r])},size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Zt,{size:14}),` Load current list`]}),(0,W.jsx)(`span`,{className:`sets-current`,children:r===void 0?`No current list to load`:r.length===0?`Current list: none`:`Current list: ${r.join(` · `)}`})]})]})}function _I(e,t,n){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)();return{run:(0,H.useCallback)(async(...r)=>{i(!0);let a=await nP(typeof e==`string`?e:e(...r),()=>t(...r));return o(a),i(!1),a.kind===`answered`&&n?.(),a},[e,t,n]),pending:r,outcome:a}}function vI(e,t,n,r){let[i,a]=(0,H.useState)(`continue`),[o,s]=(0,H.useState)({}),[c,l]=(0,H.useState)(),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(``);return{shortcut:i,setShortcut:a,fields:o,setField:(0,H.useCallback)((e,t)=>s(n=>({...n,[e]:t})),[]),problem:c,compose:(0,H.useCallback)(()=>{let e=dI(i,{...n,...o});if(`problem`in e){l(e.problem);return}l(void 0),d(e.bytes)},[i,o,n]),envelope:u,setEnvelope:d,correlation:f,setCorrelation:p,send:_I(`Reply`,(0,H.useCallback)(()=>e.reply(t,u,f.trim()===``?void 0:f.trim()),[e,t,u,f]),r)}}var yI={message:`Message`,reason:`Reason`,instruction:`Instruction`,title:`Title`,replacement:`Replacement node id (optional)`,comments:`Review comments (JSON, optional)`,id:`Node id`,text:`Text`,addressee:`Addressee`,deliver:`Deliver`,persist:`Carry to the next dispatch if no turn takes it`,criterion:`Criterion (optional)`,dependents:`Dependents`,deps:`Dependencies, one per line`,reference:`Reference`,outcome:`Outcome`,evidence:`Evidence`,landing:`Landing (optional)`,blocking:`Blocking`,json:`Mapping (JSON)`,sets:`Node overrides`,runSets:`Run-wide overrides`},bI={addressee:LM.options,deliver:RM.options,dependents:zM.options,outcome:BM.options},xI=Object.fromEntries(Object.entries(bI).map(([e,t])=>[e,t[0]]));function SI({client:e,runId:t,onSent:n,overrides:r}){let i=(0,H.useId)(),{shortcut:a,setShortcut:o,fields:s,setField:c,problem:l,compose:u,envelope:d,setEnvelope:f,correlation:p,setCorrelation:m,send:h}=vI(e,t,xI,n);return(0,W.jsxs)(`section`,{"aria-labelledby":`${i}-heading`,className:`composer`,children:[(0,W.jsx)(`h3`,{id:`${i}-heading`,children:`Reply`}),(0,W.jsxs)(`div`,{className:`composer-shortcut`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-shortcut`,children:`Shortcut`}),(0,W.jsxs)(`select`,{className:`composer-select`,id:`${i}-shortcut`,onChange:e=>{let t=e.target.value;lI(t)&&o(t)},value:a,children:[(0,W.jsx)(`optgroup`,{label:`Verdict`,children:Object.entries(oI).map(([e,t])=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`optgroup`,{label:`Edit`,children:cI.filter(e=>!(e in oI)).map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,W.jsx)(`div`,{className:`composer-fields`,children:uI[a].map(e=>{let t=`${i}-${e}`,n=bI[e];if(e===`sets`||e===`runSets`){let t=typeof s.id==`string`?s.id.trim():``;return(0,W.jsx)(gI,{current:e===`runSets`?r?.run:r?.nodes.get(t),legend:`${yI[e]}, in order`,onChange:t=>c(e,t),sets:s[e]??[]},e)}if(e===`persist`||e===`blocking`)return(0,W.jsxs)(`div`,{className:`composer-check`,children:[(0,W.jsx)(`input`,{checked:e===`persist`?s.persist!==!1:s.blocking===!0,id:t,onChange:t=>c(e,t.target.checked),type:`checkbox`}),(0,W.jsx)(Oc,{htmlFor:t,children:yI[e]})]},e);let a=s[e],o=typeof a==`string`?a:``;return(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:t,children:yI[e]}),n===void 0?e===`message`||e===`text`||e===`json`||e===`deps`||e===`evidence`?(0,W.jsx)(Tp,{id:t,onChange:t=>c(e,t.target.value),rows:e===`json`?5:2,value:o}):(0,W.jsx)(Tc,{id:t,onChange:t=>c(e,t.target.value),value:o}):(0,W.jsx)(`select`,{className:`composer-select`,id:t,onChange:t=>c(e,t.target.value),value:o||n[0],children:n.map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]},e)})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{onClick:u,size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(cn,{size:14}),` Compose envelope`]}),l!==void 0&&(0,W.jsx)(`p`,{"aria-label":`Envelope not composed`,className:`composer-problem`,role:`alert`,children:l})]}),(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-envelope`,children:`Envelope (sent as typed)`}),(0,W.jsx)(Tp,{className:`composer-envelope`,id:`${i}-envelope`,onChange:e=>f(e.target.value),rows:8,spellCheck:!1,value:d})]}),(0,W.jsxs)(`div`,{className:`composer-field composer-correlation`,children:[(0,W.jsx)(Oc,{htmlFor:`${i}-correlation`,children:`Correlation (optional)`}),(0,W.jsx)(Tc,{id:`${i}-correlation`,onChange:e=>m(e.target.value),value:p})]}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(Pa,{disabled:h.pending||d.trim()===``,onClick:()=>void h.run(),size:`sm`,type:`button`,children:[(0,W.jsx)(en,{size:14}),` Send reply`]}),(0,W.jsx)(`span`,{"aria-live":`polite`,className:`run-list-status`,children:h.pending?`Sending…`:``})]}),(0,W.jsx)(tP,{label:`Reply`,outcome:h.outcome})]})}function CI(e){return(0,H.useMemo)(()=>{let t=new Set(e.surfaces.flatMap(e=>e.correlation?[e.correlation]:[]));return{exchanges:[...e.surfaces].reverse().map(t=>({surface:t,replies:e.replies.filter(e=>t.correlation!==void 0&&e.correlation===t.correlation)})),otherReplies:e.replies.filter(e=>!t.has(e.correlation??``))}},[e])}function wI({client:e,runId:t,filter:n,decisions:r,observedAt:i,channel:a,journalSeq:o,overrides:s}){let c=(0,H.useCallback)(()=>void 0,[]),l=_I(`Next`,(0,H.useCallback)(()=>e.claimNext(t,n),[e,t,n]),c);return(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`channel-view`,"data-journal-seq":o,children:[(0,W.jsxs)(`section`,{"aria-labelledby":`channel-queue-heading`,className:`channel-section`,children:[(0,W.jsxs)(`div`,{className:`section-heading channel-heading`,children:[(0,W.jsxs)(`h3`,{id:`channel-queue-heading`,children:[(0,W.jsx)(Ft,{size:15}),` Channel queue`]}),(0,W.jsx)(Pa,{disabled:l.pending,onClick:()=>void l.run(),size:`sm`,type:`button`,children:`Next`})]}),a===void 0?(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,W.jsx)(xf,{className:`h-2 w-48`}),`Loading channel…`]}):(0,W.jsx)(TI,{observedAt:i,queue:a}),(0,W.jsx)(tP,{label:`Next`,outcome:l.outcome})]}),(0,W.jsx)(kI,{client:e,decisions:r,onWrote:c,runId:t}),(0,W.jsx)(SI,{client:e,onSent:c,overrides:s,runId:t}),(0,W.jsx)(AI,{client:e,onRaised:c,runId:t})]})})}function TI({queue:e,observedAt:t}){let{exchanges:n,otherReplies:r}=CI(e);return(0,W.jsxs)(`div`,{className:`channel-queue`,children:[(0,W.jsxs)(`section`,{"aria-label":`Surfaces`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Conversation`}),e.surfaces.length===0&&(0,W.jsx)(`p`,{className:`channel-empty`,children:`No surfaces yet.`}),(0,W.jsx)(`ul`,{children:n.map(({surface:e,replies:n})=>(0,W.jsxs)(`li`,{"aria-label":`Surface ${e.id}`,children:[(0,W.jsx)(OI,{observedAt:t,surface:e}),n.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`Waiting for reply`}):n.map(e=>(0,W.jsx)(DI,{reply:e},e.id))]},e.id))})]}),(0,W.jsxs)(`section`,{"aria-label":`Replies`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Other replies`}),r.map(e=>(0,W.jsx)(DI,{reply:e},e.id))]}),(0,W.jsxs)(`section`,{"aria-label":`Queued commands`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Queued commands`}),e.commands.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`Nothing awaits the reconciler.`}):(0,W.jsx)(`ul`,{children:e.commands.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Fa,{className:`channel-card`,children:(0,W.jsx)(Ia,{children:(0,W.jsxs)(`div`,{className:`channel-card-head`,children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`envelope `,e.id]}),(0,W.jsx)(Ma,{variant:`secondary`,children:e.author??`planner`}),(0,W.jsx)(`span`,{children:e.commands.map(hI).join(`, `)})]})})})},e.id))})]}),(0,W.jsxs)(`section`,{"aria-label":`Command outcomes`,className:`channel-list`,children:[(0,W.jsx)(`h4`,{children:`Command outcomes`}),e.outcomes.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`The reconciler has answered nothing yet.`}):(0,W.jsx)(`ul`,{children:e.outcomes.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(Fa,{className:`channel-card`,children:(0,W.jsxs)(Ia,{children:[(0,W.jsxs)(`div`,{className:`channel-card-head`,children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`envelope `,e.id]}),(0,W.jsx)(Ma,{variant:e.applied?`default`:`destructive`,children:e.applied?`applied`:`not applied`})]}),e.reason!==void 0&&(0,W.jsx)(`pre`,{className:`verb-text`,children:e.reason}),e.results!==void 0&&e.results.length>0&&(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.results,null,2)})]})})},e.id))})]})]})}function EI({text:e,children:t,meta:n,label:r}){let i=e.split(/\r?\n/,1)[0];return(0,W.jsxs)(`details`,{"aria-label":r,className:`channel-message-details`,children:[(0,W.jsxs)(`summary`,{"aria-label":`${r}: ${i}`,children:[(0,W.jsx)(`span`,{className:`channel-message-meta`,children:n}),(0,W.jsxs)(`span`,{className:`channel-message-preview`,children:[i,`…`]})]}),(0,W.jsx)(`pre`,{className:`verb-text`,children:e}),t]})}function DI({reply:e}){let t=typeof e.reply.message==`string`?e.reply.message:`Reply without message`;return(0,W.jsx)(Fa,{className:`channel-card py-2`,children:(0,W.jsx)(Ia,{children:(0,W.jsx)(EI,{label:`Reply ${e.id} message`,text:t,meta:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ma,{variant:`outline`,children:[`reply `,e.id]}),(0,W.jsx)(aI,{at:rI(e.at),relative:!0})]}),children:(0,W.jsxs)(`details`,{"aria-label":`Raw envelope for reply ${e.id}`,children:[(0,W.jsx)(`summary`,{children:`Raw envelope`}),(0,W.jsx)(`pre`,{className:`verb-text`,children:JSON.stringify(e.reply,null,2)})]})})})})}function OI({surface:e,observedAt:t}){let n=Math.max(0,(Date.parse(t)-e.queued_at)/1e3);return(0,W.jsx)(Fa,{className:`channel-card py-2`,children:(0,W.jsx)(Ia,{children:(0,W.jsx)(EI,{label:`Surface ${e.id} message`,text:e.message,meta:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ma,{children:e.kind}),(0,W.jsxs)(Ma,{variant:`secondary`,children:[`from `,e.source]}),e.blocking?(0,W.jsx)(Ma,{variant:`destructive`,children:`blocking`}):(0,W.jsx)(Ma,{variant:`outline`,children:`non-blocking`}),e.workstream!==void 0&&(0,W.jsxs)(Ma,{variant:`outline`,children:[`node `,e.workstream]}),(0,W.jsxs)(`span`,{className:`channel-age`,children:[`surface `,e.id,` · `,$F(n),` old`]})]})})})})}function kI({client:e,runId:t,decisions:n,onWrote:r}){let i=jI(e,t,r);return(0,W.jsxs)(`section`,{"aria-labelledby":`attest-heading`,className:`channel-section`,children:[(0,W.jsxs)(`h3`,{id:`attest-heading`,children:[(0,W.jsx)(bt,{size:15}),` Ready human actions`]}),n.length===0?(0,W.jsx)(`p`,{className:`channel-empty`,children:`No decision point is holding the graph.`}):(0,W.jsx)(`ul`,{className:`attest-list`,children:n.map(e=>(0,W.jsxs)(`li`,{className:`attest-row`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(Ma,{variant:`outline`,children:e.kind}),` `,(0,W.jsx)(`span`,{className:`attest-reference`,children:e.id}),e.unblocks.length>0&&(0,W.jsxs)(`span`,{className:`channel-age`,children:[` `,`· unblocks `,e.unblocks.join(`, `)]})]}),(0,W.jsxs)(Pa,{disabled:i.pending,onClick:()=>void i.run(e.id),size:`sm`,type:`button`,variant:`outline`,children:[`Attest `,e.id]})]},e.id))}),(0,W.jsx)(tP,{label:`Attest`,outcome:i.outcome})]})}function AI({client:e,runId:t,onRaised:n}){let r=(0,H.useId)(),{kind:i,setKind:a,message:o,setMessage:s,raise:c}=MI(e,t,n);return(0,W.jsxs)(`section`,{"aria-labelledby":`${r}-heading`,className:`channel-section`,children:[(0,W.jsxs)(`h3`,{id:`${r}-heading`,children:[(0,W.jsx)(Ht,{size:15}),` Surface`]}),(0,W.jsxs)(`div`,{className:`composer-fields`,children:[(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${r}-kind`,children:`Kind`}),(0,W.jsx)(Tc,{id:`${r}-kind`,onChange:e=>a(e.target.value),placeholder:`finding`,value:i})]}),(0,W.jsxs)(`div`,{className:`composer-field`,children:[(0,W.jsx)(Oc,{htmlFor:`${r}-message`,children:`Message`}),(0,W.jsx)(Tp,{id:`${r}-message`,onChange:e=>s(e.target.value),rows:2,value:o})]})]}),(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{disabled:c.pending||i.trim()===``,onClick:()=>void c.run(),size:`sm`,type:`button`,variant:`outline`,children:`Raise surface`})}),(0,W.jsx)(tP,{label:`Surface`,outcome:c.outcome})]})}function jI(e,t,n){return _I(e=>`Attest ${e}`,(0,H.useCallback)(n=>e.attest(t,n),[e,t]),n)}function MI(e,t,n){let[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(``);return{kind:r,setKind:i,message:a,setMessage:o,raise:_I(`Surface`,(0,H.useCallback)(()=>e.surface(t,{kind:r,message:a}),[e,t,r,a]),(0,H.useCallback)(()=>{o(``),n()},[n]))}}function NI(e){return/\[[^\]]+\]/.exec(e)?.[0]}function PI({runId:e,control:t,ended:n}){let{stop:r,stopOpen:i,setStopOpen:a,forceOpen:o,setForceOpen:s,refusal:c}=FI(t),l=c===void 0?void 0:NI(c.message),u=r.outcome,d=r.pending,f=t.status.value?.liveness;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`run-actions`,children:[f!==void 0&&(0,W.jsx)(Ma,{"aria-label":`Liveness ${f}`,className:`run-actions-badge`,variant:`outline`,children:f}),!n&&(0,W.jsxs)(Pa,{"aria-label":`Stop`,disabled:d,onClick:()=>a(!0),size:`sm`,title:`Stop`,type:`button`,variant:`destructive`,children:[(0,W.jsx)(qt,{size:14}),(0,W.jsx)(`span`,{className:`run-action-label`,children:`Stop`})]})]}),(0,W.jsx)(gc,{onOpenChange:a,open:i,children:(0,W.jsxs)(bc,{children:[(0,W.jsxs)(xc,{children:[(0,W.jsxs)(Cc,{children:[`Stop `,e,`?`]}),(0,W.jsx)(wc,{children:`The run is stopped as the acting session. A run another session owns is refused, naming its owner.`})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsx)(Pa,{disabled:d,onClick:()=>void r.run(!1),type:`button`,variant:`destructive`,children:`Stop run`})]})]})}),(0,W.jsx)(gc,{onOpenChange:s,open:o,children:(0,W.jsxs)(bc,{children:[(0,W.jsxs)(xc,{children:[(0,W.jsxs)(Cc,{children:[`Force-stop `,e,l!==void 0&&`, overriding ${l}`,`?`]}),(0,W.jsxs)(wc,{children:[c?.message,` — `,`a forced stop is journalled forced with the owner it overrode.`]})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsxs)(Pa,{disabled:d,onClick:()=>void r.run(!0),type:`button`,variant:`destructive`,children:[`Force stop`,l!==void 0&&`, overriding ${l}`]})]})]})}),u!==void 0&&(0,W.jsxs)(`div`,{className:`run-outcomes`,children:[(0,W.jsx)(tP,{label:`Stop`,outcome:u}),c!==void 0&&(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{onClick:()=>s(!0),size:`sm`,type:`button`,variant:`destructive`,children:`Force stop…`})})]})]})}function FI(e){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1),a=_I(e=>e?`Forced stop`:`Stop`,(0,H.useCallback)(async t=>{try{return await e.stop(t)}finally{n(!1),i(!1)}},[e.stop]));return{stop:a,stopOpen:t,setStopOpen:n,forceOpen:r,setForceOpen:i,refusal:a.outcome?.kind===`refused`&&a.outcome.error instanceof YN&&a.outcome.error.code===`not_owner`?a.outcome.error:void 0}}function II(e,t,n){let[r,i]=(0,H.useState)({}),a=(0,H.useRef)({key:e});(0,H.useEffect)(()=>{a.current.key=e},[e]),(0,H.useEffect)(()=>{if(e===void 0)return;let n=a.current.out;if(n?.key===e){n.again=!0;return}let r=()=>{let n={key:e,again:!1};a.current.out=n;let o=t=>{a.current.out===n&&(a.current.out=void 0),a.current.key===e&&(t(),n.again&&r())};t().then(t=>o(()=>i({key:e,value:t}))).catch(t=>o(()=>i(n=>({...n.key===e?n:{},key:e,error:LI(t)}))))};r()},[e,n]);let o=r.key===e?r:void 0;return{value:o?.value,error:o?.error,loading:e!==void 0&&o?.value===void 0&&o?.error===void 0}}function LI(e){return e instanceof Error?e:Error(String(e))}function RI(e,t){let[n,r]=(0,H.useState)(0),i=(0,H.useCallback)(()=>r(e=>e+1),[]);return{status:II(t,()=>e.getStatus(t??``),n),stop:(0,H.useCallback)(async n=>{try{return await e.stop(t??``,n)}finally{i()}},[e,t,i]),reread:i}}var zI=o(((e,t)=>{var n=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>void 0;_defaultEdgeLabelFn=()=>void 0;_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=!Object.hasOwn(e,`directed`)||e.directed,this._isMultigraph=Object.hasOwn(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.hasOwn(e,`compound`)?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!=`function`&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var n=arguments,r=this;return e.forEach(function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(var n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else if(e===`\0`)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,i(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!=`function`&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce(function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,i,s=!1,c=arguments[0];typeof c==`object`&&c&&`v`in c?(e=c.v,t=c.w,n=c.name,arguments.length===2&&(i=arguments[1],s=!0)):(e=c,t=arguments[1],n=arguments[3],arguments.length>2&&(i=arguments[2],s=!0)),e=``+e,t=``+t,n!==void 0&&(n=``+n);var l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=i),this;if(n!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[l]=s?i:this._defaultEdgeLabelFn(e,t,n);var u=o(this._isDirected,e,t,n);return e=u.v,t=u.w,Object.freeze(u),this._edgeObjs[l]=u,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][l]=u,this._out[e][l]=u,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){let e=this.edge(...arguments);return typeof e==`object`?e:{label:e}}hasEdge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[t],e),i(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.v===t):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.w===t):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};function r(e,t){e[t]?e[t]++:e[t]=1}function i(e,t){--e[t]||delete e[t]}function a(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}return i+``+a+``+(r===void 0?`\0`:r)}function o(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=n})),BI=o(((e,t)=>{t.exports=`2.2.4`})),VI=o(((e,t)=>{t.exports={Graph:zI(),version:BI()}})),HI=o(((e,t)=>{var n=zI();t.exports={write:r,read:o};function r(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:i(e),edges:a(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function i(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function a(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function o(e){var t=new n(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}})),UI=o(((e,t)=>{t.exports=n;function n(e){var t={},n=[],r;function i(n){Object.hasOwn(t,n)||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}})),WI=o(((e,t)=>{t.exports=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}}})),GI=o(((e,t)=>{var n=WI();t.exports=i;var r=()=>1;function i(e,t,n,i){return a(e,String(t),n||r,i||function(t){return e.outEdges(t)})}function a(e,t,r,i){var a={},o=new n,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<n.distance&&(n.distance=l,n.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var n=e===t?0:1/0;a[e]={distance:n},o.add(e,n)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}})),KI=o(((e,t)=>{var n=GI();t.exports=r;function r(e,t,r){return e.nodes().reduce(function(i,a){return i[a]=n(e,a,t,r),i},{})}})),qI=o(((e,t)=>{t.exports=n;function n(e){var t=0,n=[],r={},i=[];function a(o){var s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){Object.hasOwn(r,e)?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(o!==l);i.push(c)}}return e.nodes().forEach(function(e){Object.hasOwn(r,e)||a(e)}),i}})),JI=o(((e,t)=>{var n=qI();t.exports=r;function r(e){return n(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}})),YI=o(((e,t)=>{t.exports=r;var n=()=>1;function r(e,t,r){return i(e,t||n,r||function(t){return e.outEdges(t)})}function i(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}})),XI=o(((e,t)=>{function n(e){var t={},n={},i=[];function a(o){if(Object.hasOwn(n,o))throw new r;Object.hasOwn(t,o)||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(a),delete n[o],i.push(o))}if(e.sinks().forEach(a),Object.keys(t).length!==e.nodeCount())throw new r;return i}var r=class extends Error{constructor(){super(...arguments)}};t.exports=n,n.CycleException=r})),ZI=o(((e,t)=>{var n=XI();t.exports=r;function r(e){try{n(e)}catch(e){if(e instanceof n.CycleException)return!1;throw e}return!0}})),QI=o(((e,t)=>{t.exports=n;function n(e,t,n){Array.isArray(t)||(t=[t]);var a=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o=n===`post`?r:i,s=[],c={};return t.forEach(t=>{if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);o(t,a,c,s)}),s}function r(e,t,n,r){for(var i=[[e,!1]];i.length>0;){var o=i.pop();o[1]?r.push(o[0]):Object.hasOwn(n,o[0])||(n[o[0]]=!0,i.push([o[0],!0]),a(t(o[0]),e=>i.push([e,!1])))}}function i(e,t,n,r){for(var i=[e];i.length>0;){var o=i.pop();Object.hasOwn(n,o)||(n[o]=!0,r.push(o),a(t(o),e=>i.push(e)))}}function a(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}})),$I=o(((e,t)=>{var n=QI();t.exports=r;function r(e,t){return n(e,t,`post`)}})),eL=o(((e,t)=>{var n=QI();t.exports=r;function r(e,t){return n(e,t,`pre`)}})),tL=o(((e,t)=>{var n=zI(),r=WI();t.exports=i;function i(e,t){var i=new n,a={},o=new r,s;function c(e){var n=e.v===s?e.w:e.v,r=o.priority(n);if(r!==void 0){var i=t(e);i<r&&(a[n]=s,o.decrease(n,i))}}if(e.nodeCount()===0)return i;e.nodes().forEach(function(e){o.add(e,1/0),i.setNode(e)}),o.decrease(e.nodes()[0],0);for(var l=!1;o.size()>0;){if(s=o.removeMin(),Object.hasOwn(a,s))i.setEdge(s,a[s]);else if(l)throw Error(`Input graph is not connected: `+e);else l=!0;e.nodeEdges(s).forEach(c)}return i}})),nL=o(((e,t)=>{t.exports={components:UI(),dijkstra:GI(),dijkstraAll:KI(),findCycles:JI(),floydWarshall:YI(),isAcyclic:ZI(),postorder:$I(),preorder:eL(),prim:tL(),tarjan:qI(),topsort:XI()}})),rL=o(((e,t)=>{var n=VI();t.exports={Graph:n.Graph,json:HI(),alg:nL(),version:n.version}})),iL=o(((e,t)=>{var n=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,i)),n=n._prev;return`[`+e.join(`, `)+`]`}};function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i(e,t){if(e!==`_next`&&e!==`_prev`)return t}t.exports=n})),aL=o(((e,t)=>{var n=rL().Graph,r=iL();t.exports=a;var i=()=>1;function a(e,t){if(e.nodeCount()<=1)return[];let n=c(e,t||i);return o(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))}function o(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)s(e,t,n,o);for(;o=i.dequeue();)s(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){r=r.concat(s(e,t,n,o,!0));break}}}return r}function s(e,t,n,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,l(t,n,s)}),e.outEdges(r.v).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,l(t,n,o)}),e.removeNode(r.v),a}function c(e,t){let i=new n,a=0,o=0;e.nodes().forEach(e=>{i.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let n=i.edge(e.v,e.w)||0,r=t(e),s=n+r;i.setEdge(e.v,e.w,s),o=Math.max(o,i.node(e.v).out+=r),a=Math.max(a,i.node(e.w).in+=r)});let s=u(o+a+3).map(()=>new r),c=a+1;return i.nodes().forEach(e=>{l(s,c,i.node(e))}),{graph:i,buckets:s,zeroIdx:c}}function l(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function u(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}})),oL=o(((e,t)=>{var n=rL().Graph;t.exports={addBorderNode:f,addDummyNode:r,applyWithChunking:h,asNonCompoundGraph:a,buildLayerMatrix:l,intersectRect:c,mapValues:w,maxRank:g,normalizeRanks:u,notime:y,partition:_,pick:C,predecessorWeights:s,range:S,removeEmptyRanks:d,simplify:i,successorWeights:o,time:v,uniqueId:x,zipObject:T};function r(e,t,n,r){for(var i=r;e.hasNode(i);)i=x(r);return n.dummy=t,e.setNode(i,n),i}function i(e){let t=new n().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function a(e){let t=new n({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function o(e){let t=e.nodes().map(t=>{let n={};return e.outEdges(t).forEach(t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function s(e){let t=e.nodes().map(t=>{let n={};return e.inEdges(t).forEach(t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function c(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function l(e){let t=S(g(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i][r.order]=n)}),t}function u(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=h(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function d(e){let t=e.nodes().map(t=>e.node(t).rank),n=h(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function f(e,t,n,i){let a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=i),r(e,`border`,a,t)}function p(e,t=m){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var m=65535;function h(e,t){if(t.length>m){let n=p(t);return e.apply(null,n.map(t=>e.apply(null,t)))}else return e.apply(null,t)}function g(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return h(Math.max,t)}function _(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function v(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function y(e,t){return t()}var b=0;function x(e){return e+(``+ ++b)}function S(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function C(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function w(e,t){let n=t;return typeof t==`string`&&(n=e=>e[t]),Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function T(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}})),sL=o(((e,t)=>{var n=aL(),r=oL().uniqueId;t.exports={run:i,undo:o};function i(e){(e.graph().acyclicer===`greedy`?n(e,t(e)):a(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,r(`rev`))});function t(e){return t=>e.edge(t).weight}}function a(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}})),cL=o(((e,t)=>{var n=oL();t.exports={run:r,undo:a};function r(e){e.graph().dummyChains=[],e.edges().forEach(t=>i(e,t))}function i(e,t){let r=t.v,i=e.node(r).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:t,rank:i},u=n.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(r,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),r=u;e.setEdge(r,a,{weight:c.weight},s)}function a(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}})),lL=o(((e,t)=>{var{applyWithChunking:n}=oL();t.exports={longestPath:r,slack:i};function r(e){var t={};function r(i){var a=e.node(i);if(Object.hasOwn(t,i))return a.rank;t[i]=!0;let o=e.outEdges(i).map(t=>t==null?1/0:r(t.w)-e.edge(t).minlen);var s=n(Math.min,o);return s===1/0&&(s=0),a.rank=s}e.sources().forEach(r)}function i(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}})),uL=o(((e,t)=>{var n=rL().Graph,r=lL().slack;t.exports=i;function i(e){var t=new n({directed:!1}),i=e.nodes()[0],c=e.nodeCount();t.setNode(i,{});for(var l,u;a(t,e)<c;)l=o(t,e),u=t.hasNode(l.v)?r(e,l):-r(e,l),s(t,e,u);return t}function a(e,t){function n(i){t.nodeEdges(i).forEach(a=>{var o=a.v,s=i===o?a.w:o;!e.hasNode(s)&&!r(t,a)&&(e.setNode(s,{}),e.setEdge(i,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function o(e,t){return t.edges().reduce((n,i)=>{let a=1/0;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=r(t,i)),a<n[0]?[a,i]:n},[1/0,null])[1]}function s(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}})),dL=o(((e,t)=>{var n=uL(),r=lL().slack,i=lL().longestPath,a=rL().alg.preorder,o=rL().alg.postorder,s=oL().simplify;t.exports=c,c.initLowLimValues=f,c.initCutValues=l,c.calcCutValue=d,c.leaveEdge=m,c.enterEdge=h,c.exchangeEdges=g;function c(e){e=s(e),i(e);var t=n(e);f(t),l(t,e);for(var r,a;r=m(t);)a=h(t,e,r),g(t,e,r,a)}function l(e,t){var n=o(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>u(e,t,n))}function u(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=d(e,t,n)}function d(e,t,n){var r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;return a||=(i=!1,t.edge(r,n)),o=a.weight,t.nodeEdges(n).forEach(a=>{var s=a.v===n,c=s?a.w:a.v;if(c!==r){var l=s===i,u=t.edge(a).weight;if(o+=l?u:-u,v(e,n,c)){var d=e.edge(n,c).cutvalue;o+=l?-d:d}}}),o}function f(e,t){arguments.length<2&&(t=e.nodes()[0]),p(e,{},1,t)}function p(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(i=>{Object.hasOwn(t,i)||(n=p(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function h(e,t,n){var i=n.v,a=n.w;t.hasEdge(i,a)||(i=n.w,a=n.v);var o=e.node(i),s=e.node(a),c=o,l=!1;return o.lim>s.lim&&(c=s,l=!0),t.edges().filter(t=>l===y(e,e.node(t.v),c)&&l!==y(e,e.node(t.w),c)).reduce((e,n)=>r(t,n)<r(t,e)?n:e)}function g(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),f(e),l(e,t),_(e,t)}function _(e,t){var n=a(e,e.nodes().find(e=>!t.node(e).parent));n=n.slice(1),n.forEach(n=>{var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function v(e,t,n){return e.hasEdge(t,n)}function y(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}})),fL=o(((e,t)=>{var n=lL().longestPath,r=uL(),i=dL();t.exports=a;function a(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case`network-simplex`:c(e);break;case`tight-tree`:s(e);break;case`longest-path`:o(e);break;case`none`:break;default:c(e)}}var o=n;function s(e){n(e),r(e)}function c(e){i(e)}})),pL=o(((e,t)=>{t.exports=n;function n(e){let t=i(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),a=i.edgeObj,o=r(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;for(;n!==a.w;){if(i=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRank<i.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(u=s[l+1]).minRank<=i.rank;)l++;u=s[l]}e.setParent(n,u),n=e.successors(n)[0]}})}function r(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c,l;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function i(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children().forEach(r),t}})),mL=o(((e,t)=>{var n=oL();t.exports={run:r,cleanup:s};function r(e){let t=n.addDummyNode(e,`root`,{},`_root`),r=a(e),s=Object.values(r),c=n.applyWithChunking(Math.max,s)-1,l=2*c+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=l);let u=o(e)+1;e.children().forEach(n=>i(e,t,l,u,c,r,n)),e.graph().nodeRankFactor=l}function i(e,t,r,a,o,s,c){let l=e.children(c);if(!l.length){c!==t&&e.setEdge(t,c,{weight:0,minlen:r});return}let u=n.addBorderNode(e,`_bt`),d=n.addBorderNode(e,`_bb`),f=e.node(c);e.setParent(u,c),f.borderTop=u,e.setParent(d,c),f.borderBottom=d,l.forEach(n=>{i(e,t,r,a,o,s,n);let l=e.node(n),f=l.borderTop?l.borderTop:n,p=l.borderBottom?l.borderBottom:n,m=l.borderTop?a:2*a,h=f===p?o-s[c]+1:1;e.setEdge(u,f,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,d,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(c)||e.setEdge(t,u,{weight:0,minlen:o+s[c]})}function a(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children().forEach(e=>n(e,1)),t}function o(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function s(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}})),hL=o(((e,t)=>{var n=oL();t.exports=r;function r(e){function t(n){let r=e.children(n),a=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(a,`minRank`)){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,r=a.maxRank+1;t<r;++t)i(e,`borderLeft`,`_bl`,n,a,t),i(e,`borderRight`,`_br`,n,a,t)}}e.children().forEach(t)}function i(e,t,r,i,a,o){let s={width:0,height:0,rank:o,borderType:t},c=a[t][o-1],l=n.addDummyNode(e,`border`,s,r);a[t][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}})),gL=o(((e,t)=>{t.exports={adjust:n,undo:r};function n(e){let t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&i(e)}function r(e){let t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&o(e),(t===`lr`||t===`rl`)&&(c(e),i(e))}function i(e){e.nodes().forEach(t=>a(e.node(t))),e.edges().forEach(t=>a(e.edge(t)))}function a(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.nodes().forEach(t=>s(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(s),Object.hasOwn(n,`y`)&&s(n)})}function s(e){e.y=-e.y}function c(e){e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(l),Object.hasOwn(n,`x`)&&l(n)})}function l(e){let t=e.x;e.x=e.y,e.y=t}})),_L=o(((e,t)=>{var n=oL();t.exports=r;function r(e){let t={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=n.applyWithChunking(Math.max,i),o=n.range(a+1).map(()=>[]);function s(n){if(t[n])return;t[n]=!0;let r=e.node(n);o[r.rank].push(n),e.successors(n).forEach(s)}return r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(s),o}})),vL=o(((e,t)=>{var n=oL().zipObject;t.exports=r;function r(e,t){let n=0;for(let r=1;r<t.length;++r)n+=i(e,t[r-1],t[r]);return n}function i(e,t,r){let i=n(r,r.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:i[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),o=1;for(;o<r.length;)o<<=1;let s=2*o-1;--o;let c=Array(s).fill(0),l=0;return a.forEach(e=>{let t=e.pos+o;c[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n}),l}})),yL=o(((e,t)=>{t.exports=n;function n(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:t}})}})),bL=o(((e,t)=>{var n=oL();t.exports=r;function r(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(n[e.w]))}),i(Object.values(n).filter(e=>!e.indegree))}function i(e){let t=[];function r(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&a(e,t)}}function i(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let n=e.pop();t.push(n),n.in.reverse().forEach(r(n)),n.out.forEach(i(n))}return t.filter(e=>!e.merged).map(e=>n.pick(e,[`vs`,`i`,`barycenter`,`weight`]))}function a(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}})),xL=o(((e,t)=>{var n=oL();t.exports=r;function r(e,t){let r=n.partition(e,e=>Object.hasOwn(e,`barycenter`)),o=r.lhs,s=r.rhs.sort((e,t)=>t.i-e.i),c=[],l=0,u=0,d=0;o.sort(a(!!t)),d=i(c,s,d),o.forEach(e=>{d+=e.vs.length,c.push(e.vs),l+=e.barycenter*e.weight,u+=e.weight,d=i(c,s,d)});let f={vs:c.flat(!0)};return u&&(f.barycenter=l/u,f.weight=u),f}function i(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function a(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}})),SL=o(((e,t)=>{var n=yL(),r=bL(),i=xL();t.exports=a;function a(e,t,c,l){let u=e.children(t),d=e.node(t),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(e=>e!==f&&e!==p));let h=n(e,u);h.forEach(t=>{if(e.children(t.v).length){let n=a(e,t.v,c,l);m[t.v]=n,Object.hasOwn(n,`barycenter`)&&s(t,n)}});let g=r(h,c);o(g,m);let _=i(g,l);if(f&&(_.vs=[f,_.vs,p].flat(!0),e.predecessors(f).length)){let t=e.node(e.predecessors(f)[0]),n=e.node(e.predecessors(p)[0]);Object.hasOwn(_,`barycenter`)||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+t.order+n.order)/(_.weight+2),_.weight+=2}return _}function o(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function s(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}})),CL=o(((e,t)=>{var n=rL().Graph,r=oL();t.exports=i;function i(e,t,r){let i=a(e),o=new n({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return e.nodes().forEach(n=>{let a=e.node(n),s=e.parent(n);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(o.setNode(n),o.setParent(n,s||i),e[r](n).forEach(t=>{let r=t.v===n?t.w:t.v,i=o.edge(r,n),a=i===void 0?0:i.weight;o.setEdge(r,n,{weight:e.edge(t).weight+a})}),Object.hasOwn(a,`minRank`)&&o.setNode(n,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),o}function a(e){for(var t;e.hasNode(t=r.uniqueId(`_root`)););return t}})),wL=o(((e,t)=>{t.exports=n;function n(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}})),TL=o(((e,t)=>{var n=_L(),r=vL(),i=SL(),a=CL(),o=wL(),s=rL().Graph,c=oL();t.exports=l;function l(e,t){if(t&&typeof t.customOrder==`function`){t.customOrder(e,l);return}let i=c.maxRank(e),a=u(e,c.range(1,i+1),`inEdges`),o=u(e,c.range(i-1,-1,-1),`outEdges`),s=n(e);if(f(e,s),t&&t.disableOptimalOrderHeuristic)return;let p=1/0,m;for(let t=0,n=0;n<4;++t,++n){d(t%2?a:o,t%4>=2),s=c.buildLayerMatrix(e);let i=r(e,s);i<p&&(n=0,m=Object.assign({},s),p=i)}f(e,m)}function u(e,t,n){return t.map(function(t){return a(e,t,n)})}function d(e,t){let n=new s;e.forEach(function(e){let r=e.graph().root,a=i(e,r,n,t);a.vs.forEach((t,n)=>e.node(t).order=n),o(e,n,a.vs)})}function f(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}})),EL=o(((e,t)=>{var n=rL().Graph,r=oL();t.exports={positionX:h,findType1Conflicts:i,findType2Conflicts:a,addConflict:s,hasConflict:c,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:m};function i(e,t){let n={};function r(t,r){let i=0,a=0,c=t.length,l=r[r.length-1];return r.forEach((t,u)=>{let d=o(e,t),f=d?e.node(d).order:c;(d||t===l)&&(r.slice(a,u+1).forEach(t=>{e.predecessors(t).forEach(r=>{let a=e.node(r),o=a.order;(o<i||f<o)&&!(a.dummy&&e.node(t).dummy)&&s(n,r,t)})}),a=u+1,i=f)}),r}return t.length&&t.reduce(r),n}function a(e,t){let n={};function i(t,i,a,o,c){let l;r.range(i,a).forEach(r=>{l=t[r],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let r=e.node(t);r.dummy&&(r.order<o||r.order>c)&&s(n,t,l)})})}function a(t,n){let r=-1,a,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);t.length&&(a=e.node(t[0]).order,i(n,o,c,r,a),o=c,r=a)}i(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(a),n}function o(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}function s(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function c(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function l(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s.length){s=s.sort((e,t)=>o[e]-o[t]);let r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){let r=s[l];a[e]===e&&t<o[r]&&!c(n,e,r)&&(a[r]=e,a[e]=i[e]=i[r],t=o[r])}}})}),{root:i,align:a}}function u(e,t,n,r,i){let a={},o=d(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes(),r=n.pop(),i={};for(;r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function l(e){a[e]=o.inEdges(e).reduce((e,t)=>Math.max(e,a[t.v]+o.edge(t)),0)}function u(t){let n=o.outEdges(t).reduce((e,t)=>Math.min(e,a[t.w]-o.edge(t)),1/0),r=e.node(t);n!==1/0&&r.borderType!==s&&(a[t]=Math.max(a[t],n))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),Object.keys(r).forEach(e=>a[e]=a[n[e]]),a}function d(e,t,r,i){let a=new n,o=e.graph(),s=g(o.nodesep,o.edgesep,i);return t.forEach(t=>{let n;t.forEach(t=>{let i=r[t];if(a.setNode(i),n){var o=r[n],c=a.edge(o,i);a.setEdge(o,i,Math.max(s(e,t,n),c||0))}n=t})}),a}function f(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=_(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function p(e,t){let n=Object.values(t),i=r.applyWithChunking(Math.min,n),a=r.applyWithChunking(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(o=>{let s=n+o,c=e[s];if(c===t)return;let l=Object.values(c),u=i-r.applyWithChunking(Math.min,l);o!==`l`&&(u=a-r.applyWithChunking(Math.max,l)),u&&(e[s]=r.mapValues(c,e=>e+u))})})}function m(e,t){return r.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map(e=>e[r]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}function h(e){let t=r.buildLayerMatrix(e),n=Object.assign(i(e,t),a(e,t)),o={},s;return[`u`,`d`].forEach(i=>{s=i===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(s=s.map(e=>Object.values(e).reverse()));let a=(i===`u`?e.predecessors:e.successors).bind(e),c=l(e,s,n,a),d=u(e,s,c.root,c.align,t===`r`);t===`r`&&(d=r.mapValues(d,e=>-e)),o[i+t]=d})}),p(o,f(e,o)),m(o,e.graph().align)}function g(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function _(e,t){return e.node(t).width}})),DL=o(((e,t)=>{var n=oL(),r=EL().positionX;t.exports=i;function i(e){e=n.asNonCompoundGraph(e),a(e),Object.entries(r(e)).forEach(([t,n])=>e.node(t).x=n)}function a(e){let t=n.buildLayerMatrix(e),r=e.graph().ranksep,i=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height;return t>r?t:r},0);t.forEach(t=>e.node(t).y=i+n/2),i+=n+r})}})),OL=o(((e,t)=>{var n=sL(),r=cL(),i=fL(),a=oL().normalizeRanks,o=pL(),s=oL().removeEmptyRanks,c=mL(),l=hL(),u=gL(),d=TL(),f=DL(),p=oL(),m=rL().Graph;t.exports=h;function h(e,t){let n=t&&t.debugTiming?p.time:p.notime;n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>E(e));n(` runLayout`,()=>g(r,n,t)),n(` updateInputGraph`,()=>_(e,r))})}function g(e,t,m){t(` makeSpaceForEdgeLabels`,()=>D(e)),t(` removeSelfEdges`,()=>I(e)),t(` acyclic`,()=>n.run(e)),t(` nestingGraph.run`,()=>c.run(e)),t(` rank`,()=>i(p.asNonCompoundGraph(e))),t(` injectEdgeLabelProxies`,()=>O(e)),t(` removeEmptyRanks`,()=>s(e)),t(` nestingGraph.cleanup`,()=>c.cleanup(e)),t(` normalizeRanks`,()=>a(e)),t(` assignRankMinMax`,()=>k(e)),t(` removeEdgeLabelProxies`,()=>A(e)),t(` normalize.run`,()=>r.run(e)),t(` parentDummyChains`,()=>o(e)),t(` addBorderSegments`,()=>l(e)),t(` order`,()=>d(e,m)),t(` insertSelfEdges`,()=>L(e)),t(` adjustCoordinateSystem`,()=>u.adjust(e)),t(` position`,()=>f(e)),t(` positionSelfEdges`,()=>ee(e)),t(` removeBorderNodes`,()=>F(e)),t(` normalize.undo`,()=>r.undo(e)),t(` fixupEdgeLabelCoords`,()=>N(e)),t(` undoCoordinateSystem`,()=>u.undo(e)),t(` translateGraph`,()=>j(e)),t(` assignNodeIntersects`,()=>M(e)),t(` reversePoints`,()=>P(e)),t(` acyclic.undo`,()=>n.undo(e))}function _(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var v=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],y={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},b=[`acyclicer`,`ranker`,`rankdir`,`align`],x=[`width`,`height`,`rank`],S={width:0,height:0},C=[`minlen`,`weight`,`width`,`height`,`labeloffset`],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},T=[`labelpos`];function E(e){let t=new m({multigraph:!0,compound:!0}),n=ne(e.graph());return t.setGraph(Object.assign({},y,te(n,v),p.pick(n,b))),e.nodes().forEach(n=>{let r=te(ne(e.node(n)),x);Object.keys(S).forEach(e=>{r[e]===void 0&&(r[e]=S[e])}),t.setNode(n,r),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let r=ne(e.edge(n));t.setEdge(n,Object.assign({},w,te(r,C),p.pick(r,T)))}),t}function D(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function O(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};p.addDummyNode(e,`edge-proxy`,r,`_ep`)}})}function k(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function A(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function j(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function M(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(p.intersectRect(r,a)),n.points.push(p.intersectRect(i,o))})}function N(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function P(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function F(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function I(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function L(e){p.buildLayerMatrix(e).forEach(t=>{var n=0;t.forEach((t,r)=>{var i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{p.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function ee(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function te(e,t){return p.mapValues(p.pick(e,t),Number)}function ne(e){var t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}})),kL=o(((e,t)=>{var n=oL(),r=rL().Graph;t.exports={debugOrdering:i};function i(e){let t=n.buildLayerMatrix(e),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{i.setNode(t,{label:t}),i.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>i.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let n=`layer`+t;i.setNode(n,{rank:`same`}),e.reduce((e,t)=>(i.setEdge(e,t,{style:`invis`}),t))}),i}})),AL=o(((e,t)=>{t.exports=`1.1.5`})),jL=l(o(((e,t)=>{t.exports={graphlib:rL(),layout:OL(),debug:kL(),util:{time:oL().time,notime:oL().notime},version:AL()}}))(),1),ML=[`pending`,`ready`,`running`,`waiting`,`blocked`,`skipped`,`done`,`not-completed`,`failed`,`parked`,`cancelled`,`complete-but-draft`,`complete-but-held`,`unknown`],NL=200,PL=72,FL=80,IL=32,LL=20,RL=e=>PL+Math.max(0,Math.floor(e.lines??0))*LL,zL=new Set(ML),BL={pending:`neutral`,ready:`neutral`,running:`active`,waiting:`blocked`,blocked:`blocked`,skipped:`blocked`,done:`success`,"not-completed":`danger`,failed:`danger`,parked:`muted`,cancelled:`muted`,"complete-but-draft":`blocked`,"complete-but-held":`blocked`,unknown:`neutral`},VL=(e,t)=>e<t?-1:+(e>t);function HL(e){let t=[...e.nodes].sort((e,t)=>VL(e.id,t.id)),n=[...e.edges].sort((e,t)=>VL(e.id,t.id)),r=new Map(t.map(e=>[e.id,e]));if(r.size!==t.length)throw Error(`DAG node IDs must be unique`);for(let e of t)if(!zL.has(e.state))throw Error(`DAG node ${e.id} has unsupported state ${e.state}`);let i=new Map(t.map(e=>[e.id,0])),a=new Map(t.map(e=>[e.id,[]])),o=new Set;for(let e of n){if(o.has(e.id))throw Error(`DAG edge IDs must be unique`);if(o.add(e.id),!r.has(e.source)||!r.has(e.target))throw Error(`DAG edge ${e.id} has a missing endpoint`);if(e.source===e.target)throw Error(`DAG edge ${e.id} is a self-edge`);i.set(e.target,(i.get(e.target)??0)+1),a.get(e.source)?.push(e.target)}let s=new Map,c=t.filter(e=>i.get(e.id)===0).map(e=>e.id),l=0;for(;c.length>0;){let e=c;c=[];for(let t of e){l+=1;let e=s.get(t)??0;for(let n of a.get(t)??[]){s.set(n,Math.max(s.get(n)??0,e+1));let t=(i.get(n)??0)-1;i.set(n,t),t===0&&c.push(n)}}c.sort()}if(l!==t.length)throw Error(`DAG contains a cycle`);let u=new jL.default.graphlib.Graph({multigraph:!0});u.setGraph({rankdir:`LR`,ranksep:FL,nodesep:IL,marginx:0,marginy:0}),u.setDefaultEdgeLabel(()=>({}));for(let e of t)u.setNode(e.id,{width:NL,height:RL(e)});for(let e of n)u.setEdge(e.source,e.target,{},e.id);jL.default.layout(u);let d=new Map;for(let e of t){let t=s.get(e.id)??0,n=d.get(t)??[];n.push(e.id),d.set(t,n)}for(let e of d.values())e.sort((e,t)=>(u.node(e)?.y??0)-(u.node(t)?.y??0)||VL(e,t));let f=new Map;for(let e of d.values()){let t=0;for(let n of e){f.set(n,t);let e=r.get(n);t+=(e===void 0?PL:RL(e))+IL}}let p=t.map(e=>{let t=s.get(e.id)??0;return{...e,x:t*280,y:f.get(e.id)??0,width:NL,height:RL(e),style:BL[e.state]}}),m=new Map(p.map(e=>[e.id,e])),h=n.map(e=>{let t=m.get(e.source),n=m.get(e.target);if(!t||!n)throw Error(`DAG layout lost an edge endpoint`);let r={x:t.x+t.width,y:t.y+t.height/2},i={x:n.x,y:n.y+n.height/2},a=Math.round((r.x+i.x)/2);return{...e,points:[r,{x:a,y:r.y},{x:a,y:i.y},i]}});return{width:p.length===0?0:Math.max(...p.map(e=>e.x+e.width)),height:p.length===0?0:Math.max(...p.map(e=>e.y+e.height)),nodes:p,edges:h}}function UL(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=UL(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var WL={value:()=>{}};function GL(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new KL(n)}function KL(e){this._=e}function qL(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}KL.prototype=GL.prototype={constructor:KL,on:function(e,t){var n=this._,r=qL(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=JL(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=YL(n[i],e.name,t);else if(t==null)for(i in n)n[i]=YL(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new KL(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function JL(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function YL(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=WL,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var XL={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function ZL(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),XL.hasOwnProperty(t)?{space:XL[t],local:e}:e}function QL(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function $L(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function eR(e){var t=ZL(e);return(t.local?$L:QL)(t)}function tR(){}function nR(e){return e==null?tR:function(){return this.querySelector(e)}}function rR(e){typeof e!=`function`&&(e=nR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Gz(r,this._parents)}function iR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function aR(){return[]}function oR(e){return e==null?aR:function(){return this.querySelectorAll(e)}}function sR(e){return function(){return iR(e.apply(this,arguments))}}function cR(e){e=typeof e==`function`?sR(e):oR(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Gz(r,i)}function lR(e){return function(){return this.matches(e)}}function uR(e){return function(t){return t.matches(e)}}var dR=Array.prototype.find;function fR(e){return function(){return dR.call(this.children,e)}}function pR(){return this.firstElementChild}function mR(e){return this.select(e==null?pR:fR(typeof e==`function`?e:uR(e)))}var hR=Array.prototype.filter;function gR(){return Array.from(this.children)}function _R(e){return function(){return hR.call(this.children,e)}}function vR(e){return this.selectAll(e==null?gR:_R(typeof e==`function`?e:uR(e)))}function yR(e){typeof e!=`function`&&(e=lR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Gz(r,this._parents)}function bR(e){return Array(e.length)}function xR(){return new Gz(this._enter||this._groups.map(bR),this._parents)}function SR(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}SR.prototype={constructor:SR,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function CR(e){return function(){return e}}function wR(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new SR(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function TR(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new SR(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function ER(e){return e.__data__}function DR(e,t){if(!arguments.length)return Array.from(this,ER);var n=t?TR:wR,r=this._parents,i=this._groups;typeof e!=`function`&&(e=CR(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=OR(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Gz(o,r),o._enter=s,o._exit=c,o}function OR(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function kR(){return new Gz(this._exit||this._groups.map(bR),this._parents)}function AR(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function jR(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Gz(s,this._parents)}function MR(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],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 NR(e){e||=PR;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Gz(i,this._parents).order()}function PR(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function FR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function IR(){return Array.from(this)}function LR(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function RR(){let e=0;for(let t of this)++e;return e}function zR(){return!this.node()}function BR(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function VR(e){return function(){this.removeAttribute(e)}}function HR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function UR(e,t){return function(){this.setAttribute(e,t)}}function WR(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function GR(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function KR(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function qR(e,t){var n=ZL(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?HR:VR:typeof t==`function`?n.local?KR:GR:n.local?WR:UR)(n,t))}function JR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function YR(e){return function(){this.style.removeProperty(e)}}function XR(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ZR(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function QR(e,t,n){return arguments.length>1?this.each((t==null?YR:typeof t==`function`?ZR:XR)(e,t,n??``)):$R(this.node(),e)}function $R(e,t){return e.style.getPropertyValue(t)||JR(e).getComputedStyle(e,null).getPropertyValue(t)}function ez(e){return function(){delete this[e]}}function tz(e,t){return function(){this[e]=t}}function nz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function rz(e,t){return arguments.length>1?this.each((t==null?ez:typeof t==`function`?nz:tz)(e,t)):this.node()[e]}function iz(e){return e.trim().split(/^|\s+/)}function az(e){return e.classList||new oz(e)}function oz(e){this._node=e,this._names=iz(e.getAttribute(`class`)||``)}oz.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function sz(e,t){for(var n=az(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function cz(e,t){for(var n=az(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function lz(e){return function(){sz(this,e)}}function uz(e){return function(){cz(this,e)}}function dz(e,t){return function(){(t.apply(this,arguments)?sz:cz)(this,e)}}function fz(e,t){var n=iz(e+``);if(arguments.length<2){for(var r=az(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?dz:t?lz:uz)(n,t))}function pz(){this.textContent=``}function mz(e){return function(){this.textContent=e}}function hz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function gz(e){return arguments.length?this.each(e==null?pz:(typeof e==`function`?hz:mz)(e)):this.node().textContent}function _z(){this.innerHTML=``}function vz(e){return function(){this.innerHTML=e}}function yz(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function bz(e){return arguments.length?this.each(e==null?_z:(typeof e==`function`?yz:vz)(e)):this.node().innerHTML}function xz(){this.nextSibling&&this.parentNode.appendChild(this)}function Sz(){return this.each(xz)}function Cz(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wz(){return this.each(Cz)}function Tz(e){var t=typeof e==`function`?e:eR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ez(){return null}function Dz(e,t){var n=typeof e==`function`?e:eR(e),r=t==null?Ez:typeof t==`function`?t:nR(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Oz(){var e=this.parentNode;e&&e.removeChild(this)}function kz(){return this.each(Oz)}function Az(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jz(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mz(e){return this.select(e?jz:Az)}function Nz(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Pz(e){return function(t){e.call(this,t,this.__data__)}}function Fz(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Iz(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Lz(e,t,n){return function(){var r=this.__on,i,a=Pz(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Rz(e,t,n){var r=Fz(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Lz:Iz,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function zz(e,t,n){var r=JR(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Bz(e,t){return function(){return zz(this,e,t)}}function Vz(e,t){return function(){return zz(this,e,t.apply(this,arguments))}}function Hz(e,t){return this.each((typeof t==`function`?Vz:Bz)(e,t))}function*Uz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Wz=[null];function Gz(e,t){this._groups=e,this._parents=t}function Kz(){return new Gz([[document.documentElement]],Wz)}function qz(){return this}Gz.prototype=Kz.prototype={constructor:Gz,select:rR,selectAll:cR,selectChild:mR,selectChildren:vR,filter:yR,data:DR,enter:xR,exit:kR,join:AR,merge:jR,selection:qz,order:MR,sort:NR,call:FR,nodes:IR,node:LR,size:RR,empty:zR,each:BR,attr:qR,style:QR,property:rz,classed:fz,text:gz,html:bz,raise:Sz,lower:wz,append:Tz,insert:Dz,remove:kz,clone:Mz,datum:Nz,on:Rz,dispatch:Hz,[Symbol.iterator]:Uz};function Jz(e){return typeof e==`string`?new Gz([[document.querySelector(e)]],[document.documentElement]):new Gz([[e]],Wz)}function Yz(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xz(e,t){if(e=Yz(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Zz={passive:!1},Qz={capture:!0,passive:!1};function $z(e){e.stopImmediatePropagation()}function eB(e){e.preventDefault(),e.stopImmediatePropagation()}function tB(e){var t=e.document.documentElement,n=Jz(e).on(`dragstart.drag`,eB,Qz);`onselectstart`in t?n.on(`selectstart.drag`,eB,Qz):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function nB(e,t){var n=e.document.documentElement,r=Jz(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,eB,Qz),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var rB=e=>()=>e;function iB(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,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:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}iB.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function aB(e){return!e.ctrlKey&&!e.button}function oB(){return this.parentNode}function sB(e,t){return t??{x:e.x,y:e.y}}function cB(){return navigator.maxTouchPoints||`ontouchstart`in this}function lB(){var e=aB,t=oB,n=sB,r=cB,i={},a=GL(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Zz).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Jz(n.view).on(`mousemove.drag`,m,Qz).on(`mouseup.drag`,h,Qz),tB(n.view),$z(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(eB(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Jz(e.view).on(`mousemove.drag mouseup.drag`,null),nB(e.view,l),eB(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&($z(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(eB(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&($z(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Xz(l||r,t),p,m,h;if((h=n.call(e,new iB(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Xz(l||a,t),_=o;break}u.call(r,e,new iB(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:rB(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:rB(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:rB(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:rB(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function uB(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function dB(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function fB(){}var pB=.7,mB=1/pB,hB=`\\s*([+-]?\\d+)\\s*`,gB=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,_B=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,vB=/^#([0-9a-f]{3,8})$/,yB=RegExp(`^rgb\\(${hB},${hB},${hB}\\)$`),bB=RegExp(`^rgb\\(${_B},${_B},${_B}\\)$`),xB=RegExp(`^rgba\\(${hB},${hB},${hB},${gB}\\)$`),SB=RegExp(`^rgba\\(${_B},${_B},${_B},${gB}\\)$`),CB=RegExp(`^hsl\\(${gB},${_B},${_B}\\)$`),wB=RegExp(`^hsla\\(${gB},${_B},${_B},${gB}\\)$`),TB={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};uB(fB,AB,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:EB,formatHex:EB,formatHex8:DB,formatHsl:OB,formatRgb:kB,toString:kB});function EB(){return this.rgb().formatHex()}function DB(){return this.rgb().formatHex8()}function OB(){return UB(this).formatHsl()}function kB(){return this.rgb().formatRgb()}function AB(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=vB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jB(t):n===3?new FB(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?MB(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?MB(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=yB.exec(e))?new FB(t[1],t[2],t[3],1):(t=bB.exec(e))?new FB(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=xB.exec(e))?MB(t[1],t[2],t[3],t[4]):(t=SB.exec(e))?MB(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=CB.exec(e))?HB(t[1],t[2]/100,t[3]/100,1):(t=wB.exec(e))?HB(t[1],t[2]/100,t[3]/100,t[4]):TB.hasOwnProperty(e)?jB(TB[e]):e===`transparent`?new FB(NaN,NaN,NaN,0):null}function jB(e){return new FB(e>>16&255,e>>8&255,e&255,1)}function MB(e,t,n,r){return r<=0&&(e=t=n=NaN),new FB(e,t,n,r)}function NB(e){return e instanceof fB||(e=AB(e)),e?(e=e.rgb(),new FB(e.r,e.g,e.b,e.opacity)):new FB}function PB(e,t,n,r){return arguments.length===1?NB(e):new FB(e,t,n,r??1)}function FB(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}uB(FB,PB,dB(fB,{brighter(e){return e=e==null?mB:mB**+e,new FB(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?pB:pB**+e,new FB(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new FB(BB(this.r),BB(this.g),BB(this.b),zB(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:IB,formatHex:IB,formatHex8:LB,formatRgb:RB,toString:RB}));function IB(){return`#${VB(this.r)}${VB(this.g)}${VB(this.b)}`}function LB(){return`#${VB(this.r)}${VB(this.g)}${VB(this.b)}${VB((isNaN(this.opacity)?1:this.opacity)*255)}`}function RB(){let e=zB(this.opacity);return`${e===1?`rgb(`:`rgba(`}${BB(this.r)}, ${BB(this.g)}, ${BB(this.b)}${e===1?`)`:`, ${e})`}`}function zB(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function BB(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function VB(e){return e=BB(e),(e<16?`0`:``)+e.toString(16)}function HB(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new GB(e,t,n,r)}function UB(e){if(e instanceof GB)return new GB(e.h,e.s,e.l,e.opacity);if(e instanceof fB||(e=AB(e)),!e)return new GB;if(e instanceof GB)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new GB(o,s,c,e.opacity)}function WB(e,t,n,r){return arguments.length===1?UB(e):new GB(e,t,n,r??1)}function GB(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}uB(GB,WB,dB(fB,{brighter(e){return e=e==null?mB:mB**+e,new GB(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?pB:pB**+e,new GB(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new FB(JB(e>=240?e-240:e+120,i,r),JB(e,i,r),JB(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new GB(KB(this.h),qB(this.s),qB(this.l),zB(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=zB(this.opacity);return`${e===1?`hsl(`:`hsla(`}${KB(this.h)}, ${qB(this.s)*100}%, ${qB(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function KB(e){return e=(e||0)%360,e<0?e+360:e}function qB(e){return Math.max(0,Math.min(1,e||0))}function JB(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var YB=e=>()=>e;function XB(e,t){return function(n){return e+n*t}}function ZB(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function QB(e){return(e=+e)==1?$B:function(t,n){return n-t?ZB(t,n,e):YB(isNaN(t)?n:t)}}function $B(e,t){var n=t-e;return n?XB(e,n):YB(isNaN(e)?t:e)}var eV=(function e(t){var n=QB(t);function r(e,t){var r=n((e=PB(e)).r,(t=PB(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$B(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function tV(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function nV(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rV(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=fV(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function iV(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function aV(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function oV(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=fV(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var sV=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cV=new RegExp(sV.source,`g`);function lV(e){return function(){return e}}function uV(e){return function(t){return e(t)+``}}function dV(e,t){var n=sV.lastIndex=cV.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=sV.exec(e))&&(i=cV.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:aV(r,i)})),n=cV.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?uV(c[0].x):lV(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function fV(e,t){var n=typeof t,r;return t==null||n===`boolean`?YB(t):(n===`number`?aV:n===`string`?(r=AB(t))?(t=r,eV):dV:t instanceof AB?eV:t instanceof Date?iV:nV(t)?tV:Array.isArray(t)?rV:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?oV:aV)(e,t)}var pV=180/Math.PI,mV={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function hV(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*pV,skewX:Math.atan(c)*pV,scaleX:o,scaleY:s}}var gV;function _V(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?mV:hV(t.a,t.b,t.c,t.d,t.e,t.f)}function vV(e){return e==null||(gV||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),gV.setAttribute(`transform`,e),!(e=gV.transform.baseVal.consolidate()))?mV:(e=e.matrix,hV(e.a,e.b,e.c,e.d,e.e,e.f))}function yV(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:aV(e,i)},{i:c-2,x:aV(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:aV(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:aV(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:aV(e,n)},{i:s-2,x:aV(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var bV=yV(_V,`px, `,`px)`,`deg)`),xV=yV(vV,`, `,`)`,`)`),SV=1e-12;function CV(e){return((e=Math.exp(e))+1/e)/2}function wV(e){return((e=Math.exp(e))-1/e)/2}function TV(e){return((e=Math.exp(2*e))-1)/(e+1)}var EV=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<SV)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=CV(y),c=s/(n*g)*(i*TV(t*r+y)-wV(y));return[a+c*d,o+c*f,s*i/CV(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),DV=0,OV=0,kV=0,AV=1e3,jV,MV,NV=0,PV=0,FV=0,IV=typeof performance==`object`&&performance.now?performance:Date,LV=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function RV(){return PV||=(LV(zV),IV.now()+FV)}function zV(){PV=0}function BV(){this._call=this._time=this._next=null}BV.prototype=VV.prototype={constructor:BV,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?RV():+n)+(t==null?0:+t),!this._next&&MV!==this&&(MV?MV._next=this:jV=this,MV=this),this._call=e,this._time=n,KV()},stop:function(){this._call&&(this._call=null,this._time=1/0,KV())}};function VV(e,t,n){var r=new BV;return r.restart(e,t,n),r}function HV(){RV(),++DV;for(var e=jV,t;e;)(t=PV-e._time)>=0&&e._call.call(void 0,t),e=e._next;--DV}function UV(){PV=(NV=IV.now())+FV,DV=OV=0;try{HV()}finally{DV=0,GV(),PV=0}}function WV(){var e=IV.now(),t=e-NV;t>AV&&(FV-=t,NV=e)}function GV(){for(var e,t=jV,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:jV=n);MV=e,KV(r)}function KV(e){DV||(OV&&=clearTimeout(OV),e-PV>24?(e<1/0&&(OV=setTimeout(UV,e-IV.now()-FV)),kV&&=clearInterval(kV)):(kV||=(NV=IV.now(),setInterval(WV,AV)),DV=1,LV(UV)))}function qV(e,t,n){var r=new BV;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var JV=GL(`start`,`end`,`cancel`,`interrupt`),YV=[];function XV(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;eH(e,n,{name:t,index:r,group:i,on:JV,tween:YV,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ZV(e,t){var n=$V(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function QV(e,t){var n=$V(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function $V(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function eH(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=VV(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return qV(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(qV(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function tH(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nH(e){return this.each(function(){tH(this,e)})}function rH(e,t){var n,r;return function(){var i=QV(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function iH(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=QV(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function aH(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=$V(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rH:iH)(n,e,t))}function oH(e,t,n){var r=e._id;return e.each(function(){var e=QV(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return $V(e,r).value[t]}}function sH(e,t){var n;return(typeof t==`number`?aV:t instanceof AB?eV:(n=AB(t))?(t=n,eV):dV)(e,t)}function cH(e){return function(){this.removeAttribute(e)}}function lH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uH(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function dH(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function fH(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pH(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mH(e,t){var n=ZL(e),r=n===`transform`?xV:sH;return this.attrTween(e,typeof t==`function`?(n.local?pH:fH)(n,r,oH(this,`attr.`+e,t)):t==null?(n.local?lH:cH)(n):(n.local?dH:uH)(n,r,t))}function hH(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gH(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _H(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&gH(e,i)),n}return i._value=t,i}function vH(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hH(e,i)),n}return i._value=t,i}function yH(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=ZL(e);return this.tween(n,(r.local?_H:vH)(r,t))}function bH(e,t){return function(){ZV(this,e).delay=+t.apply(this,arguments)}}function xH(e,t){return t=+t,function(){ZV(this,e).delay=t}}function SH(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?bH:xH)(t,e)):$V(this.node(),t).delay}function CH(e,t){return function(){QV(this,e).duration=+t.apply(this,arguments)}}function wH(e,t){return t=+t,function(){QV(this,e).duration=t}}function TH(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?CH:wH)(t,e)):$V(this.node(),t).duration}function EH(e,t){if(typeof t!=`function`)throw Error();return function(){QV(this,e).ease=t}}function DH(e){var t=this._id;return arguments.length?this.each(EH(t,e)):$V(this.node(),t).ease}function OH(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();QV(this,e).ease=n}}function kH(e){if(typeof e!=`function`)throw Error();return this.each(OH(this._id,e))}function AH(e){typeof e!=`function`&&(e=lR(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new aU(r,this._parents,this._name,this._id)}function jH(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new aU(o,this._parents,this._name,this._id)}function MH(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function NH(e,t,n){var r,i,a=MH(t)?ZV:QV;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function PH(e,t){var n=this._id;return arguments.length<2?$V(this.node(),n).on.on(e):this.each(NH(n,e,t))}function FH(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function IH(){return this.on(`end.remove`,FH(this._id))}function LH(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=nR(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,XV(l[f],t,n,f,l,$V(u,n)));return new aU(a,this._parents,t,n)}function RH(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=oR(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=$V(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&XV(p,t,n,h,f,m);a.push(f),o.push(u)}return new aU(a,o,t,n)}var zH=Kz.prototype.constructor;function BH(){return new zH(this._groups,this._parents)}function VH(e,t){var n,r,i;return function(){var a=$R(this,e),o=(this.style.removeProperty(e),$R(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function HH(e){return function(){this.style.removeProperty(e)}}function UH(e,t,n){var r,i=n+``,a;return function(){var o=$R(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function WH(e,t,n){var r,i,a;return function(){var o=$R(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),$R(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function GH(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=QV(this,e),l=c.on,u=c.value[a]==null?s||=HH(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function KH(e,t,n){var r=(e+=``)==`transform`?bV:sH;return t==null?this.styleTween(e,VH(e,r)).on(`end.style.`+e,HH(e)):typeof t==`function`?this.styleTween(e,WH(e,r,oH(this,`style.`+e,t))).each(GH(this._id,e)):this.styleTween(e,UH(e,r,t),n).on(`end.style.`+e,null)}function qH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function JH(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&qH(e,a,n)),r}return a._value=t,a}function YH(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,JH(e,t,n??``))}function XH(e){return function(){this.textContent=e}}function ZH(e){return function(){var t=e(this);this.textContent=t??``}}function QH(e){return this.tween(`text`,typeof e==`function`?ZH(oH(this,`text`,e)):XH(e==null?``:e+``))}function $H(e){return function(t){this.textContent=e.call(this,t)}}function eU(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$H(r)),t}return r._value=e,r}function tU(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,eU(e))}function nU(){for(var e=this._name,t=this._id,n=sU(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=$V(c,t);XV(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new aU(r,this._parents,e,n)}function rU(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=QV(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var iU=0;function aU(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function oU(e){return Kz().transition(e)}function sU(){return++iU}var cU=Kz.prototype;aU.prototype=oU.prototype={constructor:aU,select:LH,selectAll:RH,selectChild:cU.selectChild,selectChildren:cU.selectChildren,filter:AH,merge:jH,selection:BH,transition:nU,call:cU.call,nodes:cU.nodes,node:cU.node,size:cU.size,empty:cU.empty,each:cU.each,on:PH,attr:mH,attrTween:yH,style:KH,styleTween:YH,text:QH,textTween:tU,remove:IH,tween:aH,delay:SH,duration:TH,ease:DH,easeVarying:kH,end:rU,[Symbol.iterator]:cU[Symbol.iterator]};function lU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var uU={time:null,delay:0,duration:250,ease:lU};function dU(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function fU(e){var t,n;e instanceof aU?(t=e._id,e=e._name):(t=sU(),(n=uU).time=RV(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&XV(c,e,t,l,o,n||dU(c,t));return new aU(r,this._parents,e,t)}Kz.prototype.interrupt=nH,Kz.prototype.transition=fU;var pU=e=>()=>e;function mU(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function hU(e,t,n){this.k=e,this.x=t,this.y=n}hU.prototype={constructor:hU,scale:function(e){return e===1?this:new hU(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new hU(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var gU=new hU(1,0,0);_U.prototype=hU.prototype;function _U(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gU;return e.__zoom}function vU(e){e.stopImmediatePropagation()}function yU(e){e.preventDefault(),e.stopImmediatePropagation()}function bU(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function xU(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function SU(){return this.__zoom||gU}function CU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wU(){return navigator.maxTouchPoints||`ontouchstart`in this}function TU(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.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 EU(){var e=bU,t=xU,n=TU,r=CU,i=wU,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=EV,l=GL(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,SU).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,SU),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(gU.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new hU(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new hU(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new hU(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Jz(this.that).datum();l.call(e,this.that,new mU(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Xz(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],tH(this),s.start();yU(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Jz(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Xz(t,i),l=t.clientX,u=t.clientY;tB(t.view),vU(t),a.mouse=[c,this.__zoom.invert(c)],tH(this),a.start();function d(e){if(yU(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Xz(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),nB(e.view,a.moved),yU(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Xz(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);yU(r),s>0?Jz(this).transition().duration(s).call(x,d,c,r):Jz(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(vU(t),s=0;s<i;++s)c=r[s],l=Xz(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),tH(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(yU(e),s=0;s<a;++s)c=i[s],l=Xz(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(vU(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.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&&(o=Xz(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Jz(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:pU(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:pU(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:pU(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:pU([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var DU={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.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:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The 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:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/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.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},OU=[[-1/0,-1/0],[1/0,1/0]],kU=[`Enter`,` `,`Escape`],AU={"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:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, 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`},jU;(function(e){e.Strict=`strict`,e.Loose=`loose`})(jU||={});var MU;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(MU||={});var NU;(function(e){e.Partial=`partial`,e.Full=`full`})(NU||={});var PU={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},FU;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(FU||={});var IU;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(IU||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var LU={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function RU(e){return e===null?null:e?`valid`:`invalid`}var zU=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,BU=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),VU=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),HU=(e,t=[0,0])=>{let{width:n,height:r}=SW(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},UU=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:iW(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):VU(n)?n:t.nodeLookup.get(n.id)),nW(e,i?oW(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),WU=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=nW(n,oW(e)),r=!0)}),r?iW(n):{x:0,y:0,width:0,height:0}},GU=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=cW(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},KU=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function qU(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=SW(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function JU({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=yW(WU(qU(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function YU({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,DU.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&xW(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=xW(d)?QU(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,DU.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function XU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=KU(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ZU=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),QU=(e={x:0,y:0},t,n)=>({x:ZU(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ZU(e.y,t[0][1],t[1][1]-(n?.height??0))});function $U(e,t,n){let{width:r,height:i}=SW(n),{x:a,y:o}=n.internals.positionAbsolute;return QU(e,[[a,o],[a+r,o+i]],t)}var eW=(e,t,n)=>e<t?ZU(Math.abs(e-t),1,t)/t:e>n?-ZU(Math.abs(e-n),1,t)/t:0,tW=(e,t,n=15,r=40)=>[eW(e.x,r,t.width-r)*n,eW(e.y,r,t.height-r)*n],nW=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),rW=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),iW=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),aW=(e,t=[0,0])=>{let{x:n,y:r}=VU(e)?e.internals.positionAbsolute:HU(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},oW=(e,t=[0,0])=>{let{x:n,y:r}=VU(e)?e.internals.positionAbsolute:HU(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},sW=(e,t)=>iW(nW(rW(e),rW(t))),cW=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},lW=(e,t)=>cW(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),uW=e=>dW(e.width)&&dW(e.height)&&dW(e.x)&&dW(e.y),dW=e=>!isNaN(e)&&isFinite(e),fW=(e,t)=>(e,t)=>{},pW=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),mW=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?pW(s,o):s},hW=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function gW(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function _W(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=gW(e,n),i=gW(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=gW(e.top??e.y??0,n),i=gW(e.bottom??e.y??0,n),a=gW(e.left??e.x??0,t),o=gW(e.right??e.x??0,t);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 vW(e,t,n,r,i,a){let{x:o,y:s}=hW(e,[t,n,r]),{x:c,y:l}=hW({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var yW=(e,t,n,r,i,a)=>{let o=_W(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ZU(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=vW(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},bW=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function xW(e){return e!=null&&e!==`parent`}function SW(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function CW(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function wW(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function TW(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function EW(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function DW(e){return{...AU,...e||{}}}function OW(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=PW(e),s=mW({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?pW(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var kW=e=>({width:e.offsetWidth,height:e.offsetHeight}),AW=e=>e?.getRootNode?.()||window?.document,jW=[`INPUT`,`SELECT`,`TEXTAREA`];function MW(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?jW.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var NW=e=>`clientX`in e,PW=(e,t)=>{let n=NW(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},FW=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...kW(t)}})};function IW({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function LW(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function RW({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-LW(t-r,a),n];case $.Right:return[t+LW(r-t,a),n];case $.Top:return[t,n-LW(n-i,a)];case $.Bottom:return[t,n+LW(i-n,a)]}}function zW({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=RW({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=RW({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=IW({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function BW({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function VW({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function HW({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=nW(oW(e),oW(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),lW({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},iW(a))>0}var UW=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,WW=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),GW=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,DU.error006()),t;let r=n.getEdgeId||UW,i;return i=zU(e)?{...e}:{...e,id:r(e)},WW(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function KW({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=BW({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var qW={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},JW=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},YW=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function XW({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=qW[t],c=qW[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=JW({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=BW({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function ZW(e,t,n,r){let i=Math.min(YW(e,t)/2,YW(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function QW({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=XW({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=ZW(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function $W(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function eG(e){let{sourceNode:t,targetNode:n}=e;if(!$W(t)||!$W(n))return null;let r=t.internals.handleBounds||tG(t.handles),i=n.internals.handleBounds||tG(n.handles),a=rG(r?.source??[],e.sourceHandle),o=rG(e.connectionMode===jU.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,DU.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=nG(t,a,s),u=nG(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function tG(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function nG(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??SW(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function rG(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function iG(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function aG(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=iG(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var oG=1e3,sG=10,cG={nodeOrigin:[0,0],nodeExtent:OU,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},lG={...cG,checkEquality:!0};function uG(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function dG(e,t,n){let r=uG(cG,n);for(let n of e.values())if(n.parentId)gG(n,e,t,r);else{let e=QU(HU(n,r.nodeOrigin),xW(n.extent)?n.extent:r.nodeExtent,SW(n));n.internals.positionAbsolute=e}}function fG(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function pG(e){return e===`manual`}function mG(e,t,n,r={}){let i=uG(lG,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!pG(i.zIndexMode)?oG:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=QU(HU(u,i.nodeOrigin),xW(u.extent)?u.extent:i.nodeExtent,SW(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:fG(u,e),z:_G(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&gG(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function hG(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function gG(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=uG(cG,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}hG(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*sG),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=vG(e,u,o,s,a&&!pG(c)?oG:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function _G(e,t,n){let r=dW(e.zIndex)?e.zIndex:0;return pG(n)?r:r+(e.selected?t:0)}function vG(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=SW(e),l=HU(e,n),u=xW(e.extent)?QU(l,e.extent,c):l,d=QU({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=$U(d,c,t));let f=_G(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function yG(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=sW(a.get(n.parentId)?.expandedRect??aW(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=SW(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function bG(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=kW(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=xW(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=$U(h,s,n))}else m&&(h=QU(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:FW(`source`,r.nodeElement,p,d,e.id),target:FW(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&gG(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:aW(g,i)}))}}if(f.length>0){let e=yG(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function xG({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function SG(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function CG(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;SG(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),SG(`target`,s,c,e,i,o),t.set(r.id,r)}}function wG(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:wG(n,t):!1}function TG(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function EG(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!wG(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function DG({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function OG({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=pW(a,t);return{x:o.x-a.x,y:o.y-a.y}}function kG({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Jz(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?rW(WU(s)):null,x=v&&l?OG({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:pW(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=YU({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=DG({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=tW(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=OW(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=EG(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=DG({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=lB().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=OW(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=PW(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=OW(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=PW(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=PW(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=DG({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!TG(t,`.${g}`,v))&&(!_||TG(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function AG(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())lW(i,aW(e))>0&&r.push(e);return r}var jG=250;function MG(e,t,n,r){let i=[],a=1/0,o=AG(e,n,t+jG);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=nG(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function NG(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...nG(o,c,c.position,!0)}:c}function PG(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function FG(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var IG=()=>!0;function LG(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=IG,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=AW(e.target),E=0,D,{x:O,y:k}=PW(e),A=PG(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=NG(i,A,r,c,t);if(!N)return;let P=PW(e,j),F=!1,I=null,L=!1,ee=null;function te(){if(!u||!j)return;let[e,t]=tW(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(te)}let ne={...N,nodeId:i,type:A,position:N.position},re=c.get(i),R={inProgress:!0,isValid:null,from:nG(re,ne,$.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:re,to:P,toHandle:null,toPosition:LU[ne.position],toNode:null,pointer:P};function ie(){M=!0,y(R),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ie();function ae(e){if(!M){let{x:t,y:n}=PW(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ie()}if(!x()||!ne){oe(e);return}let a=b();P=PW(e,j),D=MG(mW(P,a,!1,[1,1]),n,c,ne),F||=(te(),!0);let s=RG(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});ee=s.handleDomNode,I=s.connection,L=FG(!!D,s.isValid);let u=c.get(i),f=u?nG(u,ne,$.Left,!0):R.from,p={...R,from:f,isValid:L,to:s.toHandle&&L?hW({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:LU[ne.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),R=p}function oe(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||ee)&&I&&L&&h?.(I);let{inProgress:t,...n}=R,r={...n,toPosition:R.toHandle?R.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,ee=null,T.removeEventListener(`mousemove`,ae),T.removeEventListener(`mouseup`,oe),T.removeEventListener(`touchmove`,ae),T.removeEventListener(`touchend`,oe)}}T.addEventListener(`mousemove`,ae),T.addEventListener(`mouseup`,oe),T.addEventListener(`touchmove`,ae),T.addEventListener(`touchend`,oe)}function RG(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=IG,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=PW(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=PG(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===jU.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=NG(t,e,a,u,n,!0)}return _}var zG={onPointerDown:LG,isValid:RG};function BG({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Jz(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&bW()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=EU().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Xz}}var VG=e=>({x:e.x,y:e.y,zoom:e.k}),HG=({x:e,y:t,zoom:n})=>gU.translate(e,t).scale(n),UG=(e,t)=>e.target.closest(`.${t}`),WG=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),GG=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,KG=(e,t=0,n=GG,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},qG=e=>{let t=e.ctrlKey&&bW()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function JG({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(UG(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Xz(u),t=d*2**qG(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===MU.Vertical?0:u.deltaX*f,m=i===MU.Horizontal?0:u.deltaY*f;!bW()&&u.shiftKey&&i!==MU.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=VG(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function YG({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=UG(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function XG({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=VG(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function ZG({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&WG(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,VG(a.transform))}}function QG({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&WG(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=VG(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function $G({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(UG(d,`${l}-flow__node`)||UG(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||UG(d,s)&&m||UG(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function eK({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=EU().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=Jz(e).call(f);y({x:i.x,y:i.y,zoom:ZU(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(qG);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fV:EV).transform(KG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&v();let O=i&&!S&&!r;f.clickDistance(D?1/0:!dW(E)||E<0?0:E);let k=O?JG({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):YG({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,k,{passive:!1});let A=XG({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,A);let j=ZG({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});f.on(`zoom`,j);let M=QG({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,M);let N=$G({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});f.filter(N),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=HG(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=HG(e);return await g(n,t),n}function x(e){if(p){let t=HG(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?_U(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fV:EV).scaleTo(KG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fV:EV).scaleBy(KG(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!dW(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var tK;(function(e){e.Line=`line`,e.Handle=`handle`})(tK||={});function nK({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function rK(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function iK(e,t){return Math.max(0,t-e)}function aK(e,t){return Math.max(0,e-t)}function oK(e,t,n){return Math.max(0,t-e,e-n)}function sK(e,t){return e?!t:t}function cK(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=oK(E,h,g),j=oK(D,_,v);if(o){let e=0,t=0;c&&w<0?e=iK(y+w+O,o[0][0]):!c&&w>0&&(e=aK(y+E+O,o[1][0])),l&&T<0?t=iK(b+T+k,o[0][1]):!l&&T>0&&(t=aK(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=aK(y+w,s[0][0]):!c&&w<0&&(e=iK(y+E,s[1][0])),l&&T>0?t=aK(b+T,s[0][1]):!l&&T<0&&(t=iK(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=oK(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?aK(b+k+E/C,o[1][1])*C:iK(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?iK(b+E/C,s[1][1])*C:aK(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=oK(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?aK(y+D*C+O,o[1][0])/C:iK(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?iK(y+D*C,s[1][0])/C:aK(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(sK(c,l)?-w:w)/C:w=(sK(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var lK={width:0,height:0,x:0,y:0},uK={...lK,pointerX:0,pointerY:0,aspectRatio:1};function dK(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function fK({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Jz(e),o={controlDirection:rK(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...lK},h={...uK};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:rK(e)};let g,_=null,v=[],y,b,x,S=!1,C=lB().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=OW(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=xW(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=dK(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=OW(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=cK(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=nK({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var pK=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),mK=o(((e,t)=>{t.exports=pK()})),hK=o((e=>{var t=d(),n=mK();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),gK=l(o(((e,t)=>{t.exports=hK()}))(),1),_K=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},vK=e=>e?_K(e):_K,{useDebugValue:yK}=H.default,{useSyncExternalStoreWithSelector:bK}=gK.default,xK=e=>e;function SK(e,t=xK,n){let r=bK(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yK(r),r}var CK=(e,t)=>{let n=vK(e),r=(e,r=t)=>SK(n,e,r);return Object.assign(r,n),r},wK=(e,t)=>e?CK(e,t):CK;function TK(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var EK=(0,H.createContext)(null),DK=EK.Provider,OK=DU.error001(`react`);function kK(e,t){let n=(0,H.useContext)(EK);if(n===null)throw Error(OK);return SK(n,e,t)}function AK(){let e=(0,H.useContext)(EK);if(e===null)throw Error(OK);return(0,H.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var jK={display:`none`},MK={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},NK=`react-flow__node-desc`,PK=`react-flow__edge-desc`,FK=`react-flow__aria-live`,IK=e=>e.ariaLiveMessage,LK=e=>e.ariaLabelConfig;function RK({rfId:e}){let t=kK(IK);return(0,W.jsx)(`div`,{id:`${FK}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:MK,children:t})}function zK({rfId:e,disableKeyboardA11y:t}){let n=kK(LK);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{id:`${NK}-${e}`,style:jK,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,W.jsx)(`div`,{id:`${PK}-${e}`,style:jK,children:n[`edge.a11yDescription.default`]}),!t&&(0,W.jsx)(RK,{rfId:e})]})}var BK=(0,H.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,W.jsx)(`div`,{className:UL([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));BK.displayName=`Panel`;var VK=`https://reactflow.dev?utm_source=attribution`;function HK({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,W.jsx)(BK,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${VK}`,children:(0,W.jsx)(`a`,{href:VK,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var UK=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},WK=e=>e.id;function GK(e,t){return TK(e.selectedNodes.map(WK),t.selectedNodes.map(WK))&&TK(e.selectedEdges.map(WK),t.selectedEdges.map(WK))}function KK({onSelectionChange:e}){let t=AK(),{selectedNodes:n,selectedEdges:r}=kK(UK,GK);return(0,H.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var qK=e=>!!e.onSelectionChangeHandlers;function JK({onSelectionChange:e}){let t=kK(qK);return e||t?(0,W.jsx)(KK,{onSelectionChange:e}):null}var YK=[0,0],XK={x:0,y:0,zoom:1},ZK=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],QK=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),$K={translateExtent:OU,nodeOrigin:YK,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function eq(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=kK(QK,TK),l=AK();(0,H.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=$K,s()}),[]);let u=(0,H.useRef)($K);return(0,H.useEffect)(()=>{for(let s of ZK){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:DW(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},ZK.map(t=>e[t])),null}function tq(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function nq(e){let[t,n]=(0,H.useState)(e===`system`?null:e);return(0,H.useEffect)(()=>{if(e!==`system`){n(e);return}let t=tq(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?tq()?.matches?`dark`:`light`:t}var rq=typeof document<`u`?document:null;function iq(e=null,t={target:rq,actInsideInputWithModifier:!0}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(!1),a=(0,H.useRef)(new Set([])),[o,s]=(0,H.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
|
|
90
90
|
`).replace(`
|
|
91
91
|
|
|
92
92
|
`,`
|
|
93
93
|
+`).split(`
|
|
94
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??nq,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&jW(e))return!1;let n=aq(e.code,s);if(a.current.add(e[n]),iq(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=aq(e.code,s);iq(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function iq(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function aq(e,t){return t.includes(e)?`code`:`key`}var oq=()=>{let e=kK();return(0,H.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=vW(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return pW(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=mW(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function sq(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)cq(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function cq(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function lq(e,t){return sq(e,t)}function uq(e,t){return sq(e,t)}function dq(e,t){return{id:e,type:`select`,selected:t}}function fq(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(dq(a.id,e)))}return r}function pq({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function mq(e){return{id:e.id,type:`remove`}}var hq=dW(`React Flow`,`https://reactflow.dev/`);function gq(e,t,n={}){return WW(e,t,{...n,onError:n.onError??hq})}var _q=e=>zU(e),vq=e=>RU(e);function yq(e){return(0,H.forwardRef)(e)}var bq=typeof window<`u`?H.useLayoutEffect:H.useEffect;function xq(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>Sq(()=>n(e=>e+BigInt(1))));return bq(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Sq(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Cq=(0,H.createContext)(null);function wq({children:e}){let t=kK(),n=xq((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=pq({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=xq((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(pq({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,W.jsx)(Cq.Provider,{value:i,children:e})}function Tq(){let e=(0,H.useContext)(Cq);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Eq=e=>!!e.panZoom;function Dq(){let e=oq(),t=kK(),n=Tq(),r=OK(Eq),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=_q(e)?e:n.get(e.id),a=i.parentId?CW(i.position,i.measured,i.parentId,n,r):i.position;return iW({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&_q(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&vq(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await YU({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(mq);o?.(f),c(e)}if(m){let e=d.map(mq);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=lW(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=iW(s?r:a),l=cW(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=lW(e)?e:a(e);if(!r)return!1;let i=cW(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return HU(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??TW();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Oq=e=>e.selected,kq=typeof window<`u`?window:void 0;function Aq({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=kK(),{deleteElements:r}=Dq(),i=rq(e,{actInsideInputWithModifier:!1}),a=rq(t,{target:kq});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Oq),edges:e.filter(Oq)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function jq(e){let t=kK();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=OW(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,EU.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var Mq={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Nq=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Pq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=jU.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=kK(),S=(0,H.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=OK(Nq,wK),E=rq(f),D=(0,H.useRef)();jq(S);let O=(0,H.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,H.useEffect)(()=>{if(S.current){D.current=$G({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,H.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,W.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:Mq,children:m})}var Fq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Iq(){let{userSelectionActive:e,userSelectionRect:t}=OK(Fq,wK);return e&&t?(0,W.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Lq=(e,t)=>n=>{n.target===t.current&&e?.(n)},Rq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function zq({isSelecting:e,selectionKeyPressed:t,selectionMode:n=MU.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,H.useRef)(0),_=kK(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=OK(Rq,wK),C=y&&(e||v),w=(0,H.useRef)(null),T=(0,H.useRef)(),E=(0,H.useRef)(new Set),D=(0,H.useRef)(new Set),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useRef)({x:0,y:0}),j=(0,H.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=NW(n.nativeEvent,T.current),l=pW({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=mW(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(WU(a,m,i,n===MU.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}wW(h,E.current)||c(fq(a,E.current,!0)),wW(g,D.current)||l(fq(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function ee(){if(!i||!T.current)return;let[e,t]=eW(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(ee);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(ee)})}let te=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};return(0,H.useEffect)(()=>()=>te(),[]),(0,W.jsxs)(`div`,{className:HL([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:C?void 0:Lq(M,w),onContextMenu:Lq(N,w),onWheel:Lq(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=NW(e.nativeEvent,T.current);A.current={x:o,y:c};let l=mW({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(ee(),!0),L(o,c)}:p,onPointerUp:e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),te())},onPointerCancel:C?e=>{e.target?.releasePointerCapture?.(e.pointerId),te()}:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:Mq,children:[h,(0,W.jsx)(Iq,{})]})}function Bq({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,EU.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Vq({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=kK(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{if(!t)return u.current=OG({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{Bq({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,H.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var Hq=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Uq(){let e=kK();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=Hq(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=fW(t,i));let{position:a,positionAbsolute:s}=JU({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Wq=(0,H.createContext)(null),Gq=Wq.Provider;Wq.Consumer;var Kq=()=>(0,H.useContext)(Wq),qq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Jq=(0,H.createContext)(null);function Yq({children:e}){let t=OK(qq,wK);return(0,W.jsx)(Jq.Provider,{value:t,children:e})}function Xq(){let e=(0,H.useContext)(Jq);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Zq={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Qq=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Zq;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===AU.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function $q({type:e=`source`,position:t=$.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=kK(),_=Kq(),{connectOnClick:v,noPanClassName:y,rfId:b}=Xq(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=OK(Qq(_,m,e),wK);_||g.getState().onError?.(`010`,EU.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(gq(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=MW(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();RG.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,W.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:HL([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=kW(t.target),h=n||c,{connection:v,isValid:y}=RG.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var eJ=(0,H.memo)(yq($q));function tJ({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[e?.label,(0,W.jsx)(eJ,{type:`source`,position:n,isConnectable:t})]})}function nJ({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eJ,{type:`target`,position:n,isConnectable:t}),e?.label,(0,W.jsx)(eJ,{type:`source`,position:r,isConnectable:t})]})}function rJ(){return null}function iJ({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(eJ,{type:`target`,position:n,isConnectable:t}),e?.label]})}var aJ={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},oJ={input:tJ,default:nJ,output:iJ,group:rJ};function sJ(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var cJ=e=>{let{width:t,height:n,x:r,y:i}=UU(e.nodeLookup,{filter:e=>!!e.selected});return{width:uW(t)?t:null,height:uW(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function lJ({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=kK(),{width:i,height:a,transformString:o,userSelectionActive:s}=OK(cJ,wK),c=Uq(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Vq({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,W.jsx)(`div`,{className:HL([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,W.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(aJ,e.key)&&(e.preventDefault(),c({direction:aJ[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var uJ=typeof window<`u`?window:void 0,dJ=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function fJ({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:ee}=OK(dJ,wK),te=rq(l,{target:uJ}),ne=rq(h,{target:uJ}),re=ne||w,R=ne||b,ie=u&&re!==!0,ae=te||ee||ie;return Aq({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,W.jsx)(Pq,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:R,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!te&&re,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:ie,children:(0,W.jsxs)(zq,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:re,autoPanOnSelection:T,isSelecting:!!ae,selectionMode:d,selectionKeyPressed:te,paneClickDistance:s,selectionOnDrag:ie,children:[e,L&&(0,W.jsx)(lJ,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}fJ.displayName=`FlowRenderer`;var pJ=(0,H.memo)(fJ),mJ=e=>t=>e?WU(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function hJ(e){return OK((0,H.useCallback)(mJ(e),[e]),wK)}var gJ=e=>e.updateNodeInternals;function _J(){let e=OK(gJ),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function vJ({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=kK(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function yJ({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=OK(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},wK),S=y.type||`default`,C=g?.[S]||oJ[S];C===void 0&&(v?.(`003`,EU.error003(S)),S=`default`,C=g?.default||oJ.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=kK(),k=SW(y),A=vJ({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=Vq({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Uq();if(y.hidden)return null;let N=xW(y),P=sJ(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,ee=i?e=>i(e,{...b.userNode}):void 0,te=a?e=>a(e,{...b.userNode}):void 0,ne=o?e=>o(e,{...b.userNode}):void 0,re=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&Bq({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},R=t=>{if(!(jW(t.nativeEvent)||m)){if(OU.includes(t.key)&&T){let n=t.key===`Escape`;Bq({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(aJ,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:aJ[t.key],factor:t.shiftKey?4:1})}}},ie=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(WU(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,W.jsx)(`div`,{className:HL([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:ee,onContextMenu:te,onClick:re,onDoubleClick:ne,onKeyDown:D?R:void 0,tabIndex:D?0:void 0,onFocus:D?ie:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${MK}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,W.jsx)(Gq,{value:e,children:(0,W.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var bJ=(0,H.memo)(yJ),xJ=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function SJ(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=OK(xJ,wK),a=hJ(e.onlyRenderVisibleElements),o=_J();return(0,W.jsx)(`div`,{className:`react-flow__nodes`,style:Mq,children:a.map(a=>(0,W.jsx)(bJ,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}SJ.displayName=`NodeRenderer`;var CJ=(0,H.memo)(SJ);function wJ(e){return OK((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&VW({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),wK)}var TJ=({color:e=`none`,strokeWidth:t=1})=>(0,W.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),EJ=({color:e=`none`,strokeWidth:t=1})=>(0,W.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),DJ={[FU.Arrow]:TJ,[FU.ArrowClosed]:EJ};function OJ(e){let t=kK();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(DJ,e)?DJ[e]:(t.getState().onError?.(`009`,EU.error009(e)),null),[e])}var kJ=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=OJ(t);return c?(0,W.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,W.jsx)(c,{color:n,strokeWidth:o})}):null},AJ=({defaultColor:e,rfId:t})=>{let n=OK(e=>e.edges),r=OK(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>iG(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,W.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,W.jsx)(`defs`,{children:i.map(e=>(0,W.jsx)(kJ,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};AJ.displayName=`MarkerDefinitions`;var jJ=(0,H.memo)(AJ);function MJ({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=HL([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,W.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,W.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,W.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}MJ.displayName=`EdgeText`;var NJ=(0,H.memo)(MJ);function PJ({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{...u,d:e,fill:`none`,className:HL([`react-flow__edge-path`,u.className])}),l?(0,W.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&uW(t)&&uW(n)?(0,W.jsx)(NJ,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function FJ({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function IJ({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=FJ({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=FJ({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=FW({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function LJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=IJ({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,W.jsx)(PJ,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var RJ=LJ({isInternal:!1}),zJ=LJ({isInternal:!0});RJ.displayName=`SimpleBezierEdge`,zJ.displayName=`SimpleBezierEdgeInternal`;function BJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ZW({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,W.jsx)(PJ,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var VJ=BJ({isInternal:!1}),HJ=BJ({isInternal:!0});VJ.displayName=`SmoothStepEdge`,HJ.displayName=`SmoothStepEdgeInternal`;function UJ(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,W.jsx)(VJ,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var WJ=UJ({isInternal:!1}),GJ=UJ({isInternal:!0});WJ.displayName=`StepEdge`,GJ.displayName=`StepEdgeInternal`;function KJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=GW({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,W.jsx)(PJ,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var qJ=KJ({isInternal:!1}),JJ=KJ({isInternal:!0});qJ.displayName=`StraightEdge`,JJ.displayName=`StraightEdgeInternal`;function YJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=RW({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,W.jsx)(PJ,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var XJ=YJ({isInternal:!1}),ZJ=YJ({isInternal:!0});XJ.displayName=`BezierEdge`,ZJ.displayName=`BezierEdgeInternal`;var QJ={default:ZJ,straight:JJ,step:GJ,smoothstep:HJ,simplebezier:zJ},$J={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},eY=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,tY=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,nY=`react-flow__edgeupdater`;function rY({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,W.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:HL([nY,`${nY}-${s}`]),cx:eY(t,r,e),cy:tY(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function iY({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=kK(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;RG.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,W.jsxs)(W.Fragment,{children:[(e===!0||e===`source`)&&(0,W.jsx)(rY,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,W.jsx)(rY,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function aY({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=OK(t=>t.edgeLookup.get(e)),b=OK(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||QJ[x];S===void 0&&(_?.(`011`,EU.error011(x)),x=`default`,S=h?.default||QJ.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=kK(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee}=OK((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return $J;let i=$W({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=BW({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||$J,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),wK),te=(0,H.useMemo)(()=>y.markerStart?`url('#${rG(y.markerStart,m)}')`:void 0,[y.markerStart,m]),ne=(0,H.useMemo)(()=>y.markerEnd?`url('#${rG(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let re=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},R=a?e=>{a(e,{...y})}:void 0,ie=o?e=>{o(e,{...y})}:void 0,ae=s?e=>{s(e,{...y})}:void 0,oe=c?e=>{c(e,{...y})}:void 0,se=l?e=>{l(e,{...y})}:void 0;return(0,W.jsx)(`svg`,{style:{zIndex:M},children:(0,W.jsxs)(`g`,{className:HL([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:re,onDoubleClick:R,onContextMenu:ie,onMouseEnter:ae,onMouseMove:oe,onMouseLeave:se,onKeyDown:C?t=>{if(!v&&OU.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${NK}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,W.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:te,markerEnd:ne,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,W.jsx)(iY,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee,setUpdateHover:O,setReconnecting:A})]})})}var oY=(0,H.memo)(aY),sY=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function cY({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=OK(sY,wK),b=wJ(t);return(0,W.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,W.jsx)(jJ,{defaultColor:e,rfId:n}),b.map(e=>(0,W.jsx)(oY,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}cY.displayName=`EdgeRenderer`;var lY=(0,H.memo)(cY),uY=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function dY({children:e}){let t=kK(),n=(0,H.useRef)(null),[r]=(0,H.useState)(()=>t.getState().transform);return bq(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=uY(r)))};return r(),t.subscribe(r)},[t]),(0,W.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:uY(r)},children:e})}function fY(e){let t=Dq(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var pY=e=>e.panZoom?.syncViewport;function mY(e){let t=OK(pY),n=kK();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function hY(e){return e.connection.inProgress?{...e.connection,to:pW(e.connection.to,e.transform)}:{...e.connection}}function gY(e){return e?t=>e(hY(t)):hY}function _Y(e){return OK(gY(e),wK)}var vY=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function yY({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=OK(vY,wK);return a&&i&&c?(0,W.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,W.jsx)(`g`,{className:HL([`react-flow__connection`,LU(s)]),children:(0,W.jsx)(bY,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var bY=({style:e,type:t=PU.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=_Y();if(!i)return;if(n)return(0,W.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:LU(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case PU.Bezier:[m]=RW(h);break;case PU.SimpleBezier:[m]=IJ(h);break;case PU.Step:[m]=ZW({...h,borderRadius:0});break;case PU.SmoothStep:[m]=ZW(h);break;default:[m]=GW(h)}return(0,W.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};bY.displayName=`ConnectionLine`;var xY={};function SY(e=xY){(0,H.useRef)(e),kK(),(0,H.useEffect)(()=>{},[e])}function CY(){kK(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function wY({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:ee,panOnDrag:te,autoPanOnSelection:ne,onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,onPaneScroll:oe,onPaneContextMenu:se,paneClickDistance:ce,nodeClickDistance:le,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce,viewport:we,onViewportChange:Te,nodesDraggable:Ee}){return SY(e),SY(t),CY(),fY(n),mY(we),(0,W.jsx)(pJ,{onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,onPaneContextMenu:se,onPaneScroll:oe,paneClickDistance:ce,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:ee,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:te,autoPanOnSelection:ne,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,onViewportChange:Te,isControlledViewport:!!we,children:(0,W.jsxs)(dY,{children:[(0,W.jsx)(lY,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,onlyRenderVisibleElements:T,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,defaultMarkerColor:M,noPanClassName:be,disableKeyboardA11y:xe,rfId:Ce}),(0,W.jsx)(yY,{style:h,type:m,component:g,containerStyle:_}),(0,W.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,W.jsx)(CJ,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:le,onlyRenderVisibleElements:T,noPanClassName:be,noDragClassName:ve,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce,nodesDraggable:Ee}),(0,W.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}wY.displayName=`GraphView`;var TY=(0,H.memo)(wY),EY=dW(`React Flow`,`https://reactflow.dev/`),DY=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??DU;SG(h,g,_);let{nodesInitialized:x}=pG(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=vW(UU(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:DU,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:AU.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...NU},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:EY,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:kU,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},OY=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>CK((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await qU({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...DY({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=pG(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();SG(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=yG(e,n,r,i,a,o,l);d&&(uG(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=tG(e,o.fromHandle,$.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=vG(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(lq(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(uq(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>dq(e,!0)));return}i(fq(r,new Set([...e]),!0)),a(fq(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>dq(e,!0)));return}a(fq(n,new Set([...e]))),i(fq(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(dq(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(dq(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,dq(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,dq(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(pG(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return bG({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...NU}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...DY()})}},Object.is);function kY({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>OY({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,W.jsx)(EK,{value:m,children:(0,W.jsx)(wq,{children:(0,W.jsx)(Yq,{children:p})})})}function AY({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(TK)?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(kY,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var jY={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function MY({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:ee=PU.Bezier,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,deleteKeyCode:R=`Backspace`,selectionKeyCode:ie=`Shift`,selectionOnDrag:ae=!1,selectionMode:oe=MU.Full,panActivationKeyCode:se=`Space`,multiSelectionKeyCode:ce=yW()?`Meta`:`Control`,zoomActivationKeyCode:le=yW()?`Meta`:`Control`,snapToGrid:ue,snapGrid:de,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:pe,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,nodeOrigin:ve=JK,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe=!0,defaultViewport:Se=YK,minZoom:Ce=.5,maxZoom:we=2,translateExtent:Te=DU,preventScrolling:Ee=!0,nodeExtent:De,defaultMarkerColor:Oe=`#b1b1b7`,zoomOnScroll:ke=!0,zoomOnPinch:Ae=!0,panOnScroll:je=!1,panOnScrollSpeed:Me=.5,panOnScrollMode:Ne=jU.Free,zoomOnDoubleClick:Pe=!0,panOnDrag:Fe=!0,onPaneClick:z,onPaneMouseEnter:Ie,onPaneMouseMove:Le,onPaneMouseLeave:Re,onPaneScroll:ze,onPaneContextMenu:Be,paneClickDistance:Ve=1,nodeClickDistance:He=0,children:B,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze=10,onNodesChange:Qe,onEdgesChange:$e,noDragClassName:et=`nodrag`,noWheelClassName:tt=`nowheel`,noPanClassName:nt=`nopan`,fitView:rt,fitViewOptions:it,connectOnClick:at,attributionPosition:ot,proOptions:V,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:U,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=tq(Tt),Pt=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,W.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...jY},ref:jt,className:HL([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,W.jsxs)(AY,{nodes:e,edges:t,width:Ct,height:wt,fitView:rt,fitViewOptions:it,minZoom:Ce,maxZoom:we,nodeOrigin:ve,nodeExtent:De,zIndexMode:kt,children:[(0,W.jsx)($K,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:Ce,maxZoom:we,nodeExtent:De,onNodesChange:Qe,onEdgesChange:$e,snapToGrid:ue,snapGrid:de,connectionMode:L,translateExtent:Te,connectOnClick:at,defaultEdgeOptions:st,fitView:rt,fitViewOptions:it,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:nt,nodeOrigin:ve,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:gt,connectionRadius:ht,isValidConnection:U,selectNodesOnDrag:pe,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:I,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,W.jsx)(TY,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:ee,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,selectionKeyCode:ie,selectionOnDrag:ae,selectionMode:oe,deleteKeyCode:R,multiSelectionKeyCode:ce,panActivationKeyCode:se,zoomActivationKeyCode:le,onlyRenderVisibleElements:fe,defaultViewport:Se,translateExtent:Te,minZoom:Ce,maxZoom:we,preventScrolling:Ee,zoomOnScroll:ke,zoomOnPinch:Ae,zoomOnDoubleClick:Pe,panOnScroll:je,panOnScrollSpeed:Me,panOnScrollMode:Ne,panOnDrag:Fe,autoPanOnSelection:pt,onPaneClick:z,onPaneMouseEnter:Ie,onPaneMouseMove:Le,onPaneMouseLeave:Re,onPaneScroll:ze,onPaneContextMenu:Be,paneClickDistance:Ve,nodeClickDistance:He,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze,defaultMarkerColor:Oe,noDragClassName:et,noWheelClassName:tt,noPanClassName:nt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:De,viewport:xt,onViewportChange:St,nodesDraggable:me}),(0,W.jsx)(qK,{onSelectionChange:k}),B,(0,W.jsx)(VK,{proOptions:V,position:ot}),(0,W.jsx)(RK,{rfId:Mt,disableKeyboardA11y:ut})]})})}var NY=yq(MY);EU.error014();function PY({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,W.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:HL([`react-flow__background-pattern`,n,r])})}function FY({radius:e,className:t}){return(0,W.jsx)(`circle`,{cx:e,cy:e,r:e,className:HL([`react-flow__background-pattern`,`dots`,t])})}var IY;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(IY||={});var LY={[IY.Dots]:1,[IY.Lines]:1,[IY.Cross]:6},RY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function zY({id:e,variant:t=IY.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=OK(RY,wK),m=r||LY[t],h=t===IY.Dots,g=t===IY.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,W.jsxs)(`svg`,{className:HL([`react-flow__background`,l]),style:{...c,...Mq,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,W.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,W.jsx)(FY,{radius:y/2,className:u}):(0,W.jsx)(PY,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,W.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}zY.displayName=`Background`;var BY=(0,H.memo)(zY);function VY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,W.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function HY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,W.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function UY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,W.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function WY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function GY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function KY({children:e,className:t,...n}){return(0,W.jsx)(`button`,{type:`button`,className:HL([`react-flow__controls-button`,t]),...n,children:e})}var qY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function JY({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=kK(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=OK(qY,wK),{zoomIn:y,zoomOut:b,fitView:x}=Dq();return(0,W.jsxs)(zK,{className:HL([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(KY,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,W.jsx)(VY,{})}),(0,W.jsx)(KY,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,W.jsx)(HY,{})})]}),n&&(0,W.jsx)(KY,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,W.jsx)(UY,{})}),r&&(0,W.jsx)(KY,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,W.jsx)(GY,{}):(0,W.jsx)(WY,{})}),u]})}JY.displayName=`Controls`;var YY=(0,H.memo)(JY);function XY({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,W.jsx)(`rect`,{className:HL([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var ZY=(0,H.memo)(XY),QY=e=>e.nodes.map(e=>e.id),$Y=e=>e instanceof Function?e:()=>e;function eX({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=ZY,onClick:o}){let s=OK(QY,wK),c=$Y(t),l=$Y(e),u=$Y(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsx)(nX,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function tX({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=OK(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=xW(r);return{node:r,x:i,y:a,width:o,height:s}},wK);return!l||l.hidden||!SW(l)?null:(0,W.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var nX=(0,H.memo)(tX),rX=(0,H.memo)(eX),iX=200,aX=150,oX=e=>!e.hidden,sX=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?oW(UU(e.nodeLookup,{filter:oX}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},cX=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,lX=(e,t)=>cX(e.viewBB,t.viewBB)&&cX(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,uX=`react-flow__minimap-desc`;function dX({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=kK(),S=(0,H.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=OK(sX,lX),j=e?.width??iX,M=e?.height??aX,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,ee=b*F,te=C.x-(I-C.width)/2-ee,ne=C.y-(L-C.height)/2-ee,re=I+ee*2,R=L+ee*2,ie=`${uX}-${T}`,ae=(0,H.useRef)(0),oe=(0,H.useRef)();ae.current=F,(0,H.useEffect)(()=>{if(S.current&&E)return oe.current=zG({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ae.current}),()=>{oe.current?.destroy()}},[E]),(0,H.useEffect)(()=>{oe.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let se=p?e=>{let[t,n]=oe.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ce=m?(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,le=_??A[`minimap.ariaLabel`];return(0,W.jsx)(zK,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:HL([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,W.jsxs)(`svg`,{width:j,height:M,viewBox:`${te} ${ne} ${re} ${R}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ie,ref:S,onClick:se,children:[le&&(0,W.jsx)(`title`,{id:ie,children:le}),(0,W.jsx)(rX,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,W.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${te-ee},${ne-ee}h${re+ee*2}v${R+ee*2}h${-re-ee*2}z
|
|
95
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}dX.displayName=`MiniMap`,(0,H.memo)(dX);var fX=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,pX={[eK.Line]:`right`,[eK.Handle]:`bottom-right`};function mX({nodeId:e,position:t,variant:n=eK.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Kq(),y=typeof e==`string`?e:v,b=kK(),x=(0,H.useRef)(null),S=n===eK.Handle,C=OK((0,H.useCallback)(fX(S&&p),[S,p]),wK),w=(0,H.useRef)(null),T=t??pX[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=dK({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=vG([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...CW({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,W.jsx)(`div`,{className:HL([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(mX);function hX(e){return e.graph??void 0}function gX(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function _X(e){let t=hX(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=jX(r,`kind`)===`human`?`human`:MX(r)?`lifecycle`:`agent`,a=t.node_results[r.id]??t.result?.results?.[r.id],o=t.node_status[r.id];return o===void 0?[]:[{id:r.id,label:jX(r,`name`)??r.id,status:o,kind:i,task:r,telemetry:n.get(r.id),result:a,detail:e.node_details[r.id],control:t.node_control[r.id],failure:n.get(r.id)?.failure,blockers:[...t.node_gated_by[r.id]??[],...a?.blocked_by??[]],dependents:t.plan.tasks.filter(e=>e.deps?.includes(r.id)).map(e=>e.id)}]})}function vX(e){let t=Object.values(e);return t.some(e=>e===`failed`||e===`skipped`)?`failed`:t.every(e=>e===`done`)?`complete`:`waiting`}function yX(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function bX(e){let t=yX(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${NX(e.launch_id)}`:`${t} session · ${NX(e.session_key)}`}function xX(e){if(e.blockers.length>0&&EX.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(kX(e.status))return TX(e)??`${e.status}, with no reason recorded`}var SX=new Set([`complete-but-draft`,`complete-but-held`]);function CX(e){return SX.has(e.status)?e.result?.awaiting??[]:[]}function wX(e){let[t,...n]=CX(e);if(t===void 0)return;let r=t.producer.split(`/`).filter(Boolean).at(-1),i=n.length>0?` +${n.length}`:``;return`awaits ${t.target} of ${r??t.producer}${i}`}function TX(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var EX=new Set([`blocked`,`skipped`,`waiting`]),DX=new Set([`failed`,`not-completed`,`cancelled`]);function OX(e){let t=jL,n=t=>(e[t]??0)>0;return[...t.filter(n),...Object.keys(e).filter(e=>!t.includes(e)).sort().filter(n)].map(t=>`${e[t]} ${t}`).join(` · `)}function kX(e){return DX.has(e)}function AX(e){return kX(e)||e===`blocked`||e===`skipped`}function jX(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function MX(e){return`repo`in e||`steps`in e}function NX(e){return e.length>12?`${e.slice(0,8)}…`:e}function PX({data:e}){let t=e.style===`success`?xt:e.style===`danger`||e.style===`muted`?un:e.style===`active`?Et:kt;return(0,W.jsxs)(`article`,{"aria-label":`${e.label}: ${e.state}`,className:V(`dag-node`,`state-${e.state}`,`token-${e.style}`),"data-selected":e.selected,children:[(0,W.jsx)(eJ,{type:`target`,position:$.Left}),(0,W.jsxs)(`div`,{className:`node-heading`,children:[(0,W.jsx)(Ma,{className:`px-1.5 py-0 text-[9px] tracking-[.1em] uppercase`,variant:`outline`,children:e.kind}),(0,W.jsx)(t,{className:V(e.style===`active`&&`spin`),size:17})]}),(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`span`,{className:`node-status`,children:e.state}),e.reason!==void 0&&(0,W.jsx)(`span`,{className:`node-reason`,title:e.reason,children:e.reason}),e.awaits!==void 0&&(0,W.jsx)(`span`,{className:`node-awaits`,title:e.awaits,children:e.awaits}),(0,W.jsx)(eJ,{type:`source`,position:$.Right})]})}function FX({data:e,id:t,markerEnd:n,style:r}){return(0,W.jsx)(PJ,{id:t,path:IX(e?.points??[]),markerEnd:n,style:r})}function IX(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var LX={dagNode:PX},RX={routed:FX};function zX({nodes:e,selectedNodeId:t,onSelectNode:n,journalSeq:r}){let i=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)AX(n.status)&&t.set(n.id,xX(n));return t},[e]),a=(0,H.useMemo)(()=>new Map(e.map(e=>[e.id,wX(e)])),[e]),{nodes:o,edges:s}=(0,H.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),r=VL({nodes:e.map(e=>({id:e.id,label:e.label,kind:e.kind,state:e.status,...a.get(e.id)===void 0?{}:{lines:1}})),edges:e.flatMap(e=>(e.task.deps??[]).filter(e=>n.has(e)).map(t=>({id:`${t}->${e.id}`,source:t,target:e.id})))});return{nodes:r.nodes.map(e=>({id:e.id,type:`dagNode`,position:{x:e.x,y:e.y},data:{label:e.label,kind:e.kind,state:e.state,style:e.style,selected:e.id===t,...i.get(e.id)===void 0?{}:{reason:i.get(e.id)},...a.get(e.id)===void 0?{}:{awaits:a.get(e.id)}},width:e.width,height:e.height,measured:{width:e.width,height:e.height},handles:[{type:`target`,position:$.Left,x:0,y:e.height/2,width:0,height:0},{type:`source`,position:$.Right,x:e.width,y:e.height/2,width:0,height:0}]})),edges:r.edges.map(t=>({id:t.id,source:t.source,target:t.target,type:`routed`,data:{points:t.points},animated:e.find(({id:e})=>e===t.target)?.status===`running`}))}},[e,i,a,t]);return(0,W.jsxs)(`div`,{className:`graph-wrap`,"data-journal-seq":r,children:[(0,W.jsxs)(NY,{nodes:o,edges:s,colorMode:`dark`,nodeTypes:LX,edgeTypes:RX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,fitView:!0,minZoom:.05,onInit:e=>void e.fitView(),onNodeClick:(e,t)=>n(t.id),"aria-label":`DAG execution graph`,children:[(0,W.jsx)(BY,{color:`var(--border)`,gap:22}),(0,W.jsx)(YY,{showInteractive:!1})]}),(0,W.jsx)(`ol`,{className:`accessible-node-list`,"aria-label":`DAG nodes`,children:e.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.label,`: `,e.status,i.get(e.id)===void 0?``:` — ${i.get(e.id)}`,a.get(e.id)===void 0?``:` — ${a.get(e.id)}`]})},e.id))})]})}function BX({value:e,label:t=`Record`}){return e==null?(0,W.jsx)(`span`,{children:`Not recorded`}):typeof e==`boolean`?(0,W.jsx)(`span`,{children:e?`Yes`:`No`}):typeof e==`string`||typeof e==`number`?(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:String(e)}):Array.isArray(e)?e.length===0?(0,W.jsx)(`span`,{children:`None`}):(0,W.jsx)(`ol`,{"aria-label":t,children:e.map((e,n)=>(0,W.jsx)(`li`,{"aria-label":`${t}.${n}`,children:(0,W.jsx)(BX,{label:`${t}.${n}`,value:e})},n))}):typeof e==`object`?(0,W.jsx)(`div`,{className:`structured-fields`,children:Object.entries(e).map(([e,n])=>(0,W.jsxs)(`fieldset`,{"aria-label":`${t}.${e}`,children:[(0,W.jsx)(`legend`,{children:e.replaceAll(`_`,` `)}),(0,W.jsx)(BX,{label:`${t}.${e}`,value:n})]},e))}):(0,W.jsx)(`span`,{children:`Not recorded`})}function VX(e,t){let[n,r]=(0,H.useState)(0);return{host:FI(`host`,()=>e.host(),n),unwatched:FI(`unwatched`,()=>e.unwatched(),n),refresh:(0,H.useCallback)(()=>{r(e=>e+1),t?.()},[t])}}var HX=[`Run`,`Node`,`Provider`,`Age (ms)`,`Proof`];function UX(e,t){let n=e?.runs??[];if(t===void 0)return n;let r=new Map(t.map(e=>[e.id,e])),i=new Set(n.map(e=>e.run_id));return[...n.flatMap(e=>{let t=r.get(e.run_id);if(t===void 0)return[];let{done:n,failed:i,running:a}=t.nodes;return[{run_id:e.run_id,state:t.state,node_counts:{...e.node_counts,done:n,failed:i,running:a}}]}),...(e===void 0?[]:t).filter(e=>!i.has(e.id)).map(({id:e,state:t,nodes:{done:n,failed:r,running:i}})=>({run_id:e,state:t,node_counts:{done:n,failed:r,running:i}}))]}function WX({client:e,onRefresh:t,list:n,rows:r,listError:i,children:a}){let{host:o,unwatched:s,refresh:c}=VX(e,t),l=o.value?.reading;return(0,W.jsx)(sf,{className:`min-h-0 flex-1`,children:(0,W.jsxs)(`section`,{"aria-label":`Host`,className:`channel-view host-page`,children:[(0,W.jsxs)(`h2`,{children:[`This host`,l&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`output`,{"aria-label":`Host name`,className:`host-name`,children:l.host})]})]}),(0,W.jsx)(Pa,{onClick:c,children:`Refresh host`}),(o.error||s.error)&&(0,W.jsx)(`p`,{role:`alert`,children:o.error?.message??s.error?.message}),o.loading&&(0,W.jsx)(`p`,{role:`status`,children:`Reading host…`}),l&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Runs root`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Runs root path`,children:l.root})})]}),l.root_error&&(0,W.jsx)(`p`,{role:`alert`,children:l.root_error}),(0,W.jsxs)(`section`,{"aria-label":`Free space`,children:[(0,W.jsx)(`h3`,{children:`Free space`}),l.free_space.map((e,t)=>(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Filesystem`}),(0,W.jsx)(`dd`,{children:e.roots.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0&&` · `,e.role,`:`,` `,(0,W.jsx)(`output`,{"aria-label":`Filesystem root path`,children:e.path??`unresolved`}),e.measured_at&&(0,W.jsxs)(W.Fragment,{children:[` `,`(measured at`,` `,(0,W.jsx)(`output`,{"aria-label":`Measured root ancestor`,children:e.measured_at}),`)`]})]},e.role))}),(0,W.jsx)(`dt`,{children:`Free bytes`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Free capacity bytes`,children:e.free_bytes??`Unknown`})}),(0,W.jsx)(`dt`,{children:`Total bytes`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Total capacity bytes`,children:e.total_bytes??`Unknown`})}),e.error&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Error`}),(0,W.jsx)(`dd`,{children:e.error})]})]},e.roots[0]?.path??t))]}),(0,W.jsxs)(`section`,{"aria-label":`Providers and dispatches`,children:[(0,W.jsx)(`h3`,{children:`Providers and dispatches`}),l.dispatches.length===0?(0,W.jsx)(`p`,{children:`No live dispatches`}):(0,W.jsx)(`section`,{"aria-label":`Providers and dispatches table`,className:`host-table`,children:(0,W.jsxs)(`table`,{children:[(0,W.jsx)(`thead`,{children:(0,W.jsx)(`tr`,{children:HX.map(e=>(0,W.jsx)(`th`,{children:e},e))})}),(0,W.jsx)(`tbody`,{children:l.dispatches.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{"data-label":`Run`,children:e.run}),(0,W.jsx)(`td`,{"data-label":`Node`,children:e.node}),(0,W.jsx)(`td`,{"data-label":`Provider`,children:e.launcher}),(0,W.jsx)(`td`,{"data-label":`Age (ms)`,children:(0,W.jsx)(`output`,{"aria-label":`Dispatch age milliseconds`,className:`host-age`,children:e.age_ms??`Unknown`})}),(0,W.jsxs)(`td`,{"data-label":`Proof`,children:[e.proof,e.unproven&&`: ${e.unproven}`]})]},`${e.run}/${e.node}`))})]})})]}),(0,W.jsxs)(`section`,{"aria-label":`Gone dispatches`,children:[(0,W.jsx)(`h3`,{children:`Gone dispatches`}),l.gone.map(e=>(0,W.jsxs)(`p`,{children:[e.run,` · `,e.node,` · `,e.reason]},`${e.run}/${e.node}`))]}),l.skipped.map(e=>(0,W.jsxs)(`p`,{children:[e.path,`: `,e.reason]},e.path))]}),(0,W.jsxs)(`section`,{"aria-label":`Unwatched runs`,children:[(0,W.jsxs)(`h3`,{children:[`Unwatched runs: `,s.value?.reported.length??`…`]}),s.value?.reported.map(e=>(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:e.run}),(0,W.jsxs)(`dd`,{children:[e.standing,` · `,e.why_not_watched]})]},e.run)),s.value?.unresolved.map(e=>(0,W.jsx)(`p`,{children:e},e))]}),(0,W.jsxs)(`section`,{"aria-label":`Runs on the host`,children:[(0,W.jsx)(`h3`,{children:`Runs on the host`}),i&&(0,W.jsxs)(`p`,{role:`alert`,children:[`Listing unavailable: `,i.message]}),UX(n,r).map(e=>(0,W.jsx)(`p`,{children:[e.run_id,e.state,OX(e.node_counts)].filter(Boolean).join(` · `)},e.run_id))]}),(0,W.jsxs)(`details`,{"aria-label":`Provider health`,children:[(0,W.jsx)(`summary`,{children:`Provider health`}),(0,W.jsx)(BX,{value:n?.provider_health})]}),a]})})}function GX(e,t,n){let{value:r,error:i}=FI(t?`host-listing`:void 0,async()=>{let[t,n]=await Promise.all([e.listRuns(!0),e.listProjects()]);return{...t,runs:n.projects.flatMap(e=>e.runs),next_cursor:void 0}},n);return t?{list:r,error:i}:{}}function KX(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function qX(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function JX(e){return e}var YX=[],XX=`skip`;function ZX(e,t,n,r){if(!e||typeof e!=`object`)throw Error("Unexpected value `"+e+"` for `tree`, expected node");let i=!0,a,o,s,c;if(typeof n==`function`||n&&typeof n==`object`?(a=t,o=n,r&&(i=!1)):(o=t,n&&(i=!1)),typeof o==`function`)s=o;else if(o&&typeof o==`object`){if(!(o.enter===null||o.enter===void 0))if(typeof o.enter==`function`)s=o.enter;else throw Error("Unexpected value `"+o.enter+"` for `visitors.enter`, expected optional visitor");if(typeof o.exit==`function`)c=o.exit;else throw Error("Unexpected value `"+o.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw Error("Unexpected value `"+o+"` for `enter` or `visitors`, expected visitor or object with visitors");let l=lb(a),u=i?1:-1;d(e,void 0,[])();function d(e,t,n){let r=e&&typeof e==`object`?e:{};if(typeof r.type==`string`){let t=typeof r.tagName==`string`?r.tagName:typeof r.name==`string`?r.name:void 0;Object.defineProperty(o,"name",{value:`node (`+JX(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=YX;if(s&&r&&(o=QX(s(e,n,t)),o[0]===!1))return o;if(`children`in e&&e.children){let t=e;if(t.children&&o[0]!==`skip`){let e=(i?-1:t.children.length)+u,r=[...n,t];for(;e>-1&&e<t.children.length;){let n=t.children[e],i=d(n,e,r)();if(i[0]===!1)return i;e=typeof i[1]==`number`?i[1]:e+u}}}if(c&&r){let r=QX(c(e,n,t));if(r[0]===`skip`)throw Error("Unexpected value `"+r[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(r[0]===!1||typeof r[1]==`number`)return r}return o}}}function QX(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?YX:[e]}function $X(e,t,n){let r=lb((n||{}).ignore||[]),i=eZ(t),a=-1;for(;++a<i.length;)ZX(e,o);function o(e,t,n){if(e.type===`text`&&typeof n==`number`)return s(e,t,n);if(r(e,n,t[t.length-1]))return XX}function s(e,t,n){let r=t[t.length-1],o=i[a][0],s=i[a][1],c=0,l=!1,u=[];o.lastIndex=0;let d=o.exec(e.value);for(;d;){let n=d.index,r={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,r);if(typeof i==`string`&&(i=i.length>0?{type:`text`,value:i}:void 0),i===!1)o.lastIndex=n+1;else{if(c!==n&&f({type:`text`,value:e.value.slice(c,n)}),Array.isArray(i))for(let e of i)f(e);else i&&f(i);c=n+d[0].length,l=!0}if(!o.global)break;d=o.exec(e.value)}return l?(c<e.value.length&&f({type:`text`,value:e.value.slice(c)}),r.children.splice(n,1,...u)):u=[e],n+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function eZ(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([tZ(e[0]),nZ(e[1])])}return t}function tZ(e){return typeof e==`string`?new RegExp(qX(e),`g`):e}function nZ(e){return typeof e==`function`?e:function(){return e}}var rZ=`phrasing`,iZ=[`autolink`,`link`,`image`,`label`];function aZ(){return{transforms:[pZ],enter:{literalAutolink:sZ,literalAutolinkEmail:cZ,literalAutolinkHttp:cZ,literalAutolinkWww:cZ},exit:{literalAutolink:fZ,literalAutolinkEmail:dZ,literalAutolinkHttp:lZ,literalAutolinkWww:uZ}}}function oZ(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:rZ,notInConstruct:iZ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:rZ,notInConstruct:iZ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:rZ,notInConstruct:iZ}]}}function sZ(e){this.enter({type:`link`,title:null,url:``,children:[],position:void 0},e)}function cZ(e){this.config.enter.autolinkProtocol.call(this,e)}function lZ(e){this.config.exit.autolinkProtocol.call(this,e)}function uZ(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function dZ(e){this.config.exit.autolinkEmail.call(this,e)}function fZ(e){this.exit(e)}function pZ(e){$X(e,[[/(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,mZ],[/(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,_Z],[/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,gZ],[/(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,hZ]],{ignore:[`link`,`linkReference`]})}function mZ(e,t,n,r,i){if(!bZ(i))return!1;let a=``;if(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),zg(n.charCodeAt(0))||!vZ(n))return!1;let o=yZ(n+r),s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0],position:void 0}],position:void 0};return o[1]?[s,{type:`text`,value:o[1],position:void 0}]:s}function hZ(e,t,n){return!/[\d\-_]$/.test(n)&&{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n,position:void 0}],position:void 0}}function gZ(e,t,n){if(/[\d\-_]$/.test(n))return!1;let r=`mailto:`+t+`@`+n;return{type:`link`,title:null,url:r,children:[{type:`text`,value:r,position:void 0}],position:void 0}}function _Z(e,t,n,r,i){if(/[\d\-_]$/.test(n)||r&&(!/[A-Za-z]$/.test(r)||i.input.charAt(i.index+e.length)===`@`))return!1;let a=`xmpp:`+t+`@`+n+(r||``);return{type:`link`,title:null,url:a,children:[{type:`text`,value:a,position:void 0}],position:void 0}}function vZ(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[\dA-Za-z]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[\dA-Za-z]/.test(t[t.length-2])))}function yZ(e){let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n===33||n===34||n===38||n===39||n===41||n===44||n===46||n===58||n===59||n===60||n===62||n===63||n===93||n===125)t--;else break}if(t===e.length)return[e,void 0];let n=e.slice(t);e=e.slice(0,t);let r=n.indexOf(`)`),i=KX(e,`(`),a=KX(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function bZ(e){let t=e.input.charCodeAt(e.index-1);return e.index===0||Bg(t)||zg(t)}AZ.peek=kZ;function xZ(){this.buffer()}function SZ(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function CZ(){this.buffer()}function wZ(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function TZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=kg(this.sliceSerialize(e)).toLowerCase(),n.label=t}function EZ(e){this.exit(e)}function DZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=kg(this.sliceSerialize(e)).toLowerCase(),n.label=t}function OZ(e){this.exit(e)}function kZ(){return`[`}function AZ(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function jZ(){return{enter:{gfmFootnoteCallString:xZ,gfmFootnoteCall:SZ,gfmFootnoteDefinitionLabelString:CZ,gfmFootnoteDefinition:wZ},exit:{gfmFootnoteCallString:TZ,gfmFootnoteCall:EZ,gfmFootnoteDefinitionLabelString:DZ,gfmFootnoteDefinition:OZ}}}function MZ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:AZ},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
96
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?PZ
|
|
97
|
-
`)}function
|
|
98
|
-
`&&
|
|
99
|
-
`}function
|
|
94
|
+
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??rq,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&MW(e))return!1;let n=oq(e.code,s);if(a.current.add(e[n]),aq(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=oq(e.code,s);aq(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function aq(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function oq(e,t){return t.includes(e)?`code`:`key`}var sq=()=>{let e=AK();return(0,H.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=yW(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return mW(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=hW(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function cq(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)lq(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function lq(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function uq(e,t){return cq(e,t)}function dq(e,t){return cq(e,t)}function fq(e,t){return{id:e,type:`select`,selected:t}}function pq(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(fq(a.id,e)))}return r}function mq({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function hq(e){return{id:e.id,type:`remove`}}var gq=fW(`React Flow`,`https://reactflow.dev/`);function _q(e,t,n={}){return GW(e,t,{...n,onError:n.onError??gq})}var vq=e=>BU(e),yq=e=>zU(e);function bq(e){return(0,H.forwardRef)(e)}var xq=typeof window<`u`?H.useLayoutEffect:H.useEffect;function Sq(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>Cq(()=>n(e=>e+BigInt(1))));return xq(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Cq(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var wq=(0,H.createContext)(null);function Tq({children:e}){let t=AK(),n=Sq((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=mq({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Sq((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(mq({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,W.jsx)(wq.Provider,{value:i,children:e})}function Eq(){let e=(0,H.useContext)(wq);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Dq=e=>!!e.panZoom;function Oq(){let e=sq(),t=AK(),n=Eq(),r=kK(Dq),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=vq(e)?e:n.get(e.id),a=i.parentId?wW(i.position,i.measured,i.parentId,n,r):i.position;return aW({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&vq(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&yq(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await XU({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(hq);o?.(f),c(e)}if(m){let e=d.map(hq);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=uW(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=aW(s?r:a),l=lW(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=uW(e)?e:a(e);if(!r)return!1;let i=lW(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return UU(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??EW();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var kq=e=>e.selected,Aq=typeof window<`u`?window:void 0;function jq({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=AK(),{deleteElements:r}=Oq(),i=iq(e,{actInsideInputWithModifier:!1}),a=iq(t,{target:Aq});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(kq),edges:e.filter(kq)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Mq(e){let t=AK();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=kW(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,DU.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var Nq={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Pq=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Fq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=MU.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=AK(),S=(0,H.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=kK(Pq,TK),E=iq(f),D=(0,H.useRef)();Mq(S);let O=(0,H.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,H.useEffect)(()=>{if(S.current){D.current=eK({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,H.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,W.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:Nq,children:m})}var Iq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Lq(){let{userSelectionActive:e,userSelectionRect:t}=kK(Iq,TK);return e&&t?(0,W.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Rq=(e,t)=>n=>{n.target===t.current&&e?.(n)},zq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Bq({isSelecting:e,selectionKeyPressed:t,selectionMode:n=NU.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,H.useRef)(0),_=AK(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=kK(zq,TK),C=y&&(e||v),w=(0,H.useRef)(null),T=(0,H.useRef)(),E=(0,H.useRef)(new Set),D=(0,H.useRef)(new Set),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useRef)({x:0,y:0}),j=(0,H.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=PW(n.nativeEvent,T.current),l=mW({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=hW(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(GU(a,m,i,n===NU.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}TW(h,E.current)||c(pq(a,E.current,!0)),TW(g,D.current)||l(pq(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function ee(){if(!i||!T.current)return;let[e,t]=tW(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(ee);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(ee)})}let te=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};return(0,H.useEffect)(()=>()=>te(),[]),(0,W.jsxs)(`div`,{className:UL([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:C?void 0:Rq(M,w),onContextMenu:Rq(N,w),onWheel:Rq(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=PW(e.nativeEvent,T.current);A.current={x:o,y:c};let l=hW({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(ee(),!0),L(o,c)}:p,onPointerUp:e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),te())},onPointerCancel:C?e=>{e.target?.releasePointerCapture?.(e.pointerId),te()}:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:Nq,children:[h,(0,W.jsx)(Lq,{})]})}function Vq({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,DU.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Hq({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=AK(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{if(!t)return u.current=kG({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{Vq({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,H.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var Uq=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Wq(){let e=AK();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=Uq(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=pW(t,i));let{position:a,positionAbsolute:s}=YU({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Gq=(0,H.createContext)(null),Kq=Gq.Provider;Gq.Consumer;var qq=()=>(0,H.useContext)(Gq),Jq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Yq=(0,H.createContext)(null);function Xq({children:e}){let t=kK(Jq,TK);return(0,W.jsx)(Yq.Provider,{value:t,children:e})}function Zq(){let e=(0,H.useContext)(Yq);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Qq={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},$q=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Qq;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===jU.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function eJ({type:e=`source`,position:t=$.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=AK(),_=qq(),{connectOnClick:v,noPanClassName:y,rfId:b}=Zq(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=kK($q(_,m,e),TK);_||g.getState().onError?.(`010`,DU.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(_q(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=NW(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();zG.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,W.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:UL([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=AW(t.target),h=n||c,{connection:v,isValid:y}=zG.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var tJ=(0,H.memo)(bq(eJ));function nJ({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[e?.label,(0,W.jsx)(tJ,{type:`source`,position:n,isConnectable:t})]})}function rJ({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tJ,{type:`target`,position:n,isConnectable:t}),e?.label,(0,W.jsx)(tJ,{type:`source`,position:r,isConnectable:t})]})}function iJ(){return null}function aJ({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(tJ,{type:`target`,position:n,isConnectable:t}),e?.label]})}var oJ={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},sJ={input:nJ,default:rJ,output:aJ,group:iJ};function cJ(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var lJ=e=>{let{width:t,height:n,x:r,y:i}=WU(e.nodeLookup,{filter:e=>!!e.selected});return{width:dW(t)?t:null,height:dW(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function uJ({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=AK(),{width:i,height:a,transformString:o,userSelectionActive:s}=kK(lJ,TK),c=Wq(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Hq({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,W.jsx)(`div`,{className:UL([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,W.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(oJ,e.key)&&(e.preventDefault(),c({direction:oJ[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var dJ=typeof window<`u`?window:void 0,fJ=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function pJ({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:ee}=kK(fJ,TK),te=iq(l,{target:dJ}),ne=iq(h,{target:dJ}),re=ne||w,R=ne||b,ie=u&&re!==!0,ae=te||ee||ie;return jq({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,W.jsx)(Fq,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:R,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!te&&re,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:ie,children:(0,W.jsxs)(Bq,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:re,autoPanOnSelection:T,isSelecting:!!ae,selectionMode:d,selectionKeyPressed:te,paneClickDistance:s,selectionOnDrag:ie,children:[e,L&&(0,W.jsx)(uJ,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}pJ.displayName=`FlowRenderer`;var mJ=(0,H.memo)(pJ),hJ=e=>t=>e?GU(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function gJ(e){return kK((0,H.useCallback)(hJ(e),[e]),TK)}var _J=e=>e.updateNodeInternals;function vJ(){let e=kK(_J),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function yJ({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=AK(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function bJ({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=kK(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},TK),S=y.type||`default`,C=g?.[S]||sJ[S];C===void 0&&(v?.(`003`,DU.error003(S)),S=`default`,C=g?.default||sJ.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=AK(),k=CW(y),A=yJ({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=Hq({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Wq();if(y.hidden)return null;let N=SW(y),P=cJ(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,ee=i?e=>i(e,{...b.userNode}):void 0,te=a?e=>a(e,{...b.userNode}):void 0,ne=o?e=>o(e,{...b.userNode}):void 0,re=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&Vq({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},R=t=>{if(!(MW(t.nativeEvent)||m)){if(kU.includes(t.key)&&T){let n=t.key===`Escape`;Vq({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(oJ,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:oJ[t.key],factor:t.shiftKey?4:1})}}},ie=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(GU(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,W.jsx)(`div`,{className:UL([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:ee,onContextMenu:te,onClick:re,onDoubleClick:ne,onKeyDown:D?R:void 0,tabIndex:D?0:void 0,onFocus:D?ie:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${NK}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,W.jsx)(Kq,{value:e,children:(0,W.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var xJ=(0,H.memo)(bJ),SJ=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function CJ(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=kK(SJ,TK),a=gJ(e.onlyRenderVisibleElements),o=vJ();return(0,W.jsx)(`div`,{className:`react-flow__nodes`,style:Nq,children:a.map(a=>(0,W.jsx)(xJ,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}CJ.displayName=`NodeRenderer`;var wJ=(0,H.memo)(CJ);function TJ(e){return kK((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&HW({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),TK)}var EJ=({color:e=`none`,strokeWidth:t=1})=>(0,W.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),DJ=({color:e=`none`,strokeWidth:t=1})=>(0,W.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),OJ={[IU.Arrow]:EJ,[IU.ArrowClosed]:DJ};function kJ(e){let t=AK();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(OJ,e)?OJ[e]:(t.getState().onError?.(`009`,DU.error009(e)),null),[e])}var AJ=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=kJ(t);return c?(0,W.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,W.jsx)(c,{color:n,strokeWidth:o})}):null},jJ=({defaultColor:e,rfId:t})=>{let n=kK(e=>e.edges),r=kK(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>aG(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,W.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,W.jsx)(`defs`,{children:i.map(e=>(0,W.jsx)(AJ,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};jJ.displayName=`MarkerDefinitions`;var MJ=(0,H.memo)(jJ);function NJ({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=UL([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,W.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,W.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,W.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}NJ.displayName=`EdgeText`;var PJ=(0,H.memo)(NJ);function FJ({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{...u,d:e,fill:`none`,className:UL([`react-flow__edge-path`,u.className])}),l?(0,W.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&dW(t)&&dW(n)?(0,W.jsx)(PJ,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function IJ({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function LJ({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=IJ({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=IJ({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=IW({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function RJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=LJ({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,W.jsx)(FJ,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var zJ=RJ({isInternal:!1}),BJ=RJ({isInternal:!0});zJ.displayName=`SimpleBezierEdge`,BJ.displayName=`SimpleBezierEdgeInternal`;function VJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=QW({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,W.jsx)(FJ,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var HJ=VJ({isInternal:!1}),UJ=VJ({isInternal:!0});HJ.displayName=`SmoothStepEdge`,UJ.displayName=`SmoothStepEdgeInternal`;function WJ(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,W.jsx)(HJ,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var GJ=WJ({isInternal:!1}),KJ=WJ({isInternal:!0});GJ.displayName=`StepEdge`,KJ.displayName=`StepEdgeInternal`;function qJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=KW({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,W.jsx)(FJ,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var JJ=qJ({isInternal:!1}),YJ=qJ({isInternal:!0});JJ.displayName=`StraightEdge`,YJ.displayName=`StraightEdgeInternal`;function XJ(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=zW({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,W.jsx)(FJ,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var ZJ=XJ({isInternal:!1}),QJ=XJ({isInternal:!0});ZJ.displayName=`BezierEdge`,QJ.displayName=`BezierEdgeInternal`;var $J={default:QJ,straight:YJ,step:KJ,smoothstep:UJ,simplebezier:BJ},eY={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},tY=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,nY=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,rY=`react-flow__edgeupdater`;function iY({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,W.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:UL([rY,`${rY}-${s}`]),cx:tY(t,r,e),cy:nY(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function aY({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=AK(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;zG.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,W.jsxs)(W.Fragment,{children:[(e===!0||e===`source`)&&(0,W.jsx)(iY,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,W.jsx)(iY,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function oY({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=kK(t=>t.edgeLookup.get(e)),b=kK(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||$J[x];S===void 0&&(_?.(`011`,DU.error011(x)),x=`default`,S=h?.default||$J.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=AK(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee}=kK((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return eY;let i=eG({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=VW({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||eY,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),TK),te=(0,H.useMemo)(()=>y.markerStart?`url('#${iG(y.markerStart,m)}')`:void 0,[y.markerStart,m]),ne=(0,H.useMemo)(()=>y.markerEnd?`url('#${iG(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let re=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},R=a?e=>{a(e,{...y})}:void 0,ie=o?e=>{o(e,{...y})}:void 0,ae=s?e=>{s(e,{...y})}:void 0,oe=c?e=>{c(e,{...y})}:void 0,se=l?e=>{l(e,{...y})}:void 0;return(0,W.jsx)(`svg`,{style:{zIndex:M},children:(0,W.jsxs)(`g`,{className:UL([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:re,onDoubleClick:R,onContextMenu:ie,onMouseEnter:ae,onMouseMove:oe,onMouseLeave:se,onKeyDown:C?t=>{if(!v&&kU.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${PK}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,W.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:te,markerEnd:ne,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,W.jsx)(aY,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:ee,setUpdateHover:O,setReconnecting:A})]})})}var sY=(0,H.memo)(oY),cY=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function lY({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=kK(cY,TK),b=TJ(t);return(0,W.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,W.jsx)(MJ,{defaultColor:e,rfId:n}),b.map(e=>(0,W.jsx)(sY,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}lY.displayName=`EdgeRenderer`;var uY=(0,H.memo)(lY),dY=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function fY({children:e}){let t=AK(),n=(0,H.useRef)(null),[r]=(0,H.useState)(()=>t.getState().transform);return xq(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=dY(r)))};return r(),t.subscribe(r)},[t]),(0,W.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:dY(r)},children:e})}function pY(e){let t=Oq(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var mY=e=>e.panZoom?.syncViewport;function hY(e){let t=kK(mY),n=AK();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function gY(e){return e.connection.inProgress?{...e.connection,to:mW(e.connection.to,e.transform)}:{...e.connection}}function _Y(e){return e?t=>e(gY(t)):gY}function vY(e){return kK(_Y(e),TK)}var yY=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function bY({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=kK(yY,TK);return a&&i&&c?(0,W.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,W.jsx)(`g`,{className:UL([`react-flow__connection`,RU(s)]),children:(0,W.jsx)(xY,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var xY=({style:e,type:t=FU.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=vY();if(!i)return;if(n)return(0,W.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:RU(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case FU.Bezier:[m]=zW(h);break;case FU.SimpleBezier:[m]=LJ(h);break;case FU.Step:[m]=QW({...h,borderRadius:0});break;case FU.SmoothStep:[m]=QW(h);break;default:[m]=KW(h)}return(0,W.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};xY.displayName=`ConnectionLine`;var SY={};function CY(e=SY){(0,H.useRef)(e),AK(),(0,H.useEffect)(()=>{},[e])}function wY(){AK(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function TY({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:ee,panOnDrag:te,autoPanOnSelection:ne,onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,onPaneScroll:oe,onPaneContextMenu:se,paneClickDistance:ce,nodeClickDistance:le,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce,viewport:we,onViewportChange:Te,nodesDraggable:Ee}){return CY(e),CY(t),wY(),pY(n),hY(we),(0,W.jsx)(mJ,{onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,onPaneContextMenu:se,onPaneScroll:oe,paneClickDistance:ce,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:ee,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:te,autoPanOnSelection:ne,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,onViewportChange:Te,isControlledViewport:!!we,children:(0,W.jsxs)(fY,{children:[(0,W.jsx)(uY,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,onlyRenderVisibleElements:T,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,defaultMarkerColor:M,noPanClassName:be,disableKeyboardA11y:xe,rfId:Ce}),(0,W.jsx)(bY,{style:h,type:m,component:g,containerStyle:_}),(0,W.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,W.jsx)(wJ,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:le,onlyRenderVisibleElements:T,noPanClassName:be,noDragClassName:ve,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce,nodesDraggable:Ee}),(0,W.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}TY.displayName=`GraphView`;var EY=(0,H.memo)(TY),DY=fW(`React Flow`,`https://reactflow.dev/`),OY=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??OU;CG(h,g,_);let{nodesInitialized:x}=mG(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=yW(WU(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:OU,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:jU.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...PU},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:DY,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:AU,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},kY=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>wK((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await JU({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...OY({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=mG(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();CG(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=bG(e,n,r,i,a,o,l);d&&(dG(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=nG(e,o.fromHandle,$.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=yG(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(uq(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(dq(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>fq(e,!0)));return}i(pq(r,new Set([...e]),!0)),a(pq(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>fq(e,!0)));return}a(pq(n,new Set([...e]))),i(pq(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(fq(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(fq(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,fq(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,fq(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(mG(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return xG({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...PU}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...OY()})}},Object.is);function AY({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>kY({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,W.jsx)(DK,{value:m,children:(0,W.jsx)(Tq,{children:(0,W.jsx)(Xq,{children:p})})})}function jY({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(EK)?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(AY,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var MY={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function NY({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:ee=FU.Bezier,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,deleteKeyCode:R=`Backspace`,selectionKeyCode:ie=`Shift`,selectionOnDrag:ae=!1,selectionMode:oe=NU.Full,panActivationKeyCode:se=`Space`,multiSelectionKeyCode:ce=bW()?`Meta`:`Control`,zoomActivationKeyCode:le=bW()?`Meta`:`Control`,snapToGrid:ue,snapGrid:de,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:pe,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,nodeOrigin:ve=YK,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe=!0,defaultViewport:Se=XK,minZoom:Ce=.5,maxZoom:we=2,translateExtent:Te=OU,preventScrolling:Ee=!0,nodeExtent:De,defaultMarkerColor:Oe=`#b1b1b7`,zoomOnScroll:ke=!0,zoomOnPinch:Ae=!0,panOnScroll:je=!1,panOnScrollSpeed:Me=.5,panOnScrollMode:Ne=MU.Free,zoomOnDoubleClick:Pe=!0,panOnDrag:Fe=!0,onPaneClick:z,onPaneMouseEnter:Ie,onPaneMouseMove:Le,onPaneMouseLeave:Re,onPaneScroll:ze,onPaneContextMenu:Be,paneClickDistance:Ve=1,nodeClickDistance:He=0,children:B,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze=10,onNodesChange:Qe,onEdgesChange:$e,noDragClassName:et=`nodrag`,noWheelClassName:tt=`nowheel`,noPanClassName:nt=`nopan`,fitView:rt,fitViewOptions:it,connectOnClick:at,attributionPosition:ot,proOptions:V,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:U,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=nq(Tt),Pt=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,W.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...MY},ref:jt,className:UL([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,W.jsxs)(jY,{nodes:e,edges:t,width:Ct,height:wt,fitView:rt,fitViewOptions:it,minZoom:Ce,maxZoom:we,nodeOrigin:ve,nodeExtent:De,zIndexMode:kt,children:[(0,W.jsx)(eq,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:Ce,maxZoom:we,nodeExtent:De,onNodesChange:Qe,onEdgesChange:$e,snapToGrid:ue,snapGrid:de,connectionMode:L,translateExtent:Te,connectOnClick:at,defaultEdgeOptions:st,fitView:rt,fitViewOptions:it,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:nt,nodeOrigin:ve,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:gt,connectionRadius:ht,isValidConnection:U,selectNodesOnDrag:pe,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:I,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,W.jsx)(EY,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:ee,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,selectionKeyCode:ie,selectionOnDrag:ae,selectionMode:oe,deleteKeyCode:R,multiSelectionKeyCode:ce,panActivationKeyCode:se,zoomActivationKeyCode:le,onlyRenderVisibleElements:fe,defaultViewport:Se,translateExtent:Te,minZoom:Ce,maxZoom:we,preventScrolling:Ee,zoomOnScroll:ke,zoomOnPinch:Ae,zoomOnDoubleClick:Pe,panOnScroll:je,panOnScrollSpeed:Me,panOnScrollMode:Ne,panOnDrag:Fe,autoPanOnSelection:pt,onPaneClick:z,onPaneMouseEnter:Ie,onPaneMouseMove:Le,onPaneMouseLeave:Re,onPaneScroll:ze,onPaneContextMenu:Be,paneClickDistance:Ve,nodeClickDistance:He,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze,defaultMarkerColor:Oe,noDragClassName:et,noWheelClassName:tt,noPanClassName:nt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:De,viewport:xt,onViewportChange:St,nodesDraggable:me}),(0,W.jsx)(JK,{onSelectionChange:k}),B,(0,W.jsx)(HK,{proOptions:V,position:ot}),(0,W.jsx)(zK,{rfId:Mt,disableKeyboardA11y:ut})]})})}var PY=bq(NY);DU.error014();function FY({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,W.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:UL([`react-flow__background-pattern`,n,r])})}function IY({radius:e,className:t}){return(0,W.jsx)(`circle`,{cx:e,cy:e,r:e,className:UL([`react-flow__background-pattern`,`dots`,t])})}var LY;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(LY||={});var RY={[LY.Dots]:1,[LY.Lines]:1,[LY.Cross]:6},zY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function BY({id:e,variant:t=LY.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=kK(zY,TK),m=r||RY[t],h=t===LY.Dots,g=t===LY.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,W.jsxs)(`svg`,{className:UL([`react-flow__background`,l]),style:{...c,...Nq,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,W.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,W.jsx)(IY,{radius:y/2,className:u}):(0,W.jsx)(FY,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,W.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}BY.displayName=`Background`;var VY=(0,H.memo)(BY);function HY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,W.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function UY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,W.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function WY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,W.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function GY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function KY(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function qY({children:e,className:t,...n}){return(0,W.jsx)(`button`,{type:`button`,className:UL([`react-flow__controls-button`,t]),...n,children:e})}var JY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function YY({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=AK(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=kK(JY,TK),{zoomIn:y,zoomOut:b,fitView:x}=Oq();return(0,W.jsxs)(BK,{className:UL([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qY,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,W.jsx)(HY,{})}),(0,W.jsx)(qY,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,W.jsx)(UY,{})})]}),n&&(0,W.jsx)(qY,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,W.jsx)(WY,{})}),r&&(0,W.jsx)(qY,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,W.jsx)(KY,{}):(0,W.jsx)(GY,{})}),u]})}YY.displayName=`Controls`;var XY=(0,H.memo)(YY);function ZY({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,W.jsx)(`rect`,{className:UL([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var QY=(0,H.memo)(ZY),$Y=e=>e.nodes.map(e=>e.id),eX=e=>e instanceof Function?e:()=>e;function tX({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=QY,onClick:o}){let s=kK($Y,TK),c=eX(t),l=eX(e),u=eX(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsx)(rX,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function nX({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=kK(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=SW(r);return{node:r,x:i,y:a,width:o,height:s}},TK);return!l||l.hidden||!CW(l)?null:(0,W.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var rX=(0,H.memo)(nX),iX=(0,H.memo)(tX),aX=200,oX=150,sX=e=>!e.hidden,cX=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?sW(WU(e.nodeLookup,{filter:sX}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},lX=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,uX=(e,t)=>lX(e.viewBB,t.viewBB)&&lX(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,dX=`react-flow__minimap-desc`;function fX({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=AK(),S=(0,H.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=kK(cX,uX),j=e?.width??aX,M=e?.height??oX,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,ee=b*F,te=C.x-(I-C.width)/2-ee,ne=C.y-(L-C.height)/2-ee,re=I+ee*2,R=L+ee*2,ie=`${dX}-${T}`,ae=(0,H.useRef)(0),oe=(0,H.useRef)();ae.current=F,(0,H.useEffect)(()=>{if(S.current&&E)return oe.current=BG({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ae.current}),()=>{oe.current?.destroy()}},[E]),(0,H.useEffect)(()=>{oe.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let se=p?e=>{let[t,n]=oe.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ce=m?(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,le=_??A[`minimap.ariaLabel`];return(0,W.jsx)(BK,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:UL([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,W.jsxs)(`svg`,{width:j,height:M,viewBox:`${te} ${ne} ${re} ${R}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ie,ref:S,onClick:se,children:[le&&(0,W.jsx)(`title`,{id:ie,children:le}),(0,W.jsx)(iX,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,W.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${te-ee},${ne-ee}h${re+ee*2}v${R+ee*2}h${-re-ee*2}z
|
|
95
|
+
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}fX.displayName=`MiniMap`,(0,H.memo)(fX);var pX=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,mX={[tK.Line]:`right`,[tK.Handle]:`bottom-right`};function hX({nodeId:e,position:t,variant:n=tK.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=qq(),y=typeof e==`string`?e:v,b=AK(),x=(0,H.useRef)(null),S=n===tK.Handle,C=kK((0,H.useCallback)(pX(S&&p),[S,p]),TK),w=(0,H.useRef)(null),T=t??mX[n];return(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=fK({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=yG([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...wW({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,W.jsx)(`div`,{className:UL([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(hX);function gX(e){return e.graph??void 0}function _X(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function vX(e){let t=gX(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=MX(r,`kind`)===`human`?`human`:NX(r)?`lifecycle`:`agent`,a=t.node_results[r.id]??t.result?.results?.[r.id],o=t.node_status[r.id];return o===void 0?[]:[{id:r.id,label:MX(r,`name`)??r.id,status:o,kind:i,task:r,telemetry:n.get(r.id),result:a,detail:e.node_details[r.id],control:t.node_control[r.id],failure:n.get(r.id)?.failure,blockers:[...t.node_gated_by[r.id]??[],...a?.blocked_by??[]],dependents:t.plan.tasks.filter(e=>e.deps?.includes(r.id)).map(e=>e.id)}]})}function yX(e){let t=Object.values(e);return t.some(e=>e===`failed`||e===`skipped`)?`failed`:t.every(e=>e===`done`)?`complete`:`waiting`}function bX(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function xX(e){let t=bX(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${PX(e.launch_id)}`:`${t} session · ${PX(e.session_key)}`}function SX(e){if(e.blockers.length>0&&DX.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(AX(e.status))return EX(e)??`${e.status}, with no reason recorded`}var CX=new Set([`complete-but-draft`,`complete-but-held`]);function wX(e){return CX.has(e.status)?e.result?.awaiting??[]:[]}function TX(e){let[t,...n]=wX(e);if(t===void 0)return;let r=t.producer.split(`/`).filter(Boolean).at(-1),i=n.length>0?` +${n.length}`:``;return`awaits ${t.target} of ${r??t.producer}${i}`}function EX(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var DX=new Set([`blocked`,`skipped`,`waiting`]),OX=new Set([`failed`,`not-completed`,`cancelled`]);function kX(e){let t=ML,n=t=>(e[t]??0)>0;return[...t.filter(n),...Object.keys(e).filter(e=>!t.includes(e)).sort().filter(n)].map(t=>`${e[t]} ${t}`).join(` · `)}function AX(e){return OX.has(e)}function jX(e){return AX(e)||e===`blocked`||e===`skipped`}function MX(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function NX(e){return`repo`in e||`steps`in e}function PX(e){return e.length>12?`${e.slice(0,8)}…`:e}function FX({data:e}){let t=e.style===`success`?xt:e.style===`danger`||e.style===`muted`?un:e.style===`active`?Et:kt;return(0,W.jsxs)(`article`,{"aria-label":`${e.label}: ${e.state}`,className:V(`dag-node`,`state-${e.state}`,`token-${e.style}`),"data-selected":e.selected,children:[(0,W.jsx)(tJ,{type:`target`,position:$.Left}),(0,W.jsxs)(`div`,{className:`node-heading`,children:[(0,W.jsx)(Ma,{className:`px-1.5 py-0 text-[9px] tracking-[.1em] uppercase`,variant:`outline`,children:e.kind}),(0,W.jsx)(t,{className:V(e.style===`active`&&`spin`),size:17})]}),(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`span`,{className:`node-status`,children:e.state}),e.reason!==void 0&&(0,W.jsx)(`span`,{className:`node-reason`,title:e.reason,children:e.reason}),e.awaits!==void 0&&(0,W.jsx)(`span`,{className:`node-awaits`,title:e.awaits,children:e.awaits}),(0,W.jsx)(tJ,{type:`source`,position:$.Right})]})}function IX({data:e,id:t,markerEnd:n,style:r}){return(0,W.jsx)(FJ,{id:t,path:LX(e?.points??[]),markerEnd:n,style:r})}function LX(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var RX={dagNode:FX},zX={routed:IX};function BX({nodes:e,selectedNodeId:t,onSelectNode:n,journalSeq:r}){let i=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)jX(n.status)&&t.set(n.id,SX(n));return t},[e]),a=(0,H.useMemo)(()=>new Map(e.map(e=>[e.id,TX(e)])),[e]),{nodes:o,edges:s}=(0,H.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),r=HL({nodes:e.map(e=>({id:e.id,label:e.label,kind:e.kind,state:e.status,...a.get(e.id)===void 0?{}:{lines:1}})),edges:e.flatMap(e=>(e.task.deps??[]).filter(e=>n.has(e)).map(t=>({id:`${t}->${e.id}`,source:t,target:e.id})))});return{nodes:r.nodes.map(e=>({id:e.id,type:`dagNode`,position:{x:e.x,y:e.y},data:{label:e.label,kind:e.kind,state:e.state,style:e.style,selected:e.id===t,...i.get(e.id)===void 0?{}:{reason:i.get(e.id)},...a.get(e.id)===void 0?{}:{awaits:a.get(e.id)}},width:e.width,height:e.height,measured:{width:e.width,height:e.height},handles:[{type:`target`,position:$.Left,x:0,y:e.height/2,width:0,height:0},{type:`source`,position:$.Right,x:e.width,y:e.height/2,width:0,height:0}]})),edges:r.edges.map(t=>({id:t.id,source:t.source,target:t.target,type:`routed`,data:{points:t.points},animated:e.find(({id:e})=>e===t.target)?.status===`running`}))}},[e,i,a,t]);return(0,W.jsxs)(`div`,{className:`graph-wrap`,"data-journal-seq":r,children:[(0,W.jsxs)(PY,{nodes:o,edges:s,colorMode:`dark`,nodeTypes:RX,edgeTypes:zX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,fitView:!0,minZoom:.05,onInit:e=>void e.fitView(),onNodeClick:(e,t)=>n(t.id),"aria-label":`DAG execution graph`,children:[(0,W.jsx)(VY,{color:`var(--border)`,gap:22}),(0,W.jsx)(XY,{showInteractive:!1})]}),(0,W.jsx)(`ol`,{className:`accessible-node-list`,"aria-label":`DAG nodes`,children:e.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.label,`: `,e.status,i.get(e.id)===void 0?``:` — ${i.get(e.id)}`,a.get(e.id)===void 0?``:` — ${a.get(e.id)}`]})},e.id))})]})}function VX({value:e,label:t=`Record`}){return e==null?(0,W.jsx)(`span`,{children:`Not recorded`}):typeof e==`boolean`?(0,W.jsx)(`span`,{children:e?`Yes`:`No`}):typeof e==`string`||typeof e==`number`?(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:String(e)}):Array.isArray(e)?e.length===0?(0,W.jsx)(`span`,{children:`None`}):(0,W.jsx)(`ol`,{"aria-label":t,children:e.map((e,n)=>(0,W.jsx)(`li`,{"aria-label":`${t}.${n}`,children:(0,W.jsx)(VX,{label:`${t}.${n}`,value:e})},n))}):typeof e==`object`?(0,W.jsx)(`div`,{className:`structured-fields`,children:Object.entries(e).map(([e,n])=>(0,W.jsxs)(`fieldset`,{"aria-label":`${t}.${e}`,children:[(0,W.jsx)(`legend`,{children:e.replaceAll(`_`,` `)}),(0,W.jsx)(VX,{label:`${t}.${e}`,value:n})]},e))}):(0,W.jsx)(`span`,{children:`Not recorded`})}function HX(e,t){let[n,r]=(0,H.useState)(0);return{host:II(`host`,()=>e.host(),n),unwatched:II(`unwatched`,()=>e.unwatched(),n),refresh:(0,H.useCallback)(()=>{r(e=>e+1),t?.()},[t])}}var UX=[`Run`,`Node`,`Provider`,`Age (ms)`,`Proof`];function WX(e,t){let n=e?.runs??[];if(t===void 0)return n;let r=new Map(t.map(e=>[e.id,e])),i=new Set(n.map(e=>e.run_id));return[...n.flatMap(e=>{let t=r.get(e.run_id);if(t===void 0)return[];let{done:n,failed:i,running:a}=t.nodes;return[{run_id:e.run_id,state:t.state,node_counts:{...e.node_counts,done:n,failed:i,running:a}}]}),...(e===void 0?[]:t).filter(e=>!i.has(e.id)).map(({id:e,state:t,nodes:{done:n,failed:r,running:i}})=>({run_id:e,state:t,node_counts:{done:n,failed:r,running:i}}))]}function GX({client:e,onRefresh:t,list:n,rows:r,listError:i,children:a}){let{host:o,unwatched:s,refresh:c}=HX(e,t),l=o.value?.reading;return(0,W.jsx)(sf,{className:`min-h-0 flex-1`,children:(0,W.jsxs)(`section`,{"aria-label":`Host`,className:`channel-view host-page`,children:[(0,W.jsxs)(`h2`,{children:[`This host`,l&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`output`,{"aria-label":`Host name`,className:`host-name`,children:l.host})]})]}),(0,W.jsx)(Pa,{onClick:c,children:`Refresh host`}),(o.error||s.error)&&(0,W.jsx)(`p`,{role:`alert`,children:o.error?.message??s.error?.message}),o.loading&&(0,W.jsx)(`p`,{role:`status`,children:`Reading host…`}),l&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Runs root`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Runs root path`,children:l.root})})]}),l.root_error&&(0,W.jsx)(`p`,{role:`alert`,children:l.root_error}),(0,W.jsxs)(`section`,{"aria-label":`Free space`,children:[(0,W.jsx)(`h3`,{children:`Free space`}),l.free_space.map((e,t)=>(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Filesystem`}),(0,W.jsx)(`dd`,{children:e.roots.map((e,t)=>(0,W.jsxs)(`span`,{children:[t>0&&` · `,e.role,`:`,` `,(0,W.jsx)(`output`,{"aria-label":`Filesystem root path`,children:e.path??`unresolved`}),e.measured_at&&(0,W.jsxs)(W.Fragment,{children:[` `,`(measured at`,` `,(0,W.jsx)(`output`,{"aria-label":`Measured root ancestor`,children:e.measured_at}),`)`]})]},e.role))}),(0,W.jsx)(`dt`,{children:`Free bytes`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Free capacity bytes`,children:e.free_bytes??`Unknown`})}),(0,W.jsx)(`dt`,{children:`Total bytes`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Total capacity bytes`,children:e.total_bytes??`Unknown`})}),e.error&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`Error`}),(0,W.jsx)(`dd`,{children:e.error})]})]},e.roots[0]?.path??t))]}),(0,W.jsxs)(`section`,{"aria-label":`Providers and dispatches`,children:[(0,W.jsx)(`h3`,{children:`Providers and dispatches`}),l.dispatches.length===0?(0,W.jsx)(`p`,{children:`No live dispatches`}):(0,W.jsx)(`section`,{"aria-label":`Providers and dispatches table`,className:`host-table`,children:(0,W.jsxs)(`table`,{children:[(0,W.jsx)(`thead`,{children:(0,W.jsx)(`tr`,{children:UX.map(e=>(0,W.jsx)(`th`,{children:e},e))})}),(0,W.jsx)(`tbody`,{children:l.dispatches.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{"data-label":`Run`,children:e.run}),(0,W.jsx)(`td`,{"data-label":`Node`,children:e.node}),(0,W.jsx)(`td`,{"data-label":`Provider`,children:e.launcher}),(0,W.jsx)(`td`,{"data-label":`Age (ms)`,children:(0,W.jsx)(`output`,{"aria-label":`Dispatch age milliseconds`,className:`host-age`,children:e.age_ms??`Unknown`})}),(0,W.jsxs)(`td`,{"data-label":`Proof`,children:[e.proof,e.unproven&&`: ${e.unproven}`]})]},`${e.run}/${e.node}`))})]})})]}),(0,W.jsxs)(`section`,{"aria-label":`Gone dispatches`,children:[(0,W.jsx)(`h3`,{children:`Gone dispatches`}),l.gone.map(e=>(0,W.jsxs)(`p`,{children:[e.run,` · `,e.node,` · `,e.reason]},`${e.run}/${e.node}`))]}),l.skipped.map(e=>(0,W.jsxs)(`p`,{children:[e.path,`: `,e.reason]},e.path))]}),(0,W.jsxs)(`section`,{"aria-label":`Unwatched runs`,children:[(0,W.jsxs)(`h3`,{children:[`Unwatched runs: `,s.value?.reported.length??`…`]}),s.value?.reported.map(e=>(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:e.run}),(0,W.jsxs)(`dd`,{children:[e.standing,` · `,e.why_not_watched]})]},e.run)),s.value?.unresolved.map(e=>(0,W.jsx)(`p`,{children:e},e))]}),(0,W.jsxs)(`section`,{"aria-label":`Runs on the host`,children:[(0,W.jsx)(`h3`,{children:`Runs on the host`}),i&&(0,W.jsxs)(`p`,{role:`alert`,children:[`Listing unavailable: `,i.message]}),WX(n,r).map(e=>(0,W.jsx)(`p`,{children:[e.run_id,e.state,kX(e.node_counts)].filter(Boolean).join(` · `)},e.run_id))]}),(0,W.jsxs)(`details`,{"aria-label":`Provider health`,children:[(0,W.jsx)(`summary`,{children:`Provider health`}),(0,W.jsx)(VX,{value:n?.provider_health})]}),a]})})}function KX(e,t,n){let{value:r,error:i}=II(t?`host-listing`:void 0,async()=>{let[t,n]=await Promise.all([e.listRuns(!0),e.listProjects()]);return{...t,runs:n.projects.flatMap(e=>e.runs),next_cursor:void 0}},n);return t?{list:r,error:i}:{}}function qX(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function JX(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function YX(e){return e}var XX=[],ZX=`skip`;function QX(e,t,n,r){if(!e||typeof e!=`object`)throw Error("Unexpected value `"+e+"` for `tree`, expected node");let i=!0,a,o,s,c;if(typeof n==`function`||n&&typeof n==`object`?(a=t,o=n,r&&(i=!1)):(o=t,n&&(i=!1)),typeof o==`function`)s=o;else if(o&&typeof o==`object`){if(!(o.enter===null||o.enter===void 0))if(typeof o.enter==`function`)s=o.enter;else throw Error("Unexpected value `"+o.enter+"` for `visitors.enter`, expected optional visitor");if(typeof o.exit==`function`)c=o.exit;else throw Error("Unexpected value `"+o.exit+"` for `visitors.exit`, expected visitor (pass a visitor directly if you only want an enter visitor)")}else throw Error("Unexpected value `"+o+"` for `enter` or `visitors`, expected visitor or object with visitors");let l=lb(a),u=i?1:-1;d(e,void 0,[])();function d(e,t,n){let r=e&&typeof e==`object`?e:{};if(typeof r.type==`string`){let t=typeof r.tagName==`string`?r.tagName:typeof r.name==`string`?r.name:void 0;Object.defineProperty(o,"name",{value:`node (`+YX(e.type+(t?`<`+t+`>`:``))+`)`})}return o;function o(){let r=!a||l(e,t,n[n.length-1]||void 0),o=XX;if(s&&r&&(o=$X(s(e,n,t)),o[0]===!1))return o;if(`children`in e&&e.children){let t=e;if(t.children&&o[0]!==`skip`){let e=(i?-1:t.children.length)+u,r=[...n,t];for(;e>-1&&e<t.children.length;){let n=t.children[e],i=d(n,e,r)();if(i[0]===!1)return i;e=typeof i[1]==`number`?i[1]:e+u}}}if(c&&r){let r=$X(c(e,n,t));if(r[0]===`skip`)throw Error("Unexpected value `"+r[0]+"` from `exit`, expected `CONTINUE`, `EXIT`, index, or nothing");if(r[0]===!1||typeof r[1]==`number`)return r}return o}}}function $X(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?XX:[e]}function eZ(e,t,n){let r=lb((n||{}).ignore||[]),i=tZ(t),a=-1;for(;++a<i.length;)QX(e,o);function o(e,t,n){if(e.type===`text`&&typeof n==`number`)return s(e,t,n);if(r(e,n,t[t.length-1]))return ZX}function s(e,t,n){let r=t[t.length-1],o=i[a][0],s=i[a][1],c=0,l=!1,u=[];o.lastIndex=0;let d=o.exec(e.value);for(;d;){let n=d.index,r={index:d.index,input:d.input,stack:[...t,e]},i=s(...d,r);if(typeof i==`string`&&(i=i.length>0?{type:`text`,value:i}:void 0),i===!1)o.lastIndex=n+1;else{if(c!==n&&f({type:`text`,value:e.value.slice(c,n)}),Array.isArray(i))for(let e of i)f(e);else i&&f(i);c=n+d[0].length,l=!0}if(!o.global)break;d=o.exec(e.value)}return l?(c<e.value.length&&f({type:`text`,value:e.value.slice(c)}),r.children.splice(n,1,...u)):u=[e],n+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function tZ(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([nZ(e[0]),rZ(e[1])])}return t}function nZ(e){return typeof e==`string`?new RegExp(JX(e),`g`):e}function rZ(e){return typeof e==`function`?e:function(){return e}}var iZ=`phrasing`,aZ=[`autolink`,`link`,`image`,`label`];function oZ(){return{transforms:[mZ],enter:{literalAutolink:cZ,literalAutolinkEmail:lZ,literalAutolinkHttp:lZ,literalAutolinkWww:lZ},exit:{literalAutolink:pZ,literalAutolinkEmail:fZ,literalAutolinkHttp:uZ,literalAutolinkWww:dZ}}}function sZ(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:iZ,notInConstruct:aZ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:iZ,notInConstruct:aZ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:iZ,notInConstruct:aZ}]}}function cZ(e){this.enter({type:`link`,title:null,url:``,children:[],position:void 0},e)}function lZ(e){this.config.enter.autolinkProtocol.call(this,e)}function uZ(e){this.config.exit.autolinkProtocol.call(this,e)}function dZ(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function fZ(e){this.config.exit.autolinkEmail.call(this,e)}function pZ(e){this.exit(e)}function mZ(e){eZ(e,[[/(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,hZ],[/(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,vZ],[/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,_Z],[/(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,gZ]],{ignore:[`link`,`linkReference`]})}function hZ(e,t,n,r,i){if(!xZ(i))return!1;let a=``;if(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),zg(n.charCodeAt(0))||!yZ(n))return!1;let o=bZ(n+r),s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0],position:void 0}],position:void 0};return o[1]?[s,{type:`text`,value:o[1],position:void 0}]:s}function gZ(e,t,n){return!/[\d\-_]$/.test(n)&&{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n,position:void 0}],position:void 0}}function _Z(e,t,n){if(/[\d\-_]$/.test(n))return!1;let r=`mailto:`+t+`@`+n;return{type:`link`,title:null,url:r,children:[{type:`text`,value:r,position:void 0}],position:void 0}}function vZ(e,t,n,r,i){if(/[\d\-_]$/.test(n)||r&&(!/[A-Za-z]$/.test(r)||i.input.charAt(i.index+e.length)===`@`))return!1;let a=`xmpp:`+t+`@`+n+(r||``);return{type:`link`,title:null,url:a,children:[{type:`text`,value:a,position:void 0}],position:void 0}}function yZ(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[\dA-Za-z]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[\dA-Za-z]/.test(t[t.length-2])))}function bZ(e){let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n===33||n===34||n===38||n===39||n===41||n===44||n===46||n===58||n===59||n===60||n===62||n===63||n===93||n===125)t--;else break}if(t===e.length)return[e,void 0];let n=e.slice(t);e=e.slice(0,t);let r=n.indexOf(`)`),i=qX(e,`(`),a=qX(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function xZ(e){let t=e.input.charCodeAt(e.index-1);return e.index===0||Bg(t)||zg(t)}jZ.peek=AZ;function SZ(){this.buffer()}function CZ(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function wZ(){this.buffer()}function TZ(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function EZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=kg(this.sliceSerialize(e)).toLowerCase(),n.label=t}function DZ(e){this.exit(e)}function OZ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=kg(this.sliceSerialize(e)).toLowerCase(),n.label=t}function kZ(e){this.exit(e)}function AZ(){return`[`}function jZ(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function MZ(){return{enter:{gfmFootnoteCallString:SZ,gfmFootnoteCall:CZ,gfmFootnoteDefinitionLabelString:wZ,gfmFootnoteDefinition:TZ},exit:{gfmFootnoteCallString:EZ,gfmFootnoteCall:DZ,gfmFootnoteDefinitionLabelString:OZ,gfmFootnoteDefinition:kZ}}}function NZ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:jZ},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
96
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?FZ:PZ))),s(),o}}function PZ(e,t,n){return t===0?e:FZ(e,t,n)}function FZ(e,t,n){return(n?``:` `)+e}var IZ=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];VZ.attention=HZ,VZ.peek=UZ;function LZ(){return{canContainEols:[`delete`],enter:{strikethrough:zZ},exit:{strikethrough:BZ}}}function RZ(){return{handlers:{delete:VZ},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:IZ}]}}function zZ(e){this.enter({type:`delete`,children:[],position:void 0},e)}function BZ(e){this.exit(e)}function VZ(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function HZ(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function UZ(){return`~`}function WZ(e){return e.length}function GZ(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||WZ,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=KZ(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=qZ(r[d]);else{let e=qZ(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u],r=n.fillRows===!1?Math.max(1,o[u===1?0:u].length):l;d=-1;let i=[];for(;++d<r;){let o=e[d]||``,s=``,l=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];if(n===114)s=` `.repeat(e);else if(n===99){let t=e/2;e%2?(s=` `.repeat(t+.5),l=` `.repeat(t-.5)):(s=` `.repeat(t),l=s)}else l=` `.repeat(e)}n.delimiterStart!==!1&&!d&&i.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&o===``)&&(n.delimiterStart!==!1||d)&&i.push(` `),n.alignDelimiters!==!1&&i.push(s),i.push(o),n.alignDelimiters!==!1&&i.push(l),n.padding!==!1&&i.push(` `),(n.delimiterEnd!==!1||d!==r-1)&&i.push(`|`)}m.push(n.delimiterEnd===!1?i.join(``).replace(/ +$/,``):i.join(``))}return m.join(`
|
|
97
|
+
`)}function KZ(e){return e==null?``:String(e)}function qZ(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function JZ(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),YZ);return i(),o}function YZ(e,t,n){return`>`+(n?``:` `)+e}function XZ(e,t){return ZZ(e,t.inConstruct,!0)&&!ZZ(e,t.notInConstruct,!1)}function ZZ(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function QZ(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
98
|
+
`&&XZ(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
99
|
+
`}function $Z(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function eQ(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function tQ(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function nQ(e,t,n,r){let i=tQ(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(eQ(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,rQ);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max($Z(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
100
100
|
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
101
101
|
`),a&&(u+=s.move(a+`
|
|
102
|
-
`)),u+=s.move(c),l(),u}function
|
|
103
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function
|
|
102
|
+
`)),u+=s.move(c),l(),u}function rQ(e,t,n){return(n?``:` `)+e}function iQ(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function aQ(e,t,n,r){let i=iQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
103
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function oQ(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function sQ(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function cQ(e,t,n){let r=Xg(e),i=Xg(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}lQ.peek=uQ;function lQ(e,t,n,r){let i=oQ(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=cQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=sQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=cQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+sQ(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function uQ(e,t,n){return n.options.emphasis||`*`}function dQ(e,t){let n=!1;return bb(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&gg(e)&&(t.options.setext||n))}function fQ(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(dQ(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
104
104
|
`,after:`
|
|
105
105
|
`});return r(),t(),o+`
|
|
106
106
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
107
107
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
108
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=
|
|
108
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=sQ(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}pQ.peek=mQ;function pQ(e){return e.value||``}function mQ(){return`<`}hQ.peek=gQ;function hQ(e,t,n,r){let i=iQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function gQ(){return`!`}_Q.peek=vQ;function _Q(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function vQ(){return`!`}yQ.peek=bQ;function yQ(e,t,n){let r=e.value||``,i="`",a=-1;for(;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;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function bQ(){return"`"}function xQ(e,t){let n=gg(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}SQ.peek=CQ;function SQ(e,t,n,r){let i=iQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(xQ(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function CQ(e,t,n){return xQ(e,n)?`<`:`[`}wQ.peek=TQ;function wQ(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function TQ(){return`[`}function EQ(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function DQ(e){let t=EQ(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function OQ(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function kQ(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function AQ(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?OQ(n):EQ(n),s=e.ordered?o===`.`?`)`:`.`:DQ(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.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&&(c=!0),kQ(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function jQ(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function MQ(e,t,n,r){let i=jQ(n),a=n.bulletCurrent||EQ(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function NQ(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var PQ=lb([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function FQ(e,t,n,r){return(e.children.some(function(e){return PQ(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function IQ(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}LQ.peek=RQ;function LQ(e,t,n,r){let i=IQ(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=cQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=sQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=cQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+sQ(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function RQ(e,t,n){return n.options.strong||`*`}function zQ(e,t,n,r){return n.safe(e.value,r)}function BQ(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function VQ(e,t,n){let r=(kQ(n)+(n.options.ruleSpaces?` `:``)).repeat(BQ(n));return n.options.ruleSpaces?r.slice(0,-1):r}var HQ={blockquote:JZ,break:QZ,code:nQ,definition:aQ,emphasis:lQ,hardBreak:QZ,heading:fQ,html:pQ,image:hQ,imageReference:_Q,inlineCode:yQ,link:SQ,linkReference:wQ,list:AQ,listItem:MQ,paragraph:NQ,root:FQ,strong:LQ,text:zQ,thematicBreak:VQ};function UQ(){return{enter:{table:WQ,tableData:JQ,tableHeader:JQ,tableRow:KQ},exit:{codeText:YQ,table:GQ,tableData:qQ,tableHeader:qQ,tableRow:qQ}}}function WQ(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[],position:void 0},e),this.data.inTable=!0}function GQ(e){this.exit(e),this.data.inTable=void 0}function KQ(e){this.enter({type:`tableRow`,children:[],position:void 0},e)}function qQ(e){this.exit(e)}function JQ(e){this.enter({type:`tableCell`,children:[],position:void 0},e)}function YQ(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,XQ));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function XQ(e,t){return t===`|`?t:e}function ZQ(e){let{tableCellPadding:t,tablePipeAlign:n,stringLength:r}=e||{},i=t?` `:`|`;return{handlers:{inlineCode:d,table:a,tableCell:s,tableRow:o},join:[QQ],unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
109
109
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}]};function a(e,t,n,r){let i=l(e,n,r),a=i[0];if(a){let t=e.align?e.align.length:0,n=-1;if(!t)for(;++n<i.length;)i[n].length>t&&(t=i[n].length);for(;a.length<t;)a.push(``)}return c(i,e.align)}function o(e,t,n,r){let i=c([u(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
110
|
-
`))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:i,after:i});return o(),a(),s}function c(e,i){return WZ(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=VQ.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function ZQ(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&QQ(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function QQ(e,t){let n=!1;return bb(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&gg(e)&&(t.options.setext||n))}function $Q(){return{exit:{taskListCheckValueChecked:t$,taskListCheckValueUnchecked:t$,paragraph:n$}}}function e$(){return{handlers:{paragraph:r$},join:[i$]}}function t$(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function n$(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start={...n.position.start}))}}this.exit(e)}function r$(e,t,n,r){if(!t||t.type!==`listItem`||a$(t)!==e)return VQ.paragraph(e,t,n,r);let i=`[`+(t.checked?`x`:` `)+`] `,a=n.createTracker(r);return a.move(i),i+VQ.paragraph(e.children.length>0?e:{type:`paragraph`,children:[{type:`text`,value:` `}]},t,n,{...r,...a.current()})}function i$(e,t,n){if(!(e.type===`definition`&&n.type===`listItem`))return;let r=a$(n);if(r&&n.children.indexOf(e)<n.children.indexOf(r))return 0}function a$(e){if(typeof e.checked==`boolean`)for(let t of e.children){if(t.type===`paragraph`)return t;if(t.type!==`definition`)return}}function o$(){return[aZ(),jZ(),IZ(),HQ(),$Q()]}function s$(e){return{extensions:[oZ(),MZ(e),LZ(),XQ(e),e$()]}}var c$={tokenize:S$,partial:!0},l$={tokenize:C$,partial:!0},u$={tokenize:w$,partial:!0},d$={tokenize:T$,partial:!0},f$={tokenize:E$,partial:!0},p$={name:`wwwAutolink`,tokenize:b$,previous:D$},m$={name:`protocolAutolink`,tokenize:x$,previous:O$},h$={name:`emailAutolink`,tokenize:y$,previous:k$},g$={};function _$(){return{text:g$}}for(var v$=48;v$<123;)g$[v$]=h$,v$++,v$===58?v$=65:v$===91&&(v$=97);g$[43]=h$,g$[45]=h$,g$[46]=h$,g$[95]=h$,g$[72]=[h$,m$],g$[104]=[h$,m$],g$[87]=[h$,p$],g$[119]=[h$,p$];function y$(e,t,n){let r=this,i,a;return o;function o(t){return!A$(t)||!k$.call(r,r.previous)||j$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return A$(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(f$,u,l)(t):t===45||t===95||jg(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Ag(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function b$(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!D$.call(r,r.previous)||j$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(c$,e.attempt(l$,e.attempt(u$,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function x$(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&O$.call(r,r.previous)&&!j$(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Ag(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ng(t)||Lg(t)||Bg(t)||zg(t)?n(t):e.attempt(l$,e.attempt(u$,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function S$(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function C$(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(d$,c,s)(t):t===null||Lg(t)||Bg(t)||t!==45&&zg(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function w$(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.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?e.check(d$,t,a)(o):o===null||Lg(o)||Bg(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function T$(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Lg(o)||Bg(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Lg(e)||Bg(e)?t(e):r(e)}function a(e){return Ag(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Ag(t)?(e.consume(t),o):n(t)}}function E$(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return jg(e)?n(e):t(e)}}function D$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Lg(e)}function O$(e){return!Ag(e)}function k$(e){return!(e===47||A$(e))}function A$(e){return e===43||e===45||e===46||e===95||jg(e)}function j$(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var M$={tokenize:B$,partial:!0};function N$(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:L$,continuation:{tokenize:R$},exit:z$}},text:{91:{name:`gfmFootnoteCall`,tokenize:I$},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:P$,resolveTo:F$}}}}function P$(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=kg(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function F$(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function I$(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Lg(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(kg(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Lg(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function L$(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Lg(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=kg(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Lg(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Ug(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function R$(e,t,n){return e.check(i_,t,e.attempt(M$,t,n))}function z$(e){e.exit(`gfmFootnoteDefinition`)}function B$(e,t,n){let r=this;return Ug(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function V$(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Sg(o,o.length,0,Zg(s,e.slice(r+1,n),t)),Sg(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Sg(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Xg(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Xg(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var H$=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){U$(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function U$(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function W$(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function G$(){return{flow:{null:{name:`table`,tokenize:K$,resolveAll:q$}}}}function K$(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):K(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Rg(t)?Ug(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Lg(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Rg(t)?Ug(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Rg(t)?Ug(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||K(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Rg(t)?Ug(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||K(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||K(n)?(e.exit(`tableRow`),t(n)):Rg(n)?Ug(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Lg(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function q$(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new H$;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Y$(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=J$(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=J$(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=J$(f,t,o,i,n,d)):(o[0]=o[1],d=J$(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Y$(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=W$(t.events,n))}return e}function J$(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},X$(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=X$(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=X$(t.events,n[2]),a=X$(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},X$(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Y$(e,t,n,r,i){let a=[],o=X$(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function X$(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Z$={name:`tasklistCheck`,tokenize:$$};function Q$(){return{text:{91:Z$}}}function $$(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Lg(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return K(r)?t(r):Rg(r)?e.check({tokenize:e1},t,n)(r):n(r)}}function e1(e,t,n){return Ug(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function t1(e){return Tg([_$(),N$(),V$(e),G$(),Q$()])}var n1={};function r1(e){let t=this,n=e||n1,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(t1(n)),a.push(o$()),o.push(s$(n))}var i1=new Set([`http:`,`https:`,`mailto:`]);function a1(e){try{return new URL(e)}catch{return}}function o1(e){let t=e===void 0?void 0:a1(e)?.protocol;return t!==void 0&&i1.has(t)?e:void 0}var s1={target:`_blank`,rel:`noopener noreferrer`},c1=typeof window>`u`?H.useEffect:H.useLayoutEffect;function l1(e,t){let n=(0,H.useRef)(null);return c1(()=>{let t=n.current;if(!t||e===void 0)return;let r=()=>{t.removeAttribute(`data-otg-table-cut`);let e=t.querySelector(`table`);if(!e||t.scrollHeight<=t.clientHeight)return;let n=e.getBoundingClientRect().top-t.getBoundingClientRect().top;t.toggleAttribute(`data-otg-table-cut`,n<t.clientHeight)};r();let i=t.clientWidth,a=new ResizeObserver(()=>{t.clientWidth!==i&&(i=t.clientWidth,r())});a.observe(t);let o=!0;return document.fonts?.ready.then(()=>{o&&r()}),()=>{o=!1,a.disconnect()}},[e,t]),n}function u1(e){return e.tagName===`img`?{type:`text`,value:String(e.properties?.alt||`image`)}:(e.children&&=e.children.map(u1),e)}function d1(){let e=t=>{t.tagName===`a`?u1(t):t.children?.forEach(e)};return e}function f1({href:e,children:t}){let n=o1(e);return(0,W.jsx)(`a`,{href:n,...n===void 0?{}:s1,children:t})}var p1={a:({href:e,children:t})=>(0,W.jsx)(f1,{href:e,children:t}),img:({src:e,alt:t})=>(0,W.jsx)(f1,{href:typeof e==`string`?e:void 0,children:t||`image`})},m1=[r1],h1=[d1];function g1({source:e,clamp:t}){let n=t!==void 0&&Number.isInteger(t)&&t>0?t:void 0,r=l1(n,e),i=n===void 0?void 0:{WebkitLineClamp:n,maxHeight:`calc(${n} * 1lh)`};return(0,W.jsx)(`div`,{className:n===void 0?`otg-markdown`:`otg-markdown otg-markdown--clamped`,ref:r,style:i,children:(0,W.jsx)(vx,{components:p1,rehypePlugins:h1,remarkPlugins:m1,children:e})})}function _1({title:e,body:t,badges:n,meta:r,links:i,actions:a,clamp:o,children:s,className:c,...l}){let u=(0,H.useId)();return(0,W.jsx)(`article`,{...l,"aria-labelledby":u,className:c?`otg-card ${c}`:`otg-card`,children:(0,W.jsxs)(`div`,{className:`otg-card__surface`,children:[(0,W.jsxs)(`div`,{className:`otg-card__header`,children:[n!=null&&(0,W.jsx)(`div`,{className:`otg-card__badges`,children:n}),(0,W.jsx)(`h3`,{className:`otg-card__title`,id:u,children:e}),a!=null&&(0,W.jsx)(`div`,{className:`otg-card__actions`,children:a})]}),r!=null&&(0,W.jsx)(`div`,{className:`otg-card__meta`,children:r}),i!=null&&(0,W.jsx)(`div`,{className:`otg-card__links`,children:i}),t?(0,W.jsx)(g1,{source:t,...o===void 0?{}:{clamp:o}}):null,s]})})}var v1=new Map([[`github.com`,`GitHub`],[`linear.app`,`Linear`]]);function y1(e){return v1.get(a1(e)?.hostname??``)??`tracker`}function b1({url:e,label:t,...n}){let r=o1(e);return(0,W.jsx)(`a`,{"aria-label":`Open ${y1(e)} issue ${t}`,...n,href:r,...s1,className:[`otg-source-link`,n.className].filter(Boolean).join(` `),children:t})}var x1=15e3;function S1(e,t,n){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),{key:m,phase:h,followUp:g}=e,_=h===`sending`||g?.phase===`failed`||g?.phase===`sending`;return(0,H.useLayoutEffect)(()=>{if(f(!1),_)return;let e=setTimeout(()=>f(!0),x1);return()=>clearTimeout(e)},[`${m}:${h}:${g?.kind??``}:${g?.phase??``}`,_]),(0,H.useEffect)(()=>{c(!1),u(``)},[m]),(0,H.useEffect)(()=>{g?.kind===`note`&&g.phase===`done`&&(c(!1),u(``))},[g]),(0,H.useEffect)(()=>{if(!d||r||s)return;let e=p.current?.contains(document.activeElement)??!1;a&&e||t()},[d,r,a,s,t]),(0,H.useEffect)(()=>{let e=p.current;if(e===null)return;let t=()=>n(e.getBoundingClientRect().height);t();let r=new ResizeObserver(t);return r.observe(e),()=>{r.disconnect(),n(0)}},[n]),{holds:{ref:p,onFocus:()=>o(!0),onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||o(!1)},onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1)},writing:s,setWriting:c,text:l,setText:u}}var C1={answer:`Answered`,complete:`Completed`,dismiss:`Dismissed`},w1={answer:`Answering`,complete:`Completing`,dismiss:`Dismissing`},T1={complete:`Reopened`,dismiss:`Restored`};function E1(e){let{action:t,title:n,phase:r,error:i,followUp:a}=e;if(r===`failed`)return`Not ${C1[t].toLowerCase()}: ${n}. ${i??``}`.trim();let o=t===`answer`?`Reopened`:T1[t],s=t===`dismiss`?`Reason`:`Comment`;return a?.phase===`failed`?a.kind===`undo`?`Not ${o.toLowerCase()}: ${n}. ${a.error??``}`.trim():`${s} not saved: ${n}. ${a.error??``}`.trim():a?.phase===`done`?a.kind===`undo`?`${o}: ${n}`:`${s} saved: ${n}`:r===`sending`?`${w1[t]}: ${n}…`:`${C1[t]}: ${n}`}function D1({toast:e,onUndo:t,onNote:n,onClose:r,onRoom:i}){let{holds:a,writing:o,setWriting:s,text:c,setText:l}=S1(e,r,i),u=(0,H.useId)(),{action:d,phase:f,followUp:p}=e,m=f===`failed`||p?.phase===`failed`,h=d!==`answer`&&f!==`failed`,g=p?.kind===`undo`&&p.phase===`done`,_=d===`dismiss`?`Add reason`:`Add comment`,v=d===`dismiss`?`Reason`:`Comment`;return(0,W.jsxs)(`section`,{"aria-label":`Action result`,className:`human-items-toast`,"data-phase":p?.phase??f,"data-tone":m?`failure`:`success`,...a,children:[(0,W.jsx)(`p`,{className:`human-items-toast-message`,role:m?`alert`:`status`,children:E1(e)}),h&&!g&&(0,W.jsxs)(`div`,{className:`human-items-toast-actions`,children:[(0,W.jsx)(O1,{label:d===`dismiss`?`Restore`:`Reopen`,onPress:t,reopen:e.reopen,sending:p?.kind===`undo`&&p.phase===`sending`}),!o&&(0,W.jsx)(`button`,{className:`human-items-toast-action`,onClick:()=>s(!0),type:`button`,children:_})]}),h&&!g&&o&&(0,W.jsxs)(`form`,{className:`human-items-toast-note`,onSubmit:e=>{e.preventDefault(),c.trim()!==``&&n(c)},children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:u,children:v}),(0,W.jsx)(`input`,{autoFocus:!0,id:u,onChange:e=>l(e.target.value),placeholder:`${v}, then Enter`,readOnly:p?.kind===`note`&&p.phase===`sending`,value:c}),(0,W.jsx)(`button`,{className:`human-items-toast-action`,type:`submit`,children:p?.kind===`note`&&p.phase===`failed`?`Send again`:`Send`})]}),(0,W.jsx)(`button`,{"aria-label":`Close`,className:`human-items-toast-close`,onClick:r,type:`button`,children:(0,W.jsx)(un,{"aria-hidden":`true`,size:14})})]})}function O1({label:e,reopen:t,sending:n,onPress:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),c=(0,H.useId)();return t?.available===!1?(0,W.jsxs)(`fieldset`,{"aria-label":`${e} (unavailable)`,className:`human-items-toast-action human-items-unavailable`,onPointerEnter:()=>s(!0),onPointerLeave:()=>s(!1),children:[(0,W.jsx)(`button`,{"aria-describedby":c,disabled:!0,type:`button`,children:e}),(0,W.jsx)(`sup`,{className:`human-items-why-anchor`,children:(0,W.jsx)(`button`,{"aria-controls":c,"aria-expanded":i,"aria-label":`Why ${e} is unavailable`,className:`human-items-why`,onClick:()=>a(e=>!e),type:`button`,children:`?`})}),(0,W.jsx)(`span`,{className:`human-items-why-tip`,hidden:!(i||o),id:c,role:`tooltip`,children:t.reason})]}):(0,W.jsx)(`button`,{"aria-busy":n,className:`human-items-toast-action`,onClick:()=>{n||r()},type:`button`,children:n?`${e}…`:e})}var k1=MA.map(e=>({wire:e,label:NA[e]}));function A1(e){return NA[e.priority]}function j1(e){return e.kind===`task`?`Task`:`Question`}var M1={open:`Open`,answered:`Answered`,completed:`Completed`,dismissed:`Dismissed`},N1=[`open`,`answered`,`completed`,`dismissed`],P1=N1.map(e=>({state:e,label:M1[e]}));function F1(e){return M1[e.state]}function I1(e){return e.state===`open`&&e.block.scope!==`nothing`}function L1(e){return e===1?`1 step`:`${e} steps`}function R1(e){let{item:t,blocked:n}=e;if(!I1(t))return[];switch(t.block.scope){case`host`:return[`blocks all work on this host`];case`plan`:return[`blocks all of ${t.block.plan}`];case`work`:return n.plans.map(({plan:e,count:t})=>`blocks ${L1(t)} in ${e}`);default:return[]}}function z1(e){let t=R1(e);return e.item.block.scope===`work`?e.blocked.plans.map(({count:e,preview:n},r)=>{let i=e-n.length,a=n.map(({node:e})=>e).join(`, `);return`${t[r]}: ${a}${i>0?` +${i} more`:``}`}).join(`; `):t.join(`; `)}function B1(e){if(e.block.scope===`host`)return`host`;let{plan:t,run:n,session:r}=e.owner;return t!==null&&n!==null?`plan ${t} / run ${n}`:t===null?n===null?`session ${r}`:`run ${n}`:`plan ${t}`}function V1(e){let t=R1(e);if(e.item.block.scope!==`work`)return t.map(t=>({phrase:t,nodes:e.nodes}));let n=0;return e.blocked.plans.map(({count:r},i)=>{let a=e.nodes.slice(n,n+r);return n+=r,{phrase:t[i]??``,nodes:a}})}function H1(e,t){return e.find(e=>e===t)}var U1=[``,`task`,`question`],W1=[``,`yes`,`no`],G1=[``,...MA],K1=N1,q1=[``,`session`,`run`,`plan`,`host`],J1={kind:``,blocking:``,priority:``,state:`open`,source:``,sourceId:``};function Y1(e){let t=e.sourceId.trim();return{...e.kind===``?{}:{kind:e.kind},...e.blocking===``?{}:{blocking:e.blocking===`yes`},...e.priority===``?{}:{priority:e.priority},...e.state===`open`?{}:{state:e.state},...e.source===`host`?{host:!0}:{},...e.source!==``&&e.source!==`host`&&t!==``?{[e.source]:t}:{}}}function X1(e){return Number(e.kind!==J1.kind)+Number(e.blocking!==J1.blocking)+Number(e.priority!==J1.priority)+Number(e.state!==J1.state)+Number(e.source!==J1.source)}var Z1=[`priority`,`kind`,`source`,`blocking`,`none`],Q1=`priority`,$1=[{value:`priority`,label:`Priority`},{value:`kind`,label:`Kind`},{value:`source`,label:`Source`},{value:`blocking`,label:`Blocking`},{value:`none`,label:`None`}];function e0(e,t){let{item:n}=e;switch(t){case`priority`:return{key:n.priority,label:A1(n),rank:MA.indexOf(n.priority)};case`kind`:return{key:n.kind,label:j1(n),rank:n.kind===`task`?0:1};case`blocking`:return I1(n)?{key:`blocking`,label:`Blocking`,rank:0}:{key:`not-blocking`,label:`Not blocking`,rank:1};case`source`:{let e=B1(n);return{key:e,label:`Source: ${e}`,rank:0}}}}function t0(e,t){if(t===`none`)return[{key:`all`,items:e}];let n=new Map;return e.forEach((e,r)=>{let{key:i,label:a,rank:o}=e0(e,t),s=n.get(i);s?s.items.push(e):n.set(i,{label:a,rank:o,first:r,items:[e]})}),[...n.entries()].sort(([,e],[,t])=>e.rank-t.rank||e.first-t.first).map(([e,{label:t,items:n}])=>({key:e,label:t,items:n}))}var n0=`onepipeline-ui.human-items.group-by`;function r0(){try{return H1(Z1,window.localStorage.getItem(`onepipeline-ui.human-items.group-by`)??``)??`priority`}catch{return Q1}}function i0(){let[e,t]=(0,H.useState)(r0);return{groupBy:e,setGroupBy:(0,H.useCallback)(e=>{t(e);try{window.localStorage.setItem(n0,e)}catch{}},[])}}function a0(e){let[t,n]=(0,H.useState)(J1),[r,i]=(0,H.useState)(),a=(0,H.useMemo)(()=>{if(!e)return;let n=Y1(t);return{type:`human-items`,...Object.keys(n).length===0?{}:{filter:n},...r===void 0?{}:{item:r}}},[e,JSON.stringify(Y1(t)),r]);return(0,H.useEffect)(()=>{e||(n(J1),i(void 0))},[e]),{choice:t,setChoice:n,selectedId:r,setSelectedId:i,view:a}}function o0(e,t,n,r,i=``){let[a,o]=(0,H.useState)({}),[s,c]=(0,H.useState)({}),[l,u]=(0,H.useState)(),[d,f]=(0,H.useState)([]),[p,m]=(0,H.useState)({}),[h,g]=(0,H.useState)({}),[_,v]=(0,H.useState)(),y=(0,H.useRef)(new Set),b=(0,H.useRef)(new Map),x=(0,H.useRef)(0),S=(0,H.useRef)(void 0);S.current=l;let C=t.items,w=(0,H.useRef)(i);w.current=i,(0,H.useEffect)(()=>{g(e=>Object.keys(e).length===0?e:{})},[i]);let T=(0,H.useMemo)(()=>{if(C===void 0)return;let e=C.flatMap(e=>{if(p[e.item.id]!==void 0)return[];let t=h[e.item.id]?.view;return t===void 0||!c0(t,e)?[e]:t.item.state===r?[t]:[]}),t=t=>e.some(({item:e})=>e.id===t);for(let{view:n,at:a,filter:o}of Object.values(h))o===i&&n.item.state===r&&!t(n.item.id)&&e.splice(Math.min(a,e.length),0,n);for(let{view:n,at:r}of d)t(n.item.id)||e.splice(Math.min(r,e.length),0,n);return e},[C,d,h,p,r,i]);(0,H.useEffect)(()=>{C!==void 0&&g(e=>{let t=Object.entries(e).filter(([e,{view:t}])=>{let n=C.find(({item:t})=>t.id===e);return n===void 0?t.item.state===r:c0(t,n)});return t.length===Object.keys(e).length?e:Object.fromEntries(t)})},[C,r]);let E=t.error===void 0&&t.item===n?t.detail:void 0,D=n===void 0?void 0:h[n]?.view,O=E&&D!==void 0&&c0(D,{item:E.item})?{...E,item:D.item,reopen:D.reopen}:E,k=(0,H.useRef)(C);k.current=C;let A=(0,H.useCallback)((e,t)=>u(n=>n?.key===e?t(n):n),[]),j=(0,H.useCallback)((t,n)=>{let{id:r,title:i}=t.item;if(y.current.has(r))return;y.current.add(r);let a=++x.current,s=w.current,l=Math.max(0,k.current?.findIndex(({item:e})=>e.id===r)??0),d=n.action===`answer`;o(e=>({...e,[r]:{pending:d}})),d?f(e=>[...e,{view:t,at:l}]):m(e=>({...e,[r]:{view:t,at:l}})),u({key:a,id:r,title:i,action:n.action,phase:`sending`});let p=n.action===`answer`?e.answerHumanItem(r,n.text):n.action===`complete`?e.completeHumanItem(r):e.dismissHumanItem(r,n.reason);b.current.set(a,p),p.then(e=>{g(t=>({...t,[r]:{view:e.item,at:l,filter:s}})),o(e=>({...e,[r]:{pending:!1}})),c(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==r))),A(a,t=>({...t,phase:`done`,reopen:e.item.reopen}))},e=>{let t=l0(e);o(e=>({...e,[r]:{pending:!1,error:t}})),A(a,e=>({...e,phase:`failed`,error:t})),d||v({id:r})}).finally(()=>{y.current.delete(r),f(e=>e.filter(({view:e})=>e.item.id!==r)),m(s0(r))})},[e,A]),M=(0,H.useCallback)((e,t)=>{let n=S.current;if(n===void 0)return;let r=b.current.get(n.key);if(r===void 0||n.followUp?.phase===`sending`)return;let{key:i,id:a}=n,o=w.current;A(i,t=>({...t,followUp:{kind:e,phase:`sending`}})),r.then(n=>{if(e===`undo`&&!n.item.reopen.available){A(i,e=>({...e,followUp:void 0}));return}t(a).then(t=>{g(e=>({...e,[a]:{view:t.item,at:e[a]?.at??0,filter:o}})),A(i,n=>({...n,reopen:t.item.reopen,followUp:{kind:e,phase:`done`}}))},t=>A(i,n=>({...n,followUp:{kind:e,phase:`failed`,error:l0(t)}})))},()=>A(i,e=>({...e,followUp:void 0})))},[A]),N=(0,H.useCallback)(()=>M(`undo`,t=>e.reopenHumanItem(t)),[e,M]),P=(0,H.useCallback)(t=>M(`note`,n=>e.noteHumanItem(n,t)),[e,M]),F=(0,H.useCallback)(()=>u(void 0),[]),I=(0,H.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]);return{items:T,listError:n===void 0||T===void 0?t.error:void 0,detail:O===null?void 0:O,gone:n!==void 0&&O===null,detailError:n===void 0?void 0:t.error,writes:a,drafts:s,setDraft:I,write:j,toast:l,undo:N,note:P,closeToast:F,returned:_}}function s0(e){return t=>t[e]===void 0?t:Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))}function c0(e,t){return Date.parse(e.item.updated_at)>Date.parse(t.item.updated_at)}function l0(e){return e instanceof Error?e.message:String(e)}var u0=`data-card-action`,d0=4;function f0({client:e,live:t,choice:n,setChoice:r,selectedId:i,setSelectedId:a}){let o=o0(e,t,i,n.state,JSON.stringify(n)),{groupBy:s,setGroupBy:c}=i0(),[l,u]=(0,H.useState)(0),d=(0,H.useRef)(null),f=o.items?.find(({item:e})=>e.id===i)??o.detail,p=(0,H.useRef)(void 0);f===void 0?p.current?.item.id!==i&&(p.current=void 0):p.current=f;let m=(e,t)=>{t.action!==`answer`&&e.item.id===i&&a(void 0),o.write(e,t)},h=o.returned;(0,H.useEffect)(()=>{h!==void 0&&d.current?.querySelector(`[data-item-id="${CSS.escape(h.id)}"]`)?.scrollIntoView({block:`nearest`})},[h]);let g=t0(o.items??[],s);return(0,W.jsxs)(`section`,{"aria-label":`Action items`,className:`human-items-page`,"data-detail-open":i!==void 0,style:p0(l),children:[(0,W.jsx)(g0,{choice:n,groupBy:s,onChange:r,onGroupBy:c}),(0,W.jsxs)(`div`,{className:`human-items-body`,children:[(0,W.jsxs)(`section`,{"aria-label":`Action item list`,className:`human-items-list`,children:[o.listError&&(0,W.jsx)(`p`,{role:`alert`,children:o.listError}),o.items===void 0&&!o.listError&&(0,W.jsx)(`p`,{role:`status`,children:`Reading action items…`}),o.items?.length===0&&(0,W.jsx)(`p`,{role:`status`,children:`No action items match these filters.`}),(0,W.jsx)(`div`,{className:`human-items-groups`,onKeyDown:e=>h0(e,d.current),ref:d,children:g.map(e=>(0,W.jsx)(m0,{draftOf:e=>o.drafts[e]??``,group:e,groupBy:s,onDraft:o.setDraft,onSelect:a,onWrite:m,selectedId:i,writes:o.writes},e.key))}),(o.items?.length??0)>0&&(0,W.jsx)(`button`,{className:`card-actions-entry`,onFocus:()=>d.current?.querySelector(`[${u0}]`)?.focus(),type:`button`,children:`Card actions: use the arrow keys`})]}),i!==void 0&&(0,W.jsx)(C0,{draft:o.drafts[i]??``,error:o.detailError,detail:o.detail,gone:o.gone,lastShown:p.current,onClose:()=>a(void 0),onDraft:e=>o.setDraft(i,e),onWrite:m,state:o.writes[i],view:f})]}),o.toast&&(0,W.jsx)(D1,{onClose:o.closeToast,onNote:o.note,onRoom:u,onUndo:o.undo,toast:o.toast})]})}function p0(e){return{"--toast-room":`${e}px`}}function m0({group:e,groupBy:t,selectedId:n,writes:r,draftOf:i,onDraft:a,onSelect:o,onWrite:s}){let c=(0,H.useId)(),l=e.items.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(y0,{draft:i(e.item.id),groupBy:t,onDraft:t=>a(e.item.id,t),onSelect:()=>o(e.item.id),onWrite:s,selected:e.item.id===n,state:r[e.item.id],view:e})},e.item.id));return e.label===void 0?(0,W.jsx)(`ul`,{"aria-label":`Action items`,children:l}):(0,W.jsxs)(`section`,{"aria-labelledby":c,className:`human-items-group`,children:[(0,W.jsxs)(`h2`,{className:`human-items-group-heading`,id:c,children:[e.label,` `,(0,W.jsxs)(`span`,{className:`human-items-group-count`,children:[`(`,e.items.length,`)`]})]}),(0,W.jsx)(`ul`,{"aria-labelledby":c,children:l})]})}function h0(e,t){let n=e.target;if(t===null||!(n instanceof HTMLElement)||!n.hasAttribute(u0))return;let r=[...t.querySelectorAll(`[${u0}]`)],i=r.indexOf(n),a=e.key===`ArrowRight`||e.key===`ArrowDown`?r[Math.min(i+1,r.length-1)]:e.key===`ArrowLeft`||e.key===`ArrowUp`?r[Math.max(i-1,0)]:e.key===`Home`?r[0]:e.key===`End`?r.at(-1):void 0;a!==void 0&&(e.preventDefault(),a.focus())}function g0({choice:e,groupBy:t,onChange:n,onGroupBy:r}){let i=(0,H.useId)(),[a,o]=(0,H.useState)(!1),s=(t,r)=>n({...e,[t]:r}),c=e.source!==``&&e.source!==`host`,l=X1(e)+Number(t!==Q1);return(0,W.jsxs)(`div`,{className:`human-items-controls`,"data-open":a,children:[(0,W.jsxs)(`button`,{"aria-controls":`${i}-filters`,"aria-expanded":a,"aria-label":l>0?`Filters, ${l} changed`:`Filters`,className:`human-items-filters-toggle`,onClick:()=>o(e=>!e),type:`button`,children:[(0,W.jsx)(nn,{"aria-hidden":`true`,size:14}),`Filters`,l>0&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`human-items-filters-count`,children:l})]}),(0,W.jsxs)(`fieldset`,{className:`human-items-filters`,id:`${i}-filters`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Filter action items`}),(0,W.jsx)(`label`,{htmlFor:`${i}-group`,children:`Group by`}),(0,W.jsx)(`select`,{id:`${i}-group`,onChange:e=>r(H1(Z1,e.target.value)??`priority`),value:t,children:$1.map(({value:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`label`,{htmlFor:`${i}-kind`,children:`Kind`}),(0,W.jsxs)(`select`,{id:`${i}-kind`,onChange:e=>s(`kind`,H1(U1,e.target.value)??``),value:e.kind,children:[(0,W.jsx)(`option`,{value:``,children:`Any kind`}),(0,W.jsx)(`option`,{value:`task`,children:`Task`}),(0,W.jsx)(`option`,{value:`question`,children:`Question`})]}),(0,W.jsx)(`label`,{htmlFor:`${i}-blocking`,children:`Blocking`}),(0,W.jsxs)(`select`,{id:`${i}-blocking`,onChange:e=>s(`blocking`,H1(W1,e.target.value)??``),value:e.blocking,children:[(0,W.jsx)(`option`,{value:``,children:`Any`}),(0,W.jsx)(`option`,{value:`yes`,children:`Yes`}),(0,W.jsx)(`option`,{value:`no`,children:`No`})]}),(0,W.jsx)(`label`,{htmlFor:`${i}-priority`,children:`Priority`}),(0,W.jsxs)(`select`,{id:`${i}-priority`,onChange:e=>s(`priority`,H1(G1,e.target.value)??``),value:e.priority,children:[(0,W.jsx)(`option`,{value:``,children:`Any priority`}),k1.map(({wire:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))]}),(0,W.jsx)(`label`,{htmlFor:`${i}-state`,children:`State`}),(0,W.jsx)(`select`,{id:`${i}-state`,onChange:e=>s(`state`,H1(K1,e.target.value)??`open`),value:e.state,children:P1.map(({state:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`label`,{htmlFor:`${i}-source`,children:`Source`}),(0,W.jsxs)(`select`,{id:`${i}-source`,onChange:e=>s(`source`,H1(q1,e.target.value)??``),value:e.source,children:[(0,W.jsx)(`option`,{value:``,children:`Any source`}),(0,W.jsx)(`option`,{value:`session`,children:`Session`}),(0,W.jsx)(`option`,{value:`run`,children:`Run`}),(0,W.jsx)(`option`,{value:`plan`,children:`Plan`}),(0,W.jsx)(`option`,{value:`host`,children:`Host`})]}),c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`label`,{htmlFor:`${i}-source-id`,children:`Source identifier`}),(0,W.jsx)(`input`,{id:`${i}-source-id`,onChange:e=>s(`sourceId`,e.target.value),placeholder:`${e.source} id`,type:`search`,value:e.sourceId})]})]})]})}function _0(e){return e.target instanceof Element&&e.target.closest(`a, button, textarea, input, select`)===null}function v0({view:e,groupBy:t}){let{item:n}=e;return(0,W.jsxs)(W.Fragment,{children:[t!==`priority`&&(0,W.jsx)(`span`,{className:`human-item-priority`,"data-priority":n.priority,children:A1(n)}),t!==`kind`&&(0,W.jsx)(`span`,{className:`human-item-kind`,children:j1(n)}),t!==`blocking`&&I1(n)&&(0,W.jsx)(`span`,{className:`human-item-blocking`,children:`Blocking`})]})}function y0({view:e,groupBy:t,selected:n,state:r,draft:i,onDraft:a,onSelect:o,onWrite:s}){let{item:c}=e,l=c.state===`open`,u=z1(e),d=[...l?[]:[F1(c)],...u?[u]:[],...t===`source`?[]:[`Source: ${B1(c)}`]];return(0,W.jsxs)(_1,{actions:(0,W.jsx)(b0,{item:e,onSelect:o,onWrite:s}),badges:(0,W.jsx)(v0,{groupBy:t,view:e}),body:c.body,className:`human-item-card`,clamp:d0,"data-blocking":I1(c),"data-item-id":c.id,"data-selected":n,meta:d.length===0?void 0:d.map((e,t)=>(0,W.jsxs)(H.Fragment,{children:[t>0&&` · `,(0,W.jsx)(`span`,{children:e})]},e)),onClick:e=>{_0(e)&&o()},title:c.title,children:[c.kind===`question`&&l&&(0,W.jsx)(x0,{draft:i,label:`Answer: ${c.title}`,onDraft:a,onSubmit:t=>s(e,{action:`answer`,text:t}),pending:r?.pending??!1}),(0,W.jsx)(S0,{state:r})]})}function b0({item:e,onSelect:t,onWrite:n}){let{item:r}=e,i=r.state===`open`;return(0,W.jsxs)(W.Fragment,{children:[r.tracker&&(0,W.jsx)(b1,{className:`human-item-tracker`,"data-card-action":``,label:r.tracker.task,onClick:e=>e.stopPropagation(),tabIndex:-1,url:r.tracker.url}),(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:t,type:`button`,"aria-label":`Details: ${r.title}`,children:`Details`}),i&&r.kind===`task`&&(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:()=>n(e,{action:`complete`}),type:`button`,"aria-label":`Complete: ${r.title}`,children:`Complete`}),i&&(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:()=>n(e,{action:`dismiss`}),type:`button`,"aria-label":`Dismiss: ${r.title}`,children:`Dismiss`})]})}function x0({label:e,draft:t,pending:n,onDraft:r,onSubmit:i}){return(0,W.jsx)(`textarea`,{"aria-busy":n,"aria-label":e,className:`human-item-answer`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!n&&t.trim()!==``&&i(t))},placeholder:`Answer, then press Enter`,readOnly:n,rows:1,value:t})}function S0({state:e}){return e?.pending?(0,W.jsx)(`p`,{className:`human-item-status`,role:`status`,children:`Sending…`}):e?.error?(0,W.jsx)(`p`,{className:`human-item-status`,"data-failed":`true`,role:`alert`,children:e.error}):null}function C0({view:e,detail:t,gone:n,lastShown:r,error:i,state:a,draft:o,onDraft:s,onWrite:c,onClose:l}){if(n&&e===void 0)return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsxs)(`header`,{className:`human-item-detail-head`,children:[r&&(0,W.jsx)(`h2`,{children:r.item.title}),(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})})]}),(0,W.jsx)(`p`,{role:`status`,children:`Resolved: this item needs nothing more from you.`})]});let u=t??e;if(u===void 0)return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})}),i?(0,W.jsx)(`p`,{role:`alert`,children:i}):(0,W.jsx)(`p`,{role:`status`,children:`Reading…`})]});let{item:d}=u,f=d.state===`open`,p=R1(u);return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsxs)(`header`,{className:`human-item-detail-head`,children:[(0,W.jsxs)(`p`,{className:`human-item-meta`,children:[(0,W.jsx)(`span`,{className:`human-item-priority`,"data-priority":d.priority,children:A1(d)}),` `,j1(d),` · `,F1(d)]}),(0,W.jsx)(`h2`,{children:d.title}),(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})})]}),(0,W.jsxs)(`p`,{className:`human-item-meta`,children:[`Source: `,B1(d)]}),p.length>0&&(0,W.jsx)(`p`,{className:`human-item-meta human-item-blocks`,children:p.join(`; `)}),i&&(0,W.jsx)(`p`,{role:`alert`,children:i}),t&&t.nodes.length>0&&(0,W.jsx)(`section`,{"aria-label":`Blocked steps`,className:`human-item-steps`,children:V1(t).map(({phrase:e,nodes:t})=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:e}),(0,W.jsx)(`ul`,{children:t.map(e=>(0,W.jsxs)(`li`,{children:[e.run,` / `,e.node,`: `,e.title]},`${e.run}/${e.node}`))})]},e))}),(0,W.jsx)(`section`,{"aria-label":`Full body`,className:`human-item-detail-body`,tabIndex:0,children:(0,W.jsx)(g1,{source:d.body})}),(0,W.jsxs)(`div`,{className:`human-item-detail-actions`,children:[d.kind===`question`&&f&&(0,W.jsx)(x0,{draft:o,label:`Answer in detail: ${d.title}`,onDraft:s,onSubmit:e=>c(u,{action:`answer`,text:e}),pending:a?.pending??!1}),d.tracker&&(0,W.jsx)(b1,{className:`human-item-tracker`,label:d.tracker.task,url:d.tracker.url}),f&&d.kind===`task`&&(0,W.jsx)(Pa,{onClick:()=>c(u,{action:`complete`}),size:`sm`,type:`button`,children:`Complete`}),f&&(0,W.jsx)(Pa,{onClick:()=>c(u,{action:`dismiss`}),size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`}),(0,W.jsx)(S0,{state:a})]})]})}function w0({className:e,state:t}){let n=T0(t);return(0,W.jsxs)(Ma,{className:V(`gap-1.5 tracking-[.03em] uppercase`,n&&D0[n],e),variant:`outline`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:V(`size-1.5 rounded-full bg-current`,t===`running`&&`animate-pulse`)}),t]})}function T0(e){return N0[e]}var E0=e=>{let t=T0(e);return V(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:O0[t])},D0={success:`border-success bg-success-surface text-success`,destructive:`border-destructive bg-destructive-surface text-destructive`,warning:`border-warning bg-warning-surface text-warning`,info:`border-info bg-info-surface text-info`},O0={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},k0=`success`,A0=`destructive`,j0=`warning`,M0={blocked:j0,cancelled:A0,"complete-but-draft":j0,"complete-but-held":j0,done:k0,failed:A0,"not-completed":A0,parked:void 0,pending:void 0,ready:void 0,running:`info`,skipped:j0,unknown:void 0,waiting:void 0},N0={...M0,complete:M0.done,settled:M0.done,active:M0.running},P0=`/human-items`;function F0(e){return e===`/human-items`||e===`/human-items/`}function I0(e){return F0(e)?`/`:e}function L0(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}var R0=()=>window.location.pathname;function z0(){let e=(0,H.useSyncExternalStore)(L0,R0,R0),t=(0,H.useCallback)(()=>{let e=new URLSearchParams;for(let t of new URLSearchParams(window.location.search).getAll(`hide-kind`))e.append(`hide-kind`,t);let t=e.size>0?`?${e}`:``;window.history.pushState(null,``,`${P0}${t}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{active:F0(e),open:t}}var B0={graph:`graph`,overall:`overall`,channel:`channel`};function V0(e){return e!==null&&Object.hasOwn(B0,e)}var H0={projects:`projects`,runs:`runs`};function U0(e){return e!==null&&Object.hasOwn(H0,e)}var W0={decisions:{label:`Decisions`,description:`Decision points and settlements only`,profile:lj.planner},activity:{label:`Detailed activity`,description:`Every record all three producers put on the stream`,profile:lj.detailed}};function G0(e){return e!==null&&Object.hasOwn(W0,e)}var K0={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,remote:`Remote`};function q0(e){return e!==null&&Object.hasOwn(K0,e)}function J0(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function Y0(e,t){let n=e.get(t);return n!==null&&J0(n)?n:void 0}function X0(){let e=(0,H.useSyncExternalStore)(Z0,Q0,Q0),t=new URLSearchParams(e),n=t.get(`list`),r=U0(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||AM(i))?i:void 0,o=Y0(t,`run`),s=Y0(t,`node`),c=Y0(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=G0(d)?d:`activity`,p=u===`pr`||u===`checks`?`remote`:q0(u)?u:`timeline`,m=V0(l)?l:s===void 0?`overall`:`graph`,h=(0,H.useCallback)((e,t=!1)=>{let n=new URLSearchParams(window.location.search);e(n);let r=t?window.location.pathname:I0(window.location.pathname);window.history.pushState(null,``,`${r}?${n}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{list:r,host:t.get(`page`)===`host`,hiddenKinds:t.getAll(`hide-kind`),selectHost:()=>h(e=>{e.set(`page`,`host`)}),selectKinds:e=>h(t=>{t.delete(`hide-kind`);for(let n of e)t.append(`hide-kind`,n)},!0),projectKey:a,runId:o,nodeId:s,itemId:c,view:m,detail:f,nodeTab:p,selectList:e=>h(t=>{e===`projects`?t.delete(`list`):t.set(`list`,e),t.delete(`project`)}),selectProject:e=>h(t=>{e===void 0?t.delete(`project`):t.set(`project`,e),t.delete(`list`),t.delete(`run`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectRun:e=>h(t=>{t.set(`run`,e),t.delete(`page`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectNode:e=>h(t=>{e?t.set(`node`,e):t.delete(`node`),t.delete(`event`),t.delete(`tab`),t.set(`view`,`graph`)}),selectItem:e=>h(t=>{e?t.set(`event`,e):t.delete(`event`)}),showOverall:()=>h(e=>{e.set(`view`,`overall`),e.delete(`node`),e.delete(`event`),e.delete(`tab`)}),selectDetail:e=>h(t=>{e===`activity`?t.delete(`detail`):t.set(`detail`,e)}),selectNodeTab:e=>h(t=>{e===`timeline`?t.delete(`tab`):t.set(`tab`,e),e!==`timeline`&&t.delete(`event`)}),selectView:e=>h(t=>{t.set(`view`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)})}}function Z0(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function Q0(){return window.location.search}function $0(e){return[...e].sort((e,t)=>{let n=e.started_at,r=t.started_at;return n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:(r===void 0?0:Date.parse(r))-(n===void 0?0:Date.parse(n))||Date.parse(t.updated_at)-Date.parse(e.updated_at)||e.id.localeCompare(t.id)})}function e2(e){let t=new Map;for(let n of e){let e=n.group?.project??`none`,r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t].map(([e,t])=>{let n=$0(t),r=t[0]?.group?.project??null,i=t.map(e=>e.updated_at).reduce((e,t)=>Date.parse(t)>Date.parse(e)?t:e);return{key:e,project:r,label:r===null?`Other runs`:n.find(e=>e.group?.name)?.group?.name??r,rows:n,updatedAt:i}}).sort((e,t)=>Number(e.project===null)-Number(t.project===null)||Date.parse(t.updatedAt)-Date.parse(e.updatedAt)||e.key.localeCompare(t.key))}function t2(e){let{done:t,failed:n,running:r}=e.nodes;return OX({done:t,failed:n,running:r})}function n2(e,t){let n=new Map(e.map(e=>[e.id,JSON.stringify(e)])),r=t.filter(e=>n.get(e.id)!==JSON.stringify(e)).length,i=new Set(t.map(e=>e.id));return r+e.filter(e=>!i.has(e.id)).length}function r2(e,t,n,r){let[i,a]=(0,H.useState)(new Set),o=(0,H.useCallback)(e=>{a(t=>t.has(e)?t:new Set(t).add(e))},[]),s=(0,H.useCallback)(e=>{a(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),c=(0,H.useMemo)(()=>e2(e??[]),[e]),l=c.find(e=>e.rows.some(e=>e.id===n))?.key,[u,d]=(0,H.useState)();return l!==u&&(d(l),l!==void 0&&o(l)),(0,H.useMemo)(()=>({kinds:[...new Set(e?.flatMap(e=>e.kind?[e.kind]:[])??[])].sort(),groups:c.map(e=>{let n=e.rows.filter(e=>!e.kind||!t.includes(e.kind)),a=n[0];return{key:e.key,label:e.label,runs:n,expanded:i.has(e.key),toggle:()=>s(e.key),open:()=>{o(e.key),a&&r(a.id)}}})}),[e,c,t,i,o,s,r])}var i2=240,a2=`data-row-key`;function o2(e,t){let n=(0,H.useRef)(new Map);(0,H.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=t.getBoundingClientRect().top,i=[...t.querySelectorAll(`[${a2}]`)],a=new Map(i.map(e=>[e.getAttribute(`data-row-key`)??``,e.getBoundingClientRect().top-r])),o=[...n.current.keys()].filter(e=>a.has(e)),s=[...a.keys()].filter(e=>n.current.has(e));if(o.join(`
|
|
110
|
+
`))}function s(e,t,n,r){let a=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:i,after:i});return o(),a(),s}function c(e,i){return GZ(e,{align:i,alignDelimiters:n,fillRows:!1,padding:t,stringLength:r})}function l(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=u(r[i],t,n);return o(),a}function u(e,t,n){let{children:r}=e,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=s(r[i],e,t,n);return o(),a}function d(e,t,n){let r=HQ.inlineCode(e,t,n);if(!n.stack.includes(`tableCell`))return r;let i=[],a=0,o=r.indexOf(`|`);for(;o!==-1;){let e=o;for(;e>a&&r.charCodeAt(e-1)===92;)e--;i.push(r.slice(a,o)),(o-e)%2==0&&i.push(`\\`),a=o,o=r.indexOf(`|`,o+1)}return i.push(r.slice(a)),i.join(``)}}function QQ(e,t,n,r){if(e.type===`table`&&n.type===`listItem`&&n.spread===!1&&(t.type===`definition`||t.type===`heading`&&$Q(t,r)||t.type===`paragraph`||t.type===`table`))return 1}function $Q(e,t){let n=!1;return bb(e,function(e){if(e.type===`break`||`value`in e&&/\r?\n|\r/.test(e.value))return n=!0,!1}),!!((!e.depth||e.depth<3)&&gg(e)&&(t.options.setext||n))}function e$(){return{exit:{taskListCheckValueChecked:n$,taskListCheckValueUnchecked:n$,paragraph:r$}}}function t$(){return{handlers:{paragraph:i$},join:[a$]}}function n$(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function r$(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start={...n.position.start}))}}this.exit(e)}function i$(e,t,n,r){if(!t||t.type!==`listItem`||o$(t)!==e)return HQ.paragraph(e,t,n,r);let i=`[`+(t.checked?`x`:` `)+`] `,a=n.createTracker(r);return a.move(i),i+HQ.paragraph(e.children.length>0?e:{type:`paragraph`,children:[{type:`text`,value:` `}]},t,n,{...r,...a.current()})}function a$(e,t,n){if(!(e.type===`definition`&&n.type===`listItem`))return;let r=o$(n);if(r&&n.children.indexOf(e)<n.children.indexOf(r))return 0}function o$(e){if(typeof e.checked==`boolean`)for(let t of e.children){if(t.type===`paragraph`)return t;if(t.type!==`definition`)return}}function s$(){return[oZ(),MZ(),LZ(),UQ(),e$()]}function c$(e){return{extensions:[sZ(),NZ(e),RZ(),ZQ(e),t$()]}}var l$={tokenize:C$,partial:!0},u$={tokenize:w$,partial:!0},d$={tokenize:T$,partial:!0},f$={tokenize:E$,partial:!0},p$={tokenize:D$,partial:!0},m$={name:`wwwAutolink`,tokenize:x$,previous:O$},h$={name:`protocolAutolink`,tokenize:S$,previous:k$},g$={name:`emailAutolink`,tokenize:b$,previous:A$},_$={};function v$(){return{text:_$}}for(var y$=48;y$<123;)_$[y$]=g$,y$++,y$===58?y$=65:y$===91&&(y$=97);_$[43]=g$,_$[45]=g$,_$[46]=g$,_$[95]=g$,_$[72]=[g$,h$],_$[104]=[g$,h$],_$[87]=[g$,m$],_$[119]=[g$,m$];function b$(e,t,n){let r=this,i,a;return o;function o(t){return!j$(t)||!A$.call(r,r.previous)||M$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return j$(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(p$,u,l)(t):t===45||t===95||jg(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Ag(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function x$(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!O$.call(r,r.previous)||M$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(l$,e.attempt(u$,e.attempt(d$,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function S$(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&k$.call(r,r.previous)&&!M$(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Ag(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ng(t)||Lg(t)||Bg(t)||zg(t)?n(t):e.attempt(u$,e.attempt(d$,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function C$(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function w$(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(f$,c,s)(t):t===null||Lg(t)||Bg(t)||t!==45&&zg(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function T$(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.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?e.check(f$,t,a)(o):o===null||Lg(o)||Bg(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function E$(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Lg(o)||Bg(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Lg(e)||Bg(e)?t(e):r(e)}function a(e){return Ag(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Ag(t)?(e.consume(t),o):n(t)}}function D$(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return jg(e)?n(e):t(e)}}function O$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Lg(e)}function k$(e){return!Ag(e)}function A$(e){return!(e===47||j$(e))}function j$(e){return e===43||e===45||e===46||e===95||jg(e)}function M$(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var N$={tokenize:V$,partial:!0};function P$(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:R$,continuation:{tokenize:z$},exit:B$}},text:{91:{name:`gfmFootnoteCall`,tokenize:L$},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:F$,resolveTo:I$}}}}function F$(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=kg(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function I$(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function L$(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Lg(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(kg(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Lg(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function R$(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Lg(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=kg(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Lg(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Ug(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function z$(e,t,n){return e.check(i_,t,e.attempt(N$,t,n))}function B$(e){e.exit(`gfmFootnoteDefinition`)}function V$(e,t,n){let r=this;return Ug(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function H$(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Sg(o,o.length,0,Zg(s,e.slice(r+1,n),t)),Sg(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Sg(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Xg(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Xg(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var U$=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){W$(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function W$(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function G$(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function K$(){return{flow:{null:{name:`table`,tokenize:q$,resolveAll:J$}}}}function q$(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):K(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Rg(t)?Ug(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Lg(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Rg(t)?Ug(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Rg(t)?Ug(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||K(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Rg(t)?Ug(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||K(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||K(n)?(e.exit(`tableRow`),t(n)):Rg(n)?Ug(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Lg(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function J$(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new U$;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(X$(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Y$(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Y$(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Y$(f,t,o,i,n,d)):(o[0]=o[1],d=Y$(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&X$(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=G$(t.events,n))}return e}function Y$(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Z$(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Z$(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Z$(t.events,n[2]),a=Z$(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Z$(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function X$(e,t,n,r,i){let a=[],o=Z$(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Z$(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Q$={name:`tasklistCheck`,tokenize:e1};function $$(){return{text:{91:Q$}}}function e1(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Lg(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return K(r)?t(r):Rg(r)?e.check({tokenize:t1},t,n)(r):n(r)}}function t1(e,t,n){return Ug(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function n1(e){return Tg([v$(),P$(),H$(e),K$(),$$()])}var r1={};function i1(e){let t=this,n=e||r1,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(n1(n)),a.push(s$()),o.push(c$(n))}var a1=new Set([`http:`,`https:`,`mailto:`]);function o1(e){try{return new URL(e)}catch{return}}function s1(e){let t=e===void 0?void 0:o1(e)?.protocol;return t!==void 0&&a1.has(t)?e:void 0}var c1={target:`_blank`,rel:`noopener noreferrer`},l1=typeof window>`u`?H.useEffect:H.useLayoutEffect;function u1(e,t){let n=(0,H.useRef)(null);return l1(()=>{let t=n.current;if(!t||e===void 0)return;let r=()=>{t.removeAttribute(`data-otg-table-cut`);let e=t.querySelector(`table`);if(!e||t.scrollHeight<=t.clientHeight)return;let n=e.getBoundingClientRect().top-t.getBoundingClientRect().top;t.toggleAttribute(`data-otg-table-cut`,n<t.clientHeight)};r();let i=t.clientWidth,a=new ResizeObserver(()=>{t.clientWidth!==i&&(i=t.clientWidth,r())});a.observe(t);let o=!0;return document.fonts?.ready.then(()=>{o&&r()}),()=>{o=!1,a.disconnect()}},[e,t]),n}function d1(e){return e.tagName===`img`?{type:`text`,value:String(e.properties?.alt||`image`)}:(e.children&&=e.children.map(d1),e)}function f1(){let e=t=>{t.tagName===`a`?d1(t):t.children?.forEach(e)};return e}function p1({href:e,children:t}){let n=s1(e);return(0,W.jsx)(`a`,{href:n,...n===void 0?{}:c1,children:t})}var m1={a:({href:e,children:t})=>(0,W.jsx)(p1,{href:e,children:t}),img:({src:e,alt:t})=>(0,W.jsx)(p1,{href:typeof e==`string`?e:void 0,children:t||`image`})},h1=[i1],g1=[f1];function _1({source:e,clamp:t}){let n=t!==void 0&&Number.isInteger(t)&&t>0?t:void 0,r=u1(n,e),i=n===void 0?void 0:{WebkitLineClamp:n,maxHeight:`calc(${n} * 1lh)`};return(0,W.jsx)(`div`,{className:n===void 0?`otg-markdown`:`otg-markdown otg-markdown--clamped`,ref:r,style:i,children:(0,W.jsx)(vx,{components:m1,rehypePlugins:g1,remarkPlugins:h1,children:e})})}function v1({title:e,body:t,badges:n,meta:r,links:i,actions:a,clamp:o,children:s,className:c,...l}){let u=(0,H.useId)();return(0,W.jsx)(`article`,{...l,"aria-labelledby":u,className:c?`otg-card ${c}`:`otg-card`,children:(0,W.jsxs)(`div`,{className:`otg-card__surface`,children:[(0,W.jsxs)(`div`,{className:`otg-card__header`,children:[n!=null&&(0,W.jsx)(`div`,{className:`otg-card__badges`,children:n}),(0,W.jsx)(`h3`,{className:`otg-card__title`,id:u,children:e}),a!=null&&(0,W.jsx)(`div`,{className:`otg-card__actions`,children:a})]}),r!=null&&(0,W.jsx)(`div`,{className:`otg-card__meta`,children:r}),i!=null&&(0,W.jsx)(`div`,{className:`otg-card__links`,children:i}),t?(0,W.jsx)(_1,{source:t,...o===void 0?{}:{clamp:o}}):null,s]})})}var y1=new Map([[`github.com`,`GitHub`],[`linear.app`,`Linear`]]);function b1(e){return y1.get(o1(e)?.hostname??``)??`tracker`}function x1({url:e,label:t,...n}){let r=s1(e);return(0,W.jsx)(`a`,{"aria-label":`Open ${b1(e)} issue ${t}`,...n,href:r,...c1,className:[`otg-source-link`,n.className].filter(Boolean).join(` `),children:t})}var S1=15e3;function C1(e,t,n){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(!1),p=(0,H.useRef)(null),{key:m,phase:h,followUp:g}=e,_=h===`sending`||g?.phase===`failed`||g?.phase===`sending`;return(0,H.useLayoutEffect)(()=>{if(f(!1),_)return;let e=setTimeout(()=>f(!0),S1);return()=>clearTimeout(e)},[`${m}:${h}:${g?.kind??``}:${g?.phase??``}`,_]),(0,H.useEffect)(()=>{c(!1),u(``)},[m]),(0,H.useEffect)(()=>{g?.kind===`note`&&g.phase===`done`&&(c(!1),u(``))},[g]),(0,H.useEffect)(()=>{if(!d||r||s)return;let e=p.current?.contains(document.activeElement)??!1;a&&e||t()},[d,r,a,s,t]),(0,H.useEffect)(()=>{let e=p.current;if(e===null)return;let t=()=>n(e.getBoundingClientRect().height);t();let r=new ResizeObserver(t);return r.observe(e),()=>{r.disconnect(),n(0)}},[n]),{holds:{ref:p,onFocus:()=>o(!0),onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||o(!1)},onPointerEnter:()=>i(!0),onPointerLeave:()=>i(!1)},writing:s,setWriting:c,text:l,setText:u}}var w1={answer:`Answered`,complete:`Completed`,dismiss:`Dismissed`},T1={answer:`Answering`,complete:`Completing`,dismiss:`Dismissing`},E1={complete:`Reopened`,dismiss:`Restored`};function D1(e){let{action:t,title:n,phase:r,error:i,followUp:a}=e;if(r===`failed`)return`Not ${w1[t].toLowerCase()}: ${n}. ${i??``}`.trim();let o=t===`answer`?`Reopened`:E1[t],s=t===`dismiss`?`Reason`:`Comment`;return a?.phase===`failed`?a.kind===`undo`?`Not ${o.toLowerCase()}: ${n}. ${a.error??``}`.trim():`${s} not saved: ${n}. ${a.error??``}`.trim():a?.phase===`done`?a.kind===`undo`?`${o}: ${n}`:`${s} saved: ${n}`:r===`sending`?`${T1[t]}: ${n}…`:`${w1[t]}: ${n}`}function O1({toast:e,onUndo:t,onNote:n,onClose:r,onRoom:i}){let{holds:a,writing:o,setWriting:s,text:c,setText:l}=C1(e,r,i),u=(0,H.useId)(),{action:d,phase:f,followUp:p}=e,m=f===`failed`||p?.phase===`failed`,h=d!==`answer`&&f!==`failed`,g=p?.kind===`undo`&&p.phase===`done`,_=d===`dismiss`?`Add reason`:`Add comment`,v=d===`dismiss`?`Reason`:`Comment`;return(0,W.jsxs)(`section`,{"aria-label":`Action result`,className:`human-items-toast`,"data-phase":p?.phase??f,"data-tone":m?`failure`:`success`,...a,children:[(0,W.jsx)(`p`,{className:`human-items-toast-message`,role:m?`alert`:`status`,children:D1(e)}),h&&!g&&(0,W.jsxs)(`div`,{className:`human-items-toast-actions`,children:[(0,W.jsx)(k1,{label:d===`dismiss`?`Restore`:`Reopen`,onPress:t,reopen:e.reopen,sending:p?.kind===`undo`&&p.phase===`sending`}),!o&&(0,W.jsx)(`button`,{className:`human-items-toast-action`,onClick:()=>s(!0),type:`button`,children:_})]}),h&&!g&&o&&(0,W.jsxs)(`form`,{className:`human-items-toast-note`,onSubmit:e=>{e.preventDefault(),c.trim()!==``&&n(c)},children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:u,children:v}),(0,W.jsx)(`input`,{autoFocus:!0,id:u,onChange:e=>l(e.target.value),placeholder:`${v}, then Enter`,readOnly:p?.kind===`note`&&p.phase===`sending`,value:c}),(0,W.jsx)(`button`,{className:`human-items-toast-action`,type:`submit`,children:p?.kind===`note`&&p.phase===`failed`?`Send again`:`Send`})]}),(0,W.jsx)(`button`,{"aria-label":`Close`,className:`human-items-toast-close`,onClick:r,type:`button`,children:(0,W.jsx)(un,{"aria-hidden":`true`,size:14})})]})}function k1({label:e,reopen:t,sending:n,onPress:r}){let[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),c=(0,H.useId)();return t?.available===!1?(0,W.jsxs)(`fieldset`,{"aria-label":`${e} (unavailable)`,className:`human-items-toast-action human-items-unavailable`,onPointerEnter:()=>s(!0),onPointerLeave:()=>s(!1),children:[(0,W.jsx)(`button`,{"aria-describedby":c,disabled:!0,type:`button`,children:e}),(0,W.jsx)(`sup`,{className:`human-items-why-anchor`,children:(0,W.jsx)(`button`,{"aria-controls":c,"aria-expanded":i,"aria-label":`Why ${e} is unavailable`,className:`human-items-why`,onClick:()=>a(e=>!e),type:`button`,children:`?`})}),(0,W.jsx)(`span`,{className:`human-items-why-tip`,hidden:!(i||o),id:c,role:`tooltip`,children:t.reason})]}):(0,W.jsx)(`button`,{"aria-busy":n,className:`human-items-toast-action`,onClick:()=>{n||r()},type:`button`,children:n?`${e}…`:e})}var A1=MA.map(e=>({wire:e,label:NA[e]}));function j1(e){return NA[e.priority]}function M1(e){return e.kind===`task`?`Task`:`Question`}var N1={open:`Open`,answered:`Answered`,completed:`Completed`,dismissed:`Dismissed`},P1=[`open`,`answered`,`completed`,`dismissed`],F1=P1.map(e=>({state:e,label:N1[e]}));function I1(e){return N1[e.state]}function L1(e){return e.state===`open`&&e.block.scope!==`nothing`}function R1(e){return e===1?`1 step`:`${e} steps`}function z1(e){let{item:t,blocked:n}=e;if(!L1(t))return[];switch(t.block.scope){case`host`:return[`blocks all work on this host`];case`plan`:return[`blocks all of ${t.block.plan}`];case`work`:return n.plans.map(({plan:e,count:t})=>`blocks ${R1(t)} in ${e}`);default:return[]}}function B1(e){let t=z1(e);return e.item.block.scope===`work`?e.blocked.plans.map(({count:e,preview:n},r)=>{let i=e-n.length,a=n.map(({node:e})=>e).join(`, `);return`${t[r]}: ${a}${i>0?` +${i} more`:``}`}).join(`; `):t.join(`; `)}function V1(e){if(e.block.scope===`host`)return`host`;let{plan:t,run:n,session:r}=e.owner;return t!==null&&n!==null?`plan ${t} / run ${n}`:t===null?n===null?`session ${r}`:`run ${n}`:`plan ${t}`}function H1(e){let t=z1(e);if(e.item.block.scope!==`work`)return t.map(t=>({phrase:t,nodes:e.nodes}));let n=0;return e.blocked.plans.map(({count:r},i)=>{let a=e.nodes.slice(n,n+r);return n+=r,{phrase:t[i]??``,nodes:a}})}function U1(e,t){return e.find(e=>e===t)}var W1=[``,`task`,`question`],G1=[``,`yes`,`no`],K1=[``,...MA],q1=P1,J1=[``,`session`,`run`,`plan`,`host`],Y1={kind:``,blocking:``,priority:``,state:`open`,source:``,sourceId:``};function X1(e){let t=e.sourceId.trim();return{...e.kind===``?{}:{kind:e.kind},...e.blocking===``?{}:{blocking:e.blocking===`yes`},...e.priority===``?{}:{priority:e.priority},...e.state===`open`?{}:{state:e.state},...e.source===`host`?{host:!0}:{},...e.source!==``&&e.source!==`host`&&t!==``?{[e.source]:t}:{}}}function Z1(e){return Number(e.kind!==Y1.kind)+Number(e.blocking!==Y1.blocking)+Number(e.priority!==Y1.priority)+Number(e.state!==Y1.state)+Number(e.source!==Y1.source)}var Q1=[`priority`,`kind`,`source`,`blocking`,`none`],$1=`priority`,e0=[{value:`priority`,label:`Priority`},{value:`kind`,label:`Kind`},{value:`source`,label:`Source`},{value:`blocking`,label:`Blocking`},{value:`none`,label:`None`}];function t0(e,t){let{item:n}=e;switch(t){case`priority`:return{key:n.priority,label:j1(n),rank:MA.indexOf(n.priority)};case`kind`:return{key:n.kind,label:M1(n),rank:n.kind===`task`?0:1};case`blocking`:return L1(n)?{key:`blocking`,label:`Blocking`,rank:0}:{key:`not-blocking`,label:`Not blocking`,rank:1};case`source`:{let e=V1(n);return{key:e,label:`Source: ${e}`,rank:0}}}}function n0(e,t){if(t===`none`)return[{key:`all`,items:e}];let n=new Map;return e.forEach((e,r)=>{let{key:i,label:a,rank:o}=t0(e,t),s=n.get(i);s?s.items.push(e):n.set(i,{label:a,rank:o,first:r,items:[e]})}),[...n.entries()].sort(([,e],[,t])=>e.rank-t.rank||e.first-t.first).map(([e,{label:t,items:n}])=>({key:e,label:t,items:n}))}var r0=`onepipeline-ui.human-items.group-by`;function i0(){try{return U1(Q1,window.localStorage.getItem(`onepipeline-ui.human-items.group-by`)??``)??`priority`}catch{return $1}}function a0(){let[e,t]=(0,H.useState)(i0);return{groupBy:e,setGroupBy:(0,H.useCallback)(e=>{t(e);try{window.localStorage.setItem(r0,e)}catch{}},[])}}function o0(e){let[t,n]=(0,H.useState)(Y1),[r,i]=(0,H.useState)(),a=(0,H.useMemo)(()=>{if(!e)return;let n=X1(t);return{type:`human-items`,...Object.keys(n).length===0?{}:{filter:n},...r===void 0?{}:{item:r}}},[e,JSON.stringify(X1(t)),r]);return(0,H.useEffect)(()=>{e||(n(Y1),i(void 0))},[e]),{choice:t,setChoice:n,selectedId:r,setSelectedId:i,view:a}}function s0(e,t,n,r,i=``){let[a,o]=(0,H.useState)({}),[s,c]=(0,H.useState)({}),[l,u]=(0,H.useState)(),[d,f]=(0,H.useState)([]),[p,m]=(0,H.useState)({}),[h,g]=(0,H.useState)({}),[_,v]=(0,H.useState)(),y=(0,H.useRef)(new Set),b=(0,H.useRef)(new Map),x=(0,H.useRef)(0),S=(0,H.useRef)(void 0);S.current=l;let C=t.items,w=(0,H.useRef)(i);w.current=i,(0,H.useEffect)(()=>{g(e=>Object.keys(e).length===0?e:{})},[i]);let T=(0,H.useMemo)(()=>{if(C===void 0)return;let e=C.flatMap(e=>{if(p[e.item.id]!==void 0)return[];let t=h[e.item.id]?.view;return t===void 0||!l0(t,e)?[e]:t.item.state===r?[t]:[]}),t=t=>e.some(({item:e})=>e.id===t);for(let{view:n,at:a,filter:o}of Object.values(h))o===i&&n.item.state===r&&!t(n.item.id)&&e.splice(Math.min(a,e.length),0,n);for(let{view:n,at:r}of d)t(n.item.id)||e.splice(Math.min(r,e.length),0,n);return e},[C,d,h,p,r,i]);(0,H.useEffect)(()=>{C!==void 0&&g(e=>{let t=Object.entries(e).filter(([e,{view:t}])=>{let n=C.find(({item:t})=>t.id===e);return n===void 0?t.item.state===r:l0(t,n)});return t.length===Object.keys(e).length?e:Object.fromEntries(t)})},[C,r]);let E=t.error===void 0&&t.item===n?t.detail:void 0,D=n===void 0?void 0:h[n]?.view,O=E&&D!==void 0&&l0(D,{item:E.item})?{...E,item:D.item,reopen:D.reopen}:E,k=(0,H.useRef)(C);k.current=C;let A=(0,H.useCallback)((e,t)=>u(n=>n?.key===e?t(n):n),[]),j=(0,H.useCallback)((t,n)=>{let{id:r,title:i}=t.item;if(y.current.has(r))return;y.current.add(r);let a=++x.current,s=w.current,l=Math.max(0,k.current?.findIndex(({item:e})=>e.id===r)??0),d=n.action===`answer`;o(e=>({...e,[r]:{pending:d}})),d?f(e=>[...e,{view:t,at:l}]):m(e=>({...e,[r]:{view:t,at:l}})),u({key:a,id:r,title:i,action:n.action,phase:`sending`});let p=n.action===`answer`?e.answerHumanItem(r,n.text):n.action===`complete`?e.completeHumanItem(r):e.dismissHumanItem(r,n.reason);b.current.set(a,p),p.then(e=>{g(t=>({...t,[r]:{view:e.item,at:l,filter:s}})),o(e=>({...e,[r]:{pending:!1}})),c(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==r))),A(a,t=>({...t,phase:`done`,reopen:e.item.reopen}))},e=>{let t=u0(e);o(e=>({...e,[r]:{pending:!1,error:t}})),A(a,e=>({...e,phase:`failed`,error:t})),d||v({id:r})}).finally(()=>{y.current.delete(r),f(e=>e.filter(({view:e})=>e.item.id!==r)),m(c0(r))})},[e,A]),M=(0,H.useCallback)((e,t)=>{let n=S.current;if(n===void 0)return;let r=b.current.get(n.key);if(r===void 0||n.followUp?.phase===`sending`)return;let{key:i,id:a}=n,o=w.current;A(i,t=>({...t,followUp:{kind:e,phase:`sending`}})),r.then(n=>{if(e===`undo`&&!n.item.reopen.available){A(i,e=>({...e,followUp:void 0}));return}t(a).then(t=>{g(e=>({...e,[a]:{view:t.item,at:e[a]?.at??0,filter:o}})),A(i,n=>({...n,reopen:t.item.reopen,followUp:{kind:e,phase:`done`}}))},t=>A(i,n=>({...n,followUp:{kind:e,phase:`failed`,error:u0(t)}})))},()=>A(i,e=>({...e,followUp:void 0})))},[A]),N=(0,H.useCallback)(()=>M(`undo`,t=>e.reopenHumanItem(t)),[e,M]),P=(0,H.useCallback)(t=>M(`note`,n=>e.noteHumanItem(n,t)),[e,M]),F=(0,H.useCallback)(()=>u(void 0),[]),I=(0,H.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]);return{items:T,listError:n===void 0||T===void 0?t.error:void 0,detail:O===null?void 0:O,gone:n!==void 0&&O===null,detailError:n===void 0?void 0:t.error,writes:a,drafts:s,setDraft:I,write:j,toast:l,undo:N,note:P,closeToast:F,returned:_}}function c0(e){return t=>t[e]===void 0?t:Object.fromEntries(Object.entries(t).filter(([t])=>t!==e))}function l0(e,t){return Date.parse(e.item.updated_at)>Date.parse(t.item.updated_at)}function u0(e){return e instanceof Error?e.message:String(e)}var d0=`data-card-action`,f0=4;function p0({client:e,live:t,choice:n,setChoice:r,selectedId:i,setSelectedId:a}){let o=s0(e,t,i,n.state,JSON.stringify(n)),{groupBy:s,setGroupBy:c}=a0(),[l,u]=(0,H.useState)(0),d=(0,H.useRef)(null),f=o.items?.find(({item:e})=>e.id===i)??o.detail,p=(0,H.useRef)(void 0);f===void 0?p.current?.item.id!==i&&(p.current=void 0):p.current=f;let m=(e,t)=>{t.action!==`answer`&&e.item.id===i&&a(void 0),o.write(e,t)},h=o.returned;(0,H.useEffect)(()=>{h!==void 0&&d.current?.querySelector(`[data-item-id="${CSS.escape(h.id)}"]`)?.scrollIntoView({block:`nearest`})},[h]);let g=n0(o.items??[],s);return(0,W.jsxs)(`section`,{"aria-label":`Action items`,className:`human-items-page`,"data-detail-open":i!==void 0,style:m0(l),children:[(0,W.jsx)(_0,{choice:n,groupBy:s,onChange:r,onGroupBy:c}),(0,W.jsxs)(`div`,{className:`human-items-body`,children:[(0,W.jsxs)(`section`,{"aria-label":`Action item list`,className:`human-items-list`,children:[o.listError&&(0,W.jsx)(`p`,{role:`alert`,children:o.listError}),o.items===void 0&&!o.listError&&(0,W.jsx)(`p`,{role:`status`,children:`Reading action items…`}),o.items?.length===0&&(0,W.jsx)(`p`,{role:`status`,children:`No action items match these filters.`}),(0,W.jsx)(`div`,{className:`human-items-groups`,onKeyDown:e=>g0(e,d.current),ref:d,children:g.map(e=>(0,W.jsx)(h0,{draftOf:e=>o.drafts[e]??``,group:e,groupBy:s,onDraft:o.setDraft,onSelect:a,onWrite:m,selectedId:i,writes:o.writes},e.key))}),(o.items?.length??0)>0&&(0,W.jsx)(`button`,{className:`card-actions-entry`,onFocus:()=>d.current?.querySelector(`[${d0}]`)?.focus(),type:`button`,children:`Card actions: use the arrow keys`})]}),i!==void 0&&(0,W.jsx)(w0,{draft:o.drafts[i]??``,error:o.detailError,detail:o.detail,gone:o.gone,lastShown:p.current,onClose:()=>a(void 0),onDraft:e=>o.setDraft(i,e),onWrite:m,state:o.writes[i],view:f})]}),o.toast&&(0,W.jsx)(O1,{onClose:o.closeToast,onNote:o.note,onRoom:u,onUndo:o.undo,toast:o.toast})]})}function m0(e){return{"--toast-room":`${e}px`}}function h0({group:e,groupBy:t,selectedId:n,writes:r,draftOf:i,onDraft:a,onSelect:o,onWrite:s}){let c=(0,H.useId)(),l=e.items.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(b0,{draft:i(e.item.id),groupBy:t,onDraft:t=>a(e.item.id,t),onSelect:()=>o(e.item.id),onWrite:s,selected:e.item.id===n,state:r[e.item.id],view:e})},e.item.id));return e.label===void 0?(0,W.jsx)(`ul`,{"aria-label":`Action items`,children:l}):(0,W.jsxs)(`section`,{"aria-labelledby":c,className:`human-items-group`,children:[(0,W.jsxs)(`h2`,{className:`human-items-group-heading`,id:c,children:[e.label,` `,(0,W.jsxs)(`span`,{className:`human-items-group-count`,children:[`(`,e.items.length,`)`]})]}),(0,W.jsx)(`ul`,{"aria-labelledby":c,children:l})]})}function g0(e,t){let n=e.target;if(t===null||!(n instanceof HTMLElement)||!n.hasAttribute(d0))return;let r=[...t.querySelectorAll(`[${d0}]`)],i=r.indexOf(n),a=e.key===`ArrowRight`||e.key===`ArrowDown`?r[Math.min(i+1,r.length-1)]:e.key===`ArrowLeft`||e.key===`ArrowUp`?r[Math.max(i-1,0)]:e.key===`Home`?r[0]:e.key===`End`?r.at(-1):void 0;a!==void 0&&(e.preventDefault(),a.focus())}function _0({choice:e,groupBy:t,onChange:n,onGroupBy:r}){let i=(0,H.useId)(),[a,o]=(0,H.useState)(!1),s=(t,r)=>n({...e,[t]:r}),c=e.source!==``&&e.source!==`host`,l=Z1(e)+Number(t!==$1);return(0,W.jsxs)(`div`,{className:`human-items-controls`,"data-open":a,children:[(0,W.jsxs)(`button`,{"aria-controls":`${i}-filters`,"aria-expanded":a,"aria-label":l>0?`Filters, ${l} changed`:`Filters`,className:`human-items-filters-toggle`,onClick:()=>o(e=>!e),type:`button`,children:[(0,W.jsx)(nn,{"aria-hidden":`true`,size:14}),`Filters`,l>0&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`human-items-filters-count`,children:l})]}),(0,W.jsxs)(`fieldset`,{className:`human-items-filters`,id:`${i}-filters`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Filter action items`}),(0,W.jsx)(`label`,{htmlFor:`${i}-group`,children:`Group by`}),(0,W.jsx)(`select`,{id:`${i}-group`,onChange:e=>r(U1(Q1,e.target.value)??`priority`),value:t,children:e0.map(({value:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`label`,{htmlFor:`${i}-kind`,children:`Kind`}),(0,W.jsxs)(`select`,{id:`${i}-kind`,onChange:e=>s(`kind`,U1(W1,e.target.value)??``),value:e.kind,children:[(0,W.jsx)(`option`,{value:``,children:`Any kind`}),(0,W.jsx)(`option`,{value:`task`,children:`Task`}),(0,W.jsx)(`option`,{value:`question`,children:`Question`})]}),(0,W.jsx)(`label`,{htmlFor:`${i}-blocking`,children:`Blocking`}),(0,W.jsxs)(`select`,{id:`${i}-blocking`,onChange:e=>s(`blocking`,U1(G1,e.target.value)??``),value:e.blocking,children:[(0,W.jsx)(`option`,{value:``,children:`Any`}),(0,W.jsx)(`option`,{value:`yes`,children:`Yes`}),(0,W.jsx)(`option`,{value:`no`,children:`No`})]}),(0,W.jsx)(`label`,{htmlFor:`${i}-priority`,children:`Priority`}),(0,W.jsxs)(`select`,{id:`${i}-priority`,onChange:e=>s(`priority`,U1(K1,e.target.value)??``),value:e.priority,children:[(0,W.jsx)(`option`,{value:``,children:`Any priority`}),A1.map(({wire:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))]}),(0,W.jsx)(`label`,{htmlFor:`${i}-state`,children:`State`}),(0,W.jsx)(`select`,{id:`${i}-state`,onChange:e=>s(`state`,U1(q1,e.target.value)??`open`),value:e.state,children:F1.map(({state:e,label:t})=>(0,W.jsx)(`option`,{value:e,children:t},e))}),(0,W.jsx)(`label`,{htmlFor:`${i}-source`,children:`Source`}),(0,W.jsxs)(`select`,{id:`${i}-source`,onChange:e=>s(`source`,U1(J1,e.target.value)??``),value:e.source,children:[(0,W.jsx)(`option`,{value:``,children:`Any source`}),(0,W.jsx)(`option`,{value:`session`,children:`Session`}),(0,W.jsx)(`option`,{value:`run`,children:`Run`}),(0,W.jsx)(`option`,{value:`plan`,children:`Plan`}),(0,W.jsx)(`option`,{value:`host`,children:`Host`})]}),c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`label`,{htmlFor:`${i}-source-id`,children:`Source identifier`}),(0,W.jsx)(`input`,{id:`${i}-source-id`,onChange:e=>s(`sourceId`,e.target.value),placeholder:`${e.source} id`,type:`search`,value:e.sourceId})]})]})]})}function v0(e){return e.target instanceof Element&&e.target.closest(`a, button, textarea, input, select`)===null}function y0({view:e,groupBy:t}){let{item:n}=e;return(0,W.jsxs)(W.Fragment,{children:[t!==`priority`&&(0,W.jsx)(`span`,{className:`human-item-priority`,"data-priority":n.priority,children:j1(n)}),t!==`kind`&&(0,W.jsx)(`span`,{className:`human-item-kind`,children:M1(n)}),t!==`blocking`&&L1(n)&&(0,W.jsx)(`span`,{className:`human-item-blocking`,children:`Blocking`})]})}function b0({view:e,groupBy:t,selected:n,state:r,draft:i,onDraft:a,onSelect:o,onWrite:s}){let{item:c}=e,l=c.state===`open`,u=B1(e),d=[...l?[]:[I1(c)],...u?[u]:[],...t===`source`?[]:[`Source: ${V1(c)}`]];return(0,W.jsxs)(v1,{actions:(0,W.jsx)(x0,{item:e,onSelect:o,onWrite:s}),badges:(0,W.jsx)(y0,{groupBy:t,view:e}),body:c.body,className:`human-item-card`,clamp:f0,"data-blocking":L1(c),"data-item-id":c.id,"data-selected":n,meta:d.length===0?void 0:d.map((e,t)=>(0,W.jsxs)(H.Fragment,{children:[t>0&&` · `,(0,W.jsx)(`span`,{children:e})]},e)),onClick:e=>{v0(e)&&o()},title:c.title,children:[c.kind===`question`&&l&&(0,W.jsx)(S0,{draft:i,label:`Answer: ${c.title}`,onDraft:a,onSubmit:t=>s(e,{action:`answer`,text:t}),pending:r?.pending??!1}),(0,W.jsx)(C0,{state:r})]})}function x0({item:e,onSelect:t,onWrite:n}){let{item:r}=e,i=r.state===`open`;return(0,W.jsxs)(W.Fragment,{children:[r.tracker&&(0,W.jsx)(x1,{className:`human-item-tracker`,"data-card-action":``,label:r.tracker.task,onClick:e=>e.stopPropagation(),tabIndex:-1,url:r.tracker.url}),(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:t,type:`button`,"aria-label":`Details: ${r.title}`,children:`Details`}),i&&r.kind===`task`&&(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:()=>n(e,{action:`complete`}),type:`button`,"aria-label":`Complete: ${r.title}`,children:`Complete`}),i&&(0,W.jsx)(`button`,{className:`human-item-action`,"data-card-action":``,tabIndex:-1,onClick:()=>n(e,{action:`dismiss`}),type:`button`,"aria-label":`Dismiss: ${r.title}`,children:`Dismiss`})]})}function S0({label:e,draft:t,pending:n,onDraft:r,onSubmit:i}){return(0,W.jsx)(`textarea`,{"aria-busy":n,"aria-label":e,className:`human-item-answer`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!n&&t.trim()!==``&&i(t))},placeholder:`Answer, then press Enter`,readOnly:n,rows:1,value:t})}function C0({state:e}){return e?.pending?(0,W.jsx)(`p`,{className:`human-item-status`,role:`status`,children:`Sending…`}):e?.error?(0,W.jsx)(`p`,{className:`human-item-status`,"data-failed":`true`,role:`alert`,children:e.error}):null}function w0({view:e,detail:t,gone:n,lastShown:r,error:i,state:a,draft:o,onDraft:s,onWrite:c,onClose:l}){if(n&&e===void 0)return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsxs)(`header`,{className:`human-item-detail-head`,children:[r&&(0,W.jsx)(`h2`,{children:r.item.title}),(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})})]}),(0,W.jsx)(`p`,{role:`status`,children:`Resolved: this item needs nothing more from you.`})]});let u=t??e;if(u===void 0)return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})}),i?(0,W.jsx)(`p`,{role:`alert`,children:i}):(0,W.jsx)(`p`,{role:`status`,children:`Reading…`})]});let{item:d}=u,f=d.state===`open`,p=z1(u);return(0,W.jsxs)(`aside`,{"aria-label":`Action item detail`,className:`human-item-detail`,children:[(0,W.jsxs)(`header`,{className:`human-item-detail-head`,children:[(0,W.jsxs)(`p`,{className:`human-item-meta`,children:[(0,W.jsx)(`span`,{className:`human-item-priority`,"data-priority":d.priority,children:j1(d)}),` `,M1(d),` · `,I1(d)]}),(0,W.jsx)(`h2`,{children:d.title}),(0,W.jsx)(Pa,{"aria-label":`Close detail`,onClick:l,size:`sm`,type:`button`,variant:`ghost`,children:(0,W.jsx)(un,{size:14})})]}),(0,W.jsxs)(`p`,{className:`human-item-meta`,children:[`Source: `,V1(d)]}),p.length>0&&(0,W.jsx)(`p`,{className:`human-item-meta human-item-blocks`,children:p.join(`; `)}),i&&(0,W.jsx)(`p`,{role:`alert`,children:i}),t&&t.nodes.length>0&&(0,W.jsx)(`section`,{"aria-label":`Blocked steps`,className:`human-item-steps`,children:H1(t).map(({phrase:e,nodes:t})=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{children:e}),(0,W.jsx)(`ul`,{children:t.map(e=>(0,W.jsxs)(`li`,{children:[e.run,` / `,e.node,`: `,e.title]},`${e.run}/${e.node}`))})]},e))}),(0,W.jsx)(`section`,{"aria-label":`Full body`,className:`human-item-detail-body`,tabIndex:0,children:(0,W.jsx)(_1,{source:d.body})}),(0,W.jsxs)(`div`,{className:`human-item-detail-actions`,children:[d.kind===`question`&&f&&(0,W.jsx)(S0,{draft:o,label:`Answer in detail: ${d.title}`,onDraft:s,onSubmit:e=>c(u,{action:`answer`,text:e}),pending:a?.pending??!1}),d.tracker&&(0,W.jsx)(x1,{className:`human-item-tracker`,label:d.tracker.task,url:d.tracker.url}),f&&d.kind===`task`&&(0,W.jsx)(Pa,{onClick:()=>c(u,{action:`complete`}),size:`sm`,type:`button`,children:`Complete`}),f&&(0,W.jsx)(Pa,{onClick:()=>c(u,{action:`dismiss`}),size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`}),(0,W.jsx)(C0,{state:a})]})]})}function T0({className:e,state:t}){let n=E0(t);return(0,W.jsxs)(Ma,{className:V(`gap-1.5 tracking-[.03em] uppercase`,n&&O0[n],e),variant:`outline`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:V(`size-1.5 rounded-full bg-current`,t===`running`&&`animate-pulse`)}),t]})}function E0(e){return P0[e]}var D0=e=>{let t=E0(e);return V(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:k0[t])},O0={success:`border-success bg-success-surface text-success`,destructive:`border-destructive bg-destructive-surface text-destructive`,warning:`border-warning bg-warning-surface text-warning`,info:`border-info bg-info-surface text-info`},k0={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},A0=`success`,j0=`destructive`,M0=`warning`,N0={blocked:M0,cancelled:j0,"complete-but-draft":M0,"complete-but-held":M0,done:A0,failed:j0,"not-completed":j0,parked:void 0,pending:void 0,ready:void 0,running:`info`,skipped:M0,unknown:void 0,waiting:void 0},P0={...N0,complete:N0.done,settled:N0.done,active:N0.running},F0=`/human-items`;function I0(e){return e===`/human-items`||e===`/human-items/`}function L0(e){return I0(e)?`/`:e}function R0(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}var z0=()=>window.location.pathname;function B0(){let e=(0,H.useSyncExternalStore)(R0,z0,z0),t=(0,H.useCallback)(()=>{let e=new URLSearchParams;for(let t of new URLSearchParams(window.location.search).getAll(`hide-kind`))e.append(`hide-kind`,t);let t=e.size>0?`?${e}`:``;window.history.pushState(null,``,`${F0}${t}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{active:I0(e),open:t}}var V0={graph:`graph`,overall:`overall`,channel:`channel`};function H0(e){return e!==null&&Object.hasOwn(V0,e)}var U0={projects:`projects`,runs:`runs`};function W0(e){return e!==null&&Object.hasOwn(U0,e)}var G0={decisions:{label:`Decisions`,description:`Decision points and settlements only`,profile:uj.planner},activity:{label:`Detailed activity`,description:`Every record all three producers put on the stream`,profile:uj.detailed}};function K0(e){return e!==null&&Object.hasOwn(G0,e)}var q0={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,remote:`Remote`};function J0(e){return e!==null&&Object.hasOwn(q0,e)}function Y0(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function X0(e,t){let n=e.get(t);return n!==null&&Y0(n)?n:void 0}function Z0(){let e=(0,H.useSyncExternalStore)(Q0,$0,$0),t=new URLSearchParams(e),n=t.get(`list`),r=W0(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||jM(i))?i:void 0,o=X0(t,`run`),s=X0(t,`node`),c=X0(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=K0(d)?d:`activity`,p=u===`pr`||u===`checks`?`remote`:J0(u)?u:`timeline`,m=H0(l)?l:s===void 0?`overall`:`graph`,h=(0,H.useCallback)((e,t=!1)=>{let n=new URLSearchParams(window.location.search);e(n);let r=t?window.location.pathname:L0(window.location.pathname);window.history.pushState(null,``,`${r}?${n}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{list:r,host:t.get(`page`)===`host`,hiddenKinds:t.getAll(`hide-kind`),selectHost:()=>h(e=>{e.set(`page`,`host`)}),selectKinds:e=>h(t=>{t.delete(`hide-kind`);for(let n of e)t.append(`hide-kind`,n)},!0),projectKey:a,runId:o,nodeId:s,itemId:c,view:m,detail:f,nodeTab:p,selectList:e=>h(t=>{e===`projects`?t.delete(`list`):t.set(`list`,e),t.delete(`project`)}),selectProject:e=>h(t=>{e===void 0?t.delete(`project`):t.set(`project`,e),t.delete(`list`),t.delete(`run`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectRun:e=>h(t=>{t.set(`run`,e),t.delete(`page`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectNode:e=>h(t=>{e?t.set(`node`,e):t.delete(`node`),t.delete(`event`),t.delete(`tab`),t.set(`view`,`graph`)}),selectItem:e=>h(t=>{e?t.set(`event`,e):t.delete(`event`)}),showOverall:()=>h(e=>{e.set(`view`,`overall`),e.delete(`node`),e.delete(`event`),e.delete(`tab`)}),selectDetail:e=>h(t=>{e===`activity`?t.delete(`detail`):t.set(`detail`,e)}),selectNodeTab:e=>h(t=>{e===`timeline`?t.delete(`tab`):t.set(`tab`,e),e!==`timeline`&&t.delete(`event`)}),selectView:e=>h(t=>{t.set(`view`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)})}}function Q0(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function $0(){return window.location.search}function e2(e){return[...e].sort((e,t)=>{let n=e.started_at,r=t.started_at;return n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:(r===void 0?0:Date.parse(r))-(n===void 0?0:Date.parse(n))||Date.parse(t.updated_at)-Date.parse(e.updated_at)||e.id.localeCompare(t.id)})}function t2(e){let t=new Map;for(let n of e){let e=n.group?.project??`none`,r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t].map(([e,t])=>{let n=e2(t),r=t[0]?.group?.project??null,i=t.map(e=>e.updated_at).reduce((e,t)=>Date.parse(t)>Date.parse(e)?t:e);return{key:e,project:r,label:r===null?`Other runs`:n.find(e=>e.group?.name)?.group?.name??r,rows:n,updatedAt:i}}).sort((e,t)=>Number(e.project===null)-Number(t.project===null)||Date.parse(t.updatedAt)-Date.parse(e.updatedAt)||e.key.localeCompare(t.key))}function n2(e){let{done:t,failed:n,running:r}=e.nodes;return kX({done:t,failed:n,running:r})}function r2(e,t){let n=new Map(e.map(e=>[e.id,JSON.stringify(e)])),r=t.filter(e=>n.get(e.id)!==JSON.stringify(e)).length,i=new Set(t.map(e=>e.id));return r+e.filter(e=>!i.has(e.id)).length}function i2(e,t,n,r){let[i,a]=(0,H.useState)(new Set),o=(0,H.useCallback)(e=>{a(t=>t.has(e)?t:new Set(t).add(e))},[]),s=(0,H.useCallback)(e=>{a(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),c=(0,H.useMemo)(()=>t2(e??[]),[e]),l=c.find(e=>e.rows.some(e=>e.id===n))?.key,[u,d]=(0,H.useState)();return l!==u&&(d(l),l!==void 0&&o(l)),(0,H.useMemo)(()=>({kinds:[...new Set(e?.flatMap(e=>e.kind?[e.kind]:[])??[])].sort(),groups:c.map(e=>{let n=e.rows.filter(e=>!e.kind||!t.includes(e.kind)),a=n[0];return{key:e.key,label:e.label,runs:n,expanded:i.has(e.key),toggle:()=>s(e.key),open:()=>{o(e.key),a&&r(a.id)}}})}),[e,c,t,i,o,s,r])}var a2=240,o2=`data-row-key`;function s2(e,t){let n=(0,H.useRef)(new Map);(0,H.useLayoutEffect)(()=>{let t=e.current;if(t===null)return;let r=t.getBoundingClientRect().top,i=[...t.querySelectorAll(`[${o2}]`)],a=new Map(i.map(e=>[e.getAttribute(`data-row-key`)??``,e.getBoundingClientRect().top-r])),o=[...n.current.keys()].filter(e=>a.has(e)),s=[...a.keys()].filter(e=>n.current.has(e));if(o.join(`
|
|
111
111
|
`)!==s.join(`
|
|
112
|
-
`)&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)for(let e of i){let t=n.current.get(e.getAttribute(`data-row-key`)??``),r=a.get(e.getAttribute(`data-row-key`)??``);t===void 0||r===void 0||t===r||e.animate([{transform:`translateY(${t-r}px)`},{transform:`translateY(0)`}],{duration:i2,easing:`ease-out`})}n.current=a},[e,t])}function s2({rows:e,selectedRunId:t,onSelect:n,onOpenProject:r,onHost:i,hostCurrent:a=!1,onActionItems:o,actionItemsCurrent:s=!1,hiddenKinds:c,onKindsChange:l,updates:u,drawerOpen:d=!1,drawerRef:f}){let{kinds:p,groups:m}=r2(e,c,t,r??n),h=(0,H.useRef)(null);return o2(h,m),(0,W.jsx)(`nav`,{"aria-label":`Projects`,className:`run-nav`,"data-open":d,id:`run-navigation`,ref:f,children:(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`px-[18px] py-6 max-sm:px-2`,children:[(0,W.jsxs)(`div`,{className:`brand`,children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`brand-mark`,children:(0,W.jsx)(gt,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Local orchestration`}),(0,W.jsx)(`h1`,{children:`DAG Observatory`})]})]}),(0,W.jsx)(bf,{className:`my-[22px]`}),(0,W.jsxs)(`div`,{className:`nav-pages`,children:[(0,W.jsx)(Pa,{"aria-current":a?`page`:void 0,onClick:i,variant:`ghost`,children:`Host`}),o&&(0,W.jsx)(Pa,{"aria-current":s?`page`:void 0,onClick:o,variant:`ghost`,children:`Action items`})]}),p.length>0&&(0,W.jsxs)(`details`,{className:`kind-filter`,children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsxs)(`span`,{children:[`Run kinds:`,` `,p.filter(e=>!c.includes(e)).length,` of`,` `,p.length]}),(0,W.jsx)(St,{"aria-hidden":`true`,size:14})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Run kinds`}),p.map(e=>(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!c.includes(e),onChange:t=>l(t.target.checked?c.filter(t=>t!==e):[...c,e])}),e]},e))]})]}),u,e===void 0?(0,W.jsx)(`p`,{role:`status`,children:`Loading projects…`}):(0,W.jsx)(`div`,{className:`nav-rows`,ref:h,children:m.map(e=>(0,W.jsxs)(`fieldset`,{"aria-label":`Project ${e.label}`,className:`project-group`,children:[(0,W.jsxs)(`div`,{className:`project-row`,[a2]:`project:${e.key}`,children:[(0,W.jsx)(`button`,{"aria-expanded":e.expanded,"aria-label":`${e.expanded?`Collapse`:`Expand`} ${e.label}`,className:`project-toggle`,onClick:e.toggle,type:`button`,children:(0,W.jsx)(Ct,{"aria-hidden":`true`,"data-open":e.expanded,size:12})}),(0,W.jsxs)(`button`,{className:`project-open`,onClick:e.open,type:`button`,children:[(0,W.jsx)(`span`,{className:`project-name`,children:e.label}),(0,W.jsxs)(`span`,{className:`project-count`,children:[e.runs.length,(0,W.jsx)(`span`,{className:`sr-only`,children:` shown runs`})]})]})]}),e.expanded&&e.runs.length===0&&(0,W.jsx)(`p`,{className:`run-list-status`,role:`status`,children:`No runs of the shown kinds.`}),e.expanded&&e.runs.length>0&&(0,W.jsx)(`ul`,{"aria-label":`Runs of ${e.label}`,className:`run-list`,children:e.runs.map(e=>{let r=t===e.id,i=[e.state,t2(e)].filter(Boolean).join(` · `);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{"aria-current":r?`page`:void 0,className:`run-link`,"data-active":r,onClick:()=>n(e.id),title:i,type:`button`,"data-row-key":`run:${e.id}`,children:[(0,W.jsxs)(fm,{children:[(0,W.jsx)(pm,{asChild:!0,children:(0,W.jsx)(`span`,{role:`img`,"aria-label":e.state,className:V(`run-dot`,E0(e.state))})}),(0,W.jsx)(mm,{children:e.state})]}),(0,W.jsx)(`span`,{className:`run-link-name`,children:e.name}),e.kind&&(0,W.jsx)(`span`,{"aria-label":e.kind,className:`run-link-tag`,role:`note`,children:e.kind}),r&&(0,W.jsx)(`span`,{className:`run-link-counts`,children:i})]})},e.id)})})]},e.key))})]})})})}function c2(){let[e,t]=(0,H.useState)(!1),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)(!1),a=(0,H.useCallback)(()=>t(!1),[]),o=(0,H.useCallback)(()=>t(e=>!e),[]);return(0,H.useEffect)(()=>{if(!e)return;let r=e=>{e.key===`Escape`&&t(!1)},i=()=>{n.current?.offsetParent===null&&t(!1)};return document.addEventListener(`keydown`,r),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,i)}},[e]),(0,H.useEffect)(()=>{e?r.current?.querySelector(`button`)?.focus():i.current&&n.current?.focus(),i.current=e},[e]),{open:e,close:a,toggle:o,menuButton:n,drawer:r}}function l2(e,t){let[n,r]=(0,H.useState)(0),i=(0,H.useRef)(void 0),a=(0,H.useRef)(t);a.current=t;let o=e===`live`,s=(0,H.useRef)(o);s.current=o;let c=(0,H.useCallback)(e=>{i.current=void 0,r(0),a.current(e)},[]),l=(0,H.useCallback)(()=>{i.current!==void 0&&c(i.current.value)},[c]),u=(0,H.useCallback)((e,t=1)=>{s.current?c(e):(i.current={value:e},r(e=>e+t))},[c]),d=(0,H.useCallback)(()=>{i.current=void 0,r(0)},[]);return(0,H.useEffect)(()=>{o&&l()},[o,l]),(0,H.useEffect)(()=>{if(typeof e!=`number`)return;let t=setInterval(l,e*1e3);return()=>clearInterval(t)},[e,l]),{waiting:n,show:c,take:l,offer:u,drop:d}}function u2(e,t){let[n,r]=(0,H.useState)(),[i,a]=(0,H.useState)({}),o=(0,H.useRef)([]),[s,c]=(0,H.useState)(),[l,u]=(0,H.useState)(),[d,f]=(0,H.useState)(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(0),x=t.runId,S=s===void 0||x!==void 0&&s.some(e=>e.id===x)?x:x!==void 0||t.selectFirst?$0(s)[0]?.id:void 0,C=(0,H.useMemo)(()=>t.humanItems??d2(t.host?void 0:S,t.view,t.nodeId,t.filter),[t.humanItems,t.host,S,t.view,t.nodeId,t.filter]),w=(0,H.useRef)(void 0),T=(0,H.useRef)(C);T.current=C;let E=l2(t.navigationUpdates,u),D=l2(t.mainUpdates,(0,H.useCallback)(e=>{r(e.state);let{visible:t}=e.state;if(t.type===`human-items`){let{items:n,detail:r}=t;a({items:n,detail:r,...e.view.type===`human-items`&&e.view.item!==void 0?{item:e.view.item}:{}})}f(new Date().toISOString()),e.reset!==void 0&&v(`The live view was re-sent whole: ${e.reset}.`)},[])),O=t.navigationUpdates!==`off`||t.mainUpdates!==`off`,k=(0,H.useRef)(O);k.current=O,(0,H.useEffect)(()=>{m(void 0);let t=!0,n=e.live({view:T.current,paused:!k.current,onState:(e,r)=>{let i=o.current;o.current=e.sidebar,c(e.sidebar),m(void 0),g(void 0);let a={state:e,view:n.view,...r.kind===`reset`?{reset:r.reason}:{}};if(r.kind===`snapshot`){if(D.show(a),t)E.show(e.sidebar);else if(i!==e.sidebar){let t=n2(i,e.sidebar);t>0&&E.offer(e.sidebar,t)}t=!1;return}if(r.kind===`reset`){E.offer(e.sidebar),D.offer(a);return}let s=r.frame.type===`run.changed`||r.frame.type===`run.removed`;s&&E.offer(e.sidebar),(!s||e.visible.type===`sidebar`)&&D.offer(a)},onError:e=>{if(n.view.type===`human-items`){a(t=>({...t.items===void 0?{}:{items:t.items},error:e.message})),n.change({type:`sidebar`});return}if(e instanceof JN&&(e.code===`run_not_found`||e.code===`node_not_found`)){n.change({type:`sidebar`});return}m(e)},onDisconnected:()=>g(Error(`Live telemetry stream disconnected`)),onConnected:()=>g(void 0)});return w.current=n,()=>{n.close(),w.current===n&&(w.current=void 0)}},[e,y,D.show,D.offer,E.show,E.offer]),(0,H.useEffect)(()=>{JSON.stringify(w.current?.view)!==JSON.stringify(C)&&D.drop(),w.current?.change(C),C.type!==`human-items`&&a(e=>Object.keys(e).length===0?e:{})},[C,D.drop]),(0,H.useEffect)(()=>{O?w.current?.resume():w.current?.pause()},[O]);let A=(0,H.useCallback)(()=>{E.take(),D.take()},[E.take,D.take]),j=(0,H.useCallback)(()=>{v(void 0),A(),b(e=>e+1)},[A]),M=n?.visible,N=M!==void 0&&M.type!==`sidebar`&&M.type!==`human-items`&&M.run_id===S&&f2(M,C)?M:void 0,P=(0,H.useRef)(void 0),F=N?.detail??(P.current?.run.run_id===S?P.current:void 0);P.current=F;let I=(0,H.useMemo)(()=>p2(F),[F]),L=p!==void 0&&C.type===`timeline`&&F!==void 0;return{rows:s,navigationRows:l,navigationWaiting:E.waiting,hostRows:n?.sidebar,mainWaiting:D.waiting,runId:S,detail:F,timeline:N&&`timeline`in N?N.timeline:void 0,channel:N&&`channel`in N?N.channel:void 0,humanItems:i,timelineError:L?p:void 0,loading:n===void 0&&p===void 0,lastUpdated:d,activity:I,error:L?h:p??h,notice:_,refresh:j}}function d2(e,t,n,r){if(e===void 0)return{type:`sidebar`};let i=r===void 0?{}:{filter:r};switch(t){case`channel`:return{type:`channel`,run_id:e};case`overall`:return{type:`timeline`,run_id:e,scope:`run`,...i};case`node`:return n===void 0?{type:`detail`,run_id:e,...i}:{type:`timeline`,run_id:e,scope:`node`,node:n,...i};case`graph`:return{type:`detail`,run_id:e,...i}}}function f2(e,t){return t.type===e.type?t.type===`timeline`&&e.type===`timeline`?t.scope===e.scope&&(t.scope===`run`||e.scope===`node`&&e.node===t.node):!0:!1}function p2(e){let t=e?.run.live_activity;if(t===void 0)return[];let n=lM.safeParse(t);return n.success?n.data:[]}var m2={minutes:60,seconds:1},h2=e=>Object.hasOwn(m2,e),g2=600%m2.minutes==0?{amount:String(600/m2.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function _2(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*m2[e.unit];return Number.isSafeInteger(n)?n:void 0}function v2(e){if(e===0)return`no grace`;let t=Math.floor(e/60),n=e%60,r=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return t===0?r(n,`second`):n===0?r(t,`minute`):`${r(t,`minute`)} ${r(n,`second`)}`}function y2(e){return e.map(e=>({runId:e.run_id,owner:bX(e.launch)}))}function b2(e,t){return t instanceof JN&&t.status!==void 0&&t.code!==void 0?{phase:`refused`,sent:e,error:t}:{phase:`lost`,sent:e,error:t instanceof Error?t:Error(String(t))}}var x2={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function S2(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(x2);return n.flatMap(e=>{if(!r.has(e.run_id))return[];let n=e.last_event;if(n===null||!i.includes(n))return[];let a=t.get(e.run_id);return a!==void 0&&a.last_event===n&&a.last_progress_at===e.last_progress_at?[]:[{runId:e.run_id,recorded:n===x2.hostShutdown?x2.hostShutdown:x2.dispatchStopped}]})}function C2(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}function w2(e){return(0,H.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.owner,(t.get(n.owner)??0)+1);return[...t].map(([e,t])=>({owner:e,count:t}))},[e])}var T2=`Each live dispatch is asked to stop and commit, and given the grace to end itself; whatever is still standing then is torn down, and every branch the run's records name is pushed to its origin. Nothing is sent until you confirm.`;function E2({open:e,onOpenChange:t,runs:n,blocked:r,unreadable:i=0,onConfirm:a}){let o=(0,H.useId)(),[s,c]=(0,H.useState)(g2),[l,u]=(0,H.useState)(!1),d=_2(s),f=n!==void 0&&r===void 0,p=()=>{c(g2),u(!1),t(!1)};return(0,W.jsx)(gc,{onOpenChange:e=>e?t(!0):p(),open:e,children:(0,W.jsxs)(bc,{className:`shutdown-dialog`,children:[(0,W.jsxs)(xc,{children:[(0,W.jsx)(Cc,{children:`Shut down the entire host?`}),(0,W.jsx)(wc,{children:T2})]}),(0,W.jsxs)(`div`,{className:`shutdown-dialog-body`,children:[r===void 0?n===void 0?(0,W.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:`Reading which runs this acts on…`}):(0,W.jsx)(O2,{caption:`It acts on all ${D2(n.length)} on this host, over their owners — each is interrupted, torn down and pushed:`,label:`Runs on this host`,runs:n,warning:!0}):(0,W.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:r}),i>0&&(0,W.jsxs)(`p`,{className:`shutdown-scope-note`,children:[i===1?`1 run root on this host could not be read`:`${i} run roots on this host could not be read`,`: the engine cannot read them either, so this shutdown signals nothing in them and pushes none of their branches.`]}),(0,W.jsxs)(`fieldset`,{className:`shutdown-grace`,children:[(0,W.jsx)(`legend`,{children:`Grace`}),(0,W.jsxs)(`div`,{className:`shutdown-grace-row`,children:[(0,W.jsx)(Oc,{className:`sr-only`,htmlFor:`${o}-grace`,children:`Grace`}),(0,W.jsx)(Tc,{"aria-describedby":`${o}-grace-help`,"aria-invalid":d===void 0,id:`${o}-grace`,inputMode:`numeric`,min:0,onChange:e=>c({...s,amount:e.target.value}),step:1,type:`number`,value:s.amount}),(0,W.jsx)(Oc,{className:`sr-only`,htmlFor:`${o}-unit`,children:`Grace unit`}),(0,W.jsx)(`select`,{className:`composer-select`,id:`${o}-unit`,onChange:e=>{let t=e.target.value;h2(t)&&c({...s,unit:t})},value:s.unit,children:Object.keys(m2).map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(`p`,{className:`channel-age`,id:`${o}-grace-help`,children:d===void 0?`The grace is a whole number of minutes or seconds, 0 or more.`:`How long each live dispatch has to end itself once asked: ${v2(d)}. The engine's default is ${v2(_2(g2)??0)}.`})]}),(0,W.jsxs)(`div`,{className:`composer-check shutdown-force`,children:[(0,W.jsx)(`input`,{checked:l,id:`${o}-force`,onChange:e=>u(e.target.checked),type:`checkbox`}),(0,W.jsx)(Oc,{htmlFor:`${o}-force`,children:`Force: skip the interrupt and the wait and go straight to the teardown — whatever a worker had not committed is lost.`})]})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsx)(Pa,{disabled:!f||d===void 0,onClick:()=>{d!==void 0&&(a(d,l),p())},type:`button`,variant:`destructive`,children:`Shut down the host`})]})]})})}var D2=e=>e===1?`1 run`:`${e} runs`;function O2({caption:e,label:t,runs:n,warning:r=!1}){let i=w2(n);return(0,W.jsxs)(`div`,{className:`shutdown-runs`,"data-warning":r,children:[(0,W.jsx)(`p`,{className:`shutdown-scope-note`,children:e}),(0,W.jsx)(`ul`,{"aria-label":t,children:i.map(({owner:e,count:t})=>(0,W.jsxs)(`li`,{children:[e,` — `,D2(t)]},e))})]})}function k2(e,t,n){let[r,i]=(0,H.useState)(),a=A2(r!==void 0,e,t,n);return{open:r,setOpen:i,opener:e=>()=>i(e),runs:a.rows===void 0||r===void 0?void 0:y2(a.rows),blocked:a.blocked,unreadable:e?.unreadable?.length??0}}function A2(e,t,n,r){let i=(0,H.useRef)(new Set),a=t?.next_cursor;return(0,H.useEffect)(()=>{if(!e){i.current.clear();return}a===void 0||r||i.current.has(a)||(i.current.add(a),n())},[e,a,r,n]),t===void 0?{blocked:`Reading the runs listing this view holds…`}:a===void 0?{rows:t.runs}:!r&&i.current.has(a)?{blocked:`The rest of the runs listing could not be read (${t.runs.length} runs read), so the runs this acts on cannot all be named. Close this and try again.`}:{blocked:`Reading the rest of the runs listing so every run this acts on can be named (${t.runs.length} read so far)…`}}function j2(e,t){let[n,r]=(0,H.useState)({phase:`idle`}),i=(0,H.useRef)(!1);return{state:n,confirm:(0,H.useCallback)((n,a,o)=>{if(i.current)return;i.current=!0;let s={scope:e,runs:n,grace:a,force:o,sentAt:Date.now()};r({phase:`sending`,sent:s}),t({grace:a,force:o}).then(e=>r({phase:`answered`,sent:s,report:e}),e=>r(b2(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,H.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var M2=[`host`];function N2(e){return{host:j2(`host`,(0,H.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function P2({list:e,loadMore:t,loadingMore:n,shutdowns:r}){let{open:i,setOpen:a,opener:o,runs:s,blocked:c,unreadable:l}=k2(e,t,n),u=r.host.state.phase===`sending`;return(0,W.jsxs)(`fieldset`,{"aria-label":`Shut down runs on this host`,className:`host-shutdown`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`This host`}),(0,W.jsx)(`div`,{className:`host-shutdown-actions`,children:(0,W.jsxs)(Pa,{disabled:u,onClick:o(`host`),size:`sm`,type:`button`,variant:`destructive`,children:[(0,W.jsx)(Yt,{size:14}),` Shut down the entire host`]})}),M2.map(e=>(0,W.jsx)(E2,{blocked:c,onConfirm:(e,t)=>s!==void 0&&r.host.confirm(s,e,t),onOpenChange:t=>a(t?e:void 0),open:i===e,runs:i===e?s:void 0,unreadable:l},e))]})}var F2=1e3;function I2(e,t){let[n,r]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),F2);return()=>clearInterval(e)},[]);let i=S2(e,(0,H.useRef)(new Map(t.filter(t=>e.runs.some(({runId:e})=>e===t.run_id)).map(e=>[e.run_id,e]))).current,t);return{now:n,progress:i,done:i.filter(({recorded:e})=>e===x2.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function L2({label:e,state:t,rows:n,onDismiss:r}){return t.phase===`idle`?null:(0,W.jsxs)(`section`,{"aria-label":e,className:`shutdown-status`,children:[t.phase===`sending`?(0,W.jsx)(z2,{rows:n,sent:t.sent}):t.phase===`lost`?(0,W.jsxs)(sa,{"aria-label":`${e} lost`,variant:`destructive`,children:[(0,W.jsx)(on,{}),(0,W.jsx)(ca,{children:`Shutdown lost: no answer came back`}),(0,W.jsxs)(la,{children:[(0,W.jsxs)(`p`,{children:[`The request sent at `,C2(t.sent.sentAt),` ended without an answer (`,t.error.message,`). The engine may still be carrying out the shutdown — check the runs before sending another.`]}),(0,W.jsx)(R2,{sent:t.sent})]})]}):t.phase===`refused`?(0,W.jsxs)(sa,{"aria-label":`${e} refused`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsxs)(ca,{children:[`Shutdown refused · `,t.error.status,` `,t.error.code]}),(0,W.jsxs)(la,{children:[(0,W.jsx)(`pre`,{className:`verb-text`,children:t.error.message}),(0,W.jsx)(`p`,{children:`Nothing was signalled and nothing was pushed.`})]})]}):(0,W.jsx)(V2,{label:e,report:t.report}),t.phase!==`sending`&&(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{onClick:r,size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`})})]})}function R2({sent:e}){return(0,W.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,C2(e.sentAt),` · scope `,e.scope,` · grace`,` `,v2(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function z2({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=I2(e,t);return(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`shutdown-inflight`,role:`status`,children:[(0,W.jsxs)(`p`,{className:`shutdown-inflight-head`,children:[(0,W.jsx)(Rt,{"aria-hidden":`true`,className:`animate-spin`,size:14}),(0,W.jsx)(`strong`,{children:`Shutdown in progress`}),` — still waiting for the engine's answer, `,ZF(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,W.jsx)(R2,{sent:e}),(0,W.jsx)(`p`,{children:o?n<a?`Waiting out the ${v2(e.grace)} grace until ${C2(a)} (${ZF(a-n)} left) for each live dispatch to end itself; runs are worked through one after another, each with its own grace.`:`The first grace ran out at ${C2(a)}; the engine is tearing down what is still standing and pushing branches, run by run.`:`Forced: nothing is asked or waited for; the engine is tearing the runs down and pushing their branches.`}),(0,W.jsxs)(`p`,{children:[i,` of `,e.runs.length,` `,e.runs.length===1?`run has`:`runs have`,` recorded their shutdown.`]}),r.length>0&&(0,W.jsx)(`ul`,{"aria-label":`Recorded so far`,children:r.map(({runId:e,recorded:t})=>(0,W.jsxs)(`li`,{children:[e,`:`,` `,t===x2.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function B2(e){let t=e.remote===null?``:` to ${e.remote}`,n=e.commit===null?``:` at ${e.commit}`;switch(e.result){case`pushed`:return`pushed${t}${n}`;case`already-on-origin`:return`already on its origin${t}${n}; nothing was pushed`;case`no-remote`:return`not pushed: this identity has no origin${n}`;case`refused`:return`could not be preserved${n}`}}function V2({label:e,report:t}){return(0,W.jsxs)(sa,{"aria-label":`${e} report`,variant:t.complete?`default`:`destructive`,children:[t.complete?(0,W.jsx)(Tt,{}):(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:t.complete?`Shutdown complete`:`Shutdown incomplete`}),(0,W.jsxs)(la,{className:`shutdown-report`,children:[!t.complete&&(0,W.jsx)(`p`,{children:`Not everything went as asked: a dispatch was killed at the deadline or is still running, a teardown was not clean, or a branch could not be preserved. Read the runs below.`}),(0,W.jsxs)(`p`,{className:`channel-age`,children:[`Scope `,t.scope,` · grace `,v2(t.grace_seconds),t.forced?` · forced`:``,` · runs root `,t.root]}),t.runs.length===0?(0,W.jsx)(`p`,{children:`No run was selected: nothing was signalled.`}):t.runs.map(e=>(0,W.jsxs)(`section`,{"aria-label":`Shutdown of ${e.run_id}`,className:`shutdown-report-run`,children:[(0,W.jsxs)(`h4`,{children:[e.run_id,` · owner `,e.owner,e.forced_over_owner&&` — another session's run, acted on over its owner`]}),e.dispatches.length===0?(0,W.jsx)(`p`,{children:`No live dispatch to interrupt.`}):(0,W.jsx)(`ul`,{"aria-label":`Dispatches of ${e.run_id}`,children:e.dispatches.map(e=>(0,W.jsxs)(`li`,{children:[e.node,` (pid `,e.pid,`): interrupt`,` `,e.interrupt,`; ended `,e.ended,` after`,` `,ZF(e.waited_ms),(0,W.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.node}-${e.pid}`))}),(0,W.jsxs)(`p`,{children:[`Teardown: `,e.teardown]}),e.branches.length===0?(0,W.jsx)(`p`,{children:`No branch this run's records name.`}):(0,W.jsx)(`ul`,{"aria-label":`Branches of ${e.run_id}`,children:e.branches.map(e=>(0,W.jsxs)(`li`,{children:[e.identity,`@`,e.branch,`: `,B2(e),(0,W.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.identity}@${e.branch}`))})]},e.run_id)),t.not_pushed_unread===null?t.not_pushed.length===0?(0,W.jsx)(`p`,{children:`Other unpublished branches on this host: none.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`Other unpublished branches on this host, which this shutdown did not push (`,t.not_pushed.length,`):`]}),(0,W.jsx)(`ul`,{"aria-label":`Branches not pushed`,children:t.not_pushed.map(({identity:e,branch:t})=>(0,W.jsxs)(`li`,{children:[e,`@`,t]},`${e}@${t}`))})]}):(0,W.jsxs)(`p`,{children:[`Other unpublished branches on this host: not read —`,` `,t.not_pushed_unread,`. This is not a count of zero: there may be work on this host nothing outside it carries.`]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`The engine's own report`}),(0,W.jsx)(`pre`,{className:`verb-text`,children:t.rendered})]})]})]})}var H2={crosshair:!0,ticks:{minSpacingPx:80}},U2=2e3;function W2(e){let[t,n]=e;if(n-t>=2e3)return e;let r=(t+n)/2;return[r-U2/2,r+U2/2]}var G2=1e3;function K2({completedAt:e,startedAt:t}){let n=t===void 0?void 0:$F(t),r=e===void 0?void 0:$F(e),i=q2(n!==void 0&&r===void 0);return n===void 0?null:r===void 0?(0,W.jsxs)(W.Fragment,{children:[ZF(i-n.getTime()),` · running`]}):(0,W.jsx)(W.Fragment,{children:ZF(r.getTime()-n.getTime())})}function q2(e){let[t,n]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),G2);return()=>clearInterval(t)},[e]),t}function J2({control:e}){if(e===void 0)return null;let t=e.addressable?`Turn reachable`:`No turn to reach`,n=e.addressable?`a planner's note can be delivered into the ${e.member??`member`} turn in flight`:e.reason,r=e.addressable?Ut:Vt;return(0,W.jsxs)(Ma,{"aria-label":`${t}: ${n}`,className:V(`node-view-control gap-1.5`,e.addressable?`border-info bg-info-surface text-info`:`border-warning bg-warning-surface text-warning`),title:n,variant:`outline`,children:[(0,W.jsx)(r,{"aria-hidden":`true`,size:12}),t]})}function Y2(e){return e.charAt(0).toUpperCase()+e.slice(1)}var X2=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`refused`,`exceeded`,`conflict`]],[`human`,[`human`]],[`planning`,[`planner`,`decision`,`note`]],[`contention`,[`lock`,`concurrent`,`quiet`,`wait`,`held`,`unheld`]],[`verification`,[`verification`,`gate`,`check`,`checks`,`coverage`,`judge`]],[`publication`,[`pr`,`publication`,`published`,`release`,`merge`,`merged`,`change`,`drafting`,`landing`,`landed`]],[`repository`,[`edit`,`fetch`,`push`,`branch`,`branches`,`commit`]],[`session`,[`turn`,`member`,`session`,`heartbeat`,`conversation`]],[`lifecycle`,[`run`,`graph`,`node`,`round`,`step`,`edge`,`setup`,`cleanup`,`driver`,`cross`,`upstream`]]],Z2={"change-retitled":`publication`,"title-unverified":`verification`,"node-restack-started":`repository`,"node-restacked":`repository`,"review-comments-read":`publication`,"review-reply-posted":`publication`,"review-reply-not-drafted":`publication`,"node-absorbed":`publication`,"node-readjusted":`repository`,"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`,"scratch-removed":`lifecycle`,"scratch-retained":`lifecycle`,"home-status":`lifecycle`};function Q2(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function $2(e){let t=Z2[e];if(t!==void 0)return t;let n=Q2(e);return X2.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var e4={recovery:Zt,failure:an,human:sn,planning:Ot,contention:Pt,verification:tn,publication:Nt,repository:Mt,session:Wt,lifecycle:Gt,activity:Dt};function t4({category:e,className:t=`size-3`}){let n=e4[e];return(0,W.jsx)(n,{"aria-hidden":`true`,className:t})}function n4(e){return e===`human-step`?`human step`:e}function r4(e){return e.style===`human-step`}function i4(e){switch(e){case`not-released`:return`not released yet`;case`awaiting-human-step`:return`waiting for the human step`;case`not-answered`:return`the registry did not answer`;case`not-landed`:return`released, but not carrying this work yet`;default:return e}}function a4(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function o4(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`next`?`Deferred — onto the node's next dispatch`:e}function s4(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function c4({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:n4(e.style)],[`Version`,e.version],[`Probe outcome`,e.outcome],[`Probed through`,e.form],[`Probe took`,e.elapsed_ms===void 0?void 0:`${e.elapsed_ms} ms`],[`Acknowledged by`,e.actor],[`Superseded`,a4(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,o4(e.delivery)]].filter(([,e])=>e!==void 0);return(0,W.jsxs)(W.Fragment,{children:[t.length>0&&(0,W.jsx)(`dl`,{className:`facts`,children:t.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:t})]},e))}),e.awaiting!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Held on`}),(0,W.jsx)(`ul`,{className:`release-awaiting`,children:e.awaiting.map(e=>(0,W.jsxs)(`li`,{children:[r4(e)?(0,W.jsxs)(sa,{children:[(0,W.jsx)(sn,{}),(0,W.jsxs)(ca,{children:[`Waiting on a person · `,s4(e)]}),(0,W.jsx)(la,{children:e.action??`The release is a human step and the run recorded no action for it.`})]}):(0,W.jsxs)(`p`,{className:`detail-note`,children:[`Waiting on an automated release · `,s4(e)]}),(0,W.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:i4(e.last_answer),e.waited_seconds===void 0?void 0:`waited ${e.waited_seconds}s`].filter(e=>e!==void 0).join(` · `)})]},`${e.dep}·${e.identity??``}·${e.target??``}`))})]}),e.versions!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Versions adopted`}),(0,W.jsx)(`ul`,{className:`release-awaiting`,children:e.versions.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`p`,{className:`detail-note`,children:[e.identity,` · `,e.target,` · `,e.version]})},`${e.identity}·${e.target}`))})]})]})}function l4({node:e}){let t=e.result?.release??void 0;if(t===void 0)return(0,W.jsx)(W.Fragment,{children:`Not recorded`});let n=t.identity!==e.task.repo;return(0,W.jsx)(W.Fragment,{children:[t.target,t.style===void 0?void 0:n4(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function u4({artifactId:e,client:t,runId:n}){let r=FI(`${n}/${e}`,()=>t.getArtifact(n,e),0),i=r.value?.turns??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Oneharness conversation`}),r.loading?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:`Loading conversation…`}):r.value===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:`The history store holds no readable copy of that conversation.`}):r.value.unavailable===void 0?(0,W.jsx)(Fa,{className:`gap-0 py-3`,children:(0,W.jsx)(Ia,{className:`px-3`,children:i.map(e=>(0,W.jsx)(Sw,{turn:e},e.id))})}):(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Transcript unavailable`}),(0,W.jsx)(la,{children:r.value.unavailable})]})]})}function d4({artifactId:e,client:t,heading:n,missing:r,noun:i,runId:a,unreadable:o}){let s=f4(e),c=FI(s===void 0?void 0:`${a}/${s}`,()=>t.getArtifact(a,s??``),0),l=c.value?.content;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:n}),s===void 0?(0,W.jsx)(`p`,{className:`detail-note`,children:r}):c.loading?(0,W.jsxs)(`p`,{"aria-live":`polite`,className:`detail-note`,children:[`Loading `,i,`…`]}):l===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:o}):(0,W.jsxs)(W.Fragment,{children:[c.value?.truncated===!0&&(0,W.jsxs)(`p`,{className:`detail-note`,children:[`The server keeps the end of a `,i,` this long; its beginning is not shown.`]}),(0,W.jsx)(`section`,{"aria-label":n,children:(0,W.jsx)(`pre`,{children:l})})]})]})}function f4(e){if(!(e===void 0||/[/?#]/u.test(e)))return e}function p4(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:ZF(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`&&e.status===`running`,...e.status?{status:e.status}:{}}}function m4({row:e}){let t=p4(e);return(0,W.jsxs)(`header`,{className:`detail-title`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ma,{className:`mb-1`,variant:`outline`,children:t.kind}),(0,W.jsx)(`h2`,{children:t.label}),(0,W.jsxs)(`p`,{className:`detail-when`,children:[(0,W.jsx)(iI,{at:t.startedAt}),t.duration!==void 0&&` · ${t.duration}`,t.running&&` · still running`]})]}),t.status!==void 0&&(0,W.jsx)(Ma,{variant:`secondary`,children:t.status})]})}function h4(e){let t=p4(e);return[t.kind,t.label,eI(t.startedAt),Y2(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function g4({row:e}){return(0,W.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":h4(e),children:(0,W.jsx)(t4,{category:e.category})})}var _4=`data-timeline-reading`;function v4(e){let t=e.closest(`[${_4}]`)??e.closest(`button`)?.querySelector(`[${_4}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(_4)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var y4={rows:[],total:0},b4={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},x4=`idle`,S4=new Set([...Object.keys(b4),x4]),C4=`member:`;function w4(e){return S4.has(e)?`${C4}${e}`:e}var T4=Object.entries(b4).map(([e,t])=>({id:e,label:t}));function E4(e){let t=e?.spans??[],n=[];for(let e of t){let t=e.agent_role??e.harness_scope;t!==void 0&&!n.includes(t)&&n.push(t)}let r=t.some(e=>Y4(e)===`dispatch`),[i,...a]=T4;return[...i===void 0?[]:[i],...n.map(e=>({id:w4(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var D4={run:null,node:null,step:null,dispatch:`dispatch`,verification:`verification`,publication:`publication`,"pr-drafting":`dispatch`,"conflict-resolution":`publication`,"human-wait":`human-wait`,queued:`queued`,rollup:`lock-waits`};function O4(e){return e===`agent`}function k4(e,t){return e===void 0?t===void 0?b4.dispatch:A4(t):p3(t)&&t!==e?`${e} · ${t}`:e}function A4(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var j4={"lock-wait":`Lock waits`};function M4(e,t=T4){let n=[...e].sort((e,t)=>e.start-t.start),r=n.at(0)?.start??0,i=Math.max(r+1,...n.map(e=>e.end??e.start)),a=new Set([n.at(0),n.reduce((e,t)=>e===void 0||(t.end??t.start)>(e.end??e.start)?t:e,void 0)].filter(e=>e!==void 0).map(({id:e})=>e)),o=(i-r)*.02,s=[];for(let e of n){let n=Math.max(e.end??e.start,e.start+o),r=s.findLast(t=>{let r=Math.max(t.end??t.start,t.start+o);return e.start<=r&&t.start<=n});r===void 0||a.has(e.id)?s.push(e):P4(e,t)<P4(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:N4(e,r,o)||s.push(e)}return s.sort((e,n)=>P4(n,t)-P4(e,t)||(e.end??e.start)-e.start-((n.end??n.start)-n.start))}function N4(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function P4(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function F4(e,t,n){let r=[...e.map(({at:e})=>e),...t.flatMap(e=>[e.start,e.end??e.start])],i=Math.min(...r),a=(Math.max(...r)-i)*.02,o=[];for(let t of[...e].sort((e,t)=>e.at-t.at)){let e=o.findLast(e=>t.at-e.at<=a);e===void 0?o.push(t):t.id===n&&(o[o.indexOf(e)]=t)}return o}function I4(e,t){let n=V4(e,t).rows,r=z4(n),i=z4(n,!1).flatMap(e=>{let t=B4(e);if(t===null)return[];let n=Date.parse(e.startedAt),r=e.endedAt===null?null:Date.parse(e.endedAt),i=e.rowKind===`span`&&e.span.total_duration_ms!==void 0?n+e.span.total_duration_ms:r;return[{id:e.id,label:e.displayLabel,laneId:t,payload:e,start:n,end:i,duration:i===null?null:i-n,status:e.status}]}),a=r.flatMap(e=>e.rowKind===`event`?[{id:e.id,label:e.displayLabel,at:Date.parse(e.startedAt),payload:e,status:e.status,icon:(0,H.createElement)(g4,{row:e})}]:[]),o=Math.max(...i.map(e=>e.end??e.start),...a.map(e=>e.at));return{items:i.map(e=>e.end===null?{...e,end:o,duration:o-e.start}:e),markers:a,lanes:E4(e),rows:r,tree:n}}function L4(e,t){let n=new Set,r=[],i=e=>{for(let a of e){if(a.rowKind===`group`){let e=t.has(a.id),n=a.children,o=n.at(0),s=n.at(-1);o!==void 0&&i([o]),r.push({entryKind:`collapse`,group:a,hidden:Math.max(n.length-2,0),expanded:e}),e&&i(n.slice(1,-1)),s!==void 0&&s!==o&&i([s]);continue}n.has(a.id)||(n.add(a.id),r.push({entryKind:`row`,row:a})),i(a.children)}};return i(e),r}function R4(e,t){return`${e} more ${t} events`}function z4(e,t=!0){let n=new Set,r=[],i=e=>{for(let a of e)n.has(a.id)||(n.add(a.id),r.push(a)),(t||a.rowKind!==`group`)&&i(a.children)};return i(e),r}function B4(e){return e.rowKind===`event`?null:e.role===void 0?D4[e.rowKind===`span`?e.span.kind:e.kind]??null:w4(e.role)}function V4(e,t){if(e===void 0)return y4;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=h3(e.spans,new Set,t);return n.length===0?y4:{rows:a3(n),total:n.length}}let r=new Set(n.map(({id:e})=>e)),i=new Map,a=[];for(let e of n){let t=e.parent_id!==void 0&&r.has(e.parent_id)?e.parent_id:void 0;t===void 0?a.push(e):i.set(t,[...i.get(t)??[],e])}let o=a.find(({kind:e})=>e===`node`),s=[...o===void 0?[]:K4(o,i),...a.filter(e=>e!==o).map(e=>q4(e,i)),...h3(e.spans,r,t)].sort(_3),c=n.some(e=>e.dispatch_group!==void 0||e.events.some(e=>e.dispatch_group!==void 0))?f3(s):a3(d3(u3(s)));return{span:o,rows:c,total:g3(c)}}function H4(e){return q4(e,new Map)}function U4(e){return i3(e)}function W4(e,t){return G4(e,t).at(-1)}function G4(e,t){let n=(e,r)=>{for(let i of e){if(r?i.rowKind===`event`&&i.event.id===t:i.id===t)return[i];let e=n(i.children,r);if(e.length>0)return[i,...e]}return[]},r=n(e,!1);return r.length>0?r:n(e,!0)}function K4(e,t){return[...(t.get(e.id)??[]).map(e=>q4(e,t)),...e.events.map(i3)].sort(_3)}function q4(e,t){let n=J4(e),r=e.kind===`dispatch`?e.transport_role:void 0;return{rowKind:`span`,span:e,id:e.id,kind:e.kind,...n===void 0?{}:{role:n},...r===void 0?{}:{transport:r},label:e.label,startedAt:e.started_at,endedAt:e.ended_at,status:e.status,durationMs:e.total_duration_ms??v3(e.started_at,e.ended_at),children:a3(K4(e,t)),displayLabel:l3(e,n,r),displayKind:o3(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function J4(e){return e.kind===`dispatch`?e.agent_role??e.harness_scope:void 0}function Y4(e){return e.agent_role===void 0?e.harness_scope===void 0?D4[e.kind===`rollup`?e.label:e.kind]??null:w4(e.harness_scope):w4(e.agent_role)}function X4(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?b4[e]??(e.startsWith(C4)?e.slice(7):e):n.label}function Z4(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var Q4=`Redirection`;function $4(e){if(e.surface===void 0)return;let t=[e.surface.kind,e.surface.message].filter(e=>e!==void 0);return t.length===0?void 0:t.join(`: `)}var e3=`Surface`,t3=`Blocking surface`;function n3(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function r3(e,t){let n=n3(t);return n===void 0?e:`${e} · by ${n}`}function i3(e){let t=Z4(e),n=$4(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?t3:e3:Q4;return{rowKind:`event`,event:e,id:e.record_id??e.id,kind:e.kind,label:e.step_id??``,startedAt:e.at,endedAt:null,status:e.status,durationMs:null,children:[],displayLabel:r3(t??n??(e.kind===`turn-activity`&&e.description!==void 0&&e.description!==``?e.description:void 0)??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:$2(e.kind)}}function a3(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)continue;let i=n;for(;i+1<e.length&&m3(r,e[i+1]);)i+=1;let a=e.slice(n,i+1),o=a.at(-1);a.length<4||o===void 0?t.push(...a):t.push({rowKind:`group`,count:a.length,id:`group-${r.id}`,kind:r.kind,label:`${a.length} × ${r.kind}`,startedAt:r.startedAt,endedAt:o.endedAt,status:void 0,durationMs:v3(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind,...r.role===void 0?{}:{role:r.role},...r.transport===void 0?{}:{transport:r.transport},...r.dispatch!==void 0&&a.every(e=>e.dispatch?.id===r.dispatch?.id)?{dispatch:r.dispatch}:{}}),n=i}return t}function o3(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return j4[e.label]??e.label;if(e.kind===`dispatch`)return k4(t,n);let r=D4[e.kind];return r===null?e.kind:X4(r)}function s3(e){let t=e=>(e??[]).join(`, `);switch(e.kind){case`concurrency`:return e.ahead===void 0?`behind the work already running`:`behind ${t(e.ahead)}`;case`dependencies`:return`waiting on ${t(e.blocking)}`;case`decision`:return`held by decision ${e.reference??`nobody named`}`;case`release`:return`awaiting the release of ${t(e.awaiting)}`;default:return`held by ${e.kind}`}}function c3(e){return e.map(s3).join(` and `)}function l3(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${c3(e.reasons??[])}`.trim();let r=o3(e,t,n);return e.kind===`rollup`?`${r}: ${e.count??0} recorded`:!e.label||e.label===r?r:e.kind===`dispatch`?`${r} (${e.label})`:`${r}: ${e.label}`}function u3(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=u3(e.children);return!O4(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function d3(e){let t=[],n=-1,r=0,i=(e,t)=>({...e,dispatch:t,children:e.children.map(e=>i(e,t))});for(let a of e){if(O4(a.transport)){r+=1,n=t.length,t.push(i(a,{id:a.id,label:`Dispatch ${r}`}));continue}let e=n<0?void 0:t[n];if(p3(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function f3(e){let t=new Map,n=[];for(let r of z4(e).filter(e=>e.rowKind!==`group`)){let e=r.rowKind===`event`?r.event.dispatch_group:r.span.dispatch_group,i={...r,children:[]};if(e===void 0){n.push(i);continue}let a=t.get(e.id)??{metadata:e,members:[]};a.members.push({...i,dispatch:{id:e.id,label:e.label}}),t.set(e.id,a)}let r=e=>[...a3(e.filter(e=>e.rowKind===`span`&&e.kind===`dispatch`).sort(_3)),...a3(e.filter(e=>e.rowKind!==`span`||e.kind!==`dispatch`).sort(_3))];return[...n.map(e=>({at:e.startedAt,order:e.rowKind===`event`?(e.event.journal_order??0)*3:0,rows:[e]})),...[...t.values()].map(({metadata:e,members:t})=>({at:e.started_at,order:e.order,rows:r(t)}))].sort((e,t)=>Date.parse(e.at)-Date.parse(t.at)||e.order-t.order).flatMap(({rows:e})=>e)}function p3(e){return e===`judge`||e===`llmlint`}function m3(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind&&e.role===t.role&&e.transport===t.transport}function h3(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(i3)}function g3(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+g3(t.children),0)}function _3(e,t){let n=Date.parse(e.startedAt)-Date.parse(t.startedAt);return n===0?e.rowKind===`event`&&t.rowKind===`event`?(e.event.journal_order??0)-(t.event.journal_order??0):0:n}function v3(e,t){if(t===null)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?null:r-n}function y3(e,t,n,r){let[i,a]=(0,H.useState)(),o=t===void 0||n===void 0?void 0:JSON.stringify([t,n]);(0,H.useEffect)(()=>{if(o===void 0||t===void 0||n===void 0)return;let r=!0;return e.getConversation(t,n).then(e=>{r&&a({key:o,conversation:e})}).catch(e=>{if(!r)return;let t=e instanceof Error?e:Error(String(e));a(e=>e?.key===o&&e.conversation!==void 0?e:{key:o,error:t})}),()=>{r=!1}},[e,t,n,o,r]);let s=i?.key===o?i:void 0;return(0,H.useMemo)(()=>({conversation:s?.conversation,error:s?.error,loading:o!==void 0&&s===void 0}),[s,o])}var b3=32;function x3(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function S3(e,t){let n=(0,H.useRef)(null),r=(0,H.useRef)(!0),i=(0,H.useRef)({key:e,count:t}),a=(0,H.useCallback)(()=>{let e=n.current;e!==null&&(r.current=e.scrollHeight-e.scrollTop-e.clientHeight<=b3)},[]),o=(0,H.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=x3(e),n.current?.addEventListener(`scroll`,a,{passive:!0}),a()},[a]);return(0,H.useLayoutEffect)(()=>{let a=i.current;i.current={key:e,count:t};let o=a.key===e&&a.count>0&&t>a.count,s=n.current;!o||s===null||!r.current||(s.scrollTop=s.scrollHeight)},[e,t]),o}var C3=25;function w3({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:G3(r),a=i?.kind===`conversation`?i.value:void 0,o=y3(e,t,a,r===void 0?void 0:B3(r));return(0,W.jsx)(`section`,{"aria-label":`Timeline item detail`,className:`timeline-detail`,children:(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsx)(`div`,{className:`p-[22px] max-sm:p-3`,ref:S3(a,V3(r,o)),children:r===void 0?(0,W.jsxs)(`div`,{className:`detail-placeholder`,children:[(0,W.jsx)(Lt,{size:30}),(0,W.jsx)(`p`,{children:`Select an item in the timeline to read what it recorded.`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(m4,{row:r}),(0,W.jsx)(bf,{className:`my-4`}),(0,W.jsx)(T3,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function T3({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=H3(n);if(o!==void 0)return(0,W.jsx)(F3,{redirection:o,row:n});let s=U3(n);if(s!==void 0)return(0,W.jsx)(c4,{release:s});let c=W3(n);return c===void 0?i?.kind===`conversation`?(0,W.jsxs)(W.Fragment,{children:[n.rowKind===`event`&&(0,W.jsx)(R3,{row:n,reference:i}),(0,W.jsx)(A3,{row:n,transcript:a})]}):q3(n)?(0,W.jsx)(j3,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&f4(i.value)!==void 0?(0,W.jsx)(M3,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&f4(i.value)!==void 0?(0,W.jsx)(N3,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):J3(n,i)&&r!==void 0?(0,W.jsx)(P3,{node:r,reference:i}):(0,W.jsx)(R3,{reference:i,row:n}):(0,W.jsx)(L3,{row:n,surface:c})}function E3({turn:e}){return e.judges===void 0||e.judges.length===0?null:(0,W.jsx)(`ul`,{"aria-label":`Judges on turn ${e.id}`,className:`judge-decisions`,children:e.judges.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`judge-decision-who`,children:[e.judge,` (`,e.kind,`)`]}),` `,e.decision,` — `,e.reason]},e.judge))})}function D3(e){return e.tool?.turn??e.id}function O3(e,t){if(e.rowKind!==`event`||e.event.tool===void 0)return;let n=D3(e.event),r=t.find(({id:e})=>e===n);if(r===void 0)return;let{index:i,tool_call_id:a}=e.event.tool;return a!==void 0&&r.tools.some(e=>e.toolCallId===a)?{turnId:r.id,toolCallId:a}:{turnId:r.id,eventIndex:i}}function k3({turn:e}){let t=[e.unknown.instruction_truncated===!0?`its prompt`:void 0,e.unknown.truncated===!0?`its reply`:void 0,e.tools.some(e=>e.output_truncated===!0)?`a tool's output`:void 0,e.tools.some(e=>e.input_truncated===!0)?`a tool's input`:void 0].filter(e=>e!==void 0);return t.length===0?null:(0,W.jsxs)(sa,{className:`mb-3`,role:`note`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Cut by the recorder`}),(0,W.jsxs)(la,{children:[`The run's recorder cut `,t.join(`, `),` to its bound, and no whole copy exists: neither the member's report nor a history file this run names holds it.`]})]})}function A3({row:e,transcript:t}){let[n,r]=(0,H.useState)(C3),i=t.conversation?.conversation.turns??[],a=e.rowKind===`event`?D3(e.event):void 0,o=a===void 0?i:i.filter(({id:e})=>e===a),s=Dm(o.map(e=>({id:e.id,time:Date.parse(e.timestamp)})));if(t.loading)return(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-inline`,children:[(0,W.jsx)(xf,{className:`h-2 w-40`}),(0,W.jsx)(xf,{className:`h-2 w-24`}),`Loading transcript…`]});if(t.conversation===void 0)return(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Transcript unavailable`}),(0,W.jsx)(la,{children:t.error?.message??`The server recorded no transcript.`})]});let{conversation:c,attribution:l}=t.conversation,u=Y3(l.agentRole,l.transportRole),d=O3(e,o);return(0,W.jsx)(Fa,{className:`gap-0 py-3`,children:(0,W.jsxs)(Ia,{className:`px-3`,children:[(0,W.jsxs)(`header`,{className:`transcript-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{className:`eyebrow`,children:[e.dispatch===void 0?``:`${e.dispatch.label} · `,u,l.persona?` · ${l.persona}`:``]}),(0,W.jsx)(`h4`,{children:c.name})]}),(0,W.jsx)(gm,{state:c.state})]}),(0,W.jsx)(bf,{className:`my-2.5`}),(0,W.jsx)(`div`,{className:`conversation-timeline-sticky`,children:(0,W.jsx)(Em,{cursor:s.cursor,...d===void 0?{}:{focus:d},onSelectTurn:s.scrollTo,turns:[...o]})}),o.length===0?(0,W.jsx)(`p`,{className:`detail-note`,children:`This turn is no longer part of the recorded transcript.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{ref:s.containerRef,children:o.slice(0,n).map(e=>(0,W.jsxs)(`div`,{ref:t=>s.register(e.id,t),children:[(0,W.jsx)(k3,{turn:e}),(0,W.jsx)(Sw,{author:{label:u},...d?.turnId===e.id?{focus:d}:{},turn:e}),(0,W.jsx)(E3,{turn:e})]},e.id))}),o.length>n&&(0,W.jsxs)(Pa,{onClick:()=>r(n+C3),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,o.length,` turns`]})]})]})})}function j3({row:e,client:t,runId:n,reference:r}){let i=e.rowKind===`span`?e.span.detail:void 0,a=i?.artifact_id??(r?.kind===`gate_log`?r.value:void 0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Verification record`}),(0,W.jsx)(`dl`,{className:`facts`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Result`}),(0,W.jsx)(`dd`,{children:i?.ok===void 0?e.status??`in progress`:i.ok?`passed`:`failed`})]})}),i?.output_tail&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Output`}),(0,W.jsx)(`pre`,{children:i.output_tail})]}),(0,W.jsx)(d4,{artifactId:a,client:t,heading:`Full log`,missing:`No readable log was recorded.`,noun:`log`,runId:n,unreadable:`No readable log was recorded.`}),(0,W.jsxs)(`p`,{className:`detail-note`,children:[`Verification `,e.status??`in progress`,`.`]})]})}function M3({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(d4,{artifactId:e,client:t,heading:`Worker report`,missing:`This settlement recorded no report.`,noun:`report`,runId:i,unreadable:`This run kept no readable copy of that report.`}),(0,W.jsx)(R3,{reference:n,row:r})]})}function N3({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(u4,{artifactId:e,client:t,runId:i}),(0,W.jsx)(R3,{reference:n,row:r})]})}function P3({node:e,reference:t}){let n=e.detail?.verification.checks??[],r=e.detail?.publication;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Publication`}),r?.pr_url&&(0,W.jsx)(z3,{fallback:``,reference:{kind:`pr`,value:r.pr_url}}),r?.merged&&r.commit_url?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:r.commit_url,rel:`noreferrer`,target:`_blank`,children:[`Merged commit `,r.commit?.slice(0,8),` `,(0,W.jsx)(jt,{size:13})]})}):r?.branch_url?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:r.branch_url,rel:`noreferrer`,target:`_blank`,children:[`Branch `,r.branch,` `,(0,W.jsx)(jt,{size:13})]})}):!r?.pr_url&&(0,W.jsx)(z3,{fallback:`No publication was recorded.`,reference:t}),(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Observed checks`}),n.length===0?(0,W.jsx)(`p`,{className:`detail-note`,children:`No checks were observed on this node.`}):(0,W.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.name}),(0,W.jsx)(`dd`,{children:e.url?(0,W.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.state}):e.state})]},e.name))})]})}function F3({redirection:e,row:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Delivery`}),(0,W.jsx)(`dd`,{children:e.delivered?`Live — into the turn that was already running`:`Deferred — onto the node's next dispatch`})]}),e.turn!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Turn`}),(0,W.jsx)(`dd`,{children:e.turn===`turn-end`?`Left to end — the note reached it as it ended`:`Interrupted — its replacement opened on the note`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Redirected at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(iI,{at:t.startedAt,relative:!0})})]}),e.member!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Member`}),(0,W.jsx)(`dd`,{children:e.member})]}),e.input_bytes!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Note`}),(0,W.jsxs)(`dd`,{children:[e.input_bytes,` bytes offered`]})]}),(0,W.jsx)(I3,{row:t})]}),e.reason!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Why it was not delivered`}),(0,W.jsx)(`p`,{className:`detail-note`,children:e.reason})]})]})}function I3({row:e}){let t=e.rowKind===`event`?n3(e.event):void 0;return t===void 0?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Author`}),(0,W.jsx)(`dd`,{children:t})]})}function L3({surface:e,row:t}){let n=[[`Kind`,e.kind],[`Raised by`,e.source],[`Blocking`,e.blocking===void 0?void 0:e.blocking?`yes — dependents wait on the answer`:`no — nothing waits on it`]].filter(([,e])=>e!==void 0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(iI,{at:t.startedAt,relative:!0})})]}),n.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:t})]},e))]}),e.message!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Message`}),(0,W.jsx)(`p`,{className:`detail-note`,children:e.message})]})]})}function R3({row:e,reference:t}){if(e.rowKind===`event`)return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(iI,{at:e.startedAt,relative:!0})})]}),Object.entries(e.event.fields??{}).map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:typeof t==`string`?t:JSON.stringify(t)})]},e))]}),t!==void 0&&(0,W.jsx)(z3,{reference:t,fallback:`No recorded artifact.`})]});let n=e.rowKind===`group`?void 0:e,r=e.rowKind===`span`&&e.span.count!==void 0?`${e.span.count} records`:void 0,i=(e.rowKind===`span`?e.span.reasons:void 0)??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(iI,{at:e.startedAt,relative:!0})})]}),e.rowKind===`span`&&(e.endedAt!==null||e.status===`running`)&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Ended`}),(0,W.jsx)(`dd`,{children:e.endedAt===null?`Still running`:(0,W.jsx)(iI,{at:e.endedAt,relative:!0})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Status`}),(0,W.jsx)(`dd`,{children:e.status??`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Duration`}),(0,W.jsx)(`dd`,{children:e.durationMs===null?`Not recorded`:ZF(e.durationMs)})]}),r!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Aggregated`}),(0,W.jsx)(`dd`,{children:r})]}),i.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Waiting on`}),(0,W.jsx)(`dd`,{children:i.map(s3).join(` and `)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Step`}),(0,W.jsx)(`dd`,{children:K3(n)??`None`})]}),(0,W.jsx)(I3,{row:e})]}),(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,W.jsx)(z3,{fallback:e.rowKind===`span`&&e.span.kind===`dispatch`?`No transcript was recorded for this dispatch.`:`This item points at no recorded artifact.`,reference:t})]})}function z3({reference:e,fallback:t}){return e===void 0?(0,W.jsx)(`p`,{className:`detail-note`,children:t}):e.value.startsWith(`http`)?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:e.value,rel:`noreferrer`,target:`_blank`,children:[e.value,` `,(0,W.jsx)(jt,{size:13})]})}):(0,W.jsxs)(`p`,{className:`detail-note`,children:[(0,W.jsx)(`span`,{className:`detail-reference-kind`,children:e.kind}),(0,W.jsx)(`code`,{children:e.value})]})}function B3(e){if(e.rowKind!==`span`)return e.id;let t=e.span.events.at(-1);return[e.span.id,e.span.status??``,e.span.ended_at??``,e.span.events.length,t?.id??``,t?.at??``,t?.status??``].join(`|`)}function V3(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function H3(e){return e.rowKind===`event`?e.event.redirection:void 0}function U3(e){return e.rowKind===`event`?e.event.release:void 0}function W3(e){return e.rowKind===`event`?e.event.surface:void 0}function G3(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function K3(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function q3(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function J3(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function Y3(e,t){return k4(e,t)}function X3({client:e,runId:t,node:n,nodes:r,timeline:i,timelineError:a,selectedItemId:o,onSelectItem:s,onBack:c,selectedTab:l,onSelectTab:u}){let d=(0,H.useMemo)(()=>V4(i,n.id),[i,n.id]);(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(o===void 0?c():s())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,s,o]);let f=n.detail?.publication===void 0?n.result?.pr??void 0:n.detail.publication.pr_url;return(0,W.jsxs)(`section`,{"aria-label":`Timeline for ${n.label}`,className:`node-view`,children:[(0,W.jsxs)(`header`,{className:`node-view-head`,children:[(0,W.jsx)(`nav`,{"aria-label":`Breadcrumb`,children:(0,W.jsxs)(`ol`,{className:`breadcrumb`,children:[(0,W.jsx)(`li`,{children:(0,W.jsxs)(Pa,{onClick:c,size:`sm`,type:`button`,variant:`ghost`,children:[(0,W.jsx)(vt,{size:14}),` Graph`]})}),(0,W.jsx)(`li`,{"aria-current":`page`,children:(0,W.jsx)(`span`,{className:`breadcrumb-node`,children:n.label})})]})}),(0,W.jsxs)(`div`,{className:`node-view-facts`,children:[(0,W.jsx)(w0,{className:`node-view-state`,state:n.status}),(0,W.jsx)(J2,{control:n.control}),(0,W.jsxs)(`span`,{className:`node-view-meta`,children:[n.kind,` node · `,n.telemetry?.turns??0,` turns ·`,` `,n.telemetry?.lint??0,` lint turns`]}),f!==void 0&&(0,W.jsxs)(`a`,{className:`node-view-pr`,href:f,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,W.jsx)(jt,{size:12})]})]})]}),(0,W.jsx)(o6,{node:n,nodes:r}),(0,W.jsx)(a6,{node:n}),(0,W.jsxs)(bp,{className:`node-tabs`,onValueChange:e=>{q0(e)&&u(e)},value:l,children:[(0,W.jsx)(Sp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(K0).map(([e,t])=>(0,W.jsx)(Cp,{value:e,children:t},e))}),(0,W.jsxs)(wp,{className:`node-tab-panel`,value:`task`,children:[(0,W.jsx)(g1,{source:n6(n.task)}),(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Settled as`}),(0,W.jsx)(`dd`,{children:s6(n.result?.outcome)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Outcome`}),(0,W.jsx)(`dd`,{children:s6(n.result?.detail)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Graph overrides`}),(0,W.jsx)(`dd`,{children:(n.task.sets??[]).length===0?`None`:(0,W.jsx)(`ol`,{"aria-label":`Graph overrides`,className:`sets-served`,children:n.task.sets?.map((e,t)=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},t))})})]})]})]}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`criteria`,children:(0,W.jsx)(g1,{source:r6(n.task)})}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`dependencies`,children:(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Dependencies`}),(0,W.jsx)(`dd`,{children:(n.task.deps??[]).map(e=>{let t=r.find(t=>t.id===e)?.status;return t===void 0?e:`${e} (${t})`}).join(`, `)||`None`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Unblocks`}),(0,W.jsx)(`dd`,{children:n.dependents.join(`, `)||`None`})]})]})}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`remote`,children:(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Publication`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(i6,{node:n})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Branch`}),(0,W.jsx)(`dd`,{children:n.detail?.publication?.branch??`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Merge`}),(0,W.jsx)(`dd`,{children:n.detail?.publication?n.detail.publication.merged?`Merged`:`Not merged`:`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Release`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(l4,{node:n})})]}),(0,W.jsxs)(`div`,{className:`remote-check-facts`,children:[(0,W.jsx)(`dt`,{children:`Verification coverage`}),(0,W.jsxs)(`dd`,{children:[`Hook:`,` `,n.detail?.verification.pre_push_hook?`present`:`not recorded`,` · `,`Required checks:`,` `,n.detail?.verification.required_checks?.join(`, `)||`none configured`]})]}),(0,W.jsxs)(`div`,{className:`remote-check-facts`,children:[(0,W.jsx)(`dt`,{children:`Observed checks`}),(0,W.jsx)(`dd`,{children:(n.detail?.verification.checks??[]).length===0?`No checks observed`:(0,W.jsxs)(`table`,{"aria-label":`Remote checks`,className:`remote-checks`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{children:`Name`}),(0,W.jsx)(`th`,{children:`Status`}),(0,W.jsx)(`th`,{children:`Conclusion`}),(0,W.jsx)(`th`,{children:`Runtime`}),(0,W.jsx)(`th`,{children:`Required`})]})}),(0,W.jsx)(`tbody`,{children:n.detail?.verification.checks?.map(e=>(0,W.jsxs)(`tr`,{className:e.status===`completed`&&![`success`,`neutral`,`skipped`].includes(e.conclusion??``)?`check-failing`:void 0,children:[(0,W.jsx)(`th`,{scope:`row`,children:e.url?(0,W.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.name}):e.name}),(0,W.jsx)(`td`,{children:e.status??`Not recorded`}),(0,W.jsx)(`td`,{children:e.conclusion??`—`}),(0,W.jsx)(`td`,{children:(0,W.jsx)(K2,{...e.started_at===void 0?{}:{startedAt:e.started_at},...e.completed_at===void 0?{}:{completedAt:e.completed_at}})}),(0,W.jsxs)(`td`,{title:e.requirement,className:e.required?`check-required`:`check-optional`,children:[(0,W.jsx)(`svg`,{role:`img`,"aria-label":e.required?`required`:`not required`,width:`12`,height:`12`,viewBox:`0 0 12 12`,children:e.required?(0,W.jsx)(`path`,{d:`M6 0.5 L11 2.5 V6 C11 9 8.5 11 6 11.5 C3.5 11 1 9 1 6 V2.5 Z`,fill:`currentColor`}):(0,W.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`2 1.5`})}),e.required?`Required`:`Optional`]})]},e.name))})]})})]})]})}),(0,W.jsx)(wp,{className:`node-timeline-panel`,value:`timeline`,children:a===void 0?i===void 0?(0,W.jsx)(`div`,{"aria-live":`polite`,className:`loading-state`,children:`Loading the recorded timeline…`}):d.rows.length===0?(0,W.jsxs)(Fa,{className:`m-5 items-center gap-2 p-8 text-muted-foreground`,children:[(0,W.jsx)(`p`,{className:`m-0`,children:`This node has no recorded timeline yet.`}),(0,W.jsx)(`p`,{className:`m-0 text-[11px]`,children:`Spans and events appear here as the run records them.`})]}):(0,W.jsx)(Z3,{client:e,node:n,onSelectItem:s,runId:t,selectedItemId:o,timeline:i}):(0,W.jsxs)(sa,{className:`m-5 w-auto`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Timeline unavailable`}),(0,W.jsx)(la,{children:a.message})]})})]})]})}function Z3({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,H.useMemo)(()=>I4(a,t.id),[a,t.id]),[s,c]=(0,H.useState)(()=>new Set),l=(0,H.useMemo)(()=>{if(i!==void 0)return G4(o.tree,i).find(e=>e.rowKind===`group`)?.id},[o.tree,i]),u=(0,H.useMemo)(()=>l===void 0?s:new Set([...s,l]),[s,l]),d=(0,H.useMemo)(()=>L4(o.tree,u),[o.tree,u]),f=Dm((0,H.useMemo)(()=>d.flatMap(e=>e.entryKind===`row`?[{id:e.row.id,time:Date.parse(e.row.startedAt)}]:[]),[d])),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(),_=(0,H.useMemo)(()=>M4(o.items,o.lanes),[o.items,o.lanes]),v=(0,H.useMemo)(()=>F4(o.markers,o.items,i),[o.items,o.markers,i]),y=(0,H.useMemo)(()=>Q3([...o.items,...o.markers.map(({at:e})=>({start:e}))]),[o.items,o.markers]),b=(0,H.useMemo)(()=>Q3([...p?o.items:_,...v.map(({at:e})=>({start:e}))]),[p,o.items,_,v]),x=f.cursor===void 0?void 0:Math.min(Math.max(f.cursor,y[0]),y[1]),S=i===void 0?void 0:W4(o.rows,i),C=e=>{n(e),f.scrollTo(e)},{scrollTo:w}=f;return(0,H.useEffect)(()=>{i!==void 0&&w(i)},[i,w]),(0,W.jsxs)(`div`,{className:`node-execution`,"data-expanded":p,children:[(0,W.jsx)(`section`,{"aria-label":`Node timeline`,className:`node-timeline-sticky`,"data-testid":`node-timeline`,children:(0,W.jsx)(Cn,{...H2,axis:{origin:y[0]},cursor:x,expanded:p,getFailureExcerpt:e=>e.payload.rowKind===`span`?e.payload.span.detail?.output_tail:void 0,items:p?o.items:_,lanes:o.lanes,markers:v,onExpandedChange:m,onRangeChange:e=>g(e[0]<=b[0]&&e[1]>=b[1]?void 0:W2(e)),onSelect:e=>C(e.id),range:h??b,selectedId:i})}),(0,W.jsx)(`section`,{"aria-label":`Node transcript`,className:`node-transcript`,ref:f.containerRef,children:$3(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,W.jsx)(t6,{onOpen:C,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,W.jsx)(e6,{entry:e,onToggle:()=>c(t=>{let n=new Set(t);return n.has(e.group.id)?n.delete(e.group.id):n.add(e.group.id),n})},`collapse-${e.group.id}`));return e.dispatch===void 0?(0,W.jsx)(H.Fragment,{children:t},e.id):(0,W.jsxs)(`section`,{"aria-label":e.dispatch.label,className:`transcript-dispatch`,children:[(0,W.jsx)(`h3`,{children:e.dispatch.label}),t]},e.id)})}),S!==void 0&&(0,W.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>n(),size:`icon`,variant:`ghost`,children:(0,W.jsx)(un,{})}),(0,W.jsx)(w3,{client:e,node:t,row:S,runId:r})]})]})}function Q3(e){let t=e.map(({start:e})=>e),n=e.map(e=>e.end??e.start);if(t.length===0)return[0,1];let r=Math.min(...t),i=Math.max(...n);return[r,i>r?i:r+1]}function $3(e){let t=[];for(let n of e){let e=n.entryKind===`row`?n.row:n.group,r=t.at(-1);e.dispatch!==void 0&&r?.dispatch!==void 0&&r.dispatch.id===e.dispatch.id?r.entries.push(n):t.push({id:e.id,dispatch:e.dispatch,entries:[n]})}return t}function e6({entry:e,onToggle:t}){let n=R4(e.hidden,e.group.kind);return(0,W.jsx)(`p`,{className:`transcript-collapsed`,children:(0,W.jsxs)(`button`,{"aria-expanded":e.expanded,onClick:t,type:`button`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),e.expanded?`Collapse ${n}`:`Show ${n}`]})})}function t6({row:e,selected:t,register:n,onOpen:r}){return(0,W.jsx)(`article`,{"aria-label":e.displayLabel,className:`transcript-item`,"data-dispatch-group":e.dispatch?.label,"data-journal-seq":e.rowKind===`event`?e.event.seq:void 0,"data-selected":t,ref:t=>n(e.id,t),children:(0,W.jsxs)(`button`,{"aria-label":`Open ${e.displayLabel}`,onClick:()=>r(e.id),type:`button`,children:[(0,W.jsxs)(`span`,{className:`eyebrow`,children:[e.rowKind===`event`&&(0,W.jsx)(t4,{category:e.category}),e.displayKind]}),(0,W.jsx)(`strong`,{children:e.displayLabel}),(0,W.jsxs)(`span`,{className:`transcript-facts`,children:[(0,W.jsx)(iI,{at:e.startedAt}),e.durationMs!==null&&` · ${ZF(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function n6(e){if(e.task!==void 0)return e.task;let t=e.steps??[];return t.length===0?`No task prose recorded.`:t.map(e=>`## ${e.id}\n\n${e.task}`).join(`
|
|
112
|
+
`)&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)for(let e of i){let t=n.current.get(e.getAttribute(`data-row-key`)??``),r=a.get(e.getAttribute(`data-row-key`)??``);t===void 0||r===void 0||t===r||e.animate([{transform:`translateY(${t-r}px)`},{transform:`translateY(0)`}],{duration:a2,easing:`ease-out`})}n.current=a},[e,t])}function c2({rows:e,selectedRunId:t,onSelect:n,onOpenProject:r,onHost:i,hostCurrent:a=!1,onActionItems:o,actionItemsCurrent:s=!1,hiddenKinds:c,onKindsChange:l,updates:u,drawerOpen:d=!1,drawerRef:f}){let{kinds:p,groups:m}=i2(e,c,t,r??n),h=(0,H.useRef)(null);return s2(h,m),(0,W.jsx)(`nav`,{"aria-label":`Projects`,className:`run-nav`,"data-open":d,id:`run-navigation`,ref:f,children:(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`px-[18px] py-6 max-sm:px-2`,children:[(0,W.jsxs)(`div`,{className:`brand`,children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`brand-mark`,children:(0,W.jsx)(gt,{size:20})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Local orchestration`}),(0,W.jsx)(`h1`,{children:`DAG Observatory`})]})]}),(0,W.jsx)(bf,{className:`my-[22px]`}),(0,W.jsxs)(`div`,{className:`nav-pages`,children:[(0,W.jsx)(Pa,{"aria-current":a?`page`:void 0,onClick:i,variant:`ghost`,children:`Host`}),o&&(0,W.jsx)(Pa,{"aria-current":s?`page`:void 0,onClick:o,variant:`ghost`,children:`Action items`})]}),p.length>0&&(0,W.jsxs)(`details`,{className:`kind-filter`,children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsxs)(`span`,{children:[`Run kinds:`,` `,p.filter(e=>!c.includes(e)).length,` of`,` `,p.length]}),(0,W.jsx)(St,{"aria-hidden":`true`,size:14})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Run kinds`}),p.map(e=>(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:!c.includes(e),onChange:t=>l(t.target.checked?c.filter(t=>t!==e):[...c,e])}),e]},e))]})]}),u,e===void 0?(0,W.jsx)(`p`,{role:`status`,children:`Loading projects…`}):(0,W.jsx)(`div`,{className:`nav-rows`,ref:h,children:m.map(e=>(0,W.jsxs)(`fieldset`,{"aria-label":`Project ${e.label}`,className:`project-group`,children:[(0,W.jsxs)(`div`,{className:`project-row`,[o2]:`project:${e.key}`,children:[(0,W.jsx)(`button`,{"aria-expanded":e.expanded,"aria-label":`${e.expanded?`Collapse`:`Expand`} ${e.label}`,className:`project-toggle`,onClick:e.toggle,type:`button`,children:(0,W.jsx)(Ct,{"aria-hidden":`true`,"data-open":e.expanded,size:12})}),(0,W.jsxs)(`button`,{className:`project-open`,onClick:e.open,type:`button`,children:[(0,W.jsx)(`span`,{className:`project-name`,children:e.label}),(0,W.jsxs)(`span`,{className:`project-count`,children:[e.runs.length,(0,W.jsx)(`span`,{className:`sr-only`,children:` shown runs`})]})]})]}),e.expanded&&e.runs.length===0&&(0,W.jsx)(`p`,{className:`run-list-status`,role:`status`,children:`No runs of the shown kinds.`}),e.expanded&&e.runs.length>0&&(0,W.jsx)(`ul`,{"aria-label":`Runs of ${e.label}`,className:`run-list`,children:e.runs.map(e=>{let r=t===e.id,i=[e.state,n2(e)].filter(Boolean).join(` · `);return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{"aria-current":r?`page`:void 0,className:`run-link`,"data-active":r,onClick:()=>n(e.id),title:i,type:`button`,"data-row-key":`run:${e.id}`,children:[(0,W.jsxs)(fm,{children:[(0,W.jsx)(pm,{asChild:!0,children:(0,W.jsx)(`span`,{role:`img`,"aria-label":e.state,className:V(`run-dot`,D0(e.state))})}),(0,W.jsx)(mm,{children:e.state})]}),(0,W.jsx)(`span`,{className:`run-link-name`,children:e.name}),e.kind&&(0,W.jsx)(`span`,{"aria-label":e.kind,className:`run-link-tag`,role:`note`,children:e.kind}),r&&(0,W.jsx)(`span`,{className:`run-link-counts`,children:i})]})},e.id)})})]},e.key))})]})})})}function l2(){let[e,t]=(0,H.useState)(!1),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)(!1),a=(0,H.useCallback)(()=>t(!1),[]),o=(0,H.useCallback)(()=>t(e=>!e),[]);return(0,H.useEffect)(()=>{if(!e)return;let r=e=>{e.key===`Escape`&&t(!1)},i=()=>{n.current?.offsetParent===null&&t(!1)};return document.addEventListener(`keydown`,r),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`keydown`,r),window.removeEventListener(`resize`,i)}},[e]),(0,H.useEffect)(()=>{e?r.current?.querySelector(`button`)?.focus():i.current&&n.current?.focus(),i.current=e},[e]),{open:e,close:a,toggle:o,menuButton:n,drawer:r}}function u2(e,t){let[n,r]=(0,H.useState)(0),i=(0,H.useRef)(void 0),a=(0,H.useRef)(t);a.current=t;let o=e===`live`,s=(0,H.useRef)(o);s.current=o;let c=(0,H.useCallback)(e=>{i.current=void 0,r(0),a.current(e)},[]),l=(0,H.useCallback)(()=>{i.current!==void 0&&c(i.current.value)},[c]),u=(0,H.useCallback)((e,t=1)=>{s.current?c(e):(i.current={value:e},r(e=>e+t))},[c]),d=(0,H.useCallback)(()=>{i.current=void 0,r(0)},[]);return(0,H.useEffect)(()=>{o&&l()},[o,l]),(0,H.useEffect)(()=>{if(typeof e!=`number`)return;let t=setInterval(l,e*1e3);return()=>clearInterval(t)},[e,l]),{waiting:n,show:c,take:l,offer:u,drop:d}}function d2(e,t){let[n,r]=(0,H.useState)(),[i,a]=(0,H.useState)({}),o=(0,H.useRef)([]),[s,c]=(0,H.useState)(),[l,u]=(0,H.useState)(),[d,f]=(0,H.useState)(),[p,m]=(0,H.useState)(),[h,g]=(0,H.useState)(),[_,v]=(0,H.useState)(),[y,b]=(0,H.useState)(0),x=t.runId,S=s===void 0||x!==void 0&&s.some(e=>e.id===x)?x:x!==void 0||t.selectFirst?e2(s)[0]?.id:void 0,C=(0,H.useMemo)(()=>t.humanItems??f2(t.host?void 0:S,t.view,t.nodeId,t.filter),[t.humanItems,t.host,S,t.view,t.nodeId,t.filter]),w=(0,H.useRef)(void 0),T=(0,H.useRef)(C);T.current=C;let E=u2(t.navigationUpdates,u),D=u2(t.mainUpdates,(0,H.useCallback)(e=>{r(e.state);let{visible:t}=e.state;if(t.type===`human-items`){let{items:n,detail:r}=t;a({items:n,detail:r,...e.view.type===`human-items`&&e.view.item!==void 0?{item:e.view.item}:{}})}f(new Date().toISOString()),e.reset!==void 0&&v(`The live view was re-sent whole: ${e.reset}.`)},[])),O=t.navigationUpdates!==`off`||t.mainUpdates!==`off`,k=(0,H.useRef)(O);k.current=O,(0,H.useEffect)(()=>{m(void 0);let t=!0,n=e.live({view:T.current,paused:!k.current,onState:(e,r)=>{let i=o.current;o.current=e.sidebar,c(e.sidebar),m(void 0),g(void 0);let a={state:e,view:n.view,...r.kind===`reset`?{reset:r.reason}:{}};if(r.kind===`snapshot`){if(D.show(a),t)E.show(e.sidebar);else if(i!==e.sidebar){let t=r2(i,e.sidebar);t>0&&E.offer(e.sidebar,t)}t=!1;return}if(r.kind===`reset`){E.offer(e.sidebar),D.offer(a);return}let s=r.frame.type===`run.changed`||r.frame.type===`run.removed`;s&&E.offer(e.sidebar),(!s||e.visible.type===`sidebar`)&&D.offer(a)},onError:e=>{if(n.view.type===`human-items`){a(t=>({...t.items===void 0?{}:{items:t.items},error:e.message})),n.change({type:`sidebar`});return}if(e instanceof YN&&(e.code===`run_not_found`||e.code===`node_not_found`)){n.change({type:`sidebar`});return}m(e)},onDisconnected:()=>g(Error(`Live telemetry stream disconnected`)),onConnected:()=>g(void 0)});return w.current=n,()=>{n.close(),w.current===n&&(w.current=void 0)}},[e,y,D.show,D.offer,E.show,E.offer]),(0,H.useEffect)(()=>{JSON.stringify(w.current?.view)!==JSON.stringify(C)&&D.drop(),w.current?.change(C),C.type!==`human-items`&&a(e=>Object.keys(e).length===0?e:{})},[C,D.drop]),(0,H.useEffect)(()=>{O?w.current?.resume():w.current?.pause()},[O]);let A=(0,H.useCallback)(()=>{E.take(),D.take()},[E.take,D.take]),j=(0,H.useCallback)(()=>{v(void 0),A(),b(e=>e+1)},[A]),M=n?.visible,N=M!==void 0&&M.type!==`sidebar`&&M.type!==`human-items`&&M.run_id===S&&p2(M,C)?M:void 0,P=(0,H.useRef)(void 0),F=N?.detail??(P.current?.run.run_id===S?P.current:void 0);P.current=F;let I=(0,H.useMemo)(()=>m2(F),[F]),L=p!==void 0&&C.type===`timeline`&&F!==void 0;return{rows:s,navigationRows:l,navigationWaiting:E.waiting,hostRows:n?.sidebar,mainWaiting:D.waiting,runId:S,detail:F,timeline:N&&`timeline`in N?N.timeline:void 0,channel:N&&`channel`in N?N.channel:void 0,humanItems:i,timelineError:L?p:void 0,loading:n===void 0&&p===void 0,lastUpdated:d,activity:I,error:L?h:p??h,notice:_,refresh:j}}function f2(e,t,n,r){if(e===void 0)return{type:`sidebar`};let i=r===void 0?{}:{filter:r};switch(t){case`channel`:return{type:`channel`,run_id:e};case`overall`:return{type:`timeline`,run_id:e,scope:`run`,...i};case`node`:return n===void 0?{type:`detail`,run_id:e,...i}:{type:`timeline`,run_id:e,scope:`node`,node:n,...i};case`graph`:return{type:`detail`,run_id:e,...i}}}function p2(e,t){return t.type===e.type?t.type===`timeline`&&e.type===`timeline`?t.scope===e.scope&&(t.scope===`run`||e.scope===`node`&&e.node===t.node):!0:!1}function m2(e){let t=e?.run.live_activity;if(t===void 0)return[];let n=uM.safeParse(t);return n.success?n.data:[]}var h2={minutes:60,seconds:1},g2=e=>Object.hasOwn(h2,e),_2=600%h2.minutes==0?{amount:String(600/h2.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function v2(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*h2[e.unit];return Number.isSafeInteger(n)?n:void 0}function y2(e){if(e===0)return`no grace`;let t=Math.floor(e/60),n=e%60,r=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return t===0?r(n,`second`):n===0?r(t,`minute`):`${r(t,`minute`)} ${r(n,`second`)}`}function b2(e){return e.map(e=>({runId:e.run_id,owner:xX(e.launch)}))}function x2(e,t){return t instanceof YN&&t.status!==void 0&&t.code!==void 0?{phase:`refused`,sent:e,error:t}:{phase:`lost`,sent:e,error:t instanceof Error?t:Error(String(t))}}var S2={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function C2(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(S2);return n.flatMap(e=>{if(!r.has(e.run_id))return[];let n=e.last_event;if(n===null||!i.includes(n))return[];let a=t.get(e.run_id);return a!==void 0&&a.last_event===n&&a.last_progress_at===e.last_progress_at?[]:[{runId:e.run_id,recorded:n===S2.hostShutdown?S2.hostShutdown:S2.dispatchStopped}]})}function w2(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}function T2(e){return(0,H.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.owner,(t.get(n.owner)??0)+1);return[...t].map(([e,t])=>({owner:e,count:t}))},[e])}var E2=`Each live dispatch is asked to stop and commit, and given the grace to end itself; whatever is still standing then is torn down, and every branch the run's records name is pushed to its origin. Nothing is sent until you confirm.`;function D2({open:e,onOpenChange:t,runs:n,blocked:r,unreadable:i=0,onConfirm:a}){let o=(0,H.useId)(),[s,c]=(0,H.useState)(_2),[l,u]=(0,H.useState)(!1),d=v2(s),f=n!==void 0&&r===void 0,p=()=>{c(_2),u(!1),t(!1)};return(0,W.jsx)(gc,{onOpenChange:e=>e?t(!0):p(),open:e,children:(0,W.jsxs)(bc,{className:`shutdown-dialog`,children:[(0,W.jsxs)(xc,{children:[(0,W.jsx)(Cc,{children:`Shut down the entire host?`}),(0,W.jsx)(wc,{children:E2})]}),(0,W.jsxs)(`div`,{className:`shutdown-dialog-body`,children:[r===void 0?n===void 0?(0,W.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:`Reading which runs this acts on…`}):(0,W.jsx)(k2,{caption:`It acts on all ${O2(n.length)} on this host, over their owners — each is interrupted, torn down and pushed:`,label:`Runs on this host`,runs:n,warning:!0}):(0,W.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:r}),i>0&&(0,W.jsxs)(`p`,{className:`shutdown-scope-note`,children:[i===1?`1 run root on this host could not be read`:`${i} run roots on this host could not be read`,`: the engine cannot read them either, so this shutdown signals nothing in them and pushes none of their branches.`]}),(0,W.jsxs)(`fieldset`,{className:`shutdown-grace`,children:[(0,W.jsx)(`legend`,{children:`Grace`}),(0,W.jsxs)(`div`,{className:`shutdown-grace-row`,children:[(0,W.jsx)(Oc,{className:`sr-only`,htmlFor:`${o}-grace`,children:`Grace`}),(0,W.jsx)(Tc,{"aria-describedby":`${o}-grace-help`,"aria-invalid":d===void 0,id:`${o}-grace`,inputMode:`numeric`,min:0,onChange:e=>c({...s,amount:e.target.value}),step:1,type:`number`,value:s.amount}),(0,W.jsx)(Oc,{className:`sr-only`,htmlFor:`${o}-unit`,children:`Grace unit`}),(0,W.jsx)(`select`,{className:`composer-select`,id:`${o}-unit`,onChange:e=>{let t=e.target.value;g2(t)&&c({...s,unit:t})},value:s.unit,children:Object.keys(h2).map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))})]}),(0,W.jsx)(`p`,{className:`channel-age`,id:`${o}-grace-help`,children:d===void 0?`The grace is a whole number of minutes or seconds, 0 or more.`:`How long each live dispatch has to end itself once asked: ${y2(d)}. The engine's default is ${y2(v2(_2)??0)}.`})]}),(0,W.jsxs)(`div`,{className:`composer-check shutdown-force`,children:[(0,W.jsx)(`input`,{checked:l,id:`${o}-force`,onChange:e=>u(e.target.checked),type:`checkbox`}),(0,W.jsx)(Oc,{htmlFor:`${o}-force`,children:`Force: skip the interrupt and the wait and go straight to the teardown — whatever a worker had not committed is lost.`})]})]}),(0,W.jsxs)(Sc,{children:[(0,W.jsx)(vc,{asChild:!0,children:(0,W.jsx)(Pa,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,W.jsx)(Pa,{disabled:!f||d===void 0,onClick:()=>{d!==void 0&&(a(d,l),p())},type:`button`,variant:`destructive`,children:`Shut down the host`})]})]})})}var O2=e=>e===1?`1 run`:`${e} runs`;function k2({caption:e,label:t,runs:n,warning:r=!1}){let i=T2(n);return(0,W.jsxs)(`div`,{className:`shutdown-runs`,"data-warning":r,children:[(0,W.jsx)(`p`,{className:`shutdown-scope-note`,children:e}),(0,W.jsx)(`ul`,{"aria-label":t,children:i.map(({owner:e,count:t})=>(0,W.jsxs)(`li`,{children:[e,` — `,O2(t)]},e))})]})}function A2(e,t,n){let[r,i]=(0,H.useState)(),a=j2(r!==void 0,e,t,n);return{open:r,setOpen:i,opener:e=>()=>i(e),runs:a.rows===void 0||r===void 0?void 0:b2(a.rows),blocked:a.blocked,unreadable:e?.unreadable?.length??0}}function j2(e,t,n,r){let i=(0,H.useRef)(new Set),a=t?.next_cursor;return(0,H.useEffect)(()=>{if(!e){i.current.clear();return}a===void 0||r||i.current.has(a)||(i.current.add(a),n())},[e,a,r,n]),t===void 0?{blocked:`Reading the runs listing this view holds…`}:a===void 0?{rows:t.runs}:!r&&i.current.has(a)?{blocked:`The rest of the runs listing could not be read (${t.runs.length} runs read), so the runs this acts on cannot all be named. Close this and try again.`}:{blocked:`Reading the rest of the runs listing so every run this acts on can be named (${t.runs.length} read so far)…`}}function M2(e,t){let[n,r]=(0,H.useState)({phase:`idle`}),i=(0,H.useRef)(!1);return{state:n,confirm:(0,H.useCallback)((n,a,o)=>{if(i.current)return;i.current=!0;let s={scope:e,runs:n,grace:a,force:o,sentAt:Date.now()};r({phase:`sending`,sent:s}),t({grace:a,force:o}).then(e=>r({phase:`answered`,sent:s,report:e}),e=>r(x2(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,H.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var N2=[`host`];function P2(e){return{host:M2(`host`,(0,H.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function F2({list:e,loadMore:t,loadingMore:n,shutdowns:r}){let{open:i,setOpen:a,opener:o,runs:s,blocked:c,unreadable:l}=A2(e,t,n),u=r.host.state.phase===`sending`;return(0,W.jsxs)(`fieldset`,{"aria-label":`Shut down runs on this host`,className:`host-shutdown`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`This host`}),(0,W.jsx)(`div`,{className:`host-shutdown-actions`,children:(0,W.jsxs)(Pa,{disabled:u,onClick:o(`host`),size:`sm`,type:`button`,variant:`destructive`,children:[(0,W.jsx)(Yt,{size:14}),` Shut down the entire host`]})}),N2.map(e=>(0,W.jsx)(D2,{blocked:c,onConfirm:(e,t)=>s!==void 0&&r.host.confirm(s,e,t),onOpenChange:t=>a(t?e:void 0),open:i===e,runs:i===e?s:void 0,unreadable:l},e))]})}var I2=1e3;function L2(e,t){let[n,r]=(0,H.useState)(()=>Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),I2);return()=>clearInterval(e)},[]);let i=C2(e,(0,H.useRef)(new Map(t.filter(t=>e.runs.some(({runId:e})=>e===t.run_id)).map(e=>[e.run_id,e]))).current,t);return{now:n,progress:i,done:i.filter(({recorded:e})=>e===S2.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function R2({label:e,state:t,rows:n,onDismiss:r}){return t.phase===`idle`?null:(0,W.jsxs)(`section`,{"aria-label":e,className:`shutdown-status`,children:[t.phase===`sending`?(0,W.jsx)(B2,{rows:n,sent:t.sent}):t.phase===`lost`?(0,W.jsxs)(sa,{"aria-label":`${e} lost`,variant:`destructive`,children:[(0,W.jsx)(on,{}),(0,W.jsx)(ca,{children:`Shutdown lost: no answer came back`}),(0,W.jsxs)(la,{children:[(0,W.jsxs)(`p`,{children:[`The request sent at `,w2(t.sent.sentAt),` ended without an answer (`,t.error.message,`). The engine may still be carrying out the shutdown — check the runs before sending another.`]}),(0,W.jsx)(z2,{sent:t.sent})]})]}):t.phase===`refused`?(0,W.jsxs)(sa,{"aria-label":`${e} refused`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsxs)(ca,{children:[`Shutdown refused · `,t.error.status,` `,t.error.code]}),(0,W.jsxs)(la,{children:[(0,W.jsx)(`pre`,{className:`verb-text`,children:t.error.message}),(0,W.jsx)(`p`,{children:`Nothing was signalled and nothing was pushed.`})]})]}):(0,W.jsx)(H2,{label:e,report:t.report}),t.phase!==`sending`&&(0,W.jsx)(`div`,{className:`composer-actions`,children:(0,W.jsx)(Pa,{onClick:r,size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`})})]})}function z2({sent:e}){return(0,W.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,w2(e.sentAt),` · scope `,e.scope,` · grace`,` `,y2(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function B2({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=L2(e,t);return(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`shutdown-inflight`,role:`status`,children:[(0,W.jsxs)(`p`,{className:`shutdown-inflight-head`,children:[(0,W.jsx)(Rt,{"aria-hidden":`true`,className:`animate-spin`,size:14}),(0,W.jsx)(`strong`,{children:`Shutdown in progress`}),` — still waiting for the engine's answer, `,QF(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,W.jsx)(z2,{sent:e}),(0,W.jsx)(`p`,{children:o?n<a?`Waiting out the ${y2(e.grace)} grace until ${w2(a)} (${QF(a-n)} left) for each live dispatch to end itself; runs are worked through one after another, each with its own grace.`:`The first grace ran out at ${w2(a)}; the engine is tearing down what is still standing and pushing branches, run by run.`:`Forced: nothing is asked or waited for; the engine is tearing the runs down and pushing their branches.`}),(0,W.jsxs)(`p`,{children:[i,` of `,e.runs.length,` `,e.runs.length===1?`run has`:`runs have`,` recorded their shutdown.`]}),r.length>0&&(0,W.jsx)(`ul`,{"aria-label":`Recorded so far`,children:r.map(({runId:e,recorded:t})=>(0,W.jsxs)(`li`,{children:[e,`:`,` `,t===S2.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function V2(e){let t=e.remote===null?``:` to ${e.remote}`,n=e.commit===null?``:` at ${e.commit}`;switch(e.result){case`pushed`:return`pushed${t}${n}`;case`already-on-origin`:return`already on its origin${t}${n}; nothing was pushed`;case`no-remote`:return`not pushed: this identity has no origin${n}`;case`refused`:return`could not be preserved${n}`}}function H2({label:e,report:t}){return(0,W.jsxs)(sa,{"aria-label":`${e} report`,variant:t.complete?`default`:`destructive`,children:[t.complete?(0,W.jsx)(Tt,{}):(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:t.complete?`Shutdown complete`:`Shutdown incomplete`}),(0,W.jsxs)(la,{className:`shutdown-report`,children:[!t.complete&&(0,W.jsx)(`p`,{children:`Not everything went as asked: a dispatch was killed at the deadline or is still running, a teardown was not clean, or a branch could not be preserved. Read the runs below.`}),(0,W.jsxs)(`p`,{className:`channel-age`,children:[`Scope `,t.scope,` · grace `,y2(t.grace_seconds),t.forced?` · forced`:``,` · runs root `,t.root]}),t.runs.length===0?(0,W.jsx)(`p`,{children:`No run was selected: nothing was signalled.`}):t.runs.map(e=>(0,W.jsxs)(`section`,{"aria-label":`Shutdown of ${e.run_id}`,className:`shutdown-report-run`,children:[(0,W.jsxs)(`h4`,{children:[e.run_id,` · owner `,e.owner,e.forced_over_owner&&` — another session's run, acted on over its owner`]}),e.dispatches.length===0?(0,W.jsx)(`p`,{children:`No live dispatch to interrupt.`}):(0,W.jsx)(`ul`,{"aria-label":`Dispatches of ${e.run_id}`,children:e.dispatches.map(e=>(0,W.jsxs)(`li`,{children:[e.node,` (pid `,e.pid,`): interrupt`,` `,e.interrupt,`; ended `,e.ended,` after`,` `,QF(e.waited_ms),(0,W.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.node}-${e.pid}`))}),(0,W.jsxs)(`p`,{children:[`Teardown: `,e.teardown]}),e.branches.length===0?(0,W.jsx)(`p`,{children:`No branch this run's records name.`}):(0,W.jsx)(`ul`,{"aria-label":`Branches of ${e.run_id}`,children:e.branches.map(e=>(0,W.jsxs)(`li`,{children:[e.identity,`@`,e.branch,`: `,V2(e),(0,W.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.identity}@${e.branch}`))})]},e.run_id)),t.not_pushed_unread===null?t.not_pushed.length===0?(0,W.jsx)(`p`,{children:`Other unpublished branches on this host: none.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`Other unpublished branches on this host, which this shutdown did not push (`,t.not_pushed.length,`):`]}),(0,W.jsx)(`ul`,{"aria-label":`Branches not pushed`,children:t.not_pushed.map(({identity:e,branch:t})=>(0,W.jsxs)(`li`,{children:[e,`@`,t]},`${e}@${t}`))})]}):(0,W.jsxs)(`p`,{children:[`Other unpublished branches on this host: not read —`,` `,t.not_pushed_unread,`. This is not a count of zero: there may be work on this host nothing outside it carries.`]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`The engine's own report`}),(0,W.jsx)(`pre`,{className:`verb-text`,children:t.rendered})]})]})]})}var U2={crosshair:!0,ticks:{minSpacingPx:80}},W2=2e3;function G2(e){let[t,n]=e;if(n-t>=2e3)return e;let r=(t+n)/2;return[r-W2/2,r+W2/2]}var K2=1e3;function q2({completedAt:e,startedAt:t}){let n=t===void 0?void 0:eI(t),r=e===void 0?void 0:eI(e),i=J2(n!==void 0&&r===void 0);return n===void 0?null:r===void 0?(0,W.jsxs)(W.Fragment,{children:[QF(i-n.getTime()),` · running`]}):(0,W.jsx)(W.Fragment,{children:QF(r.getTime()-n.getTime())})}function J2(e){let[t,n]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),K2);return()=>clearInterval(t)},[e]),t}function Y2({control:e}){if(e===void 0)return null;let t=e.addressable?`Turn reachable`:`No turn to reach`,n=e.addressable?`a planner's note can be delivered into the ${e.member??`member`} turn in flight`:e.reason,r=e.addressable?Ut:Vt;return(0,W.jsxs)(Ma,{"aria-label":`${t}: ${n}`,className:V(`node-view-control gap-1.5`,e.addressable?`border-info bg-info-surface text-info`:`border-warning bg-warning-surface text-warning`),title:n,variant:`outline`,children:[(0,W.jsx)(r,{"aria-hidden":`true`,size:12}),t]})}function X2(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Z2=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`refused`,`exceeded`,`conflict`]],[`human`,[`human`]],[`planning`,[`planner`,`decision`,`note`]],[`contention`,[`lock`,`concurrent`,`quiet`,`wait`,`held`,`unheld`]],[`verification`,[`verification`,`gate`,`check`,`checks`,`coverage`,`judge`]],[`publication`,[`pr`,`publication`,`published`,`release`,`merge`,`merged`,`change`,`drafting`,`landing`,`landed`]],[`repository`,[`edit`,`fetch`,`push`,`branch`,`branches`,`commit`]],[`session`,[`turn`,`member`,`session`,`heartbeat`,`conversation`]],[`lifecycle`,[`run`,`graph`,`node`,`round`,`step`,`edge`,`setup`,`cleanup`,`driver`,`cross`,`upstream`]]],Q2={"change-retitled":`publication`,"title-unverified":`verification`,"node-restack-started":`repository`,"node-restacked":`repository`,"review-comments-read":`publication`,"review-reply-posted":`publication`,"review-reply-not-drafted":`publication`,"node-absorbed":`publication`,"node-readjusted":`repository`,"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`,"scratch-removed":`lifecycle`,"scratch-retained":`lifecycle`,"home-status":`lifecycle`};function $2(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function e4(e){let t=Q2[e];if(t!==void 0)return t;let n=$2(e);return Z2.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var t4={recovery:Zt,failure:an,human:sn,planning:Ot,contention:Pt,verification:tn,publication:Nt,repository:Mt,session:Wt,lifecycle:Gt,activity:Dt};function n4({category:e,className:t=`size-3`}){let n=t4[e];return(0,W.jsx)(n,{"aria-hidden":`true`,className:t})}function r4(e){return e===`human-step`?`human step`:e}function i4(e){return e.style===`human-step`}function a4(e){switch(e){case`not-released`:return`not released yet`;case`awaiting-human-step`:return`waiting for the human step`;case`not-answered`:return`the registry did not answer`;case`not-landed`:return`released, but not carrying this work yet`;default:return e}}function o4(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function s4(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`next`?`Deferred — onto the node's next dispatch`:e}function c4(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function l4({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:r4(e.style)],[`Version`,e.version],[`Probe outcome`,e.outcome],[`Probed through`,e.form],[`Probe took`,e.elapsed_ms===void 0?void 0:`${e.elapsed_ms} ms`],[`Acknowledged by`,e.actor],[`Superseded`,o4(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,s4(e.delivery)]].filter(([,e])=>e!==void 0);return(0,W.jsxs)(W.Fragment,{children:[t.length>0&&(0,W.jsx)(`dl`,{className:`facts`,children:t.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:t})]},e))}),e.awaiting!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Held on`}),(0,W.jsx)(`ul`,{className:`release-awaiting`,children:e.awaiting.map(e=>(0,W.jsxs)(`li`,{children:[i4(e)?(0,W.jsxs)(sa,{children:[(0,W.jsx)(sn,{}),(0,W.jsxs)(ca,{children:[`Waiting on a person · `,c4(e)]}),(0,W.jsx)(la,{children:e.action??`The release is a human step and the run recorded no action for it.`})]}):(0,W.jsxs)(`p`,{className:`detail-note`,children:[`Waiting on an automated release · `,c4(e)]}),(0,W.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:a4(e.last_answer),e.waited_seconds===void 0?void 0:`waited ${e.waited_seconds}s`].filter(e=>e!==void 0).join(` · `)})]},`${e.dep}·${e.identity??``}·${e.target??``}`))})]}),e.versions!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Versions adopted`}),(0,W.jsx)(`ul`,{className:`release-awaiting`,children:e.versions.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsxs)(`p`,{className:`detail-note`,children:[e.identity,` · `,e.target,` · `,e.version]})},`${e.identity}·${e.target}`))})]})]})}function u4({node:e}){let t=e.result?.release??void 0;if(t===void 0)return(0,W.jsx)(W.Fragment,{children:`Not recorded`});let n=t.identity!==e.task.repo;return(0,W.jsx)(W.Fragment,{children:[t.target,t.style===void 0?void 0:r4(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function d4({artifactId:e,client:t,runId:n}){let r=II(`${n}/${e}`,()=>t.getArtifact(n,e),0),i=r.value?.turns??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Oneharness conversation`}),r.loading?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:`Loading conversation…`}):r.value===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:`The history store holds no readable copy of that conversation.`}):r.value.unavailable===void 0?(0,W.jsx)(Fa,{className:`gap-0 py-3`,children:(0,W.jsx)(Ia,{className:`px-3`,children:i.map(e=>(0,W.jsx)(Sw,{turn:e},e.id))})}):(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Transcript unavailable`}),(0,W.jsx)(la,{children:r.value.unavailable})]})]})}function f4({artifactId:e,client:t,heading:n,missing:r,noun:i,runId:a,unreadable:o}){let s=p4(e),c=II(s===void 0?void 0:`${a}/${s}`,()=>t.getArtifact(a,s??``),0),l=c.value?.content;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:n}),s===void 0?(0,W.jsx)(`p`,{className:`detail-note`,children:r}):c.loading?(0,W.jsxs)(`p`,{"aria-live":`polite`,className:`detail-note`,children:[`Loading `,i,`…`]}):l===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`detail-note`,children:o}):(0,W.jsxs)(W.Fragment,{children:[c.value?.truncated===!0&&(0,W.jsxs)(`p`,{className:`detail-note`,children:[`The server keeps the end of a `,i,` this long; its beginning is not shown.`]}),(0,W.jsx)(`section`,{"aria-label":n,children:(0,W.jsx)(`pre`,{children:l})})]})]})}function p4(e){if(!(e===void 0||/[/?#]/u.test(e)))return e}function m4(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:QF(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`&&e.status===`running`,...e.status?{status:e.status}:{}}}function h4({row:e}){let t=m4(e);return(0,W.jsxs)(`header`,{className:`detail-title`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ma,{className:`mb-1`,variant:`outline`,children:t.kind}),(0,W.jsx)(`h2`,{children:t.label}),(0,W.jsxs)(`p`,{className:`detail-when`,children:[(0,W.jsx)(aI,{at:t.startedAt}),t.duration!==void 0&&` · ${t.duration}`,t.running&&` · still running`]})]}),t.status!==void 0&&(0,W.jsx)(Ma,{variant:`secondary`,children:t.status})]})}function g4(e){let t=m4(e);return[t.kind,t.label,tI(t.startedAt),X2(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function _4({row:e}){return(0,W.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":g4(e),children:(0,W.jsx)(n4,{category:e.category})})}var v4=`data-timeline-reading`;function y4(e){let t=e.closest(`[${v4}]`)??e.closest(`button`)?.querySelector(`[${v4}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(v4)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var b4={rows:[],total:0},x4={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},S4=`idle`,C4=new Set([...Object.keys(x4),S4]),w4=`member:`;function T4(e){return C4.has(e)?`${w4}${e}`:e}var E4=Object.entries(x4).map(([e,t])=>({id:e,label:t}));function D4(e){let t=e?.spans??[],n=[];for(let e of t){let t=e.agent_role??e.harness_scope;t!==void 0&&!n.includes(t)&&n.push(t)}let r=t.some(e=>X4(e)===`dispatch`),[i,...a]=E4;return[...i===void 0?[]:[i],...n.map(e=>({id:T4(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var O4={run:null,node:null,step:null,dispatch:`dispatch`,verification:`verification`,publication:`publication`,"pr-drafting":`dispatch`,"conflict-resolution":`publication`,"human-wait":`human-wait`,queued:`queued`,rollup:`lock-waits`};function k4(e){return e===`agent`}function A4(e,t){return e===void 0?t===void 0?x4.dispatch:j4(t):m3(t)&&t!==e?`${e} · ${t}`:e}function j4(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var M4={"lock-wait":`Lock waits`};function N4(e,t=E4){let n=[...e].sort((e,t)=>e.start-t.start),r=n.at(0)?.start??0,i=Math.max(r+1,...n.map(e=>e.end??e.start)),a=new Set([n.at(0),n.reduce((e,t)=>e===void 0||(t.end??t.start)>(e.end??e.start)?t:e,void 0)].filter(e=>e!==void 0).map(({id:e})=>e)),o=(i-r)*.02,s=[];for(let e of n){let n=Math.max(e.end??e.start,e.start+o),r=s.findLast(t=>{let r=Math.max(t.end??t.start,t.start+o);return e.start<=r&&t.start<=n});r===void 0||a.has(e.id)?s.push(e):F4(e,t)<F4(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:P4(e,r,o)||s.push(e)}return s.sort((e,n)=>F4(n,t)-F4(e,t)||(e.end??e.start)-e.start-((n.end??n.start)-n.start))}function P4(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function F4(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function I4(e,t,n){let r=[...e.map(({at:e})=>e),...t.flatMap(e=>[e.start,e.end??e.start])],i=Math.min(...r),a=(Math.max(...r)-i)*.02,o=[];for(let t of[...e].sort((e,t)=>e.at-t.at)){let e=o.findLast(e=>t.at-e.at<=a);e===void 0?o.push(t):t.id===n&&(o[o.indexOf(e)]=t)}return o}function L4(e,t){let n=H4(e,t).rows,r=B4(n),i=B4(n,!1).flatMap(e=>{let t=V4(e);if(t===null)return[];let n=Date.parse(e.startedAt),r=e.endedAt===null?null:Date.parse(e.endedAt),i=e.rowKind===`span`&&e.span.total_duration_ms!==void 0?n+e.span.total_duration_ms:r;return[{id:e.id,label:e.displayLabel,laneId:t,payload:e,start:n,end:i,duration:i===null?null:i-n,status:e.status}]}),a=r.flatMap(e=>e.rowKind===`event`?[{id:e.id,label:e.displayLabel,at:Date.parse(e.startedAt),payload:e,status:e.status,icon:(0,H.createElement)(_4,{row:e})}]:[]),o=Math.max(...i.map(e=>e.end??e.start),...a.map(e=>e.at));return{items:i.map(e=>e.end===null?{...e,end:o,duration:o-e.start}:e),markers:a,lanes:D4(e),rows:r,tree:n}}function R4(e,t){let n=new Set,r=[],i=e=>{for(let a of e){if(a.rowKind===`group`){let e=t.has(a.id),n=a.children,o=n.at(0),s=n.at(-1);o!==void 0&&i([o]),r.push({entryKind:`collapse`,group:a,hidden:Math.max(n.length-2,0),expanded:e}),e&&i(n.slice(1,-1)),s!==void 0&&s!==o&&i([s]);continue}n.has(a.id)||(n.add(a.id),r.push({entryKind:`row`,row:a})),i(a.children)}};return i(e),r}function z4(e,t){return`${e} more ${t} events`}function B4(e,t=!0){let n=new Set,r=[],i=e=>{for(let a of e)n.has(a.id)||(n.add(a.id),r.push(a)),(t||a.rowKind!==`group`)&&i(a.children)};return i(e),r}function V4(e){return e.rowKind===`event`?null:e.role===void 0?O4[e.rowKind===`span`?e.span.kind:e.kind]??null:T4(e.role)}function H4(e,t){if(e===void 0)return b4;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=g3(e.spans,new Set,t);return n.length===0?b4:{rows:o3(n),total:n.length}}let r=new Set(n.map(({id:e})=>e)),i=new Map,a=[];for(let e of n){let t=e.parent_id!==void 0&&r.has(e.parent_id)?e.parent_id:void 0;t===void 0?a.push(e):i.set(t,[...i.get(t)??[],e])}let o=a.find(({kind:e})=>e===`node`),s=[...o===void 0?[]:q4(o,i),...a.filter(e=>e!==o).map(e=>J4(e,i)),...g3(e.spans,r,t)].sort(v3),c=n.some(e=>e.dispatch_group!==void 0||e.events.some(e=>e.dispatch_group!==void 0))?p3(s):o3(f3(d3(s)));return{span:o,rows:c,total:_3(c)}}function U4(e){return J4(e,new Map)}function W4(e){return a3(e)}function G4(e,t){return K4(e,t).at(-1)}function K4(e,t){let n=(e,r)=>{for(let i of e){if(r?i.rowKind===`event`&&i.event.id===t:i.id===t)return[i];let e=n(i.children,r);if(e.length>0)return[i,...e]}return[]},r=n(e,!1);return r.length>0?r:n(e,!0)}function q4(e,t){return[...(t.get(e.id)??[]).map(e=>J4(e,t)),...e.events.map(a3)].sort(v3)}function J4(e,t){let n=Y4(e),r=e.kind===`dispatch`?e.transport_role:void 0;return{rowKind:`span`,span:e,id:e.id,kind:e.kind,...n===void 0?{}:{role:n},...r===void 0?{}:{transport:r},label:e.label,startedAt:e.started_at,endedAt:e.ended_at,status:e.status,durationMs:e.total_duration_ms??y3(e.started_at,e.ended_at),children:o3(q4(e,t)),displayLabel:u3(e,n,r),displayKind:s3(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function Y4(e){return e.kind===`dispatch`?e.agent_role??e.harness_scope:void 0}function X4(e){return e.agent_role===void 0?e.harness_scope===void 0?O4[e.kind===`rollup`?e.label:e.kind]??null:T4(e.harness_scope):T4(e.agent_role)}function Z4(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?x4[e]??(e.startsWith(w4)?e.slice(7):e):n.label}function Q4(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var $4=`Redirection`;function e3(e){if(e.surface===void 0)return;let t=[e.surface.kind,e.surface.message].filter(e=>e!==void 0);return t.length===0?void 0:t.join(`: `)}var t3=`Surface`,n3=`Blocking surface`;function r3(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function i3(e,t){let n=r3(t);return n===void 0?e:`${e} · by ${n}`}function a3(e){let t=Q4(e),n=e3(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?n3:t3:$4;return{rowKind:`event`,event:e,id:e.record_id??e.id,kind:e.kind,label:e.step_id??``,startedAt:e.at,endedAt:null,status:e.status,durationMs:null,children:[],displayLabel:i3(t??n??(e.kind===`turn-activity`&&e.description!==void 0&&e.description!==``?e.description:void 0)??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:e4(e.kind)}}function o3(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)continue;let i=n;for(;i+1<e.length&&h3(r,e[i+1]);)i+=1;let a=e.slice(n,i+1),o=a.at(-1);a.length<4||o===void 0?t.push(...a):t.push({rowKind:`group`,count:a.length,id:`group-${r.id}`,kind:r.kind,label:`${a.length} × ${r.kind}`,startedAt:r.startedAt,endedAt:o.endedAt,status:void 0,durationMs:y3(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind,...r.role===void 0?{}:{role:r.role},...r.transport===void 0?{}:{transport:r.transport},...r.dispatch!==void 0&&a.every(e=>e.dispatch?.id===r.dispatch?.id)?{dispatch:r.dispatch}:{}}),n=i}return t}function s3(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return M4[e.label]??e.label;if(e.kind===`dispatch`)return A4(t,n);let r=O4[e.kind];return r===null?e.kind:Z4(r)}function c3(e){let t=e=>(e??[]).join(`, `);switch(e.kind){case`concurrency`:return e.ahead===void 0?`behind the work already running`:`behind ${t(e.ahead)}`;case`dependencies`:return`waiting on ${t(e.blocking)}`;case`decision`:return`held by decision ${e.reference??`nobody named`}`;case`release`:return`awaiting the release of ${t(e.awaiting)}`;default:return`held by ${e.kind}`}}function l3(e){return e.map(c3).join(` and `)}function u3(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${l3(e.reasons??[])}`.trim();let r=s3(e,t,n);return e.kind===`rollup`?`${r}: ${e.count??0} recorded`:!e.label||e.label===r?r:e.kind===`dispatch`?`${r} (${e.label})`:`${r}: ${e.label}`}function d3(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=d3(e.children);return!k4(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function f3(e){let t=[],n=-1,r=0,i=(e,t)=>({...e,dispatch:t,children:e.children.map(e=>i(e,t))});for(let a of e){if(k4(a.transport)){r+=1,n=t.length,t.push(i(a,{id:a.id,label:`Dispatch ${r}`}));continue}let e=n<0?void 0:t[n];if(m3(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function p3(e){let t=new Map,n=[];for(let r of B4(e).filter(e=>e.rowKind!==`group`)){let e=r.rowKind===`event`?r.event.dispatch_group:r.span.dispatch_group,i={...r,children:[]};if(e===void 0){n.push(i);continue}let a=t.get(e.id)??{metadata:e,members:[]};a.members.push({...i,dispatch:{id:e.id,label:e.label}}),t.set(e.id,a)}let r=e=>[...o3(e.filter(e=>e.rowKind===`span`&&e.kind===`dispatch`).sort(v3)),...o3(e.filter(e=>e.rowKind!==`span`||e.kind!==`dispatch`).sort(v3))];return[...n.map(e=>({at:e.startedAt,order:e.rowKind===`event`?(e.event.journal_order??0)*3:0,rows:[e]})),...[...t.values()].map(({metadata:e,members:t})=>({at:e.started_at,order:e.order,rows:r(t)}))].sort((e,t)=>Date.parse(e.at)-Date.parse(t.at)||e.order-t.order).flatMap(({rows:e})=>e)}function m3(e){return e===`judge`||e===`llmlint`}function h3(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind&&e.role===t.role&&e.transport===t.transport}function g3(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(a3)}function _3(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+_3(t.children),0)}function v3(e,t){let n=Date.parse(e.startedAt)-Date.parse(t.startedAt);return n===0?e.rowKind===`event`&&t.rowKind===`event`?(e.event.journal_order??0)-(t.event.journal_order??0):0:n}function y3(e,t){if(t===null)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?null:r-n}function b3(e,t,n,r){let[i,a]=(0,H.useState)(),o=t===void 0||n===void 0?void 0:JSON.stringify([t,n]);(0,H.useEffect)(()=>{if(o===void 0||t===void 0||n===void 0)return;let r=!0;return e.getConversation(t,n).then(e=>{r&&a({key:o,conversation:e})}).catch(e=>{if(!r)return;let t=e instanceof Error?e:Error(String(e));a(e=>e?.key===o&&e.conversation!==void 0?e:{key:o,error:t})}),()=>{r=!1}},[e,t,n,o,r]);let s=i?.key===o?i:void 0;return(0,H.useMemo)(()=>({conversation:s?.conversation,error:s?.error,loading:o!==void 0&&s===void 0}),[s,o])}var x3=32;function S3(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function C3(e,t){let n=(0,H.useRef)(null),r=(0,H.useRef)(!0),i=(0,H.useRef)({key:e,count:t}),a=(0,H.useCallback)(()=>{let e=n.current;e!==null&&(r.current=e.scrollHeight-e.scrollTop-e.clientHeight<=x3)},[]),o=(0,H.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=S3(e),n.current?.addEventListener(`scroll`,a,{passive:!0}),a()},[a]);return(0,H.useLayoutEffect)(()=>{let a=i.current;i.current={key:e,count:t};let o=a.key===e&&a.count>0&&t>a.count,s=n.current;!o||s===null||!r.current||(s.scrollTop=s.scrollHeight)},[e,t]),o}var w3=25;function T3({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:K3(r),a=i?.kind===`conversation`?i.value:void 0,o=b3(e,t,a,r===void 0?void 0:V3(r));return(0,W.jsx)(`section`,{"aria-label":`Timeline item detail`,className:`timeline-detail`,children:(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsx)(`div`,{className:`p-[22px] max-sm:p-3`,ref:C3(a,H3(r,o)),children:r===void 0?(0,W.jsxs)(`div`,{className:`detail-placeholder`,children:[(0,W.jsx)(Lt,{size:30}),(0,W.jsx)(`p`,{children:`Select an item in the timeline to read what it recorded.`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(h4,{row:r}),(0,W.jsx)(bf,{className:`my-4`}),(0,W.jsx)(E3,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function E3({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=U3(n);if(o!==void 0)return(0,W.jsx)(I3,{redirection:o,row:n});let s=W3(n);if(s!==void 0)return(0,W.jsx)(l4,{release:s});let c=G3(n);return c===void 0?i?.kind===`conversation`?(0,W.jsxs)(W.Fragment,{children:[n.rowKind===`event`&&(0,W.jsx)(z3,{row:n,reference:i}),(0,W.jsx)(j3,{row:n,transcript:a})]}):J3(n)?(0,W.jsx)(M3,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&p4(i.value)!==void 0?(0,W.jsx)(N3,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&p4(i.value)!==void 0?(0,W.jsx)(P3,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):Y3(n,i)&&r!==void 0?(0,W.jsx)(F3,{node:r,reference:i}):(0,W.jsx)(z3,{reference:i,row:n}):(0,W.jsx)(R3,{row:n,surface:c})}function D3({turn:e}){return e.judges===void 0||e.judges.length===0?null:(0,W.jsx)(`ul`,{"aria-label":`Judges on turn ${e.id}`,className:`judge-decisions`,children:e.judges.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`span`,{className:`judge-decision-who`,children:[e.judge,` (`,e.kind,`)`]}),` `,e.decision,` — `,e.reason]},e.judge))})}function O3(e){return e.tool?.turn??e.id}function k3(e,t){if(e.rowKind!==`event`||e.event.tool===void 0)return;let n=O3(e.event),r=t.find(({id:e})=>e===n);if(r===void 0)return;let{index:i,tool_call_id:a}=e.event.tool;return a!==void 0&&r.tools.some(e=>e.toolCallId===a)?{turnId:r.id,toolCallId:a}:{turnId:r.id,eventIndex:i}}function A3({turn:e}){let t=[e.unknown.instruction_truncated===!0?`its prompt`:void 0,e.unknown.truncated===!0?`its reply`:void 0,e.tools.some(e=>e.output_truncated===!0)?`a tool's output`:void 0,e.tools.some(e=>e.input_truncated===!0)?`a tool's input`:void 0].filter(e=>e!==void 0);return t.length===0?null:(0,W.jsxs)(sa,{className:`mb-3`,role:`note`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Cut by the recorder`}),(0,W.jsxs)(la,{children:[`The run's recorder cut `,t.join(`, `),` to its bound, and no whole copy exists: neither the member's report nor a history file this run names holds it.`]})]})}function j3({row:e,transcript:t}){let[n,r]=(0,H.useState)(w3),i=t.conversation?.conversation.turns??[],a=e.rowKind===`event`?O3(e.event):void 0,o=a===void 0?i:i.filter(({id:e})=>e===a),s=Dm(o.map(e=>({id:e.id,time:Date.parse(e.timestamp)})));if(t.loading)return(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-inline`,children:[(0,W.jsx)(xf,{className:`h-2 w-40`}),(0,W.jsx)(xf,{className:`h-2 w-24`}),`Loading transcript…`]});if(t.conversation===void 0)return(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Transcript unavailable`}),(0,W.jsx)(la,{children:t.error?.message??`The server recorded no transcript.`})]});let{conversation:c,attribution:l}=t.conversation,u=X3(l.agentRole,l.transportRole),d=k3(e,o);return(0,W.jsx)(Fa,{className:`gap-0 py-3`,children:(0,W.jsxs)(Ia,{className:`px-3`,children:[(0,W.jsxs)(`header`,{className:`transcript-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`p`,{className:`eyebrow`,children:[e.dispatch===void 0?``:`${e.dispatch.label} · `,u,l.persona?` · ${l.persona}`:``]}),(0,W.jsx)(`h4`,{children:c.name})]}),(0,W.jsx)(gm,{state:c.state})]}),(0,W.jsx)(bf,{className:`my-2.5`}),(0,W.jsx)(`div`,{className:`conversation-timeline-sticky`,children:(0,W.jsx)(Em,{cursor:s.cursor,...d===void 0?{}:{focus:d},onSelectTurn:s.scrollTo,turns:[...o]})}),o.length===0?(0,W.jsx)(`p`,{className:`detail-note`,children:`This turn is no longer part of the recorded transcript.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{ref:s.containerRef,children:o.slice(0,n).map(e=>(0,W.jsxs)(`div`,{ref:t=>s.register(e.id,t),children:[(0,W.jsx)(A3,{turn:e}),(0,W.jsx)(Sw,{author:{label:u},...d?.turnId===e.id?{focus:d}:{},turn:e}),(0,W.jsx)(D3,{turn:e})]},e.id))}),o.length>n&&(0,W.jsxs)(Pa,{onClick:()=>r(n+w3),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,o.length,` turns`]})]})]})})}function M3({row:e,client:t,runId:n,reference:r}){let i=e.rowKind===`span`?e.span.detail:void 0,a=i?.artifact_id??(r?.kind===`gate_log`?r.value:void 0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Verification record`}),(0,W.jsx)(`dl`,{className:`facts`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Result`}),(0,W.jsx)(`dd`,{children:i?.ok===void 0?e.status??`in progress`:i.ok?`passed`:`failed`})]})}),i?.output_tail&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Output`}),(0,W.jsx)(`pre`,{children:i.output_tail})]}),(0,W.jsx)(f4,{artifactId:a,client:t,heading:`Full log`,missing:`No readable log was recorded.`,noun:`log`,runId:n,unreadable:`No readable log was recorded.`}),(0,W.jsxs)(`p`,{className:`detail-note`,children:[`Verification `,e.status??`in progress`,`.`]})]})}function N3({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(f4,{artifactId:e,client:t,heading:`Worker report`,missing:`This settlement recorded no report.`,noun:`report`,runId:i,unreadable:`This run kept no readable copy of that report.`}),(0,W.jsx)(z3,{reference:n,row:r})]})}function P3({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(d4,{artifactId:e,client:t,runId:i}),(0,W.jsx)(z3,{reference:n,row:r})]})}function F3({node:e,reference:t}){let n=e.detail?.verification.checks??[],r=e.detail?.publication;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Publication`}),r?.pr_url&&(0,W.jsx)(B3,{fallback:``,reference:{kind:`pr`,value:r.pr_url}}),r?.merged&&r.commit_url?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:r.commit_url,rel:`noreferrer`,target:`_blank`,children:[`Merged commit `,r.commit?.slice(0,8),` `,(0,W.jsx)(jt,{size:13})]})}):r?.branch_url?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:r.branch_url,rel:`noreferrer`,target:`_blank`,children:[`Branch `,r.branch,` `,(0,W.jsx)(jt,{size:13})]})}):!r?.pr_url&&(0,W.jsx)(B3,{fallback:`No publication was recorded.`,reference:t}),(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Observed checks`}),n.length===0?(0,W.jsx)(`p`,{className:`detail-note`,children:`No checks were observed on this node.`}):(0,W.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.name}),(0,W.jsx)(`dd`,{children:e.url?(0,W.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.state}):e.state})]},e.name))})]})}function I3({redirection:e,row:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Delivery`}),(0,W.jsx)(`dd`,{children:e.delivered?`Live — into the turn that was already running`:`Deferred — onto the node's next dispatch`})]}),e.turn!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Turn`}),(0,W.jsx)(`dd`,{children:e.turn===`turn-end`?`Left to end — the note reached it as it ended`:`Interrupted — its replacement opened on the note`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Redirected at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(aI,{at:t.startedAt,relative:!0})})]}),e.member!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Member`}),(0,W.jsx)(`dd`,{children:e.member})]}),e.input_bytes!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Note`}),(0,W.jsxs)(`dd`,{children:[e.input_bytes,` bytes offered`]})]}),(0,W.jsx)(L3,{row:t})]}),e.reason!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Why it was not delivered`}),(0,W.jsx)(`p`,{className:`detail-note`,children:e.reason})]})]})}function L3({row:e}){let t=e.rowKind===`event`?r3(e.event):void 0;return t===void 0?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Author`}),(0,W.jsx)(`dd`,{children:t})]})}function R3({surface:e,row:t}){let n=[[`Kind`,e.kind],[`Raised by`,e.source],[`Blocking`,e.blocking===void 0?void 0:e.blocking?`yes — dependents wait on the answer`:`no — nothing waits on it`]].filter(([,e])=>e!==void 0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(aI,{at:t.startedAt,relative:!0})})]}),n.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:t})]},e))]}),e.message!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Message`}),(0,W.jsx)(`p`,{className:`detail-note`,children:e.message})]})]})}function z3({row:e,reference:t}){if(e.rowKind===`event`)return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(aI,{at:e.startedAt,relative:!0})})]}),Object.entries(e.event.fields??{}).map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e}),(0,W.jsx)(`dd`,{children:typeof t==`string`?t:JSON.stringify(t)})]},e))]}),t!==void 0&&(0,W.jsx)(B3,{reference:t,fallback:`No recorded artifact.`})]});let n=e.rowKind===`group`?void 0:e,r=e.rowKind===`span`&&e.span.count!==void 0?`${e.span.count} records`:void 0,i=(e.rowKind===`span`?e.span.reasons:void 0)??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Recorded at`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(aI,{at:e.startedAt,relative:!0})})]}),e.rowKind===`span`&&(e.endedAt!==null||e.status===`running`)&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Ended`}),(0,W.jsx)(`dd`,{children:e.endedAt===null?`Still running`:(0,W.jsx)(aI,{at:e.endedAt,relative:!0})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Status`}),(0,W.jsx)(`dd`,{children:e.status??`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Duration`}),(0,W.jsx)(`dd`,{children:e.durationMs===null?`Not recorded`:QF(e.durationMs)})]}),r!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Aggregated`}),(0,W.jsx)(`dd`,{children:r})]}),i.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Waiting on`}),(0,W.jsx)(`dd`,{children:i.map(c3).join(` and `)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Step`}),(0,W.jsx)(`dd`,{children:q3(n)??`None`})]}),(0,W.jsx)(L3,{row:e})]}),(0,W.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,W.jsx)(B3,{fallback:e.rowKind===`span`&&e.span.kind===`dispatch`?`No transcript was recorded for this dispatch.`:`This item points at no recorded artifact.`,reference:t})]})}function B3({reference:e,fallback:t}){return e===void 0?(0,W.jsx)(`p`,{className:`detail-note`,children:t}):e.value.startsWith(`http`)?(0,W.jsx)(`p`,{className:`detail-link`,children:(0,W.jsxs)(`a`,{href:e.value,rel:`noreferrer`,target:`_blank`,children:[e.value,` `,(0,W.jsx)(jt,{size:13})]})}):(0,W.jsxs)(`p`,{className:`detail-note`,children:[(0,W.jsx)(`span`,{className:`detail-reference-kind`,children:e.kind}),(0,W.jsx)(`code`,{children:e.value})]})}function V3(e){if(e.rowKind!==`span`)return e.id;let t=e.span.events.at(-1);return[e.span.id,e.span.status??``,e.span.ended_at??``,e.span.events.length,t?.id??``,t?.at??``,t?.status??``].join(`|`)}function H3(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function U3(e){return e.rowKind===`event`?e.event.redirection:void 0}function W3(e){return e.rowKind===`event`?e.event.release:void 0}function G3(e){return e.rowKind===`event`?e.event.surface:void 0}function K3(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function q3(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function J3(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function Y3(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function X3(e,t){return A4(e,t)}function Z3({client:e,runId:t,node:n,nodes:r,timeline:i,timelineError:a,selectedItemId:o,onSelectItem:s,onBack:c,selectedTab:l,onSelectTab:u}){let d=(0,H.useMemo)(()=>H4(i,n.id),[i,n.id]);(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(o===void 0?c():s())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,s,o]);let f=n.detail?.publication===void 0?n.result?.pr??void 0:n.detail.publication.pr_url;return(0,W.jsxs)(`section`,{"aria-label":`Timeline for ${n.label}`,className:`node-view`,children:[(0,W.jsxs)(`header`,{className:`node-view-head`,children:[(0,W.jsx)(`nav`,{"aria-label":`Breadcrumb`,children:(0,W.jsxs)(`ol`,{className:`breadcrumb`,children:[(0,W.jsx)(`li`,{children:(0,W.jsxs)(Pa,{onClick:c,size:`sm`,type:`button`,variant:`ghost`,children:[(0,W.jsx)(vt,{size:14}),` Graph`]})}),(0,W.jsx)(`li`,{"aria-current":`page`,children:(0,W.jsx)(`span`,{className:`breadcrumb-node`,children:n.label})})]})}),(0,W.jsxs)(`div`,{className:`node-view-facts`,children:[(0,W.jsx)(T0,{className:`node-view-state`,state:n.status}),(0,W.jsx)(Y2,{control:n.control}),(0,W.jsxs)(`span`,{className:`node-view-meta`,children:[n.kind,` node · `,n.telemetry?.turns??0,` turns ·`,` `,n.telemetry?.lint??0,` lint turns`]}),f!==void 0&&(0,W.jsxs)(`a`,{className:`node-view-pr`,href:f,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,W.jsx)(jt,{size:12})]})]})]}),(0,W.jsx)(s6,{node:n,nodes:r}),(0,W.jsx)(o6,{node:n}),(0,W.jsxs)(bp,{className:`node-tabs`,onValueChange:e=>{J0(e)&&u(e)},value:l,children:[(0,W.jsx)(Sp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(q0).map(([e,t])=>(0,W.jsx)(Cp,{value:e,children:t},e))}),(0,W.jsxs)(wp,{className:`node-tab-panel`,value:`task`,children:[(0,W.jsx)(_1,{source:r6(n.task)}),(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Settled as`}),(0,W.jsx)(`dd`,{children:c6(n.result?.outcome)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Outcome`}),(0,W.jsx)(`dd`,{children:c6(n.result?.detail)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Graph overrides`}),(0,W.jsx)(`dd`,{children:(n.task.sets??[]).length===0?`None`:(0,W.jsx)(`ol`,{"aria-label":`Graph overrides`,className:`sets-served`,children:n.task.sets?.map((e,t)=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},t))})})]})]})]}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`criteria`,children:(0,W.jsx)(_1,{source:i6(n.task)})}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`dependencies`,children:(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Dependencies`}),(0,W.jsx)(`dd`,{children:(n.task.deps??[]).map(e=>{let t=r.find(t=>t.id===e)?.status;return t===void 0?e:`${e} (${t})`}).join(`, `)||`None`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Unblocks`}),(0,W.jsx)(`dd`,{children:n.dependents.join(`, `)||`None`})]})]})}),(0,W.jsx)(wp,{className:`node-tab-panel`,value:`remote`,children:(0,W.jsxs)(`dl`,{className:`facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Publication`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(a6,{node:n})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Branch`}),(0,W.jsx)(`dd`,{children:n.detail?.publication?.branch??`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Merge`}),(0,W.jsx)(`dd`,{children:n.detail?.publication?n.detail.publication.merged?`Merged`:`Not merged`:`Not recorded`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Release`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(u4,{node:n})})]}),(0,W.jsxs)(`div`,{className:`remote-check-facts`,children:[(0,W.jsx)(`dt`,{children:`Verification coverage`}),(0,W.jsxs)(`dd`,{children:[`Hook:`,` `,n.detail?.verification.pre_push_hook?`present`:`not recorded`,` · `,`Required checks:`,` `,n.detail?.verification.required_checks?.join(`, `)||`none configured`]})]}),(0,W.jsxs)(`div`,{className:`remote-check-facts`,children:[(0,W.jsx)(`dt`,{children:`Observed checks`}),(0,W.jsx)(`dd`,{children:(n.detail?.verification.checks??[]).length===0?`No checks observed`:(0,W.jsxs)(`table`,{"aria-label":`Remote checks`,className:`remote-checks`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{children:`Name`}),(0,W.jsx)(`th`,{children:`Status`}),(0,W.jsx)(`th`,{children:`Conclusion`}),(0,W.jsx)(`th`,{children:`Runtime`}),(0,W.jsx)(`th`,{children:`Required`})]})}),(0,W.jsx)(`tbody`,{children:n.detail?.verification.checks?.map(e=>(0,W.jsxs)(`tr`,{className:e.status===`completed`&&![`success`,`neutral`,`skipped`].includes(e.conclusion??``)?`check-failing`:void 0,children:[(0,W.jsx)(`th`,{scope:`row`,children:e.url?(0,W.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.name}):e.name}),(0,W.jsx)(`td`,{children:e.status??`Not recorded`}),(0,W.jsx)(`td`,{children:e.conclusion??`—`}),(0,W.jsx)(`td`,{children:(0,W.jsx)(q2,{...e.started_at===void 0?{}:{startedAt:e.started_at},...e.completed_at===void 0?{}:{completedAt:e.completed_at}})}),(0,W.jsxs)(`td`,{title:e.requirement,className:e.required?`check-required`:`check-optional`,children:[(0,W.jsx)(`svg`,{role:`img`,"aria-label":e.required?`required`:`not required`,width:`12`,height:`12`,viewBox:`0 0 12 12`,children:e.required?(0,W.jsx)(`path`,{d:`M6 0.5 L11 2.5 V6 C11 9 8.5 11 6 11.5 C3.5 11 1 9 1 6 V2.5 Z`,fill:`currentColor`}):(0,W.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`2 1.5`})}),e.required?`Required`:`Optional`]})]},e.name))})]})})]})]})}),(0,W.jsx)(wp,{className:`node-timeline-panel`,value:`timeline`,children:a===void 0?i===void 0?(0,W.jsx)(`div`,{"aria-live":`polite`,className:`loading-state`,children:`Loading the recorded timeline…`}):d.rows.length===0?(0,W.jsxs)(Fa,{className:`m-5 items-center gap-2 p-8 text-muted-foreground`,children:[(0,W.jsx)(`p`,{className:`m-0`,children:`This node has no recorded timeline yet.`}),(0,W.jsx)(`p`,{className:`m-0 text-[11px]`,children:`Spans and events appear here as the run records them.`})]}):(0,W.jsx)(Q3,{client:e,node:n,onSelectItem:s,runId:t,selectedItemId:o,timeline:i}):(0,W.jsxs)(sa,{className:`m-5 w-auto`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Timeline unavailable`}),(0,W.jsx)(la,{children:a.message})]})})]})]})}function Q3({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,H.useMemo)(()=>L4(a,t.id),[a,t.id]),[s,c]=(0,H.useState)(()=>new Set),l=(0,H.useMemo)(()=>{if(i!==void 0)return K4(o.tree,i).find(e=>e.rowKind===`group`)?.id},[o.tree,i]),u=(0,H.useMemo)(()=>l===void 0?s:new Set([...s,l]),[s,l]),d=(0,H.useMemo)(()=>R4(o.tree,u),[o.tree,u]),f=Dm((0,H.useMemo)(()=>d.flatMap(e=>e.entryKind===`row`?[{id:e.row.id,time:Date.parse(e.row.startedAt)}]:[]),[d])),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(),_=(0,H.useMemo)(()=>N4(o.items,o.lanes),[o.items,o.lanes]),v=(0,H.useMemo)(()=>I4(o.markers,o.items,i),[o.items,o.markers,i]),y=(0,H.useMemo)(()=>$3([...o.items,...o.markers.map(({at:e})=>({start:e}))]),[o.items,o.markers]),b=(0,H.useMemo)(()=>$3([...p?o.items:_,...v.map(({at:e})=>({start:e}))]),[p,o.items,_,v]),x=f.cursor===void 0?void 0:Math.min(Math.max(f.cursor,y[0]),y[1]),S=i===void 0?void 0:G4(o.rows,i),C=e=>{n(e),f.scrollTo(e)},{scrollTo:w}=f;return(0,H.useEffect)(()=>{i!==void 0&&w(i)},[i,w]),(0,W.jsxs)(`div`,{className:`node-execution`,"data-expanded":p,children:[(0,W.jsx)(`section`,{"aria-label":`Node timeline`,className:`node-timeline-sticky`,"data-testid":`node-timeline`,children:(0,W.jsx)(Cn,{...U2,axis:{origin:y[0]},cursor:x,expanded:p,getFailureExcerpt:e=>e.payload.rowKind===`span`?e.payload.span.detail?.output_tail:void 0,items:p?o.items:_,lanes:o.lanes,markers:v,onExpandedChange:m,onRangeChange:e=>g(e[0]<=b[0]&&e[1]>=b[1]?void 0:G2(e)),onSelect:e=>C(e.id),range:h??b,selectedId:i})}),(0,W.jsx)(`section`,{"aria-label":`Node transcript`,className:`node-transcript`,ref:f.containerRef,children:e6(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,W.jsx)(n6,{onOpen:C,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,W.jsx)(t6,{entry:e,onToggle:()=>c(t=>{let n=new Set(t);return n.has(e.group.id)?n.delete(e.group.id):n.add(e.group.id),n})},`collapse-${e.group.id}`));return e.dispatch===void 0?(0,W.jsx)(H.Fragment,{children:t},e.id):(0,W.jsxs)(`section`,{"aria-label":e.dispatch.label,className:`transcript-dispatch`,children:[(0,W.jsx)(`h3`,{children:e.dispatch.label}),t]},e.id)})}),S!==void 0&&(0,W.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>n(),size:`icon`,variant:`ghost`,children:(0,W.jsx)(un,{})}),(0,W.jsx)(T3,{client:e,node:t,row:S,runId:r})]})]})}function $3(e){let t=e.map(({start:e})=>e),n=e.map(e=>e.end??e.start);if(t.length===0)return[0,1];let r=Math.min(...t),i=Math.max(...n);return[r,i>r?i:r+1]}function e6(e){let t=[];for(let n of e){let e=n.entryKind===`row`?n.row:n.group,r=t.at(-1);e.dispatch!==void 0&&r?.dispatch!==void 0&&r.dispatch.id===e.dispatch.id?r.entries.push(n):t.push({id:e.id,dispatch:e.dispatch,entries:[n]})}return t}function t6({entry:e,onToggle:t}){let n=z4(e.hidden,e.group.kind);return(0,W.jsx)(`p`,{className:`transcript-collapsed`,children:(0,W.jsxs)(`button`,{"aria-expanded":e.expanded,onClick:t,type:`button`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),e.expanded?`Collapse ${n}`:`Show ${n}`]})})}function n6({row:e,selected:t,register:n,onOpen:r}){return(0,W.jsx)(`article`,{"aria-label":e.displayLabel,className:`transcript-item`,"data-dispatch-group":e.dispatch?.label,"data-journal-seq":e.rowKind===`event`?e.event.seq:void 0,"data-selected":t,ref:t=>n(e.id,t),children:(0,W.jsxs)(`button`,{"aria-label":`Open ${e.displayLabel}`,onClick:()=>r(e.id),type:`button`,children:[(0,W.jsxs)(`span`,{className:`eyebrow`,children:[e.rowKind===`event`&&(0,W.jsx)(n4,{category:e.category}),e.displayKind]}),(0,W.jsx)(`strong`,{children:e.displayLabel}),(0,W.jsxs)(`span`,{className:`transcript-facts`,children:[(0,W.jsx)(aI,{at:e.startedAt}),e.durationMs!==null&&` · ${QF(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function r6(e){if(e.task!==void 0)return e.task;let t=e.steps??[];return t.length===0?`No task prose recorded.`:t.map(e=>`## ${e.id}\n\n${e.task}`).join(`
|
|
113
113
|
|
|
114
|
-
`)}function r6(e){let t=n6(e),n=/(?:^|\n)##[ \t]*acceptance[ \t]+criteria[ \t]*\r?\n([\s\S]*?)(?=\r?\n##[ \t]|$)/i.exec(t)?.[1]?.trim();return n===void 0||n.length===0?`No acceptance criteria recorded in this node's task.`:n}function i6({node:e}){let t=e.detail?.publication;if(t===void 0)return typeof e.result?.pr==`string`&&e.result.pr?(0,W.jsxs)(`a`,{className:`node-view-pr`,href:e.result.pr,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,W.jsx)(jt,{size:12})]}):(0,W.jsx)(W.Fragment,{children:`Not recorded`});let n=(t.merged?[[t.pr_url,`Pull request`],[t.commit_url,`Commit ${t.commit?.slice(0,8)??``}`]]:[[t.pr_url,`Pull request`],[t.branch_url,t.branch??`Branch`]]).filter(([e])=>e);return n.length===0?(0,W.jsx)(W.Fragment,{children:`Not recorded`}):(0,W.jsx)(W.Fragment,{children:n.map(([e,t],n)=>(0,W.jsxs)(`span`,{children:[n>0&&` · `,(0,W.jsxs)(`a`,{className:`node-view-pr`,href:e,rel:`noreferrer`,target:`_blank`,children:[t,` `,(0,W.jsx)(jt,{size:12})]})]},e))})}function a6({node:e}){let t=CX(e);if(t.length===0)return null;let n=e.result?.detail?.trim()||void 0;return(0,W.jsxs)(`section`,{"aria-label":`Awaited releases`,className:`node-awaiting m-5 rounded-lg border border-warning bg-warning-surface px-4 py-3 text-warning`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Kt,{size:16}),e.status===`complete-but-held`?`Complete, and held unlanded until its releases arrive`:`Complete, and held as a draft until its releases arrive`]}),(0,W.jsxs)(`dl`,{className:`facts facts-stacked`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:t.length===1?`Awaits`:`Awaits ${t.length}`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`ul`,{className:`awaited-releases`,children:t.map(e=>(0,W.jsxs)(`li`,{children:[`the `,(0,W.jsx)(`strong`,{children:e.target}),` release of`,` `,(0,W.jsx)(`code`,{children:e.producer})]},`${e.producer} ${e.target}`))})})]}),n!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Detail`}),(0,W.jsx)(`dd`,{children:n})]})]})]})}function o6({node:e,nodes:t}){if(!AX(e.status))return null;let n=e.status===`blocked`||e.status===`skipped`,r=TX(e),i=e.result?.error||void 0,a=e.result?.exit_code;return(0,W.jsxs)(sa,{className:V(`m-5 w-auto`,n&&`border-warning bg-warning-surface text-warning`),variant:n?`default`:`destructive`,children:[n?(0,W.jsx)(Kt,{}):(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:n?`This node is ${e.status}`:`This node ${e.status===`cancelled`?`was cancelled`:e.status===`not-completed`?`did not complete`:`failed`}${e.failure?`: ${e.failure.class}`:``}`}),(0,W.jsx)(la,{children:(0,W.jsxs)(`dl`,{className:`facts`,children:[n&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.status===`skipped`?`Unmet`:`Blocked by`}),(0,W.jsx)(`dd`,{children:e.blockers.length>0?e.blockers.map(e=>{let n=t.find(t=>t.id===e)?.status;return n===void 0?e:`${e} (${n})`}).join(`, `):`Nothing recorded; the run has not written what holds it.`})]}),e.status===`skipped`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Attempts`}),(0,W.jsx)(`dd`,{children:`Never attempted`})]}),!n&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Detail`}),(0,W.jsx)(`dd`,{children:r??`No reason was recorded for this outcome.`})]}),i!==void 0&&i!==r&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Error`}),(0,W.jsx)(`dd`,{children:i})]}),typeof a==`number`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Exit code`}),(0,W.jsx)(`dd`,{children:a})]})]})})]})}function s6(e){return e==null||e===``?`Not recorded`:typeof e==`string`?e:JSON.stringify(e,null,2)}function c6(e){let[t,n]=(0,H.useState)(!1);return{open:t,onToggle:(0,H.useCallback)(t=>{let r=t.currentTarget.open;n(r),r&&e?.()},[e])}}function l6({label:e,className:t,onOpen:n,children:r}){let i=c6(n);return(0,W.jsxs)(`details`,{"aria-label":e,className:t,open:i.open,onToggle:i.onToggle,children:[(0,W.jsx)(`summary`,{children:e}),i.open&&r]})}var u6=`idle-`,d6=`row:run`,f6=e=>`row:node:${e}`,p6={id:x4,label:`Idle`};function m6(e){return[...E4(e),p6]}var h6=.005;function g6(e,t){let n=e?.spans??[],r=_6(e),i=m6(e),a=[v6({id:d6,kind:`run`,label:`Run-level`,range:r,spans:n.filter(e=>e.node_id===void 0),lanes:i}),...t.map(e=>v6({id:f6(e.id),kind:`node`,label:e.label,nodeId:e.id,range:r,spans:n.filter(t=>t.node_id===e.id),lanes:i}))],o=a.flatMap(e=>e.items.filter(e=>e.payload.kind===`work`)),s=o.filter(e=>e.payload.countsAsWork!==!1);return{range:r,live:n.some(e=>e.ended_at===null),rows:a,line:{items:[...S6(r,s,void 0),...M4(o,i)],markers:[...F4(a.flatMap(e=>e.markers.filter(e=>e.at<=r[1])),s),...a.flatMap(e=>e.markers.filter(e=>e.at>r[1]))],lanes:i}}}function _6(e){let t=e?.spans??[],n=t.map(e=>Date.parse(e.started_at));if(n.length===0)return[0,1];let r=Math.min(...n),i=t.find(e=>e.kind===`run`);if(i?.ended_at!==void 0&&i.ended_at!==null){let e=Date.parse(i.ended_at);return[r,e>r?e:r+1]}let a=Math.max(...t.map(e=>e.ended_at===null?Date.parse(e.started_at):Date.parse(e.ended_at))),o=Date.parse(e?.observed_at??``),s=t.some(e=>e.ended_at===null)&&Number.isFinite(o)?Math.max(a,o):a;return[r,s>r?s:r+1]}function v6({id:e,kind:t,label:n,nodeId:r,range:i,spans:a,lanes:o}){let s=a.flatMap(t=>{let a=Y4(t);if(a===null)return[];let s=Math.max(Date.parse(t.started_at),i[0]);if(s>i[1])return[];let c=Math.min(y6(t,a,s,i),i[1]),l=t.reference?.kind===`conversation`?t.reference.value:void 0;return[{id:t.id,label:`${n} · ${X4(a,o)}${b6(t)}`,laneId:a,start:s,end:c,duration:c-s,status:t.status,payload:{id:t.id,kind:`work`,...t.harness_scope===void 0?{}:{countsAsWork:!1},label:`${n} · ${X4(a,o)}`,rowId:e,...r===void 0?{}:{nodeId:r},...l===void 0?{}:{conversationId:l},startedAt:t.started_at,endedAt:t.ended_at,durationMs:c-s}}]}),c=new Set(a.filter(e=>e.harness_scope!==void 0).map(e=>e.id)),l=s.filter(e=>!c.has(e.id)),u=S6(i,l,{rowId:e,nodeId:r}),d=x6(l).reduce((e,[t,n])=>e+(n-t),0);return{id:e,kind:t,label:n,...r===void 0?{}:{nodeId:r},lanes:o.filter(({id:e})=>[...s,...u].some(t=>t.laneId===e)),items:[...u,...s],line:[...u,...M4(s,o)],markers:a.flatMap(t=>t.events.map(t=>({id:t.record_id??t.id,label:`${n} · ${t.step_id??t.kind}`,at:Date.parse(t.at),status:t.status,payload:{id:t.record_id??t.id,kind:`record`,label:t.kind,rowId:e,...r===void 0?{}:{nodeId:r},startedAt:t.at,endedAt:null,durationMs:0}}))),workedMs:d,idleMs:u.reduce((e,t)=>e+t.payload.durationMs,0)}}function y6(e,t,n,r){return t===`lock-waits`&&e.total_duration_ms!==void 0?n+e.total_duration_ms:e.ended_at===null?r[1]:Date.parse(e.ended_at)}function b6(e){return e.count!==void 0&&e.count>1?` · ${e.count} recorded`:``}function x6(e){let t=e.map(e=>[e.start,Math.max(e.end??e.start,e.start)]).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t)).sort((e,t)=>e[0]-t[0]),n=[];for(let[e,r]of t){let t=n.at(-1);t!==void 0&&e<=t[1]?t[1]=Math.max(t[1],r):n.push([e,r])}return n}function S6(e,t,n){let r=x6(t),i=[],a=e[0];for(let[e,t]of r)e>a&&i.push([a,e]),a=Math.max(a,t);a<e[1]&&i.push([a,e[1]]);let o=Math.max(1,e[1]-e[0]);return i.filter(([e,t],n)=>n===0||n===i.length-1||(t-e)/o>=h6).map(([e,t],r)=>{let i=`${u6}${n?.rowId??`graph`}-${r}`,a={id:i,kind:`idle`,label:`Idle · ${ZF(t-e)}`,...n===void 0?{}:{rowId:n.rowId},...n?.nodeId===void 0?{}:{nodeId:n.nodeId},startedAt:new Date(e).toISOString(),endedAt:new Date(t).toISOString(),durationMs:t-e};return{id:i,label:a.label,laneId:x4,start:e,end:t,duration:t-e,status:`idle`,payload:a}})}function C6({client:e,detail:t,nodes:n,timeline:r,timelineError:i,journalSeq:a,onSelectNode:o,selectedItemId:s,onSelectItem:c}){let l=t.run.run_id,u=(0,H.useMemo)(()=>g6(r,n),[r,n]),d=(r?.spans??[]).filter(e=>e.node_id===void 0),f=d.find(e=>e.id===s),p=d.flatMap(e=>e.events).find(e=>(e.record_id??e.id)===s)??d.flatMap(e=>e.events).find(e=>e.id===s),m=f===void 0?p===void 0?void 0:U4(p):H4(f);return(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&s!==void 0&&c()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,s]),(0,W.jsxs)(`div`,{className:`overall-view`,"data-journal-seq":a,children:[(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`p-[34px] max-sm:p-3`,children:[(0,W.jsxs)(`section`,{className:`overall-hero`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Whole DAG`}),(0,W.jsx)(`h2`,{children:l}),t.graph?.plan.goal?.text&&(0,W.jsx)(`p`,{className:`run-goal`,children:t.graph.plan.goal.text}),(0,W.jsxs)(`p`,{children:[t.run.phase,` ·`,` `,t.run.last_event?`last event ${t.run.last_event}`:`no events recorded yet`]})]}),(0,W.jsxs)(`section`,{"aria-label":`Run records`,children:[(0,W.jsx)(l6,{label:`Timing and usage`,children:(0,W.jsx)(BX,{value:t.telemetry})}),(0,W.jsx)(l6,{label:`Goal and repository identities`,children:(0,W.jsx)(BX,{value:{goal:t.graph?.plan.goal,repositories:[...new Set(t.graph?.plan.tasks.flatMap(e=>e.repo?[e.repo]:[])??[])]}})}),(0,W.jsx)(l6,{label:`Recorded results`,children:(0,W.jsx)(BX,{value:t.graph?.result})}),(0,W.jsx)(l6,{label:`Provider health`,children:(0,W.jsx)(BX,{value:t.provider_health})})]}),(0,W.jsxs)(`section`,{"aria-label":`Run metrics`,className:`metric-grid`,children:[(0,W.jsx)(E6,{icon:(0,W.jsx)(gt,{}),label:`Status`,value:t.run.state}),(0,W.jsx)(E6,{icon:(0,W.jsx)(It,{}),label:`Nodes`,value:String(t.run.nodes.length)}),(0,W.jsx)(E6,{icon:(0,W.jsx)(kt,{}),label:`Wall time`,value:t.run.timing.wall_seconds===null?`not measured`:QF(t.run.timing.wall_seconds)}),(0,W.jsx)(E6,{icon:(0,W.jsx)(At,{}),label:`Turns`,value:String(t.run.turns)})]}),(0,W.jsx)(Fa,{className:`gap-0 py-[15px]`,children:(0,W.jsxs)(Ia,{className:`px-[15px]`,children:[(0,W.jsxs)(`div`,{className:`section-heading`,children:[(0,W.jsx)(gt,{size:16}),(0,W.jsx)(`h3`,{children:`Graph timeline`})]}),i===void 0?r===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`m-0 text-[11px] text-muted-foreground`,children:`Loading the run's timeline…`}):r.spans.length===0?(0,W.jsx)(`p`,{className:`m-0 text-[11px] text-muted-foreground`,children:`This run has recorded no timeline yet.`}):(0,W.jsx)(w6,{graph:u,onOpenNode:o,onOpenItem:c,selectedItemId:s}):(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Timeline unavailable`}),(0,W.jsx)(la,{children:i.message})]})]})})]})}),m!==void 0&&(0,W.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>c(),size:`icon`,variant:`ghost`,children:(0,W.jsx)(un,{})}),(0,W.jsx)(w3,{client:e,row:m,runId:l})]})]})}function w6({graph:e,onOpenNode:t,onOpenItem:n,selectedItemId:r}){let[i,a]=(0,H.useState)(),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(new Set),u=i??e.range,d=e=>{e.kind===`record`&&e.nodeId===void 0||e.nodeId===void 0?n(e.id):t(e.nodeId)},f=e.line.lanes.filter(({id:t})=>e.line.items.some(e=>e.laneId===t));return(0,W.jsxs)(`div`,{className:`graph-timeline`,"data-rows-open":o,children:[(0,W.jsx)(Cn,{...H2,axis:{origin:e.range[0]},expanded:!1,items:e.line.items,label:`Graph timeline`,lanes:f,markers:e.line.markers,onExpandedChange:s,onRangeChange:e=>a(W2(e)),onSelect:e=>d(e.payload),range:u,selectedId:r}),e.line.markers.some(t=>t.at>e.range[1])&&(0,W.jsxs)(`section`,{"aria-label":`Records after execution`,className:`p-3 border-t`,children:[(0,W.jsx)(`h3`,{className:`eyebrow`,children:`After execution ended`}),e.line.markers.filter(t=>t.at>e.range[1]).map(e=>(0,W.jsxs)(Pa,{onClick:()=>d(e.payload),variant:`outline`,size:`sm`,children:[e.payload.label,` ·`,` `,(0,W.jsx)(iI,{at:e.payload.startedAt})]},e.id))]}),o&&(0,W.jsx)(`ol`,{className:`graph-rows`,children:e.rows.map(n=>(0,W.jsx)(T6,{onOpen:d,onOpenNode:t,onExpandedChange:e=>l(t=>{let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r}),expanded:c.has(n.id),origin:e.range[0],range:u,onRangeChange:e=>a(W2(e)),row:n,selectedItemId:r},n.id))})]})}function T6({row:e,range:t,origin:n,expanded:r,onExpandedChange:i,onRangeChange:a,onOpen:o,onOpenNode:s,selectedItemId:c}){let l=e.nodeId;return(0,W.jsxs)(`li`,{className:`graph-row`,"data-row-kind":e.kind,children:[(0,W.jsxs)(`header`,{className:`graph-row-head`,children:[l===void 0?(0,W.jsx)(`span`,{className:`graph-row-name`,children:e.label}):(0,W.jsx)(`button`,{className:`graph-row-name`,onClick:()=>s(l),type:`button`,children:e.label}),(0,W.jsxs)(`span`,{className:`graph-row-facts`,children:[ZF(e.workedMs),` recorded · `,ZF(e.idleMs),` `,`idle`]})]}),(0,W.jsx)(Cn,{...H2,axis:{origin:n},expanded:r,items:r?e.items:e.line,label:`${e.label} timeline`,lanes:e.lanes,markers:e.markers,onExpandedChange:i,onRangeChange:a,onSelect:e=>o(e.payload),range:t,selectedId:c})]})}function E6({icon:e,label:t,value:n}){return(0,W.jsxs)(Fa,{"aria-label":t,className:`metric flex-row items-center gap-3 p-4`,role:`group`,children:[e,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:t}),(0,W.jsx)(`strong`,{children:n})]})]})}var D6=6,O6=8,k6=`[aria-describedby^="timeline-detail-"]`,A6=e=>{if(!(e instanceof Element))return;let t=v4(e);if(t!==void 0)return t;let n=e.closest(k6);if(!(n instanceof HTMLElement))return;let r=document.getElementById(n.getAttribute(`aria-describedby`)??``)?.textContent?.trim();return r?{element:n,detail:r}:void 0},j6=(e,t)=>t!==void 0&&e?.element===t.element&&e.detail===t.detail?e:t;function M6(){let e=(0,H.useRef)(null),[t,n]=(0,H.useState)(),[r,i]=(0,H.useState)(),a=t??r,o=(0,H.useCallback)(()=>{n(void 0),i(void 0)},[]);(0,H.useEffect)(()=>{let e=e=>n(t=>j6(t,A6(e.target))),t=e=>i(t=>j6(t,A6(e.target))),r=e=>i(t=>j6(t,A6(e.relatedTarget))),a=()=>n(void 0);return document.addEventListener(`pointerover`,e),document.addEventListener(`pointerleave`,a),document.addEventListener(`focusin`,t),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`pointerover`,e),document.removeEventListener(`pointerleave`,a),document.removeEventListener(`focusin`,t),document.removeEventListener(`focusout`,r)}},[]);let s=(0,H.useCallback)(()=>{let t=e.current;if(t===null||a===void 0)return;if(!a.element.isConnected)return o();let n=a.element.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.width-O6,s=Math.min(Math.max(n.left,O6),Math.max(O6,i)),c=n.bottom+D6,l=n.top-r.height-D6,u=Math.max(O6,window.innerHeight-r.height-O6),d=c+r.height<=window.innerHeight-O6?c:l,f=Math.min(Math.max(d,O6),u);t.style.left=`${Math.round(s)}px`,t.style.top=`${Math.round(f)}px`,t.style.visibility=`visible`},[a,o]);return(0,H.useLayoutEffect)(s,[s]),(0,H.useEffect)(()=>{if(a!==void 0)return window.addEventListener(`scroll`,s,!0),window.addEventListener(`resize`,s),()=>{window.removeEventListener(`scroll`,s,!0),window.removeEventListener(`resize`,s)}},[a,s]),a===void 0?null:(0,jr.createPortal)((0,W.jsx)(`div`,{"aria-hidden":`true`,className:`timeline-popover`,"data-testid":`timeline-popover`,ref:e,style:{visibility:`hidden`},children:a.detail},a.detail),document.body)}var N6=[{setting:`live`,label:`Live`},{setting:10,label:`Every 10 seconds`},{setting:30,label:`Every 30 seconds`},{setting:60,label:`Every minute`},{setting:300,label:`Every 5 minutes`},{setting:`off`,label:`Off`}],P6=`live`,F6={navigation:`dag-ui.updates.navigation`,main:`dag-ui.updates.main`};function I6(e){return N6.find(({setting:t})=>String(t)===e)?.setting}function L6(e){try{return window.localStorage.getItem(e)}catch{return null}}function R6(e,t){try{window.localStorage.setItem(e,String(t))}catch{}}function z6(e,t){let[n,r]=(0,H.useState)(()=>I6(L6(e))??t);return[n,(0,H.useCallback)(t=>{r(t),R6(e,t)},[e])]}function B6(){let[e,t]=z6(F6.navigation,30),[n,r]=z6(F6.main,P6);return{navigation:e,setNavigation:t,main:n,setMain:r}}function V6({name:e,caption:t,setting:n,waiting:r,onChange:i}){return(0,W.jsxs)(`div`,{className:`update-setting`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`select`,{"aria-label":e,onChange:e=>{let t=I6(e.target.value);t!==void 0&&i(t)},value:String(n),children:N6.map(({setting:e,label:t})=>(0,W.jsx)(`option`,{value:String(e),children:t},e))})]}),r>0&&(0,W.jsxs)(`output`,{"aria-label":`${e} waiting`,className:`update-waiting`,children:[r,` waiting`]})]})}var H6=new XN(window.location.origin,{fetch:window.fetch.bind(window)}),U6=Object.entries(W0);function W6(e){let t=(0,H.useRef)({value:e,count:0});return t.current.value!==e&&(t.current={value:e,count:t.current.count+1}),t.current.count}var G6=()=>Promise.resolve();function K6({client:e=H6}){let t=X0(),n=z0(),r=t.host||n.active,i=a0(n.active),a=W0[t.detail].profile,o=B6(),s=c2(),c=u2(e,{runId:t.runId,view:t.view===`overall`?`overall`:t.view===`channel`?`channel`:t.nodeId===void 0?`graph`:`node`,nodeId:t.nodeId,filter:a,selectFirst:!r,host:r,humanItems:i.view,navigationUpdates:o.navigation,mainUpdates:o.main}),l=c.rows,u=c.runId,d=c.activity.at(-1),f=c.detail,p=(0,H.useMemo)(()=>f?_X(f):[],[f]),m=LI(e,u),h=N2(e),[g,_]=(0,H.useState)(0),v=h.host.state.phase===`sending`,y=W6(l),{list:b,error:x}=GX(e,t.host||v,g+(v?y:0)),S=f===void 0?void 0:hX(f),C=p.find(({id:e})=>e===t.nodeId);return(0,H.useEffect)(()=>{if(r||!l)return;let e=e2(l),n=e.find(e=>e.rows.some(e=>e.id===t.runId)),i=n?.rows.find(e=>e.id===t.runId),a=(n?.rows??e.flatMap(e=>e.rows)).filter(e=>!e.kind||!t.hiddenKinds.includes(e.kind));(!t.runId||i?.kind&&t.hiddenKinds.includes(i.kind))&&a[0]&&t.selectRun(a[0].id)},[l,t,r]),(0,H.useEffect)(()=>{if(u&&t.runId&&t.runId!==u){let e=new URLSearchParams(window.location.search);e.set(`run`,u),e.delete(`node`),e.delete(`event`),e.set(`view`,t.view),window.history.replaceState(null,``,`${window.location.pathname}?${e}`),window.dispatchEvent(new PopStateEvent(`popstate`))}},[t.runId,u,t.view]),(0,W.jsxs)(dm,{children:[(0,W.jsx)(M6,{}),(0,W.jsxs)(`div`,{className:`app-shell`,children:[(0,W.jsx)(s2,{rows:c.navigationRows,selectedRunId:u,onSelect:e=>{t.selectRun(e),s.close()},onOpenProject:t.selectRun,onHost:()=>{t.selectHost(),s.close()},hostCurrent:t.host&&!n.active,onActionItems:()=>{n.open(),s.close()},actionItemsCurrent:n.active,hiddenKinds:t.hiddenKinds,onKindsChange:t.selectKinds,drawerOpen:s.open,drawerRef:s.drawer,updates:(0,W.jsx)(V6,{caption:`Navigation`,name:`Navigation updates`,onChange:o.setNavigation,setting:o.navigation,waiting:c.navigationWaiting})}),s.open&&(0,W.jsx)(`button`,{"aria-label":`Close navigation`,className:`nav-scrim`,onClick:s.close,type:`button`}),(0,W.jsxs)(`main`,{className:`workspace`,inert:s.open,children:[(0,W.jsxs)(`section`,{"aria-label":u&&!r?`Run header`:`Workspace header`,className:`topbar${u&&!r?` run-topbar`:``}`,children:[(0,W.jsx)(`button`,{"aria-controls":`run-navigation`,"aria-expanded":s.open,"aria-label":`Open navigation`,className:`nav-menu`,onClick:s.toggle,ref:s.menuButton,type:`button`,children:(0,W.jsx)(Bt,{"aria-hidden":`true`,size:18})}),(0,W.jsx)(`div`,{className:`topbar-title`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Execution telemetry`}),(0,W.jsx)(`h2`,{children:n.active?`Action items`:t.host?`Host`:u??`No DAG selected`})]})}),(0,W.jsxs)(`div`,{className:`topbar-actions`,children:[!r&&u!==void 0&&(0,W.jsx)(NI,{control:m,runId:u,ended:f!==void 0&&(f.run.state===`settled`||f.run.state.startsWith(`ended-`))}),(0,W.jsxs)(`span`,{className:`connection`,children:[(0,W.jsx)($t,{size:15}),c.lastUpdated===void 0?`Waiting for first update`:(0,W.jsxs)(W.Fragment,{children:[`Last updated`,` `,(0,W.jsx)(iI,{at:c.lastUpdated,relative:!0})]})]}),!r&&d!==void 0&&(0,W.jsxs)(`button`,{className:`last-activity connection`,type:`button`,title:`${d.node}: ${q6(d)}`,onClick:()=>{t.selectNode(d.node),t.selectItem(d.event_id)},children:[d.node,`: `,q6(d)]})]}),(0,W.jsxs)(`div`,{className:`main-updates`,children:[(0,W.jsx)(V6,{caption:`Updates`,name:`Main area updates`,onChange:o.setMain,setting:o.main,waiting:c.mainWaiting}),(0,W.jsxs)(Pa,{onClick:()=>{_(e=>e+1),c.refresh()},size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Xt,{size:14}),` Refresh`]})]})]}),!r&&f&&(0,W.jsxs)(l6,{label:`Run details`,className:`run-header-details`,onOpen:m.reread,children:[(0,W.jsxs)(`p`,{children:[`Launching session: `,bX(f.launch)]}),m.status.error&&(0,W.jsxs)(`p`,{role:`alert`,children:[`Status unavailable: `,m.status.error.message]}),m.status.value&&(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Summary`}),(0,W.jsx)(`dd`,{children:m.status.value.summary}),(0,W.jsx)(`dt`,{children:`Graph state`}),(0,W.jsx)(`dd`,{children:vX(m.status.value.node_status)}),(0,W.jsx)(`dt`,{children:`Unread surfaces`}),(0,W.jsx)(`dd`,{children:m.status.value.unread_surfaces.count}),(0,W.jsx)(`dt`,{children:`Oldest unread (seconds)`}),(0,W.jsx)(`dd`,{children:m.status.value.unread_surfaces.oldest_seconds??`None`}),(0,W.jsx)(`dt`,{children:`Last progress`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Last progress`,children:f.run.last_progress_at===void 0?`Not recorded`:(0,W.jsx)(iI,{at:new Date(f.run.last_progress_at*1e3).toISOString(),relative:!0})})})]}),m.status.value&&(0,W.jsx)(`section`,{"aria-label":`Node statuses`,children:(0,W.jsx)(BX,{value:m.status.value.node_status})})]}),c.error&&(0,W.jsxs)(sa,{className:`rounded-none border-x-0 border-t-0`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Live telemetry issue`}),(0,W.jsx)(la,{children:c.error.message})]}),c.notice&&(0,W.jsx)(`p`,{className:`live-notice`,role:`status`,children:c.notice}),(0,W.jsx)(L2,{label:`Shutdown of the entire host`,onDismiss:h.host.dismiss,rows:b?.runs??[],state:h.host.state}),n.active?(0,W.jsx)(f0,{client:e,live:c.humanItems,choice:i.choice,setChoice:i.setChoice,selectedId:i.selectedId,setSelectedId:i.setSelectedId}):t.host?(0,W.jsx)(WX,{client:e,listError:x,onRefresh:()=>_(e=>e+1),list:b,rows:c.hostRows,children:(0,W.jsx)(P2,{list:b,loadMore:G6,loadingMore:!1,shutdowns:h})}):(0,W.jsxs)(bp,{className:`min-h-0 flex-1 gap-0`,onValueChange:e=>e===`overall`?t.showOverall():e===`graph`?t.selectNode(void 0):V0(e)?t.selectView(e):void 0,value:t.view,children:[(0,W.jsxs)(`div`,{className:`view-tabs`,children:[(0,W.jsxs)(Sp,{"aria-label":`DAG views`,variant:`line`,children:[(0,W.jsxs)(Cp,{value:`graph`,children:[(0,W.jsx)(ln,{size:15}),` Graph`]}),(0,W.jsxs)(Cp,{value:`overall`,children:[(0,W.jsx)(Qt,{size:15}),` Overall`]}),(0,W.jsxs)(Cp,{value:`channel`,children:[(0,W.jsx)(Ft,{size:15}),` Channel`]})]}),(0,W.jsxs)(`fieldset`,{className:`detail-switch`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Level of detail`}),U6.map(([e,{label:n,description:r}])=>(0,W.jsx)(Pa,{"aria-pressed":t.detail===e,onClick:()=>t.selectDetail(e),size:`sm`,title:r,type:`button`,variant:t.detail===e?`default`:`outline`,children:n},e))]})]}),(0,W.jsx)(wp,{className:`min-h-0`,value:t.view,children:!f&&(c.loading||u!==void 0)?(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,W.jsx)(xf,{className:`h-2 w-48`}),(0,W.jsx)(xf,{className:`h-2 w-32`}),`Loading execution history…`]}):f&&u?t.view===`channel`?(0,W.jsx)(CI,{channel:c.channel,client:e,decisions:S?.decisions??[],filter:a,journalSeq:S?.last_seq,observedAt:f.observed_at,overrides:S&&gX(S),runId:u}):t.view===`overall`?(0,W.jsx)(C6,{client:e,detail:f,journalSeq:S?.last_seq,nodes:p,timeline:c.timeline,timelineError:c.timelineError,onSelectNode:t.selectNode,onSelectItem:t.selectItem,selectedItemId:t.itemId}):C?(0,W.jsx)(X3,{client:e,node:C,nodes:p,onBack:()=>t.selectNode(void 0),onSelectItem:t.selectItem,runId:u,selectedItemId:t.itemId,selectedTab:t.nodeTab,onSelectTab:t.selectNodeTab,timeline:c.timeline,timelineError:c.timelineError}):(0,W.jsx)(zX,{journalSeq:S?.last_seq,nodes:p,selectedNodeId:t.nodeId,onSelectNode:t.selectNode}):(0,W.jsxs)(`div`,{className:`empty-state`,children:[(0,W.jsx)(ln,{size:34}),(0,W.jsx)(`h2`,{children:`No DAG runs found`}),(0,W.jsx)(`p`,{children:`Start an orchestrated run to see it appear here.`})]})})]})]})]})]})}function q6(e){return e.description||e.kind}var J6=class extends H.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`DAG UI render failed`,e,t.componentStack)}render(){return this.state.error?(0,W.jsxs)(`main`,{className:`fatal-error`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Rendering error`}),(0,W.jsx)(`h1`,{children:`The DAG view could not be displayed.`}),(0,W.jsx)(`p`,{children:this.state.error.message}),(0,W.jsx)(Pa,{onClick:()=>(this.props.onReload??(()=>window.location.reload()))(),type:`button`,variant:`secondary`,children:`Reload`})]}):this.props.children}},Y6=document.getElementById(`root`);if(!Y6)throw Error(`DAG UI root element is missing`);(0,jA.createRoot)(Y6).render((0,W.jsx)(H.StrictMode,{children:(0,W.jsx)(J6,{children:(0,W.jsx)(K6,{})})}));
|
|
114
|
+
`)}function i6(e){let t=r6(e),n=/(?:^|\n)##[ \t]*acceptance[ \t]+criteria[ \t]*\r?\n([\s\S]*?)(?=\r?\n##[ \t]|$)/i.exec(t)?.[1]?.trim();return n===void 0||n.length===0?`No acceptance criteria recorded in this node's task.`:n}function a6({node:e}){let t=e.detail?.publication;if(t===void 0)return typeof e.result?.pr==`string`&&e.result.pr?(0,W.jsxs)(`a`,{className:`node-view-pr`,href:e.result.pr,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,W.jsx)(jt,{size:12})]}):(0,W.jsx)(W.Fragment,{children:`Not recorded`});let n=(t.merged?[[t.pr_url,`Pull request`],[t.commit_url,`Commit ${t.commit?.slice(0,8)??``}`]]:[[t.pr_url,`Pull request`],[t.branch_url,t.branch??`Branch`]]).filter(([e])=>e);return n.length===0?(0,W.jsx)(W.Fragment,{children:`Not recorded`}):(0,W.jsx)(W.Fragment,{children:n.map(([e,t],n)=>(0,W.jsxs)(`span`,{children:[n>0&&` · `,(0,W.jsxs)(`a`,{className:`node-view-pr`,href:e,rel:`noreferrer`,target:`_blank`,children:[t,` `,(0,W.jsx)(jt,{size:12})]})]},e))})}function o6({node:e}){let t=wX(e);if(t.length===0)return null;let n=e.result?.detail?.trim()||void 0;return(0,W.jsxs)(`section`,{"aria-label":`Awaited releases`,className:`node-awaiting m-5 rounded-lg border border-warning bg-warning-surface px-4 py-3 text-warning`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,W.jsx)(Kt,{size:16}),e.status===`complete-but-held`?`Complete, and held unlanded until its releases arrive`:`Complete, and held as a draft until its releases arrive`]}),(0,W.jsxs)(`dl`,{className:`facts facts-stacked`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:t.length===1?`Awaits`:`Awaits ${t.length}`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`ul`,{className:`awaited-releases`,children:t.map(e=>(0,W.jsxs)(`li`,{children:[`the `,(0,W.jsx)(`strong`,{children:e.target}),` release of`,` `,(0,W.jsx)(`code`,{children:e.producer})]},`${e.producer} ${e.target}`))})})]}),n!==void 0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Detail`}),(0,W.jsx)(`dd`,{children:n})]})]})]})}function s6({node:e,nodes:t}){if(!jX(e.status))return null;let n=e.status===`blocked`||e.status===`skipped`,r=EX(e),i=e.result?.error||void 0,a=e.result?.exit_code;return(0,W.jsxs)(sa,{className:V(`m-5 w-auto`,n&&`border-warning bg-warning-surface text-warning`),variant:n?`default`:`destructive`,children:[n?(0,W.jsx)(Kt,{}):(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:n?`This node is ${e.status}`:`This node ${e.status===`cancelled`?`was cancelled`:e.status===`not-completed`?`did not complete`:`failed`}${e.failure?`: ${e.failure.class}`:``}`}),(0,W.jsx)(la,{children:(0,W.jsxs)(`dl`,{className:`facts`,children:[n&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.status===`skipped`?`Unmet`:`Blocked by`}),(0,W.jsx)(`dd`,{children:e.blockers.length>0?e.blockers.map(e=>{let n=t.find(t=>t.id===e)?.status;return n===void 0?e:`${e} (${n})`}).join(`, `):`Nothing recorded; the run has not written what holds it.`})]}),e.status===`skipped`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Attempts`}),(0,W.jsx)(`dd`,{children:`Never attempted`})]}),!n&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Detail`}),(0,W.jsx)(`dd`,{children:r??`No reason was recorded for this outcome.`})]}),i!==void 0&&i!==r&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Error`}),(0,W.jsx)(`dd`,{children:i})]}),typeof a==`number`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Exit code`}),(0,W.jsx)(`dd`,{children:a})]})]})})]})}function c6(e){return e==null||e===``?`Not recorded`:typeof e==`string`?e:JSON.stringify(e,null,2)}function l6(e){let[t,n]=(0,H.useState)(!1);return{open:t,onToggle:(0,H.useCallback)(t=>{let r=t.currentTarget.open;n(r),r&&e?.()},[e])}}function u6({label:e,className:t,onOpen:n,children:r}){let i=l6(n);return(0,W.jsxs)(`details`,{"aria-label":e,className:t,open:i.open,onToggle:i.onToggle,children:[(0,W.jsx)(`summary`,{children:e}),i.open&&r]})}var d6=`idle-`,f6=`row:run`,p6=e=>`row:node:${e}`,m6={id:S4,label:`Idle`};function h6(e){return[...D4(e),m6]}var g6=.005;function _6(e,t){let n=e?.spans??[],r=v6(e),i=h6(e),a=[y6({id:f6,kind:`run`,label:`Run-level`,range:r,spans:n.filter(e=>e.node_id===void 0),lanes:i}),...t.map(e=>y6({id:p6(e.id),kind:`node`,label:e.label,nodeId:e.id,range:r,spans:n.filter(t=>t.node_id===e.id),lanes:i}))],o=a.flatMap(e=>e.items.filter(e=>e.payload.kind===`work`)),s=o.filter(e=>e.payload.countsAsWork!==!1);return{range:r,live:n.some(e=>e.ended_at===null),rows:a,line:{items:[...C6(r,s,void 0),...N4(o,i)],markers:[...I4(a.flatMap(e=>e.markers.filter(e=>e.at<=r[1])),s),...a.flatMap(e=>e.markers.filter(e=>e.at>r[1]))],lanes:i}}}function v6(e){let t=e?.spans??[],n=t.map(e=>Date.parse(e.started_at));if(n.length===0)return[0,1];let r=Math.min(...n),i=t.find(e=>e.kind===`run`);if(i?.ended_at!==void 0&&i.ended_at!==null){let e=Date.parse(i.ended_at);return[r,e>r?e:r+1]}let a=Math.max(...t.map(e=>e.ended_at===null?Date.parse(e.started_at):Date.parse(e.ended_at))),o=Date.parse(e?.observed_at??``),s=t.some(e=>e.ended_at===null)&&Number.isFinite(o)?Math.max(a,o):a;return[r,s>r?s:r+1]}function y6({id:e,kind:t,label:n,nodeId:r,range:i,spans:a,lanes:o}){let s=a.flatMap(t=>{let a=X4(t);if(a===null)return[];let s=Math.max(Date.parse(t.started_at),i[0]);if(s>i[1])return[];let c=Math.min(b6(t,a,s,i),i[1]),l=t.reference?.kind===`conversation`?t.reference.value:void 0;return[{id:t.id,label:`${n} · ${Z4(a,o)}${x6(t)}`,laneId:a,start:s,end:c,duration:c-s,status:t.status,payload:{id:t.id,kind:`work`,...t.harness_scope===void 0?{}:{countsAsWork:!1},label:`${n} · ${Z4(a,o)}`,rowId:e,...r===void 0?{}:{nodeId:r},...l===void 0?{}:{conversationId:l},startedAt:t.started_at,endedAt:t.ended_at,durationMs:c-s}}]}),c=new Set(a.filter(e=>e.harness_scope!==void 0).map(e=>e.id)),l=s.filter(e=>!c.has(e.id)),u=C6(i,l,{rowId:e,nodeId:r}),d=S6(l).reduce((e,[t,n])=>e+(n-t),0);return{id:e,kind:t,label:n,...r===void 0?{}:{nodeId:r},lanes:o.filter(({id:e})=>[...s,...u].some(t=>t.laneId===e)),items:[...u,...s],line:[...u,...N4(s,o)],markers:a.flatMap(t=>t.events.map(t=>({id:t.record_id??t.id,label:`${n} · ${t.step_id??t.kind}`,at:Date.parse(t.at),status:t.status,payload:{id:t.record_id??t.id,kind:`record`,label:t.kind,rowId:e,...r===void 0?{}:{nodeId:r},startedAt:t.at,endedAt:null,durationMs:0}}))),workedMs:d,idleMs:u.reduce((e,t)=>e+t.payload.durationMs,0)}}function b6(e,t,n,r){return t===`lock-waits`&&e.total_duration_ms!==void 0?n+e.total_duration_ms:e.ended_at===null?r[1]:Date.parse(e.ended_at)}function x6(e){return e.count!==void 0&&e.count>1?` · ${e.count} recorded`:``}function S6(e){let t=e.map(e=>[e.start,Math.max(e.end??e.start,e.start)]).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t)).sort((e,t)=>e[0]-t[0]),n=[];for(let[e,r]of t){let t=n.at(-1);t!==void 0&&e<=t[1]?t[1]=Math.max(t[1],r):n.push([e,r])}return n}function C6(e,t,n){let r=S6(t),i=[],a=e[0];for(let[e,t]of r)e>a&&i.push([a,e]),a=Math.max(a,t);a<e[1]&&i.push([a,e[1]]);let o=Math.max(1,e[1]-e[0]);return i.filter(([e,t],n)=>n===0||n===i.length-1||(t-e)/o>=g6).map(([e,t],r)=>{let i=`${d6}${n?.rowId??`graph`}-${r}`,a={id:i,kind:`idle`,label:`Idle · ${QF(t-e)}`,...n===void 0?{}:{rowId:n.rowId},...n?.nodeId===void 0?{}:{nodeId:n.nodeId},startedAt:new Date(e).toISOString(),endedAt:new Date(t).toISOString(),durationMs:t-e};return{id:i,label:a.label,laneId:S4,start:e,end:t,duration:t-e,status:`idle`,payload:a}})}function w6({client:e,detail:t,nodes:n,timeline:r,timelineError:i,journalSeq:a,onSelectNode:o,selectedItemId:s,onSelectItem:c}){let l=t.run.run_id,u=(0,H.useMemo)(()=>_6(r,n),[r,n]),d=(r?.spans??[]).filter(e=>e.node_id===void 0),f=d.find(e=>e.id===s),p=d.flatMap(e=>e.events).find(e=>(e.record_id??e.id)===s)??d.flatMap(e=>e.events).find(e=>e.id===s),m=f===void 0?p===void 0?void 0:W4(p):U4(f);return(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&s!==void 0&&c()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,s]),(0,W.jsxs)(`div`,{className:`overall-view`,"data-journal-seq":a,children:[(0,W.jsx)(sf,{className:`h-full`,children:(0,W.jsxs)(`div`,{className:`p-[34px] max-sm:p-3`,children:[(0,W.jsxs)(`section`,{className:`overall-hero`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Whole DAG`}),(0,W.jsx)(`h2`,{children:l}),t.graph?.plan.goal?.text&&(0,W.jsx)(`p`,{className:`run-goal`,children:t.graph.plan.goal.text}),(0,W.jsxs)(`p`,{children:[t.run.phase,` ·`,` `,t.run.last_event?`last event ${t.run.last_event}`:`no events recorded yet`]})]}),(0,W.jsxs)(`section`,{"aria-label":`Run records`,children:[(0,W.jsx)(u6,{label:`Timing and usage`,children:(0,W.jsx)(VX,{value:t.telemetry})}),(0,W.jsx)(u6,{label:`Goal and repository identities`,children:(0,W.jsx)(VX,{value:{goal:t.graph?.plan.goal,repositories:[...new Set(t.graph?.plan.tasks.flatMap(e=>e.repo?[e.repo]:[])??[])]}})}),(0,W.jsx)(u6,{label:`Recorded results`,children:(0,W.jsx)(VX,{value:t.graph?.result})}),(0,W.jsx)(u6,{label:`Provider health`,children:(0,W.jsx)(VX,{value:t.provider_health})})]}),(0,W.jsxs)(`section`,{"aria-label":`Run metrics`,className:`metric-grid`,children:[(0,W.jsx)(D6,{icon:(0,W.jsx)(gt,{}),label:`Status`,value:t.run.state}),(0,W.jsx)(D6,{icon:(0,W.jsx)(It,{}),label:`Nodes`,value:String(t.run.nodes.length)}),(0,W.jsx)(D6,{icon:(0,W.jsx)(kt,{}),label:`Wall time`,value:t.run.timing.wall_seconds===null?`not measured`:$F(t.run.timing.wall_seconds)}),(0,W.jsx)(D6,{icon:(0,W.jsx)(At,{}),label:`Turns`,value:String(t.run.turns)})]}),(0,W.jsx)(Fa,{className:`gap-0 py-[15px]`,children:(0,W.jsxs)(Ia,{className:`px-[15px]`,children:[(0,W.jsxs)(`div`,{className:`section-heading`,children:[(0,W.jsx)(gt,{size:16}),(0,W.jsx)(`h3`,{children:`Graph timeline`})]}),i===void 0?r===void 0?(0,W.jsx)(`p`,{"aria-live":`polite`,className:`m-0 text-[11px] text-muted-foreground`,children:`Loading the run's timeline…`}):r.spans.length===0?(0,W.jsx)(`p`,{className:`m-0 text-[11px] text-muted-foreground`,children:`This run has recorded no timeline yet.`}):(0,W.jsx)(T6,{graph:u,onOpenNode:o,onOpenItem:c,selectedItemId:s}):(0,W.jsxs)(sa,{variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Timeline unavailable`}),(0,W.jsx)(la,{children:i.message})]})]})})]})}),m!==void 0&&(0,W.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,W.jsx)(Pa,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>c(),size:`icon`,variant:`ghost`,children:(0,W.jsx)(un,{})}),(0,W.jsx)(T3,{client:e,row:m,runId:l})]})]})}function T6({graph:e,onOpenNode:t,onOpenItem:n,selectedItemId:r}){let[i,a]=(0,H.useState)(),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(new Set),u=i??e.range,d=e=>{e.kind===`record`&&e.nodeId===void 0||e.nodeId===void 0?n(e.id):t(e.nodeId)},f=e.line.lanes.filter(({id:t})=>e.line.items.some(e=>e.laneId===t));return(0,W.jsxs)(`div`,{className:`graph-timeline`,"data-rows-open":o,children:[(0,W.jsx)(Cn,{...U2,axis:{origin:e.range[0]},expanded:!1,items:e.line.items,label:`Graph timeline`,lanes:f,markers:e.line.markers,onExpandedChange:s,onRangeChange:e=>a(G2(e)),onSelect:e=>d(e.payload),range:u,selectedId:r}),e.line.markers.some(t=>t.at>e.range[1])&&(0,W.jsxs)(`section`,{"aria-label":`Records after execution`,className:`p-3 border-t`,children:[(0,W.jsx)(`h3`,{className:`eyebrow`,children:`After execution ended`}),e.line.markers.filter(t=>t.at>e.range[1]).map(e=>(0,W.jsxs)(Pa,{onClick:()=>d(e.payload),variant:`outline`,size:`sm`,children:[e.payload.label,` ·`,` `,(0,W.jsx)(aI,{at:e.payload.startedAt})]},e.id))]}),o&&(0,W.jsx)(`ol`,{className:`graph-rows`,children:e.rows.map(n=>(0,W.jsx)(E6,{onOpen:d,onOpenNode:t,onExpandedChange:e=>l(t=>{let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r}),expanded:c.has(n.id),origin:e.range[0],range:u,onRangeChange:e=>a(G2(e)),row:n,selectedItemId:r},n.id))})]})}function E6({row:e,range:t,origin:n,expanded:r,onExpandedChange:i,onRangeChange:a,onOpen:o,onOpenNode:s,selectedItemId:c}){let l=e.nodeId;return(0,W.jsxs)(`li`,{className:`graph-row`,"data-row-kind":e.kind,children:[(0,W.jsxs)(`header`,{className:`graph-row-head`,children:[l===void 0?(0,W.jsx)(`span`,{className:`graph-row-name`,children:e.label}):(0,W.jsx)(`button`,{className:`graph-row-name`,onClick:()=>s(l),type:`button`,children:e.label}),(0,W.jsxs)(`span`,{className:`graph-row-facts`,children:[QF(e.workedMs),` recorded · `,QF(e.idleMs),` `,`idle`]})]}),(0,W.jsx)(Cn,{...U2,axis:{origin:n},expanded:r,items:r?e.items:e.line,label:`${e.label} timeline`,lanes:e.lanes,markers:e.markers,onExpandedChange:i,onRangeChange:a,onSelect:e=>o(e.payload),range:t,selectedId:c})]})}function D6({icon:e,label:t,value:n}){return(0,W.jsxs)(Fa,{"aria-label":t,className:`metric flex-row items-center gap-3 p-4`,role:`group`,children:[e,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:t}),(0,W.jsx)(`strong`,{children:n})]})]})}var O6=6,k6=8,A6=`[aria-describedby^="timeline-detail-"]`,j6=e=>{if(!(e instanceof Element))return;let t=y4(e);if(t!==void 0)return t;let n=e.closest(A6);if(!(n instanceof HTMLElement))return;let r=document.getElementById(n.getAttribute(`aria-describedby`)??``)?.textContent?.trim();return r?{element:n,detail:r}:void 0},M6=(e,t)=>t!==void 0&&e?.element===t.element&&e.detail===t.detail?e:t;function N6(){let e=(0,H.useRef)(null),[t,n]=(0,H.useState)(),[r,i]=(0,H.useState)(),a=t??r,o=(0,H.useCallback)(()=>{n(void 0),i(void 0)},[]);(0,H.useEffect)(()=>{let e=e=>n(t=>M6(t,j6(e.target))),t=e=>i(t=>M6(t,j6(e.target))),r=e=>i(t=>M6(t,j6(e.relatedTarget))),a=()=>n(void 0);return document.addEventListener(`pointerover`,e),document.addEventListener(`pointerleave`,a),document.addEventListener(`focusin`,t),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`pointerover`,e),document.removeEventListener(`pointerleave`,a),document.removeEventListener(`focusin`,t),document.removeEventListener(`focusout`,r)}},[]);let s=(0,H.useCallback)(()=>{let t=e.current;if(t===null||a===void 0)return;if(!a.element.isConnected)return o();let n=a.element.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.width-k6,s=Math.min(Math.max(n.left,k6),Math.max(k6,i)),c=n.bottom+O6,l=n.top-r.height-O6,u=Math.max(k6,window.innerHeight-r.height-k6),d=c+r.height<=window.innerHeight-k6?c:l,f=Math.min(Math.max(d,k6),u);t.style.left=`${Math.round(s)}px`,t.style.top=`${Math.round(f)}px`,t.style.visibility=`visible`},[a,o]);return(0,H.useLayoutEffect)(s,[s]),(0,H.useEffect)(()=>{if(a!==void 0)return window.addEventListener(`scroll`,s,!0),window.addEventListener(`resize`,s),()=>{window.removeEventListener(`scroll`,s,!0),window.removeEventListener(`resize`,s)}},[a,s]),a===void 0?null:(0,jr.createPortal)((0,W.jsx)(`div`,{"aria-hidden":`true`,className:`timeline-popover`,"data-testid":`timeline-popover`,ref:e,style:{visibility:`hidden`},children:a.detail},a.detail),document.body)}var P6=[{setting:`live`,label:`Live`},{setting:10,label:`Every 10 seconds`},{setting:30,label:`Every 30 seconds`},{setting:60,label:`Every minute`},{setting:300,label:`Every 5 minutes`},{setting:`off`,label:`Off`}],F6=`live`,I6={navigation:`dag-ui.updates.navigation`,main:`dag-ui.updates.main`};function L6(e){return P6.find(({setting:t})=>String(t)===e)?.setting}function R6(e){try{return window.localStorage.getItem(e)}catch{return null}}function z6(e,t){try{window.localStorage.setItem(e,String(t))}catch{}}function B6(e,t){let[n,r]=(0,H.useState)(()=>L6(R6(e))??t);return[n,(0,H.useCallback)(t=>{r(t),z6(e,t)},[e])]}function V6(){let[e,t]=B6(I6.navigation,30),[n,r]=B6(I6.main,F6);return{navigation:e,setNavigation:t,main:n,setMain:r}}function H6({name:e,caption:t,setting:n,waiting:r,onChange:i}){return(0,W.jsxs)(`div`,{className:`update-setting`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:t}),(0,W.jsx)(`select`,{"aria-label":e,onChange:e=>{let t=L6(e.target.value);t!==void 0&&i(t)},value:String(n),children:P6.map(({setting:e,label:t})=>(0,W.jsx)(`option`,{value:String(e),children:t},e))})]}),r>0&&(0,W.jsxs)(`output`,{"aria-label":`${e} waiting`,className:`update-waiting`,children:[r,` waiting`]})]})}var U6=new ZN(window.location.origin,{fetch:window.fetch.bind(window)}),W6=Object.entries(G0);function G6(e){let t=(0,H.useRef)({value:e,count:0});return t.current.value!==e&&(t.current={value:e,count:t.current.count+1}),t.current.count}var K6=()=>Promise.resolve();function q6({client:e=U6}){let t=Z0(),n=B0(),r=t.host||n.active,i=o0(n.active),a=G0[t.detail].profile,o=V6(),s=l2(),c=d2(e,{runId:t.runId,view:t.view===`overall`?`overall`:t.view===`channel`?`channel`:t.nodeId===void 0?`graph`:`node`,nodeId:t.nodeId,filter:a,selectFirst:!r,host:r,humanItems:i.view,navigationUpdates:o.navigation,mainUpdates:o.main}),l=c.rows,u=c.runId,d=c.activity.at(-1),f=c.detail,p=(0,H.useMemo)(()=>f?vX(f):[],[f]),m=RI(e,u),h=P2(e),[g,_]=(0,H.useState)(0),v=h.host.state.phase===`sending`,y=G6(l),{list:b,error:x}=KX(e,t.host||v,g+(v?y:0)),S=f===void 0?void 0:gX(f),C=p.find(({id:e})=>e===t.nodeId);return(0,H.useEffect)(()=>{if(r||!l)return;let e=t2(l),n=e.find(e=>e.rows.some(e=>e.id===t.runId)),i=n?.rows.find(e=>e.id===t.runId),a=(n?.rows??e.flatMap(e=>e.rows)).filter(e=>!e.kind||!t.hiddenKinds.includes(e.kind));(!t.runId||i?.kind&&t.hiddenKinds.includes(i.kind))&&a[0]&&t.selectRun(a[0].id)},[l,t,r]),(0,H.useEffect)(()=>{if(u&&t.runId&&t.runId!==u){let e=new URLSearchParams(window.location.search);e.set(`run`,u),e.delete(`node`),e.delete(`event`),e.set(`view`,t.view),window.history.replaceState(null,``,`${window.location.pathname}?${e}`),window.dispatchEvent(new PopStateEvent(`popstate`))}},[t.runId,u,t.view]),(0,W.jsxs)(dm,{children:[(0,W.jsx)(N6,{}),(0,W.jsxs)(`div`,{className:`app-shell`,children:[(0,W.jsx)(c2,{rows:c.navigationRows,selectedRunId:u,onSelect:e=>{t.selectRun(e),s.close()},onOpenProject:t.selectRun,onHost:()=>{t.selectHost(),s.close()},hostCurrent:t.host&&!n.active,onActionItems:()=>{n.open(),s.close()},actionItemsCurrent:n.active,hiddenKinds:t.hiddenKinds,onKindsChange:t.selectKinds,drawerOpen:s.open,drawerRef:s.drawer,updates:(0,W.jsx)(H6,{caption:`Navigation`,name:`Navigation updates`,onChange:o.setNavigation,setting:o.navigation,waiting:c.navigationWaiting})}),s.open&&(0,W.jsx)(`button`,{"aria-label":`Close navigation`,className:`nav-scrim`,onClick:s.close,type:`button`}),(0,W.jsxs)(`main`,{className:`workspace`,inert:s.open,children:[(0,W.jsxs)(`section`,{"aria-label":u&&!r?`Run header`:`Workspace header`,className:`topbar${u&&!r?` run-topbar`:``}`,children:[(0,W.jsx)(`button`,{"aria-controls":`run-navigation`,"aria-expanded":s.open,"aria-label":`Open navigation`,className:`nav-menu`,onClick:s.toggle,ref:s.menuButton,type:`button`,children:(0,W.jsx)(Bt,{"aria-hidden":`true`,size:18})}),(0,W.jsx)(`div`,{className:`topbar-title`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Execution telemetry`}),(0,W.jsx)(`h2`,{children:n.active?`Action items`:t.host?`Host`:u??`No DAG selected`})]})}),(0,W.jsxs)(`div`,{className:`topbar-actions`,children:[!r&&u!==void 0&&(0,W.jsx)(PI,{control:m,runId:u,ended:f!==void 0&&(f.run.state===`settled`||f.run.state.startsWith(`ended-`))}),(0,W.jsxs)(`span`,{className:`connection`,children:[(0,W.jsx)($t,{size:15}),c.lastUpdated===void 0?`Waiting for first update`:(0,W.jsxs)(W.Fragment,{children:[`Last updated`,` `,(0,W.jsx)(aI,{at:c.lastUpdated,relative:!0})]})]}),!r&&d!==void 0&&(0,W.jsxs)(`button`,{className:`last-activity connection`,type:`button`,title:`${d.node}: ${J6(d)}`,onClick:()=>{t.selectNode(d.node),t.selectItem(d.event_id)},children:[d.node,`: `,J6(d)]})]}),(0,W.jsxs)(`div`,{className:`main-updates`,children:[(0,W.jsx)(H6,{caption:`Updates`,name:`Main area updates`,onChange:o.setMain,setting:o.main,waiting:c.mainWaiting}),(0,W.jsxs)(Pa,{onClick:()=>{_(e=>e+1),c.refresh()},size:`sm`,type:`button`,variant:`outline`,children:[(0,W.jsx)(Xt,{size:14}),` Refresh`]})]})]}),!r&&f&&(0,W.jsxs)(u6,{label:`Run details`,className:`run-header-details`,onOpen:m.reread,children:[(0,W.jsxs)(`p`,{children:[`Launching session: `,xX(f.launch)]}),m.status.error&&(0,W.jsxs)(`p`,{role:`alert`,children:[`Status unavailable: `,m.status.error.message]}),m.status.value&&(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Summary`}),(0,W.jsx)(`dd`,{children:m.status.value.summary}),(0,W.jsx)(`dt`,{children:`Graph state`}),(0,W.jsx)(`dd`,{children:yX(m.status.value.node_status)}),(0,W.jsx)(`dt`,{children:`Unread surfaces`}),(0,W.jsx)(`dd`,{children:m.status.value.unread_surfaces.count}),(0,W.jsx)(`dt`,{children:`Oldest unread (seconds)`}),(0,W.jsx)(`dd`,{children:m.status.value.unread_surfaces.oldest_seconds??`None`}),(0,W.jsx)(`dt`,{children:`Last progress`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`output`,{"aria-label":`Last progress`,children:f.run.last_progress_at===void 0?`Not recorded`:(0,W.jsx)(aI,{at:new Date(f.run.last_progress_at*1e3).toISOString(),relative:!0})})})]}),m.status.value&&(0,W.jsx)(`section`,{"aria-label":`Node statuses`,children:(0,W.jsx)(VX,{value:m.status.value.node_status})})]}),c.error&&(0,W.jsxs)(sa,{className:`rounded-none border-x-0 border-t-0`,variant:`destructive`,children:[(0,W.jsx)(an,{}),(0,W.jsx)(ca,{children:`Live telemetry issue`}),(0,W.jsx)(la,{children:c.error.message})]}),c.notice&&(0,W.jsx)(`p`,{className:`live-notice`,role:`status`,children:c.notice}),(0,W.jsx)(R2,{label:`Shutdown of the entire host`,onDismiss:h.host.dismiss,rows:b?.runs??[],state:h.host.state}),n.active?(0,W.jsx)(p0,{client:e,live:c.humanItems,choice:i.choice,setChoice:i.setChoice,selectedId:i.selectedId,setSelectedId:i.setSelectedId}):t.host?(0,W.jsx)(GX,{client:e,listError:x,onRefresh:()=>_(e=>e+1),list:b,rows:c.hostRows,children:(0,W.jsx)(F2,{list:b,loadMore:K6,loadingMore:!1,shutdowns:h})}):(0,W.jsxs)(bp,{className:`min-h-0 flex-1 gap-0`,onValueChange:e=>e===`overall`?t.showOverall():e===`graph`?t.selectNode(void 0):H0(e)?t.selectView(e):void 0,value:t.view,children:[(0,W.jsxs)(`div`,{className:`view-tabs`,children:[(0,W.jsxs)(Sp,{"aria-label":`DAG views`,variant:`line`,children:[(0,W.jsxs)(Cp,{value:`graph`,children:[(0,W.jsx)(ln,{size:15}),` Graph`]}),(0,W.jsxs)(Cp,{value:`overall`,children:[(0,W.jsx)(Qt,{size:15}),` Overall`]}),(0,W.jsxs)(Cp,{value:`channel`,children:[(0,W.jsx)(Ft,{size:15}),` Channel`]})]}),(0,W.jsxs)(`fieldset`,{className:`detail-switch`,children:[(0,W.jsx)(`legend`,{className:`sr-only`,children:`Level of detail`}),W6.map(([e,{label:n,description:r}])=>(0,W.jsx)(Pa,{"aria-pressed":t.detail===e,onClick:()=>t.selectDetail(e),size:`sm`,title:r,type:`button`,variant:t.detail===e?`default`:`outline`,children:n},e))]})]}),(0,W.jsx)(wp,{className:`min-h-0`,value:t.view,children:!f&&(c.loading||u!==void 0)?(0,W.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,W.jsx)(xf,{className:`h-2 w-48`}),(0,W.jsx)(xf,{className:`h-2 w-32`}),`Loading execution history…`]}):f&&u?t.view===`channel`?(0,W.jsx)(wI,{channel:c.channel,client:e,decisions:S?.decisions??[],filter:a,journalSeq:S?.last_seq,observedAt:f.observed_at,overrides:S&&_X(S),runId:u}):t.view===`overall`?(0,W.jsx)(w6,{client:e,detail:f,journalSeq:S?.last_seq,nodes:p,timeline:c.timeline,timelineError:c.timelineError,onSelectNode:t.selectNode,onSelectItem:t.selectItem,selectedItemId:t.itemId}):C?(0,W.jsx)(Z3,{client:e,node:C,nodes:p,onBack:()=>t.selectNode(void 0),onSelectItem:t.selectItem,runId:u,selectedItemId:t.itemId,selectedTab:t.nodeTab,onSelectTab:t.selectNodeTab,timeline:c.timeline,timelineError:c.timelineError}):(0,W.jsx)(BX,{journalSeq:S?.last_seq,nodes:p,selectedNodeId:t.nodeId,onSelectNode:t.selectNode}):(0,W.jsxs)(`div`,{className:`empty-state`,children:[(0,W.jsx)(ln,{size:34}),(0,W.jsx)(`h2`,{children:`No DAG runs found`}),(0,W.jsx)(`p`,{children:`Start an orchestrated run to see it appear here.`})]})})]})]})]})]})}function J6(e){return e.description||e.kind}var Y6=class extends H.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`DAG UI render failed`,e,t.componentStack)}render(){return this.state.error?(0,W.jsxs)(`main`,{className:`fatal-error`,role:`alert`,children:[(0,W.jsx)(`p`,{className:`eyebrow`,children:`Rendering error`}),(0,W.jsx)(`h1`,{children:`The DAG view could not be displayed.`}),(0,W.jsx)(`p`,{children:this.state.error.message}),(0,W.jsx)(Pa,{onClick:()=>(this.props.onReload??(()=>window.location.reload()))(),type:`button`,variant:`secondary`,children:`Reload`})]}):this.props.children}},X6=document.getElementById(`root`);if(!X6)throw Error(`DAG UI root element is missing`);(0,jA.createRoot)(X6).render((0,W.jsx)(H.StrictMode,{children:(0,W.jsx)(Y6,{children:(0,W.jsx)(q6,{})})}));
|